From 2c7c7080e3d590ce13e72c83822e2ac7754a24be Mon Sep 17 00:00:00 2001
From: GamerVII-NET <111225722+GamerVII-NET@users.noreply.github.com>
Date: Wed, 7 Aug 2024 08:36:00 +0300
Subject: [PATCH 1/5] #46 Remove redundant command execution in GmlButton
The `Command.Execute` call within the button click event handler was redundant since the command is already executed elsewhere. This change improves code readability and prevents potential double execution of the command.
---
src/Gml.Launcher/Views/Components/GmlButton.axaml.cs | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/Gml.Launcher/Views/Components/GmlButton.axaml.cs b/src/Gml.Launcher/Views/Components/GmlButton.axaml.cs
index a7d267a..700eae4 100644
--- a/src/Gml.Launcher/Views/Components/GmlButton.axaml.cs
+++ b/src/Gml.Launcher/Views/Components/GmlButton.axaml.cs
@@ -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));;
}
}
From 8e3748163e8e439517c91d62ed797c54dc4aad50 Mon Sep 17 00:00:00 2001
From: GamerVII-NET <111225722+GamerVII-NET@users.noreply.github.com>
Date: Wed, 7 Aug 2024 11:02:37 +0300
Subject: [PATCH 2/5] Handle disk full errors with new localized messages.
Added a new IsDiskFull resource string in multiple languages to display an error message when the disk is full. Updated the SystemService and OverviewPageViewModel to catch IOException and check for disk full errors using the new IsDiskFull method in SystemService.
---
.../Assets/Resources/ResourceKeysDictionary.Template.cs | 1 +
.../Assets/Resources/ResourceKeysDictionary.cs | 3 +--
src/Gml.Launcher/Assets/Resources/Resources.Designer.cs | 8 ++++++++
src/Gml.Launcher/Assets/Resources/Resources.en.resx | 3 +++
src/Gml.Launcher/Assets/Resources/Resources.resx | 3 +++
src/Gml.Launcher/Assets/Resources/Resources.ru.resx | 3 +++
src/Gml.Launcher/Core/Services/ISystemService.cs | 3 +++
src/Gml.Launcher/Core/Services/SystemService.cs | 8 ++++++++
.../ViewModels/Pages/OverviewPageViewModel.cs | 7 +++++++
9 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.Template.cs b/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.Template.cs
index 35085dc..2d15214 100644
--- a/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.Template.cs
+++ b/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.Template.cs
@@ -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}}";
}
diff --git a/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs b/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs
index e10bcee..813e8a2 100644
--- a/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs
+++ b/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs
@@ -23,9 +23,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";
diff --git a/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs b/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs
index 649e671..4c757e8 100644
--- a/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs
+++ b/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs
@@ -258,5 +258,13 @@ public static string InvalidFolder {
return ResourceManager.GetString("InvalidFolder", resourceCulture);
}
}
+ ///
+ /// Ищет локализованную строку, похожую на ProfileNotConfigured.
+ ///
+ public static string IsDiskFull {
+ get {
+ return ResourceManager.GetString("IsDiskFull", resourceCulture);
+ }
+ }
}
}
diff --git a/src/Gml.Launcher/Assets/Resources/Resources.en.resx b/src/Gml.Launcher/Assets/Resources/Resources.en.resx
index 3441c25..aa1771b 100644
--- a/src/Gml.Launcher/Assets/Resources/Resources.en.resx
+++ b/src/Gml.Launcher/Assets/Resources/Resources.en.resx
@@ -135,4 +135,7 @@
Failed to change the installation folder or an error occurred while changing the folder.
+
+ Not enough disk space
+
diff --git a/src/Gml.Launcher/Assets/Resources/Resources.resx b/src/Gml.Launcher/Assets/Resources/Resources.resx
index 32ad5b3..0fdd2b3 100644
--- a/src/Gml.Launcher/Assets/Resources/Resources.resx
+++ b/src/Gml.Launcher/Assets/Resources/Resources.resx
@@ -143,4 +143,7 @@
Failed to change the installation folder or an error occurred while changing the folder.
+
+ Not enough disk space
+
diff --git a/src/Gml.Launcher/Assets/Resources/Resources.ru.resx b/src/Gml.Launcher/Assets/Resources/Resources.ru.resx
index b1a4814..f12a6b3 100644
--- a/src/Gml.Launcher/Assets/Resources/Resources.ru.resx
+++ b/src/Gml.Launcher/Assets/Resources/Resources.ru.resx
@@ -135,4 +135,7 @@
Не получилось сменить папку установки или произошла ошибка при смене папки
+
+ Недостаточно места на диске
+
diff --git a/src/Gml.Launcher/Core/Services/ISystemService.cs b/src/Gml.Launcher/Core/Services/ISystemService.cs
index 3f15683..445fd4d 100644
--- a/src/Gml.Launcher/Core/Services/ISystemService.cs
+++ b/src/Gml.Launcher/Core/Services/ISystemService.cs
@@ -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;
@@ -52,4 +53,6 @@ public interface ISystemService
///
/// A task representing the asynchronous operation.
Task LoadSystemData();
+
+ bool IsDiskFull(IOException ioException);
}
diff --git a/src/Gml.Launcher/Core/Services/SystemService.cs b/src/Gml.Launcher/Core/Services/SystemService.cs
index 00e96d9..b55c811 100644
--- a/src/Gml.Launcher/Core/Services/SystemService.cs
+++ b/src/Gml.Launcher/Core/Services/SystemService.cs
@@ -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;
@@ -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()
{
@@ -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;
diff --git a/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs b/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
index 007ea90..84bd365 100644
--- a/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
+++ b/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
@@ -178,6 +178,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));
From 1a6a890ed0d55e7b64f1b58b30784eb8a407b35f Mon Sep 17 00:00:00 2001
From: GamerVII-NET <111225722+GamerVII-NET@users.noreply.github.com>
Date: Wed, 7 Aug 2024 11:53:06 +0300
Subject: [PATCH 3/5] Add error handling for game profile initialization
Introduce a new error message "GameProfileError" in resource files. Implement logic to capture and display this error when initializing game profiles, ensuring errors are properly logged and displayed to the user.
---
.../Resources/ResourceKeysDictionary.cs | 1 +
.../Assets/Resources/Resources.Designer.cs | 8 +++++++
.../Assets/Resources/Resources.en.resx | 3 +++
.../Assets/Resources/Resources.resx | 3 +++
.../Assets/Resources/Resources.ru.resx | 3 +++
.../ViewModels/Pages/OverviewPageViewModel.cs | 21 ++++++++++++++++++-
6 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs b/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs
index 813e8a2..b641583 100644
--- a/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs
+++ b/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs
@@ -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";
diff --git a/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs b/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs
index 4c757e8..916933e 100644
--- a/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs
+++ b/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs
@@ -266,5 +266,13 @@ public static string IsDiskFull {
return ResourceManager.GetString("IsDiskFull", resourceCulture);
}
}
+ ///
+ /// Ищет локализованную строку, похожую на ProfileNotConfigured.
+ ///
+ public static string GameProfileError {
+ get {
+ return ResourceManager.GetString("GameProfileError", resourceCulture);
+ }
+ }
}
}
diff --git a/src/Gml.Launcher/Assets/Resources/Resources.en.resx b/src/Gml.Launcher/Assets/Resources/Resources.en.resx
index aa1771b..ba38ddd 100644
--- a/src/Gml.Launcher/Assets/Resources/Resources.en.resx
+++ b/src/Gml.Launcher/Assets/Resources/Resources.en.resx
@@ -138,4 +138,7 @@
Not enough disk space
+
+ Error initializing the game profile.
+
diff --git a/src/Gml.Launcher/Assets/Resources/Resources.resx b/src/Gml.Launcher/Assets/Resources/Resources.resx
index 0fdd2b3..52adde4 100644
--- a/src/Gml.Launcher/Assets/Resources/Resources.resx
+++ b/src/Gml.Launcher/Assets/Resources/Resources.resx
@@ -146,4 +146,7 @@
Not enough disk space
+
+ Error initializing the game profile.
+
diff --git a/src/Gml.Launcher/Assets/Resources/Resources.ru.resx b/src/Gml.Launcher/Assets/Resources/Resources.ru.resx
index f12a6b3..0be8cae 100644
--- a/src/Gml.Launcher/Assets/Resources/Resources.ru.resx
+++ b/src/Gml.Launcher/Assets/Resources/Resources.ru.resx
@@ -138,4 +138,7 @@
Недостаточно места на диске
+
+ Ошибка инициализации игрового профиля.
+
diff --git a/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs b/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
index 84bd365..7e1e8c0 100644
--- a/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
+++ b/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
@@ -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);
@@ -214,7 +217,23 @@ private async Task 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);
+ }
+ };
+
+ process.ErrorDataReceived += (sender, e) =>
+ {
+ if (!string.IsNullOrEmpty(e.Data) && !e.Data.Contains("[gml-patch]"))
+ {
+ ShowError(ResourceKeysDictionary.GameProfileError, e.Data);
+ }
+ };
await _gmlManager.ClearFiles(profileInfo.Data);
From 21cea5a7f0a062ca5d986736b76366e221b6424f Mon Sep 17 00:00:00 2001
From: GamerVII-NET <111225722+GamerVII-NET@users.noreply.github.com>
Date: Wed, 7 Aug 2024 12:06:00 +0300
Subject: [PATCH 4/5] Add placeholder for Sentry Java logging
Commented-out code added as a placeholder for future Sentry logging implementation. This will facilitate capturing Java log4j-related exceptions once the actual logging code is integrated.
---
src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs b/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
index 7e1e8c0..ffb8221 100644
--- a/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
+++ b/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
@@ -224,6 +224,12 @@ private async Task GenerateProcess(CancellationToken cancellationToken,
if (!string.IsNullOrEmpty(e.Data))
{
Console.WriteLine(e.Data);
+
+ // ToDo: Add sentry java logging
+ // if (e.Data.Contains("log4j:Throwable"))
+ // {
+ //
+ // }
}
};
From 57981898f9a5b962240a30a8835553dae1b7252d Mon Sep 17 00:00:00 2001
From: GamerVII-NET <111225722+GamerVII-NET@users.noreply.github.com>
Date: Sun, 11 Aug 2024 09:45:29 +0300
Subject: [PATCH 5/5] Update submodule link Gml.Client
---
src/Gml.Client | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Gml.Client b/src/Gml.Client
index 0d334ab..9fa59a1 160000
--- a/src/Gml.Client
+++ b/src/Gml.Client
@@ -1 +1 @@
-Subproject commit 0d334abe23f13b2fe361a7444d5df6e9924eb6e8
+Subproject commit 9fa59a165af6e33ca04193ea990e40c86c2e584e