diff --git a/src/Gml.Client b/src/Gml.Client index a7a7825..70ab8a3 160000 --- a/src/Gml.Client +++ b/src/Gml.Client @@ -1 +1 @@ -Subproject commit a7a782593813b360c0277192a3474f3582c565bc +Subproject commit 70ab8a3bd71c0214416e05d596bb529989eeb567 diff --git a/src/Gml.Launcher/App.axaml b/src/Gml.Launcher/App.axaml index 2bd69a7..863037e 100644 --- a/src/Gml.Launcher/App.axaml +++ b/src/Gml.Launcher/App.axaml @@ -30,6 +30,7 @@ + diff --git a/src/Gml.Launcher/Assets/Images/users.svg b/src/Gml.Launcher/Assets/Images/users.svg new file mode 100644 index 0000000..b8970a1 --- /dev/null +++ b/src/Gml.Launcher/Assets/Images/users.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.Template.cs b/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.Template.cs index 63545cc..6295512 100644 --- a/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.Template.cs +++ b/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.Template.cs @@ -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}}"; } diff --git a/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs b/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs index 578b9a4..9b77891 100644 --- a/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs +++ b/src/Gml.Launcher/Assets/Resources/ResourceKeysDictionary.cs @@ -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"; } diff --git a/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs b/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs index 6107b98..ef35d1a 100644 --- a/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs +++ b/src/Gml.Launcher/Assets/Resources/Resources.Designer.cs @@ -202,5 +202,21 @@ public static string Available { return ResourceManager.GetString("Available", resourceCulture); } } + /// + /// Ищет локализованную строку, похожую на ProfileNotConfigured. + /// + public static string OnServers { + get { + return ResourceManager.GetString("OnServers", resourceCulture); + } + } + /// + /// Ищет локализованную строку, похожую на ProfileNotConfigured. + /// + public static string PlayersShort { + get { + return ResourceManager.GetString("PlayersShort", resourceCulture); + } + } } } diff --git a/src/Gml.Launcher/Assets/Resources/Resources.en.resx b/src/Gml.Launcher/Assets/Resources/Resources.en.resx index 9b54437..e4546a5 100644 --- a/src/Gml.Launcher/Assets/Resources/Resources.en.resx +++ b/src/Gml.Launcher/Assets/Resources/Resources.en.resx @@ -107,4 +107,13 @@ Failed to determine the operating system + + On servers + + + pl. + + + Unable to detect a loaded Java for your operating system, please contact support or the project administrator. + diff --git a/src/Gml.Launcher/Assets/Resources/Resources.resx b/src/Gml.Launcher/Assets/Resources/Resources.resx index b3e1692..a69dbe2 100644 --- a/src/Gml.Launcher/Assets/Resources/Resources.resx +++ b/src/Gml.Launcher/Assets/Resources/Resources.resx @@ -114,4 +114,13 @@ Failed to determine the operating system + + On servers + + + pl. + + + Unable to detect a loaded Java for your operating system, please contact support or the project administrator. + diff --git a/src/Gml.Launcher/Assets/Resources/Resources.ru.resx b/src/Gml.Launcher/Assets/Resources/Resources.ru.resx index 791bee6..b051bee 100644 --- a/src/Gml.Launcher/Assets/Resources/Resources.ru.resx +++ b/src/Gml.Launcher/Assets/Resources/Resources.ru.resx @@ -107,4 +107,13 @@ Не удалось определить операционную систему + + На серверах + + + чел. + + + Не удалось обнаружить загруженную Java для Вашей операционной системы, обратитесь в поддержку или к администратору проекта + \ No newline at end of file diff --git a/src/Gml.Launcher/Core/Converters/SumServersOnlineConverter.cs b/src/Gml.Launcher/Core/Converters/SumServersOnlineConverter.cs new file mode 100644 index 0000000..d32a61e --- /dev/null +++ b/src/Gml.Launcher/Core/Converters/SumServersOnlineConverter.cs @@ -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 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"; + } +} diff --git a/src/Gml.Launcher/Core/Converters/UrlRedirectProperty.cs b/src/Gml.Launcher/Core/Converters/UrlRedirectProperty.cs new file mode 100644 index 0000000..54cdad5 --- /dev/null +++ b/src/Gml.Launcher/Core/Converters/UrlRedirectProperty.cs @@ -0,0 +1,30 @@ +using System.Diagnostics; +using Avalonia; +using Avalonia.Controls; + +namespace Gml.Launcher.Core.Converters; + +public class UrlRedirectProperty +{ + public static readonly AttachedProperty RedirectUrlProperty = + AvaloniaProperty.RegisterAttached("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(OnSourceChanged); + } + + private void OnSourceChanged(Control control, AvaloniaPropertyChangedEventArgs args) + { + var url = args.GetNewValue(); + + Process.Start(new ProcessStartInfo + { + FileName = url, + UseShellExecute = true + }); + } +} diff --git a/src/Gml.Launcher/Models/SettingsInfo.cs b/src/Gml.Launcher/Models/SettingsInfo.cs index 34106a6..2c40f16 100644 --- a/src/Gml.Launcher/Models/SettingsInfo.cs +++ b/src/Gml.Launcher/Models/SettingsInfo.cs @@ -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"); } diff --git a/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs b/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs index f60ad0b..1c72c39 100644 --- a/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs +++ b/src/Gml.Launcher/ViewModels/Pages/OverviewPageViewModel.cs @@ -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; @@ -130,7 +131,7 @@ await ExecuteFromNewThread(async () => { try { - var profileInfo = await PrepareLaunch(); + var profileInfo = await GetProfileInfo(); if (profileInfo is { Data: not null }) { @@ -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)); @@ -191,7 +198,7 @@ private async Task GenerateProcess(CancellationToken cancellationToken, return process; } - private async Task?> PrepareLaunch() + private async Task?> GetProfileInfo() { UpdateProgress( LocalizationService.GetString(ResourceKeysDictionary.Updating), @@ -200,23 +207,20 @@ private async Task GenerateProcess(CancellationToken cancellationToken, await _gmlManager.UpdateDiscordRpcState($"{LocalizationService.GetString(ResourceKeysDictionary.PlayDRpcText)} \"{ListViewModel.SelectedProfile!.Name}\""); - var settings = await _storageService.GetAsync(StorageConstants.Settings); - - if (settings is null) - { - throw new Exception(LocalizationService.GetString(ResourceKeysDictionary.NotSetting)); - } + var settings = await _storageService.GetAsync(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); diff --git a/src/Gml.Launcher/ViewModels/SplashScreenViewModel.cs b/src/Gml.Launcher/ViewModels/SplashScreenViewModel.cs index 91e3eaa..7a80094 100644 --- a/src/Gml.Launcher/ViewModels/SplashScreenViewModel.cs +++ b/src/Gml.Launcher/ViewModels/SplashScreenViewModel.cs @@ -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; @@ -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) { @@ -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) { diff --git a/src/Gml.Launcher/Views/Components/OnlineComponent.axaml b/src/Gml.Launcher/Views/Components/OnlineComponent.axaml new file mode 100644 index 0000000..0d69f5f --- /dev/null +++ b/src/Gml.Launcher/Views/Components/OnlineComponent.axaml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + diff --git a/src/Gml.Launcher/Views/Components/OnlineComponent.axaml.cs b/src/Gml.Launcher/Views/Components/OnlineComponent.axaml.cs new file mode 100644 index 0000000..662365f --- /dev/null +++ b/src/Gml.Launcher/Views/Components/OnlineComponent.axaml.cs @@ -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 OnlineProperty = AvaloniaProperty.Register( + "Online", "0"); + + public string Online + { + get => GetValue(OnlineProperty); + set => SetValue(OnlineProperty, value); + } +} + diff --git a/src/Gml.Launcher/Views/Components/ProfileInfoComponent.axaml.cs b/src/Gml.Launcher/Views/Components/ProfileInfoComponent.axaml.cs index e980aed..51b30af 100644 --- a/src/Gml.Launcher/Views/Components/ProfileInfoComponent.axaml.cs +++ b/src/Gml.Launcher/Views/Components/ProfileInfoComponent.axaml.cs @@ -12,10 +12,10 @@ public class ProfileInfoComponent : TemplatedControl AvaloniaProperty.Register>( nameof(ProfileInfoItems), new List { - new("На проекте", "150 дней"), - new("Наиграно", " 551 час 45 мин"), - new("Баланс", "150 руб."), - new("Группа", "Premium"), + // new("На проекте", "150 дней"), + // new("Наиграно", " 551 час 45 мин"), + // new("Баланс", "150 руб."), + // new("Группа", "Premium"), }); diff --git a/src/Gml.Launcher/Views/Components/ProfileUserControl.axaml b/src/Gml.Launcher/Views/Components/ProfileUserControl.axaml index fc3f4bb..686b388 100644 --- a/src/Gml.Launcher/Views/Components/ProfileUserControl.axaml +++ b/src/Gml.Launcher/Views/Components/ProfileUserControl.axaml @@ -54,14 +54,7 @@ FontWeight="ExtraBlack" /> - - - - + diff --git a/src/Gml.Launcher/Views/Components/ProfileUserControl.axaml.cs b/src/Gml.Launcher/Views/Components/ProfileUserControl.axaml.cs index 19eea98..b48d35b 100644 --- a/src/Gml.Launcher/Views/Components/ProfileUserControl.axaml.cs +++ b/src/Gml.Launcher/Views/Components/ProfileUserControl.axaml.cs @@ -6,18 +6,22 @@ namespace Gml.Launcher.Views.Components; -public class ProfileUserControl : TemplatedControl +public class ProfileUserControl : ItemsControl { + public static readonly StyledProperty SpacingProperty = AvaloniaProperty.Register( + nameof(Spacing)); public static readonly StyledProperty> ProfileInfoItemsProperty = AvaloniaProperty.Register>( nameof(ProfileInfoItems)); - public static readonly StyledProperty SkinUrlProperty = AvaloniaProperty.Register( - nameof(SkinUrl), "https://www.clipartkey.com/mpngs/m/215-2156859_fond-transparent-steve-minecraft.png"); + public static readonly StyledProperty SkinUrlProperty = + AvaloniaProperty.Register( + nameof(SkinUrl), "https://www.clipartkey.com/mpngs/m/215-2156859_fond-transparent-steve-minecraft.png"); - public static readonly StyledProperty UserNameProperty = AvaloniaProperty.Register( - nameof(UserName), "GamerVII"); + public static readonly StyledProperty UserNameProperty = + AvaloniaProperty.Register( + nameof(UserName), "GamerVII"); public string UserName { @@ -37,4 +41,9 @@ public IEnumerable ProfileInfoItems set => SetValue(ProfileInfoItemsProperty, value); } + public int Spacing + { + get => GetValue(SpacingProperty); + set => SetValue(SpacingProperty, value); + } } diff --git a/src/Gml.Launcher/Views/Pages/OverviewPageView.axaml b/src/Gml.Launcher/Views/Pages/OverviewPageView.axaml index 7f5554e..ba9b84a 100644 --- a/src/Gml.Launcher/Views/Pages/OverviewPageView.axaml +++ b/src/Gml.Launcher/Views/Pages/OverviewPageView.axaml @@ -31,6 +31,13 @@ + + + VerticalAlignment="Top"> + + + + + + + + + + +