forked from FakeFishGames/Barotrauma
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Begun implementation of package loading.
- Loading branch information
1 parent
e4eb463
commit 9bcdb25
Showing
16 changed files
with
215 additions
and
21 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IModConfigInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Collections.Immutable; | ||
|
||
namespace Barotrauma.LuaCs.Data; | ||
|
||
public partial interface IModConfigInfo | ||
{ | ||
/// <summary> | ||
/// Collection of loadable styles data. | ||
/// </summary> | ||
ImmutableArray<IStylesResourceInfo> StylesResourceInfos { get; } | ||
} |
2 changes: 1 addition & 1 deletion
2
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IStylesResourceInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
namespace Barotrauma.LuaCs.Data; | ||
|
||
public interface IStylesResourceInfo : IResourceInfo, IResourceCultureInfo { } | ||
public interface IStylesResourceInfo : IResourceInfo, IResourceCultureInfo, ILazyLoadableResourceInfo, IPackageDependenciesInfo { } |
8 changes: 8 additions & 0 deletions
8
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/ModConfigInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System.Collections.Immutable; | ||
|
||
namespace Barotrauma.LuaCs.Data; | ||
|
||
public readonly partial struct ModConfigInfo : IModConfigInfo | ||
{ | ||
public ImmutableArray<IStylesResourceInfo> StylesResourceInfos { get; init; } | ||
} |
29 changes: 29 additions & 0 deletions
29
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/PackageService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using Barotrauma.LuaCs.Services.Processing; | ||
|
||
namespace Barotrauma.LuaCs.Services; | ||
|
||
public partial class PackageService | ||
{ | ||
private readonly Lazy<IXmlStylesToResConverterService> _stylesConverterService; | ||
|
||
public PackageService( | ||
Lazy<IXmlModConfigConverterService> converterService, | ||
Lazy<IXmlLegacyModConfigConverterService> legacyConfigConverterService, | ||
Lazy<IXmlLocalizationResConverterService> localizationConverterService, | ||
Lazy<IXmlStylesToResConverterService> stylesConverterService, | ||
IStorageService storageService, | ||
ILoggerService loggerService) | ||
{ | ||
_modConfigConverterService = converterService; | ||
_legacyConfigConverterService = legacyConfigConverterService; | ||
_localizationConverterService = localizationConverterService; | ||
_stylesConverterService = stylesConverterService; | ||
_storageService = storageService; | ||
_loggerService = loggerService; | ||
} | ||
partial void TryParsePackageClient(ContentPackage package) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Barotrauma/BarotraumaServer/ServerSource/LuaCs/Services/PackageService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using Barotrauma.LuaCs.Services.Processing; | ||
|
||
namespace Barotrauma.LuaCs.Services; | ||
|
||
public partial class PackageService | ||
{ | ||
public PackageService( | ||
Lazy<IXmlModConfigConverterService> converterService, | ||
Lazy<IXmlLegacyModConfigConverterService> legacyConfigConverterService, | ||
Lazy<IXmlLocalizationResConverterService> localizationConverterService, | ||
IStorageService storageService, | ||
ILoggerService loggerService) | ||
{ | ||
_modConfigConverterService = converterService; | ||
_legacyConfigConverterService = legacyConfigConverterService; | ||
_localizationConverterService = localizationConverterService; | ||
_storageService = storageService; | ||
_loggerService = loggerService; | ||
} | ||
// No implementation | ||
partial void TryParsePackageClient(ContentPackage package) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 7 additions & 6 deletions
13
Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IContentPackageService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
using Barotrauma.LuaCs.Data; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using Barotrauma.LuaCs.Data; | ||
|
||
namespace Barotrauma.LuaCs.Services; | ||
|
||
public interface IContentPackageService : IService | ||
{ | ||
bool TryLoadPackageData(ContentPackage package); | ||
ModConfigInfo GetModConfigData(); | ||
ContentPackage TryFindPackage(string packageName, bool prioritizeLocal = true); | ||
ContentPackage TryFindPackage(int steamId); | ||
ContentPath GetContentPath(); | ||
bool TryParsePackage(ContentPackage package); | ||
ContentPackage Package { get; } | ||
IModConfigInfo ModConfigInfo { get; } | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IPackageManagementService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Barotrauma.LuaCs.Services; | ||
|
||
public interface IPackageManagementService : IService | ||
{ | ||
|
||
} |
28 changes: 27 additions & 1 deletion
28
Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/IStorageService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
using System.Xml.Linq; | ||
using System.Collections.Immutable; | ||
using System.Xml.Linq; | ||
|
||
namespace Barotrauma.LuaCs.Services; | ||
|
||
public interface IStorageService : IService | ||
{ | ||
#region LocalGameData | ||
|
||
bool TryLoadLocalXml(ContentPackage package, string localFilePath, out XDocument document); | ||
bool TryLoadLocalBinary(ContentPackage package, string localFilePath, out byte[] bytes); | ||
bool TryLoadLocalText(ContentPackage package, string localFilePath, out string text); | ||
|
||
#endregion | ||
|
||
#region ContentPackageData | ||
bool TryLoadPackageXml(ContentPackage package, string localFilePath, out XDocument document); | ||
bool TryLoadPackageBinary(ContentPackage package, string localFilePath, out byte[] bytes); | ||
bool TryLoadPackageText(ContentPackage package, string localFilePath, out string text); | ||
|
||
ImmutableArray<bool> TryLoadPackageXmlFiles(ContentPackage package, ImmutableArray<string> localFilePath, out ImmutableArray<XDocument> document); | ||
ImmutableArray<bool> TryLoadPackageBinaryFiles(ContentPackage package, ImmutableArray<string> localFilePath, out ImmutableArray<byte[]> bytes); | ||
ImmutableArray<bool> TryLoadPackageTextFiles(ContentPackage package, ImmutableArray<string> localFilePath, out ImmutableArray<string> text); | ||
|
||
bool FindFilesInPackage(ContentPackage package, string localSubfolder, string regexFilter, bool searchRecursively, out ImmutableArray<string> localFilePaths); | ||
|
||
#endregion | ||
|
||
#region AbsolutePaths | ||
|
||
bool TryLoadXml(string filePath, out XDocument document); | ||
bool TrySaveXml(string filePath, in XDocument document); | ||
bool TryLoadBinary(string filePath, out byte[] bytes); | ||
bool TrySaveBinary(string filePath, in byte[] bytes); | ||
bool TryLoadText(string filePath, out string text); | ||
bool TrySaveText(string filePath, string text); | ||
bool FileExists(string filePath); | ||
|
||
#endregion | ||
} |
18 changes: 18 additions & 0 deletions
18
Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageManagementService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
|
||
namespace Barotrauma.LuaCs.Services; | ||
|
||
public class PackageManagementService : IPackageManagementService | ||
{ | ||
private Func<IContentPackageService> GetPackageServiceInstance { get; init; } | ||
|
||
public PackageManagementService(Func<IContentPackageService> getPackageService) | ||
{ | ||
this.GetPackageServiceInstance = getPackageService; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Barotrauma/BarotraumaShared/SharedSource/LuaCs/Services/PackageService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using Barotrauma.LuaCs.Data; | ||
using Barotrauma.LuaCs.Services.Processing; | ||
|
||
namespace Barotrauma.LuaCs.Services; | ||
|
||
public partial class PackageService : IContentPackageService | ||
{ | ||
private readonly Lazy<IXmlModConfigConverterService> _modConfigConverterService; | ||
private readonly Lazy<IXmlLegacyModConfigConverterService> _legacyConfigConverterService; | ||
private readonly Lazy<IXmlLocalizationResConverterService> _localizationConverterService; | ||
private readonly IStorageService _storageService; | ||
private readonly ILoggerService _loggerService; | ||
|
||
// cctor in server source and client source | ||
|
||
public ContentPackage Package { get; private set; } | ||
|
||
public IModConfigInfo ModConfigInfo { get; private set; } | ||
|
||
public bool TryParsePackage(ContentPackage package) | ||
{ | ||
// scan for files: modconfig.xml | ||
|
||
// on fail, scan and try for legacy loading | ||
|
||
// load resources info for: config, assemblies, lua files, localization | ||
|
||
// load styles data on clients | ||
TryParsePackageClient(package); | ||
|
||
throw new NotImplementedException(); | ||
} | ||
|
||
partial void TryParsePackageClient(ContentPackage package); | ||
|
||
public void Dispose() | ||
{ | ||
// TODO release managed resources here | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters