Skip to content

Commit

Permalink
- Xml Resource interfaces work.
Browse files Browse the repository at this point in the history
  • Loading branch information
MapleWheels committed Sep 23, 2024
1 parent 99a2595 commit 7437680
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Barotrauma.LuaCs.Data;

public interface IStylesResourceInfo : IResourceInfo, IResourceCultureInfo { }
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
namespace Barotrauma.LuaCs.Services;

// TODO: Rework interface to support resource infos.
/// <summary>
/// Loads XML Style assets from the given content package.
/// </summary>
public interface IXmlAssetService : IService
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Linq;
using Barotrauma.LuaCs.Data;

namespace Barotrauma.LuaCs.Services.Processing;

#region XmlToResourceParsers

public interface IXmlStylesToResParser : IResourceParser<XElement, IStylesResourceInfo> { }

#endregion
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ public interface IAssemblyResourceInfo : IResourceInfo
/// </summary>
public string Name { get; }
/// <summary>
/// Is this entry referring to a script file.
/// Is this entry referring to a script file collection.
/// </summary>
public bool IsScriptFile { get; }
public bool IsScript { get; }
/// <summary>
/// Should this be compiled or loaded immediately or stored for On-Demand compilation.
/// </summary>
public bool LazyLoad { get; }
/// <summary>
/// Path to the file.
/// </summary>
public string Path { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,4 @@

namespace Barotrauma.LuaCs.Data;

public interface IConfigResourceInfo : IResourceInfo
{
string FilePath { get; init; }
Platform Platforms { get; init; }
Target Targets { get; init; }
ImmutableArray<CultureInfo> SupportedCultures { get; init; }
}
public interface IConfigResourceInfo : IResourceInfo, IResourceCultureInfo { }
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,4 @@

namespace Barotrauma.LuaCs.Data;

public interface ILocalizationResourceInfo : IResourceInfo
{
/// <summary>
/// The target culture (languages) that this localization data is intended for.
/// </summary>
CultureInfo TargetCulture { get; }
/// <summary>
/// List of localization files with their absolute path.
/// </summary>
ImmutableArray<string> FilePaths { get; }
}
public interface ILocalizationResourceInfo : IResourceInfo, IResourceCultureInfo { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Barotrauma.LuaCs.Data;

public interface IModConfigInfo
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Immutable;
using System.Globalization;

namespace Barotrauma.LuaCs.Data;

public interface IResourceCultureInfo
{
ImmutableArray<CultureInfo> SupportedCultures { get; init; }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
namespace Barotrauma.LuaCs.Data;
using System.Collections.Generic;
using System.Collections.Immutable;

namespace Barotrauma.LuaCs.Data;

/// <summary>
/// ResourceInfos contain metadata about a resource.
/// </summary>
public interface IResourceInfo
{
/// <summary>
Expand All @@ -10,5 +16,10 @@ public interface IResourceInfo
/// <summary>
/// Targets that these localization files should be loaded for.
/// </summary>
Target SupportedTargets { get; init; }
Target SupportedTargets { get; }

/// <summary>
/// Resource absolute file paths.
/// </summary>
ImmutableArray<string> FilePaths { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Barotrauma.LuaCs.Data;
#region ModConfigurationInfo

[Serializable]
public readonly struct ModConfigData : IRunConfig
public readonly struct ModConfigInfo : IRunConfig, IModConfigInfo
{
public bool RunConfigLegacy { get; init; }
public ContentPackage Package { get; init; }
Expand All @@ -21,11 +21,12 @@ namespace Barotrauma.LuaCs.Data;

public TargetRunMode RunModes { get; init; }

public bool UseNonPublicizedAssemblies { get; }

public bool UseNonPublicizedAssemblies { get; init; }
[Obsolete]
public bool AutoGenerated => false;
public bool UseInternalAssemblyName { get; init; }

[Obsolete("Use RunModes flag.")]
public string Client
{
get
Expand All @@ -37,7 +38,7 @@ public string Client
return "None";
}
}

[Obsolete("Use RunModes flag.")]
public string Server
{
get
Expand All @@ -50,16 +51,19 @@ public string Server
}
}

[Obsolete("Use RunModes flag.")]
public bool IsForced()
{
throw new NotImplementedException();
}


[Obsolete("Use RunModes flag.")]
public bool IsStandard()
{
throw new NotImplementedException();
}


[Obsolete("Use RunModes flag.")]
public bool IsForcedOrStandard()
{
throw new NotImplementedException();
Expand All @@ -70,16 +74,19 @@ public bool IsForcedOrStandard()

#region DataContracts

[Serializable]
public readonly struct AssemblyResourceInfo : IAssemblyResourceInfo
{
public string Name { get; init; }
public bool IsScriptFile { get; init; }
public bool IsScript { get; init; }
public bool LazyLoad { get; init; }
public string Path { get; init; }
public Platform SupportedPlatforms { get; init; }
public Target SupportedTargets { get; init; }
public ImmutableArray<string> FilePaths { get; init; }
}

[Serializable]
public readonly struct DependencyInfo : IPackageDependencyInfo
{
public string FolderPath { get; init; }
Expand All @@ -88,12 +95,14 @@ public bool IsForcedOrStandard()
public ContentPackage DependencyPackage { get; init; }
}

[Serializable]
public readonly struct LocalizationResourceInfo : ILocalizationResourceInfo
{
public CultureInfo TargetCulture { get; init; }
public ImmutableArray<string> FilePaths { get; init; }
public Platform SupportedPlatforms { get; init; }
public Target SupportedTargets { get; init; }
public ImmutableArray<string> FilePaths { get; init; }
public ImmutableArray<CultureInfo> SupportedCultures { get; init; }
}

#endregion
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Barotrauma.LuaCs.Services;

public interface IContentPackageProcessorService : IService
public interface IContentPackageService : IService
{
bool TryLoadPackageData(ContentPackage package);
ModConfigData GetModConfigData();
ModConfigInfo GetModConfigData();
ContentPackage TryFindPackage(string packageName, bool prioritizeLocal = true);
ContentPackage TryFindPackage(int steamId);
ContentPath GetContentPath();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Xml.Linq;
using Barotrauma.LuaCs.Data;

namespace Barotrauma.LuaCs.Services.Processing;

/// <summary>
/// Parses Xml to produce loading metadata info for linked loadable files.
/// </summary>
#region XmlToResourceInfoParsers

public interface IXmlAssemblyResParser : IResourceParser<XElement, IAssemblyResourceInfo> { }
public interface IXmlConfigResParser : IResourceParser<XElement, IConfigResourceInfo> { }
public interface IXmlLocalizationResParser : IResourceParser<XElement, ILocalizationResourceInfo> { }

#endregion

/// <summary>
/// Parses Xml to produce ready-to-use info/data without any additional file/data loading.
/// </summary>
#region XmlToInfoParsers
public interface IXmlDependencyParser : IResourceParser<XElement, IPackageDependencyInfo> { }
public interface IXmlModConfigParser : IResourceParser<XElement, IModConfigInfo> { }

#endregion




Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace Barotrauma.LuaCs.Services.Processing;

public interface IResourceParser<TSrc,TOut>
{
bool TryParseResource(in TSrc src, out TOut resources);
bool TryParseResources(in IEnumerable<TSrc> sources, out List<TOut> resources);
}

0 comments on commit 7437680

Please sign in to comment.