restart button added for singleplayer in cnc, ra, d2k
This commit is contained in:
@@ -175,6 +175,12 @@ namespace OpenRA
|
|||||||
GC.Collect();
|
GC.Collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void RestartGame()
|
||||||
|
{
|
||||||
|
OrderManager.World.EndGame();
|
||||||
|
StartGame(OrderManager.World.Map.Uid, WorldType.Regular);
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsHost
|
public static bool IsHost
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -55,6 +55,39 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
onCancel();
|
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(
|
public static void TextInputPrompt(
|
||||||
string title, string prompt, string initialText,
|
string title, string prompt, string initialText,
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
hideMenu = true;
|
hideMenu = true;
|
||||||
ConfirmationDialogs.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, showMenu);
|
ConfirmationDialogs.PromptAbortMission(world, "Abort Mission", "Leave this game and return to the menu?", onQuit, showMenu, closeMenu);
|
||||||
};
|
};
|
||||||
|
|
||||||
var exitEditorButton = menu.Get<ButtonWidget>("EXIT_EDITOR");
|
var exitEditorButton = menu.Get<ButtonWidget>("EXIT_EDITOR");
|
||||||
|
|||||||
@@ -200,6 +200,50 @@ Container@CANCEL_PROMPT:
|
|||||||
Height: 35
|
Height: 35
|
||||||
Text: Cancel
|
Text: Cancel
|
||||||
|
|
||||||
|
Container@ABORT_MISSION_PROMPT:
|
||||||
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
|
Y: (WINDOW_BOTTOM - 90)/2
|
||||||
|
Width: 500
|
||||||
|
Height: 125
|
||||||
|
Children:
|
||||||
|
Label@PROMPT_TITLE:
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Y: 0-25
|
||||||
|
Font: BigBold
|
||||||
|
Contrast: true
|
||||||
|
Align: Center
|
||||||
|
Background@bg:
|
||||||
|
Width: 500
|
||||||
|
Height: 90
|
||||||
|
Background: panel-black
|
||||||
|
Children:
|
||||||
|
Label@PROMPT_TEXT:
|
||||||
|
Y: (PARENT_BOTTOM-HEIGHT)/2
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 25
|
||||||
|
Font: Bold
|
||||||
|
Align: Center
|
||||||
|
Button@ABORT_BUTTON:
|
||||||
|
Key: return
|
||||||
|
X: 360
|
||||||
|
Y: 89
|
||||||
|
Width: 140
|
||||||
|
Height: 35
|
||||||
|
Text: Abort
|
||||||
|
Button@RESTART_BUTTON:
|
||||||
|
Key: r
|
||||||
|
X: 180
|
||||||
|
Y: 89
|
||||||
|
Width: 140
|
||||||
|
Height: 35
|
||||||
|
Text: Restart
|
||||||
|
Button@CANCEL_BUTTON:
|
||||||
|
Key: escape
|
||||||
|
Y: 89
|
||||||
|
Width: 140
|
||||||
|
Height: 35
|
||||||
|
Text: Cancel
|
||||||
|
|
||||||
Container@TEXT_INPUT_PROMPT:
|
Container@TEXT_INPUT_PROMPT:
|
||||||
X: (WINDOW_RIGHT - WIDTH)/2
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||||
|
|||||||
@@ -33,6 +33,48 @@ Background@CONFIRM_PROMPT:
|
|||||||
Font: Bold
|
Font: Bold
|
||||||
Key: escape
|
Key: escape
|
||||||
|
|
||||||
|
Background@ABORT_MISSION_PROMPT:
|
||||||
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
|
Y: (WINDOW_BOTTOM - 90)/2
|
||||||
|
Width: 600
|
||||||
|
Height: 175
|
||||||
|
Children:
|
||||||
|
Label@PROMPT_TITLE:
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Y: 20
|
||||||
|
Height: 25
|
||||||
|
Font: Bold
|
||||||
|
Align: Center
|
||||||
|
Label@PROMPT_TEXT:
|
||||||
|
X: 15
|
||||||
|
Y: 50
|
||||||
|
Width: PARENT_RIGHT - 30
|
||||||
|
Height: 65
|
||||||
|
Align: Center
|
||||||
|
Button@ABORT_BUTTON:
|
||||||
|
X: 20
|
||||||
|
Y: PARENT_BOTTOM - 45
|
||||||
|
Width: 160
|
||||||
|
Height: 25
|
||||||
|
Text: Abort
|
||||||
|
Font: Bold
|
||||||
|
Key: return
|
||||||
|
Button@RESTART_BUTTON:
|
||||||
|
X: PARENT_RIGHT - 380
|
||||||
|
Y: PARENT_BOTTOM - 45
|
||||||
|
Width: 160
|
||||||
|
Height: 25
|
||||||
|
Text: Restart
|
||||||
|
Font: Bold
|
||||||
|
Button@CANCEL_BUTTON:
|
||||||
|
X: PARENT_RIGHT - 180
|
||||||
|
Y: PARENT_BOTTOM - 45
|
||||||
|
Width: 160
|
||||||
|
Height: 25
|
||||||
|
Text: Cancel
|
||||||
|
Font: Bold
|
||||||
|
Key: escape
|
||||||
|
|
||||||
Background@CANCEL_PROMPT:
|
Background@CANCEL_PROMPT:
|
||||||
X: (WINDOW_RIGHT - WIDTH)/2
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
Y: (WINDOW_BOTTOM - 90)/2
|
Y: (WINDOW_BOTTOM - 90)/2
|
||||||
|
|||||||
Reference in New Issue
Block a user