diff --git a/OpenRA.FileFormats/Mod.cs b/OpenRA.FileFormats/Mod.cs index 6af74177bf..9c75a7c0a2 100644 --- a/OpenRA.FileFormats/Mod.cs +++ b/OpenRA.FileFormats/Mod.cs @@ -12,7 +12,7 @@ namespace OpenRA.FileFormats public string Description; public string Version; public string Author; - public string[] RequiresMods; + public string Requires; public bool Standalone = false; public static readonly Dictionary AllMods = ValidateMods(Directory.GetDirectories("mods").Select(x => x.Substring(5)).ToArray()); @@ -27,9 +27,7 @@ namespace OpenRA.FileFormats var yaml = new MiniYaml(null, MiniYaml.FromFile("mods" + Path.DirectorySeparatorChar + m + Path.DirectorySeparatorChar + "mod.yaml")); if (!yaml.NodesDict.ContainsKey("Metadata")) - { continue; - } ret.Add(m, FieldLoader.Load(yaml.NodesDict["Metadata"])); } diff --git a/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs index c65ea9768d..1d30e4ca25 100755 --- a/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs @@ -13,6 +13,8 @@ using OpenRA.FileFormats; using OpenRA.Network; using OpenRA.Server; using OpenRA.Widgets; +using System; +using System.Drawing; namespace OpenRA.Mods.RA.Widgets.Delegates { @@ -28,6 +30,45 @@ namespace OpenRA.Mods.RA.Widgets.Delegates widget.GetWidget("MAINMENU_BUTTON_MUSIC").OnMouseUp = mi => { Widget.OpenWindow("MUSIC_MENU"); return true; }; widget.GetWidget("MAINMENU_BUTTON_REPLAY_VIEWER").OnMouseUp = mi => { Widget.OpenWindow("REPLAYBROWSER_BG"); return true; }; widget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => { Game.Exit(); return true; }; + + var selector = widget.GetWidget("QUICKMODSWITCHER"); + selector.OnMouseDown = _ => ShowModsDropDown(selector); + selector.GetText = ActiveModTitle; + } + + string ActiveModTitle() + { + var mod = Game.modData.Manifest.Mods[0]; + return Mod.AllMods[mod].Title; + } + + bool ShowModsDropDown(ButtonWidget selector) + { + var dropDownOptions = new List>(); + + foreach (var kv in Mod.AllMods) + { + var modList = new List() { kv.Key }; + var m = kv.Key; + while (!string.IsNullOrEmpty(Mod.AllMods[m].Requires)) + { + m = Mod.AllMods[m].Requires; + modList.Add(m); + } + + dropDownOptions.Add(new Pair( kv.Value.Title, + () => Game.InitializeWithMods( modList.ToArray() ) )); + } + + DropDownButtonWidget.ShowDropDown( selector, + dropDownOptions, + (ac, w) => new LabelWidget + { + Bounds = new Rectangle(0, 0, w, 24), + Text = " {0}".F(ac.First), + OnMouseUp = mi => { ac.Second(); return true; }, + }); + return true; } } } diff --git a/mods/cnc/chrome/mainmenu.yaml b/mods/cnc/chrome/mainmenu.yaml index 7e78b686fb..3e4a598064 100644 --- a/mods/cnc/chrome/mainmenu.yaml +++ b/mods/cnc/chrome/mainmenu.yaml @@ -72,6 +72,28 @@ Background@MAINMENU_BG: Height:25 Text:Video Player Bold:True + Background@QUICKMODSWITCHER_BG: + Background: dialog4 + X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10) + Y:10 - PARENT_TOP + Width:205 + Height:35 + Children: + Label@TITLE: + X:8 + Y:3 + Width:PARENT_RIGHT + Height:25 + Text:Mod: + Align:Left + Bold:True + DropDownButton@QUICKMODSWITCHER: + Id:QUICKMODSWITCHER + Text:Team + Width:150 + Height:25 + X:50 + Y:5 Background@PERF_BG: Id:PERF_BG Background:dialog4 diff --git a/mods/example/mod.yaml b/mods/example/mod.yaml index 8ab64b1673..efee2d4c9c 100644 --- a/mods/example/mod.yaml +++ b/mods/example/mod.yaml @@ -3,7 +3,7 @@ Metadata: Description: Adds a soviet troop transport Version: a0001 Author: The OpenRA Developers - RequiresMods: ra + Requires: ra Folders: mods/example diff --git a/mods/ra/chrome/mainmenu.yaml b/mods/ra/chrome/mainmenu.yaml index 737f3fb7d4..5ad31f4a17 100644 --- a/mods/ra/chrome/mainmenu.yaml +++ b/mods/ra/chrome/mainmenu.yaml @@ -69,10 +69,32 @@ Background@MAINMENU_BG: Visible:false X:45 Y:260 - Width:160 + Width:200 Height:25 Text:Video Player Bold:True + Background@QUICKMODSWITCHER_BG: + Background: dialog4 + X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10) + Y:10 - PARENT_TOP + Width:205 + Height:35 + Children: + Label@TITLE: + X:8 + Y:3 + Width:PARENT_RIGHT + Height:25 + Text:Mod: + Align:Left + Bold:True + DropDownButton@QUICKMODSWITCHER: + Id:QUICKMODSWITCHER + Text:Team + Width:150 + Height:25 + X:50 + Y:5 Background@PERF_BG: ClickThrough:true Id:PERF_BG diff --git a/mods/ra_perf/mod.yaml b/mods/ra_perf/mod.yaml index d81cb57c23..4b49031e6a 100644 --- a/mods/ra_perf/mod.yaml +++ b/mods/ra_perf/mod.yaml @@ -3,7 +3,7 @@ Metadata: Description: Performance Test map pack Version: a0001 Author: The OpenRA Developers - RequiresMods: ra + Requires: ra Folders: ./mods/ra_perf