diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index 786f8af667..0992297605 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -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() diff --git a/sequences.xml b/sequences.xml index 499b7c30bb..882366a0d1 100644 --- a/sequences.xml +++ b/sequences.xml @@ -1028,4 +1028,10 @@ + + + + + + \ No newline at end of file