From 72f298c2d8b362a7d439a106909178cc4c981ee5 Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Sun, 23 Feb 2025 03:15:09 +0000 Subject: [PATCH] move debug settings to config --- .../TransformSync/AnglerTransformSync.cs | 2 +- .../RemoteThrusterFlameController.cs | 2 +- QSB/DeathSync/Patches/DeathPatches.cs | 2 +- QSB/HUD/MultiplayerHUDManager.cs | 2 +- .../TransformSync/JellyfishTransformSync.cs | 2 +- QSB/Menus/MenuManager.cs | 2 +- QSB/Messaging/QSBMessageManager.cs | 4 +- QSB/Player/Messages/PlayerJoinMessage.cs | 7 -- .../TransformSync/PlayerTransformSync.cs | 2 +- QSB/QSB.csproj | 3 - QSB/QSBCore.cs | 102 +++++++++++------- QSB/QSBNetworkManager.cs | 10 +- QSB/QuantumSync/QuantumManager.cs | 2 +- QSB/RespawnSync/RespawnManager.cs | 2 +- QSB/Syncs/SyncBase.cs | 4 +- QSB/TimeSync/WakeUpSync.cs | 4 +- .../TranslatorTool/QSBTranslatorScanBeam.cs | 2 +- QSB/Utility/CommandInterpreter.cs | 2 +- QSB/Utility/DebugActions.cs | 2 +- QSB/Utility/DebugCameraSettings.cs | 24 ++--- QSB/Utility/DebugGUI.cs | 28 +---- QSB/Utility/DebugLog.cs | 4 +- QSB/Utility/DebugSettings.cs | 63 ----------- QSB/default-config.json | 74 ++++++++++++- 24 files changed, 179 insertions(+), 172 deletions(-) delete mode 100644 QSB/Utility/DebugSettings.cs diff --git a/QSB/Anglerfish/TransformSync/AnglerTransformSync.cs b/QSB/Anglerfish/TransformSync/AnglerTransformSync.cs index 6bd58767..7b0dd4b8 100644 --- a/QSB/Anglerfish/TransformSync/AnglerTransformSync.cs +++ b/QSB/Anglerfish/TransformSync/AnglerTransformSync.cs @@ -64,7 +64,7 @@ public class AnglerTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehavi protected override void OnRenderObject() { - if (!QSBCore.DebugSettings.DrawLines + if (!QSBCore.DrawLines || !IsValid || !ReferenceTransform || !AttachedTransform.gameObject.activeInHierarchy) diff --git a/QSB/Animation/Player/Thrusters/RemoteThrusterFlameController.cs b/QSB/Animation/Player/Thrusters/RemoteThrusterFlameController.cs index 835fb0b7..551349b6 100644 --- a/QSB/Animation/Player/Thrusters/RemoteThrusterFlameController.cs +++ b/QSB/Animation/Player/Thrusters/RemoteThrusterFlameController.cs @@ -105,7 +105,7 @@ public class RemoteThrusterFlameController : MonoBehaviour private void OnRenderObject() { - if (!QSBCore.DebugSettings.DrawLines || !QSBWorldSync.AllObjectsReady) + if (!QSBCore.DrawLines || !QSBWorldSync.AllObjectsReady) { return; } diff --git a/QSB/DeathSync/Patches/DeathPatches.cs b/QSB/DeathSync/Patches/DeathPatches.cs index ea4be865..1d025381 100644 --- a/QSB/DeathSync/Patches/DeathPatches.cs +++ b/QSB/DeathSync/Patches/DeathPatches.cs @@ -83,7 +83,7 @@ public class DeathPatches : QSBPatch } var deadPlayersCount = QSBPlayerManager.PlayerList.Count(x => x.IsDead); - if (deadPlayersCount == QSBPlayerManager.PlayerList.Count - 1 && !QSBCore.DebugSettings.DisableLoopDeath) + if (deadPlayersCount == QSBPlayerManager.PlayerList.Count - 1) { new EndLoopMessage().Send(); DebugLog.DebugWrite($"- All players are dead."); diff --git a/QSB/HUD/MultiplayerHUDManager.cs b/QSB/HUD/MultiplayerHUDManager.cs index 37886cd7..bce6cfbe 100644 --- a/QSB/HUD/MultiplayerHUDManager.cs +++ b/QSB/HUD/MultiplayerHUDManager.cs @@ -230,7 +230,7 @@ public class MultiplayerHUDManager : MonoBehaviour, IAddComponentOnStart previousMessages.Push(message); - if (QSBCore.DebugSettings.DebugMode && CommandInterpreter.InterpretCommand(message)) + if (QSBCore.DebugMode && CommandInterpreter.InterpretCommand(message)) { return; } diff --git a/QSB/JellyfishSync/TransformSync/JellyfishTransformSync.cs b/QSB/JellyfishSync/TransformSync/JellyfishTransformSync.cs index a389a920..02b9389b 100644 --- a/QSB/JellyfishSync/TransformSync/JellyfishTransformSync.cs +++ b/QSB/JellyfishSync/TransformSync/JellyfishTransformSync.cs @@ -88,7 +88,7 @@ public class JellyfishTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBeh protected override void OnRenderObject() { - if (!QSBCore.DebugSettings.DrawLines + if (!QSBCore.DrawLines || !IsValid || !ReferenceTransform || !AttachedTransform.gameObject.activeInHierarchy) diff --git a/QSB/Menus/MenuManager.cs b/QSB/Menus/MenuManager.cs index 865852a4..891487c7 100644 --- a/QSB/Menus/MenuManager.cs +++ b/QSB/Menus/MenuManager.cs @@ -71,7 +71,7 @@ public class MenuManager : MonoBehaviour, IAddComponentOnStart QSBLocalization.LanguageChanged += OnLanguageChanged; - if (QSBCore.DebugSettings.AutoStart) + if (QSBCore.AutoStart) { // auto host/connect Delay.RunWhen(PlayerData.IsLoaded, () => diff --git a/QSB/Messaging/QSBMessageManager.cs b/QSB/Messaging/QSBMessageManager.cs index c4be56f9..0b8cb43d 100644 --- a/QSB/Messaging/QSBMessageManager.cs +++ b/QSB/Messaging/QSBMessageManager.cs @@ -49,7 +49,7 @@ public static class QSBMessageManager NetworkServer.RegisterHandler((_, wrapper) => OnServerReceive(wrapper)); NetworkClient.RegisterHandler(wrapper => OnClientReceive(wrapper)); - if (!QSBCore.DebugSettings.LogQSBMessages) + if (!QSBCore.LogQSBMessages) { return; } @@ -169,7 +169,7 @@ public static class QSBMessageManager public static void SaveRXTX(QSBMessage msg, bool transmit) { - if (!QSBCore.DebugSettings.LogQSBMessages) + if (!QSBCore.LogQSBMessages) { return; } diff --git a/QSB/Player/Messages/PlayerJoinMessage.cs b/QSB/Player/Messages/PlayerJoinMessage.cs index 6a2fec8f..46deac8a 100644 --- a/QSB/Player/Messages/PlayerJoinMessage.cs +++ b/QSB/Player/Messages/PlayerJoinMessage.cs @@ -62,13 +62,6 @@ public class PlayerJoinMessage : QSBMessage { if (QSBCore.IsHost) { - if (QSBCore.DebugSettings.KickEveryone) - { - DebugLog.ToConsole($"Kicking {PlayerName} because of DebugSettings.KickEveryone", MessageType.Error); - new PlayerKickMessage(From, "This server has DebugSettings.KickEveryone enabled.").Send(); - return; - } - if (QSBVersion != QSBCore.QSBVersion) { DebugLog.ToConsole($"Error - Client {PlayerName} connecting with wrong QSB version. (Client:{QSBVersion}, Server:{QSBCore.QSBVersion})", MessageType.Error); diff --git a/QSB/Player/TransformSync/PlayerTransformSync.cs b/QSB/Player/TransformSync/PlayerTransformSync.cs index 27f79e29..329a0b22 100644 --- a/QSB/Player/TransformSync/PlayerTransformSync.cs +++ b/QSB/Player/TransformSync/PlayerTransformSync.cs @@ -111,7 +111,7 @@ public class PlayerTransformSync : SectoredTransformSync protected override void OnRenderObject() { - if (!QSBCore.DebugSettings.DrawLines + if (!QSBCore.DrawLines || !IsValid || !ReferenceTransform) { diff --git a/QSB/QSB.csproj b/QSB/QSB.csproj index 6d8b84d6..4a903159 100644 --- a/QSB/QSB.csproj +++ b/QSB/QSB.csproj @@ -66,9 +66,6 @@ - - PreserveNewest - PreserveNewest diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index 9893d0b7..4de146d6 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -72,15 +72,45 @@ public class QSBCore : ModBehaviour public static bool TextChatInput { get; private set; } public static string SkinVariation { get; private set; } = "Default"; public static string JetpackVariation { get; private set; } = "Orange"; + public static int Timeout { get; private set; } + + public static bool DebugMode { get; private set; } + + private static bool _instanceIdInLogs; + public static bool InstanceIDInLogs => DebugMode && _instanceIdInLogs; + + private static bool _hookDebugLogs; + public static bool HookDebugLogs => DebugMode && _hookDebugLogs; + + private static bool _avoidTimeSync; + public static bool AvoidTimeSync => DebugMode && _avoidTimeSync; + + private static bool _autoStart; + public static bool AutoStart => DebugMode && _autoStart; + + private static bool _drawGUI; + public static bool DrawGUI => DebugMode && _drawGUI; + + private static bool _drawLines; + public static bool DrawLines => DebugMode && _drawLines; + + private static bool _drawLabels; + public static bool DrawLabels => DebugMode && _drawLabels; + + private static bool _greySkybox; + public static bool GreySkybox => DebugMode && _greySkybox; + + private static float _latencySimulation; + public static float LatencySimulation => DebugMode ? _latencySimulation : 0; + + private static bool _logQSBMessages; + public static bool LogQSBMessages => DebugMode && _logQSBMessages; + public static GameVendor GameVendor { get; private set; } = GameVendor.None; public static bool IsStandalone => GameVendor is GameVendor.Epic or GameVendor.Steam; public static IProfileManager ProfileManager => IsStandalone ? QSBStandaloneProfileManager.SharedInstance : QSBMSStoreProfileManager.SharedInstance; - public static DebugSettings DebugSettings { get; private set; } = new(); - - private static string randomSkinType; - private static string randomJetpackType; public static Assembly QSBNHAssembly = null; @@ -217,9 +247,7 @@ public class QSBCore : ModBehaviour CheckNewHorizons(); - DebugSettings = Helper.Storage.Load("debugsettings.json") ?? new DebugSettings(); - - if (DebugSettings.HookDebugLogs) + if (HookDebugLogs) { Application.logMessageReceived += (condition, stackTrace, logType) => DebugLog.ToConsole( @@ -237,10 +265,9 @@ public class QSBCore : ModBehaviour ); } - if (DebugSettings.AutoStart) + if (AutoStart) { UseKcpTransport = true; - DebugSettings.DebugMode = true; } RegisterAddons(); @@ -273,19 +300,6 @@ public class QSBCore : ModBehaviour QSBWorldSync.Managers = components.OfType().ToArray(); QSBPatchManager.OnPatchType += OnPatchType; QSBPatchManager.OnUnpatchType += OnUnpatchType; - - if (DebugSettings.RandomizeSkins) - { - var skinSetting = (JObject)ModHelper.Config.Settings["skinType"]; - var skinOptions = skinSetting["options"].ToObject(); - randomSkinType = skinOptions[UnityEngine.Random.Range(0, skinOptions.Length - 1)]; - - var jetpackSetting = (JObject)ModHelper.Config.Settings["jetpackType"]; - var jetpackOptions = jetpackSetting["options"].ToObject(); - randomJetpackType = jetpackOptions[UnityEngine.Random.Range(0, jetpackOptions.Length - 1)]; - - Configure(ModHelper.Config); - } } private AssetBundle LoadBundle(string bundleName) @@ -402,7 +416,29 @@ public class QSBCore : ModBehaviour public override void Configure(IModConfig config) { - UseKcpTransport = config.GetSettingsValue("useKcpTransport") || DebugSettings.AutoStart; + DebugMode = config.GetSettingsValue("debugMode"); + + if (GetComponent() != null) + { + GetComponent().enabled = DebugMode; + GetComponent().enabled = DebugMode; + } + + _instanceIdInLogs = config.GetSettingsValue("instanceIdInLogs"); + _hookDebugLogs = config.GetSettingsValue("hookDebugLogs"); + _avoidTimeSync = config.GetSettingsValue("avoidTimeSync"); + _autoStart = config.GetSettingsValue("autoStart"); + _drawGUI = config.GetSettingsValue("drawGui"); + _drawLines = config.GetSettingsValue("drawLines"); + _drawLabels = config.GetSettingsValue("drawLabels"); + _greySkybox = config.GetSettingsValue("greySkybox"); + _latencySimulation = config.GetSettingsValue("latencySimulation"); + _logQSBMessages = config.GetSettingsValue("logQSBMessages"); + + DebugCameraSettings.UpdateFromDebugSetting(); + + Timeout = config.GetSettingsValue("timeout"); + UseKcpTransport = config.GetSettingsValue("useKcpTransport") || AutoStart; var foundValue = config.GetSettingsValue("kcpPort"); KcpPort = (ushort)Mathf.Clamp(foundValue, ushort.MinValue, ushort.MaxValue); QSBNetworkManager.UpdateTransport(); @@ -414,16 +450,8 @@ public class QSBCore : ModBehaviour TextChatInput = config.GetSettingsValue("textChatInput"); AlwaysShowPlanetIcons = config.GetSettingsValue("alwaysShowPlanetIcons"); - if (DebugSettings.RandomizeSkins) - { - SkinVariation = randomSkinType; - JetpackVariation = randomJetpackType; - } - else - { - SkinVariation = config.GetSettingsValue("skinType"); - JetpackVariation = config.GetSettingsValue("jetpackType"); - } + SkinVariation = config.GetSettingsValue("skinType"); + JetpackVariation = config.GetSettingsValue("jetpackType"); if (IsHost) { @@ -442,13 +470,13 @@ public class QSBCore : ModBehaviour { if (Keyboard.current[Key.Q].isPressed && Keyboard.current[Key.NumpadEnter].wasPressedThisFrame) { - DebugSettings.DebugMode = !DebugSettings.DebugMode; + DebugMode = !DebugMode; - GetComponent().enabled = DebugSettings.DebugMode; - GetComponent().enabled = DebugSettings.DebugMode; + GetComponent().enabled = DebugMode; + GetComponent().enabled = DebugMode; DebugCameraSettings.UpdateFromDebugSetting(); - DebugLog.ToConsole($"DEBUG MODE = {DebugSettings.DebugMode}"); + DebugLog.ToConsole($"DEBUG MODE = {DebugMode}"); } if (_steamworksInitialized) diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index fb894121..9c119bf9 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -79,23 +79,23 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart { _kcpTransport = gameObject.AddComponent(); // KCP uses milliseconds - _kcpTransport.Timeout = QSBCore.DebugSettings.Timeout * 1000; + _kcpTransport.Timeout = QSBCore.Timeout * 1000; _kcpTransport.Port = QSBCore.KcpPort; } { _steamTransport = gameObject.AddComponent(); // Steam uses seconds - _steamTransport.Timeout = QSBCore.DebugSettings.Timeout; + _steamTransport.Timeout = QSBCore.Timeout; } { _latencyTransport = gameObject.AddComponent(); - _latencyTransport.reliableLatency = _latencyTransport.unreliableLatency = QSBCore.DebugSettings.LatencySimulation; + _latencyTransport.reliableLatency = _latencyTransport.unreliableLatency = QSBCore.LatencySimulation; _latencyTransport.wrap = QSBCore.UseKcpTransport ? _kcpTransport : _steamTransport; } - transport = QSBCore.DebugSettings.LatencySimulation > 0 + transport = QSBCore.LatencySimulation > 0 ? _latencyTransport : QSBCore.UseKcpTransport ? _kcpTransport : _steamTransport; @@ -176,7 +176,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart if (singleton != null) { - if (QSBCore.DebugSettings.LatencySimulation > 0) + if (QSBCore.LatencySimulation > 0) { _latencyTransport.wrap = QSBCore.UseKcpTransport ? _kcpTransport : _steamTransport; singleton.transport = Transport.active = _latencyTransport; diff --git a/QSB/QuantumSync/QuantumManager.cs b/QSB/QuantumSync/QuantumManager.cs index 6769ccd5..c744759e 100644 --- a/QSB/QuantumSync/QuantumManager.cs +++ b/QSB/QuantumSync/QuantumManager.cs @@ -56,7 +56,7 @@ public class QuantumManager : WorldObjectManager public void OnRenderObject() { - if (!QSBCore.DebugSettings.DrawLines) + if (!QSBCore.DrawLines) { return; } diff --git a/QSB/RespawnSync/RespawnManager.cs b/QSB/RespawnSync/RespawnManager.cs index 7d8b43e9..b21c4fa8 100644 --- a/QSB/RespawnSync/RespawnManager.cs +++ b/QSB/RespawnSync/RespawnManager.cs @@ -162,7 +162,7 @@ public class RespawnManager : MonoBehaviour, IAddComponentOnStart var deadPlayersCount = QSBPlayerManager.PlayerList.Count(x => x.IsDead); - if (deadPlayersCount == QSBPlayerManager.PlayerList.Count && !QSBCore.DebugSettings.DisableLoopDeath) + if (deadPlayersCount == QSBPlayerManager.PlayerList.Count) { new EndLoopMessage().Send(); return; diff --git a/QSB/Syncs/SyncBase.cs b/QSB/Syncs/SyncBase.cs index c024455f..f9672a93 100644 --- a/QSB/Syncs/SyncBase.cs +++ b/QSB/Syncs/SyncBase.cs @@ -309,7 +309,7 @@ public abstract class SyncBase : QSBNetworkTransform protected virtual void OnRenderObject() { - if (!QSBCore.DebugSettings.DrawLines + if (!QSBCore.DrawLines || !IsValid || !ReferenceTransform) { @@ -334,7 +334,7 @@ public abstract class SyncBase : QSBNetworkTransform private void OnGUI() { - if (!QSBCore.DebugSettings.DrawLabels + if (!QSBCore.DrawLabels || Event.current.type != EventType.Repaint || !IsValid || !ReferenceTransform) diff --git a/QSB/TimeSync/WakeUpSync.cs b/QSB/TimeSync/WakeUpSync.cs index a04af356..c6663480 100644 --- a/QSB/TimeSync/WakeUpSync.cs +++ b/QSB/TimeSync/WakeUpSync.cs @@ -124,7 +124,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart } else { - if (!QSBCore.DebugSettings.AvoidTimeSync) + if (!QSBCore.AvoidTimeSync) { WakeUpOrSleep(); } @@ -275,7 +275,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart { UpdateServer(); } - else if (NetworkClient.active && QSBSceneManager.IsInUniverse && !QSBCore.DebugSettings.AvoidTimeSync) + else if (NetworkClient.active && QSBSceneManager.IsInUniverse && !QSBCore.AvoidTimeSync) { UpdateClient(); } diff --git a/QSB/Tools/TranslatorTool/QSBTranslatorScanBeam.cs b/QSB/Tools/TranslatorTool/QSBTranslatorScanBeam.cs index 4591349f..952aee2b 100644 --- a/QSB/Tools/TranslatorTool/QSBTranslatorScanBeam.cs +++ b/QSB/Tools/TranslatorTool/QSBTranslatorScanBeam.cs @@ -80,7 +80,7 @@ public class QSBTranslatorScanBeam : MonoBehaviour private void OnRenderObject() { - if (!QSBCore.DebugSettings.DrawLines || !QSBWorldSync.AllObjectsReady) + if (!QSBCore.DrawLines || !QSBWorldSync.AllObjectsReady) { return; } diff --git a/QSB/Utility/CommandInterpreter.cs b/QSB/Utility/CommandInterpreter.cs index ee4a7ce8..2f67378e 100644 --- a/QSB/Utility/CommandInterpreter.cs +++ b/QSB/Utility/CommandInterpreter.cs @@ -60,7 +60,7 @@ public class CommandInterpreter : MonoBehaviour, IAddComponentOnStart public static void ShipCommand(string[] arguments) { - if (!QSBCore.DebugSettings.DebugMode) + if (!QSBCore.DebugMode) { return; } diff --git a/QSB/Utility/DebugActions.cs b/QSB/Utility/DebugActions.cs index 1cf23019..87b74de2 100644 --- a/QSB/Utility/DebugActions.cs +++ b/QSB/Utility/DebugActions.cs @@ -45,7 +45,7 @@ public class DebugActions : MonoBehaviour, IAddComponentOnStart private static void DamageShipElectricalSystem() => ShipManager.Instance.ShipElectricalComponent.SetDamaged(true); - private void Awake() => enabled = QSBCore.DebugSettings.DebugMode; + private void Awake() => enabled = QSBCore.DebugMode; private int _otherPlayerToTeleportTo; private int _backTimer; diff --git a/QSB/Utility/DebugCameraSettings.cs b/QSB/Utility/DebugCameraSettings.cs index 661e5100..b459b7b8 100644 --- a/QSB/Utility/DebugCameraSettings.cs +++ b/QSB/Utility/DebugCameraSettings.cs @@ -6,21 +6,21 @@ public class DebugCameraSettings : MonoBehaviour, IAddComponentOnStart { public static void UpdateFromDebugSetting() { - if (QSBCore.DebugSettings.GreySkybox) + QSBSceneManager.OnSceneLoaded -= OnSceneLoaded; + if (Camera.main) { - QSBSceneManager.OnSceneLoaded += OnSceneLoaded; - if (Camera.main) - { - Camera.main.backgroundColor = Color.gray; - } + Camera.main.backgroundColor = _origColor; } - else + + if (!QSBCore.GreySkybox) { - QSBSceneManager.OnSceneLoaded -= OnSceneLoaded; - if (Camera.main) - { - Camera.main.backgroundColor = _origColor; - } + return; + } + + QSBSceneManager.OnSceneLoaded += OnSceneLoaded; + if (Camera.main) + { + Camera.main.backgroundColor = Color.gray; } } diff --git a/QSB/Utility/DebugGUI.cs b/QSB/Utility/DebugGUI.cs index 308496e5..5e0e9c16 100644 --- a/QSB/Utility/DebugGUI.cs +++ b/QSB/Utility/DebugGUI.cs @@ -37,7 +37,7 @@ public class DebugGUI : MonoBehaviour, IAddComponentOnStart private void Awake() { - enabled = QSBCore.DebugSettings.DebugMode; + enabled = QSBCore.DebugMode; guiGUIStyle.fontSize = 9; } @@ -105,7 +105,7 @@ public class DebugGUI : MonoBehaviour, IAddComponentOnStart WriteLine(1, $"FPS : {Mathf.Round(1f / Time.smoothDeltaTime)}"); WriteLine(1, $"Ping : {Math.Round(NetworkTime.rtt * 1000.0)} ms"); - if (!QSBCore.DebugSettings.DrawGui) + if (!QSBCore.DrawGUI) { return; } @@ -408,7 +408,7 @@ public class DebugGUI : MonoBehaviour, IAddComponentOnStart private static void DrawWorldObjectLabels() { - if (QSBCore.DebugSettings.DrawLabels) + if (QSBCore.DrawLabels) { var list = DebugActions.WorldObjectSelection == null ? QSBWorldSync.GetWorldObjects() @@ -422,23 +422,13 @@ public class DebugGUI : MonoBehaviour, IAddComponentOnStart } } } - else if (QSBCore.DebugSettings.DrawGhostAI) - { - foreach (var obj in QSBWorldSync.GetWorldObjects()) - { - if (obj.ShouldDisplayDebug()) - { - DrawLabel(obj.AttachedObject.transform, obj.ReturnLabel()); - } - } - } } public void OnRenderObject() => DrawWorldObjectLines(); private static void DrawWorldObjectLines() { - if (QSBCore.DebugSettings.DrawLines) + if (QSBCore.DrawLines) { var list = DebugActions.WorldObjectSelection == null ? QSBWorldSync.GetWorldObjects() @@ -452,16 +442,6 @@ public class DebugGUI : MonoBehaviour, IAddComponentOnStart } } } - else if (QSBCore.DebugSettings.DrawGhostAI) - { - foreach (var obj in QSBWorldSync.GetWorldObjects()) - { - if (obj.ShouldDisplayDebug()) - { - obj.DisplayLines(); - } - } - } } public static void DrawLabel(Transform obj, string label) diff --git a/QSB/Utility/DebugLog.cs b/QSB/Utility/DebugLog.cs index ee3ce361..f5a429b7 100644 --- a/QSB/Utility/DebugLog.cs +++ b/QSB/Utility/DebugLog.cs @@ -16,7 +16,7 @@ public static class DebugLog public static void ToConsole(string message, MessageType type = MessageType.Message) { - if (QSBCore.DebugSettings.InstanceIdInLogs) + if (QSBCore.InstanceIDInLogs) { message = $"[{ProcessInstanceId}] " + message; } @@ -44,7 +44,7 @@ public static class DebugLog public static void DebugWrite(string message, MessageType type = MessageType.Message) { - if (QSBCore.Helper == null || QSBCore.DebugSettings.DebugMode) + if (QSBCore.Helper == null || QSBCore.DebugMode) { ToConsole(message, type); } diff --git a/QSB/Utility/DebugSettings.cs b/QSB/Utility/DebugSettings.cs deleted file mode 100644 index b928e1c9..00000000 --- a/QSB/Utility/DebugSettings.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Newtonsoft.Json; - -namespace QSB.Utility; - -[JsonObject(MemberSerialization.OptIn)] -public class DebugSettings -{ - [JsonProperty("logQSBMessages")] - public bool LogQSBMessages; - - [JsonProperty("instanceIdInLogs")] - public bool InstanceIdInLogs; - - [JsonProperty("hookDebugLogs")] - public bool HookDebugLogs; - - [JsonProperty("avoidTimeSync")] - public bool AvoidTimeSync; - - [JsonProperty("autoStart")] - public bool AutoStart; - - [JsonProperty("kickEveryone")] - public bool KickEveryone; - - [JsonProperty("disableLoopDeath")] - public bool DisableLoopDeath; - - [JsonProperty("latencySimulation")] - public int LatencySimulation; - - [JsonProperty("randomizeSkins")] - public bool RandomizeSkins; - - /// - /// Timeout in seconds - /// - [JsonProperty("timeout")] - public int Timeout = 40; - - [JsonProperty("debugMode")] - public bool DebugMode; - - [JsonProperty("drawGui")] - private bool _drawGui; - public bool DrawGui => DebugMode && _drawGui; - - [JsonProperty("drawLines")] - private bool _drawLines; - public bool DrawLines => DebugMode && _drawLines; - - [JsonProperty("drawLabels")] - private bool _drawLabels; - public bool DrawLabels => DebugMode && _drawLabels; - - [JsonProperty("drawGhostAI")] - private bool _drawGhostAI; - public bool DrawGhostAI => DebugMode && _drawGhostAI; - - [JsonProperty("greySkybox")] - private bool _greySkybox; - public bool GreySkybox => DebugMode && _greySkybox; -} diff --git a/QSB/default-config.json b/QSB/default-config.json index a1e68b4d..3287a0a6 100644 --- a/QSB/default-config.json +++ b/QSB/default-config.json @@ -34,6 +34,12 @@ "value": "localhost", "tooltip": "Used if you leave the connect prompt blank." }, + "timeout": { + "title": "Timeout", + "type": "number", + "value": 40, + "tooltip": "How many seconds it takes for a connection to time out." + }, "showPlayerNames": { "title": "Show Player Names", "type": "toggle", @@ -57,12 +63,78 @@ "type": "toggle", "value": false, "tooltip": "If disabled, the planet icon shown for each player will be replaced by a question mark (?) in thematically appropriate situations." - } , + }, "textChatInput": { "title": "Text Chat Input", "type": "toggle", "value": true, "tooltip": "Disable this if using NomaiVR, or any other mod with conflicting inputs." + }, + "debugMode": { + "title": "[DEBUG] Debug Mode", + "type": "toggle", + "value": false, + "tooltip": "[DEBUG] Enables debug mode. If this is disabled, none of the following settings do anything." + }, + "instanceIdInLogs": { + "title": "[DEBUG] Instance ID in Logs", + "type": "toggle", + "value": false, + "tooltip": "[DEBUG] Appends the game instance id to every log message sent. Only takes effect after a game restart." + }, + "hookDebugLogs": { + "title": "[DEBUG] Hook Debug Logs", + "type": "toggle", + "value": false, + "tooltip": "[DEBUG] Prints every Unity warning + error to the logs. Only takes effect after a game restart." + }, + "avoidTimeSync": { + "title": "[DEBUG] Disable Time Sync", + "type": "toggle", + "value": false, + "tooltip": "[DEBUG] If enabled, you will no longer fast forward / pause to match the server time. THIS CAN BREAK A LOT OF STUFF!" + }, + "autoStart": { + "title": "[DEBUG] Auto Start", + "type": "toggle", + "value": false, + "tooltip": "[DEBUG] Automatically host and connect depending on the game instance id for faster testing." + }, + "drawGui": { + "title": "[DEBUG] Draw GUI", + "type": "toggle", + "value": false, + "tooltip": "[DEBUG] Draws a lot of helpful text at the top of the screen." + }, + "drawLines": { + "title": "[DEBUG] Draw Lines", + "type": "toggle", + "value": false, + "tooltip": "[DEBUG] Draws a lot of helpful lines between stuff. LAGGY!" + }, + "drawLabels": { + "title": "[DEBUG] Draw Labels", + "type": "toggle", + "value": false, + "tooltip": "[DEBUG] Draws a lot of helpful labels on stuff. LAGGY!" + }, + "greySkybox": { + "title": "[DEBUG] Grey Skybox", + "type": "toggle", + "value": false, + "tooltip": "[DEBUG] Makes the skybox grey." + }, + "latencySimulation": { + "title": "[DEBUG] Latency Simulation", + "type": "number", + "value": 0, + "tooltip": "[DEBUG] How many seconds of latency to simulate." + }, + "logQSBMessages": { + "title": "[DEBUG] Log QSB Messages", + "type": "toggle", + "value": false, + "tooltip": "[DEBUG] If enabled, QSB creates log files of every network message received and transmitted." } } } \ No newline at end of file