restart button added for singleplayer in cnc, ra, d2k

This commit is contained in:
Alexander Heinz
2015-01-31 13:58:19 +01:00
committed by Whinis
parent 5516291c60
commit e0c033fe99
5 changed files with 126 additions and 1 deletions

View File

@@ -55,6 +55,39 @@ namespace OpenRA.Mods.Common.Widgets
onCancel();
};
}
/**
* open confirmation dialog for mission / game restart
*/
public static void PromptAbortMission(World world, string title, string text, Action onAbort, Action onCancel = null, Action closeMenu = null)
{
var isMultiplayer = !world.LobbyInfo.IsSinglePlayer && !world.IsReplay;
var prompt = Ui.OpenWindow("ABORT_MISSION_PROMPT");
prompt.Get<LabelWidget>("PROMPT_TITLE").GetText = () => title;
prompt.Get<LabelWidget>("PROMPT_TEXT").GetText = () => text;
prompt.Get<ButtonWidget>("ABORT_BUTTON").OnClick = () =>
{
Ui.CloseWindow();
onAbort();
};
var restartButton = prompt.Get<ButtonWidget>("RESTART_BUTTON");
restartButton.IsVisible = () => !isMultiplayer;
restartButton.OnClick = () =>
{
if (closeMenu != null)
closeMenu();
Ui.CloseWindow();
Game.RestartGame();
};
prompt.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
{
Ui.CloseWindow();
if (onCancel != null)
onCancel();
};
}
public static void TextInputPrompt(
string title, string prompt, string initialText,