diff --git a/OpenRA.Mods.RA/Widgets/Logic/MissionBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MissionBrowserLogic.cs index 2d15e169c4..46edd5bb62 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/MissionBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/MissionBrowserLogic.cs @@ -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("MISSION_DESCRIPTION"); descriptionFont = Game.Renderer.Fonts[description.Font]; + difficultyButton = widget.Get("DIFFICULTY_DROPDOWNBUTTON"); + startVideoButton = widget.Get("START_VIDEO_BUTTON"); stopVideoButton = widget.Get("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 setupItem = (option, template) => + { + var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); + item.Get("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 IsSelected; + public Action OnClick; + } } } diff --git a/mods/cnc/chrome/missionbrowser.yaml b/mods/cnc/chrome/missionbrowser.yaml index c4e27df95b..992e2613d9 100644 --- a/mods/cnc/chrome/missionbrowser.yaml +++ b/mods/cnc/chrome/missionbrowser.yaml @@ -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: diff --git a/mods/ra/chrome/missionbrowser.yaml b/mods/ra/chrome/missionbrowser.yaml index 65bfb17581..1200ec72d3 100644 --- a/mods/ra/chrome/missionbrowser.yaml +++ b/mods/ra/chrome/missionbrowser.yaml @@ -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 diff --git a/mods/ra/maps/intervention/intervention.lua b/mods/ra/maps/intervention/intervention.lua index 1c7d862900..29740d1cfd 100644 --- a/mods/ra/maps/intervention/intervention.lua +++ b/mods/ra/maps/intervention/intervention.lua @@ -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) diff --git a/mods/ra/maps/survival01/survival01.lua b/mods/ra/maps/survival01/survival01.lua index 07baa6c804..56d65c01e2 100644 --- a/mods/ra/maps/survival01/survival01.lua +++ b/mods/ra/maps/survival01/survival01.lua @@ -1,4 +1,4 @@ -Difficulty = "Medium" +Difficulty = Map.Difficulty if Difficulty == "Easy" then AttackAtFrameIncrement = DateTime.Seconds(22)