Allow kicking dead players
This commit is contained in:
committed by
Matthias Mailänder
parent
c4bd9fb7aa
commit
bf00577d33
@@ -48,6 +48,9 @@ namespace OpenRA.Mods.Common.Server
|
||||
[TranslationReference]
|
||||
const string KickNone = "notification-kick-none";
|
||||
|
||||
[TranslationReference]
|
||||
const string NoKickSelf = "notification-kick-self";
|
||||
|
||||
[TranslationReference]
|
||||
const string NoKickGameStarted = "notification-no-kick-game-started";
|
||||
|
||||
@@ -794,7 +797,13 @@ namespace OpenRA.Mods.Common.Server
|
||||
}
|
||||
|
||||
var kickClient = server.GetClient(kickConn);
|
||||
if (server.State == ServerState.GameStarted && !kickClient.IsObserver)
|
||||
if (client == kickClient)
|
||||
{
|
||||
server.SendLocalizedMessageTo(conn, NoKickSelf);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!server.CanKickClient(kickClient))
|
||||
{
|
||||
server.SendLocalizedMessageTo(conn, NoKickGameStarted);
|
||||
return true;
|
||||
|
||||
@@ -114,6 +114,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
.GroupBy(p => (world.LobbyInfo.ClientWithIndex(p.Player.ClientIndex) ?? new Session.Client()).Team)
|
||||
.OrderByDescending(g => g.Sum(gg => gg.PlayerStatistics?.Experience ?? 0));
|
||||
|
||||
void KickAction(Session.Client client)
|
||||
{
|
||||
hideMenu(true);
|
||||
ConfirmationDialogs.ButtonPrompt(modData,
|
||||
title: KickTitle,
|
||||
titleArguments: Translation.Arguments("player", client.Name),
|
||||
text: KickPrompt,
|
||||
onConfirm: () =>
|
||||
{
|
||||
orderManager.IssueOrder(Order.Command($"kick {client.Index} {false}"));
|
||||
hideMenu(false);
|
||||
},
|
||||
onCancel: () => hideMenu(false),
|
||||
confirmText: KickAccept);
|
||||
}
|
||||
|
||||
foreach (var t in teams)
|
||||
{
|
||||
if (teams.Count() > 1)
|
||||
@@ -165,6 +181,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
muteCheckbox.IsVisible = () => !pp.IsBot && client.State != Session.ClientState.Disconnected && pp.ClientIndex != orderManager.LocalClient?.Index;
|
||||
muteCheckbox.GetTooltipText = () => muteCheckbox.IsChecked() ? unmuteTooltip : muteTooltip;
|
||||
|
||||
var kickButton = item.Get<ButtonWidget>("KICK");
|
||||
kickButton.IsVisible = () => Game.IsHost && client.Index != orderManager.LocalClient?.Index && client.State != Session.ClientState.Disconnected && pp.WinState != WinState.Undefined && !pp.IsBot;
|
||||
kickButton.OnClick = () => KickAction(client);
|
||||
|
||||
playerPanel.AddChild(item);
|
||||
}
|
||||
}
|
||||
@@ -198,21 +218,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var kickButton = item.Get<ButtonWidget>("KICK");
|
||||
kickButton.IsVisible = () => Game.IsHost && client.Index != orderManager.LocalClient?.Index && client.State != Session.ClientState.Disconnected;
|
||||
kickButton.OnClick = () =>
|
||||
{
|
||||
hideMenu(true);
|
||||
ConfirmationDialogs.ButtonPrompt(modData,
|
||||
title: KickTitle,
|
||||
titleArguments: Translation.Arguments("player", client.Name),
|
||||
text: KickPrompt,
|
||||
onConfirm: () =>
|
||||
{
|
||||
orderManager.IssueOrder(Order.Command($"kick {client.Index} {false}"));
|
||||
hideMenu(false);
|
||||
},
|
||||
onCancel: () => hideMenu(false),
|
||||
confirmText: KickAccept);
|
||||
};
|
||||
kickButton.OnClick = () => KickAction(client);
|
||||
|
||||
var muteCheckbox = item.Get<CheckboxWidget>("MUTE");
|
||||
muteCheckbox.IsChecked = () => TextNotificationsManager.MutedPlayers[client.Index];
|
||||
|
||||
Reference in New Issue
Block a user