fixed some bugs, added ability to work without internet
This commit is contained in:
parent
ab1aefd619
commit
e915892fa2
@ -38,7 +38,7 @@ public class GameVersion
|
|||||||
_descriptor.javaVersion.component, LauncherApp.Config.redirect_game_output);
|
_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}");
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ 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));
|
||||||
@ -57,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);
|
||||||
|
|||||||
@ -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.*" />
|
||||||
@ -36,8 +35,4 @@
|
|||||||
<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.холопы;
|
||||||
|
|
||||||
@ -21,7 +20,9 @@ public class LauncherApp : Application
|
|||||||
Logger.DebugLogEnabled = Config.debug;
|
Logger.DebugLogEnabled = Config.debug;
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
|
||||||
Update();
|
try
|
||||||
|
{
|
||||||
|
SelfUpdateAsync();
|
||||||
|
|
||||||
// some file required by forge installer
|
// some file required by forge installer
|
||||||
if (!File.Exists("launcher_profiles.json"))
|
if (!File.Exists("launcher_profiles.json"))
|
||||||
@ -31,8 +32,13 @@ public class LauncherApp : Application
|
|||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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();
|
||||||
@ -120,10 +134,17 @@ public partial class MainWindow : Window
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void RescanInstalledVersionsButton_OnClick(object? sender, RoutedEventArgs e)
|
private void RescanInstalledVersionsButton_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var selectedVersionView = InstalledVersionCatalogComboBox.SelectedItem as InstalledGameVersionItemView;
|
var selectedVersionView = InstalledVersionCatalogComboBox.SelectedItem as InstalledGameVersionItemView;
|
||||||
UpdateInstalledVersionsCatalogView(selectedVersionView?.Props.Id);
|
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,13 +168,12 @@ 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);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
await v.Download(UpdateGameFiles, nt =>
|
await v.Download(UpdateGameFiles, nt =>
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
@ -163,6 +183,12 @@ public partial class MainWindow : Window
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ErrorHelper.ShowMessageBox(nameof(MainWindow), ex);
|
||||||
|
}
|
||||||
|
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
UpdateGameFiles = false;
|
UpdateGameFiles = false;
|
||||||
@ -183,7 +209,6 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
string workingDir = Directory.GetCurrent().ToString();
|
string workingDir = Directory.GetCurrent().ToString();
|
||||||
LauncherApp.Logger.LogDebug(nameof(MainWindow),
|
LauncherApp.Logger.LogDebug(nameof(MainWindow),
|
||||||
$"opening working directory: {workingDir}");
|
$"opening working directory: {workingDir}");
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
1
build.sh
1
build.sh
@ -40,6 +40,7 @@ case "$mode" in
|
|||||||
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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user