v1.2.6.0 (Winter Update)
This commit is contained in:
@@ -122,12 +122,12 @@ namespace Barotrauma.Networking
|
||||
VoipSound = null;
|
||||
}
|
||||
|
||||
public void SetPermissions(ClientPermissions permissions, IEnumerable<string> permittedConsoleCommands)
|
||||
public void SetPermissions(ClientPermissions permissions, IEnumerable<Identifier> permittedConsoleCommands)
|
||||
{
|
||||
List<DebugConsole.Command> permittedCommands = new List<DebugConsole.Command>();
|
||||
foreach (string commandName in permittedConsoleCommands)
|
||||
foreach (Identifier commandName in permittedConsoleCommands)
|
||||
{
|
||||
var consoleCommand = DebugConsole.Commands.Find(c => c.names.Contains(commandName));
|
||||
var consoleCommand = DebugConsole.Commands.Find(c => c.Names.Contains(commandName));
|
||||
if (consoleCommand != null)
|
||||
{
|
||||
permittedCommands.Add(consoleCommand);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Barotrauma.Networking
|
||||
public bool LateCampaignJoin = false;
|
||||
|
||||
private ClientPermissions permissions = ClientPermissions.None;
|
||||
private List<string> permittedConsoleCommands = new List<string>();
|
||||
private List<Identifier> permittedConsoleCommands = new List<Identifier>();
|
||||
|
||||
private bool connected;
|
||||
|
||||
@@ -170,9 +170,9 @@ namespace Barotrauma.Networking
|
||||
internal readonly struct PermissionChangedEvent
|
||||
{
|
||||
public readonly ClientPermissions NewPermissions;
|
||||
public readonly ImmutableArray<string> NewPermittedConsoleCommands;
|
||||
public readonly ImmutableArray<Identifier> NewPermittedConsoleCommands;
|
||||
|
||||
public PermissionChangedEvent(ClientPermissions newPermissions, IReadOnlyList<string> newPermittedConsoleCommands)
|
||||
public PermissionChangedEvent(ClientPermissions newPermissions, IReadOnlyList<Identifier> newPermittedConsoleCommands)
|
||||
{
|
||||
NewPermissions = newPermissions;
|
||||
NewPermittedConsoleCommands = newPermittedConsoleCommands.ToImmutableArray();
|
||||
@@ -1211,11 +1211,11 @@ namespace Barotrauma.Networking
|
||||
targetClient?.SetPermissions(permissions, permittedCommands);
|
||||
if (clientId == SessionId)
|
||||
{
|
||||
SetMyPermissions(permissions, permittedCommands.Select(command => command.names[0]));
|
||||
SetMyPermissions(permissions, permittedCommands.Select(command => command.Names[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private void SetMyPermissions(ClientPermissions newPermissions, IEnumerable<string> permittedConsoleCommands)
|
||||
private void SetMyPermissions(ClientPermissions newPermissions, IEnumerable<Identifier> permittedConsoleCommands)
|
||||
{
|
||||
if (!(this.permittedConsoleCommands.Any(c => !permittedConsoleCommands.Contains(c)) ||
|
||||
permittedConsoleCommands.Any(c => !this.permittedConsoleCommands.Contains(c))))
|
||||
@@ -1227,7 +1227,7 @@ namespace Barotrauma.Networking
|
||||
permissions.HasFlag(ClientPermissions.ManageRound) != newPermissions.HasFlag(ClientPermissions.ManageRound);
|
||||
|
||||
permissions = newPermissions;
|
||||
this.permittedConsoleCommands = new List<string>(permittedConsoleCommands);
|
||||
this.permittedConsoleCommands = permittedConsoleCommands.ToList();
|
||||
//don't show the "permissions changed" popup if the client owns the server
|
||||
if (!IsServerOwner)
|
||||
{
|
||||
@@ -1265,10 +1265,10 @@ namespace Barotrauma.Networking
|
||||
var commandsLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), rightColumn.RectTransform),
|
||||
TextManager.Get("PermittedConsoleCommands"), wrap: true, font: GUIStyle.SubHeadingFont);
|
||||
var commandList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), rightColumn.RectTransform));
|
||||
foreach (string permittedCommand in permittedConsoleCommands)
|
||||
foreach (Identifier permittedCommand in permittedConsoleCommands)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), commandList.Content.RectTransform, minSize: new Point(0, 15)),
|
||||
permittedCommand, font: GUIStyle.SmallFont)
|
||||
permittedCommand.Value, font: GUIStyle.SmallFont)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
@@ -1348,6 +1348,7 @@ namespace Barotrauma.Networking
|
||||
bool respawnAllowed = inc.ReadBoolean();
|
||||
ServerSettings.AllowDisguises = inc.ReadBoolean();
|
||||
ServerSettings.AllowRewiring = inc.ReadBoolean();
|
||||
ServerSettings.AllowImmediateItemDelivery = inc.ReadBoolean();
|
||||
ServerSettings.AllowFriendlyFire = inc.ReadBoolean();
|
||||
ServerSettings.LockAllDefaultWires = inc.ReadBoolean();
|
||||
ServerSettings.AllowLinkingWifiToChat = inc.ReadBoolean();
|
||||
@@ -2221,7 +2222,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
outmsg.WriteByte((byte)MultiplayerPreferences.Instance.TeamPreference);
|
||||
|
||||
if (!(GameMain.GameSession?.GameMode is MultiPlayerCampaign campaign) || campaign.LastSaveID == 0)
|
||||
if (GameMain.GameSession?.GameMode is not MultiPlayerCampaign campaign || campaign.LastSaveID == 0)
|
||||
{
|
||||
outmsg.WriteUInt16((UInt16)0);
|
||||
}
|
||||
@@ -2551,18 +2552,18 @@ namespace Barotrauma.Networking
|
||||
return permissions.HasFlag(permission);
|
||||
}
|
||||
|
||||
public bool HasConsoleCommandPermission(string commandName)
|
||||
public bool HasConsoleCommandPermission(Identifier commandName)
|
||||
{
|
||||
if (!permissions.HasFlag(ClientPermissions.ConsoleCommands)) { return false; }
|
||||
|
||||
if (permittedConsoleCommands.Any(c => c.Equals(commandName, StringComparison.OrdinalIgnoreCase))) { return true; }
|
||||
if (permittedConsoleCommands.Contains(commandName)) { return true; }
|
||||
|
||||
//check aliases
|
||||
foreach (DebugConsole.Command command in DebugConsole.Commands)
|
||||
{
|
||||
if (command.names.Contains(commandName))
|
||||
if (command.Names.Contains(commandName))
|
||||
{
|
||||
if (command.names.Intersect(permittedConsoleCommands).Any()) { return true; }
|
||||
if (command.Names.Intersect(permittedConsoleCommands).Any()) { return true; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,9 @@ namespace Barotrauma.Networking
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
public LanguageIdentifier Language { get; set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
public string SelectedSub { get; set; } = string.Empty;
|
||||
|
||||
public Version GameVersion { get; set; } = new Version(0, 0, 0, 0);
|
||||
|
||||
public Option<int> Ping = Option<int>.None();
|
||||
@@ -104,6 +107,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
public ImmutableArray<ContentPackageInfo> ContentPackages;
|
||||
|
||||
public int ContentPackageCount;
|
||||
|
||||
public bool IsModded => ContentPackages.Any(p => !GameMain.VanillaContent.NameMatches(p.Name));
|
||||
|
||||
public ServerInfo(Endpoint endpoint)
|
||||
@@ -176,33 +181,6 @@ namespace Barotrauma.Networking
|
||||
};
|
||||
title.Text = ToolBox.LimitString(title.Text, title.Font, (int)(title.Rect.Width * 0.85f));
|
||||
|
||||
bool isFavorite = serverListScreen.IsFavorite(this);
|
||||
|
||||
static LocalizedString favoriteTickBoxToolTip(bool isFavorite)
|
||||
=> TextManager.Get(isFavorite ? "RemoveFromFavorites" : "AddToFavorites");
|
||||
|
||||
GUITickBox favoriteTickBox = new GUITickBox(new RectTransform(new Vector2(0.15f, 0.8f), title.RectTransform, Anchor.CenterRight),
|
||||
"", null, "GUIServerListFavoriteTickBox")
|
||||
{
|
||||
UserData = this,
|
||||
Selected = isFavorite,
|
||||
ToolTip = favoriteTickBoxToolTip(isFavorite),
|
||||
OnSelected = tickbox =>
|
||||
{
|
||||
ServerInfo info = (ServerInfo)tickbox.UserData;
|
||||
if (tickbox.Selected)
|
||||
{
|
||||
GameMain.ServerListScreen.AddToFavoriteServers(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.ServerListScreen.RemoveFromFavoriteServers(info);
|
||||
}
|
||||
tickbox.ToolTip = favoriteTickBoxToolTip(tickbox.Selected);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), frame.RectTransform),
|
||||
TextManager.AddPunctuation(':', TextManager.Get("ServerListVersion"),
|
||||
GameVersion == new Version(0, 0, 0, 0) ? TextManager.Get("Unknown") : GameVersion.ToString()))
|
||||
@@ -258,6 +236,59 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 0.25f), playStyleBanner.RectTransform, Anchor.BottomRight),
|
||||
isHorizontal: true, childAnchor: Anchor.BottomRight);
|
||||
|
||||
//shadow behind the buttons
|
||||
new GUIFrame(new RectTransform(new Vector2(3.15f, 1.05f), buttonContainer.RectTransform, Anchor.BottomRight, scaleBasis: ScaleBasis.Smallest), style: null)
|
||||
{
|
||||
Color = Color.Black * 0.7f,
|
||||
IgnoreLayoutGroups = true
|
||||
};
|
||||
|
||||
bool isFavorite = serverListScreen.IsFavorite(this);
|
||||
static LocalizedString favoriteTickBoxToolTip(bool isFavorite)
|
||||
=> TextManager.Get(isFavorite ? "RemoveFromFavorites" : "AddToFavorites");
|
||||
|
||||
GUITickBox favoriteTickBox = new GUITickBox(new RectTransform(Vector2.One, buttonContainer.RectTransform, scaleBasis: ScaleBasis.Smallest),
|
||||
"", null, "GUIServerListFavoriteTickBox")
|
||||
{
|
||||
UserData = this,
|
||||
Selected = isFavorite,
|
||||
ToolTip = favoriteTickBoxToolTip(isFavorite),
|
||||
OnSelected = tickbox =>
|
||||
{
|
||||
ServerInfo info = (ServerInfo)tickbox.UserData;
|
||||
if (tickbox.Selected)
|
||||
{
|
||||
GameMain.ServerListScreen.AddToFavoriteServers(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.ServerListScreen.RemoveFromFavoriteServers(info);
|
||||
}
|
||||
tickbox.ToolTip = favoriteTickBoxToolTip(tickbox.Selected);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(Vector2.One, buttonContainer.RectTransform, scaleBasis: ScaleBasis.Smallest), style: "GUIServerListReportServer")
|
||||
{
|
||||
ToolTip = TextManager.Get("reportserver"),
|
||||
OnClicked = (_, _) => {ServerListScreen.CreateReportPrompt(this); return true; }
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(Vector2.One, buttonContainer.RectTransform, scaleBasis: ScaleBasis.Smallest), style: "GUIServerListHideServer")
|
||||
{
|
||||
ToolTip = TextManager.Get("filterserver"),
|
||||
OnClicked = (_, _) =>
|
||||
{
|
||||
ServerListScreen.CreateFilterServerPrompt(this);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// playstyle tags -----------------------------------------------------------------------------
|
||||
|
||||
var playStyleContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), content.RectTransform), isHorizontal: true)
|
||||
@@ -309,6 +340,14 @@ namespace Barotrauma.Networking
|
||||
TextManager.Get(GameMode.IsEmpty ? "Unknown" : "GameMode." + GameMode).Fallback(GameMode.Value),
|
||||
textAlignment: Alignment.Right);
|
||||
|
||||
if (!string.IsNullOrEmpty(SelectedSub))
|
||||
{
|
||||
var submarineText = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("Submarine"));
|
||||
new GUITextBlock(new RectTransform(Vector2.One, submarineText.RectTransform),
|
||||
SelectedSub,
|
||||
textAlignment: Alignment.Right);
|
||||
}
|
||||
|
||||
GUITextBlock playStyleText = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("serverplaystyle"));
|
||||
new GUITextBlock(new RectTransform(Vector2.One, playStyleText.RectTransform), TextManager.Get("servertag." + playStyle), textAlignment: Alignment.Right);
|
||||
|
||||
@@ -385,6 +424,15 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ContentPackageCount > ContentPackages.Length)
|
||||
{
|
||||
new GUITextBlock(
|
||||
new RectTransform(new Vector2(1.0f, 0.15f), contentPackageList.Content.RectTransform) { MinSize = new Point(0, 15) },
|
||||
TextManager.GetWithVariable("workshopitemdownloadprompttruncated", "[number]", (ContentPackageCount - ContentPackages.Length).ToString()))
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -423,14 +471,16 @@ namespace Barotrauma.Networking
|
||||
AllowSpectating = getBool("allowspectating");
|
||||
AllowRespawn = getBool("allowrespawn");
|
||||
VoipEnabled = getBool("voicechatenabled");
|
||||
|
||||
GameMode = valueGetter("gamemode")?.ToIdentifier() ?? Identifier.Empty;
|
||||
if (float.TryParse(valueGetter("traitors"), NumberStyles.Any, CultureInfo.InvariantCulture, out float traitorProbability)) { TraitorProbability = traitorProbability; }
|
||||
if (Enum.TryParse(valueGetter("playstyle"), out PlayStyle playStyle)) { PlayStyle = playStyle; }
|
||||
Language = valueGetter("language")?.ToLanguageIdentifier() ?? LanguageIdentifier.None;
|
||||
SelectedSub = valueGetter("submarine") ?? string.Empty;
|
||||
|
||||
ContentPackages = ExtractContentPackageInfo(ServerName, valueGetter).ToImmutableArray();
|
||||
|
||||
ContentPackageCount = ContentPackages.Length;
|
||||
if (int.TryParse(valueGetter("packagecount"), out int packageCount)) { ContentPackageCount = packageCount; }
|
||||
|
||||
bool getBool(string key)
|
||||
{
|
||||
string? data = valueGetter(key);
|
||||
|
||||
@@ -936,6 +936,10 @@ namespace Barotrauma.Networking
|
||||
TextManager.Get("ServerSettingsAllowVoteKick"));
|
||||
GetPropertyData(nameof(AllowVoteKick)).AssignGUIComponent(voteKickBox);
|
||||
|
||||
var allowImmediateItemDeliveryBox = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
|
||||
TextManager.Get("ServerSettingsImmediateItemDelivery"));
|
||||
GetPropertyData(nameof(AllowImmediateItemDelivery)).AssignGUIComponent(allowImmediateItemDeliveryBox);
|
||||
|
||||
GUITextBlock.AutoScaleAndNormalize(tickBoxContainer.Content.Children.Select(c => ((GUITickBox)c).TextBlock));
|
||||
|
||||
tickBoxContainer.RectTransform.MinSize = new Point(0, (int)(tickBoxContainer.Content.Children.First().Rect.Height * 2.0f + tickBoxContainer.Padding.Y + tickBoxContainer.Padding.W));
|
||||
|
||||
Reference in New Issue
Block a user