Remove some unnecessary fields from chrome

This commit is contained in:
Paul Chote
2010-07-13 20:49:04 +12:00
parent 4a7c19cf93
commit 8d2693019d
6 changed files with 29 additions and 28 deletions

View File

@@ -101,9 +101,7 @@ namespace OpenRA.Widgets.Delegates
};
Game.LobbyInfoChanged += UpdatePlayerList;
Chrome.chatWidget = lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY");
Game.AddChatLine += (c,n,s) => lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c,n,s);
bool teamChat = false;
var chatLabel = lobby.GetWidget<LabelWidget>("LABEL_CHATTYPE");
@@ -158,14 +156,13 @@ namespace OpenRA.Widgets.Delegates
if (name.Text.Length == 0)
name.Text = c.Name;
Chrome.selectedWidget = null;
name.LoseFocus();
if (name.Text == c.Name)
return true;
Game.IssueOrder(Order.Command( "name "+name.Text ));
Game.Settings.PlayerName = name.Text;
Game.Settings.Save();
Chrome.selectedWidget = null;
return true;
};
name.OnLoseFocus = () => name.OnEnterKey();

View File

@@ -25,6 +25,8 @@ namespace OpenRA.Widgets.Delegates
{
public MainMenuButtonsDelegate()
{
// Main menu is the default window
Widget.WindowList.Push("MAINMENU_BG");
Chrome.rootWidget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => {Game.Exit(); return true;};
var version = Chrome.rootWidget.GetWidget("MAINMENU_BG").GetWidget<LabelWidget>("VERSION_STRING");

View File

@@ -152,23 +152,30 @@ namespace OpenRA.Widgets
}
public bool Focused { get { return Chrome.selectedWidget == this; } }
public static Widget SelectedWidget;
public bool Focused { get { return SelectedWidget == this; } }
public virtual bool TakeFocus(MouseInput mi)
{
if (Focused)
return true;
if (Chrome.selectedWidget != null && !Chrome.selectedWidget.LoseFocus(mi))
if (SelectedWidget != null && !SelectedWidget.LoseFocus(mi))
return false;
Chrome.selectedWidget = this;
SelectedWidget = this;
return true;
}
// Remove focus from this widget; return false if you don't want to give it up
public virtual bool LoseFocus(MouseInput mi)
{
if (Chrome.selectedWidget == this)
Chrome.selectedWidget = null;
// Some widgets may need to override focus depending on mouse click
return LoseFocus();
}
public virtual bool LoseFocus()
{
if (SelectedWidget == this)
SelectedWidget = null;
return true;
}