options menu shows (empty) options dialog

This commit is contained in:
Alli
2010-01-08 00:57:37 +13:00
parent 447612f340
commit 389f659984
2 changed files with 57 additions and 4 deletions

View File

@@ -28,6 +28,16 @@ namespace OpenRa.Game
readonly Animation sellButton;
readonly Animation pwrdownButton;
readonly Animation optionsButton;
readonly Sprite optionsTop;
readonly Sprite optionsBottom;
readonly Sprite optionsLeft;
readonly Sprite optionsRight;
readonly Sprite optionsTopLeft;
readonly Sprite optionsTopRight;
readonly Sprite optionsBottomLeft;
readonly Sprite optionsBottomRight;
readonly Sprite optionsBackground;
readonly SpriteRenderer buildPaletteRenderer;
readonly Animation cantBuild;
@@ -87,6 +97,16 @@ namespace OpenRa.Game
optionsButton = new Animation("tabs");
optionsButton.PlayRepeating("left-normal");
optionsLeft = SpriteSheetBuilder.LoadAllSprites("dd-left")[0];
optionsRight = SpriteSheetBuilder.LoadAllSprites("dd-right")[0];
optionsTop = SpriteSheetBuilder.LoadAllSprites("dd-top")[0];
optionsBottom = SpriteSheetBuilder.LoadAllSprites("dd-botm")[0];
optionsTopLeft = SpriteSheetBuilder.LoadAllSprites("dd-crnr")[0];
optionsTopRight = SpriteSheetBuilder.LoadAllSprites("dd-crnr")[1];
optionsBottomLeft = SpriteSheetBuilder.LoadAllSprites("dd-crnr")[2];
optionsBottomRight = SpriteSheetBuilder.LoadAllSprites("dd-crnr")[3];
optionsBackground = SpriteSheetBuilder.LoadAllSprites("dd-bkgnd")[Game.CosmeticRandom.Next(4)];
blank = SheetBuilder.Add(new Size(64, 48), 16);
sprites = groups
@@ -154,6 +174,7 @@ namespace OpenRa.Game
int paletteHeight = DrawBuildPalette(currentTab);
DrawBuildTabs(paletteHeight);
DrawChat();
DrawOptionsMenu();
}
void DrawMinimap()
@@ -357,17 +378,43 @@ namespace OpenRa.Game
optionsButton.ReplaceAnim(optionsPressed ? "left-pressed" : "left-normal");
AddButton(optionsRect, isLmb => DrawOptionsMenu());
AddButton(optionsRect, isLmb => optionsPressed = !optionsPressed);
buildPaletteRenderer.DrawSprite(optionsButton.Image, optionsDrawPos, PaletteType.Chrome);
buildPaletteRenderer.Flush();
renderer.DrawText("Exit", new int2(80, -2) , Color.White);
renderer.DrawText("Options", new int2(80, -2) , Color.White);
}
void DrawOptionsMenu()
{
Environment.Exit(0);
if (optionsPressed){
var menuDrawPos = Game.viewport.Location + new float2(Game.viewport.Width/2, Game.viewport.Height/2);
var width = optionsTop.bounds.Width + optionsTopLeft.bounds.Width + optionsTopRight.bounds.Width;
var height = optionsLeft.bounds.Height + optionsTopLeft.bounds.Height + optionsBottomLeft.bounds.Height;
var adjust = 8;
menuDrawPos = menuDrawPos + new float2(-width/2, -height/2);
var backgroundDrawPos = menuDrawPos + new float2( (width - optionsBackground.bounds.Width)/2, (height - optionsBackground.bounds.Height)/2);
//draw background
buildPaletteRenderer.DrawSprite(optionsBackground, backgroundDrawPos, PaletteType.Chrome);
//draw borders
buildPaletteRenderer.DrawSprite(optionsTopLeft, menuDrawPos, PaletteType.Chrome);
buildPaletteRenderer.DrawSprite(optionsLeft, menuDrawPos + new float2(0, optionsTopLeft.bounds.Height), PaletteType.Chrome);
buildPaletteRenderer.DrawSprite(optionsBottomLeft, menuDrawPos + new float2(0, optionsTopLeft.bounds.Height + optionsLeft.bounds.Height), PaletteType.Chrome);
buildPaletteRenderer.DrawSprite(optionsTop, menuDrawPos + new float2(optionsTopLeft.bounds.Width, 0), PaletteType.Chrome);
buildPaletteRenderer.DrawSprite(optionsTopRight, menuDrawPos + new float2(optionsTopLeft.bounds.Width + optionsTop.bounds.Width, 0), PaletteType.Chrome);
buildPaletteRenderer.DrawSprite(optionsBottom, menuDrawPos + new float2(optionsTopLeft.bounds.Width, optionsTopLeft.bounds.Height + optionsLeft.bounds.Height +adjust), PaletteType.Chrome);
buildPaletteRenderer.DrawSprite(optionsBottomRight, menuDrawPos + new float2(optionsBottomLeft.bounds.Width + optionsBottom.bounds.Width, optionsTopLeft.bounds.Height + optionsLeft.bounds.Height), PaletteType.Chrome);
buildPaletteRenderer.DrawSprite(optionsRight, menuDrawPos + new float2(optionsTopLeft.bounds.Width + optionsTop.bounds.Width + adjust + 1, optionsTopRight.bounds.Height), PaletteType.Chrome);
buildPaletteRenderer.Flush();
}
}
void HandleChronosphereButton()

View File

@@ -1028,4 +1028,10 @@
<sequence name="left-normal" start="0" length="1" />
<sequence name="left-pressed" start="1" length="1" />
</unit>
<unit name="dd-crnr">
<sequence name="top-left" start="0" length="1" />
<sequence name="top-right" start="1" length="1" />
<sequence name="bottom-left" start="2" length="1" />
<sequence name="bottom-right" start="3" length="1" />
</unit>
</sequences>