Layout/font weight polish

This commit is contained in:
Paul Chote
2010-07-10 23:19:55 +12:00
parent 56fb711fc6
commit a29198c237
5 changed files with 79 additions and 36 deletions

View File

@@ -26,6 +26,7 @@ namespace OpenRA.Widgets
class ButtonWidget : Widget class ButtonWidget : Widget
{ {
public string Text = ""; public string Text = "";
public bool Bold = false;
public bool Depressed = false; public bool Depressed = false;
public int VisualHeight = 1; public int VisualHeight = 1;
public Func<string> GetText; public Func<string> GetText;
@@ -82,16 +83,16 @@ namespace OpenRA.Widgets
public override void DrawInner(World world) public override void DrawInner(World world)
{ {
var pos = DrawPosition(); var pos = DrawPosition();
var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont;
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0); var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
WidgetUtils.DrawPanel(Depressed ? "dialog3" : "dialog2", WidgetUtils.DrawPanel(Depressed ? "dialog3" : "dialog2",
new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height ) ); new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height ) );
var text = GetText(); var text = GetText();
Game.chrome.renderer.BoldFont.DrawText(text, font.DrawText(text,
new int2( pos.X + Bounds.Width / 2, pos.Y + Bounds.Height / 2) new int2( pos.X + Bounds.Width / 2, pos.Y + Bounds.Height / 2)
- new int2(Game.chrome.renderer.BoldFont.Measure(text).X / 2, - new int2(font.Measure(text).X / 2,
Game.chrome.renderer.BoldFont.Measure(text).Y / 2) + stateOffset, Color.White); font.Measure(text).Y / 2) + stateOffset, Color.White);
} }
public override Widget Clone() public override Widget Clone()

View File

@@ -26,17 +26,21 @@ namespace OpenRA.Widgets
class CheckboxWidget : Widget class CheckboxWidget : Widget
{ {
public string Text = ""; public string Text = "";
public int baseLine = 1;
public bool Bold = false;
public Func<bool> Checked = () => {return false;}; public Func<bool> Checked = () => {return false;};
public override void DrawInner(World world) public override void DrawInner(World world)
{ {
var font = (Bold) ? Game.chrome.renderer.BoldFont : Game.chrome.renderer.RegularFont;
var pos = DrawPosition(); var pos = DrawPosition();
var rect = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height); var rect = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height);
WidgetUtils.DrawPanel("dialog3", new Rectangle(rect.Location, WidgetUtils.DrawPanel("dialog3", new Rectangle(rect.Location,
new Size(Bounds.Height, Bounds.Height))); new Size(Bounds.Height, Bounds.Height)));
Game.chrome.renderer.BoldFont.DrawText(Text, var textSize = font.Measure(Text);
new float2(rect.Left + rect.Height * 2, rect.Top), Color.White); font.DrawText(Text,
new float2(rect.Left + rect.Height * 1.5f, pos.Y - baseLine + (Bounds.Height - textSize.Y)/2), Color.White);
if (Checked()) if (Checked())
{ {

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Widgets
public string Text = ""; public string Text = "";
public TextAlign Align = TextAlign.Left; public TextAlign Align = TextAlign.Left;
public bool Bold = true; public bool Bold = false;
public Func<string> GetText; public Func<string> GetText;
public LabelWidget() public LabelWidget()

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Widgets
class TextFieldWidget : Widget class TextFieldWidget : Widget
{ {
public string Text = ""; public string Text = "";
public bool Bold = true; public bool Bold = false;
public int VisualHeight = 1; public int VisualHeight = 1;
public Func<bool> OnEnterKey = () => {return false;}; public Func<bool> OnEnterKey = () => {return false;};
public Func<bool> OnTabKey = () => {return false;}; public Func<bool> OnTabKey = () => {return false;};

View File

@@ -25,6 +25,7 @@ Container:
Height:25 Height:25
Text:OpenRA Main Menu Text:OpenRA Main Menu
Align:Center Align:Center
Bold:True
Button@MAINMENU_BUTTON_JOIN: Button@MAINMENU_BUTTON_JOIN:
Id:MAINMENU_BUTTON_JOIN Id:MAINMENU_BUTTON_JOIN
X:45 X:45
@@ -32,6 +33,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Join Game Text:Join Game
Bold:True
Button@MAINMENU_BUTTON_CREATE: Button@MAINMENU_BUTTON_CREATE:
Id:MAINMENU_BUTTON_CREATE Id:MAINMENU_BUTTON_CREATE
X:45 X:45
@@ -39,6 +41,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Create Game Text:Create Game
Bold:True
Button@MAINMENU_BUTTON_SETTINGS: Button@MAINMENU_BUTTON_SETTINGS:
Id:MAINMENU_BUTTON_SETTINGS Id:MAINMENU_BUTTON_SETTINGS
X:45 X:45
@@ -46,6 +49,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Settings Text:Settings
Bold:True
Button@MAINMENU_BUTTON_QUIT: Button@MAINMENU_BUTTON_QUIT:
Id:MAINMENU_BUTTON_QUIT Id:MAINMENU_BUTTON_QUIT
X:45 X:45
@@ -53,6 +57,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Quit Text:Quit
Bold:True
Label@VERSION_STRING: Label@VERSION_STRING:
Id:VERSION_STRING Id:VERSION_STRING
X:WINDOW_RIGHT - PARENT_LEFT - WIDTH - 15 X:WINDOW_RIGHT - PARENT_LEFT - WIDTH - 15
@@ -61,6 +66,7 @@ Container:
Height:35 Height:35
Text: Text:
Align:Right Align:Right
Bold:True
Background@CREATESERVER_BG: Background@CREATESERVER_BG:
Id:CREATESERVER_BG Id:CREATESERVER_BG
Delegate:CreateServerMenuDelegate Delegate:CreateServerMenuDelegate
@@ -78,6 +84,7 @@ Container:
Height:25 Height:25
Text:Create Server Text:Create Server
Align:Center Align:Center
Bold:True
Checkbox@CREATESERVER_CHECKBOX_ONLINE: Checkbox@CREATESERVER_CHECKBOX_ONLINE:
Id:CREATESERVER_CHECKBOX_ONLINE Id:CREATESERVER_CHECKBOX_ONLINE
X:100 X:100
@@ -92,6 +99,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Create Text:Create
Bold:True
Button@CREATESERVER_BUTTON_CANCEL: Button@CREATESERVER_BUTTON_CANCEL:
Id:CREATESERVER_BUTTON_CANCEL Id:CREATESERVER_BUTTON_CANCEL
X:270 X:270
@@ -99,6 +107,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Cancel Text:Cancel
Bold:True
Background@SETTINGS_BG: Background@SETTINGS_BG:
Id:SETTINGS_BG Id:SETTINGS_BG
Delegate:SettingsMenuDelegate Delegate:SettingsMenuDelegate
@@ -116,6 +125,7 @@ Container:
Height:25 Height:25
Text:Settings Text:Settings
Align:Center Align:Center
Bold:True
Checkbox@SETTINGS_CHECKBOX_UNITDEBUG: Checkbox@SETTINGS_CHECKBOX_UNITDEBUG:
Id:SETTINGS_CHECKBOX_UNITDEBUG Id:SETTINGS_CHECKBOX_UNITDEBUG
X:100 X:100
@@ -172,6 +182,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:OK Text:OK
Bold:True
Background@JOINSERVER_BG: Background@JOINSERVER_BG:
Id:JOINSERVER_BG Id:JOINSERVER_BG
Delegate:ServerBrowserDelegate Delegate:ServerBrowserDelegate
@@ -189,6 +200,7 @@ Container:
Height:25 Height:25
Text:Quick'n'dirty Server Browser Text:Quick'n'dirty Server Browser
Align:Center Align:Center
Bold:True
Label@JOINSERVER_PROGRESS_TITLE: Label@JOINSERVER_PROGRESS_TITLE:
Id:JOINSERVER_PROGRESS_TITLE Id:JOINSERVER_PROGRESS_TITLE
X:0 X:0
@@ -204,6 +216,7 @@ Container:
Width:120 Width:120
Height:25 Height:25
Text:Direct Connect Text:Direct Connect
Bold:True
Button@JOINSERVER_BUTTON_REFRESH: Button@JOINSERVER_BUTTON_REFRESH:
Id:JOINSERVER_BUTTON_REFRESH Id:JOINSERVER_BUTTON_REFRESH
X:PARENT_RIGHT - 140 - 130 X:PARENT_RIGHT - 140 - 130
@@ -211,6 +224,7 @@ Container:
Width:120 Width:120
Height:25 Height:25
Text:Refresh Text:Refresh
Bold:True
Button@JOINSERVER_BUTTON_CANCEL: Button@JOINSERVER_BUTTON_CANCEL:
Id:JOINSERVER_BUTTON_CANCEL Id:JOINSERVER_BUTTON_CANCEL
X:PARENT_RIGHT - 140 X:PARENT_RIGHT - 140
@@ -218,6 +232,7 @@ Container:
Width:120 Width:120
Height:25 Height:25
Text:Cancel Text:Cancel
Bold:True
Background@CONNECTION_FAILED_BG: Background@CONNECTION_FAILED_BG:
Id:CONNECTION_FAILED_BG Id:CONNECTION_FAILED_BG
Delegate:ConnectionDialogsDelegate Delegate:ConnectionDialogsDelegate
@@ -235,6 +250,7 @@ Container:
Height:25 Height:25
Text:Connection Failed Text:Connection Failed
Align:Center Align:Center
Bold:True
Label@CONNECTION_FAILED_DESC: Label@CONNECTION_FAILED_DESC:
Id:CONNECTION_FAILED_DESC Id:CONNECTION_FAILED_DESC
X:0 X:0
@@ -250,6 +266,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Retry Text:Retry
Bold:True
Button@CONNECTION_BUTTON_CANCEL: Button@CONNECTION_BUTTON_CANCEL:
Id:CONNECTION_BUTTON_CANCEL Id:CONNECTION_BUTTON_CANCEL
X:PARENT_RIGHT - 180 X:PARENT_RIGHT - 180
@@ -257,6 +274,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Cancel Text:Cancel
Bold:True
Background@CONNECTING_BG: Background@CONNECTING_BG:
Id:CONNECTING_BG Id:CONNECTING_BG
Delegate:ConnectionDialogsDelegate Delegate:ConnectionDialogsDelegate
@@ -274,6 +292,7 @@ Container:
Height:25 Height:25
Text:Connecting Text:Connecting
Align:Center Align:Center
Bold:True
Label@CONNECTING_DESC: Label@CONNECTING_DESC:
Id:CONNECTING_DESC Id:CONNECTING_DESC
X:0 X:0
@@ -289,6 +308,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Abort Text:Abort
Bold:True
Background@SERVER_LOBBY: Background@SERVER_LOBBY:
Id:SERVER_LOBBY Id:SERVER_LOBBY
Delegate:LobbyDelegate Delegate:LobbyDelegate
@@ -304,6 +324,7 @@ Container:
Align:Center Align:Center
Width:800 Width:800
Height:20 Height:20
Bold:True
Text:OpenRA Multiplayer Lobby Text:OpenRA Multiplayer Lobby
Background@LOBBY_MAP_BG: Background@LOBBY_MAP_BG:
X:PARENT_RIGHT-268 X:PARENT_RIGHT-268
@@ -335,7 +356,7 @@ Container:
TextField@NAME: TextField@NAME:
Id:NAME Id:NAME
Text:Name Text:Name
Width:95 Width:127
Height:25 Height:25
X:0 X:0
Y:0 Y:0
@@ -344,7 +365,7 @@ Container:
Id:COLOR Id:COLOR
Width:65 Width:65
Height:25 Height:25
X:100 X:159
Y:0 Y:0
Children: Children:
ColorBlock@COLORBLOCK: ColorBlock@COLORBLOCK:
@@ -355,9 +376,9 @@ Container:
Height:PARENT_BOTTOM-12 Height:PARENT_BOTTOM-12
Button@FACTION: Button@FACTION:
Id:FACTION Id:FACTION
Width:105 Width:110
Height:25 Height:25
X:180 X:256
Y:0 Y:0
Children: Children:
Image@FACTIONFLAG: Image@FACTIONFLAG:
@@ -376,16 +397,15 @@ Container:
Button@TEAM: Button@TEAM:
Id:TEAM Id:TEAM
Text:Team Text:Team
Width:70 Width:25
Height:25 Height:25
X:300 X:398
Y:0 Y:0
Checkbox@STATUS: Checkbox@STATUS:
Id:STATUS Id:STATUS
X:405 X:455
Y:1 Width:25
Width:20 Height:25
Height:20
Container@TEMPLATE_REMOTE: Container@TEMPLATE_REMOTE:
Id:TEMPLATE_REMOTE Id:TEMPLATE_REMOTE
X:0 X:0
@@ -397,21 +417,21 @@ Container:
Label@NAME: Label@NAME:
Id:NAME Id:NAME
Text:Name Text:Name
Width:95 Width:127
Height:25 Height:25
X:0 X:0
Y:0 Y:0
ColorBlock@COLOR: ColorBlock@COLOR:
Id:COLOR Id:COLOR
X:105 X:164
Y:7 Y:7
Width:55 Width:55
Height:13 Height:13
Label@FACTION: Label@FACTION:
Id:FACTION Id:FACTION
Width:105 Width:110
Height:25 Height:25
X:180 X:256
Y:0 Y:0
Children: Children:
Image@FACTIONFLAG: Image@FACTIONFLAG:
@@ -432,58 +452,64 @@ Container:
Text:Team Text:Team
Width:70 Width:70
Height:25 Height:25
X:300 X:375
Y:0 Y:0
Align:Center Align:Center
Bold: false
Checkbox@STATUS: Checkbox@STATUS:
Id:STATUS Id:STATUS
X:405 X:455
Y:1 Width:25
Width:20 Height:25
Height:20
Container@LABEL_CONTAINER: Container@LABEL_CONTAINER:
X:30 X:30
Y:45 Y:45
Children: Children:
Label@LABEL_LOBBY_NAME: Label@LABEL_LOBBY_NAME:
Id:LABEL_LOBBY_NAME Id:LABEL_LOBBY_NAME
Width:95 Width:127
Height:25 Height:25
X:0 X:0
Y:0 Y:0
Text:Name Text:Name
Align:Center
Bold:True
Label@LABEL_LOBBY_COLOR: Label@LABEL_LOBBY_COLOR:
Id:LABEL_LOBBY_COLOR Id:LABEL_LOBBY_COLOR
Width:65 Width:65
Height:25 Height:25
X:100 X:159
Y:0 Y:0
Text:Color Text:Color
Align:Center Align:Center
Bold:True
Label@LABEL_LOBBY_FACTION: Label@LABEL_LOBBY_FACTION:
Id:LABEL_LOBBY_FACTION Id:LABEL_LOBBY_FACTION
Width:90 Width:110
Height:25 Height:25
X:180 X:256
Y:0 Y:0
Text:Faction Text:Faction
Align:Center Align:Center
Bold:True
Label@LABEL_LOBBY_TEAM: Label@LABEL_LOBBY_TEAM:
Id:LABEL_LOBBY_TEAM Id:LABEL_LOBBY_TEAM
Width:70 Width:70
Height:25 Height:25
X:295 X:375
Y:0 Y:0
Text:Team Text:Team
Align:Center Align:Center
Bold:True
Label@LABEL_LOBBY_STATUS: Label@LABEL_LOBBY_STATUS:
Id:LABEL_LOBBY_STATUS Id:LABEL_LOBBY_STATUS
X:380 X:432
Y:0 Y:0
Width:70 Width:70
Height:25 Height:25
Text:Ready Text:Ready
Align:Center Align:Center
Bold:True
Button@CHANGEMAP_BUTTON: Button@CHANGEMAP_BUTTON:
Id:CHANGEMAP_BUTTON Id:CHANGEMAP_BUTTON
Visible:true Visible:true
@@ -492,6 +518,7 @@ Container:
Width:120 Width:120
Height:25 Height:25
Text:Change Map Text:Change Map
Bold:True
ChatDisplay@CHAT_DISPLAY: ChatDisplay@CHAT_DISPLAY:
Id:CHAT_DISPLAY Id:CHAT_DISPLAY
Visible:true Visible:true
@@ -506,15 +533,15 @@ Container:
Width:70 Width:70
Height:25 Height:25
X:0 X:0
Y:PARENT_BOTTOM - 76 Y:PARENT_BOTTOM - 75
Text:Chat: Text:Chat:
Align:Right Align:Right
TextField@CHAT_TEXTFIELD: TextField@CHAT_TEXTFIELD:
Id:CHAT_TEXTFIELD Id:CHAT_TEXTFIELD
Visible:true Visible:true
X:75 X:75
Y:PARENT_BOTTOM - 75 Y:PARENT_BOTTOM - 74
Width:700 Width:705
Height:25 Height:25
Button@DISCONNECT_BUTTON: Button@DISCONNECT_BUTTON:
Id:DISCONNECT_BUTTON Id:DISCONNECT_BUTTON
@@ -524,6 +551,7 @@ Container:
Width:120 Width:120
Height:25 Height:25
Text:Disconnect Text:Disconnect
Bold:True
Checkbox@LOCKTEAMS_CHECKBOX: Checkbox@LOCKTEAMS_CHECKBOX:
Id:LOCKTEAMS_CHECKBOX Id:LOCKTEAMS_CHECKBOX
Visible: true Visible: true
@@ -547,6 +575,7 @@ Container:
Width:800 Width:800
Height:20 Height:20
Text:Choose Map Text:Choose Map
Bold:True
Background@MAPCHOOSER_MAP_BG: Background@MAPCHOOSER_MAP_BG:
X:PARENT_RIGHT-268 X:PARENT_RIGHT-268
Y:39 Y:39
@@ -581,6 +610,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Options Text:Options
Bold:True
Button@INGAME_DIPLOMACY_BUTTON: Button@INGAME_DIPLOMACY_BUTTON:
Id:INGAME_DIPLOMACY_BUTTON Id:INGAME_DIPLOMACY_BUTTON
X:162 X:162
@@ -588,6 +618,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Diplomacy Text:Diplomacy
Bold:True
WorldTooltip@INGAME_WORLD_TOOLTIP: WorldTooltip@INGAME_WORLD_TOOLTIP:
Id:INGAME_WORLD_TOOLTIP Id:INGAME_WORLD_TOOLTIP
RadarBin@INGAME_RADAR_BIN: RadarBin@INGAME_RADAR_BIN:
@@ -617,6 +648,7 @@ Container:
Height:25 Height:25
Text:Options Text:Options
Align:Center Align:Center
Bold:True
Button@BUTTON_RESUME: Button@BUTTON_RESUME:
Id:BUTTON_RESUME Id:BUTTON_RESUME
X:(PARENT_RIGHT - WIDTH)/2 X:(PARENT_RIGHT - WIDTH)/2
@@ -624,6 +656,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Resume Text:Resume
Bold:True
Button@BUTTON_SURRENDER: Button@BUTTON_SURRENDER:
Id:BUTTON_SURRENDER Id:BUTTON_SURRENDER
X:(PARENT_RIGHT - WIDTH)/2 X:(PARENT_RIGHT - WIDTH)/2
@@ -631,6 +664,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Surrender Text:Surrender
Bold:True
Button@BUTTON_SETTINGS: Button@BUTTON_SETTINGS:
Id:BUTTON_SETTINGS Id:BUTTON_SETTINGS
X:(PARENT_RIGHT - WIDTH)/2 X:(PARENT_RIGHT - WIDTH)/2
@@ -638,6 +672,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Settings Text:Settings
Bold:True
Button@BUTTON_DISCONNECT: Button@BUTTON_DISCONNECT:
Id:BUTTON_DISCONNECT Id:BUTTON_DISCONNECT
X:(PARENT_RIGHT - WIDTH)/2 X:(PARENT_RIGHT - WIDTH)/2
@@ -645,6 +680,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Disconnect Text:Disconnect
Bold:True
Button@BUTTON_QUIT: Button@BUTTON_QUIT:
Id:BUTTON_QUIT Id:BUTTON_QUIT
X:(PARENT_RIGHT - WIDTH)/2 X:(PARENT_RIGHT - WIDTH)/2
@@ -652,6 +688,7 @@ Container:
Width:160 Width:160
Height:25 Height:25
Text:Quit Text:Quit
Bold:True
Background@DIPLOMACY_BG: Background@DIPLOMACY_BG:
Id:DIPLOMACY_BG Id:DIPLOMACY_BG
Delegate:DiplomacyDelegate Delegate:DiplomacyDelegate
@@ -669,6 +706,7 @@ Container:
Height:25 Height:25
Text:Diplomacy Text:Diplomacy
Align:Center Align:Center
Bold:True
Background@PERF_BG: Background@PERF_BG:
ClickThrough:true ClickThrough:true
Id:PERF_BG Id:PERF_BG