Skip to content

Commit

Permalink
- Added QuikGraph for Depth-first search function.
Browse files Browse the repository at this point in the history
- Lots of resource structure refactoring.
- Combined some related interface definitions into single files.
  • Loading branch information
TBN-MapleWheels committed Sep 25, 2024
1 parent 7437680 commit ef91d6e
Show file tree
Hide file tree
Showing 22 changed files with 318 additions and 170 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.Xna.Framework;

namespace Barotrauma.LuaCs.Data;

/// <summary>
/// Client-only information for IConfigInfo contract, such as icons and display resources.
/// </summary>
public interface IConfigInfoClient
{
string Description { get; }
/// <summary>
/// Human-friendly name displayed in menus. Internal name will be used if empty.
/// </summary>
string DisplayName { get; }
/// <summary>
/// What category should this be displayed under in the menus. Overriden when 'ConfigDataType' is 'ControlInput'.
/// </summary>
string DisplayCategory { get; }
/// <summary>
/// Icon to be displayed next to the setting.
/// </summary>
string ImageIcon { get; }
/// <summary>
/// Absolute icon size in pixels.
/// </summary>
Vector2 IconSize { get; }
/// <summary>
/// On hover tooltip.
/// </summary>
string Tooltip { get; }
/// <summary>
/// Whether the value should be allowed to be shown when mods are not loaded. Used when developers want to hook events
/// before values are allowed to be changed.
/// </summary>
bool HideWhenPackageNotLoaded { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Barotrauma.LuaCs.Data;

public interface IStylesInfo
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Barotrauma.LuaCs.Services.Processing;

#region XmlToResourceParsers

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

#endregion
1 change: 1 addition & 0 deletions Barotrauma/BarotraumaShared/Luatrauma.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<PackageReference Include="Lib.Harmony" Version="2.2.2" />
<PackageReference Include="Sigil" Version="5.0.0" />
<PackageReference Include="LightInject" Version="6.6.4" />
<PackageReference Include="QuikGraph" Version="2.5.0" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Libraries\moonsharp\MoonSharp.Interpreter\MoonSharp.Interpreter.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Libraries\moonsharp\MoonSharp.VsCodeDebugger\MoonSharp.VsCodeDebugger.csproj" />
</ItemGroup>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;

namespace Barotrauma.LuaCs.Data;

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

Target SupportedTargets { get; }
}


/// <summary>
/// ResourceInfos contain metadata about a resource.
/// </summary>
public interface IResourceInfo : IPlatformInfo
{
/// <summary>
/// Resource absolute file paths.
/// </summary>
ImmutableArray<string> FilePaths { get; }
}

/// <summary>
/// Information about supported cultures. It is intended to be ignored if the array is ImmutableArray.Empty .
/// </summary>
public interface IResourceCultureInfo
{
/// <summary>
/// List of supported cultures by this resource.
/// </summary>
ImmutableArray<CultureInfo> SupportedCultures { get; init; }
}
19 changes: 11 additions & 8 deletions Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IConfigInfo.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using System;
using Barotrauma.Networking;

namespace Barotrauma.LuaCs.Data;

// TODO: Finish
public interface IConfigInfo
{
public string Name { get; }
public string PackageName { get; }
public string DisplayName { get; }
public string DisplayCategory { get; }
public string ImageIcon { get; }
public ConfigDataType Type { get; }
public string DefaultValue { get; }

string Name { get; }
string PackageName { get; }
ConfigDataType Type { get; }
string DefaultValue { get; }
ClientPermissions RequiredPermissions { get; }
}

public enum ConfigDataType
Expand All @@ -21,3 +19,8 @@ public enum ConfigDataType
Color, Vector2, Vector3, List,
RangeInt32, RangeSingle, ControlInput
}

public enum NetSync
{
None, TwoWay, ServerAuthority, ClientOneWay
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Barotrauma.LuaCs.Data;

public interface IConfigProfileInfo
{

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
namespace Barotrauma.LuaCs.Data;
using System.Collections.Immutable;

public interface IModConfigInfo
namespace Barotrauma.LuaCs.Data;

public interface IModConfigInfo : IPackageDependenciesInfo, IResourceCultureInfo
{
// package info
ContentPackage Package { get; }
string PackageName { get; }

// loadable content metadata
ImmutableArray<IAssemblyResourceInfo> LoadableAssemblies { get; }
ImmutableArray<ILocalizationResourceInfo> LocalizationFiles { get; }

// configuration
TargetRunMode RunModes { get; }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Barotrauma.LuaCs.Data;
using System.Collections.Immutable;

namespace Barotrauma.LuaCs.Data;

public interface IPackageDependencyInfo
{
Expand All @@ -15,7 +17,20 @@ public interface IPackageDependencyInfo
/// </summary>
public ulong SteamWorkshopId { get; }
/// <summary>
/// The dependency package, if found.
/// The dependency package, if found in the ALL Packages List.
/// </summary>
public ContentPackage DependencyPackage { get; }
/// <summary>
/// Marks this dependency optional (ie. Cross-CP content). Setting this to true will allow the dependency system to
/// try and order the loading but not fail if it runs into circular dependency issues.
/// </summary>
bool Optional { get; }
}

public interface IPackageDependenciesInfo
{
/// <summary>
/// List of required packages.
/// </summary>
ImmutableArray<IPackageDependencyInfo> Dependencies { get; }
}

This file was deleted.

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

namespace Barotrauma.LuaCs.Data;

public interface IConfigResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo { }
public interface IConfigProfileResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo { }
public interface ILocalizationResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo { }

public interface IAssemblyResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo
{
/// <summary>
/// The friendly name of the assembly. Script files belonging to the same assembly should all have the same name.
/// Legacy scripts will all be given the sanitized name of the Content Package they belong to.
/// </summary>
public string FriendlyName { get; }
/// <summary>
/// Is this entry referring to a script file collection.
/// </summary>
public bool IsScript { get; }
/// <summary>
/// Should this be compiled/loaded immediately or stored until demanded.
/// </summary>
public bool LazyLoad { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,102 +7,52 @@ namespace Barotrauma.LuaCs.Data;

#region ModConfigurationInfo

[Serializable]
public readonly struct ModConfigInfo : IRunConfig, IModConfigInfo
public readonly struct ModConfigInfo : IModConfigInfo
{
public bool RunConfigLegacy { get; init; }
public ContentPackage Package { get; init; }
public string ModName { get; init; }


public DependencyInfo[] Dependencies { get; init; }
public AssemblyResourceInfo[] LoadableAssemblies { get; init; }
public LocalizationResourceInfo[] LocalizationFiles { get; init; }

public string PackageName { get; init; }
public TargetRunMode RunModes { get; init; }
public ImmutableArray<CultureInfo> SupportedCultures { get; init; }

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

[Obsolete("Use RunModes flag.")]
public string Client
{
get
{
if (RunModes.HasFlag(TargetRunMode.ClientEnabled))
return "Standard";
if (RunModes.HasFlag(TargetRunMode.ClientAlways))
return "Forced";
return "None";
}
}
[Obsolete("Use RunModes flag.")]
public string Server
{
get
{
if (RunModes.HasFlag(TargetRunMode.ServerEnabled))
return "Standard";
if (RunModes.HasFlag(TargetRunMode.ServerAlways))
return "Forced";
return "None";
}
}

[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();
}
// metadata
public ImmutableArray<IPackageDependencyInfo> Dependencies { get; init; }
public ImmutableArray<IAssemblyResourceInfo> LoadableAssemblies { get; init; }
public ImmutableArray<ILocalizationResourceInfo> LocalizationFiles { get; init; }
}

#endregion

#region DataContracts

[Serializable]
public readonly struct AssemblyResourceInfo : IAssemblyResourceInfo
{
public string Name { get; init; }
public string FriendlyName { 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; }
public ImmutableArray<CultureInfo> SupportedCultures { get; init; }
public ImmutableArray<IPackageDependencyInfo> Dependencies { get; init; }
}

[Serializable]
public readonly struct DependencyInfo : IPackageDependencyInfo
{
public string FolderPath { get; init; }
public string PackageName { get; init; }
public ulong SteamWorkshopId { get; init; }
public ContentPackage DependencyPackage { get; init; }
public bool Optional { get; init; }
}

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

#endregion
Loading

0 comments on commit ef91d6e

Please sign in to comment.