Skip to content

Commit 38f4005

Browse files
committed
- More data interface work.
1 parent d008a94 commit 38f4005

File tree

7 files changed

+145
-86
lines changed

7 files changed

+145
-86
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
3+
namespace Barotrauma.LuaCs.Data;
4+
5+
public interface IAssemblyResourceInfo
6+
{
7+
/// <summary>
8+
/// The friendly name of the assembly. Script files belonging to the same assembly should all have the same name.
9+
/// Legacy scripts will all be given the sanitized name of the Content Package they belong to.
10+
/// </summary>
11+
public string Name { get; }
12+
/// <summary>
13+
/// Is this entry referring to a script file.
14+
/// </summary>
15+
public bool IsScriptFile { get; }
16+
/// <summary>
17+
/// Should this be compiled or loaded immediately or stored for On-Demand compilation.
18+
/// </summary>
19+
public bool LazyLoad { get; }
20+
/// <summary>
21+
/// Path to the file.
22+
/// </summary>
23+
public string Path { get; }
24+
/// <summary>
25+
/// All supported platforms.
26+
/// </summary>
27+
public Platform Platforms { get; }
28+
/// <summary>
29+
/// All supported run targets (client and/or server)
30+
/// </summary>
31+
public Target Targets { get; }
32+
}
33+
34+
[Flags]
35+
public enum Platform
36+
{
37+
Linux=0x1,
38+
OSX=0x2,
39+
Windows=0x4
40+
}
41+
42+
[Flags]
43+
public enum Target
44+
{
45+
Client=0x1,
46+
Server=0x2
47+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
3+
namespace Barotrauma.LuaCs.Data;
4+
5+
// TODO: Finish
6+
public interface IConfigDefinitionInfo
7+
{
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+
}
16+
17+
public enum ConfigDataType
18+
{
19+
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace Barotrauma.LuaCs.Data;
2+
3+
public interface IPackageDependencyInfo
4+
{
5+
/// <summary>
6+
/// Root folder of the content package.
7+
/// </summary>
8+
public string FolderPath { get; }
9+
/// <summary>
10+
/// Name of the package.
11+
/// </summary>
12+
public string PackageName { get; }
13+
/// <summary>
14+
/// Steam ID of the package.
15+
/// </summary>
16+
public int SteamId { get; }
17+
/// <summary>
18+
/// The dependency package, if found.
19+
/// </summary>
20+
public ContentPackage DependencyPackage { get; }
21+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.Immutable;
4+
5+
namespace Barotrauma.LuaCs.Data;
6+
7+
public readonly struct ModConfigData
8+
{
9+
public bool RunConfigLegacy { get; init; }
10+
11+
public DependencyInfo[] Dependencies { get; init; }
12+
public AssemblyResourceInfo[] LoadableAssemblies { get; init; }
13+
14+
15+
public readonly struct ConfigInitData
16+
{
17+
// TODO: complete struct, data here should be already parsed and ready-to-use by the config service.
18+
}
19+
20+
public readonly struct AssemblyResourceInfo : IAssemblyResourceInfo
21+
{
22+
public string Name { get; init; }
23+
public bool IsScriptFile { get; init; }
24+
public bool LazyLoad { get; init; }
25+
public string Path { get; init; }
26+
public Platform Platforms { get; init; }
27+
public Target Targets { get; init; }
28+
}
29+
30+
public readonly struct DependencyInfo : IPackageDependencyInfo
31+
{
32+
public string FolderPath { get; init; }
33+
public string PackageName { get; init; }
34+
public int SteamId { get; init; }
35+
public ContentPackage DependencyPackage { get; init; }
36+
}
37+
38+
39+
}

Barotrauma/BarotraumaShared/SharedSource/LuaCs/ModConfigData.cs

Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
namespace Barotrauma.LuaCs.Services;
1+
using Barotrauma.LuaCs.Data;
2+
3+
namespace Barotrauma.LuaCs.Services;
24

35
public interface IContentPackageProcessorService : IService
46
{
5-
ModConfigData GetModConfigData(ContentPackage package);
7+
bool TryLoadPackageData(ContentPackage package);
8+
ModConfigData GetModConfigData();
69
ContentPackage TryFindPackage(string packageName, bool prioritizeLocal = true);
710
ContentPackage TryFindPackage(int steamId);
8-
ContentPath GetContentPath(ContentPackage package);
11+
ContentPath GetContentPath();
912
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace Barotrauma.LuaCs.Services;
5+
6+
public interface ILocalizationService : IService
7+
{
8+
bool TryLoadFiles(in string[] filePaths);
9+
void UnloadAll();
10+
string GetLocalizedString(string key, string fallback);
11+
string GetLocalizedString(string key, Func<string, string> fbValueFactory);
12+
}

0 commit comments

Comments
 (0)