From b59920629457ac2340fc8ed1b2e9bc57e7d9a010 Mon Sep 17 00:00:00 2001 From: itchyOwl Date: Tue, 27 Mar 2018 11:29:36 +0300 Subject: [PATCH] Add a GUI slider for setting the auto ban duration. Define the max auto ban length in the server settings. (Issue #128) --- .../Source/Networking/GameServerSettings.cs | 17 +++++++++++++++++ .../Source/Networking/GameServerSettings.cs | 9 +++++++++ Barotrauma/BarotraumaShared/serversettings.xml | 1 + 3 files changed, 27 insertions(+) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameServerSettings.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameServerSettings.cs index 033538684..1cde5daf4 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameServerSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameServerSettings.cs @@ -350,6 +350,23 @@ namespace Barotrauma.Networking }; kickVoteSlider.OnMoved(kickVoteSlider, kickVoteSlider.BarScroll); + y += 20; + + var autobanTimeText = new GUITextBlock(new Rectangle(20, y + 20, 20, 20), $"Auto ban time: " + ToolBox.SecondsToReadableTime(AutoBanTime), "", settingsTabs[1], GUI.SmallFont); + + var autobanTimeSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 15), "", 0.1f, settingsTabs[1]); + autobanTimeSlider.UserData = autobanTimeText; + autobanTimeSlider.Step = 0.05f; + autobanTimeSlider.BarScroll = AutoBanTime / MaxAutoBanTime; + autobanTimeSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) => + { + GUITextBlock voteText = scrollBar.UserData as GUITextBlock; + AutoBanTime = Math.Max(barScroll * MaxAutoBanTime, 0); + voteText.Text = "Auto ban time: " + ToolBox.SecondsToReadableTime(AutoBanTime); + return true; + }; + autobanTimeSlider.OnMoved(autobanTimeSlider, autobanTimeSlider.BarScroll); + y += 45; var shareSubsBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Share submarine files with players", Alignment.Left, settingsTabs[1]); diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServerSettings.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServerSettings.cs index b7160c07d..a148dde48 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServerSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServerSettings.cs @@ -260,6 +260,14 @@ namespace Barotrauma.Networking get; private set; } + + [Serialize(360f, true)] + public float MaxAutoBanTime + { + get; + private set; + } + private void SaveSettings() { XDocument doc = new XDocument(new XElement("serversettings")); @@ -369,6 +377,7 @@ namespace Barotrauma.Networking extraCargo = new Dictionary(); AutoBanTime = doc.Root.GetAttributeFloat("autobantime", 60); + MaxAutoBanTime = doc.Root.GetAttributeFloat("maxautobantime", 360); } public void LoadClientPermissions() diff --git a/Barotrauma/BarotraumaShared/serversettings.xml b/Barotrauma/BarotraumaShared/serversettings.xml index 0cce423d4..c42cf2a7b 100644 --- a/Barotrauma/BarotraumaShared/serversettings.xml +++ b/Barotrauma/BarotraumaShared/serversettings.xml @@ -30,4 +30,5 @@ MissionType="Random" TraitorsEnabled="No" autobantime="60" + maxautobantime="360" />