Skip to content

Commit

Permalink
Summary of Recent Changes and Updates in the Project beta2 (#37)
Browse files Browse the repository at this point in the history
1. **Update host URL in ResourceKeysDictionary**
   - The host URL used in the ResourceKeysDictionary file has been updated from a local address to a production address. Additionally, a minor formatting change was made in the OverviewPageViewModel file.

2. **Update submodule link Gml.Client**

3. **Replace submodule update with git clone in scripts**
   - The git submodule update command in both the 'load-repositories.sh' and 'load-repositories.bat' scripts has been replaced with git clone. This allows for repositories 'GamerVII.Notification.Avalonia' and 'Gml.Client' to be cloned directly instead of being updated through submodules.

4. **Update system service, resources, and application UI**
   - The system service has been updated to asynchronously load system data. Additional resource keys and corresponding translations have been added to the localization service. Several changes have been made to the application user interface including a new splash screen, application icon, and version number.

5. **Add error tracking to AsyncStreamToImageLoader**
   - The update wraps the core logic of the OnSourceChanged method inside a try-catch block. In case of any exceptions during execution, they are captured and sent to Sentry for error tracking and troubleshooting. This ensures smoother runtime and easier debugging.

6. **Update host URL and clean up code**
   - The host URL in the ResourceKeysDictionary file was changed from a local IP address to an external URL "https://gmlb.recloud.tech".

7. **Gif background functionality (#29)**
   - Introduced several new classes to handle the decoding of GIF files. This includes reading the data stream and processing headers, frames, color tables, and extensions. Functionality for rendering frames and handling exceptions has also been implemented.

8. **Refactor code and optimize exceptions in gif decoder**
   - Code for gif decoding has been refactored for improved readability and efficiency. The exception handling has been optimized for specific errors, such as LzwDecompressionException, contributing to better error reporting and debugging. Unnecessary comments and code have also been removed.

9. **Remove unnecessary whitespace in AsyncStreamToImageLoader**
   - This commit eliminates a redundant line in the AsyncStreamToImageLoader class file. The change helps to maintain the cleanliness and readability of the code.

10. **Refactor LoginPageViewModel and update AsyncStreamToImageLoader**
    - This commit refactors LoginPageViewModel to change the type of _screen from IScreen to MainWindowViewModel. This allows the app to subscribe to the 'OnClosed' event of the main window, and dispose of connections when the window is closed to prevent memory leaks. AsyncStreamToImageLoader has also been updated to clear avatar image classes upfront and enhance filename checking mechanism to prevent non-loaded images.

11. **Update background component in MainWindow**
    - Updated the background image's component in MainWindow.axaml file. Added a class attribute, which can be used for styling or Javascript manipulation in the future.

12. **Remove invalid character from document.svg**
    - The first character of the document.svg file in the Gml.Launcher/Assets/Images directory was an invalid character and is now removed. This fix ensures that the SVG file is correctly formed and interprets as expected.

13. **Add 'launcher' project and comment out language combo box**
    - Added a new 'launcher' project to the Gml.Launcher.sln file and made adjustments to project settings for consistency. Additionally, commented out the language selection combo box in the SettingsPageView.axaml as it is currently not in use.

14. **Switch host and update debugging settings**
    - Furthermore, the debugging settings in App.axaml.cs have been updated to not debug mode, and the return value in case of null 'actualVersion' has been set to true in SplashScreenViewModel.cs.

15. **Optimize system data loading process**
    - The previous implementation executed the tasks for refreshing the drive, motherboard, and CPU lists sequentially. This was unnecessarily time-consuming. With the new implementation, these tasks are run concurrently using Task.WhenAll method for better performance and efficiency.

16. **Change execution context for MainWindow in debug mode**
    - This update modifies the execution context for MainWindow in the Gml.Launcher App. Previously, it was running in non-debug mode. Now, it is set up to run in debug mode.

17. **Disable window resizing and update pointer events handling**
    - A new property `CanResize=False` has been added to the MainWindow.axaml to prevent the window from being resized. The pointer events handling logic was moved from OverviewPageView to MainWindow. This was done to ensure better control over dragging behavior and to prevent inappropriate actions during specific interactions.

18. **Update settings validation for window size**
    - Improved the validation and error-handling approach for setting window size parameters. Now, the windowWidth and windowHeight values are only updated when numeric values are provided. If non-numeric values are input, they will be reset to default.

19. **Remove commented out code in MainWindow.axaml.cs**

20. **Added default font**

21. **Update font styles and host URL**
    - This commit updates the font styles across several components, improving text readability and consistency. It also switches the host URL in the ResourceKeysDictionary to a production-ready address.

22. **Add new game session management and enhance game profile features**
    - Enhanced game profile features by adding support for system types, file and profile session handling functionalities. Changes in the IGameProfile interface allow for game sessions to be locally stored and accessed. Introduced ProfileState type in the ProfileState enum. Also updated functionality to include OS specifics in process creation. This update increases compatibility across different systems and aids in clearer session management.

23. **Refactor code for skin rendering and noise string conversion**
    - Specifically, the update handles question mark in the value for noise string conversion and it also removes unnecessary spaces in ProfilePageView.axaml. Moreover, unnecessary comments in ProfilePageViewModel.cs are cleaned up and HTTP header in skin rendering is updated to include User-Agent information.

24. **Update ProfileUserControl design**
    - Changed the default skin URL to a new one, adjusted image and text alignment, and increased opacity of the profile gradient.

25. **Refactor client module for improved readability**
    - Refactored the Gml.Client module to enhance code readability and maintainability. This involved restructuring functions, renaming variables for clarity, and adding comments where necessary. No functional changes were made to ensure existing behavior is preserved.

26. **Add architecture check in splash screen initialization**
    - Updated SplashScreenViewModel to include the process architecture in version checks. This helps ensure the correct software version is retrieved based on both OS type and architecture.

27. **Update settings handling in OverviewPageViewModel**
    - Change default settings handling in `OverviewPageViewModel` to use `SettingsInfo.Default` when no settings are found. Add screen dimensions and full-screen settings to profile creation details.

28. **Enhance process restart commands for Linux and Windows**
    - Updated the process restart commands to properly handle filenames with spaces or special characters on both Linux and Windows. For Linux, enclosed filenames within single quotes and adjusted the process start command. For Windows, added double quotes around filenames to ensure proper execution.

29. **Refactor method names and update host URL**
    - Renamed the method `PrepareLaunch` to `GetProfileInfo` for better clarity. Also, switched the host URL to the production endpoint in the ResourceKeysDictionary file. Commented out sample profile info in ProfileInfoComponent for a cleaner initialization.

30. **Update client processing logic.**
    - Refactor the existing client-side logic to improve performance and readability. Adjust function naming and streamline data handling to reduce complexity.

31. **Add online player component and Java not found error handler**
    - Introduced a new UI component to display online server player counts and added corresponding localization entries. Also, included error handling for missing Java installations, displaying appropriate localized messages.

32. **Switch ProfileUserControl to ItemsControl and add Spacing**
    - Updated ProfileUserControl from TemplatedControl to ItemsControl to support dynamic item presentations. Introduced a new Spacing property to allow custom spacing between items. Additionally, moved ProfileInfoComponent and GmlButton from the UserControl template to the ProfilePageView for better separation of concerns.

33. **Add URL redirect attached property**
    - Introduce `UrlRedirectProperty` to handle URL redirections in controls. This property changes start a process to open the URL with the default system browser, enhancing the app's interactivity.

34. **Add additional button and group ProfilePageView buttons**
    - Reorganized the buttons on the ProfilePageView into a horizontal stack panel, adding a new Icon Additional button alongside the existing TextIcon Primary button. Both buttons execute the OpenLinkCommand with the same URL but have distinct visual styles.
  • Loading branch information
GamerVII-NET authored Jul 13, 2024
1 parent 270ff84 commit 83a7b8e
Show file tree
Hide file tree
Showing 21 changed files with 277 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/Gml.Client
1 change: 1 addition & 0 deletions src/Gml.Launcher/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<StyleInclude Source="/Views/Components/ProfileUserControl.axaml" />
<StyleInclude Source="/Views/Components/ProfileInfoComponent.axaml" />
<StyleInclude Source="/Views/Components/ProgressBar.axaml" />
<StyleInclude Source="/Views/Components/OnlineComponent.axaml" />

<StyleInclude Source="Assets/Styles/Classes.axaml"/>

Expand Down
8 changes: 8 additions & 0 deletions src/Gml.Launcher/Assets/Images/users.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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 Host = "{{HOST}}";
public const string FolderName = "{{FOLDER_NAME}}";
}
5 changes: 3 additions & 2 deletions src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public static class ResourceKeysDictionary
public const string CheckUpdates = "CheckUpdates";
public const string InstallingUpdates = "InstallingUpdates";
public const string FailedOs = "FailedOs";
public const string Host = "http://192.168.31.199:5000";
// public const string Host = "https://gmlb.recloud.tech";
public const string JavaNotFound = "JavaNotFound";
// public const string Host = "http://192.168.31.199:5000";
public const string Host = "https://gmlb.recloud.tech";
// public const string Host = "https://gmlb-test.recloud.tech";
public const string FolderName = "GamerVIILacunerhV2";
}
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.

9 changes: 9 additions & 0 deletions src/Gml.Launcher/Assets/Resources/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,13 @@
<data name="FailedOs" xml:space="preserve">
<value>Failed to determine the operating system</value>
</data>
<data name="OnServers" xml:space="preserve">
<value>On servers</value>
</data>
<data name="PlayersShort" xml:space="preserve">
<value>pl.</value>
</data>
<data name="JavaNotFound" xml:space="preserve">
<value>Unable to detect a loaded Java for your operating system, please contact support or the project administrator.</value>
</data>
</root>
9 changes: 9 additions & 0 deletions src/Gml.Launcher/Assets/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,13 @@
<data name="FailedOs" xml:space="preserve">
<value>Failed to determine the operating system</value>
</data>
<data name="OnServers" xml:space="preserve">
<value>On servers</value>
</data>
<data name="PlayersShort" xml:space="preserve">
<value>pl.</value>
</data>
<data name="JavaNotFound" xml:space="preserve">
<value>Unable to detect a loaded Java for your operating system, please contact support or the project administrator.</value>
</data>
</root>
9 changes: 9 additions & 0 deletions src/Gml.Launcher/Assets/Resources/Resources.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,13 @@
<data name="FailedOs" xml:space="preserve">
<value>Не удалось определить операционную систему</value>
</data>
<data name="OnServers" xml:space="preserve">
<value>На серверах</value>
</data>
<data name="PlayersShort" xml:space="preserve">
<value>чел.</value>
</data>
<data name="JavaNotFound" xml:space="preserve">
<value>Не удалось обнаружить загруженную Java для Вашей операционной системы, обратитесь в поддержку или к администратору проекта</value>
</data>
</root>
32 changes: 32 additions & 0 deletions src/Gml.Launcher/Core/Converters/SumServersOnlineConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Avalonia.Data.Converters;
using Avalonia.Markup.Xaml;
using Gml.Web.Api.Dto.Servers;

namespace Gml.Launcher.Core.Converters;

public class SumServersOnlineConverter : MarkupExtension, IValueConverter
{
public override object ProvideValue(IServiceProvider serviceProvider) => this;

public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is List<ServerReadDto> server)
{
return server
.Where(c => c.IsOnline)
.Sum(c => c.Online)?
.ToString() ?? "0";
}

return "0";
}

public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return "0";
}
}
30 changes: 30 additions & 0 deletions src/Gml.Launcher/Core/Converters/UrlRedirectProperty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Diagnostics;
using Avalonia;
using Avalonia.Controls;

namespace Gml.Launcher.Core.Converters;

public class UrlRedirectProperty
{
public static readonly AttachedProperty<string> RedirectUrlProperty =
AvaloniaProperty.RegisterAttached<UrlRedirectProperty, Control, string>("RedirectUrl");

public static void SetRedirectUrl(Control obj, string value) => obj.SetValue(RedirectUrlProperty, value);
public static string GetRedirectUrl(Control obj) => obj.GetValue(RedirectUrlProperty);

public UrlRedirectProperty()
{
RedirectUrlProperty.Changed.AddClassHandler<Control>(OnSourceChanged);
}

private void OnSourceChanged(Control control, AvaloniaPropertyChangedEventArgs args)
{
var url = args.GetNewValue<string>();

Process.Start(new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
});
}
}
2 changes: 2 additions & 0 deletions src/Gml.Launcher/Models/SettingsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

public record SettingsInfo(int GameWidth, int GameHeight, bool FullScreen, bool IsDynamicRam, double RamValue, string? LanguageCode)
{
public static SettingsInfo Default
=> new SettingsInfo(900, 600, false, true, 0, "ru-RU");
}
24 changes: 14 additions & 10 deletions src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reactive.Concurrency;
Expand Down Expand Up @@ -130,7 +131,7 @@ await ExecuteFromNewThread(async () =>
{
try
{
var profileInfo = await PrepareLaunch();
var profileInfo = await GetProfileInfo();

if (profileInfo is { Data: not null })
{
Expand All @@ -147,6 +148,12 @@ await ExecuteFromNewThread(async () =>
ShowError(ResourceKeysDictionary.Error, ResourceKeysDictionary.ProfileNotConfigured);
}
}
catch (FileNotFoundException exception)
{
ShowError(ResourceKeysDictionary.Error, LocalizationService.GetString(ResourceKeysDictionary.JavaNotFound));

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

private async Task<ResponseMessage<ProfileReadInfoDto?>?> PrepareLaunch()
private async Task<ResponseMessage<ProfileReadInfoDto?>?> GetProfileInfo()
{
UpdateProgress(
LocalizationService.GetString(ResourceKeysDictionary.Updating),
Expand All @@ -200,23 +207,20 @@ private async Task<Process> GenerateProcess(CancellationToken cancellationToken,

await _gmlManager.UpdateDiscordRpcState($"{LocalizationService.GetString(ResourceKeysDictionary.PlayDRpcText)} \"{ListViewModel.SelectedProfile!.Name}\"");

var settings = await _storageService.GetAsync<SettingsInfo>(StorageConstants.Settings);

if (settings is null)
{
throw new Exception(LocalizationService.GetString(ResourceKeysDictionary.NotSetting));
}
var settings = await _storageService.GetAsync<SettingsInfo>(StorageConstants.Settings) ?? SettingsInfo.Default;

var localProfile = new ProfileCreateInfoDto
{
ProfileName = ListViewModel.SelectedProfile!.Name,
RamSize = Convert.ToInt32(settings.RamValue),
IsFullScreen = false,
IsFullScreen = settings.FullScreen,
OsType = ((int)_systemService.GetOsType()).ToString(),
OsArchitecture = Environment.Is64BitOperatingSystem ? "64" : "32",
UserAccessToken = User.AccessToken,
UserName = User.Name,
UserUuid = User.Uuid
UserUuid = User.Uuid,
WindowWidth = settings.GameWidth,
WindowHeight = settings.GameHeight
};

var profileInfo = await _gmlManager.GetProfileInfo(localProfile);
Expand Down
9 changes: 6 additions & 3 deletions src/Gml.Launcher/ViewModels/SplashScreenViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Avalonia.Controls.Shapes;
using Gml.Client;
Expand Down Expand Up @@ -46,11 +47,12 @@ public SplashScreenViewModel(ISystemService? systemService = null, IGmlClientMan
public async Task InitializeAsync()
{
var osType = _systemService.GetOsType();
var osArch = RuntimeInformation.ProcessArchitecture;

await _systemService.LoadSystemData();
ChangeState(_localizationService.GetString(ResourceKeysDictionary.CheckUpdates), true);

var versionInfo = await CheckActualVersion(osType);
var versionInfo = await CheckActualVersion(osType, osArch);

if (!versionInfo.IsActuallVersion)
{
Expand All @@ -68,9 +70,10 @@ public async Task InitializeAsync()
}
}

private async Task<(IVersionFile? ActualVersion, bool IsActuallVersion)> CheckActualVersion(OsType osType)
private async Task<(IVersionFile? ActualVersion, bool IsActuallVersion)> CheckActualVersion(OsType osType,
Architecture osArch)
{
var actualVersion = await _manager.GetActualVersion(osType);
var actualVersion = await _manager.GetActualVersion(osType, osArch);

if (actualVersion is null)
{
Expand Down
64 changes: 64 additions & 0 deletions src/Gml.Launcher/Views/Components/OnlineComponent.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Gml.Launcher.Views.Components"
xmlns:lang="clr-namespace:Gml.Launcher.Assets.Resources">
<Design.PreviewWith>
<Grid Width="350" Height="100">
<controls:BackgroundComponent Classes="Image" Source="/Assets/Images/background.jpg" />
<Rectangle Fill="{DynamicResource BackgroundOverlay}" />

<Border Padding="20">
<controls:OnlineComponent />
</Border>
</Grid>
</Design.PreviewWith>

<Style Selector="controls|OnlineComponent">

<Setter Property="Background" Value="{DynamicResource FrameBackgroundColor}" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="VerticalAlignment" Value="Top" />

<Setter Property="Template">
<ControlTemplate>
<!-- Component Border -->
<Border Background="{TemplateBinding Background}"
Padding="10, 8, 15, 8"
CornerRadius="12"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
HorizontalAlignment="Left">
<Grid ColumnDefinitions="Auto, 10, Auto">

<!-- Icon -->
<Border Background="{DynamicResource PrimaryColor}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Padding="12"
CornerRadius="{TemplateBinding CornerRadius}">
<Svg Path="/Assets/Images/users.svg" Width="18" />
</Border>

<!-- Content -->
<StackPanel Grid.Column="2">
<TextBlock Text="{x:Static lang:Resources.OnServers}"
Foreground="{DynamicResource ContentColor}"
FontSize="14"
FontWeight="Medium" />
<TextBlock>
<Run Text="{TemplateBinding Online}"
Foreground="{DynamicResource HeadlineColor}"
FontSize="20"
FontWeight="Bold" />
<Run Text="{x:Static lang:Resources.PlayersShort}"
Foreground="{DynamicResource ContentColor}"
FontSize="14"
FontWeight="Medium" />
</TextBlock>
</StackPanel>

</Grid>
</Border>
</ControlTemplate>
</Setter>
</Style>
</Styles>
18 changes: 18 additions & 0 deletions src/Gml.Launcher/Views/Components/OnlineComponent.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;

namespace Gml.Launcher.Views.Components;

public class OnlineComponent : TemplatedControl
{
public static readonly StyledProperty<string> OnlineProperty = AvaloniaProperty.Register<OnlineComponent, string>(
"Online", "0");

public string Online
{
get => GetValue(OnlineProperty);
set => SetValue(OnlineProperty, value);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class ProfileInfoComponent : TemplatedControl
AvaloniaProperty.Register<ProfileUserControl, IEnumerable<ProfileInfoItem>>(
nameof(ProfileInfoItems), new List<ProfileInfoItem>
{
new("На проекте", "150 дней"),
new("Наиграно", " 551 час 45 мин"),
new("Баланс", "150 руб."),
new("Группа", "Premium"),
// new("На проекте", "150 дней"),
// new("Наиграно", " 551 час 45 мин"),
// new("Баланс", "150 руб."),
// new("Группа", "Premium"),
});


Expand Down
9 changes: 1 addition & 8 deletions src/Gml.Launcher/Views/Components/ProfileUserControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@
FontWeight="ExtraBlack" />
</Grid>
<StackPanel Grid.Row="1" Margin="30">

<controls:ProfileInfoComponent />

<controls:GmlButton Classes="TextIcon Primary"
Margin="0, 15, 0, 0"
Padding="15, 10, 10, 10"
Text="{x:Static lang:Resources.Cabinet}"
HorizontalAlignment="Center" />
<ItemsPresenter/>
</StackPanel>
</Grid>

Expand Down
Loading

0 comments on commit 83a7b8e

Please sign in to comment.