added support for modpack defined in version descriptor

This commit is contained in:
2024-12-29 12:15:51 +05:00
parent d141ec23dc
commit 2c780afea8
15 changed files with 256 additions and 92 deletions

View File

@@ -26,7 +26,7 @@ public class GameVersionCatalog
_ => p.OtherTypeAllowed
};
if(match)
_versionPropsList.Add(new GameVersionProps(r.id, r.url));
_versionPropsList.Add(new GameVersionProps(r));
}
return _versionPropsList;
}

View File

@@ -17,6 +17,9 @@ public class GameVersionDescriptor
public JavaVersion javaVersion { get; set; } = new() { component = "jre-legacy", majorVersion = 8 };
public string? minecraftArguments { get; set; }
public ArgumentsNew? arguments { get; set; }
// my additions
public MyModpackRemoteProps? modpack { get; set; }
}
public class Artifact

View File

@@ -0,0 +1,30 @@
using Mlaumcherb.Client.Avalonia.холопы;
namespace Mlaumcherb.Client.Avalonia.классы;
public class ModpackFilesManifest
{
public class FileProps
{
[JsonRequired] public string sha1 { get; set; }
public bool allow_edit { get; set; } = false;
}
/// relative_path, hash
[JsonRequired] public Dictionary<string, FileProps> files { get; set; } = new();
public bool CheckFiles(IOPath basedir, bool checkHashes, HashSet<IOPath> unmatchedFilesLocalPaths)
{
foreach (var p in files)
{
var localPath = new IOPath(p.Key);
var realPath = Path.Concat(basedir, localPath);
if (!HashHelper.CheckFileSHA1(realPath, p.Value.sha1, checkHashes && !p.Value.allow_edit))
{
unmatchedFilesLocalPaths.Add(localPath);
}
}
return unmatchedFilesLocalPaths.Count == 0;
}
}

View File

@@ -7,7 +7,7 @@ public class GameVersionProps : IComparable<GameVersionProps>, IEquatable<GameVe
{
public string Name { get; }
public IOPath LocalDescriptorPath { get; }
public string? RemoteDescriptorUrl { get; }
public RemoteVersionDescriptorProps? RemoteProps { get; }
private bool _isDownloaded;
public bool IsDownloaded
{
@@ -23,13 +23,22 @@ public class GameVersionProps : IComparable<GameVersionProps>, IEquatable<GameVe
}
public event Action<bool>? StatusChanged;
public GameVersionProps(string name, string? url)
private GameVersionProps(string name, RemoteVersionDescriptorProps? remoteProps)
{
Name = name;
RemoteProps = remoteProps;
LocalDescriptorPath = PathHelper.GetVersionDescriptorPath(name);
RemoteDescriptorUrl = url;
IsDownloaded = File.Exists(PathHelper.GetVersionJarFilePath(name));
}
public GameVersionProps(string name)
: this(name, null)
{ }
public GameVersionProps(RemoteVersionDescriptorProps remoteProps)
: this(remoteProps.id, remoteProps)
{ }
public void DeleteFiles()
{

View File

@@ -0,0 +1,19 @@
namespace Mlaumcherb.Client.Avalonia.классы;
public class MyModpackRemoteProps
{
[JsonRequired] public int format_version { get; set; }
[JsonRequired] public Artifact artifact { get; set; } = null!;
}
public class MyModpackV1
{
// 1
[JsonRequired] public int format_version { get; set; }
[JsonRequired] public string name { get; set; }
// zip archive with all files
[JsonRequired] public Artifact zip { get; set; } = null!;
// ModpackFilesManifest
[JsonRequired] public Artifact manifest { get; set; } = null!;
}