Show version on shellmap (via alzeih)

This commit is contained in:
Paul Chote
2010-07-03 15:23:44 +12:00
committed by Chris Forbes
parent 1b38c4a6cb
commit 2835fd66fe
6 changed files with 38 additions and 4 deletions

View File

@@ -18,6 +18,7 @@
*/
#endregion
using System;
using OpenRA.FileFormats;
namespace OpenRA.Widgets.Delegates
{
public class MainMenuButtonsDelegate : IWidgetDelegate
@@ -25,6 +26,15 @@ namespace OpenRA.Widgets.Delegates
public MainMenuButtonsDelegate()
{
Chrome.rootWidget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => {Game.Exit(); return true;};
var version = Chrome.rootWidget.GetWidget("MAINMENU_BG").GetWidget<LabelWidget>("VERSION_STRING");
if (FileSystem.Exists("VERSION"))
{
var s = FileSystem.Open("VERSION");
version.Text = "Version: "+s.ReadAllText();
s.Close();
}
}
}
}

View File

@@ -56,12 +56,18 @@ namespace OpenRA.Widgets
{
var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont;
var text = GetText();
if (text == null)
return;
int2 textSize = font.Measure(text);
int2 position = DrawPosition();
if (Align == TextAlign.Center)
position += new int2((Bounds.Width - textSize.X)/2, 0);
if (Align == TextAlign.Right)
position += new int2(Bounds.Width - textSize.X,0);
font.DrawText(text, position, Color.White);
}

View File

@@ -102,6 +102,8 @@ namespace OpenRA.Widgets
substitutions.Add("WINDOW_RIGHT", Game.viewport.Width);
substitutions.Add("WINDOW_BOTTOM", Game.viewport.Height);
substitutions.Add("PARENT_RIGHT", parentBounds.Width);
substitutions.Add("PARENT_LEFT", parentBounds.Left);
substitutions.Add("PARENT_TOP", parentBounds.Top);
substitutions.Add("PARENT_BOTTOM", parentBounds.Height);
int width = Evaluator.Evaluate(Width, substitutions);
int height = Evaluator.Evaluate(Height, substitutions);