Add vote kick

(cherry picked from commit 144e716cdf)
This commit is contained in:
Gustas
2025-11-02 02:57:04 +00:00
committed by hacker
parent aacf0e2b8d
commit ee4403f923
5 changed files with 103 additions and 98 deletions

View File

@@ -50,10 +50,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[FluentReference]
const string Gone = "label-client-state-disconnected";
[FluentReference]
[TranslationReference]
const string KickTooltip = "button-kick-player";
[FluentReference("player")]
[TranslationReference("player")]
const string KickTitle = "dialog-kick.title";
[FluentReference]
@@ -62,28 +62,28 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[FluentReference]
const string KickAccept = "dialog-kick.confirm";
[FluentReference]
[TranslationReference]
const string KickVoteTooltip = "button-vote-kick-player";
[FluentReference("player")]
[TranslationReference("player")]
const string VoteKickTitle = "dialog-vote-kick.title";
[FluentReference]
[TranslationReference]
const string VoteKickPrompt = "dialog-vote-kick.prompt";
[FluentReference("bots")]
[TranslationReference("bots")]
const string VoteKickPromptBreakBots = "dialog-vote-kick.prompt-break-bots";
[FluentReference]
[TranslationReference]
const string VoteKickVoteStart = "dialog-vote-kick.vote-start";
[FluentReference]
[TranslationReference]
const string VoteKickVoteFor = "dialog-vote-kick.vote-for";
[FluentReference]
[TranslationReference]
const string VoteKickVoteAgainst = "dialog-vote-kick.vote-against";
[FluentReference]
[TranslationReference]
const string VoteKickVoteCancel = "dialog-vote-kick.vote-cancel";
[ObjectCreator.UseCtor]
@@ -133,10 +133,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var teamTemplate = playerPanel.Get<ScrollItemWidget>("TEAM_TEMPLATE");
var playerTemplate = playerPanel.Get("PLAYER_TEMPLATE");
var spectatorTemplate = playerPanel.Get("SPECTATOR_TEMPLATE");
var unmuteTooltip = FluentProvider.GetMessage(Unmute);
var muteTooltip = FluentProvider.GetMessage(Mute);
var kickTooltip = FluentProvider.GetMessage(KickTooltip);
var voteKickTooltip = FluentProvider.GetMessage(KickVoteTooltip);
var unmuteTooltip = TranslationProvider.GetString(Unmute);
var muteTooltip = TranslationProvider.GetString(Mute);
var kickTooltip = TranslationProvider.GetString(KickTooltip);
var voteKickTooltip = TranslationProvider.GetString(KickVoteTooltip);
playerPanel.RemoveChildren();
var teams = world.Players.Where(p => !p.NonCombatant && p.Playable)
@@ -159,14 +159,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
ConfirmationDialogs.ButtonPrompt(modData,
title: VoteKickTitle,
titleArguments: Translation.Arguments("player", client.Name),
text: botsCount > 0 ? VoteKickPromptBreakBots : VoteKickPrompt,
titleArguments: new object[] { "player", client.Name },
textArguments: new object[] { "bots", botsCount },
textArguments: Translation.Arguments("bots", botsCount),
onConfirm: () =>
{
orderManager.IssueOrder(Order.Command($"vote_kick {client.Index} {true}"));
hideMenu(false);
closeMenu();
},
confirmText: VoteKickVoteStart,
onCancel: () => hideMenu(false));
@@ -175,33 +174,31 @@ namespace OpenRA.Mods.Common.Widgets.Logic
ConfirmationDialogs.ButtonPrompt(modData,
title: VoteKickTitle,
titleArguments: Translation.Arguments("player", client.Name),
text: botsCount > 0 ? VoteKickPromptBreakBots : VoteKickPrompt,
titleArguments: new object[] { "player", client.Name },
textArguments: new object[] { "bots", botsCount },
textArguments: Translation.Arguments("bots", botsCount),
onConfirm: () =>
{
orderManager.IssueOrder(Order.Command($"vote_kick {client.Index} {true}"));
hideMenu(false);
closeMenu();
},
confirmText: VoteKickVoteFor,
onCancel: () => hideMenu(false),
cancelText: VoteKickVoteCancel,
onOther: () =>
{
Ui.CloseWindow();
orderManager.IssueOrder(Order.Command($"vote_kick {client.Index} {false}"));
hideMenu(false);
closeMenu();
},
otherText: VoteKickVoteAgainst);
otherText: VoteKickVoteAgainst,
onCancel: () => hideMenu(false),
cancelText: VoteKickVoteCancel);
}
else
{
ConfirmationDialogs.ButtonPrompt(modData,
title: KickTitle,
titleArguments: Translation.Arguments("player", client.Name),
text: KickPrompt,
titleArguments: new object[] { "player", client.Name },
onConfirm: () =>
{
orderManager.IssueOrder(Order.Command($"kick {client.Index} {false}"));