Added support for selecting mission difficulty
This commit is contained in:
@@ -27,6 +27,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
readonly ScrollPanelWidget descriptionPanel;
|
||||
readonly LabelWidget description;
|
||||
readonly SpriteFont descriptionFont;
|
||||
readonly DropDownButtonWidget difficultyButton;
|
||||
readonly ButtonWidget startVideoButton;
|
||||
readonly ButtonWidget stopVideoButton;
|
||||
readonly VqaPlayerWidget videoPlayer;
|
||||
@@ -39,6 +40,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
|
||||
bool showVideoPlayer;
|
||||
|
||||
string difficulty;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public MissionBrowserLogic(Widget widget, Action onStart, Action onExit)
|
||||
{
|
||||
@@ -67,6 +70,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
description = descriptionPanel.Get<LabelWidget>("MISSION_DESCRIPTION");
|
||||
descriptionFont = Game.Renderer.Fonts[description.Font];
|
||||
|
||||
difficultyButton = widget.Get<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
|
||||
|
||||
startVideoButton = widget.Get<ButtonWidget>("START_VIDEO_BUTTON");
|
||||
stopVideoButton = widget.Get<ButtonWidget>("STOP_VIDEO_BUTTON");
|
||||
stopVideoButton.IsVisible = () => showVideoPlayer;
|
||||
@@ -176,6 +181,28 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
description.Bounds.Height = descriptionFont.Measure(text).Y;
|
||||
descriptionPanel.ScrollToTop();
|
||||
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()
|
||||
@@ -202,6 +229,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
Action lobbyReady = null;
|
||||
lobbyReady = () =>
|
||||
{
|
||||
om.IssueOrder(Order.Command("difficulty {0}".F(difficulty)));
|
||||
Game.LobbyInfoChanged -= lobbyReady;
|
||||
onStart();
|
||||
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);
|
||||
}
|
||||
|
||||
class DropDownOption
|
||||
{
|
||||
public string Title;
|
||||
public Func<bool> IsSelected;
|
||||
public Action OnClick;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,13 @@ Container@MISSIONBROWSER_PANEL:
|
||||
Height: 35
|
||||
Text: Play
|
||||
Font: Bold
|
||||
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
|
||||
X: PARENT_RIGHT - 290 - 150
|
||||
Y: 376
|
||||
Width: 140
|
||||
Height: 35
|
||||
Text: Difficulty
|
||||
Font: Bold
|
||||
Container@MISSION_BIN:
|
||||
Children:
|
||||
VqaPlayer@MISSION_VIDEO:
|
||||
|
||||
@@ -98,6 +98,13 @@ Background@MISSIONBROWSER_PANEL:
|
||||
Text: Back
|
||||
Font: Bold
|
||||
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:
|
||||
X: 20
|
||||
Y: 50
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
BaseRaidInterval = DateTime.Minutes(3)
|
||||
BaseFrontAttackInterval = DateTime.Minutes(3) + DateTime.Seconds(30)
|
||||
BaseRearAttackInterval = DateTime.Minutes(8)
|
||||
UBoatPatrolDelay = DateTime.Minutes(2) + DateTime.Seconds(30)
|
||||
BaseFrontAttackWpts = { PatrolWpt1.Location, BaseRaidWpt1.Location }
|
||||
Difficulty = Map.Difficulty
|
||||
|
||||
if Difficulty == "Medium" then
|
||||
BaseRaidInterval = DateTime.Minutes(3)
|
||||
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 }
|
||||
VillageRaidInterval = DateTime.Minutes(3)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Difficulty = "Medium"
|
||||
Difficulty = Map.Difficulty
|
||||
|
||||
if Difficulty == "Easy" then
|
||||
AttackAtFrameIncrement = DateTime.Seconds(22)
|
||||
|
||||
Reference in New Issue
Block a user