This commit is contained in:
Paul Chote
2010-07-11 01:59:37 +12:00
parent 788e99fc7f
commit 96c80f357c
3 changed files with 14 additions and 11 deletions

View File

@@ -25,8 +25,6 @@ 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<TextFieldWidget>("LISTEN_PORT").Text);
int extPort = int.Parse(cs.GetWidget<TextFieldWidget>("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<TextFieldWidget>("LISTEN_PORT").Text = Game.Settings.ListenPort.ToString();
cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text = Game.Settings.ExternalPort.ToString();
r.GetWidget<CheckboxWidget>("CHECKBOX_ONLINE").Checked = () => {return AdvertiseServerOnline;};
r.GetWidget("CHECKBOX_ONLINE").OnMouseDown = mi => {
AdvertiseServerOnline = !AdvertiseServerOnline;
cs.GetWidget<CheckboxWidget>("CHECKBOX_ONLINE").Checked = () => Game.Settings.InternetServer;
cs.GetWidget("CHECKBOX_ONLINE").OnMouseDown = mi => {
Game.Settings.InternetServer ^= true;
Game.Settings.Save();
return true;
};
}

View File

@@ -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<TextFieldWidget>("NAME");
name.Text = c.Name;
name.OnLoseFocus = () => name.Text = c.Name;
name.OnEnterKey = () =>
{
name.Text = name.Text.Trim();
@@ -126,6 +127,7 @@ namespace OpenRA.Widgets.Delegates
Chrome.selectedWidget = null;
return true;
};
name.OnLoseFocus = () => name.OnEnterKey();
var color = template.GetWidget<ButtonWidget>("COLOR");
color.OnMouseUp = CyclePalette;

View File

@@ -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)
{
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);
}