- ConfigService.cs alpha testing.

This commit is contained in:
MapleWheels
2026-01-22 14:58:03 -05:00
committed by Maplewheels
parent cc07db941f
commit 7e0e671539
27 changed files with 795 additions and 546 deletions
@@ -2,9 +2,9 @@
namespace Barotrauma.LuaCs.Configuration;
public interface IConfigControl : IConfigBase
public interface ISettingControl : ISettingBase
{
event Action<IConfigControl> OnDown;
event Action<ISettingControl> OnDown;
KeyOrMouse Value { get; }
bool IsAssignable(KeyOrMouse value);
bool TrySetValue(KeyOrMouse value);
@@ -7,11 +7,11 @@ public partial interface IConfigInfo : IConfigDisplayInfo { }
public interface IConfigDisplayInfo
{
/// <summary>
/// User-friendly name or Localization Token.
/// Localization Token for display name.
/// </summary>
string DisplayName { get; }
/// <summary>
/// User-friendly description or Localization Token.
/// Localization Token for description.
/// </summary>
string Description { get; }
/// <summary>
@@ -29,5 +29,5 @@ public interface IConfigDisplayInfo
/// <summary>
/// Icon for display in menus, if available.
/// </summary>
string ImageIconPath { get; }
ContentPath ImageIconPath { get; }
}
@@ -21,8 +21,20 @@ namespace Barotrauma
}
}
public void CheckCsEnabled()
/// <summary>
///
/// </summary>
/// <returns>Returns whether the IsCsEnabled has been changed to true/enabled. Returns false if already enabled.</returns>
public bool CheckCsEnabled()
{
// fast exit if enabled or unavailable.
if (this.IsCsEnabled?.Value ?? true )
{
return false;
}
bool isCsValueChanged = false;
var csharpMods = PackageManagementService.GetLoadedAssemblyPackages();
StringBuilder sb = new StringBuilder();
@@ -38,7 +50,7 @@ namespace Barotrauma
if (GameMain.Client == null || GameMain.Client.IsServerOwner)
{
new GUIMessageBox("", $"You have CSharp mods enabled but don't have the CSharp Scripting enabled, those mods might not work, go to the Main Menu, click on LuaCs Settings and check Enable CSharp Scripting.\n\n{sb}");
return;
return false;
}
GUIMessageBox msg = new GUIMessageBox(
@@ -49,6 +61,7 @@ namespace Barotrauma
msg.Buttons[0].OnClicked = (GUIButton button, object obj) =>
{
this.IsCsEnabled.TrySetValue(true);
isCsValueChanged = true;
return true;
};
@@ -57,6 +70,8 @@ namespace Barotrauma
this.IsCsEnabled.TrySetValue(false);
return true;
};
return isCsValueChanged;
}
/// <summary>
@@ -85,7 +100,10 @@ namespace Barotrauma
case SpriteEditorScreen:
case SubEditorScreen:
case TestScreen: // notes: TestScreen is a Linux edge case editor screen and is deprecated.
CheckCsEnabled();
if (CheckCsEnabled() && this.CurrentRunState >= RunState.Running)
{
SetRunState(RunState.LoadedNoExec);
}
SetRunState(RunState.Running);
break;
default:
@@ -19,7 +19,7 @@ public partial class ConfigService
throw new NotImplementedException();
}
public Result<IConfigControl> AddConfigControl(IConfigInfo configInfo)
public Result<ISettingControl> AddConfigControl(IConfigInfo configInfo)
{
throw new NotImplementedException();
}
@@ -13,5 +13,5 @@ public partial interface IConfigService
ImmutableArray<IDisplayableConfigBase> GetDisplayableConfigs();
ImmutableArray<IDisplayableConfigBase> GetDisplayableConfigsForPackage(ContentPackage package);
FluentResults.Result<IConfigControl> AddConfigControl(IConfigInfo configInfo);
FluentResults.Result<ISettingControl> AddConfigControl(IConfigInfo configInfo);
}