Show mod version in the main menu.

This commit is contained in:
Paul Chote
2011-01-22 09:56:55 +13:00
parent d39adf67b2
commit 388e5df377
3 changed files with 30 additions and 7 deletions

View File

@@ -31,10 +31,11 @@ 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 switcher = Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "QUICKMODSWITCHER" ); var selector = Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "QUICKMODSWITCHER" );
var selector = switcher.GetWidget<ButtonWidget>("SWITCHER"); var switcher = selector.GetWidget<ButtonWidget>("SWITCHER");
selector.OnMouseDown = _ => ShowModsDropDown(selector); switcher.OnMouseDown = _ => ShowModsDropDown(switcher);
selector.GetText = ActiveModTitle; switcher.GetText = ActiveModTitle;
selector.GetWidget<LabelWidget>("VERSION").GetText = ActiveModVersion;
} }
string ActiveModTitle() string ActiveModTitle()
@@ -43,6 +44,12 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
return Mod.AllMods[mod].Title; return Mod.AllMods[mod].Title;
} }
string ActiveModVersion()
{
var mod = Game.modData.Manifest.Mods[0];
return Mod.AllMods[mod].Version;
}
bool ShowModsDropDown(ButtonWidget selector) bool ShowModsDropDown(ButtonWidget selector)
{ {
var dropDownOptions = new List<Pair<string, Action>>(); var dropDownOptions = new List<Pair<string, Action>>();

View File

@@ -78,7 +78,7 @@ Background@QUICKMODSWITCHER:
X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10) X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10)
Y:10 - PARENT_TOP Y:10 - PARENT_TOP
Width:205 Width:205
Height:35 Height:65
Children: Children:
Label@TITLE: Label@TITLE:
X:8 X:8
@@ -95,6 +95,14 @@ Background@QUICKMODSWITCHER:
Height:25 Height:25
X:50 X:50
Y:5 Y:5
Label@VERSION:
Id:VERSION
X:50
Y:30
Width:150
Height:25
Align:Center
Bold:True
Background@PERF_BG: Background@PERF_BG:
Id:PERF_BG Id:PERF_BG
Background:dialog4 Background:dialog4

View File

@@ -79,7 +79,7 @@ Background@QUICKMODSWITCHER:
X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10) X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10)
Y:10 - PARENT_TOP Y:10 - PARENT_TOP
Width:205 Width:205
Height:35 Height:65
Children: Children:
Label@TITLE: Label@TITLE:
X:8 X:8
@@ -96,6 +96,14 @@ Background@QUICKMODSWITCHER:
Height:25 Height:25
X:50 X:50
Y:5 Y:5
Label@VERSION:
Id:VERSION
X:50
Y:30
Width:150
Height:25
Align:Center
Bold:True
Background@PERF_BG: Background@PERF_BG:
ClickThrough:true ClickThrough:true
Id:PERF_BG Id:PERF_BG