[Save/Sync] Work on ModConfig loading.

This commit is contained in:
Maplewheels
2026-01-05 08:05:40 -05:00
parent 75da3a398d
commit d6968f4ea9
5 changed files with 78 additions and 15 deletions
@@ -17,16 +17,16 @@ namespace Barotrauma.LuaCs.Services.Processing;
public sealed class ModConfigService : IModConfigService
{
private IStorageService _storageService;
private IParserServiceAsync<XElement, IAssemblyResourceInfo> _assemblyParserService;
private IParserServiceAsync<XElement, ILuaScriptResourceInfo> _luaScriptParserService;
private IParserServiceAsync<XElement, IConfigResourceInfo> _configParserService;
private IParserServiceAsync<XElement, IConfigProfileResourceInfo> _configProfileParserService;
private IParserServiceAsync<ResourceParserInfo, IAssemblyResourceInfo> _assemblyParserService;
private IParserServiceAsync<ResourceParserInfo, ILuaScriptResourceInfo> _luaScriptParserService;
private IParserServiceAsync<ResourceParserInfo, IConfigResourceInfo> _configParserService;
private IParserServiceAsync<ResourceParserInfo, IConfigProfileResourceInfo> _configProfileParserService;
public ModConfigService(IStorageService storageService,
IParserServiceAsync<XElement, IAssemblyResourceInfo> assemblyParserService,
IParserServiceAsync<XElement, ILuaScriptResourceInfo> luaScriptParserService,
IParserServiceAsync<XElement, IConfigResourceInfo> configParserService,
IParserServiceAsync<XElement, IConfigProfileResourceInfo> configProfileParserService)
IParserServiceAsync<ResourceParserInfo, IAssemblyResourceInfo> assemblyParserService,
IParserServiceAsync<ResourceParserInfo, ILuaScriptResourceInfo> luaScriptParserService,
IParserServiceAsync<ResourceParserInfo, IConfigResourceInfo> configParserService,
IParserServiceAsync<ResourceParserInfo, IConfigProfileResourceInfo> configProfileParserService)
{
_storageService = storageService;
_assemblyParserService = assemblyParserService;
@@ -57,7 +57,7 @@ public sealed class ModConfigService : IModConfigService
if (await TryGetModConfigXmlAsync(src) is { IsSuccess: true, Value: { } config })
{
return await CreateFromConfigXmlAsync(config);
return await CreateFromConfigXmlAsync(src, config);
}
return await CreateFromLegacyAsync(src);
@@ -84,11 +84,55 @@ public sealed class ModConfigService : IModConfigService
: FluentResults.Result.Fail<XElement>("ModConfig.xml not found");
}
private async Task<Result<IModConfigInfo>> CreateFromConfigXmlAsync(XElement src)
private async Task<Result<IModConfigInfo>> CreateFromConfigXmlAsync(ContentPackage owner, XElement src)
{
throw new NotImplementedException();
/*var cfg = src.GetChildElements("Config");
var modConfig = new ModConfigInfo()
{
Package = owner,
Assemblies = src.GetChildElements("Assembly") is {} asm ? GetAssembliesFromXml(owner, asm)
: ImmutableArray<IAssemblyResourceInfo>.Empty,
Configs = cfg is {} ? GetConfigsFromXml(owner, cfg) : ImmutableArray<IConfigResourceInfo>.Empty,
ConfigProfiles = cfg is {} ? GetConfigProfilesFromXml(owner, cfg) : ImmutableArray<IConfigProfileResourceInfo>.Empty,
LuaScripts = src.GetChildElements("Lua") is {} lua ? GetLuaScriptsFromXml(owner, lua)
: ImmutableArray<ILuaScriptResourceInfo>.Empty
};*/
async Task<FluentResults.Result<ImmutableArray<ILuaScriptResourceInfo>>> GetLuaScriptsFromXml(ContentPackage contentPackage,
XElement cfgElement)
{
var luaElems = cfgElement.GetChildElements("Lua").ToImmutableArray();
if (cfgElement.GetChildElements("FileGroup").ToImmutableArray() is { IsDefaultOrEmpty: false } fileGroup
&& fileGroup.SelectMany(fg => fg.GetChildElements()))
{
}
throw new NotImplementedException();
}
async Task<FluentResults.Result<ImmutableArray<IConfigProfileResourceInfo>>> GetConfigProfilesFromXml(ContentPackage contentPackage,
XElement cfgElement)
{
throw new NotImplementedException();
}
async Task<FluentResults.Result<ImmutableArray<IConfigResourceInfo>>> GetConfigsFromXml(ContentPackage contentPackage,
XElement cfgElement)
{
throw new NotImplementedException();
}
async Task<FluentResults.Result<ImmutableArray<IAssemblyResourceInfo>>> GetAssembliesFromXml(ContentPackage contentPackage,
XElement cfgElement)
{
throw new NotImplementedException();
}
}
private async Task<Result<IModConfigInfo>> CreateFromLegacyAsync(ContentPackage src)
{
throw new NotImplementedException();