Move OnMouseUp onto ButtonWidget and drop its unnecessary plumbing.
This commit is contained in:
@@ -25,6 +25,9 @@ namespace OpenRA.Widgets
|
|||||||
public Func<string> GetText;
|
public Func<string> GetText;
|
||||||
public Func<bool> IsDisabled = () => false;
|
public Func<bool> IsDisabled = () => false;
|
||||||
public Action<MouseInput> OnMouseDown = _ => {};
|
public Action<MouseInput> OnMouseDown = _ => {};
|
||||||
|
public Action<MouseInput> OnMouseUp = _ => {};
|
||||||
|
|
||||||
|
// Equivalent to OnMouseUp, but without an input arg
|
||||||
public Action OnClick = () => {};
|
public Action OnClick = () => {};
|
||||||
public Action<KeyInput> OnKeyPress = _ => {};
|
public Action<KeyInput> OnKeyPress = _ => {};
|
||||||
|
|
||||||
@@ -32,7 +35,7 @@ namespace OpenRA.Widgets
|
|||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
GetText = () => { return Text; };
|
GetText = () => { return Text; };
|
||||||
OnMouseUp = mi => { if (!IsDisabled()) OnClick(); return true; };
|
OnMouseUp = _ => OnClick();
|
||||||
OnKeyPress = _ => OnClick();
|
OnKeyPress = _ => OnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +49,7 @@ namespace OpenRA.Widgets
|
|||||||
GetText = widget.GetText;
|
GetText = widget.GetText;
|
||||||
OnMouseDown = widget.OnMouseDown;
|
OnMouseDown = widget.OnMouseDown;
|
||||||
|
|
||||||
OnMouseUp = mi => { if (!IsDisabled()) OnClick(); return true; };
|
OnMouseUp = mi => OnClick();
|
||||||
OnKeyPress = _ => OnClick();
|
OnKeyPress = _ => OnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,19 +78,19 @@ namespace OpenRA.Widgets
|
|||||||
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi))
|
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
var disabled = IsDisabled();
|
||||||
// Only fire the onMouseUp event if we successfully lost focus, and were pressed
|
// Only fire the onMouseUp event if we successfully lost focus, and were pressed
|
||||||
if (Focused && mi.Event == MouseInputEvent.Up)
|
if (Focused && mi.Event == MouseInputEvent.Up)
|
||||||
{
|
{
|
||||||
if (Depressed)
|
if (Depressed && !disabled)
|
||||||
OnMouseUp(mi);
|
OnMouseUp(mi);
|
||||||
|
|
||||||
return LoseFocus(mi);
|
return LoseFocus(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mi.Event == MouseInputEvent.Down)
|
if (mi.Event == MouseInputEvent.Down)
|
||||||
{
|
{
|
||||||
// OnMouseDown returns false if the button shouldn't be pressed
|
// OnMouseDown returns false if the button shouldn't be pressed
|
||||||
if (!IsDisabled())
|
if (!disabled)
|
||||||
{
|
{
|
||||||
OnMouseDown(mi);
|
OnMouseDown(mi);
|
||||||
Depressed = true;
|
Depressed = true;
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ namespace OpenRA.Widgets
|
|||||||
public Func<bool> IsVisible;
|
public Func<bool> IsVisible;
|
||||||
public Widget() { IsVisible = () => Visible; }
|
public Widget() { IsVisible = () => Visible; }
|
||||||
protected readonly List<Widget> Children = new List<Widget>();
|
protected readonly List<Widget> Children = new List<Widget>();
|
||||||
public Func<MouseInput,bool> OnMouseUp = _ => false;
|
|
||||||
|
|
||||||
public Widget(Widget widget)
|
public Widget(Widget widget)
|
||||||
{
|
{
|
||||||
@@ -132,8 +131,6 @@ namespace OpenRA.Widgets
|
|||||||
Bounds = widget.Bounds;
|
Bounds = widget.Bounds;
|
||||||
Parent = widget.Parent;
|
Parent = widget.Parent;
|
||||||
|
|
||||||
OnMouseUp = widget.OnMouseUp;
|
|
||||||
|
|
||||||
IsVisible = widget.IsVisible;
|
IsVisible = widget.IsVisible;
|
||||||
|
|
||||||
foreach (var child in widget.Children)
|
foreach (var child in widget.Children)
|
||||||
@@ -269,16 +266,7 @@ namespace OpenRA.Widgets
|
|||||||
return HandleMouseInput(mi);
|
return HandleMouseInput(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hack: Don't eat mouse input that others want
|
public virtual bool HandleMouseInput(MouseInput mi) { return false; }
|
||||||
// TODO: Solve this properly
|
|
||||||
public virtual bool HandleMouseInput(MouseInput mi)
|
|
||||||
{
|
|
||||||
// Apply any special logic added by event handlers; they return true if they caught the input
|
|
||||||
if (mi.Event == MouseInputEvent.Up && OnMouseUp(mi)) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool HandleKeyPressInner(KeyInput e) { return false; }
|
public virtual bool HandleKeyPressInner(KeyInput e) { return false; }
|
||||||
public virtual bool HandleKeyPressOuter(KeyInput e)
|
public virtual bool HandleKeyPressOuter(KeyInput e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -45,28 +46,17 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
void SetupProductionGroupButton(ButtonWidget button, string group)
|
void SetupProductionGroupButton(ButtonWidget button, string group)
|
||||||
{
|
{
|
||||||
|
Action<bool> selectTab = reverse =>
|
||||||
|
{
|
||||||
|
if (queueTabs.QueueGroup == group)
|
||||||
|
queueTabs.SelectNextTab(reverse);
|
||||||
|
else
|
||||||
|
queueTabs.QueueGroup = group;
|
||||||
|
};
|
||||||
|
|
||||||
button.IsDisabled = () => queueTabs.Groups[group].Tabs.Count == 0;
|
button.IsDisabled = () => queueTabs.Groups[group].Tabs.Count == 0;
|
||||||
|
button.OnMouseUp = mi => selectTab(mi.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
button.OnMouseUp = mi =>
|
button.OnKeyPress = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
{
|
|
||||||
if (button.IsDisabled())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (queueTabs.QueueGroup == group)
|
|
||||||
queueTabs.SelectNextTab(mi.Modifiers.HasModifier(Modifiers.Shift));
|
|
||||||
else
|
|
||||||
queueTabs.QueueGroup = group;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
button.OnKeyPress = e =>
|
|
||||||
{
|
|
||||||
if (queueTabs.QueueGroup == group)
|
|
||||||
queueTabs.SelectNextTab(e.Modifiers.HasModifier(Modifiers.Shift));
|
|
||||||
else
|
|
||||||
queueTabs.QueueGroup = group;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
|
|||||||
@@ -21,13 +21,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
[ObjectCreator.Param] string host,
|
[ObjectCreator.Param] string host,
|
||||||
[ObjectCreator.Param] int port )
|
[ObjectCreator.Param] int port )
|
||||||
{
|
{
|
||||||
widget.GetWidget("CONNECTION_BUTTON_ABORT").OnMouseUp = mi => {
|
widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_ABORT").OnMouseUp = mi => {
|
||||||
widget.GetWidget("CONNECTION_BUTTON_ABORT").Parent.Visible = false;
|
widget.GetWidget("CONNECTION_BUTTON_ABORT").Parent.Visible = false;
|
||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
Game.LoadShellMap();
|
Game.LoadShellMap();
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
Widget.OpenWindow("MAINMENU_BG");
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
||||||
@@ -42,18 +41,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
[ObjectCreator.Param] Widget widget,
|
[ObjectCreator.Param] Widget widget,
|
||||||
[ObjectCreator.Param] OrderManager orderManager)
|
[ObjectCreator.Param] OrderManager orderManager)
|
||||||
{
|
{
|
||||||
widget.GetWidget("CONNECTION_BUTTON_CANCEL").OnMouseUp = mi => {
|
widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_CANCEL").OnMouseUp = mi => {
|
||||||
widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false;
|
widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false;
|
||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
Game.LoadShellMap();
|
Game.LoadShellMap();
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
Widget.OpenWindow("MAINMENU_BG");
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
widget.GetWidget("CONNECTION_BUTTON_RETRY").OnMouseUp = mi => {
|
widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_RETRY").OnMouseUp = mi =>
|
||||||
Game.JoinServer(orderManager.Host, orderManager.Port);
|
Game.JoinServer(orderManager.Host, orderManager.Port);
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
widget.GetWidget<LabelWidget>("CONNECTION_FAILED_DESC").GetText = () => string.IsNullOrEmpty(orderManager.ServerError) ?
|
widget.GetWidget<LabelWidget>("CONNECTION_FAILED_DESC").GetText = () => string.IsNullOrEmpty(orderManager.ServerError) ?
|
||||||
"Could not connect to {0}:{1}".F(orderManager.Host, orderManager.Port) : orderManager.ServerError;
|
"Could not connect to {0}:{1}".F(orderManager.Host, orderManager.Port) : orderManager.ServerError;
|
||||||
|
|||||||
@@ -22,12 +22,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var settings = Game.Settings;
|
var settings = Game.Settings;
|
||||||
|
|
||||||
cs.GetWidget("BUTTON_CANCEL").OnMouseUp = mi => {
|
cs.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnMouseUp = mi => Widget.CloseWindow();
|
||||||
Widget.CloseWindow();
|
cs.GetWidget<ButtonWidget>("BUTTON_START").OnMouseUp = mi =>
|
||||||
return true;
|
{
|
||||||
};
|
|
||||||
|
|
||||||
cs.GetWidget("BUTTON_START").OnMouseUp = mi => {
|
|
||||||
settings.Server.Name = cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text;
|
settings.Server.Name = cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text;
|
||||||
settings.Server.ListenPort = int.Parse(cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text);
|
settings.Server.ListenPort = int.Parse(cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text);
|
||||||
settings.Server.ExternalPort = int.Parse(cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text);
|
settings.Server.ExternalPort = int.Parse(cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text);
|
||||||
@@ -37,7 +34,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
// Take a copy so that subsequent settings changes don't affect the server
|
// Take a copy so that subsequent settings changes don't affect the server
|
||||||
Game.CreateServer(new ServerSettings(Game.Settings.Server));
|
Game.CreateServer(new ServerSettings(Game.Settings.Server));
|
||||||
Game.JoinServer(IPAddress.Loopback.ToString(), settings.Server.ListenPort);
|
Game.JoinServer(IPAddress.Loopback.ToString(), settings.Server.ListenPort);
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text = settings.Server.Name ?? "";
|
cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text = settings.Server.Name ?? "";
|
||||||
|
|||||||
@@ -32,12 +32,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var devmodeBG = Widget.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG");
|
var devmodeBG = Widget.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG");
|
||||||
var devModeButton = Widget.RootWidget.GetWidget<ButtonWidget>("INGAME_DEVELOPERMODE_BUTTON");
|
var devModeButton = Widget.RootWidget.GetWidget<ButtonWidget>("INGAME_DEVELOPERMODE_BUTTON");
|
||||||
|
devModeButton.OnMouseUp = mi => devmodeBG.Visible ^= true;
|
||||||
|
|
||||||
devModeButton.OnMouseUp = mi =>
|
|
||||||
{
|
|
||||||
devmodeBG.Visible ^= true;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
var devTrait = world.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
|
var devTrait = world.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
|
||||||
|
|
||||||
|
|||||||
@@ -30,14 +30,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
this.world = world;
|
this.world = world;
|
||||||
var root = Widget.RootWidget.GetWidget("INGAME_ROOT");
|
var root = Widget.RootWidget.GetWidget("INGAME_ROOT");
|
||||||
var diplomacyBG = root.GetWidget("DIPLOMACY_BG");
|
var diplomacyBG = root.GetWidget("DIPLOMACY_BG");
|
||||||
var diplomacy = root.GetWidget("INGAME_DIPLOMACY_BUTTON");
|
var diplomacy = root.GetWidget<ButtonWidget>("INGAME_DIPLOMACY_BUTTON");
|
||||||
|
|
||||||
diplomacy.OnMouseUp = mi =>
|
diplomacy.OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
diplomacyBG.Visible = !diplomacyBG.Visible;
|
diplomacyBG.Visible = !diplomacyBG.Visible;
|
||||||
if (diplomacyBG.IsVisible())
|
if (diplomacyBG.IsVisible())
|
||||||
LayoutDialog(diplomacyBG);
|
LayoutDialog(diplomacyBG);
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
validPlayers = world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count();
|
validPlayers = world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count();
|
||||||
|
|||||||
@@ -82,20 +82,19 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
void ShowInstallMethodDialog()
|
void ShowInstallMethodDialog()
|
||||||
{
|
{
|
||||||
var window = Widget.OpenWindow("INIT_CHOOSEINSTALL");
|
var window = Widget.OpenWindow("INIT_CHOOSEINSTALL");
|
||||||
window.GetWidget("DOWNLOAD").OnMouseUp = mi => { ShowDownloadDialog(); return true; };
|
window.GetWidget<ButtonWidget>("DOWNLOAD").OnMouseUp = mi => ShowDownloadDialog();
|
||||||
window.GetWidget("FROMCD").OnMouseUp = mi => PromptForCD();
|
window.GetWidget<ButtonWidget>("FROMCD").OnMouseUp = mi => PromptForCD();
|
||||||
|
|
||||||
window.GetWidget("QUIT").OnMouseUp = mi => { Game.Exit(); return true; };
|
window.GetWidget<ButtonWidget>("QUIT").OnMouseUp = mi => Game.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PromptForCD()
|
void PromptForCD()
|
||||||
{
|
{
|
||||||
Game.Utilities.PromptFilepathAsync("Select MAIN.MIX on the CD", path =>
|
Game.Utilities.PromptFilepathAsync("Select MAIN.MIX on the CD", path =>
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
Game.RunAfterTick(() => InstallFromCD(Path.GetDirectoryName(path)));
|
Game.RunAfterTick(() => InstallFromCD(Path.GetDirectoryName(path)));
|
||||||
});
|
});
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallFromCD(string path)
|
void InstallFromCD(string path)
|
||||||
@@ -106,8 +105,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
// TODO: Handle cancelling copy
|
// TODO: Handle cancelling copy
|
||||||
window.GetWidget<ButtonWidget>("CANCEL").IsVisible = () => false;
|
window.GetWidget<ButtonWidget>("CANCEL").IsVisible = () => false;
|
||||||
window.GetWidget("CANCEL").OnMouseUp = mi => { ShowInstallMethodDialog(); return true; };
|
window.GetWidget<ButtonWidget>("CANCEL").OnMouseUp = mi => ShowInstallMethodDialog();
|
||||||
window.GetWidget("RETRY").OnMouseUp = mi => PromptForCD();
|
window.GetWidget<ButtonWidget>("RETRY").OnMouseUp = mi => PromptForCD();
|
||||||
|
|
||||||
var t = new Thread( _ =>
|
var t = new Thread( _ =>
|
||||||
{
|
{
|
||||||
@@ -160,8 +159,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
};
|
};
|
||||||
|
|
||||||
var dl = new Download(Info.PackageURL, file, onDownloadChange, onDownloadComplete);
|
var dl = new Download(Info.PackageURL, file, onDownloadChange, onDownloadComplete);
|
||||||
window.GetWidget("CANCEL").OnMouseUp = mi => { dl.Cancel(); ShowInstallMethodDialog(); return true; };
|
window.GetWidget<ButtonWidget>("CANCEL").OnMouseUp = mi => { dl.Cancel(); ShowInstallMethodDialog(); };
|
||||||
window.GetWidget("RETRY").OnMouseUp = mi => { dl.Cancel(); ShowDownloadDialog(); return true; };
|
window.GetWidget<ButtonWidget>("RETRY").OnMouseUp = mi => { dl.Cancel(); ShowDownloadDialog(); };
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowError(Widget window, string e)
|
void ShowError(Widget window, string e)
|
||||||
|
|||||||
@@ -28,48 +28,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
gameRoot = r.GetWidget("INGAME_ROOT");
|
gameRoot = r.GetWidget("INGAME_ROOT");
|
||||||
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
|
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
|
||||||
|
|
||||||
r.GetWidget("INGAME_OPTIONS_BUTTON").OnMouseUp = mi => {
|
r.GetWidget<ButtonWidget>("INGAME_OPTIONS_BUTTON").OnMouseUp = mi =>
|
||||||
optionsBG.Visible = !optionsBG.Visible;
|
optionsBG.Visible = !optionsBG.Visible;
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
optionsBG.GetWidget("DISCONNECT").OnMouseUp = mi => {
|
optionsBG.GetWidget<ButtonWidget>("DISCONNECT").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
optionsBG.Visible = false;
|
optionsBG.Visible = false;
|
||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
Game.LoadShellMap();
|
Game.LoadShellMap();
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
Widget.OpenWindow("MAINMENU_BG");
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
optionsBG.GetWidget("SETTINGS").OnMouseUp = mi => {
|
optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnMouseUp = mi => Widget.OpenWindow("SETTINGS_MENU");
|
||||||
Widget.OpenWindow("SETTINGS_MENU");
|
optionsBG.GetWidget<ButtonWidget>("MUSIC").OnMouseUp = mi => Widget.OpenWindow("MUSIC_MENU");
|
||||||
return true;
|
optionsBG.GetWidget<ButtonWidget>("RESUME").OnMouseUp = mi => optionsBG.Visible = false;
|
||||||
};
|
|
||||||
|
|
||||||
optionsBG.GetWidget("MUSIC").OnMouseUp = mi => {
|
optionsBG.GetWidget<ButtonWidget>("SURRENDER").OnMouseUp = mi =>
|
||||||
Widget.OpenWindow("MUSIC_MENU");
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
optionsBG.GetWidget("RESUME").OnMouseUp = mi =>
|
|
||||||
{
|
|
||||||
optionsBG.Visible = false;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
optionsBG.GetWidget("SURRENDER").OnMouseUp = mi =>
|
|
||||||
{
|
|
||||||
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
optionsBG.GetWidget("SURRENDER").IsVisible = () => (world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined);
|
optionsBG.GetWidget("SURRENDER").IsVisible = () => (world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined);
|
||||||
|
optionsBG.GetWidget<ButtonWidget>("QUIT").OnMouseUp = mi => Game.Exit();
|
||||||
optionsBG.GetWidget("QUIT").OnMouseUp = mi => {
|
|
||||||
Game.Exit();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
var postgameBG = gameRoot.GetWidget("POSTGAME_BG");
|
var postgameBG = gameRoot.GetWidget("POSTGAME_BG");
|
||||||
var postgameText = postgameBG.GetWidget<LabelWidget>("TEXT");
|
var postgameText = postgameBG.GetWidget<LabelWidget>("TEXT");
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
Widget gameRoot;
|
Widget gameRoot;
|
||||||
|
|
||||||
|
// WTF duplication
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public IngameObserverChromeLogic([ObjectCreator.Param] World world)
|
public IngameObserverChromeLogic([ObjectCreator.Param] World world)
|
||||||
{
|
{
|
||||||
@@ -28,42 +29,23 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
gameRoot = r.GetWidget("OBSERVER_ROOT");
|
gameRoot = r.GetWidget("OBSERVER_ROOT");
|
||||||
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
|
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
|
||||||
|
|
||||||
r.GetWidget("INGAME_OPTIONS_BUTTON").OnMouseUp = mi => {
|
r.GetWidget<ButtonWidget>("INGAME_OPTIONS_BUTTON").OnMouseUp = mi =>
|
||||||
optionsBG.Visible = !optionsBG.Visible;
|
optionsBG.Visible = !optionsBG.Visible;
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
optionsBG.GetWidget("DISCONNECT").OnMouseUp = mi => {
|
optionsBG.GetWidget<ButtonWidget>("DISCONNECT").OnMouseUp = mi =>
|
||||||
|
{
|
||||||
optionsBG.Visible = false;
|
optionsBG.Visible = false;
|
||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
Game.LoadShellMap();
|
Game.LoadShellMap();
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
Widget.OpenWindow("MAINMENU_BG");
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
optionsBG.GetWidget("SETTINGS").OnMouseUp = mi => {
|
optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnMouseUp = mi => Widget.OpenWindow("SETTINGS_MENU");
|
||||||
Widget.OpenWindow("SETTINGS_MENU");
|
optionsBG.GetWidget<ButtonWidget>("MUSIC").OnMouseUp = mi => Widget.OpenWindow("MUSIC_MENU");
|
||||||
return true;
|
optionsBG.GetWidget<ButtonWidget>("RESUME").OnMouseUp = mi => optionsBG.Visible = false;
|
||||||
};
|
optionsBG.GetWidget<ButtonWidget>("SURRENDER").IsVisible = () => false;
|
||||||
|
optionsBG.GetWidget<ButtonWidget>("QUIT").OnMouseUp = mi => Game.Exit();
|
||||||
optionsBG.GetWidget("MUSIC").OnMouseUp = mi => {
|
|
||||||
Widget.OpenWindow("MUSIC_MENU");
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
optionsBG.GetWidget("RESUME").OnMouseUp = mi =>
|
|
||||||
{
|
|
||||||
optionsBG.Visible = false;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
optionsBG.GetWidget("SURRENDER").IsVisible = () => false;
|
|
||||||
|
|
||||||
optionsBG.GetWidget("QUIT").OnMouseUp = mi => {
|
|
||||||
Game.Exit();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnregisterEvents()
|
public void UnregisterEvents()
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
.ToDictionary(a => a.Race, a => a.Name);
|
.ToDictionary(a => a.Race, a => a.Name);
|
||||||
CountryNames.Add("random", "Random");
|
CountryNames.Add("random", "Random");
|
||||||
|
|
||||||
var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON");
|
var mapButton = lobby.GetWidget<ButtonWidget>("CHANGEMAP_BUTTON");
|
||||||
mapButton.OnMouseUp = mi =>
|
mapButton.OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
Widget.OpenWindow("MAP_CHOOSER", new WidgetArgs()
|
Widget.OpenWindow("MAP_CHOOSER", new WidgetArgs()
|
||||||
@@ -105,19 +105,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{ "orderManager", orderManager },
|
{ "orderManager", orderManager },
|
||||||
{ "mapName", MapUid }
|
{ "mapName", MapUid }
|
||||||
});
|
});
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
||||||
|
|
||||||
var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON");
|
var disconnectButton = lobby.GetWidget<ButtonWidget>("DISCONNECT_BUTTON");
|
||||||
disconnectButton.OnMouseUp = mi =>
|
disconnectButton.OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
Game.LoadShellMap();
|
Game.LoadShellMap();
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
Widget.OpenWindow("MAINMENU_BG");
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var lockTeamsCheckbox = lobby.GetWidget<CheckboxWidget>("LOCKTEAMS_CHECKBOX");
|
var lockTeamsCheckbox = lobby.GetWidget<CheckboxWidget>("LOCKTEAMS_CHECKBOX");
|
||||||
@@ -349,7 +347,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var join = template.GetWidget<ButtonWidget>("JOIN");
|
var join = template.GetWidget<ButtonWidget>("JOIN");
|
||||||
if (join != null)
|
if (join != null)
|
||||||
{
|
{
|
||||||
join.OnMouseUp = _ => { orderManager.IssueOrder(Order.Command("slot " + s.PlayerReference)); return true; };
|
join.OnMouseUp = _ => orderManager.IssueOrder(Order.Command("slot " + s.PlayerReference));
|
||||||
join.IsVisible = () => !s.Closed && c == null && orderManager.LocalClient.State != Session.ClientState.Ready;
|
join.IsVisible = () => !s.Closed && c == null && orderManager.LocalClient.State != Session.ClientState.Ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,11 +425,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
var kickButton = template.GetWidget<ButtonWidget>("KICK");
|
var kickButton = template.GetWidget<ButtonWidget>("KICK");
|
||||||
kickButton.IsVisible = () => Game.IsHost && c.Index != orderManager.LocalClient.Index;
|
kickButton.IsVisible = () => Game.IsHost && c.Index != orderManager.LocalClient.Index;
|
||||||
kickButton.OnMouseUp = mi =>
|
kickButton.OnMouseUp = mi => orderManager.IssueOrder(Order.Command("kick " + c.Slot));
|
||||||
{
|
|
||||||
orderManager.IssueOrder(Order.Command("kick " + c.Slot));
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template.IsVisible = () => true;
|
template.IsVisible = () => true;
|
||||||
@@ -490,11 +484,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
var kickButton = template.GetWidget<ButtonWidget>("KICK");
|
var kickButton = template.GetWidget<ButtonWidget>("KICK");
|
||||||
kickButton.IsVisible = () => Game.IsHost && client.Index != orderManager.LocalClient.Index;
|
kickButton.IsVisible = () => Game.IsHost && client.Index != orderManager.LocalClient.Index;
|
||||||
kickButton.OnMouseUp = mi =>
|
kickButton.OnMouseUp = mi => orderManager.IssueOrder(Order.Command("kick " + client.Index));
|
||||||
{
|
|
||||||
orderManager.IssueOrder(Order.Command("kick " + client.Index));
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template.IsVisible = () => true;
|
template.IsVisible = () => true;
|
||||||
@@ -506,7 +496,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var spec = NewSpectatorTemplate.Clone();
|
var spec = NewSpectatorTemplate.Clone();
|
||||||
var btn = spec.GetWidget<ButtonWidget>("SPECTATE");
|
var btn = spec.GetWidget<ButtonWidget>("SPECTATE");
|
||||||
btn.OnMouseUp = _ => { orderManager.IssueOrder(Order.Command("spectate")); return true; };
|
btn.OnMouseUp = _ => orderManager.IssueOrder(Order.Command("spectate"));;
|
||||||
spec.IsVisible = () => true;
|
spec.IsVisible = () => true;
|
||||||
Players.AddChild(spec);
|
Players.AddChild(spec);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
public MainMenuButtonsLogic([ObjectCreator.Param] Widget widget)
|
public MainMenuButtonsLogic([ObjectCreator.Param] Widget widget)
|
||||||
{
|
{
|
||||||
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "PERF_BG" );
|
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "PERF_BG" );
|
||||||
widget.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp = mi => { Widget.OpenWindow("JOINSERVER_BG"); return true; };
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_JOIN").OnMouseUp = mi => Widget.OpenWindow("JOINSERVER_BG");
|
||||||
widget.GetWidget("MAINMENU_BUTTON_CREATE").OnMouseUp = mi => { Widget.OpenWindow("CREATESERVER_BG"); return true; };
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_CREATE").OnMouseUp = mi => Widget.OpenWindow("CREATESERVER_BG");
|
||||||
widget.GetWidget("MAINMENU_BUTTON_SETTINGS").OnMouseUp = mi => { Widget.OpenWindow("SETTINGS_MENU"); return true; };
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_SETTINGS").OnMouseUp = mi => Widget.OpenWindow("SETTINGS_MENU");
|
||||||
widget.GetWidget("MAINMENU_BUTTON_MUSIC").OnMouseUp = mi => { Widget.OpenWindow("MUSIC_MENU"); return true; };
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_MUSIC").OnMouseUp = mi => Widget.OpenWindow("MUSIC_MENU");
|
||||||
widget.GetWidget("MAINMENU_BUTTON_REPLAY_VIEWER").OnMouseUp = mi => { Widget.OpenWindow("REPLAYBROWSER_BG"); return true; };
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_REPLAY_VIEWER").OnMouseUp = mi => Widget.OpenWindow("REPLAYBROWSER_BG");
|
||||||
widget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => { Game.Exit(); return true; };
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => Game.Exit();
|
||||||
|
|
||||||
DisplayModSelector();
|
DisplayModSelector();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,14 +47,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
orderManager.IssueOrder(Order.Command("map " + Map.Uid));
|
orderManager.IssueOrder(Order.Command("map " + Map.Uid));
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnMouseUp = mi =>
|
bg.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnMouseUp = mi => Widget.CloseWindow();
|
||||||
{
|
|
||||||
Widget.CloseWindow();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
scrollpanel = bg.GetWidget<ScrollPanelWidget>("MAP_LIST");
|
scrollpanel = bg.GetWidget<ScrollPanelWidget>("MAP_LIST");
|
||||||
itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");
|
itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");
|
||||||
|
|||||||
@@ -24,10 +24,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var bg = Widget.RootWidget.GetWidget("MUSIC_MENU");
|
var bg = Widget.RootWidget.GetWidget("MUSIC_MENU");
|
||||||
CurrentSong = GetNextSong();
|
CurrentSong = GetNextSong();
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_CLOSE").OnMouseUp = mi => {
|
bg.GetWidget<ButtonWidget>("BUTTON_CLOSE").OnMouseUp = mi => {
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -40,46 +39,42 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
*/
|
*/
|
||||||
bg.GetWidget("BUTTON_INSTALL").IsVisible = () => false;
|
bg.GetWidget("BUTTON_INSTALL").IsVisible = () => false;
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi =>
|
bg.GetWidget<ButtonWidget>("BUTTON_PLAY").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
if (CurrentSong == null)
|
if (CurrentSong == null)
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
Sound.PlayMusicThen(Rules.Music[CurrentSong],
|
Sound.PlayMusicThen(Rules.Music[CurrentSong],
|
||||||
() => bg.GetWidget(Game.Settings.Sound.Repeat ? "BUTTON_PLAY" : "BUTTON_NEXT").OnMouseUp(new MouseInput()));
|
() => bg.GetWidget<ButtonWidget>(Game.Settings.Sound.Repeat ? "BUTTON_PLAY" : "BUTTON_NEXT")
|
||||||
|
.OnMouseUp(new MouseInput()));
|
||||||
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_PAUSE").OnMouseUp = mi =>
|
bg.GetWidget<ButtonWidget>("BUTTON_PAUSE").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
Sound.PauseMusic();
|
Sound.PauseMusic();
|
||||||
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||||
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_STOP").OnMouseUp = mi =>
|
bg.GetWidget<ButtonWidget>("BUTTON_STOP").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
Sound.StopMusic();
|
Sound.StopMusic();
|
||||||
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||||
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_NEXT").OnMouseUp = mi =>
|
bg.GetWidget<ButtonWidget>("BUTTON_NEXT").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
CurrentSong = GetNextSong();
|
CurrentSong = GetNextSong();
|
||||||
return bg.GetWidget("BUTTON_PLAY").OnMouseUp(mi);
|
bg.GetWidget<ButtonWidget>("BUTTON_PLAY").OnMouseUp(mi);
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget("BUTTON_PREV").OnMouseUp = mi =>
|
bg.GetWidget<ButtonWidget>("BUTTON_PREV").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
CurrentSong = GetPrevSong();
|
CurrentSong = GetPrevSong();
|
||||||
return bg.GetWidget("BUTTON_PLAY").OnMouseUp(mi);
|
bg.GetWidget<ButtonWidget>("BUTTON_PLAY").OnMouseUp(mi);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -115,7 +110,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
if (CurrentSong == null)
|
if (CurrentSong == null)
|
||||||
CurrentSong = song;
|
CurrentSong = song;
|
||||||
|
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate, () => CurrentSong == song, () => { CurrentSong = song; bg.GetWidget("BUTTON_PLAY").OnMouseUp(new MouseInput()); });
|
var item = ScrollItemWidget.Setup(itemTemplate, () => CurrentSong == song, () => { CurrentSong = song; bg.GetWidget<ButtonWidget>("BUTTON_PLAY").OnMouseUp(new MouseInput()); });
|
||||||
item.GetWidget<LabelWidget>("TITLE").GetText = () => Rules.Music[song].Title;
|
item.GetWidget<LabelWidget>("TITLE").GetText = () => Rules.Music[song].Title;
|
||||||
item.GetWidget<LabelWidget>("LENGTH").GetText = () => "{0:D1}:{1:D2}".F(Rules.Music[song].Length / 60, Rules.Music[song].Length % 60);
|
item.GetWidget<LabelWidget>("LENGTH").GetText = () => "{0:D1}:{1:D2}".F(Rules.Music[song].Length / 60, Rules.Music[song].Length % 60);
|
||||||
ml.AddChild(item);
|
ml.AddChild(item);
|
||||||
|
|||||||
@@ -27,11 +27,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
this.widget = widget;
|
this.widget = widget;
|
||||||
|
|
||||||
widget.GetWidget("CANCEL_BUTTON").OnMouseUp = mi =>
|
widget.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnMouseUp = mi => Widget.CloseWindow();
|
||||||
{
|
|
||||||
Widget.CloseWindow();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* find some replays? */
|
/* find some replays? */
|
||||||
var rl = widget.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
|
var rl = widget.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
|
||||||
@@ -45,14 +41,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
foreach (var replayFile in Directory.GetFiles(replayDir, "*.rep").Reverse())
|
foreach (var replayFile in Directory.GetFiles(replayDir, "*.rep").Reverse())
|
||||||
AddReplay(rl, replayFile, template);
|
AddReplay(rl, replayFile, template);
|
||||||
|
|
||||||
widget.GetWidget("WATCH_BUTTON").OnMouseUp = mi =>
|
widget.GetWidget<ButtonWidget>("WATCH_BUTTON").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
if (currentReplay != null)
|
if (currentReplay != null)
|
||||||
{
|
{
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Game.JoinReplay(CurrentReplay);
|
Game.JoinReplay(CurrentReplay);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
widget.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null;
|
widget.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var sl = bg.GetWidget<ScrollPanelWidget>("SERVER_LIST");
|
var sl = bg.GetWidget<ScrollPanelWidget>("SERVER_LIST");
|
||||||
ServerTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");
|
ServerTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");
|
||||||
|
|
||||||
bg.GetWidget("REFRESH_BUTTON").OnMouseUp = mi =>
|
bg.GetWidget<ButtonWidget>("REFRESH_BUTTON").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
bg.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
|
bg.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
|
||||||
bg.GetWidget<LabelWidget>("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list...";
|
bg.GetWidget<LabelWidget>("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list...";
|
||||||
@@ -61,30 +61,22 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
currentServer = null;
|
currentServer = null;
|
||||||
|
|
||||||
ServerList.Query(RefreshServerList);
|
ServerList.Query(RefreshServerList);
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget("CANCEL_BUTTON").OnMouseUp = mi =>
|
bg.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnMouseUp = mi => Widget.CloseWindow();
|
||||||
{
|
bg.GetWidget<ButtonWidget>("DIRECTCONNECT_BUTTON").OnMouseUp = mi =>
|
||||||
Widget.CloseWindow();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
bg.GetWidget("DIRECTCONNECT_BUTTON").OnMouseUp = mi =>
|
|
||||||
{
|
{
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Widget.OpenWindow("DIRECTCONNECT_BG");
|
Widget.OpenWindow("DIRECTCONNECT_BG");
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget("JOIN_BUTTON").OnMouseUp = mi =>
|
bg.GetWidget<ButtonWidget>("JOIN_BUTTON").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
if (currentServer == null)
|
if (currentServer == null)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Game.JoinServer(currentServer.Address.Split(':')[0], int.Parse(currentServer.Address.Split(':')[1]));
|
Game.JoinServer(currentServer.Address.Split(':')[0], int.Parse(currentServer.Address.Split(':')[1]));
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,12 +163,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.Player.LastServer;
|
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.Player.LastServer;
|
||||||
|
|
||||||
dc.GetWidget("JOIN_BUTTON").OnMouseUp = mi =>
|
dc.GetWidget<ButtonWidget>("JOIN_BUTTON").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
|
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
|
||||||
var cpts = address.Split(':').ToArray();
|
var cpts = address.Split(':').ToArray();
|
||||||
if (cpts.Length < 1 || cpts.Length > 2)
|
if (cpts.Length < 1 || cpts.Length > 2)
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
int port;
|
int port;
|
||||||
if (cpts.Length != 2 || !int.TryParse(cpts[1], out port))
|
if (cpts.Length != 2 || !int.TryParse(cpts[1], out port))
|
||||||
@@ -187,14 +179,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Game.JoinServer(cpts[0], port);
|
Game.JoinServer(cpts[0], port);
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dc.GetWidget("CANCEL_BUTTON").OnMouseUp = mi =>
|
dc.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
Widget.OpenWindow("MAINMENU_BG");
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user