Merge pull request #10543 from whinis/RestartSkirmish

Restart skirmish matches
This commit is contained in:
Oliver Brakmann
2016-02-09 20:42:02 +01:00
4 changed files with 52 additions and 16 deletions

View File

@@ -90,14 +90,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
hideMenu = true;
if (world.LocalPlayer == null || (world.LocalPlayer.WinState != WinState.Won &&
(!world.IsGameOver || world.Map.Visibility == MapVisibility.MissionSelector)))
if (world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Won)
{
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;
if (world.LobbyInfo.IsSinglePlayer)
{
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
var exitDelay = iop != null ? iop.ExitDelay : 0;
restartAction = () =>
{
Ui.CloseWindow();
@@ -145,7 +145,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
};
var surrenderButton = menu.Get<ButtonWidget>("SURRENDER");
surrenderButton.IsVisible = () => world.Type == WorldType.Regular;
surrenderButton.IsDisabled = () => (world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined) || hasError;
surrenderButton.IsDisabled = () =>
world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined ||
world.Map.Visibility.HasFlag(MapVisibility.MissionSelector) || hasError;
surrenderButton.OnClick = () =>
{
hideMenu = true;
@@ -153,7 +155,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
title: "Surrender",
text: "Are you sure you want to surrender?",
onConfirm: onSurrender,
onCancel: showMenu);
onCancel: showMenu,
confirmText: "Surrender",
cancelText: "Stay");
};
var saveMapButton = menu.Get<ButtonWidget>("SAVE_MAP");

View File

@@ -14,6 +14,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using OpenRA.Graphics;
using OpenRA.Network;
using OpenRA.Primitives;
using OpenRA.Widgets;
@@ -301,6 +302,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return;
var gameStartVideo = selectedMap.Videos.GameStart;
var orders = new[] {
Order.Command("gamespeed {0}".F(gameSpeed)),
Order.Command("difficulty {0}".F(difficulty)),
Order.Command("state {0}".F(Session.ClientState.Ready))
};
if (gameStartVideo != null && Game.ModData.ModFiles.Exists(gameStartVideo))
{
var fsPlayer = fullscreenVideoPlayer.Get<VqaPlayerWidget>("PLAYER");
@@ -308,11 +315,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
PlayVideo(fsPlayer, gameStartVideo, PlayingVideo.GameStart, () =>
{
StopVideo(fsPlayer);
Game.StartMission(selectedMapPreview.Uid, gameSpeed, difficulty, onStart);
Game.CreateAndStartLocalServer(selectedMapPreview.Uid, orders, onStart);
});
}
else
Game.StartMission(selectedMapPreview.Uid, gameSpeed, difficulty, onStart);
Game.CreateAndStartLocalServer(selectedMapPreview.Uid, orders, onStart);
}
class DropDownOption