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 },
|
||||
{ "password", password },
|
||||
{ "onAbort", onAbort },
|
||||
{ "onQuit", null },
|
||||
{ "onRetry", onRetry }
|
||||
});
|
||||
}
|
||||
@@ -102,16 +103,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
bool passwordOffsetAdjusted;
|
||||
|
||||
[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 abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON");
|
||||
var quitButton = panel.Get<ButtonWidget>("QUIT_BUTTON");
|
||||
var retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON");
|
||||
var leaving = false;
|
||||
|
||||
abortButton.Visible = onAbort != null;
|
||||
abortButton.IsDisabled = () => leaving;
|
||||
abortButton.OnClick = () => { Ui.CloseWindow(); onAbort(); };
|
||||
|
||||
quitButton.Visible = onQuit != null;
|
||||
quitButton.IsDisabled = () => leaving;
|
||||
quitButton.OnClick = () => { onQuit(); leaving = true; };
|
||||
|
||||
retryButton.Visible = onRetry != null;
|
||||
retryButton.IsDisabled = () => leaving;
|
||||
retryButton.OnClick = () =>
|
||||
{
|
||||
var pass = passwordField != null && passwordField.IsVisible() ? passwordField.Text : password;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public class DisconnectWatcherLogic : ChromeLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public DisconnectWatcherLogic(Widget widget, OrderManager orderManager)
|
||||
public DisconnectWatcherLogic(Widget widget, World world, OrderManager orderManager)
|
||||
{
|
||||
var disconnected = false;
|
||||
widget.Get<LogicTickerWidget>("DISCONNECT_WATCHER").OnTick = () =>
|
||||
@@ -34,6 +34,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ "password", CurrentServerSettings.Password },
|
||||
{ "connection", connection },
|
||||
{ "onAbort", null },
|
||||
{ "onQuit", () => IngameMenuLogic.OnQuit(world) },
|
||||
{ "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
|
||||
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 exitDelay = iop?.ExitDelay ?? 0;
|
||||
var mpe = world.WorldActor.TraitOrDefault<MenuPaletteEffect>();
|
||||
if (mpe != null)
|
||||
{
|
||||
Game.RunAfterDelay(exitDelay, () =>
|
||||
@@ -295,7 +294,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
ConfirmationDialogs.ButtonPrompt(modData,
|
||||
title: LeaveMissionTitle,
|
||||
text: LeaveMissionPrompt,
|
||||
onConfirm: OnQuit,
|
||||
onConfirm: () => { OnQuit(world); leaving = true; },
|
||||
onCancel: ShowMenu,
|
||||
confirmText: LeaveMissionAccept,
|
||||
cancelText: LeaveMissionCancel);
|
||||
@@ -499,11 +498,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
title: ExitMapEditorTitle,
|
||||
text: deletedOrUnavailable ? ExitMapEditorPromptDeleted : ExitMapEditorPromptUnsaved,
|
||||
confirmText: deletedOrUnavailable ? ExitMapEditorAnywayConfirm : ExitMapEditorConfirm,
|
||||
onConfirm: OnQuit,
|
||||
onConfirm: () => { OnQuit(world); leaving = true; },
|
||||
onCancel: ShowMenu);
|
||||
}
|
||||
else
|
||||
OnQuit();
|
||||
{
|
||||
OnQuit(world);
|
||||
leaving = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ "connection", connection },
|
||||
{ "password", password },
|
||||
{ "onAbort", onExit },
|
||||
{ "onQuit", null },
|
||||
{ "onRetry", onRetry }
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user