Added support for selecting mission difficulty

This commit is contained in:
abcdefg30
2014-11-18 21:47:09 +01:00
parent c5978d0dbe
commit 19713a19f6
5 changed files with 65 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
readonly ScrollPanelWidget descriptionPanel; readonly ScrollPanelWidget descriptionPanel;
readonly LabelWidget description; readonly LabelWidget description;
readonly SpriteFont descriptionFont; readonly SpriteFont descriptionFont;
readonly DropDownButtonWidget difficultyButton;
readonly ButtonWidget startVideoButton; readonly ButtonWidget startVideoButton;
readonly ButtonWidget stopVideoButton; readonly ButtonWidget stopVideoButton;
readonly VqaPlayerWidget videoPlayer; readonly VqaPlayerWidget videoPlayer;
@@ -39,6 +40,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
bool showVideoPlayer; bool showVideoPlayer;
string difficulty;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public MissionBrowserLogic(Widget widget, Action onStart, Action onExit) public MissionBrowserLogic(Widget widget, Action onStart, Action onExit)
{ {
@@ -67,6 +70,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
description = descriptionPanel.Get<LabelWidget>("MISSION_DESCRIPTION"); description = descriptionPanel.Get<LabelWidget>("MISSION_DESCRIPTION");
descriptionFont = Game.Renderer.Fonts[description.Font]; descriptionFont = Game.Renderer.Fonts[description.Font];
difficultyButton = widget.Get<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
startVideoButton = widget.Get<ButtonWidget>("START_VIDEO_BUTTON"); startVideoButton = widget.Get<ButtonWidget>("START_VIDEO_BUTTON");
stopVideoButton = widget.Get<ButtonWidget>("STOP_VIDEO_BUTTON"); stopVideoButton = widget.Get<ButtonWidget>("STOP_VIDEO_BUTTON");
stopVideoButton.IsVisible = () => showVideoPlayer; stopVideoButton.IsVisible = () => showVideoPlayer;
@@ -176,6 +181,28 @@ namespace OpenRA.Mods.RA.Widgets.Logic
description.Bounds.Height = descriptionFont.Measure(text).Y; description.Bounds.Height = descriptionFont.Measure(text).Y;
descriptionPanel.ScrollToTop(); descriptionPanel.ScrollToTop();
descriptionPanel.Layout.AdjustChildren(); descriptionPanel.Layout.AdjustChildren();
difficultyButton.IsVisible = () => map.Options.Difficulties.Any();
if (!map.Options.Difficulties.Any())
return;
difficulty = map.Options.Difficulties.First();
difficultyButton.OnMouseDown = _ =>
{
var options = map.Options.Difficulties.Select(d => new DropDownOption
{
Title = d,
IsSelected = () => difficulty == d,
OnClick = () => difficulty = d
});
Func<DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
{
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
return item;
};
difficultyButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem);
};
} }
void StopVideo() void StopVideo()
@@ -202,6 +229,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Action lobbyReady = null; Action lobbyReady = null;
lobbyReady = () => lobbyReady = () =>
{ {
om.IssueOrder(Order.Command("difficulty {0}".F(difficulty)));
Game.LobbyInfoChanged -= lobbyReady; Game.LobbyInfoChanged -= lobbyReady;
onStart(); onStart();
om.IssueOrder(Order.Command("state {0}".F(Session.ClientState.Ready))); om.IssueOrder(Order.Command("state {0}".F(Session.ClientState.Ready)));
@@ -210,5 +238,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
om = Game.JoinServer(IPAddress.Loopback.ToString(), Game.CreateLocalServer(selectedMapPreview.Uid), "", false); om = Game.JoinServer(IPAddress.Loopback.ToString(), Game.CreateLocalServer(selectedMapPreview.Uid), "", false);
} }
class DropDownOption
{
public string Title;
public Func<bool> IsSelected;
public Action OnClick;
}
} }
} }

View File

@@ -102,6 +102,13 @@ Container@MISSIONBROWSER_PANEL:
Height: 35 Height: 35
Text: Play Text: Play
Font: Bold Font: Bold
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
X: PARENT_RIGHT - 290 - 150
Y: 376
Width: 140
Height: 35
Text: Difficulty
Font: Bold
Container@MISSION_BIN: Container@MISSION_BIN:
Children: Children:
VqaPlayer@MISSION_VIDEO: VqaPlayer@MISSION_VIDEO:

View File

@@ -98,6 +98,13 @@ Background@MISSIONBROWSER_PANEL:
Text: Back Text: Back
Font: Bold Font: Bold
Key: escape Key: escape
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
X: PARENT_RIGHT - 140 - 130 - 150
Y: PARENT_BOTTOM - 45
Width: 140
Height: 25
Text: Difficulty
Font: Bold
Background@MISSION_BIN: Background@MISSION_BIN:
X: 20 X: 20
Y: 50 Y: 50

View File

@@ -9,11 +9,21 @@ BeachheadTrigger =
CPos.New(137, 104), CPos.New(137, 105), CPos.New(137, 106), CPos.New(136, 106), CPos.New(136, 107) CPos.New(137, 104), CPos.New(137, 105), CPos.New(137, 106), CPos.New(136, 106), CPos.New(136, 107)
} }
BaseRaidInterval = DateTime.Minutes(3) Difficulty = Map.Difficulty
BaseFrontAttackInterval = DateTime.Minutes(3) + DateTime.Seconds(30)
BaseRearAttackInterval = DateTime.Minutes(8) if Difficulty == "Medium" then
UBoatPatrolDelay = DateTime.Minutes(2) + DateTime.Seconds(30) BaseRaidInterval = DateTime.Minutes(3)
BaseFrontAttackWpts = { PatrolWpt1.Location, BaseRaidWpt1.Location } BaseFrontAttackInterval = DateTime.Minutes(3) + DateTime.Seconds(30)
BaseRearAttackInterval = DateTime.Minutes(8)
UBoatPatrolDelay = DateTime.Minutes(2) + DateTime.Seconds(30)
BaseFrontAttackWpts = { PatrolWpt1.Location, BaseRaidWpt1.Location }
else
BaseRaidInterval = DateTime.Minutes(2)
BaseFrontAttackInterval = DateTime.Minutes(2) + DateTime.Seconds(30)
BaseRearAttackInterval = DateTime.Minutes(5)
UBoatPatrolDelay = DateTime.Minutes(2)
BaseFrontAttackWpts = { PatrolWpt1.Location }
end
Village = { FarmHouse1, FarmHouse2, FarmHouse3, FarmHouse4, FarmHouse5, FarmHouse6, FarmHouse7, FarmHouse8, FarmHouse9, Church } Village = { FarmHouse1, FarmHouse2, FarmHouse3, FarmHouse4, FarmHouse5, FarmHouse6, FarmHouse7, FarmHouse8, FarmHouse9, Church }
VillageRaidInterval = DateTime.Minutes(3) VillageRaidInterval = DateTime.Minutes(3)

View File

@@ -1,4 +1,4 @@
Difficulty = "Medium" Difficulty = Map.Difficulty
if Difficulty == "Easy" then if Difficulty == "Easy" then
AttackAtFrameIncrement = DateTime.Seconds(22) AttackAtFrameIncrement = DateTime.Seconds(22)