Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c3b8963ac | |||
| e915892fa2 | |||
| ab1aefd619 | |||
| 459b3f09f9 | |||
| 9bcdfd88e6 | |||
| 2dc472c85a | |||
| 2087c14285 | |||
| ef36fb5584 | |||
| d6bd7b9ef0 | |||
| 23195bd7c7 | |||
| 5e439ee8d5 |
@ -27,9 +27,9 @@ public record Config
|
|||||||
new() { name = "Mojang", url = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json" },
|
new() { name = "Mojang", url = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json" },
|
||||||
];
|
];
|
||||||
|
|
||||||
public UpdateHelper.GiteaConfig gitea { get; set; } = new UpdateHelper.GiteaConfig
|
public UpdateHelper.GiteaConfig gitea { get; set; } = new()
|
||||||
{
|
{
|
||||||
serverUrl = "https://timerix.ddns.net:3322",
|
serverUrl = "https://timerix.ddns.net/git/",
|
||||||
user = "Timerix",
|
user = "Timerix",
|
||||||
repo = "mlaumcherb",
|
repo = "mlaumcherb",
|
||||||
};
|
};
|
||||||
|
|||||||
@ -34,10 +34,11 @@ public class GameVersion
|
|||||||
_gameArgs = new GameArguments(_descriptor);
|
_gameArgs = new GameArguments(_descriptor);
|
||||||
_libraries = new Libraries(_descriptor);
|
_libraries = new Libraries(_descriptor);
|
||||||
WorkingDirectory = GetVersionDir(_descriptor.id);
|
WorkingDirectory = GetVersionDir(_descriptor.id);
|
||||||
JavaExecutableFilePath = GetJavaExecutablePath(_descriptor.javaVersion.component, LauncherApp.Config.debug);
|
JavaExecutableFilePath = GetJavaExecutablePath(
|
||||||
|
_descriptor.javaVersion.component, LauncherApp.Config.redirect_game_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Download(bool update, Action<NetworkTask> networkTaskCreatedCallback)
|
public async Task Download(bool checkHashes, Action<NetworkTask> networkTaskCreatedCallback)
|
||||||
{
|
{
|
||||||
LauncherApp.Logger.LogInfo(Id, $"started updating version {Id}");
|
LauncherApp.Logger.LogInfo(Id, $"started updating version {Id}");
|
||||||
|
|
||||||
@ -46,9 +47,9 @@ public class GameVersion
|
|||||||
new AssetsDownloadTaskFactory(_descriptor),
|
new AssetsDownloadTaskFactory(_descriptor),
|
||||||
new LibrariesDownloadTaskFactory(_descriptor, _libraries),
|
new LibrariesDownloadTaskFactory(_descriptor, _libraries),
|
||||||
];
|
];
|
||||||
if (LauncherApp.Config.download_java)
|
if (LauncherApp.Config.download_java && (!File.Exists(JavaExecutableFilePath) || checkHashes))
|
||||||
taskFactories.Add(new JavaDownloadTaskFactory(_descriptor));
|
taskFactories.Add(new JavaDownloadTaskFactory(_descriptor));
|
||||||
if (_descriptor.modpack != null)
|
if (_descriptor.modpack != null)
|
||||||
taskFactories.Add(new ModpackDownloadTaskFactory(_descriptor));
|
taskFactories.Add(new ModpackDownloadTaskFactory(_descriptor));
|
||||||
// has to be downloaded last because it is used to check if version is installed
|
// has to be downloaded last because it is used to check if version is installed
|
||||||
taskFactories.Add(new VersionJarDownloadTaskFactory(_descriptor));
|
taskFactories.Add(new VersionJarDownloadTaskFactory(_descriptor));
|
||||||
@ -56,7 +57,7 @@ public class GameVersion
|
|||||||
var networkTasks = new List<NetworkTask>();
|
var networkTasks = new List<NetworkTask>();
|
||||||
for (int i = 0; i < taskFactories.Count; i++)
|
for (int i = 0; i < taskFactories.Count; i++)
|
||||||
{
|
{
|
||||||
var nt = await taskFactories[i].CreateAsync(update);
|
var nt = await taskFactories[i].CreateAsync(checkHashes);
|
||||||
if (nt != null)
|
if (nt != null)
|
||||||
{
|
{
|
||||||
networkTasks.Add(nt);
|
networkTasks.Add(nt);
|
||||||
@ -108,6 +109,7 @@ public class GameVersion
|
|||||||
if (string.IsNullOrWhiteSpace(LauncherApp.Config.player_name))
|
if (string.IsNullOrWhiteSpace(LauncherApp.Config.player_name))
|
||||||
throw new Exception("invalid player name");
|
throw new Exception("invalid player name");
|
||||||
|
|
||||||
|
string classSeparator = PlatformHelper.GetOs() == "windows" ? ";" : ":";
|
||||||
Directory.Create(WorkingDirectory);
|
Directory.Create(WorkingDirectory);
|
||||||
string uuid = GetPlayerUUID(LauncherApp.Config.player_name);
|
string uuid = GetPlayerUUID(LauncherApp.Config.player_name);
|
||||||
Dictionary<string, string> placeholder_values = new() {
|
Dictionary<string, string> placeholder_values = new() {
|
||||||
@ -127,14 +129,14 @@ public class GameVersion
|
|||||||
{ "launcher_version", "1.6.84-j" },
|
{ "launcher_version", "1.6.84-j" },
|
||||||
{ "classpath", _libraries.Libs.Select(l => l.jarFilePath)
|
{ "classpath", _libraries.Libs.Select(l => l.jarFilePath)
|
||||||
.Append(GetVersionJarFilePath(_descriptor.id))
|
.Append(GetVersionJarFilePath(_descriptor.id))
|
||||||
.MergeToString(';') },
|
.MergeToString(classSeparator) },
|
||||||
{ "assets_index_name", _descriptor.assets },
|
{ "assets_index_name", _descriptor.assets },
|
||||||
{ "assets_root", GetAssetsDir().ToString() },
|
{ "assets_root", GetAssetsDir().ToString() },
|
||||||
{ "game_assets", GetAssetsDir().ToString() },
|
{ "game_assets", GetAssetsDir().ToString() },
|
||||||
{ "game_directory", WorkingDirectory.ToString() },
|
{ "game_directory", WorkingDirectory.ToString() },
|
||||||
{ "natives_directory", GetNativeLibrariesDir(_descriptor.id).ToString() },
|
{ "natives_directory", GetNativeLibrariesDir(_descriptor.id).ToString() },
|
||||||
{ "library_directory", GetLibrariesDir().ToString() },
|
{ "library_directory", GetLibrariesDir().ToString() },
|
||||||
{ "classpath_separator", ";"},
|
{ "classpath_separator", classSeparator},
|
||||||
{ "path", GetLog4jConfigFilePath().ToString() },
|
{ "path", GetLog4jConfigFilePath().ToString() },
|
||||||
{ "version_name", _descriptor.id },
|
{ "version_name", _descriptor.id },
|
||||||
{ "version_type", _descriptor.type },
|
{ "version_type", _descriptor.type },
|
||||||
@ -186,4 +188,4 @@ public class GameVersion
|
|||||||
|
|
||||||
|
|
||||||
public override string ToString() => Id;
|
public override string ToString() => Id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ public class LauncherLogger : ILogger
|
|||||||
private CompositeLogger _compositeLogger;
|
private CompositeLogger _compositeLogger;
|
||||||
private FileLogger _fileLogger;
|
private FileLogger _fileLogger;
|
||||||
public static readonly IOPath LogsDirectory = "launcher_logs";
|
public static readonly IOPath LogsDirectory = "launcher_logs";
|
||||||
public IOPath LogfileName => _fileLogger.LogfileName;
|
public IOPath LogFilePath => _fileLogger.LogfileName;
|
||||||
|
|
||||||
public LauncherLogger()
|
public LauncherLogger()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>1.1.0</Version>
|
<Version>1.1.2</Version>
|
||||||
<OutputType Condition="'$(Configuration)' == 'Debug'">Exe</OutputType>
|
<OutputType Condition="'$(Configuration)' == 'Debug'">Exe</OutputType>
|
||||||
<OutputType Condition="'$(Configuration)' != 'Debug'">WinExe</OutputType>
|
<OutputType Condition="'$(Configuration)' != 'Debug'">WinExe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
@ -12,7 +12,6 @@
|
|||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
<ApplicationIcon>капитал\кубе.ico</ApplicationIcon>
|
<ApplicationIcon>капитал\кубе.ico</ApplicationIcon>
|
||||||
<AssemblyName>млаумчерб</AssemblyName>
|
<AssemblyName>млаумчерб</AssemblyName>
|
||||||
<Configurations>Release;Debug</Configurations>
|
|
||||||
<Platforms>x64</Platforms>
|
<Platforms>x64</Platforms>
|
||||||
<!-- AXAML resource has no public constructor -->
|
<!-- AXAML resource has no public constructor -->
|
||||||
<NoWarn>AVLN3001</NoWarn>
|
<NoWarn>AVLN3001</NoWarn>
|
||||||
@ -25,7 +24,7 @@
|
|||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.*" />
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.*" />
|
||||||
<PackageReference Include="Avalonia.Labs.Gif" Version="11.2.*" />
|
<PackageReference Include="Avalonia.Labs.Gif" Version="11.2.*" />
|
||||||
<PackageReference Include="CliWrap" Version="3.7.0" />
|
<PackageReference Include="CliWrap" Version="3.7.0" />
|
||||||
<PackageReference Include="DTLib" Version="1.6.1" />
|
<PackageReference Include="DTLib" Version="1.7.3" />
|
||||||
<PackageReference Include="LZMA-SDK" Version="22.1.1" />
|
<PackageReference Include="LZMA-SDK" Version="22.1.1" />
|
||||||
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
|
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.*" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.*" />
|
||||||
@ -35,9 +34,5 @@
|
|||||||
<AvaloniaResource Include="капитал\**"/>
|
<AvaloniaResource Include="капитал\**"/>
|
||||||
<EmbeddedResource Include="встроенное\**" />
|
<EmbeddedResource Include="встроенное\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Gitea\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -2,7 +2,6 @@ using Avalonia;
|
|||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Mlaumcherb.Client.Avalonia.классы;
|
using Mlaumcherb.Client.Avalonia.классы;
|
||||||
using Mlaumcherb.Client.Avalonia.сеть;
|
|
||||||
using Mlaumcherb.Client.Avalonia.сеть.Update;
|
using Mlaumcherb.Client.Avalonia.сеть.Update;
|
||||||
using Mlaumcherb.Client.Avalonia.холопы;
|
using Mlaumcherb.Client.Avalonia.холопы;
|
||||||
|
|
||||||
@ -20,19 +19,26 @@ public class LauncherApp : Application
|
|||||||
Config = Config.LoadFromFile();
|
Config = Config.LoadFromFile();
|
||||||
Logger.DebugLogEnabled = Config.debug;
|
Logger.DebugLogEnabled = Config.debug;
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
|
||||||
Update();
|
|
||||||
|
|
||||||
// some file required by forge installer
|
try
|
||||||
if (!File.Exists("launcher_profiles.json"))
|
|
||||||
{
|
{
|
||||||
File.WriteAllText("launcher_profiles.json", "{}");
|
SelfUpdateAsync();
|
||||||
}
|
|
||||||
|
// some file required by forge installer
|
||||||
|
if (!File.Exists("launcher_profiles.json"))
|
||||||
|
{
|
||||||
|
File.WriteAllText("launcher_profiles.json", "{}");
|
||||||
|
}
|
||||||
|
|
||||||
InstalledVersionCatalog = InstalledVersionCatalog.Load();
|
InstalledVersionCatalog = InstalledVersionCatalog.Load();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ErrorHelper.ShowMessageBox(nameof(LauncherApp), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Update()
|
private async void SelfUpdateAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -46,6 +52,10 @@ public class LauncherApp : Application
|
|||||||
Logger.LogInfo(nameof(LauncherApp), "restarting...");
|
Logger.LogInfo(nameof(LauncherApp), "restarting...");
|
||||||
upd.RestartSelf();
|
upd.RestartSelf();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogInfo(nameof(LauncherApp), "no updates found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -71,7 +71,7 @@ public partial class MainWindow : Window
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
LauncherApp.Logger.OnLogMessage += GuiLogMessage;
|
LauncherApp.Logger.OnLogMessage += GuiLogMessage;
|
||||||
LauncherVersionTextBox.Text = $"v {Assembly.GetExecutingAssembly().GetName().Version}";
|
LauncherVersionTextBox.Text = $"v{Assembly.GetExecutingAssembly().GetName().Version}";
|
||||||
|
|
||||||
PlayerName = LauncherApp.Config.player_name;
|
PlayerName = LauncherApp.Config.player_name;
|
||||||
MemoryLimit = LauncherApp.Config.max_memory;
|
MemoryLimit = LauncherApp.Config.max_memory;
|
||||||
@ -92,6 +92,20 @@ public partial class MainWindow : Window
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnUnloaded(RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SaveGuiPropertiesToConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveGuiPropertiesToConfig()
|
||||||
|
{
|
||||||
|
LauncherApp.Config.player_name = PlayerName;
|
||||||
|
LauncherApp.Config.max_memory = MemoryLimit;
|
||||||
|
LauncherApp.Config.download_java = EnableJavaDownload;
|
||||||
|
LauncherApp.Config.redirect_game_output = RedirectGameOutput;
|
||||||
|
LauncherApp.Config.SaveToFile();
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateInstalledVersionsCatalogView(string? selectVersion)
|
private void UpdateInstalledVersionsCatalogView(string? selectVersion)
|
||||||
{
|
{
|
||||||
LauncherApp.InstalledVersionCatalog.CheckInstalledVersions();
|
LauncherApp.InstalledVersionCatalog.CheckInstalledVersions();
|
||||||
@ -121,8 +135,15 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
private void RescanInstalledVersionsButton_OnClick(object? sender, RoutedEventArgs e)
|
private void RescanInstalledVersionsButton_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var selectedVersionView = InstalledVersionCatalogComboBox.SelectedItem as InstalledGameVersionItemView;
|
try
|
||||||
UpdateInstalledVersionsCatalogView(selectedVersionView?.Props.Id);
|
{
|
||||||
|
var selectedVersionView = InstalledVersionCatalogComboBox.SelectedItem as InstalledGameVersionItemView;
|
||||||
|
UpdateInstalledVersionsCatalogView(selectedVersionView?.Props.Id);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ErrorHelper.ShowMessageBox(nameof(MainWindow), ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GuiLogMessage(LauncherLogger.LogMessage msg)
|
private void GuiLogMessage(LauncherLogger.LogMessage msg)
|
||||||
@ -147,22 +168,27 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
Dispatcher.UIThread.Invoke(() => LaunchButton.IsEnabled = false);
|
Dispatcher.UIThread.Invoke(() => LaunchButton.IsEnabled = false);
|
||||||
LauncherApp.Config.last_launched_version = selectedVersionView.Props.Id;
|
LauncherApp.Config.last_launched_version = selectedVersionView.Props.Id;
|
||||||
LauncherApp.Config.player_name = PlayerName;
|
SaveGuiPropertiesToConfig();
|
||||||
LauncherApp.Config.max_memory = MemoryLimit;
|
|
||||||
LauncherApp.Config.download_java = EnableJavaDownload;
|
|
||||||
LauncherApp.Config.redirect_game_output = RedirectGameOutput;
|
|
||||||
LauncherApp.Config.SaveToFile();
|
|
||||||
|
|
||||||
var v = await selectedVersionView.Props.LoadDescriptor(UpdateGameFiles);
|
var v = await selectedVersionView.Props.LoadDescriptor(UpdateGameFiles);
|
||||||
await v.Download(UpdateGameFiles, nt =>
|
|
||||||
{
|
try
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
{
|
||||||
|
await v.Download(UpdateGameFiles, nt =>
|
||||||
{
|
{
|
||||||
DownloadsPanel.Children.Add(new NetworkTaskView(nt,
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
ntv => DownloadsPanel.Children.Remove(ntv)));
|
{
|
||||||
});
|
DownloadsPanel.Children.Add(new NetworkTaskView(nt,
|
||||||
}
|
ntv => DownloadsPanel.Children.Remove(ntv)));
|
||||||
);
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ErrorHelper.ShowMessageBox(nameof(MainWindow), ex);
|
||||||
|
}
|
||||||
|
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
UpdateGameFiles = false;
|
UpdateGameFiles = false;
|
||||||
@ -183,7 +209,10 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Launcher.LaunchDirectoryInfoAsync(new DirectoryInfo(Directory.GetCurrent().ToString()))
|
string workingDir = Directory.GetCurrent().ToString();
|
||||||
|
LauncherApp.Logger.LogDebug(nameof(MainWindow),
|
||||||
|
$"opening working directory: {workingDir}");
|
||||||
|
Launcher.LaunchDirectoryInfoAsync(new DirectoryInfo(workingDir))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -196,7 +225,10 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Launcher.LaunchFileInfoAsync(new FileInfo(LauncherApp.Logger.LogfileName.ToString()))
|
string logFilePath = LauncherApp.Logger.LogFilePath.ToString();
|
||||||
|
LauncherApp.Logger.LogDebug(nameof(MainWindow),
|
||||||
|
$"opening log file: {logFilePath}");
|
||||||
|
Launcher.LaunchFileInfoAsync(new FileInfo(logFilePath))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -209,7 +241,10 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Launcher.LaunchUriAsync(new Uri("https://timerix.ddns.net:3322/Timerix/mlaumcherb"))
|
var sourcesUri = new Uri(LauncherApp.Config.gitea.GetRepoUrl());
|
||||||
|
LauncherApp.Logger.LogDebug(nameof(MainWindow),
|
||||||
|
$"opening in web browser: {sourcesUri}");
|
||||||
|
Launcher.LaunchUriAsync(sourcesUri)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@ -5,9 +5,9 @@ namespace Mlaumcherb.Client.Avalonia.классы;
|
|||||||
|
|
||||||
public class JavaVersionCatalog
|
public class JavaVersionCatalog
|
||||||
{
|
{
|
||||||
[JsonProperty("linux")]
|
[JsonProperty("linux-i386")]
|
||||||
public Dictionary<string, JavaVersionProps[]>? linux_x86 { get; set; }
|
public Dictionary<string, JavaVersionProps[]>? linux_x86 { get; set; }
|
||||||
[JsonProperty("linux-i386")]
|
[JsonProperty("linux")]
|
||||||
public Dictionary<string, JavaVersionProps[]>? linux_x64 { get; set; }
|
public Dictionary<string, JavaVersionProps[]>? linux_x64 { get; set; }
|
||||||
[JsonProperty("mac-os")]
|
[JsonProperty("mac-os")]
|
||||||
public Dictionary<string, JavaVersionProps[]>? osx_x64 { get; set; }
|
public Dictionary<string, JavaVersionProps[]>? osx_x64 { get; set; }
|
||||||
@ -82,4 +82,4 @@ public class JavaCompressedArtifact
|
|||||||
{
|
{
|
||||||
public Artifact? lzma { get; set; }
|
public Artifact? lzma { get; set; }
|
||||||
[JsonRequired] public Artifact raw { get; set; } = null!;
|
[JsonRequired] public Artifact raw { get; set; } = null!;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,23 +66,26 @@ public class InstalledGameVersionProps : IComparable<InstalledGameVersionProps>,
|
|||||||
JObject descriptorRaw = JObject.Parse(descriptorText);
|
JObject descriptorRaw = JObject.Parse(descriptorText);
|
||||||
|
|
||||||
// Descriptors can inherit from other descriptors.
|
// Descriptors can inherit from other descriptors.
|
||||||
// For example, 1.12.2-forge-14.23.5.2860 inherits from 1.12.2
|
// For example, timerix-anarx-2 inherits from 1.12.2-forge-14.23.5.2860, which inherits from 1.12.2
|
||||||
if (descriptorRaw.TryGetValue("inheritsFrom", out var v))
|
while (descriptorRaw.TryGetValue("inheritsFrom", out var v))
|
||||||
{
|
{
|
||||||
string parentDescriptorId = v.Value<string>()
|
string parentDescriptorId = v.Value<string>()
|
||||||
?? throw new Exception("inheritsFrom is null");
|
?? throw new Exception("inheritsFrom is null");
|
||||||
LauncherApp.Logger.LogInfo(Id, $"merging descriptor '{parentDescriptorId}' with '{Id}'");
|
LauncherApp.Logger.LogInfo(Id, $"merging descriptor '{parentDescriptorId}' with '{Id}'");
|
||||||
|
|
||||||
IOPath parentDescriptorPath = PathHelper.GetVersionDescriptorPath(parentDescriptorId);
|
IOPath parentDescriptorPath = PathHelper.GetVersionDescriptorPath(parentDescriptorId);
|
||||||
if (!File.Exists(parentDescriptorPath))
|
if (!File.Exists(parentDescriptorPath))
|
||||||
throw new Exception($"Версия '{Id} требует установить версию '{parentDescriptorId}'");
|
throw new Exception($"Версия '{Id} требует установить версию '{parentDescriptorId}'");
|
||||||
string parentDescriptorText = File.ReadAllText(parentDescriptorPath);
|
JObject parentDescriptorRaw = JObject.Parse(File.ReadAllText(parentDescriptorPath));
|
||||||
JObject parentDescriptorRaw = JObject.Parse(parentDescriptorText);
|
|
||||||
|
// Remove `inheritsFrom: parentDescriptor.Id` to prevent overriding of `parentDescriptor.inheritsFrom`
|
||||||
|
descriptorRaw.Remove("inheritsFrom");
|
||||||
|
// Merge child descriptor into its parent.
|
||||||
|
// Child descriptor values override values of parent.
|
||||||
|
// Array values are merged together.
|
||||||
parentDescriptorRaw.Merge(descriptorRaw,
|
parentDescriptorRaw.Merge(descriptorRaw,
|
||||||
new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Concat });
|
new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Concat });
|
||||||
descriptorRaw = parentDescriptorRaw;
|
descriptorRaw = parentDescriptorRaw;
|
||||||
// removing dependency
|
|
||||||
// descriptorRaw.Remove("inheritsFrom");
|
|
||||||
// File.WriteAllText(DescriptorPath, descriptorRaw.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var descriptor = descriptorRaw.ToObject<GameVersionDescriptor>()
|
var descriptor = descriptorRaw.ToObject<GameVersionDescriptor>()
|
||||||
|
|||||||
@ -29,7 +29,6 @@ public class InstalledVersionCatalog
|
|||||||
}
|
}
|
||||||
|
|
||||||
catalog.CheckInstalledVersions();
|
catalog.CheckInstalledVersions();
|
||||||
catalog.Save();
|
|
||||||
return catalog;
|
return catalog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +43,7 @@ public class InstalledVersionCatalog
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if any versions were installed or deleted manually.
|
/// Check if any versions were installed or deleted manually.
|
||||||
|
/// Calls <see cref="Save"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CheckInstalledVersions()
|
public void CheckInstalledVersions()
|
||||||
{
|
{
|
||||||
@ -53,17 +53,16 @@ public class InstalledVersionCatalog
|
|||||||
{
|
{
|
||||||
string id = subdir.LastName().ToString();
|
string id = subdir.LastName().ToString();
|
||||||
if (!File.Exists(PathHelper.GetVersionDescriptorPath(id)))
|
if (!File.Exists(PathHelper.GetVersionDescriptorPath(id)))
|
||||||
throw new Exception(
|
{
|
||||||
$"Can't find version descriptor file in directory '{subdir}'. Rename it as directory name.");
|
LauncherApp.Logger.LogWarn(nameof(CheckInstalledVersions),
|
||||||
|
$"Can't find version descriptor file in directory '{subdir}'. " +
|
||||||
|
$"Rename it as directory name.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (versions.TryGetValue(id, out var foundProps))
|
if (versions.TryGetValue(id, out var foundProps))
|
||||||
{
|
|
||||||
versionsUpdated.Add(foundProps);
|
versionsUpdated.Add(foundProps);
|
||||||
}
|
else versionsUpdated.Add(new InstalledGameVersionProps(id, null, null));
|
||||||
else
|
|
||||||
{
|
|
||||||
versionsUpdated.Add(new InstalledGameVersionProps(id, null, null));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reverse sort
|
// reverse sort
|
||||||
@ -73,5 +72,7 @@ public class InstalledVersionCatalog
|
|||||||
versionsUpdated.Select(props =>
|
versionsUpdated.Select(props =>
|
||||||
new KeyValuePair<string, InstalledGameVersionProps>(props.Id, props)
|
new KeyValuePair<string, InstalledGameVersionProps>(props.Id, props)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12,6 +12,7 @@ public static class NetworkHelper
|
|||||||
// thanks for Sashok :3
|
// thanks for Sashok :3
|
||||||
// https://github.com/new-sashok724/Launcher/blob/23485c3f7de6620d2c6b7b2dd9339c3beb6a0366/Launcher/source/helper/IOHelper.java#L259
|
// https://github.com/new-sashok724/Launcher/blob/23485c3f7de6620d2c6b7b2dd9339c3beb6a0366/Launcher/source/helper/IOHelper.java#L259
|
||||||
_http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
|
_http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
|
||||||
|
_http.Timeout = TimeSpan.FromSeconds(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task<string> GetString(string url, CancellationToken ct = default) => _http.GetStringAsync(url, ct);
|
public static Task<string> GetString(string url, CancellationToken ct = default) => _http.GetStringAsync(url, ct);
|
||||||
|
|||||||
@ -42,14 +42,20 @@ public class LibrariesDownloadTaskFactory : INetworkTaskFactory
|
|||||||
|
|
||||||
foreach (var l in _libraries.Libs)
|
foreach (var l in _libraries.Libs)
|
||||||
{
|
{
|
||||||
if (!HashHelper.CheckFileSHA1(l.jarFilePath, l.artifact?.sha1, checkHashes))
|
if (l is Libraries.NativeLib native)
|
||||||
{
|
{
|
||||||
_libsToDownload.Add(l);
|
//TODO: replace with actual native libraries check
|
||||||
|
if(!nativeDirExists || checkHashes)
|
||||||
|
{
|
||||||
|
_libsToDownload.Add(l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//TODO: replace with actual native libraries check
|
else
|
||||||
else if (!nativeDirExists && l is Libraries.NativeLib)
|
|
||||||
{
|
{
|
||||||
_libsToDownload.Add(l);
|
if (!HashHelper.CheckFileSHA1(l.jarFilePath, l.artifact?.sha1, checkHashes))
|
||||||
|
{
|
||||||
|
_libsToDownload.Add(l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class GiteaClient(string ServerUrl)
|
|||||||
{
|
{
|
||||||
public async Task<Release> GetLatestRelease(string user, string repo)
|
public async Task<Release> GetLatestRelease(string user, string repo)
|
||||||
{
|
{
|
||||||
string url = $"{ServerUrl}//api/v1/repos/{user}/{repo}/releases/latest";
|
string url = $"{ServerUrl}/api/v1/repos/{user}/{repo}/releases/latest";
|
||||||
return await NetworkHelper.DownloadStringAndDeserialize<Release>(url);
|
return await NetworkHelper.DownloadStringAndDeserialize<Release>(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10,15 +10,17 @@ public class UpdateHelper
|
|||||||
private readonly IOPath executablePathOld;
|
private readonly IOPath executablePathOld;
|
||||||
private readonly IOPath executablePathNew;
|
private readonly IOPath executablePathNew;
|
||||||
|
|
||||||
|
private readonly GiteaConfig _giteaConfig;
|
||||||
|
|
||||||
public class GiteaConfig
|
public class GiteaConfig
|
||||||
{
|
{
|
||||||
[JsonRequired] public required string serverUrl { get; set; }
|
[JsonRequired] public required string serverUrl { get; set; }
|
||||||
[JsonRequired] public required string user { get; set; }
|
[JsonRequired] public required string user { get; set; }
|
||||||
[JsonRequired] public required string repo { get; set; }
|
[JsonRequired] public required string repo { get; set; }
|
||||||
|
|
||||||
|
public string GetRepoUrl() => $"{serverUrl}/{user}/{repo}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private GiteaConfig _giteaConfig;
|
|
||||||
|
|
||||||
public UpdateHelper(GiteaConfig giteaConfig)
|
public UpdateHelper(GiteaConfig giteaConfig)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -40,14 +40,17 @@ public static class PathHelper
|
|||||||
|
|
||||||
public static IOPath GetJavaBinDir(string id) =>
|
public static IOPath GetJavaBinDir(string id) =>
|
||||||
Path.Concat(GetJavaRuntimeDir(id), "bin");
|
Path.Concat(GetJavaRuntimeDir(id), "bin");
|
||||||
public static IOPath GetJavaExecutablePath(string id, bool debug)
|
public static IOPath GetJavaExecutablePath(string id, bool redirectOutput)
|
||||||
{
|
{
|
||||||
string executable_name = "java";
|
string executable_name = "java";
|
||||||
if (debug)
|
if (!redirectOutput)
|
||||||
executable_name += "w";
|
executable_name = "javaw";
|
||||||
if(OperatingSystem.IsWindows())
|
if(OperatingSystem.IsWindows())
|
||||||
executable_name += ".exe";
|
executable_name += ".exe";
|
||||||
return Path.Concat(GetJavaBinDir(id), executable_name);
|
var path = Path.Concat(GetJavaBinDir(id), executable_name);
|
||||||
|
if(!redirectOutput && !File.Exists(path))
|
||||||
|
return GetJavaExecutablePath(id, true);
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetLog4jConfigFileName() => "log4j.xml";
|
public static string GetLog4jConfigFileName() => "log4j.xml";
|
||||||
|
|||||||
14
README.md
Normal file
14
README.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Mlaumcherb - a minecraft laumcherb
|
||||||
|
|
||||||
|
<img src="./images/cheems.png" alt="silly-dog-picture" style="width:200px;"/>
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- Downloads minecraft from mojang server or any other
|
||||||
|
- Downloads java or uses whatever you specified in config
|
||||||
|
- Downloads modpacks of my custom format
|
||||||
|
- Automatic launcher updates from git releases
|
||||||
|
|
||||||
|
## How to build
|
||||||
|
```sh
|
||||||
|
./build.sh selfcontained
|
||||||
|
```
|
||||||
@ -29,19 +29,21 @@ case "$mode" in
|
|||||||
args="$args_selfcontained"
|
args="$args_selfcontained"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "ПОЛЬЗОВАНИЕ: ./собрать.sh [способ]"
|
echo "ПОЛЬЗОВАНИЕ: ./build.sh [способ]"
|
||||||
echo " СПОСОБЫ:"
|
echo " СПОСОБЫ:"
|
||||||
echo " бинарное - компилирует промежуточный (управляемый) код в машинный вместе с рантаймом"
|
echo " aot, native, бинарное - компилирует промежуточный (управляемый) код в машинный вместе с рантаймом"
|
||||||
echo " небинарное - приделывает промежуточный (управляемый) код к рантайму"
|
echo " self-contained, selfcontained, небинарное - приделывает промежуточный (управляемый) код к рантайму"
|
||||||
echo " Оба способа собирают программу в один файл, который не является 80-мегабайтовым умственно отсталым кубом. Он 20-мегабайтовый >w<"
|
echo " Оба способа собирают программу в один файл, который не является 80-мегабайтовым умственно отсталым кубом.\
|
||||||
|
Он 20-мегабайтовый >w<"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
rm -rf "$outdir"
|
rm -rf "$outdir"
|
||||||
|
# when internet breaks again add --source /mnt/c/Users/User/.nuget/packages/
|
||||||
command="dotnet publish -c Release -o $outdir $args"
|
command="dotnet publish -c Release -o $outdir $args"
|
||||||
echo "$command"
|
echo "$command"
|
||||||
$command
|
$command
|
||||||
|
|
||||||
find "$outdir" -name '*.pdb' -delete -printf "deleted '%p'\n"
|
find "$outdir" -name '*.pdb' -delete -printf "deleted '%p'\n"
|
||||||
ls -shk "$outdir" | sort -h
|
tree -sh "$outdir"
|
||||||
BIN
images/cheems.png
Normal file
BIN
images/cheems.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
@ -5,6 +5,8 @@ EndProject
|
|||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionFolder", "SolutionFolder", "{A3217C18-CC0D-4CE8-9C48-1BDEC1E1B333}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionFolder", "SolutionFolder", "{A3217C18-CC0D-4CE8-9C48-1BDEC1E1B333}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
|
README.md = README.md
|
||||||
|
build.sh = build.sh
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user