Config presets system. (#12824)
This commit is contained in:
committed by
GitHub
parent
326fdefe85
commit
55c61b9c35
@@ -60,9 +60,6 @@ public sealed partial class CargoSystem
|
|||||||
|
|
||||||
private void InitializeShuttle()
|
private void InitializeShuttle()
|
||||||
{
|
{
|
||||||
#if !FULL_RELEASE
|
|
||||||
_configManager.OverrideDefault(CCVars.CargoShuttles, false);
|
|
||||||
#endif
|
|
||||||
_enabled = _configManager.GetCVar(CCVars.CargoShuttles);
|
_enabled = _configManager.GetCVar(CCVars.CargoShuttles);
|
||||||
// Don't want to immediately call this as shuttles will get setup in the natural course of things.
|
// Don't want to immediately call this as shuttles will get setup in the natural course of things.
|
||||||
_configManager.OnValueChanged(CCVars.CargoShuttles, SetCargoShuttleEnabled);
|
_configManager.OnValueChanged(CCVars.CargoShuttles, SetCargoShuttleEnabled);
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ namespace Content.Server.Entry
|
|||||||
{
|
{
|
||||||
public sealed class EntryPoint : GameServer
|
public sealed class EntryPoint : GameServer
|
||||||
{
|
{
|
||||||
|
private const string ConfigPresetsDir = "/ConfigPresets/";
|
||||||
|
private const string ConfigPresetsDirBuild = $"{ConfigPresetsDir}Build/";
|
||||||
|
|
||||||
private EuiManager _euiManager = default!;
|
private EuiManager _euiManager = default!;
|
||||||
private IVoteManager _voteManager = default!;
|
private IVoteManager _voteManager = default!;
|
||||||
private ServerUpdateManager _updateManager = default!;
|
private ServerUpdateManager _updateManager = default!;
|
||||||
@@ -48,6 +51,12 @@ namespace Content.Server.Entry
|
|||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|
||||||
|
var cfg = IoCManager.Resolve<IConfigurationManager>();
|
||||||
|
var res = IoCManager.Resolve<IResourceManager>();
|
||||||
|
var logManager = IoCManager.Resolve<ILogManager>();
|
||||||
|
|
||||||
|
LoadConfigPresets(cfg, res, logManager.GetSawmill("configpreset"));
|
||||||
|
|
||||||
var aczProvider = new ContentMagicAczProvider(IoCManager.Resolve<IDependencyCollection>());
|
var aczProvider = new ContentMagicAczProvider(IoCManager.Resolve<IDependencyCollection>());
|
||||||
IoCManager.Resolve<IStatusHost>().SetMagicAczProvider(aczProvider);
|
IoCManager.Resolve<IStatusHost>().SetMagicAczProvider(aczProvider);
|
||||||
|
|
||||||
@@ -85,7 +94,6 @@ namespace Content.Server.Entry
|
|||||||
_playTimeTracking = IoCManager.Resolve<PlayTimeTrackingManager>();
|
_playTimeTracking = IoCManager.Resolve<PlayTimeTrackingManager>();
|
||||||
_sysMan = IoCManager.Resolve<IEntitySystemManager>();
|
_sysMan = IoCManager.Resolve<IEntitySystemManager>();
|
||||||
|
|
||||||
var logManager = IoCManager.Resolve<ILogManager>();
|
|
||||||
logManager.GetSawmill("Storage").Level = LogLevel.Info;
|
logManager.GetSawmill("Storage").Level = LogLevel.Info;
|
||||||
logManager.GetSawmill("db.ef").Level = LogLevel.Info;
|
logManager.GetSawmill("db.ef").Level = LogLevel.Info;
|
||||||
|
|
||||||
@@ -165,5 +173,47 @@ namespace Content.Server.Entry
|
|||||||
_playTimeTracking?.Shutdown();
|
_playTimeTracking?.Shutdown();
|
||||||
_sysMan?.GetEntitySystemOrNull<StationSystem>()?.OnServerDispose();
|
_sysMan?.GetEntitySystemOrNull<StationSystem>()?.OnServerDispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void LoadConfigPresets(IConfigurationManager cfg, IResourceManager res, ISawmill sawmill)
|
||||||
|
{
|
||||||
|
LoadBuildConfigPresets(cfg, res, sawmill);
|
||||||
|
|
||||||
|
var presets = cfg.GetCVar(CCVars.ConfigPresets);
|
||||||
|
if (presets == "")
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var preset in presets.Split(','))
|
||||||
|
{
|
||||||
|
var path = $"{ConfigPresetsDir}{preset}.toml";
|
||||||
|
if (!res.TryContentFileRead(path, out var file))
|
||||||
|
{
|
||||||
|
sawmill.Error("Unable to load config preset {Preset}!", path);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.LoadDefaultsFromTomlStream(file);
|
||||||
|
sawmill.Info("Loaded config preset: {Preset}", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void LoadBuildConfigPresets(IConfigurationManager cfg, IResourceManager res, ISawmill sawmill)
|
||||||
|
{
|
||||||
|
#if !FULL_RELEASE
|
||||||
|
Load(CCVars.ConfigPresetDevelopment, "development");
|
||||||
|
#endif
|
||||||
|
#if DEBUG
|
||||||
|
Load(CCVars.ConfigPresetDebug, "debug");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void Load(CVarDef<bool> cVar, string name)
|
||||||
|
{
|
||||||
|
var path = $"{ConfigPresetsDirBuild}{name}.toml";
|
||||||
|
if (cfg.GetCVar(cVar) && res.TryContentFileRead(path, out var file))
|
||||||
|
{
|
||||||
|
cfg.LoadDefaultsFromTomlStream(file);
|
||||||
|
sawmill.Info("Loaded config preset: {Preset}", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ namespace Content.Server.NPC.Systems
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
// Makes physics etc debugging easier.
|
|
||||||
#if DEBUG
|
|
||||||
_configurationManager.OverrideDefault(CCVars.NPCEnabled, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_sawmill = Logger.GetSawmill("npc");
|
_sawmill = Logger.GetSawmill("npc");
|
||||||
_sawmill.Level = LogLevel.Info;
|
_sawmill.Level = LogLevel.Info;
|
||||||
|
|||||||
@@ -55,9 +55,6 @@ public sealed partial class ShuttleSystem
|
|||||||
|
|
||||||
private void InitializeEscape()
|
private void InitializeEscape()
|
||||||
{
|
{
|
||||||
#if !FULL_RELEASE
|
|
||||||
_configManager.OverrideDefault(CCVars.EmergencyShuttleEnabled, false);
|
|
||||||
#endif
|
|
||||||
_emergencyShuttleEnabled = _configManager.GetCVar(CCVars.EmergencyShuttleEnabled);
|
_emergencyShuttleEnabled = _configManager.GetCVar(CCVars.EmergencyShuttleEnabled);
|
||||||
// Don't immediately invoke as roundstart will just handle it.
|
// Don't immediately invoke as roundstart will just handle it.
|
||||||
_configManager.OnValueChanged(CCVars.EmergencyShuttleEnabled, SetEmergencyShuttleEnabled);
|
_configManager.OnValueChanged(CCVars.EmergencyShuttleEnabled, SetEmergencyShuttleEnabled);
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ public sealed class EventManagerSystem : EntitySystem
|
|||||||
|
|
||||||
_sawmill = Logger.GetSawmill("events");
|
_sawmill = Logger.GetSawmill("events");
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
_configurationManager.OverrideDefault(CCVars.EventsEnabled, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_configurationManager.OnValueChanged(CCVars.EventsEnabled, SetEnabled, true);
|
_configurationManager.OnValueChanged(CCVars.EventsEnabled, SetEnabled, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ namespace Content.Shared.CCVar
|
|||||||
/// Controls if the lobby is enabled. If it is not, and there are no available jobs, you may get stuck on a black screen.
|
/// Controls if the lobby is enabled. If it is not, and there are no available jobs, you may get stuck on a black screen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly CVarDef<bool>
|
public static readonly CVarDef<bool>
|
||||||
GameLobbyEnabled = CVarDef.Create("game.lobbyenabled", false, CVar.ARCHIVE);
|
GameLobbyEnabled = CVarDef.Create("game.lobbyenabled", true, CVar.ARCHIVE);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Controls the duration of the lobby timer in seconds. Defaults to 2 minutes and 30 seconds.
|
/// Controls the duration of the lobby timer in seconds. Defaults to 2 minutes and 30 seconds.
|
||||||
@@ -1339,7 +1339,6 @@ namespace Content.Shared.CCVar
|
|||||||
* PLAYTIME
|
* PLAYTIME
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Time between play time autosaves, in seconds.
|
/// Time between play time autosaves, in seconds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1391,5 +1390,38 @@ namespace Content.Shared.CCVar
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly CVarDef<string> InfoLinksBugReport =
|
public static readonly CVarDef<string> InfoLinksBugReport =
|
||||||
CVarDef.Create("infolinks.bug_report", "", CVar.SERVER | CVar.REPLICATED);
|
CVarDef.Create("infolinks.bug_report", "", CVar.SERVER | CVar.REPLICATED);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CONFIG
|
||||||
|
*/
|
||||||
|
|
||||||
|
// These are server-only for now since I don't foresee a client use yet,
|
||||||
|
// and I don't wanna have to start coming up with like .client suffixes and stuff like that.
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration presets to load during startup.
|
||||||
|
/// Multiple presets can be separated by comma and are loaded in order.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Loaded presets must be located under the <c>ConfigPresets/</c> resource directory and end with the <c>.toml</c> extension.
|
||||||
|
/// Only the file name (without extension) must be given for this variable.
|
||||||
|
/// </remarks>
|
||||||
|
public static readonly CVarDef<string> ConfigPresets =
|
||||||
|
CVarDef.Create("config.presets", "", CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to load the preset development CVars.
|
||||||
|
/// This disables some things like lobby to make development easier.
|
||||||
|
/// Even when true, these are only loaded if the game is compiled with <c>DEVELOPMENT</c> set.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<bool> ConfigPresetDevelopment =
|
||||||
|
CVarDef.Create("config.preset_development", true, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to load the preset debug CVars.
|
||||||
|
/// Even when true, these are only loaded if the game is compiled with <c>DEBUG</c> set.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<bool> ConfigPresetDebug =
|
||||||
|
CVarDef.Create("config.preset_debug", true, CVar.SERVERONLY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
Resources/ConfigPresets/Build/debug.toml
Normal file
7
Resources/ConfigPresets/Build/debug.toml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[events]
|
||||||
|
# Annoying
|
||||||
|
enabled = false
|
||||||
|
|
||||||
|
[npc]
|
||||||
|
# Makes physics etc debugging easier.
|
||||||
|
enabled = false
|
||||||
13
Resources/ConfigPresets/Build/development.toml
Normal file
13
Resources/ConfigPresets/Build/development.toml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[game]
|
||||||
|
# Straight in-game baby
|
||||||
|
lobbyenabled = false
|
||||||
|
|
||||||
|
[physics]
|
||||||
|
# Makes mapping annoying
|
||||||
|
grid_splitting = false
|
||||||
|
|
||||||
|
[shuttle]
|
||||||
|
# Wastes startup time
|
||||||
|
cargo = false
|
||||||
|
emergency_enabled = false
|
||||||
|
|
||||||
Reference in New Issue
Block a user