Add temp banning to servers
This commit is contained in:
37
OpenRA.Mods.RA/Widgets/Logic/KickClientLogic.cs
Normal file
37
OpenRA.Mods.RA/Widgets/Logic/KickClientLogic.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
class KickClientLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public KickClientLogic(Widget widget, string clientName, Action<bool> okPressed)
|
||||
{
|
||||
widget.Get<LabelWidget>("TITLE").GetText = () => "Kick {0}?".F(clientName);
|
||||
|
||||
var tempBan = false;
|
||||
var preventRejoiningCheckbox = widget.Get<CheckboxWidget>("PREVENT_REJOINING_CHECKBOX");
|
||||
preventRejoiningCheckbox.IsChecked = () => tempBan;
|
||||
preventRejoiningCheckbox.OnClick = () => tempBan ^= true;
|
||||
|
||||
widget.Get<ButtonWidget>("OK_BUTTON").OnClick = () =>
|
||||
{
|
||||
widget.Parent.RemoveChild(widget);
|
||||
okPressed(tempBan);
|
||||
};
|
||||
|
||||
widget.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => widget.Parent.RemoveChild(widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
public class LobbyLogic
|
||||
{
|
||||
Widget lobby;
|
||||
Widget EditablePlayerTemplate, NonEditablePlayerTemplate, EmptySlotTemplate,
|
||||
EditableSpectatorTemplate, NonEditableSpectatorTemplate, NewSpectatorTemplate;
|
||||
EditableSpectatorTemplate, NonEditableSpectatorTemplate, NewSpectatorTemplate;
|
||||
ScrollPanelWidget chatPanel;
|
||||
Widget chatTemplate;
|
||||
|
||||
@@ -85,7 +86,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
internal LobbyLogic(Widget widget, World world, OrderManager orderManager,
|
||||
Action onExit, Action onStart, bool addBots)
|
||||
{
|
||||
var lobby = widget;
|
||||
lobby = widget;
|
||||
this.orderManager = orderManager;
|
||||
this.OnGameStart = () => { CloseWindow(); onStart(); };
|
||||
this.onExit = onExit;
|
||||
@@ -425,7 +426,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
|
||||
LobbyUtils.SetupClientWidget(template, slot, client, orderManager, client.Bot == null);
|
||||
LobbyUtils.SetupNameWidget(template, slot, client);
|
||||
LobbyUtils.SetupKickWidget(template, slot, client, orderManager);
|
||||
LobbyUtils.SetupKickWidget(template, slot, client, orderManager, lobby);
|
||||
LobbyUtils.SetupColorWidget(template, slot, client);
|
||||
LobbyUtils.SetupFactionWidget(template, slot, client, CountryNames);
|
||||
LobbyUtils.SetupTeamWidget(template, slot, client);
|
||||
@@ -467,7 +468,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
template = NonEditableSpectatorTemplate.Clone();
|
||||
|
||||
LobbyUtils.SetupNameWidget(template, null, client);
|
||||
LobbyUtils.SetupKickWidget(template, null, client, orderManager);
|
||||
LobbyUtils.SetupKickWidget(template, null, client, orderManager, lobby);
|
||||
}
|
||||
|
||||
LobbyUtils.SetupClientWidget(template, null, c, orderManager, true);
|
||||
|
||||
@@ -262,12 +262,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
slot.IsVisible = () => false;
|
||||
}
|
||||
|
||||
public static void SetupKickWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager)
|
||||
public static void SetupKickWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, Widget lobby)
|
||||
{
|
||||
var button = parent.Get<ButtonWidget>("KICK");
|
||||
button.IsVisible = () => Game.IsHost && c.Index != orderManager.LocalClient.Index;
|
||||
button.IsDisabled = () => orderManager.LocalClient.IsReady;
|
||||
button.OnClick = () => orderManager.IssueOrder(Order.Command("kick " + c.Index));
|
||||
Action<bool> okPressed = tempBan => orderManager.IssueOrder(Order.Command("kick {0} {1}".F(c.Index, tempBan)));
|
||||
button.OnClick = () => Game.LoadWidget(null, "KICK_CLIENT_DIALOG", lobby, new WidgetArgs
|
||||
{
|
||||
{ "clientName", c.Name },
|
||||
{ "okPressed", okPressed }
|
||||
});
|
||||
}
|
||||
|
||||
public static void SetupEditableColorWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, ColorPreviewManagerWidget colorPreview)
|
||||
|
||||
Reference in New Issue
Block a user