Add quit button to connection lost panel
This commit is contained in:
committed by
Matthias Mailänder
parent
482f2fc335
commit
c4bd9fb7aa
@@ -42,6 +42,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "connection", connection },
|
{ "connection", connection },
|
||||||
{ "password", password },
|
{ "password", password },
|
||||||
{ "onAbort", onAbort },
|
{ "onAbort", onAbort },
|
||||||
|
{ "onQuit", null },
|
||||||
{ "onRetry", onRetry }
|
{ "onRetry", onRetry }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -102,16 +103,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
bool passwordOffsetAdjusted;
|
bool passwordOffsetAdjusted;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public ConnectionFailedLogic(Widget widget, ModData modData, OrderManager orderManager, NetworkConnection connection, string password, Action onAbort, Action<string> onRetry)
|
public ConnectionFailedLogic(Widget widget, ModData modData, OrderManager orderManager, NetworkConnection connection, string password, Action onAbort, Action onQuit, Action<string> onRetry)
|
||||||
{
|
{
|
||||||
var panel = widget;
|
var panel = widget;
|
||||||
var abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON");
|
var abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON");
|
||||||
|
var quitButton = panel.Get<ButtonWidget>("QUIT_BUTTON");
|
||||||
var retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON");
|
var retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON");
|
||||||
|
var leaving = false;
|
||||||
|
|
||||||
abortButton.Visible = onAbort != null;
|
abortButton.Visible = onAbort != null;
|
||||||
|
abortButton.IsDisabled = () => leaving;
|
||||||
abortButton.OnClick = () => { Ui.CloseWindow(); onAbort(); };
|
abortButton.OnClick = () => { Ui.CloseWindow(); onAbort(); };
|
||||||
|
|
||||||
|
quitButton.Visible = onQuit != null;
|
||||||
|
quitButton.IsDisabled = () => leaving;
|
||||||
|
quitButton.OnClick = () => { onQuit(); leaving = true; };
|
||||||
|
|
||||||
retryButton.Visible = onRetry != null;
|
retryButton.Visible = onRetry != null;
|
||||||
|
retryButton.IsDisabled = () => leaving;
|
||||||
retryButton.OnClick = () =>
|
retryButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
var pass = passwordField != null && passwordField.IsVisible() ? passwordField.Text : password;
|
var pass = passwordField != null && passwordField.IsVisible() ? passwordField.Text : password;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
public class DisconnectWatcherLogic : ChromeLogic
|
public class DisconnectWatcherLogic : ChromeLogic
|
||||||
{
|
{
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public DisconnectWatcherLogic(Widget widget, OrderManager orderManager)
|
public DisconnectWatcherLogic(Widget widget, World world, OrderManager orderManager)
|
||||||
{
|
{
|
||||||
var disconnected = false;
|
var disconnected = false;
|
||||||
widget.Get<LogicTickerWidget>("DISCONNECT_WATCHER").OnTick = () =>
|
widget.Get<LogicTickerWidget>("DISCONNECT_WATCHER").OnTick = () =>
|
||||||
@@ -34,6 +34,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "password", CurrentServerSettings.Password },
|
{ "password", CurrentServerSettings.Password },
|
||||||
{ "connection", connection },
|
{ "connection", connection },
|
||||||
{ "onAbort", null },
|
{ "onAbort", null },
|
||||||
|
{ "onQuit", () => IngameMenuLogic.OnQuit(world) },
|
||||||
{ "onRetry", null }
|
{ "onRetry", null }
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnQuit()
|
public static void OnQuit(World world)
|
||||||
{
|
{
|
||||||
// TODO: Create a mechanism to do things like this cleaner. Also needed for scripted missions
|
// TODO: Create a mechanism to do things like this cleaner. Also needed for scripted missions
|
||||||
if (world.Type == WorldType.Regular)
|
if (world.Type == WorldType.Regular)
|
||||||
@@ -221,10 +221,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
leaving = true;
|
|
||||||
|
|
||||||
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
|
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
|
||||||
var exitDelay = iop?.ExitDelay ?? 0;
|
var exitDelay = iop?.ExitDelay ?? 0;
|
||||||
|
var mpe = world.WorldActor.TraitOrDefault<MenuPaletteEffect>();
|
||||||
if (mpe != null)
|
if (mpe != null)
|
||||||
{
|
{
|
||||||
Game.RunAfterDelay(exitDelay, () =>
|
Game.RunAfterDelay(exitDelay, () =>
|
||||||
@@ -295,7 +294,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ConfirmationDialogs.ButtonPrompt(modData,
|
ConfirmationDialogs.ButtonPrompt(modData,
|
||||||
title: LeaveMissionTitle,
|
title: LeaveMissionTitle,
|
||||||
text: LeaveMissionPrompt,
|
text: LeaveMissionPrompt,
|
||||||
onConfirm: OnQuit,
|
onConfirm: () => { OnQuit(world); leaving = true; },
|
||||||
onCancel: ShowMenu,
|
onCancel: ShowMenu,
|
||||||
confirmText: LeaveMissionAccept,
|
confirmText: LeaveMissionAccept,
|
||||||
cancelText: LeaveMissionCancel);
|
cancelText: LeaveMissionCancel);
|
||||||
@@ -499,11 +498,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
title: ExitMapEditorTitle,
|
title: ExitMapEditorTitle,
|
||||||
text: deletedOrUnavailable ? ExitMapEditorPromptDeleted : ExitMapEditorPromptUnsaved,
|
text: deletedOrUnavailable ? ExitMapEditorPromptDeleted : ExitMapEditorPromptUnsaved,
|
||||||
confirmText: deletedOrUnavailable ? ExitMapEditorAnywayConfirm : ExitMapEditorConfirm,
|
confirmText: deletedOrUnavailable ? ExitMapEditorAnywayConfirm : ExitMapEditorConfirm,
|
||||||
onConfirm: OnQuit,
|
onConfirm: () => { OnQuit(world); leaving = true; },
|
||||||
onCancel: ShowMenu);
|
onCancel: ShowMenu);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
OnQuit();
|
{
|
||||||
|
OnQuit(world);
|
||||||
|
leaving = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "connection", connection },
|
{ "connection", connection },
|
||||||
{ "password", password },
|
{ "password", password },
|
||||||
{ "onAbort", onExit },
|
{ "onAbort", onExit },
|
||||||
|
{ "onQuit", null },
|
||||||
{ "onRetry", onRetry }
|
{ "onRetry", onRetry }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,12 @@ Container@CONNECTIONFAILED_PANEL:
|
|||||||
Width: 140
|
Width: 140
|
||||||
Height: 35
|
Height: 35
|
||||||
Text: Abort
|
Text: Abort
|
||||||
|
Button@QUIT_BUTTON:
|
||||||
|
Key: escape
|
||||||
|
Y: 84
|
||||||
|
Width: 140
|
||||||
|
Height: 35
|
||||||
|
Text: Quit
|
||||||
Button@RETRY_BUTTON:
|
Button@RETRY_BUTTON:
|
||||||
Key: return
|
Key: return
|
||||||
X: 230
|
X: 230
|
||||||
|
|||||||
@@ -57,6 +57,14 @@ Background@CONNECTIONFAILED_PANEL:
|
|||||||
Text: Abort
|
Text: Abort
|
||||||
Font: Bold
|
Font: Bold
|
||||||
Key: escape
|
Key: escape
|
||||||
|
Button@QUIT_BUTTON:
|
||||||
|
X: PARENT_RIGHT - 180
|
||||||
|
Y: PARENT_BOTTOM - 45
|
||||||
|
Width: 160
|
||||||
|
Height: 25
|
||||||
|
Text: Quit
|
||||||
|
Font: Bold
|
||||||
|
Key: escape
|
||||||
|
|
||||||
Background@CONNECTING_PANEL:
|
Background@CONNECTING_PANEL:
|
||||||
Logic: ConnectionLogic
|
Logic: ConnectionLogic
|
||||||
|
|||||||
Reference in New Issue
Block a user