Merge pull request #10264 from whinis/bleed
Restart button for missions
This commit is contained in:
@@ -88,14 +88,42 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
abortMissionButton.OnClick = () =>
|
||||
{
|
||||
if (world.IsGameOver)
|
||||
{
|
||||
onQuit();
|
||||
return;
|
||||
}
|
||||
|
||||
hideMenu = true;
|
||||
ConfirmationDialogs.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, showMenu);
|
||||
|
||||
if (world.LocalPlayer == null || (world.LocalPlayer.WinState != WinState.Won &&
|
||||
(!world.IsGameOver || world.Map.Visibility == MapVisibility.MissionSelector)))
|
||||
{
|
||||
Action restartAction = null;
|
||||
if (world.IsReplay || world.Map.Visibility == MapVisibility.MissionSelector)
|
||||
{
|
||||
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
|
||||
var exitDelay = iop != null ? iop.ExitDelay : 0;
|
||||
restartAction = () =>
|
||||
{
|
||||
Ui.CloseWindow();
|
||||
if (mpe != null)
|
||||
{
|
||||
if (Game.IsCurrentWorld(world))
|
||||
mpe.Fade(MenuPaletteEffect.EffectType.Black);
|
||||
exitDelay += 40 * mpe.Info.FadeLength;
|
||||
}
|
||||
|
||||
Game.RunAfterDelay(exitDelay, Game.RestartGame);
|
||||
};
|
||||
}
|
||||
|
||||
ConfirmationDialogs.PromptConfirmAction(
|
||||
title: "Leave Mission",
|
||||
text: "Leave this game and return to the menu?",
|
||||
onConfirm: onQuit,
|
||||
onCancel: showMenu,
|
||||
confirmText: "Leave",
|
||||
cancelText: "Stay",
|
||||
otherText: "Restart",
|
||||
onOther: restartAction);
|
||||
}
|
||||
else
|
||||
onQuit();
|
||||
};
|
||||
|
||||
var exitEditorButton = menu.Get<ButtonWidget>("EXIT_EDITOR");
|
||||
@@ -103,7 +131,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
exitEditorButton.OnClick = () =>
|
||||
{
|
||||
hideMenu = true;
|
||||
ConfirmationDialogs.PromptConfirmAction("Exit Map Editor", "Exit and lose all unsaved changes?", onQuit, showMenu);
|
||||
ConfirmationDialogs.PromptConfirmAction(
|
||||
title: "Exit Map Editor",
|
||||
text: "Exit and lose all unsaved changes?",
|
||||
onConfirm: onQuit,
|
||||
onCancel: showMenu);
|
||||
};
|
||||
|
||||
Action onSurrender = () =>
|
||||
@@ -117,7 +149,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
surrenderButton.OnClick = () =>
|
||||
{
|
||||
hideMenu = true;
|
||||
ConfirmationDialogs.PromptConfirmAction("Surrender", "Are you sure you want to surrender?", onSurrender, showMenu);
|
||||
ConfirmationDialogs.PromptConfirmAction(
|
||||
title: "Surrender",
|
||||
text: "Are you sure you want to surrender?",
|
||||
onConfirm: onSurrender,
|
||||
onCancel: showMenu);
|
||||
};
|
||||
|
||||
var saveMapButton = menu.Get<ButtonWidget>("SAVE_MAP");
|
||||
|
||||
@@ -309,31 +309,29 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
void DeleteOneMap(string map, Action<string> after)
|
||||
{
|
||||
ConfirmationDialogs.PromptConfirmAction(
|
||||
"Delete map",
|
||||
"Delete the map '{0}'?".F(Game.ModData.MapCache[map].Title),
|
||||
() =>
|
||||
title: "Delete map",
|
||||
text: "Delete the map '{0}'?".F(Game.ModData.MapCache[map].Title),
|
||||
onConfirm: () =>
|
||||
{
|
||||
var newUid = DeleteMap(map);
|
||||
if (after != null)
|
||||
after(newUid);
|
||||
},
|
||||
null,
|
||||
"Delete");
|
||||
confirmText: "Delete");
|
||||
}
|
||||
|
||||
void DeleteAllMaps(string[] maps, Action<string> after)
|
||||
{
|
||||
ConfirmationDialogs.PromptConfirmAction(
|
||||
"Delete maps",
|
||||
"Delete all maps on this page?",
|
||||
() =>
|
||||
title: "Delete maps",
|
||||
text: "Delete all maps on this page?",
|
||||
onConfirm: () =>
|
||||
{
|
||||
maps.Do(m => DeleteMap(m));
|
||||
if (after != null)
|
||||
after(WidgetUtils.ChooseInitialMap(null));
|
||||
},
|
||||
null,
|
||||
"Delete");
|
||||
confirmText: "Delete");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,29 +301,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
PlayVideo(fsPlayer, gameStartVideo, PlayingVideo.GameStart, () =>
|
||||
{
|
||||
StopVideo(fsPlayer);
|
||||
StartMission();
|
||||
Game.StartMission(selectedMapPreview.Uid, gameSpeed, difficulty, onStart);
|
||||
});
|
||||
}
|
||||
else
|
||||
StartMission();
|
||||
}
|
||||
|
||||
void StartMission()
|
||||
{
|
||||
OrderManager om = null;
|
||||
|
||||
Action lobbyReady = null;
|
||||
lobbyReady = () =>
|
||||
{
|
||||
om.IssueOrder(Order.Command("gamespeed {0}".F(gameSpeed)));
|
||||
om.IssueOrder(Order.Command("difficulty {0}".F(difficulty)));
|
||||
Game.LobbyInfoChanged -= lobbyReady;
|
||||
onStart();
|
||||
om.IssueOrder(Order.Command("state {0}".F(Session.ClientState.Ready)));
|
||||
};
|
||||
Game.LobbyInfoChanged += lobbyReady;
|
||||
|
||||
om = Game.JoinServer(IPAddress.Loopback.ToString(), Game.CreateLocalServer(selectedMapPreview.Uid), "");
|
||||
Game.StartMission(selectedMapPreview.Uid, gameSpeed, difficulty, onStart);
|
||||
}
|
||||
|
||||
class DropDownOption
|
||||
|
||||
@@ -403,16 +403,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Action<ReplayMetadata, Action> onDeleteReplay = (r, after) =>
|
||||
{
|
||||
ConfirmationDialogs.PromptConfirmAction(
|
||||
"Delete selected replay?",
|
||||
"Delete replay '{0}'?".F(Path.GetFileNameWithoutExtension(r.FilePath)),
|
||||
() =>
|
||||
title: "Delete selected replay?",
|
||||
text: "Delete replay '{0}'?".F(Path.GetFileNameWithoutExtension(r.FilePath)),
|
||||
onConfirm: () =>
|
||||
{
|
||||
DeleteReplay(r);
|
||||
if (after != null)
|
||||
after.Invoke();
|
||||
},
|
||||
null,
|
||||
"Delete");
|
||||
confirmText: "Delete");
|
||||
};
|
||||
|
||||
{
|
||||
@@ -444,16 +443,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
ConfirmationDialogs.PromptConfirmAction(
|
||||
"Delete all selected replays?",
|
||||
"Delete {0} replays?".F(list.Count),
|
||||
() =>
|
||||
title: "Delete all selected replays?",
|
||||
text: "Delete {0} replays?".F(list.Count),
|
||||
onConfirm: () =>
|
||||
{
|
||||
list.ForEach(DeleteReplay);
|
||||
if (selectedReplay == null)
|
||||
SelectFirstVisibleReplay();
|
||||
},
|
||||
null,
|
||||
"Delete All");
|
||||
confirmText: "Delete All");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
OriginalGraphicsWindowedSize != current.Graphics.WindowedSize ||
|
||||
OriginalGraphicsFullscreenSize != current.Graphics.FullscreenSize)
|
||||
ConfirmationDialogs.PromptConfirmAction(
|
||||
"Restart Now?",
|
||||
"Some changes will not be applied until\nthe game is restarted. Restart now?",
|
||||
Game.Restart,
|
||||
closeAndExit,
|
||||
"Restart Now",
|
||||
"Restart Later");
|
||||
title: "Restart Now?",
|
||||
text: "Some changes will not be applied until\nthe game is restarted. Restart now?",
|
||||
onConfirm: Game.Restart,
|
||||
onCancel: closeAndExit,
|
||||
confirmText: "Restart Now",
|
||||
cancelText: "Restart Later");
|
||||
else
|
||||
closeAndExit();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user