Ingame mod selector ui.
This commit is contained in:
@@ -12,7 +12,7 @@ namespace OpenRA.FileFormats
|
|||||||
public string Description;
|
public string Description;
|
||||||
public string Version;
|
public string Version;
|
||||||
public string Author;
|
public string Author;
|
||||||
public string[] RequiresMods;
|
public string Requires;
|
||||||
public bool Standalone = false;
|
public bool Standalone = false;
|
||||||
|
|
||||||
public static readonly Dictionary<string, Mod> AllMods = ValidateMods(Directory.GetDirectories("mods").Select(x => x.Substring(5)).ToArray());
|
public static readonly Dictionary<string, Mod> 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"));
|
var yaml = new MiniYaml(null, MiniYaml.FromFile("mods" + Path.DirectorySeparatorChar + m + Path.DirectorySeparatorChar + "mod.yaml"));
|
||||||
if (!yaml.NodesDict.ContainsKey("Metadata"))
|
if (!yaml.NodesDict.ContainsKey("Metadata"))
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
ret.Add(m, FieldLoader.Load<Mod>(yaml.NodesDict["Metadata"]));
|
ret.Add(m, FieldLoader.Load<Mod>(yaml.NodesDict["Metadata"]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ using OpenRA.FileFormats;
|
|||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Server;
|
using OpenRA.Server;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets.Delegates
|
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_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_REPLAY_VIEWER").OnMouseUp = mi => { Widget.OpenWindow("REPLAYBROWSER_BG"); return true; };
|
||||||
widget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => { Game.Exit(); return true; };
|
widget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => { Game.Exit(); return true; };
|
||||||
|
|
||||||
|
var selector = widget.GetWidget<ButtonWidget>("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<Pair<string, Action>>();
|
||||||
|
|
||||||
|
foreach (var kv in Mod.AllMods)
|
||||||
|
{
|
||||||
|
var modList = new List<string>() { 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<string, Action>( 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,28 @@ Background@MAINMENU_BG:
|
|||||||
Height:25
|
Height:25
|
||||||
Text:Video Player
|
Text:Video Player
|
||||||
Bold:True
|
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:
|
Background@PERF_BG:
|
||||||
Id:PERF_BG
|
Id:PERF_BG
|
||||||
Background:dialog4
|
Background:dialog4
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Metadata:
|
|||||||
Description: Adds a soviet troop transport
|
Description: Adds a soviet troop transport
|
||||||
Version: a0001
|
Version: a0001
|
||||||
Author: The OpenRA Developers
|
Author: The OpenRA Developers
|
||||||
RequiresMods: ra
|
Requires: ra
|
||||||
|
|
||||||
Folders:
|
Folders:
|
||||||
mods/example
|
mods/example
|
||||||
|
|||||||
@@ -69,10 +69,32 @@ Background@MAINMENU_BG:
|
|||||||
Visible:false
|
Visible:false
|
||||||
X:45
|
X:45
|
||||||
Y:260
|
Y:260
|
||||||
Width:160
|
Width:200
|
||||||
Height:25
|
Height:25
|
||||||
Text:Video Player
|
Text:Video Player
|
||||||
Bold:True
|
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:
|
Background@PERF_BG:
|
||||||
ClickThrough:true
|
ClickThrough:true
|
||||||
Id:PERF_BG
|
Id:PERF_BG
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Metadata:
|
|||||||
Description: Performance Test map pack
|
Description: Performance Test map pack
|
||||||
Version: a0001
|
Version: a0001
|
||||||
Author: The OpenRA Developers
|
Author: The OpenRA Developers
|
||||||
RequiresMods: ra
|
Requires: ra
|
||||||
|
|
||||||
Folders:
|
Folders:
|
||||||
./mods/ra_perf
|
./mods/ra_perf
|
||||||
|
|||||||
Reference in New Issue
Block a user