diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/EPlatformsTargets.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/EPlatformsTargets.cs new file mode 100644 index 0000000000..03eab0da66 --- /dev/null +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/EPlatformsTargets.cs @@ -0,0 +1,18 @@ +using System; + +namespace Barotrauma.LuaCs.Data; + +[Flags] +public enum Platform +{ + Linux=0x1, + OSX=0x2, + Windows=0x4 +} + +[Flags] +public enum Target +{ + Client=0x1, + Server=0x2 +} diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IAssemblyResourceInfo.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IAssemblyResourceInfo.cs index 8b2dc3859d..53ca993c0a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IAssemblyResourceInfo.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IAssemblyResourceInfo.cs @@ -30,18 +30,3 @@ public interface IAssemblyResourceInfo /// public Target Targets { get; } } - -[Flags] -public enum Platform -{ - Linux=0x1, - OSX=0x2, - Windows=0x4 -} - -[Flags] -public enum Target -{ - Client=0x1, - Server=0x2 -} diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IConfigDefinitionInfo.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IConfigDefinitionInfo.cs index 8beaa02b97..801086e27a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IConfigDefinitionInfo.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IConfigDefinitionInfo.cs @@ -12,9 +12,12 @@ public interface IConfigDefinitionInfo public string ImageIcon { get; } public ConfigDataType Type { get; } public string DefaultValue { get; } + } public enum ConfigDataType { - + Boolean, Int32, Int64, Single, Double, String, + Color, Vector2, Vector3, List, + RangeInt32, RangeSingle, ControlInput } diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ILocalizationResourceInfo.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ILocalizationResourceInfo.cs new file mode 100644 index 0000000000..ce3c37cf5d --- /dev/null +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ILocalizationResourceInfo.cs @@ -0,0 +1,10 @@ +using System.Collections.Immutable; +using System.Globalization; + +namespace Barotrauma.LuaCs.Data; + +public interface ILocalizationResourceInfo +{ + CultureInfo TargetCulture { get; } + ImmutableArray FilePaths { get; } +} diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ModConfigData.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ModConfigData.cs index e136b07162..ba176a3756 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ModConfigData.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ModConfigData.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; +using System.Globalization; namespace Barotrauma.LuaCs.Data; @@ -10,8 +11,14 @@ public readonly struct ModConfigData public DependencyInfo[] Dependencies { get; init; } public AssemblyResourceInfo[] LoadableAssemblies { get; init; } + public LocalizationResourceInfo[] LocalizationFiles { get; init; } - + public readonly struct LocalizationResourceInfo : ILocalizationResourceInfo + { + public CultureInfo TargetCulture { get; init; } + public ImmutableArray FilePaths { get; init; } + } + public readonly struct ConfigInitData { // TODO: complete struct, data here should be already parsed and ready-to-use by the config service. diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/ILocalizationService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/ILocalizationService.cs index ba650e5c1a..4bc44757c4 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/ILocalizationService.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/ILocalizationService.cs @@ -1,12 +1,18 @@ using System; +using System.Globalization; using System.Collections.Generic; namespace Barotrauma.LuaCs.Services; public interface ILocalizationService : IService { - bool TryLoadFiles(in string[] filePaths); + IReadOnlyCollection GetLoadedLocales(); + bool TryLoadXmlFiles(in string[] filePaths, CultureInfo defaultCulture); void UnloadAll(); + bool TrySetCurrentCulture(CultureInfo culture); + bool TrySetCurrentCulture(string cultureName); string GetLocalizedString(string key, string fallback); - string GetLocalizedString(string key, Func fbValueFactory); + string GetLocalizedString(string key, CultureInfo targetCulture); + bool TryRegisterLocalizationResolver(CultureInfo targetCulture, Func factoryResolver); + bool ReplaceSymbols(string text, string symbolExpr); }