Display the selector in all menus. Fix information leakage from previous mod.
This commit is contained in:
@@ -102,7 +102,6 @@ namespace OpenRA
|
|||||||
|
|
||||||
static object syncroot = new object();
|
static object syncroot = new object();
|
||||||
static Action tickActions = () => {};
|
static Action tickActions = () => {};
|
||||||
|
|
||||||
public static void RunAfterTick(Action a) { lock(syncroot) tickActions += a; }
|
public static void RunAfterTick(Action a) { lock(syncroot) tickActions += a; }
|
||||||
static void Tick( OrderManager orderManager, Viewport viewPort )
|
static void Tick( OrderManager orderManager, Viewport viewPort )
|
||||||
{
|
{
|
||||||
@@ -251,10 +250,20 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void InitializeWithMods(string[] mods)
|
public static void InitializeWithMods(string[] mods)
|
||||||
{
|
{
|
||||||
|
// Clear static state if we have switched mods
|
||||||
|
LobbyInfoChanged = () => {};
|
||||||
|
AddChatLine = (a,b,c) => {};
|
||||||
|
worldRenderer = null;
|
||||||
|
if (server != null)
|
||||||
|
server.Shutdown();
|
||||||
|
if (orderManager != null)
|
||||||
|
orderManager.Dispose();
|
||||||
|
|
||||||
// Discard any invalid mods
|
// Discard any invalid mods
|
||||||
var mm = mods.Where( m => Mod.AllMods.ContainsKey( m ) ).ToArray();
|
var mm = mods.Where( m => Mod.AllMods.ContainsKey( m ) ).ToArray();
|
||||||
Console.WriteLine("Loading mods: {0}",string.Join(",",mm));
|
Console.WriteLine("Loading mods: {0}",string.Join(",",mm));
|
||||||
|
|
||||||
|
|
||||||
modData = new ModData( mm );
|
modData = new ModData( mm );
|
||||||
modData.LoadInitialAssets();
|
modData.LoadInitialAssets();
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
@@ -30,6 +31,9 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void WorldLoaded(World world)
|
public void WorldLoaded(World world)
|
||||||
{
|
{
|
||||||
|
// Remove all open widgets
|
||||||
|
Widget.RootWidget.Children.Clear();
|
||||||
|
|
||||||
if (world.LocalPlayer != null)
|
if (world.LocalPlayer != null)
|
||||||
Game.OpenWindow(world, Info.Widget);
|
Game.OpenWindow(world, Info.Widget);
|
||||||
else if (Info.ObserverWidget != null)
|
else if (Info.ObserverWidget != null)
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
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");
|
var switcher = Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "QUICKMODSWITCHER" );
|
||||||
|
var selector = switcher.GetWidget<ButtonWidget>("SWITCHER");
|
||||||
selector.OnMouseDown = _ => ShowModsDropDown(selector);
|
selector.OnMouseDown = _ => ShowModsDropDown(selector);
|
||||||
selector.GetText = ActiveModTitle;
|
selector.GetText = ActiveModTitle;
|
||||||
}
|
}
|
||||||
@@ -57,7 +58,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
}
|
}
|
||||||
|
|
||||||
dropDownOptions.Add(new Pair<string, Action>( kv.Value.Title,
|
dropDownOptions.Add(new Pair<string, Action>( kv.Value.Title,
|
||||||
() => Game.InitializeWithMods( modList.ToArray() ) ));
|
() => Game.RunAfterTick(() => Game.InitializeWithMods( modList.ToArray() ) )));
|
||||||
}
|
}
|
||||||
|
|
||||||
DropDownButtonWidget.ShowDropDown( selector,
|
DropDownButtonWidget.ShowDropDown( selector,
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ Background@MAINMENU_BG:
|
|||||||
Height:25
|
Height:25
|
||||||
Text:Video Player
|
Text:Video Player
|
||||||
Bold:True
|
Bold:True
|
||||||
Background@QUICKMODSWITCHER_BG:
|
Background@QUICKMODSWITCHER:
|
||||||
|
Id:QUICKMODSWITCHER
|
||||||
Background: dialog4
|
Background: dialog4
|
||||||
X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10)
|
X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10)
|
||||||
Y:10 - PARENT_TOP
|
Y:10 - PARENT_TOP
|
||||||
@@ -87,8 +88,8 @@ Background@MAINMENU_BG:
|
|||||||
Text:Mod:
|
Text:Mod:
|
||||||
Align:Left
|
Align:Left
|
||||||
Bold:True
|
Bold:True
|
||||||
DropDownButton@QUICKMODSWITCHER:
|
DropDownButton@SWITCHER:
|
||||||
Id:QUICKMODSWITCHER
|
Id:SWITCHER
|
||||||
Text:Team
|
Text:Team
|
||||||
Width:150
|
Width:150
|
||||||
Height:25
|
Height:25
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ Background@MAINMENU_BG:
|
|||||||
Height:25
|
Height:25
|
||||||
Text:Video Player
|
Text:Video Player
|
||||||
Bold:True
|
Bold:True
|
||||||
Background@QUICKMODSWITCHER_BG:
|
Background@QUICKMODSWITCHER:
|
||||||
|
Id:QUICKMODSWITCHER
|
||||||
Background: dialog4
|
Background: dialog4
|
||||||
X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10)
|
X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10)
|
||||||
Y:10 - PARENT_TOP
|
Y:10 - PARENT_TOP
|
||||||
@@ -88,8 +89,8 @@ Background@MAINMENU_BG:
|
|||||||
Text:Mod:
|
Text:Mod:
|
||||||
Align:Left
|
Align:Left
|
||||||
Bold:True
|
Bold:True
|
||||||
DropDownButton@QUICKMODSWITCHER:
|
DropDownButton@SWITCHER:
|
||||||
Id:QUICKMODSWITCHER
|
Id:SWITCHER
|
||||||
Text:Team
|
Text:Team
|
||||||
Width:150
|
Width:150
|
||||||
Height:25
|
Height:25
|
||||||
|
|||||||
Reference in New Issue
Block a user