- Moved all console commands to their respective services and added via injector service.

- Fixed LuaCs IsCsEnabled prompt not working.
- Add settings profiles support.
This commit is contained in:
MapleWheels
2026-02-24 15:26:49 -05:00
parent 394856fa04
commit d9d980122d
9 changed files with 298 additions and 121 deletions
@@ -2311,93 +2311,7 @@ namespace Barotrauma
NewMessage($"Start item set changed to \"{AutoItemPlacer.DefaultStartItemSet}\"");
}, isCheat: false));
commands.Add(new Command("cfg_getvalue", "cfg_getvalue [Content Package] [InternalName] [ValueString]: gets a config value.", (string[] args) =>
{
if (args.Length < 1)
{
ThrowError("Please specify the name of the package to set the config.");
return;
}
if (args.Length < 2)
{
ThrowError("Please specify the name of the config.");
return;
}
var package = ContentPackageManager.RegularPackages.FirstOrDefault(p => p.Name == args[0]);
if (package == null)
{
ThrowError($"Could not find the package {args[0]}!");
return;
}
string internalName = args[1];
if (!GameMain.LuaCs.ConfigService.TryGetConfig(package, internalName, out LuaCs.Data.ISettingBase setting))
{
ThrowError($"Could not get config with name {internalName}");
return;
}
NewMessage($"config {internalName} value is {setting.GetStringValue()}", Color.Green);
}, getValidArgs: () => new[]
{
ContentPackageManager.RegularPackages.Select(p => p.Name).ToArray()
}));
commands.Add(new Command("cfg_setvalue", "cfg_setvalue [Content Package] [InternalName] [ValueString]: sets a config.", (string[] args) =>
{
if (args.Length < 1)
{
ThrowError("Please specify the name of the package to set the config.");
return;
}
if (args.Length < 2)
{
ThrowError("Please specify the name of the config.");
return;
}
if (args.Length < 3)
{
ThrowError("Please specify the value to set the config to.");
return;
}
var package = ContentPackageManager.RegularPackages.FirstOrDefault(p => p.Name == args[0]);
if (package == null)
{
ThrowError($"Could not find the package {args[0]}!");
return;
}
string internalName = args[1];
string valueString = args[2];
if (!GameMain.LuaCs.ConfigService.TryGetConfig(package, internalName, out LuaCs.Data.ISettingBase setting))
{
ThrowError($"Could not get config with name {internalName}");
return;
}
if (setting.TrySetValue(valueString))
{
NewMessage($"Set config {internalName} value to {valueString}", Color.Green);
if (GameMain.LuaCs.ConfigService.SaveConfigValue(setting) is { IsFailed: true } res)
{
NewMessage($"Failed to save new config data to disk. Reasons: {res.ToString()}");
}
}
else
{
ThrowError($"Failed to set config value");
}
}, getValidArgs: () => new[]
{
ContentPackageManager.RegularPackages.Select(p => p.Name).ToArray()
}));
//"dummy commands" that only exist so that the server can give clients permissions to use them
//TODO: alphabetical order?