public OptionsMenu(Resource.ResourceManager globalContent) { _upperButtons = new Button[7]; _optionsButtons = new Button[4]; _content = globalContent; // we need to load all the positioning data and whatnot from a file... Resource.TextResource layout = new Gk3Main.Resource.TextResource("RC_LAYOUT.TXT", FileSystem.Open("RC_LAYOUT.TXT")); string[] lines = layout.Text.Split('\n'); Dictionary <string, string> layoutInfo = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (string line in lines) { if (line.StartsWith(";") == false) { int equal = line.IndexOf('='); if (equal > 0) { layoutInfo.Add(line.Substring(0, equal).Trim(), line.Substring(equal + 1).Trim()); } } } _upperBackground = globalContent.Load <Graphics.TextureResource>(layoutInfo["backSprite"]); _optionsBackground = globalContent.Load <Graphics.TextureResource>(layoutInfo["optBackSprite"]); _advancedBackground = globalContent.Load <Graphics.TextureResource>(layoutInfo["advOptBackSprite"]); _graphicsBackground = globalContent.Load <Graphics.TextureResource>(layoutInfo["graphicsOptBackSprite"]); setupUpperButtons(globalContent, layoutInfo); setupOptionsButtons(globalContent, layoutInfo); setupAdvancedOptionsButtons(globalContent, layoutInfo); setupGraphicsOptionsButtons(globalContent, layoutInfo); }
public MsgBox(Resource.ResourceManager globalContent, string text, MsgBoxType type) { _type = type; _isActive = true; // we need to load all the positioning data and whatnot from a file... Resource.TextResource layout = new Gk3Main.Resource.TextResource("MSGBOX.TXT", FileSystem.Open("MSGBOX.TXT")); string[] lines = layout.Text.Split('\n'); Dictionary <string, string> layoutInfo = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (string line in lines) { if (line.StartsWith(";") == false) { int equal = line.IndexOf('='); if (equal > 0) { layoutInfo.Add(line.Substring(0, equal).Trim(), line.Substring(equal + 1).Trim()); } } } _font = Font.Load(globalContent.Load <FontSpec>(layoutInfo["Font"])); _yes = new Button(this, globalContent, layoutInfo["yesSpriteDown"], layoutInfo["yesSpriteHov"], layoutInfo["yesSpriteUp"], null, null); _no = new Button(this, globalContent, layoutInfo["noSpriteDown"], layoutInfo["noSpriteHov"], layoutInfo["noSpriteUp"], null, null); _ok = new Button(this, globalContent, layoutInfo["okSpriteDown"], layoutInfo["okSpriteHov"], layoutInfo["okSpriteUp"], null, null); _yes.OnClick += new EventHandler(onButtonClicked); _no.OnClick += new EventHandler(onButtonClicked); _ok.OnClick += new EventHandler(onButtonClicked); _bg = globalContent.Load <Graphics.TextureResource>("black"); _vert = globalContent.Load <Graphics.TextureResource>(layoutInfo["vertSprite"]); _horiz = globalContent.Load <Graphics.TextureResource>(layoutInfo["horizSprite"]); _ur = globalContent.Load <Graphics.TextureResource>(layoutInfo["urCornerSprite"]); _ul = globalContent.Load <Graphics.TextureResource>(layoutInfo["ulCornerSprite"]); _lr = globalContent.Load <Graphics.TextureResource>(layoutInfo["lrCornerSprite"]); _ll = globalContent.Load <Graphics.TextureResource>(layoutInfo["llCornerSprite"]); tryParse2f(layoutInfo["minSize"], out _rect.Width, out _rect.Height); tryParse2f(layoutInfo["textOffset"], out _textOffsetX, out _textOffsetY); _rect = centerBox(Graphics.RendererManager.CurrentRenderer.Viewport, calculateBoxSize(text, _rect)); if (_type == MsgBoxType.YesNo) { positionButtons(true, true, false); } else { positionButtons(false, false, true); } }