Move the easy things from the hardcoded map chooser into widgets
This commit is contained in:
@@ -78,15 +78,6 @@ namespace OpenRA
|
|||||||
renderer.Device.DisableScissor();
|
renderer.Device.DisableScissor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddUiButton(int2 pos, string text, Action<bool> 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()
|
public void DrawMapChooser()
|
||||||
{
|
{
|
||||||
buttons.Clear();
|
buttons.Clear();
|
||||||
@@ -94,22 +85,6 @@ namespace OpenRA
|
|||||||
var w = 800;
|
var w = 800;
|
||||||
var h = 600;
|
var h = 600;
|
||||||
var r = new Rectangle( (Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h );
|
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;
|
var y = r.Top + 50;
|
||||||
|
|
||||||
// Don't bother showing a subset of the data
|
// Don't bother showing a subset of the data
|
||||||
@@ -133,21 +108,6 @@ namespace OpenRA
|
|||||||
AddButton(itemRect, _ => { currentMap = closureMap; });
|
AddButton(itemRect, _ => { currentMap = closureMap; });
|
||||||
y += 20;
|
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, _ => { });
|
AddButton(r, _ => { });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -226,6 +226,7 @@
|
|||||||
<Compile Include="Traits\World\HazardLayer.cs" />
|
<Compile Include="Traits\World\HazardLayer.cs" />
|
||||||
<Compile Include="Widgets\TextFieldWidget.cs" />
|
<Compile Include="Widgets\TextFieldWidget.cs" />
|
||||||
<Compile Include="Widgets\ChatDisplayWidget.cs" />
|
<Compile Include="Widgets\ChatDisplayWidget.cs" />
|
||||||
|
<Compile Include="Widgets\Delegates\MapChooserDelegate.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
53
OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs
Normal file
53
OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#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<LabelWidget>("CURMAP_TITLE").GetText = () => {return Game.chrome.currentMap.Title;};
|
||||||
|
bg.GetWidget<LabelWidget>("CURMAP_SIZE").GetText = () => {return "{0}x{1}".F(Game.chrome.currentMap.Width, Game.chrome.currentMap.Height);};
|
||||||
|
bg.GetWidget<LabelWidget>("CURMAP_THEATER").GetText = () => {return Rules.TileSets[Game.chrome.currentMap.Tileset].Name;};
|
||||||
|
bg.GetWidget<LabelWidget>("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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -623,7 +623,6 @@ Container:
|
|||||||
Width:PARENT_RIGHT - 40
|
Width:PARENT_RIGHT - 40
|
||||||
Height:190
|
Height:190
|
||||||
Notification: beepy2.aud
|
Notification: beepy2.aud
|
||||||
#rabeep1.aud for ra
|
|
||||||
Label@LABEL_CHATTYPE:
|
Label@LABEL_CHATTYPE:
|
||||||
Id:LABEL_CHATTYPE
|
Id:LABEL_CHATTYPE
|
||||||
Width:65
|
Width:65
|
||||||
@@ -660,6 +659,7 @@ Container:
|
|||||||
Id:MAP_CHOOSER
|
Id:MAP_CHOOSER
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
|
Delegate:MapChooserDelegate
|
||||||
Width:800
|
Width:800
|
||||||
Height:600
|
Height:600
|
||||||
Visible:false
|
Visible:false
|
||||||
@@ -672,6 +672,70 @@ Container:
|
|||||||
Height:20
|
Height:20
|
||||||
Text:Choose Map
|
Text:Choose Map
|
||||||
Bold:True
|
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:
|
Background@MAPCHOOSER_MAP_BG:
|
||||||
X:PARENT_RIGHT-268
|
X:PARENT_RIGHT-268
|
||||||
Y:39
|
Y:39
|
||||||
@@ -684,6 +748,22 @@ Container:
|
|||||||
Y:4
|
Y:4
|
||||||
Width:244
|
Width:244
|
||||||
Height: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:
|
Container@INGAME_ROOT:
|
||||||
Id:INGAME_ROOT
|
Id:INGAME_ROOT
|
||||||
Delegate:IngameChromeDelegate
|
Delegate:IngameChromeDelegate
|
||||||
|
|||||||
Reference in New Issue
Block a user