From 96c80f357ce577d99183c226b8d2be81fe74b7b3 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 11 Jul 2010 01:59:37 +1200 Subject: [PATCH] Polish --- .../Widgets/Delegates/CreateServerMenuDelegate.cs | 13 ++++++------- OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs | 6 ++++-- OpenRA.Game/Widgets/TextFieldWidget.cs | 6 ++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs b/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs index 001985807d..df302f9f30 100644 --- a/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs @@ -24,9 +24,7 @@ using System.Collections.Generic; namespace OpenRA.Widgets.Delegates { public class CreateServerMenuDelegate : IWidgetDelegate - { - static bool AdvertiseServerOnline = Game.Settings.InternetServer; - + { public CreateServerMenuDelegate() { var r = Chrome.rootWidget; @@ -56,7 +54,7 @@ namespace OpenRA.Widgets.Delegates int listenPort = int.Parse(cs.GetWidget("LISTEN_PORT").Text); int extPort = int.Parse(cs.GetWidget("EXTERNAL_PORT").Text); - Server.Server.ServerMain(AdvertiseServerOnline, Game.Settings.MasterServer, + Server.Server.ServerMain(Game.Settings.InternetServer, Game.Settings.MasterServer, gameName, listenPort, extPort, mods, map); Log.Write("debug", "Joining server"); @@ -66,9 +64,10 @@ namespace OpenRA.Widgets.Delegates cs.GetWidget("LISTEN_PORT").Text = Game.Settings.ListenPort.ToString(); cs.GetWidget("EXTERNAL_PORT").Text = Game.Settings.ExternalPort.ToString(); - r.GetWidget("CHECKBOX_ONLINE").Checked = () => {return AdvertiseServerOnline;}; - r.GetWidget("CHECKBOX_ONLINE").OnMouseDown = mi => { - AdvertiseServerOnline = !AdvertiseServerOnline; + cs.GetWidget("CHECKBOX_ONLINE").Checked = () => Game.Settings.InternetServer; + cs.GetWidget("CHECKBOX_ONLINE").OnMouseDown = mi => { + Game.Settings.InternetServer ^= true; + Game.Settings.Save(); return true; }; } diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index 19cdfa8db4..0f95552c17 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -96,6 +96,8 @@ namespace OpenRA.Widgets.Delegates void UpdatePlayerList() { + // This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them) + // Todo: handle this nicer Players.Children.Clear(); int offset = 0; @@ -109,7 +111,6 @@ namespace OpenRA.Widgets.Delegates template = LocalPlayerTemplate.Clone(); var name = template.GetWidget("NAME"); name.Text = c.Name; - name.OnLoseFocus = () => name.Text = c.Name; name.OnEnterKey = () => { name.Text = name.Text.Trim(); @@ -126,7 +127,8 @@ namespace OpenRA.Widgets.Delegates Chrome.selectedWidget = null; return true; }; - + name.OnLoseFocus = () => name.OnEnterKey(); + var color = template.GetWidget("COLOR"); color.OnMouseUp = CyclePalette; diff --git a/OpenRA.Game/Widgets/TextFieldWidget.cs b/OpenRA.Game/Widgets/TextFieldWidget.cs index 6e21a33cff..b1cf312a07 100644 --- a/OpenRA.Game/Widgets/TextFieldWidget.cs +++ b/OpenRA.Game/Widgets/TextFieldWidget.cs @@ -141,10 +141,12 @@ namespace OpenRA.Widgets // Inset text by the margin and center vertically var textPos = pos + new int2( margin, (Bounds.Height - textSize.Y)/2 - VisualHeight); - // Right align and scissor when the text overflows + // Right align when editing and scissor when the text overflows if (textSize.X > Bounds.Width - 2*margin) { - textPos += new int2(Bounds.Width - 2*margin - textSize.X,0); + if (Chrome.selectedWidget == this) + textPos += new int2(Bounds.Width - 2*margin - textSize.X,0); + Game.chrome.renderer.Device.EnableScissor(pos.X + margin, pos.Y, Bounds.Width - 2*margin, Bounds.Bottom); }