Skip to content

Commit ef91d6e

Browse files
- Added QuikGraph for Depth-first search function.
- Lots of resource structure refactoring. - Combined some related interface definitions into single files.
1 parent 7437680 commit ef91d6e

22 files changed

+318
-170
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Microsoft.Xna.Framework;
2+
3+
namespace Barotrauma.LuaCs.Data;
4+
5+
/// <summary>
6+
/// Client-only information for IConfigInfo contract, such as icons and display resources.
7+
/// </summary>
8+
public interface IConfigInfoClient
9+
{
10+
string Description { get; }
11+
/// <summary>
12+
/// Human-friendly name displayed in menus. Internal name will be used if empty.
13+
/// </summary>
14+
string DisplayName { get; }
15+
/// <summary>
16+
/// What category should this be displayed under in the menus. Overriden when 'ConfigDataType' is 'ControlInput'.
17+
/// </summary>
18+
string DisplayCategory { get; }
19+
/// <summary>
20+
/// Icon to be displayed next to the setting.
21+
/// </summary>
22+
string ImageIcon { get; }
23+
/// <summary>
24+
/// Absolute icon size in pixels.
25+
/// </summary>
26+
Vector2 IconSize { get; }
27+
/// <summary>
28+
/// On hover tooltip.
29+
/// </summary>
30+
string Tooltip { get; }
31+
/// <summary>
32+
/// Whether the value should be allowed to be shown when mods are not loaded. Used when developers want to hook events
33+
/// before values are allowed to be changed.
34+
/// </summary>
35+
bool HideWhenPackageNotLoaded { get; }
36+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Barotrauma.LuaCs.Data;
2+
3+
public interface IStylesInfo
4+
{
5+
6+
}

Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/Processing/IClientParserDefinitions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
namespace Barotrauma.LuaCs.Services.Processing;
55

66
#region XmlToResourceParsers
7-
8-
public interface IXmlStylesToResParser : IResourceParser<XElement, IStylesResourceInfo> { }
7+
public interface IXmlStylesToResConverterService : IXmlResourceConverterService<IStylesResourceInfo> { }
98

109
#endregion

Barotrauma/BarotraumaShared/Luatrauma.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<PackageReference Include="Lib.Harmony" Version="2.2.2" />
66
<PackageReference Include="Sigil" Version="5.0.0" />
77
<PackageReference Include="LightInject" Version="6.6.4" />
8+
<PackageReference Include="QuikGraph" Version="2.5.0" />
89
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Libraries\moonsharp\MoonSharp.Interpreter\MoonSharp.Interpreter.csproj" />
910
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Libraries\moonsharp\MoonSharp.VsCodeDebugger\MoonSharp.VsCodeDebugger.csproj" />
1011
</ItemGroup>

Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IAssemblyResourceInfo.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using System.Collections.Generic;
22
using System.Collections.Immutable;
3+
using System.Globalization;
34

45
namespace Barotrauma.LuaCs.Data;
56

6-
/// <summary>
7-
/// ResourceInfos contain metadata about a resource.
8-
/// </summary>
9-
public interface IResourceInfo
7+
public interface IPlatformInfo
108
{
119
/// <summary>
1210
/// Platforms that these localization files should be loaded for.
@@ -16,10 +14,28 @@ public interface IResourceInfo
1614
/// <summary>
1715
/// Targets that these localization files should be loaded for.
1816
/// </summary>
19-
Target SupportedTargets { get; }
20-
17+
Target SupportedTargets { get; }
18+
}
19+
20+
21+
/// <summary>
22+
/// ResourceInfos contain metadata about a resource.
23+
/// </summary>
24+
public interface IResourceInfo : IPlatformInfo
25+
{
2126
/// <summary>
2227
/// Resource absolute file paths.
2328
/// </summary>
2429
ImmutableArray<string> FilePaths { get; }
2530
}
31+
32+
/// <summary>
33+
/// Information about supported cultures. It is intended to be ignored if the array is ImmutableArray.Empty .
34+
/// </summary>
35+
public interface IResourceCultureInfo
36+
{
37+
/// <summary>
38+
/// List of supported cultures by this resource.
39+
/// </summary>
40+
ImmutableArray<CultureInfo> SupportedCultures { get; init; }
41+
}
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
using System;
2+
using Barotrauma.Networking;
23

34
namespace Barotrauma.LuaCs.Data;
45

56
// TODO: Finish
67
public interface IConfigInfo
78
{
8-
public string Name { get; }
9-
public string PackageName { get; }
10-
public string DisplayName { get; }
11-
public string DisplayCategory { get; }
12-
public string ImageIcon { get; }
13-
public ConfigDataType Type { get; }
14-
public string DefaultValue { get; }
15-
9+
string Name { get; }
10+
string PackageName { get; }
11+
ConfigDataType Type { get; }
12+
string DefaultValue { get; }
13+
ClientPermissions RequiredPermissions { get; }
1614
}
1715

1816
public enum ConfigDataType
@@ -21,3 +19,8 @@ public enum ConfigDataType
2119
Color, Vector2, Vector3, List,
2220
RangeInt32, RangeSingle, ControlInput
2321
}
22+
23+
public enum NetSync
24+
{
25+
None, TwoWay, ServerAuthority, ClientOneWay
26+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Barotrauma.LuaCs.Data;
2+
3+
public interface IConfigProfileInfo
4+
{
5+
6+
}

Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IConfigResourceInfo.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ILocalizationResourceInfo.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
namespace Barotrauma.LuaCs.Data;
1+
using System.Collections.Immutable;
22

3-
public interface IModConfigInfo
3+
namespace Barotrauma.LuaCs.Data;
4+
5+
public interface IModConfigInfo : IPackageDependenciesInfo, IResourceCultureInfo
46
{
7+
// package info
8+
ContentPackage Package { get; }
9+
string PackageName { get; }
10+
11+
// loadable content metadata
12+
ImmutableArray<IAssemblyResourceInfo> LoadableAssemblies { get; }
13+
ImmutableArray<ILocalizationResourceInfo> LocalizationFiles { get; }
514

15+
// configuration
16+
TargetRunMode RunModes { get; }
617
}

Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IPackageDependencyInfo.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Barotrauma.LuaCs.Data;
1+
using System.Collections.Immutable;
2+
3+
namespace Barotrauma.LuaCs.Data;
24

35
public interface IPackageDependencyInfo
46
{
@@ -15,7 +17,20 @@ public interface IPackageDependencyInfo
1517
/// </summary>
1618
public ulong SteamWorkshopId { get; }
1719
/// <summary>
18-
/// The dependency package, if found.
20+
/// The dependency package, if found in the ALL Packages List.
1921
/// </summary>
2022
public ContentPackage DependencyPackage { get; }
23+
/// <summary>
24+
/// Marks this dependency optional (ie. Cross-CP content). Setting this to true will allow the dependency system to
25+
/// try and order the loading but not fail if it runs into circular dependency issues.
26+
/// </summary>
27+
bool Optional { get; }
28+
}
29+
30+
public interface IPackageDependenciesInfo
31+
{
32+
/// <summary>
33+
/// List of required packages.
34+
/// </summary>
35+
ImmutableArray<IPackageDependencyInfo> Dependencies { get; }
2136
}

Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IResourceCultureInfo.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Collections.Immutable;
2+
using System.Globalization;
3+
4+
namespace Barotrauma.LuaCs.Data;
5+
6+
public interface IConfigResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo { }
7+
public interface IConfigProfileResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo { }
8+
public interface ILocalizationResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo { }
9+
10+
public interface IAssemblyResourceInfo : IResourceInfo, IResourceCultureInfo, IPackageDependenciesInfo
11+
{
12+
/// <summary>
13+
/// The friendly name of the assembly. Script files belonging to the same assembly should all have the same name.
14+
/// Legacy scripts will all be given the sanitized name of the Content Package they belong to.
15+
/// </summary>
16+
public string FriendlyName { get; }
17+
/// <summary>
18+
/// Is this entry referring to a script file collection.
19+
/// </summary>
20+
public bool IsScript { get; }
21+
/// <summary>
22+
/// Should this be compiled/loaded immediately or stored until demanded.
23+
/// </summary>
24+
public bool LazyLoad { get; }
25+
}

Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/ModConfigInfo.cs

Lines changed: 12 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,102 +7,52 @@ namespace Barotrauma.LuaCs.Data;
77

88
#region ModConfigurationInfo
99

10-
[Serializable]
11-
public readonly struct ModConfigInfo : IRunConfig, IModConfigInfo
10+
public readonly struct ModConfigInfo : IModConfigInfo
1211
{
13-
public bool RunConfigLegacy { get; init; }
1412
public ContentPackage Package { get; init; }
15-
public string ModName { get; init; }
16-
17-
18-
public DependencyInfo[] Dependencies { get; init; }
19-
public AssemblyResourceInfo[] LoadableAssemblies { get; init; }
20-
public LocalizationResourceInfo[] LocalizationFiles { get; init; }
21-
13+
public string PackageName { get; init; }
2214
public TargetRunMode RunModes { get; init; }
15+
public ImmutableArray<CultureInfo> SupportedCultures { get; init; }
2316

24-
public bool UseNonPublicizedAssemblies { get; init; }
25-
[Obsolete]
26-
public bool AutoGenerated => false;
27-
public bool UseInternalAssemblyName { get; init; }
28-
29-
[Obsolete("Use RunModes flag.")]
30-
public string Client
31-
{
32-
get
33-
{
34-
if (RunModes.HasFlag(TargetRunMode.ClientEnabled))
35-
return "Standard";
36-
if (RunModes.HasFlag(TargetRunMode.ClientAlways))
37-
return "Forced";
38-
return "None";
39-
}
40-
}
41-
[Obsolete("Use RunModes flag.")]
42-
public string Server
43-
{
44-
get
45-
{
46-
if (RunModes.HasFlag(TargetRunMode.ServerEnabled))
47-
return "Standard";
48-
if (RunModes.HasFlag(TargetRunMode.ServerAlways))
49-
return "Forced";
50-
return "None";
51-
}
52-
}
53-
54-
[Obsolete("Use RunModes flag.")]
55-
public bool IsForced()
56-
{
57-
throw new NotImplementedException();
58-
}
59-
60-
[Obsolete("Use RunModes flag.")]
61-
public bool IsStandard()
62-
{
63-
throw new NotImplementedException();
64-
}
65-
66-
[Obsolete("Use RunModes flag.")]
67-
public bool IsForcedOrStandard()
68-
{
69-
throw new NotImplementedException();
70-
}
17+
// metadata
18+
public ImmutableArray<IPackageDependencyInfo> Dependencies { get; init; }
19+
public ImmutableArray<IAssemblyResourceInfo> LoadableAssemblies { get; init; }
20+
public ImmutableArray<ILocalizationResourceInfo> LocalizationFiles { get; init; }
7121
}
7222

7323
#endregion
7424

7525
#region DataContracts
7626

77-
[Serializable]
7827
public readonly struct AssemblyResourceInfo : IAssemblyResourceInfo
7928
{
80-
public string Name { get; init; }
29+
public string FriendlyName { get; init; }
8130
public bool IsScript { get; init; }
8231
public bool LazyLoad { get; init; }
83-
public string Path { get; init; }
8432
public Platform SupportedPlatforms { get; init; }
8533
public Target SupportedTargets { get; init; }
8634
public ImmutableArray<string> FilePaths { get; init; }
35+
public ImmutableArray<CultureInfo> SupportedCultures { get; init; }
36+
public ImmutableArray<IPackageDependencyInfo> Dependencies { get; init; }
8737
}
8838

89-
[Serializable]
9039
public readonly struct DependencyInfo : IPackageDependencyInfo
9140
{
9241
public string FolderPath { get; init; }
9342
public string PackageName { get; init; }
9443
public ulong SteamWorkshopId { get; init; }
9544
public ContentPackage DependencyPackage { get; init; }
45+
public bool Optional { get; init; }
9646
}
9747

98-
[Serializable]
9948
public readonly struct LocalizationResourceInfo : ILocalizationResourceInfo
10049
{
10150
public CultureInfo TargetCulture { get; init; }
10251
public Platform SupportedPlatforms { get; init; }
10352
public Target SupportedTargets { get; init; }
10453
public ImmutableArray<string> FilePaths { get; init; }
10554
public ImmutableArray<CultureInfo> SupportedCultures { get; init; }
55+
public ImmutableArray<IPackageDependencyInfo> Dependencies { get; init; }
10656
}
10757

10858
#endregion

0 commit comments

Comments
 (0)