Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to v0.1.0-beta4 #47

Merged
merged 5 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Gml.Client
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static class ResourceKeysDictionary
public const string InstallingUpdates = "InstallingUpdates";
public const string FailedOs = "FailedOs";
public const string JavaNotFound = "JavaNotFound";
public const string IsDiskFull = "IsDiskFull";
public const string Host = "{{HOST}}";
public const string FolderName = "{{FOLDER_NAME}}";
}
4 changes: 2 additions & 2 deletions src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public static class ResourceKeysDictionary
public const string MainPageTitle = "DefaultPageTitle";
public const string DefaultPageTitle = "DefaultPageTitle";
public const string Error = "Error";
public const string GameProfileError = "GameProfileError";
public const string InvalidFolder = "InvalidFolder";
public const string NotSetting = "NotSetting";
public const string Updating = "Updating";
Expand All @@ -23,9 +24,8 @@ public static class ResourceKeysDictionary
public const string CheckUpdates = "CheckUpdates";
public const string InstallingUpdates = "InstallingUpdates";
public const string FailedOs = "FailedOs";

public const string JavaNotFound = "JavaNotFound";

public const string IsDiskFull = "IsDiskFull";
// public const string Host = "https://gmlb.recloud.tech";
public const string Host = "https://gmlb-test.recloud.tech";
public const string FolderName = "GamerVIILacunerhV2";
Expand Down
16 changes: 16 additions & 0 deletions src/Gml.Launcher/Assets/Resources/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Gml.Launcher/Assets/Resources/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,10 @@
<data name="InvalidFolder" xml:space="preserve">
<value>Failed to change the installation folder or an error occurred while changing the folder.</value>
</data>
<data name="IsDiskFull" xml:space="preserve">
<value>Not enough disk space</value>
</data>
<data name="GameProfileError" xml:space="preserve">
<value>Error initializing the game profile.</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/Gml.Launcher/Assets/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,10 @@
<data name="InvalidFolder" xml:space="preserve">
<value>Failed to change the installation folder or an error occurred while changing the folder.</value>
</data>
<data name="IsDiskFull" xml:space="preserve">
<value>Not enough disk space</value>
</data>
<data name="GameProfileError" xml:space="preserve">
<value>Error initializing the game profile.</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/Gml.Launcher/Assets/Resources/Resources.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,10 @@
<data name="InvalidFolder" xml:space="preserve">
<value>Не получилось сменить папку установки или произошла ошибка при смене папки</value>
</data>
<data name="IsDiskFull" xml:space="preserve">
<value>Недостаточно места на диске</value>
</data>
<data name="GameProfileError" xml:space="preserve">
<value>Ошибка инициализации игрового профиля.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/Gml.Launcher/Core/Services/ISystemService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Gml.Launcher.Models;
using Gml.Web.Api.Domains.System;
Expand Down Expand Up @@ -52,4 +53,6 @@ public interface ISystemService
/// </summary>
/// <returns>A task representing the asynchronous operation.</returns>
Task LoadSystemData();

bool IsDiskFull(IOException ioException);
}
8 changes: 8 additions & 0 deletions src/Gml.Launcher/Core/Services/SystemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Gml.Launcher.Models;
using Gml.Web.Api.Domains.System;
Expand All @@ -15,6 +16,7 @@ public class SystemService : ISystemService
{
private const string NotSupportedMessage = "The operating system is not supported.";
private readonly HardwareInfo _hardwareInfo = new();
const int ERROR_DISK_FULL = 0x70;

public ulong GetMaxRam()
{
Expand Down Expand Up @@ -63,6 +65,12 @@ public async Task LoadSystemData()
await Task.WhenAll(refreshDriveListTask, refreshMotherboardListTask, refreshCpuListTask);
}

public bool IsDiskFull(IOException ioException)
{
int hr = Marshal.GetHRForException(ioException);
return (hr & 0xFFFF) == ERROR_DISK_FULL;
}

public OsType GetOsType()
{
if (IsWindows()) return OsType.Windows;
Expand Down
34 changes: 33 additions & 1 deletion src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ await ExecuteFromNewThread(async () =>
_gameProcess?.Close();
_gameProcess = await GenerateProcess(cancellationToken, profileInfo);
_gameProcess.Start();
_gameProcess.BeginOutputReadLine();
_gameProcess.BeginErrorReadLine();

await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
Dispatcher.UIThread.Invoke(() => _mainViewModel._gameLaunched.OnNext(true));
UpdateProgress(string.Empty, string.Empty, false);
Expand All @@ -178,6 +181,13 @@ await ExecuteFromNewThread(async () =>

Console.WriteLine(exception);
}
catch (IOException ioException) when (_systemService.IsDiskFull(ioException))
{
ShowError(ResourceKeysDictionary.Error,
LocalizationService.GetString(ResourceKeysDictionary.IsDiskFull));

Console.WriteLine(ioException);
}
catch (Exception exception)
{
ShowError(ResourceKeysDictionary.Error, string.Join(". ", exception.Message));
Expand Down Expand Up @@ -207,7 +217,29 @@ private async Task<Process> GenerateProcess(CancellationToken cancellationToken,

await _gmlManager.DownloadNotInstalledFiles(profileInfo.Data, cancellationToken);

var process = await _gmlManager.GetProcess(profileInfo.Data, _systemService.GetOsType());
Process process = await _gmlManager.GetProcess(profileInfo.Data, _systemService.GetOsType());

process.OutputDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
Console.WriteLine(e.Data);

// ToDo: Add sentry java logging
// if (e.Data.Contains("log4j:Throwable"))
// {
//
// }
}
};

process.ErrorDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data) && !e.Data.Contains("[gml-patch]"))
{
ShowError(ResourceKeysDictionary.GameProfileError, e.Data);
}
};

await _gmlManager.ClearFiles(profileInfo.Data);

Expand Down
6 changes: 1 addition & 5 deletions src/Gml.Launcher/Views/Components/GmlButton.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
base.OnApplyTemplate(e);

if (this.GetTemplateChildren().First() is Button button)
button.Click += (sender, args) =>
{
RaiseEvent(new RoutedEventArgs(ClickEvent));
Command?.Execute(CommandParameter);
};
button.Click += (_, _) => RaiseEvent(new RoutedEventArgs(ClickEvent));;
}
}
Loading