mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-12-11 20:15:10 +01:00
add debugsettings class back
This commit is contained in:
parent
72f298c2d8
commit
1e8694e9c8
@ -64,7 +64,7 @@ public class AnglerTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehavi
|
||||
|
||||
protected override void OnRenderObject()
|
||||
{
|
||||
if (!QSBCore.DrawLines
|
||||
if (!QSBCore.DebugSettings.DrawLines
|
||||
|| !IsValid
|
||||
|| !ReferenceTransform
|
||||
|| !AttachedTransform.gameObject.activeInHierarchy)
|
||||
|
||||
@ -105,7 +105,7 @@ public class RemoteThrusterFlameController : MonoBehaviour
|
||||
|
||||
private void OnRenderObject()
|
||||
{
|
||||
if (!QSBCore.DrawLines || !QSBWorldSync.AllObjectsReady)
|
||||
if (!QSBCore.DebugSettings.DrawLines || !QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ public class MultiplayerHUDManager : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
previousMessages.Push(message);
|
||||
|
||||
if (QSBCore.DebugMode && CommandInterpreter.InterpretCommand(message))
|
||||
if (QSBCore.DebugSettings.DebugMode && CommandInterpreter.InterpretCommand(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public class JellyfishTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBeh
|
||||
|
||||
protected override void OnRenderObject()
|
||||
{
|
||||
if (!QSBCore.DrawLines
|
||||
if (!QSBCore.DebugSettings.DrawLines
|
||||
|| !IsValid
|
||||
|| !ReferenceTransform
|
||||
|| !AttachedTransform.gameObject.activeInHierarchy)
|
||||
|
||||
@ -71,7 +71,7 @@ public class MenuManager : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
QSBLocalization.LanguageChanged += OnLanguageChanged;
|
||||
|
||||
if (QSBCore.AutoStart)
|
||||
if (QSBCore.DebugSettings.AutoStart)
|
||||
{
|
||||
// auto host/connect
|
||||
Delay.RunWhen(PlayerData.IsLoaded, () =>
|
||||
|
||||
@ -49,7 +49,7 @@ public static class QSBMessageManager
|
||||
NetworkServer.RegisterHandler<Wrapper>((_, wrapper) => OnServerReceive(wrapper));
|
||||
NetworkClient.RegisterHandler<Wrapper>(wrapper => OnClientReceive(wrapper));
|
||||
|
||||
if (!QSBCore.LogQSBMessages)
|
||||
if (!QSBCore.DebugSettings.LogQSBMessages)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -169,7 +169,7 @@ public static class QSBMessageManager
|
||||
|
||||
public static void SaveRXTX(QSBMessage msg, bool transmit)
|
||||
{
|
||||
if (!QSBCore.LogQSBMessages)
|
||||
if (!QSBCore.DebugSettings.LogQSBMessages)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public class PlayerTransformSync : SectoredTransformSync
|
||||
|
||||
protected override void OnRenderObject()
|
||||
{
|
||||
if (!QSBCore.DrawLines
|
||||
if (!QSBCore.DebugSettings.DrawLines
|
||||
|| !IsValid
|
||||
|| !ReferenceTransform)
|
||||
{
|
||||
|
||||
@ -24,6 +24,7 @@ using QSB.Player.Messages;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using QSB.Utility.Deterministic;
|
||||
using Debug = System.Diagnostics.Debug;
|
||||
|
||||
/*
|
||||
Copyright (C) 2020 - 2025
|
||||
@ -74,43 +75,12 @@ public class QSBCore : ModBehaviour
|
||||
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; }
|
||||
|
||||
public static Assembly QSBNHAssembly = null;
|
||||
|
||||
@ -247,7 +217,7 @@ public class QSBCore : ModBehaviour
|
||||
|
||||
CheckNewHorizons();
|
||||
|
||||
if (HookDebugLogs)
|
||||
if (DebugSettings.HookDebugLogs)
|
||||
{
|
||||
Application.logMessageReceived += (condition, stackTrace, logType) =>
|
||||
DebugLog.ToConsole(
|
||||
@ -265,7 +235,7 @@ public class QSBCore : ModBehaviour
|
||||
);
|
||||
}
|
||||
|
||||
if (AutoStart)
|
||||
if (DebugSettings.AutoStart)
|
||||
{
|
||||
UseKcpTransport = true;
|
||||
}
|
||||
@ -416,29 +386,18 @@ public class QSBCore : ModBehaviour
|
||||
|
||||
public override void Configure(IModConfig config)
|
||||
{
|
||||
DebugMode = config.GetSettingsValue<bool>("debugMode");
|
||||
DebugSettings = new DebugSettings(config);
|
||||
|
||||
if (GetComponent<DebugActions>() != null)
|
||||
{
|
||||
GetComponent<DebugActions>().enabled = DebugMode;
|
||||
GetComponent<DebugGUI>().enabled = DebugMode;
|
||||
GetComponent<DebugActions>().enabled = DebugSettings.DebugMode;
|
||||
GetComponent<DebugGUI>().enabled = DebugSettings.DebugMode;
|
||||
}
|
||||
|
||||
_instanceIdInLogs = config.GetSettingsValue<bool>("instanceIdInLogs");
|
||||
_hookDebugLogs = config.GetSettingsValue<bool>("hookDebugLogs");
|
||||
_avoidTimeSync = config.GetSettingsValue<bool>("avoidTimeSync");
|
||||
_autoStart = config.GetSettingsValue<bool>("autoStart");
|
||||
_drawGUI = config.GetSettingsValue<bool>("drawGui");
|
||||
_drawLines = config.GetSettingsValue<bool>("drawLines");
|
||||
_drawLabels = config.GetSettingsValue<bool>("drawLabels");
|
||||
_greySkybox = config.GetSettingsValue<bool>("greySkybox");
|
||||
_latencySimulation = config.GetSettingsValue<int>("latencySimulation");
|
||||
_logQSBMessages = config.GetSettingsValue<bool>("logQSBMessages");
|
||||
|
||||
DebugCameraSettings.UpdateFromDebugSetting();
|
||||
|
||||
Timeout = config.GetSettingsValue<int>("timeout");
|
||||
UseKcpTransport = config.GetSettingsValue<bool>("useKcpTransport") || AutoStart;
|
||||
UseKcpTransport = config.GetSettingsValue<bool>("useKcpTransport") || DebugSettings.AutoStart;
|
||||
var foundValue = config.GetSettingsValue<int>("kcpPort");
|
||||
KcpPort = (ushort)Mathf.Clamp(foundValue, ushort.MinValue, ushort.MaxValue);
|
||||
QSBNetworkManager.UpdateTransport();
|
||||
@ -470,13 +429,13 @@ public class QSBCore : ModBehaviour
|
||||
{
|
||||
if (Keyboard.current[Key.Q].isPressed && Keyboard.current[Key.NumpadEnter].wasPressedThisFrame)
|
||||
{
|
||||
DebugMode = !DebugMode;
|
||||
DebugSettings.DebugMode = !DebugSettings.DebugMode;
|
||||
|
||||
GetComponent<DebugActions>().enabled = DebugMode;
|
||||
GetComponent<DebugGUI>().enabled = DebugMode;
|
||||
GetComponent<DebugActions>().enabled = DebugSettings.DebugMode;
|
||||
GetComponent<DebugGUI>().enabled = DebugSettings.DebugMode;
|
||||
DebugCameraSettings.UpdateFromDebugSetting();
|
||||
|
||||
DebugLog.ToConsole($"DEBUG MODE = {DebugMode}");
|
||||
DebugLog.ToConsole($"DEBUG MODE = {DebugSettings.DebugMode}");
|
||||
}
|
||||
|
||||
if (_steamworksInitialized)
|
||||
|
||||
@ -91,11 +91,11 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart
|
||||
|
||||
{
|
||||
_latencyTransport = gameObject.AddComponent<LatencySimulation>();
|
||||
_latencyTransport.reliableLatency = _latencyTransport.unreliableLatency = QSBCore.LatencySimulation;
|
||||
_latencyTransport.reliableLatency = _latencyTransport.unreliableLatency = QSBCore.DebugSettings.LatencySimulation;
|
||||
_latencyTransport.wrap = QSBCore.UseKcpTransport ? _kcpTransport : _steamTransport;
|
||||
}
|
||||
|
||||
transport = QSBCore.LatencySimulation > 0
|
||||
transport = QSBCore.DebugSettings.LatencySimulation > 0
|
||||
? _latencyTransport
|
||||
: QSBCore.UseKcpTransport ? _kcpTransport : _steamTransport;
|
||||
|
||||
@ -176,7 +176,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart
|
||||
|
||||
if (singleton != null)
|
||||
{
|
||||
if (QSBCore.LatencySimulation > 0)
|
||||
if (QSBCore.DebugSettings.LatencySimulation > 0)
|
||||
{
|
||||
_latencyTransport.wrap = QSBCore.UseKcpTransport ? _kcpTransport : _steamTransport;
|
||||
singleton.transport = Transport.active = _latencyTransport;
|
||||
|
||||
@ -56,7 +56,7 @@ public class QuantumManager : WorldObjectManager
|
||||
|
||||
public void OnRenderObject()
|
||||
{
|
||||
if (!QSBCore.DrawLines)
|
||||
if (!QSBCore.DebugSettings.DrawLines)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ public abstract class SyncBase : QSBNetworkTransform
|
||||
|
||||
protected virtual void OnRenderObject()
|
||||
{
|
||||
if (!QSBCore.DrawLines
|
||||
if (!QSBCore.DebugSettings.DrawLines
|
||||
|| !IsValid
|
||||
|| !ReferenceTransform)
|
||||
{
|
||||
@ -334,7 +334,7 @@ public abstract class SyncBase : QSBNetworkTransform
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!QSBCore.DrawLabels
|
||||
if (!QSBCore.DebugSettings.DrawLabels
|
||||
|| Event.current.type != EventType.Repaint
|
||||
|| !IsValid
|
||||
|| !ReferenceTransform)
|
||||
|
||||
@ -124,7 +124,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!QSBCore.AvoidTimeSync)
|
||||
if (!QSBCore.DebugSettings.AvoidTimeSync)
|
||||
{
|
||||
WakeUpOrSleep();
|
||||
}
|
||||
@ -275,7 +275,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
||||
{
|
||||
UpdateServer();
|
||||
}
|
||||
else if (NetworkClient.active && QSBSceneManager.IsInUniverse && !QSBCore.AvoidTimeSync)
|
||||
else if (NetworkClient.active && QSBSceneManager.IsInUniverse && !QSBCore.DebugSettings.AvoidTimeSync)
|
||||
{
|
||||
UpdateClient();
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class QSBTranslatorScanBeam : MonoBehaviour
|
||||
|
||||
private void OnRenderObject()
|
||||
{
|
||||
if (!QSBCore.DrawLines || !QSBWorldSync.AllObjectsReady)
|
||||
if (!QSBCore.DebugSettings.DrawLines || !QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public class CommandInterpreter : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
public static void ShipCommand(string[] arguments)
|
||||
{
|
||||
if (!QSBCore.DebugMode)
|
||||
if (!QSBCore.DebugSettings.DebugMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class DebugActions : MonoBehaviour, IAddComponentOnStart
|
||||
private static void DamageShipElectricalSystem() =>
|
||||
ShipManager.Instance.ShipElectricalComponent.SetDamaged(true);
|
||||
|
||||
private void Awake() => enabled = QSBCore.DebugMode;
|
||||
private void Awake() => enabled = QSBCore.DebugSettings.DebugMode;
|
||||
|
||||
private int _otherPlayerToTeleportTo;
|
||||
private int _backTimer;
|
||||
|
||||
@ -12,7 +12,7 @@ public class DebugCameraSettings : MonoBehaviour, IAddComponentOnStart
|
||||
Camera.main.backgroundColor = _origColor;
|
||||
}
|
||||
|
||||
if (!QSBCore.GreySkybox)
|
||||
if (QSBCore.DebugSettings == null || !QSBCore.DebugSettings.GreySkybox)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ public class DebugGUI : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
enabled = QSBCore.DebugMode;
|
||||
enabled = QSBCore.DebugSettings.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.DrawGUI)
|
||||
if (!QSBCore.DebugSettings.DrawGUI)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -408,7 +408,7 @@ public class DebugGUI : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
private static void DrawWorldObjectLabels()
|
||||
{
|
||||
if (QSBCore.DrawLabels)
|
||||
if (QSBCore.DebugSettings.DrawLabels)
|
||||
{
|
||||
var list = DebugActions.WorldObjectSelection == null
|
||||
? QSBWorldSync.GetWorldObjects()
|
||||
@ -428,7 +428,7 @@ public class DebugGUI : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
private static void DrawWorldObjectLines()
|
||||
{
|
||||
if (QSBCore.DrawLines)
|
||||
if (QSBCore.DebugSettings.DrawLines)
|
||||
{
|
||||
var list = DebugActions.WorldObjectSelection == null
|
||||
? QSBWorldSync.GetWorldObjects()
|
||||
|
||||
@ -16,7 +16,7 @@ public static class DebugLog
|
||||
|
||||
public static void ToConsole(string message, MessageType type = MessageType.Message)
|
||||
{
|
||||
if (QSBCore.InstanceIDInLogs)
|
||||
if (QSBCore.DebugSettings != null && QSBCore.DebugSettings.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.DebugMode)
|
||||
if (QSBCore.Helper == null || QSBCore.DebugSettings == null || QSBCore.DebugSettings.DebugMode)
|
||||
{
|
||||
ToConsole(message, type);
|
||||
}
|
||||
|
||||
56
QSB/Utility/DebugSettings.cs
Normal file
56
QSB/Utility/DebugSettings.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Newtonsoft.Json;
|
||||
using OWML.Common;
|
||||
|
||||
namespace QSB.Utility;
|
||||
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class DebugSettings
|
||||
{
|
||||
public bool DebugMode;
|
||||
|
||||
private bool _logQSBMessages;
|
||||
public bool LogQSBMessages => DebugMode && _logQSBMessages;
|
||||
|
||||
private bool _instanceIdInLogs;
|
||||
public bool InstanceIDInLogs => DebugMode && _instanceIdInLogs;
|
||||
|
||||
private bool _hookDebugLogs;
|
||||
public bool HookDebugLogs => DebugMode && _hookDebugLogs;
|
||||
|
||||
private bool _avoidTimeSync;
|
||||
public bool AvoidTimeSync => DebugMode && _avoidTimeSync;
|
||||
|
||||
private bool _autoStart;
|
||||
public bool AutoStart => DebugMode && _autoStart;
|
||||
|
||||
private int _latencySimulation;
|
||||
public int LatencySimulation => DebugMode ? _latencySimulation : 0;
|
||||
|
||||
private bool _drawGUI;
|
||||
public bool DrawGUI => DebugMode && _drawGUI;
|
||||
|
||||
private bool _drawLines;
|
||||
public bool DrawLines => DebugMode && _drawLines;
|
||||
|
||||
private bool _drawLabels;
|
||||
public bool DrawLabels => DebugMode && _drawLabels;
|
||||
|
||||
private bool _greySkybox;
|
||||
public bool GreySkybox => DebugMode && _greySkybox;
|
||||
|
||||
public DebugSettings(IModConfig config)
|
||||
{
|
||||
DebugMode = config.GetSettingsValue<bool>("debugMode");
|
||||
|
||||
_instanceIdInLogs = config.GetSettingsValue<bool>("instanceIdInLogs");
|
||||
_hookDebugLogs = config.GetSettingsValue<bool>("hookDebugLogs");
|
||||
_avoidTimeSync = config.GetSettingsValue<bool>("avoidTimeSync");
|
||||
_autoStart = config.GetSettingsValue<bool>("autoStart");
|
||||
_drawGUI = config.GetSettingsValue<bool>("drawGui");
|
||||
_drawLines = config.GetSettingsValue<bool>("drawLines");
|
||||
_drawLabels = config.GetSettingsValue<bool>("drawLabels");
|
||||
_greySkybox = config.GetSettingsValue<bool>("greySkybox");
|
||||
_latencySimulation = config.GetSettingsValue<int>("latencySimulation");
|
||||
_logQSBMessages = config.GetSettingsValue<bool>("logQSBMessages");
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user