Add a force start warning dialog.
This commit is contained in:
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
readonly OrderManager orderManager;
|
readonly OrderManager orderManager;
|
||||||
readonly bool skirmishMode;
|
readonly bool skirmishMode;
|
||||||
|
|
||||||
enum PanelType { Players, Options, Kick }
|
enum PanelType { Players, Options, Kick, ForceStart }
|
||||||
PanelType panel = PanelType.Players;
|
PanelType panel = PanelType.Players;
|
||||||
|
|
||||||
Widget lobby;
|
Widget lobby;
|
||||||
@@ -138,7 +138,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
countryNames.Add("random", "Any");
|
countryNames.Add("random", "Any");
|
||||||
|
|
||||||
var gameStarting = false;
|
var gameStarting = false;
|
||||||
Func<bool> configurationDisabled = () => !Game.IsHost || gameStarting || panel == PanelType.Kick ||
|
Func<bool> configurationDisabled = () => !Game.IsHost || gameStarting ||
|
||||||
|
panel == PanelType.Kick || panel == PanelType.ForceStart ||
|
||||||
orderManager.LocalClient == null || orderManager.LocalClient.IsReady;
|
orderManager.LocalClient == null || orderManager.LocalClient.IsReady;
|
||||||
|
|
||||||
var mapButton = lobby.GetOrNull<ButtonWidget>("CHANGEMAP_BUTTON");
|
var mapButton = lobby.GetOrNull<ButtonWidget>("CHANGEMAP_BUTTON");
|
||||||
@@ -261,10 +262,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
optionsBin.IsVisible = () => panel == PanelType.Options;
|
optionsBin.IsVisible = () => panel == PanelType.Options;
|
||||||
|
|
||||||
var optionsButton = lobby.Get<ButtonWidget>("OPTIONS_BUTTON");
|
var optionsButton = lobby.Get<ButtonWidget>("OPTIONS_BUTTON");
|
||||||
optionsButton.IsDisabled = () => panel == PanelType.Kick;
|
optionsButton.IsDisabled = () => panel == PanelType.Kick || panel == PanelType.ForceStart;
|
||||||
optionsButton.GetText = () => panel == PanelType.Options ? "Players" : "Options";
|
optionsButton.GetText = () => panel == PanelType.Options ? "Players" : "Options";
|
||||||
optionsButton.OnClick = () => panel = (panel == PanelType.Options) ? PanelType.Players : PanelType.Options;
|
optionsButton.OnClick = () => panel = (panel == PanelType.Options) ? PanelType.Players : PanelType.Options;
|
||||||
|
|
||||||
|
// Force start panel
|
||||||
|
Action startGame = () =>
|
||||||
|
{
|
||||||
|
gameStarting = true;
|
||||||
|
orderManager.IssueOrder(Order.Command("startgame"));
|
||||||
|
};
|
||||||
|
|
||||||
var startGameButton = lobby.GetOrNull<ButtonWidget>("START_GAME_BUTTON");
|
var startGameButton = lobby.GetOrNull<ButtonWidget>("START_GAME_BUTTON");
|
||||||
if (startGameButton != null)
|
if (startGameButton != null)
|
||||||
{
|
{
|
||||||
@@ -272,18 +280,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
orderManager.LobbyInfo.Slots.Any(sl => sl.Value.Required && orderManager.LobbyInfo.ClientInSlot(sl.Key) == null);
|
orderManager.LobbyInfo.Slots.Any(sl => sl.Value.Required && orderManager.LobbyInfo.ClientInSlot(sl.Key) == null);
|
||||||
startGameButton.OnClick = () =>
|
startGameButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
gameStarting = true;
|
Func<KeyValuePair<string, Session.Slot>, bool> notReady = sl =>
|
||||||
orderManager.IssueOrder(Order.Command("startgame"));
|
{
|
||||||
|
var cl = orderManager.LobbyInfo.ClientInSlot(sl.Key);
|
||||||
|
|
||||||
|
// Bots and admins don't count
|
||||||
|
return cl != null && !cl.IsAdmin && cl.Bot == null && !cl.IsReady;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (orderManager.LobbyInfo.Slots.Any(notReady))
|
||||||
|
panel = PanelType.ForceStart;
|
||||||
|
else
|
||||||
|
startGame();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var statusCheckbox = lobby.GetOrNull<CheckboxWidget>("STATUS_CHECKBOX");
|
var forceStartBin = Ui.LoadWidget("FORCE_START_DIALOG", lobby, new WidgetArgs());
|
||||||
if (statusCheckbox != null)
|
forceStartBin.IsVisible = () => panel == PanelType.ForceStart;
|
||||||
{
|
forceStartBin.Get("KICK_WARNING").IsVisible = () => orderManager.LobbyInfo.Clients.Any(c => c.IsInvalid);
|
||||||
statusCheckbox.IsHighlighted = () => !statusCheckbox.IsChecked() &&
|
forceStartBin.Get<ButtonWidget>("OK_BUTTON").OnClick = startGame;
|
||||||
orderManager.LobbyInfo.FirstEmptySlot() == null &&
|
forceStartBin.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => panel = PanelType.Players;
|
||||||
orderManager.LocalFrameNumber / 25 % 2 == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Options panel
|
// Options panel
|
||||||
var allowCheats = optionsBin.GetOrNull<CheckboxWidget>("ALLOWCHEATS_CHECKBOX");
|
var allowCheats = optionsBin.GetOrNull<CheckboxWidget>("ALLOWCHEATS_CHECKBOX");
|
||||||
|
|||||||
@@ -180,4 +180,69 @@ Background@LOBBY_OPTIONS_BIN:
|
|||||||
Y:107
|
Y:107
|
||||||
Width:140
|
Width:140
|
||||||
Height:25
|
Height:25
|
||||||
Font:Regular
|
Font:Regular
|
||||||
|
|
||||||
|
Background@FORCE_START_DIALOG:
|
||||||
|
X:15
|
||||||
|
Y:30
|
||||||
|
Width:501
|
||||||
|
Height:219
|
||||||
|
Background:scrollpanel-bg
|
||||||
|
Children:
|
||||||
|
Label@TITLE:
|
||||||
|
X:0
|
||||||
|
Y:40
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Align:Center
|
||||||
|
Text: Start Game?
|
||||||
|
Label@TEXTA:
|
||||||
|
X:0
|
||||||
|
Y:67
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Regular
|
||||||
|
Align:Center
|
||||||
|
Text:One or more players are not yet ready.
|
||||||
|
Label@TEXTB:
|
||||||
|
X:0
|
||||||
|
Y:85
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Regular
|
||||||
|
Align:Center
|
||||||
|
Text:Are you sure that you want to force start the game?
|
||||||
|
Container@KICK_WARNING:
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Children:
|
||||||
|
Label@KICK_WARNING_A:
|
||||||
|
X:0
|
||||||
|
Y:106
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Align:Center
|
||||||
|
Text:One or more clients are missing the selected
|
||||||
|
Label@KICK_WARNING_B:
|
||||||
|
X:0
|
||||||
|
Y:123
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Align:Center
|
||||||
|
Text:map, and will be kicked from the server.
|
||||||
|
Button@OK_BUTTON:
|
||||||
|
X:(PARENT_RIGHT - WIDTH)/2 + 75
|
||||||
|
Y:155
|
||||||
|
Width:120
|
||||||
|
Height:25
|
||||||
|
Text:Start
|
||||||
|
Font:Bold
|
||||||
|
Button@CANCEL_BUTTON:
|
||||||
|
X:(PARENT_RIGHT - WIDTH)/2 - 75
|
||||||
|
Y:155
|
||||||
|
Width:120
|
||||||
|
Height:25
|
||||||
|
Text:Cancel
|
||||||
|
Font:Bold
|
||||||
@@ -179,3 +179,68 @@ Background@LOBBY_OPTIONS_BIN:
|
|||||||
Width:140
|
Width:140
|
||||||
Height:25
|
Height:25
|
||||||
Font:Regular
|
Font:Regular
|
||||||
|
|
||||||
|
Background@FORCE_START_DIALOG:
|
||||||
|
X:20
|
||||||
|
Y:67
|
||||||
|
Width:535
|
||||||
|
Height:235
|
||||||
|
Background:dialog3
|
||||||
|
Children:
|
||||||
|
Label@TITLE:
|
||||||
|
X:0
|
||||||
|
Y:40
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Align:Center
|
||||||
|
Text: Start Game?
|
||||||
|
Label@TEXTA:
|
||||||
|
X:0
|
||||||
|
Y:67
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Regular
|
||||||
|
Align:Center
|
||||||
|
Text:One or more players are not yet ready.
|
||||||
|
Label@TEXTB:
|
||||||
|
X:0
|
||||||
|
Y:85
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Regular
|
||||||
|
Align:Center
|
||||||
|
Text:Are you sure that you want to force start the game?
|
||||||
|
Container@KICK_WARNING:
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Children:
|
||||||
|
Label@KICK_WARNING_A:
|
||||||
|
X:0
|
||||||
|
Y:106
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Align:Center
|
||||||
|
Text:One or more clients are missing the selected
|
||||||
|
Label@KICK_WARNING_B:
|
||||||
|
X:0
|
||||||
|
Y:123
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Align:Center
|
||||||
|
Text:map, and will be kicked from the server.
|
||||||
|
Button@OK_BUTTON:
|
||||||
|
X:(PARENT_RIGHT - WIDTH)/2 + 75
|
||||||
|
Y:155
|
||||||
|
Width:120
|
||||||
|
Height:25
|
||||||
|
Text:Start
|
||||||
|
Font:Bold
|
||||||
|
Button@CANCEL_BUTTON:
|
||||||
|
X:(PARENT_RIGHT - WIDTH)/2 - 75
|
||||||
|
Y:155
|
||||||
|
Width:120
|
||||||
|
Height:25
|
||||||
|
Text:Cancel
|
||||||
|
Font:Bold
|
||||||
Reference in New Issue
Block a user