move ActiveModVersion,ActiveModTitle out of cnc-specific code
This commit is contained in:
@@ -12,6 +12,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
@@ -208,6 +209,18 @@ namespace OpenRA.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Action Once( Action a ) { return () => { if (a != null) { a(); a = null; } }; }
|
public static Action Once( Action a ) { return () => { if (a != null) { a(); a = null; } }; }
|
||||||
|
|
||||||
|
public static string ActiveModVersion()
|
||||||
|
{
|
||||||
|
var mod = Game.modData.Manifest.Mods[0];
|
||||||
|
return Mod.AllMods[mod].Version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ActiveModTitle()
|
||||||
|
{
|
||||||
|
var mod = Game.modData.Manifest.Mods[0];
|
||||||
|
return Mod.AllMods[mod].Title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
|
|||||||
@@ -33,16 +33,17 @@ namespace OpenRA.Mods.Cnc
|
|||||||
public void Init(Dictionary<string, string> info)
|
public void Init(Dictionary<string, string> info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
|
|
||||||
// Avoid standard loading mechanisms so we
|
// Avoid standard loading mechanisms so we
|
||||||
// can display loadscreen as early as possible
|
// can display loadscreen as early as possible
|
||||||
r = Game.Renderer;
|
r = Game.Renderer;
|
||||||
if (r == null) return;
|
if (r == null) return;
|
||||||
|
|
||||||
|
|
||||||
var s = new Sheet("mods/cnc/uibits/chrome.png");
|
var s = new Sheet("mods/cnc/uibits/chrome.png");
|
||||||
var res = Renderer.Resolution;
|
var res = Renderer.Resolution;
|
||||||
Bounds = new Rectangle(0, 0, res.Width, res.Height);
|
Bounds = new Rectangle(0, 0, res.Width, res.Height);
|
||||||
ss = new Sprite[]
|
|
||||||
|
ss = new []
|
||||||
{
|
{
|
||||||
new Sprite(s, new Rectangle(161,128,62,33), TextureChannel.Alpha),
|
new Sprite(s, new Rectangle(161,128,62,33), TextureChannel.Alpha),
|
||||||
new Sprite(s, new Rectangle(161,223,62,33), TextureChannel.Alpha),
|
new Sprite(s, new Rectangle(161,223,62,33), TextureChannel.Alpha),
|
||||||
@@ -53,6 +54,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
new Sprite(s, new Rectangle(128,223,33,33), TextureChannel.Alpha),
|
new Sprite(s, new Rectangle(128,223,33,33), TextureChannel.Alpha),
|
||||||
new Sprite(s, new Rectangle(223,223,33,33), TextureChannel.Alpha)
|
new Sprite(s, new Rectangle(223,223,33,33), TextureChannel.Alpha)
|
||||||
};
|
};
|
||||||
|
|
||||||
nodLogo = new Sprite(s, new Rectangle(0, 256, 256, 256), TextureChannel.Alpha);
|
nodLogo = new Sprite(s, new Rectangle(0, 256, 256, 256), TextureChannel.Alpha);
|
||||||
gdiLogo = new Sprite(s, new Rectangle(256, 256, 256, 256), TextureChannel.Alpha);
|
gdiLogo = new Sprite(s, new Rectangle(256, 256, 256, 256), TextureChannel.Alpha);
|
||||||
evaLogo = new Sprite(s, new Rectangle(256, 64, 128, 64), TextureChannel.Alpha);
|
evaLogo = new Sprite(s, new Rectangle(256, 64, 128, 64), TextureChannel.Alpha);
|
||||||
@@ -73,6 +75,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
{
|
{
|
||||||
if (r == null || loadTimer.ElapsedTime() < 0.25)
|
if (r == null || loadTimer.ElapsedTime() < 0.25)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
loadTimer.Reset();
|
loadTimer.Reset();
|
||||||
|
|
||||||
loadTick = ++loadTick % 8;
|
loadTick = ++loadTick % 8;
|
||||||
@@ -91,7 +94,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
loadingPos = new float2((Bounds.Width - loadingFont.Measure(loadingText).X) / 2, barY);
|
loadingPos = new float2((Bounds.Width - loadingFont.Measure(loadingText).X) / 2, barY);
|
||||||
|
|
||||||
versionFont = r.Fonts["Regular"];
|
versionFont = r.Fonts["Regular"];
|
||||||
versionText = CncWidgetUtils.ActiveModVersion();
|
versionText = WidgetUtils.ActiveModVersion();
|
||||||
var versionSize = versionFont.Measure(versionText);
|
var versionSize = versionFont.Measure(versionText);
|
||||||
versionPos = new float2(Bounds.Width - 107 - versionSize.X/2, 115 - versionSize.Y/2);
|
versionPos = new float2(Bounds.Width - 107 - versionSize.X/2, 115 - versionSize.Y/2);
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,6 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
public static class CncWidgetUtils
|
public static class CncWidgetUtils
|
||||||
{
|
{
|
||||||
public static string ActiveModVersion()
|
|
||||||
{
|
|
||||||
var mod = Game.modData.Manifest.Mods[0];
|
|
||||||
return Mod.AllMods[mod].Version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string ChooseInitialMap(string map)
|
public static string ChooseInitialMap(string map)
|
||||||
{
|
{
|
||||||
var availableMaps = Game.modData.AvailableMaps;
|
var availableMaps = Game.modData.AvailableMaps;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
var mpe = world.WorldActor.Trait<CncMenuPaletteEffect>();
|
var mpe = world.WorldActor.Trait<CncMenuPaletteEffect>();
|
||||||
mpe.Fade(CncMenuPaletteEffect.EffectType.Desaturated);
|
mpe.Fade(CncMenuPaletteEffect.EffectType.Desaturated);
|
||||||
|
|
||||||
menu.GetWidget<LabelWidget>("VERSION_LABEL").GetText = CncWidgetUtils.ActiveModVersion;
|
menu.GetWidget<LabelWidget>("VERSION_LABEL").GetText = WidgetUtils.ActiveModVersion;
|
||||||
|
|
||||||
bool hideButtons = false;
|
bool hideButtons = false;
|
||||||
menu.GetWidget("MENU_BUTTONS").IsVisible = () => !hideButtons;
|
menu.GetWidget("MENU_BUTTONS").IsVisible = () => !hideButtons;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
.Fade(CncMenuPaletteEffect.EffectType.Desaturated);
|
.Fade(CncMenuPaletteEffect.EffectType.Desaturated);
|
||||||
|
|
||||||
rootMenu = widget.GetWidget("MENU_BACKGROUND");
|
rootMenu = widget.GetWidget("MENU_BACKGROUND");
|
||||||
rootMenu.GetWidget<LabelWidget>("VERSION_LABEL").GetText = CncWidgetUtils.ActiveModVersion;
|
rootMenu.GetWidget<LabelWidget>("VERSION_LABEL").GetText = WidgetUtils.ActiveModVersion;
|
||||||
|
|
||||||
// Menu buttons
|
// Menu buttons
|
||||||
var mainMenu = widget.GetWidget("MAIN_MENU");
|
var mainMenu = widget.GetWidget("MAIN_MENU");
|
||||||
|
|||||||
@@ -40,20 +40,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var selector = Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "QUICKMODSWITCHER" );
|
var selector = Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "QUICKMODSWITCHER" );
|
||||||
var switcher = selector.GetWidget<DropDownButtonWidget>("SWITCHER");
|
var switcher = selector.GetWidget<DropDownButtonWidget>("SWITCHER");
|
||||||
switcher.OnMouseDown = _ => ShowModsDropDown(switcher);
|
switcher.OnMouseDown = _ => ShowModsDropDown(switcher);
|
||||||
switcher.GetText = ActiveModTitle;
|
switcher.GetText = WidgetUtils.ActiveModTitle;
|
||||||
selector.GetWidget<LabelWidget>("VERSION").GetText = ActiveModVersion;
|
selector.GetWidget<LabelWidget>("VERSION").GetText = WidgetUtils.ActiveModVersion;
|
||||||
}
|
|
||||||
|
|
||||||
static string ActiveModTitle()
|
|
||||||
{
|
|
||||||
var mod = Game.modData.Manifest.Mods[0];
|
|
||||||
return Mod.AllMods[mod].Title;
|
|
||||||
}
|
|
||||||
|
|
||||||
static string ActiveModVersion()
|
|
||||||
{
|
|
||||||
var mod = Game.modData.Manifest.Mods[0];
|
|
||||||
return Mod.AllMods[mod].Version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadMod(string mod)
|
static void LoadMod(string mod)
|
||||||
@@ -65,13 +53,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
mod = Mod.AllMods[mod].Requires;
|
mod = Mod.AllMods[mod].Requires;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Game.CurrentMods.Keys.ToArray().SymmetricDifference(mods.ToArray()).Any())
|
if (Game.CurrentMods.Keys.ToArray().SymmetricDifference(mods.ToArray()).Any())
|
||||||
return;
|
Game.RunAfterTick(() => Game.InitializeWithMods(mods.ToArray()));
|
||||||
|
|
||||||
Game.RunAfterTick(() =>
|
|
||||||
{
|
|
||||||
Game.InitializeWithMods(mods.ToArray());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowModsDropDown(DropDownButtonWidget dropdown)
|
static void ShowModsDropDown(DropDownButtonWidget dropdown)
|
||||||
|
|||||||
Reference in New Issue
Block a user