Show the mod switcher during the initial install screen.
This commit is contained in:
@@ -19,6 +19,7 @@ using System.Net;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
{
|
||||
@@ -64,6 +65,53 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
{
|
||||
ShowInstallMethodDialog();
|
||||
}
|
||||
|
||||
var selector = Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "QUICKMODSWITCHER" );
|
||||
var switcher = selector.GetWidget<ButtonWidget>("SWITCHER");
|
||||
switcher.OnMouseDown = _ => ShowModsDropDown(switcher);
|
||||
switcher.GetText = ActiveModTitle;
|
||||
selector.GetWidget<LabelWidget>("VERSION").GetText = ActiveModVersion;
|
||||
}
|
||||
|
||||
string ActiveModTitle()
|
||||
{
|
||||
var mod = Game.modData.Manifest.Mods[0];
|
||||
return Mod.AllMods[mod].Title;
|
||||
}
|
||||
|
||||
string ActiveModVersion()
|
||||
{
|
||||
var mod = Game.modData.Manifest.Mods[0];
|
||||
return Mod.AllMods[mod].Version;
|
||||
}
|
||||
|
||||
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.RunAfterTick(() => 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;
|
||||
}
|
||||
|
||||
void ShowInstallMethodDialog()
|
||||
|
||||
@@ -13,8 +13,6 @@ using OpenRA.FileFormats;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Server;
|
||||
using OpenRA.Widgets;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
{
|
||||
@@ -30,53 +28,6 @@ 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 = Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "QUICKMODSWITCHER" );
|
||||
var switcher = selector.GetWidget<ButtonWidget>("SWITCHER");
|
||||
switcher.OnMouseDown = _ => ShowModsDropDown(switcher);
|
||||
switcher.GetText = ActiveModTitle;
|
||||
selector.GetWidget<LabelWidget>("VERSION").GetText = ActiveModVersion;
|
||||
}
|
||||
|
||||
string ActiveModTitle()
|
||||
{
|
||||
var mod = Game.modData.Manifest.Mods[0];
|
||||
return Mod.AllMods[mod].Title;
|
||||
}
|
||||
|
||||
string ActiveModVersion()
|
||||
{
|
||||
var mod = Game.modData.Manifest.Mods[0];
|
||||
return Mod.AllMods[mod].Version;
|
||||
}
|
||||
|
||||
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.RunAfterTick(() => 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user