[Save/Sync] Work on ModConfig loading.
This commit is contained in:
@@ -14,10 +14,9 @@ namespace Barotrauma.LuaCs.Data;
|
|||||||
|
|
||||||
#region ModConfigurationInfo
|
#region ModConfigurationInfo
|
||||||
|
|
||||||
public partial record ModConfigInfo : IModConfigInfo
|
public record ModConfigInfo : IModConfigInfo
|
||||||
{
|
{
|
||||||
public ContentPackage Package { get; init; }
|
public ContentPackage Package { get; init; }
|
||||||
public string PackageName { get; init; }
|
|
||||||
public ImmutableArray<IAssemblyResourceInfo> Assemblies { get; init; }
|
public ImmutableArray<IAssemblyResourceInfo> Assemblies { get; init; }
|
||||||
public ImmutableArray<ILuaScriptResourceInfo> LuaScripts { get; init; }
|
public ImmutableArray<ILuaScriptResourceInfo> LuaScripts { get; init; }
|
||||||
public ImmutableArray<IConfigResourceInfo> Configs { get; init; }
|
public ImmutableArray<IConfigResourceInfo> Configs { get; init; }
|
||||||
@@ -42,6 +41,8 @@ public record BaseResourceInfo : IBaseResourceInfo
|
|||||||
public bool Optional { get; init; }
|
public bool Optional { get; init; }
|
||||||
public string InternalName { get; init; }
|
public string InternalName { get; init; }
|
||||||
public ContentPackage OwnerPackage { get; init; }
|
public ContentPackage OwnerPackage { get; init; }
|
||||||
|
public ImmutableArray<Identifier> RequiredPackages { get; init; }
|
||||||
|
public ImmutableArray<Identifier> IncompatiblePackages { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public record AssemblyResourceInfo : BaseResourceInfo, IAssemblyResourceInfo
|
public record AssemblyResourceInfo : BaseResourceInfo, IAssemblyResourceInfo
|
||||||
|
|||||||
@@ -6,6 +6,18 @@ using System.Globalization;
|
|||||||
|
|
||||||
namespace Barotrauma.LuaCs.Data;
|
namespace Barotrauma.LuaCs.Data;
|
||||||
|
|
||||||
|
public interface IDependencyInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// List of dependency packages required by this resource.
|
||||||
|
/// </summary>
|
||||||
|
ImmutableArray<Identifier> RequiredPackages { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// List of packages incompatible with this resource.
|
||||||
|
/// </summary>
|
||||||
|
ImmutableArray<Identifier> IncompatiblePackages { get; }
|
||||||
|
}
|
||||||
|
|
||||||
public interface IPlatformInfo
|
public interface IPlatformInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Barotrauma.LuaCs.Data;
|
namespace Barotrauma.LuaCs.Data;
|
||||||
|
|
||||||
@@ -8,5 +9,10 @@ public partial interface IModConfigInfo : IAssembliesResourcesInfo,
|
|||||||
{
|
{
|
||||||
// package info
|
// package info
|
||||||
ContentPackage Package { get; }
|
ContentPackage Package { get; }
|
||||||
string PackageName { get; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record ResourceParserInfo(
|
||||||
|
ContentPackage Owner,
|
||||||
|
XElement Element,
|
||||||
|
ImmutableArray<Identifier> Required,
|
||||||
|
ImmutableArray<Identifier> Incompatible);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Globalization;
|
|||||||
namespace Barotrauma.LuaCs.Data;
|
namespace Barotrauma.LuaCs.Data;
|
||||||
|
|
||||||
|
|
||||||
public interface IBaseResourceInfo : IResourceInfo, IDataInfo {}
|
public interface IBaseResourceInfo : IResourceInfo, IDataInfo, IDependencyInfo {}
|
||||||
|
|
||||||
public interface IConfigResourceInfo : IBaseResourceInfo {}
|
public interface IConfigResourceInfo : IBaseResourceInfo {}
|
||||||
|
|
||||||
|
|||||||
+55
-11
@@ -17,16 +17,16 @@ namespace Barotrauma.LuaCs.Services.Processing;
|
|||||||
public sealed class ModConfigService : IModConfigService
|
public sealed class ModConfigService : IModConfigService
|
||||||
{
|
{
|
||||||
private IStorageService _storageService;
|
private IStorageService _storageService;
|
||||||
private IParserServiceAsync<XElement, IAssemblyResourceInfo> _assemblyParserService;
|
private IParserServiceAsync<ResourceParserInfo, IAssemblyResourceInfo> _assemblyParserService;
|
||||||
private IParserServiceAsync<XElement, ILuaScriptResourceInfo> _luaScriptParserService;
|
private IParserServiceAsync<ResourceParserInfo, ILuaScriptResourceInfo> _luaScriptParserService;
|
||||||
private IParserServiceAsync<XElement, IConfigResourceInfo> _configParserService;
|
private IParserServiceAsync<ResourceParserInfo, IConfigResourceInfo> _configParserService;
|
||||||
private IParserServiceAsync<XElement, IConfigProfileResourceInfo> _configProfileParserService;
|
private IParserServiceAsync<ResourceParserInfo, IConfigProfileResourceInfo> _configProfileParserService;
|
||||||
|
|
||||||
public ModConfigService(IStorageService storageService,
|
public ModConfigService(IStorageService storageService,
|
||||||
IParserServiceAsync<XElement, IAssemblyResourceInfo> assemblyParserService,
|
IParserServiceAsync<ResourceParserInfo, IAssemblyResourceInfo> assemblyParserService,
|
||||||
IParserServiceAsync<XElement, ILuaScriptResourceInfo> luaScriptParserService,
|
IParserServiceAsync<ResourceParserInfo, ILuaScriptResourceInfo> luaScriptParserService,
|
||||||
IParserServiceAsync<XElement, IConfigResourceInfo> configParserService,
|
IParserServiceAsync<ResourceParserInfo, IConfigResourceInfo> configParserService,
|
||||||
IParserServiceAsync<XElement, IConfigProfileResourceInfo> configProfileParserService)
|
IParserServiceAsync<ResourceParserInfo, IConfigProfileResourceInfo> configProfileParserService)
|
||||||
{
|
{
|
||||||
_storageService = storageService;
|
_storageService = storageService;
|
||||||
_assemblyParserService = assemblyParserService;
|
_assemblyParserService = assemblyParserService;
|
||||||
@@ -57,7 +57,7 @@ public sealed class ModConfigService : IModConfigService
|
|||||||
|
|
||||||
if (await TryGetModConfigXmlAsync(src) is { IsSuccess: true, Value: { } config })
|
if (await TryGetModConfigXmlAsync(src) is { IsSuccess: true, Value: { } config })
|
||||||
{
|
{
|
||||||
return await CreateFromConfigXmlAsync(config);
|
return await CreateFromConfigXmlAsync(src, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await CreateFromLegacyAsync(src);
|
return await CreateFromLegacyAsync(src);
|
||||||
@@ -84,11 +84,55 @@ public sealed class ModConfigService : IModConfigService
|
|||||||
: FluentResults.Result.Fail<XElement>("ModConfig.xml not found");
|
: 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)
|
private async Task<Result<IModConfigInfo>> CreateFromLegacyAsync(ContentPackage src)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
Reference in New Issue
Block a user