Console command permissions can be changed in the client permission menu, permitted commands are displayed in the client-side permission popup
This commit is contained in:
@@ -7,12 +7,8 @@ namespace Barotrauma
|
||||
{
|
||||
public static List<GUIComponent> MessageBoxes = new List<GUIComponent>();
|
||||
|
||||
const int DefaultWidth=400, DefaultHeight=250;
|
||||
|
||||
//public delegate bool OnClickedHandler(GUIButton button, object obj);
|
||||
//public OnClickedHandler OnClicked;
|
||||
|
||||
//GUIFrame frame;
|
||||
public const int DefaultWidth = 400, DefaultHeight = 250;
|
||||
|
||||
public GUIButton[] Buttons;
|
||||
|
||||
public static GUIComponent VisibleBox
|
||||
|
||||
@@ -50,8 +50,8 @@ namespace Barotrauma
|
||||
{
|
||||
base.Rect = value;
|
||||
|
||||
box.Rect = new Rectangle(value.X,value.Y,box.Rect.Width,box.Rect.Height);
|
||||
text.Rect = new Rectangle(box.Rect.Right, box.Rect.Y + 2, 20, box.Rect.Height);
|
||||
if (box != null) box.Rect = new Rectangle(value.X,value.Y,box.Rect.Width,box.Rect.Height);
|
||||
if (text != null) text.Rect = new Rectangle(box.Rect.Right, box.Rect.Y + 2, 20, box.Rect.Height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -636,13 +636,23 @@ namespace Barotrauma.Networking
|
||||
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
msg += " - " + attributes[0].Description + "\n";
|
||||
}
|
||||
|
||||
//TODO: display permitted console commands
|
||||
}
|
||||
|
||||
permissions = newPermissions;
|
||||
this.permittedConsoleCommands = new List<string>(permittedConsoleCommands);
|
||||
new GUIMessageBox("Permissions changed", msg).UserData = "permissions";
|
||||
GUIMessageBox msgBox = new GUIMessageBox("Permissions changed", msg, GUIMessageBox.DefaultWidth, 0);
|
||||
msgBox.UserData = "permissions";
|
||||
|
||||
if (newPermissions.HasFlag(ClientPermissions.ConsoleCommands))
|
||||
{
|
||||
int listBoxWidth = (int)(msgBox.InnerFrame.Rect.Width - msgBox.InnerFrame.Padding.X - msgBox.InnerFrame.Padding.Z) / 2 - 30;
|
||||
new GUITextBlock(new Rectangle(0, 0, listBoxWidth, 15), "Permitted console commands:", "", Alignment.TopRight, Alignment.TopLeft, msgBox.InnerFrame, true, GUI.SmallFont);
|
||||
var commandList = new GUIListBox(new Rectangle(0, 20, listBoxWidth, 0), "", Alignment.BottomRight, msgBox.InnerFrame);
|
||||
foreach (string permittedCommand in permittedConsoleCommands)
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 15), permittedCommand, "", commandList, GUI.SmallFont).CanBeFocused = false;
|
||||
}
|
||||
}
|
||||
|
||||
GameMain.NetLobbyScreen.SubList.Enabled = Voting.AllowSubVoting || HasPermission(ClientPermissions.SelectSub);
|
||||
GameMain.NetLobbyScreen.ModeList.Enabled = Voting.AllowModeVoting || HasPermission(ClientPermissions.SelectMode);
|
||||
|
||||
@@ -857,7 +857,7 @@ namespace Barotrauma
|
||||
|
||||
playerFrame = new GUIFrame(new Rectangle(0, 0, 0, 0), Color.Black * 0.6f);
|
||||
|
||||
var playerFrameInner = new GUIFrame(new Rectangle(0, 0, 300, 280), null, Alignment.Center, "", playerFrame);
|
||||
var playerFrameInner = new GUIFrame(new Rectangle(0, 0, 300, 370), null, Alignment.Center, "", playerFrame);
|
||||
playerFrameInner.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 200, 20), component.UserData.ToString(),
|
||||
@@ -870,7 +870,7 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 25, 150, 15), selectedClient.Connection.RemoteEndPoint.Address.ToString(), "", playerFrameInner);
|
||||
|
||||
var permissionsBox = new GUIFrame(new Rectangle(0, 60, 0, 90), null, playerFrameInner);
|
||||
var permissionsBox = new GUIFrame(new Rectangle(0, 40, 0, 110), null, playerFrameInner);
|
||||
permissionsBox.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
permissionsBox.UserData = selectedClient;
|
||||
|
||||
@@ -911,9 +911,39 @@ namespace Barotrauma
|
||||
if (y >= permissionsBox.Rect.Height - 40)
|
||||
{
|
||||
y = 0;
|
||||
x += 100;
|
||||
x += 120;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 145, 0, 15), "Permitted console commands:", "", playerFrameInner);
|
||||
var commandList = new GUIListBox(new Rectangle(0,170,0, 80), "", playerFrameInner);
|
||||
commandList.UserData = selectedClient;
|
||||
foreach (DebugConsole.Command command in DebugConsole.Commands)
|
||||
{
|
||||
var commandTickBox = new GUITickBox(new Rectangle(0,0,15,15), command.names[0], Alignment.TopLeft, GUI.SmallFont, commandList);
|
||||
commandTickBox.Selected = selectedClient.PermittedConsoleCommands.Contains(command);
|
||||
commandTickBox.ToolTip = command.help;
|
||||
commandTickBox.UserData = command;
|
||||
commandTickBox.OnSelected += (GUITickBox tickBox) =>
|
||||
{
|
||||
Client client = tickBox.Parent.UserData as Client;
|
||||
DebugConsole.Command selectedCommand = tickBox.UserData as DebugConsole.Command;
|
||||
if (client == null) return false;
|
||||
|
||||
if (!tickBox.Selected)
|
||||
{
|
||||
client.PermittedConsoleCommands.Remove(selectedCommand);
|
||||
}
|
||||
else if (!client.PermittedConsoleCommands.Contains(selectedCommand))
|
||||
{
|
||||
client.PermittedConsoleCommands.Add(selectedCommand);
|
||||
}
|
||||
|
||||
GameMain.Server.UpdateClientPermissions(client);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (GameMain.Server != null || GameMain.Client.HasPermission(ClientPermissions.Kick))
|
||||
|
||||
@@ -111,6 +111,10 @@ namespace Barotrauma
|
||||
#endif
|
||||
|
||||
private static List<Command> commands = new List<Command>();
|
||||
public static List<Command> Commands
|
||||
{
|
||||
get { return commands; }
|
||||
}
|
||||
|
||||
private static string currentAutoCompletedCommand;
|
||||
private static int currentAutoCompletedIndex;
|
||||
|
||||
Reference in New Issue
Block a user