diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs index f9fbdd538c..34bc8d3854 100644 --- a/OpenRA.Game/Chrome.cs +++ b/OpenRA.Game/Chrome.cs @@ -77,15 +77,6 @@ namespace OpenRA buttons.Clear(); renderer.Device.DisableScissor(); } - - void AddUiButton(int2 pos, string text, Action a) - { - var rect = new Rectangle(pos.X - 160 / 2, pos.Y - 4, 160, 24); - DrawDialogBackground( rect, "dialog2"); - DrawCentered(text, new int2(pos.X, pos.Y), Color.White); - rgbaRenderer.Flush(); - AddButton(rect, a); - } public void DrawMapChooser() { @@ -94,22 +85,6 @@ namespace OpenRA var w = 800; var h = 600; var r = new Rectangle( (Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h ); - - AddUiButton(new int2(r.Left + 200, r.Bottom - 40), "OK", - _ => - { - Game.IssueOrder(Order.Chat("/map " + currentMap.Uid)); - Chrome.rootWidget.CloseWindow(); - }); - - AddUiButton(new int2(r.Right - 200, r.Bottom - 40), "Cancel", - _ => - { - Chrome.rootWidget.CloseWindow(); - }); - - var mapContainer = new Rectangle(r.Right - 280, r.Top + 30, 256, 256); - var y = r.Top + 50; // Don't bother showing a subset of the data @@ -133,21 +108,6 @@ namespace OpenRA AddButton(itemRect, _ => { currentMap = closureMap; }); y += 20; } - - y = mapContainer.Bottom + 20; - DrawCentered("Title: {0}".F(currentMap.Title), - new int2(mapContainer.Left + mapContainer.Width / 2, y), Color.White); - y += 20; - DrawCentered("Size: {0}x{1}".F(currentMap.Width, currentMap.Height), - new int2(mapContainer.Left + mapContainer.Width / 2, y), Color.White); - y += 20; - - DrawCentered("Theater: {0}".F(Rules.TileSets[currentMap.Tileset].Name), - new int2(mapContainer.Left + mapContainer.Width / 2, y), Color.White); - y += 20; - DrawCentered("Spawnpoints: {0}".F(currentMap.PlayerCount), - new int2(mapContainer.Left + mapContainer.Width / 2, y), Color.White); - AddButton(r, _ => { }); } diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 9571577514..68179d21e5 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -226,6 +226,7 @@ + diff --git a/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs b/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs new file mode 100644 index 0000000000..abe5c56c87 --- /dev/null +++ b/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs @@ -0,0 +1,53 @@ +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using OpenRA.FileFormats; + +namespace OpenRA.Widgets.Delegates +{ + public class MapChooserDelegate : IWidgetDelegate + { + public MapChooserDelegate() + { + var r = Chrome.rootWidget; + var bg = r.GetWidget("MAP_CHOOSER"); + + bg.GetWidget("CURMAP_TITLE").GetText = () => {return Game.chrome.currentMap.Title;}; + bg.GetWidget("CURMAP_SIZE").GetText = () => {return "{0}x{1}".F(Game.chrome.currentMap.Width, Game.chrome.currentMap.Height);}; + bg.GetWidget("CURMAP_THEATER").GetText = () => {return Rules.TileSets[Game.chrome.currentMap.Tileset].Name;}; + bg.GetWidget("CURMAP_PLAYERS").GetText = () => {return Game.chrome.currentMap.PlayerCount.ToString();}; + + bg.GetWidget("BUTTON_OK").OnMouseUp = mi => { + Game.IssueOrder(Order.Chat("/map " + Game.chrome.currentMap.Uid)); + r.CloseWindow(); + return true; + }; + + bg.GetWidget("BUTTON_CANCEL").OnMouseUp = mi => { + r.CloseWindow(); + return true; + }; + } + } +} diff --git a/mods/cnc/menus.yaml b/mods/cnc/menus.yaml index 7bf94f4a32..89f548379a 100644 --- a/mods/cnc/menus.yaml +++ b/mods/cnc/menus.yaml @@ -623,7 +623,6 @@ Container: Width:PARENT_RIGHT - 40 Height:190 Notification: beepy2.aud -#rabeep1.aud for ra Label@LABEL_CHATTYPE: Id:LABEL_CHATTYPE Width:65 @@ -660,6 +659,7 @@ Container: Id:MAP_CHOOSER X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 + Delegate:MapChooserDelegate Width:800 Height:600 Visible:false @@ -672,6 +672,70 @@ Container: Height:20 Text:Choose Map Bold:True + Label@CURMAP_TITLE_LABEL: + Id:CURMAP_TITLE_LABEL + X:PARENT_RIGHT - 200 - WIDTH + Y:311 + Align:Right + Width:70 + Height:20 + Text:Title: + Bold:True + Label@CURMAP_TITLE: + Id:CURMAP_TITLE + X:PARENT_RIGHT - 195 + Y:311 + Align:Left + Width:70 + Height:20 + Label@CURMAP_SIZE_LABEL: + Id:CURMAP_SIZE_LABEL + X:PARENT_RIGHT - 200 - WIDTH + Y:331 + Align:Right + Width:70 + Height:20 + Text:Size: + Bold:True + Label@CURMAP_SIZE: + Id:CURMAP_SIZE + X:PARENT_RIGHT - 195 + Y:331 + Align:Left + Width:70 + Height:20 + Label@CURMAP_THEATER_LABEL: + Id:CURMAP_THEATER_LABEL + X:PARENT_RIGHT - 200 - WIDTH + Y:351 + Align:Right + Width:70 + Height:20 + Text:Theater: + Bold:True + Label@CURMAP_THEATER: + Id:CURMAP_THEATER + X:PARENT_RIGHT - 195 + Y:351 + Align:Left + Width:70 + Height:20 + Label@CURMAP_PLAYERS_LABEL: + Id:CURMAP_PLAYERS_LABEL + X:PARENT_RIGHT - 200 - WIDTH + Y:371 + Align:Right + Width:70 + Height:20 + Text:Players: + Bold:True + Label@CURMAP_PLAYERS: + Id:CURMAP_PLAYERS + X:PARENT_RIGHT - 195 + Y:371 + Align:Left + Width:70 + Height:20 Background@MAPCHOOSER_MAP_BG: X:PARENT_RIGHT-268 Y:39 @@ -684,6 +748,22 @@ Container: Y:4 Width:244 Height:244 + Button@BUTTON_OK: + Id:BUTTON_OK + X:PARENT_RIGHT - 360 + Y:PARENT_BOTTOM - 45 + Width:160 + Height:25 + Text:Ok + Bold:True + Button@BUTTON_CANCEL: + Id:BUTTON_CANCEL + X:PARENT_RIGHT - 180 + Y:PARENT_BOTTOM - 45 + Width:160 + Height:25 + Text:Cancel + Bold:True Container@INGAME_ROOT: Id:INGAME_ROOT Delegate:IngameChromeDelegate