- tweak: loading popup thinks
* - tweak: change loading handle logic * - tweak: beautify loading thinks * - fix: speed thinks while downloading
This commit is contained in:
@@ -41,9 +41,9 @@ public partial class MainViewModel : ViewModelBase
|
||||
[ObservableProperty] private bool _isPopupClosable = true;
|
||||
[ObservableProperty] private bool _popup;
|
||||
[ObservableProperty] private ListItemTemplate? _selectedListItem;
|
||||
[ObservableProperty] private string? _loginText = LocalisationService.GetString("auth-current-login-no-name");
|
||||
[ObservableProperty] private string? _loginText = LocalizationService.GetString("auth-current-login-no-name");
|
||||
|
||||
[GenerateProperty] private LocalisationService LocalisationService { get; } // Не убирать! Без этой хуйни вся локализация идет в пизду!
|
||||
[GenerateProperty] private LocalizationService LocalizationService { get; } // Не убирать! Без этой хуйни вся локализация идет в пизду!
|
||||
[GenerateProperty] private AccountInfoViewModel AccountInfoViewModel { get; }
|
||||
[GenerateProperty] private DebugService DebugService { get; } = default!;
|
||||
[GenerateProperty] private PopupMessageService PopupMessageService { get; } = default!;
|
||||
@@ -59,7 +59,7 @@ public partial class MainViewModel : ViewModelBase
|
||||
{
|
||||
Items = new ObservableCollection<ListItemTemplate>(_templates.Select(a=>
|
||||
{
|
||||
return a with { Label = LocalisationService.GetString(a.Label) };
|
||||
return a with { Label = LocalizationService.GetString(a.Label) };
|
||||
}
|
||||
));
|
||||
RequirePage<AccountInfoViewModel>();
|
||||
@@ -92,13 +92,13 @@ public partial class MainViewModel : ViewModelBase
|
||||
CheckMigration();
|
||||
|
||||
var loadingHandler = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
||||
loadingHandler.LoadingName = LocalisationService.GetString("migration-config-task");
|
||||
loadingHandler.LoadingName = LocalizationService.GetString("migration-config-task");
|
||||
loadingHandler.IsCancellable = false;
|
||||
ConfigurationService.MigrateConfigs(loadingHandler);
|
||||
|
||||
if (!VCRuntimeDllChecker.AreVCRuntimeDllsPresent())
|
||||
{
|
||||
OnPopupRequired(LocalisationService.GetString("vcruntime-check-error"));
|
||||
OnPopupRequired(LocalizationService.GetString("vcruntime-check-error"));
|
||||
Helper.OpenBrowser("https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170");
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public partial class MainViewModel : ViewModelBase
|
||||
if(AccountInfoViewModel.Credentials.HasValue)
|
||||
{
|
||||
LoginText =
|
||||
LocalisationService.GetString("auth-current-login-name",
|
||||
LocalizationService.GetString("auth-current-login-name",
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "login", AccountInfoViewModel.Credentials.Value?.Login ?? "" },
|
||||
@@ -120,7 +120,7 @@ public partial class MainViewModel : ViewModelBase
|
||||
}
|
||||
else
|
||||
{
|
||||
LoginText = LocalisationService.GetString("auth-current-login-no-name");
|
||||
LoginText = LocalizationService.GetString("auth-current-login-no-name");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public partial class MainViewModel : ViewModelBase
|
||||
return;
|
||||
|
||||
var loadingHandler = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
||||
loadingHandler.LoadingName = LocalisationService.GetString("migration-label-task");
|
||||
loadingHandler.LoadingName = LocalizationService.GetString("migration-label-task");
|
||||
loadingHandler.IsCancellable = false;
|
||||
|
||||
if (!ContentService.CheckMigration(loadingHandler))
|
||||
|
||||
@@ -32,6 +32,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
[ObservableProperty] private bool _isLogged;
|
||||
[ObservableProperty] private bool _doRetryAuth;
|
||||
[ObservableProperty] private AuthServerCredentials _authItemSelect;
|
||||
[ObservableProperty] private string _authServerName;
|
||||
|
||||
private bool _isProfilesEmpty;
|
||||
[GenerateProperty] private PopupMessageService PopupMessageService { get; }
|
||||
@@ -68,7 +69,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
public void DoAuth(string? code = null)
|
||||
{
|
||||
var message = ViewHelperService.GetViewModel<InfoPopupViewModel>();
|
||||
message.InfoText = LocalisationService.GetString("auth-processing");
|
||||
message.InfoText = LocalizationService.GetString("auth-processing");
|
||||
message.IsInfoClosable = false;
|
||||
PopupMessageService.Popup(message);
|
||||
|
||||
@@ -95,7 +96,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = new Exception(LocalisationService.GetString("auth-error"), ex);
|
||||
exception = new Exception(LocalizationService.GetString("auth-error"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,19 +129,19 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
_logger.Log("TFA required");
|
||||
break;
|
||||
case AuthenticateDenyCode.InvalidCredentials:
|
||||
PopupError(LocalisationService.GetString("auth-invalid-credentials"), e);
|
||||
PopupError(LocalizationService.GetString("auth-invalid-credentials"), e);
|
||||
break;
|
||||
case AuthenticateDenyCode.AccountLocked:
|
||||
PopupError(LocalisationService.GetString("auth-account-locked"), e);
|
||||
PopupError(LocalizationService.GetString("auth-account-locked"), e);
|
||||
break;
|
||||
case AuthenticateDenyCode.AccountUnconfirmed:
|
||||
PopupError(LocalisationService.GetString("auth-account-unconfirmed"), e);
|
||||
PopupError(LocalizationService.GetString("auth-account-unconfirmed"), e);
|
||||
break;
|
||||
case AuthenticateDenyCode.None:
|
||||
PopupError(LocalisationService.GetString("auth-none"),e);
|
||||
PopupError(LocalizationService.GetString("auth-none"),e);
|
||||
break;
|
||||
default:
|
||||
PopupError(LocalisationService.GetString("auth-error-fuck"), e);
|
||||
PopupError(LocalizationService.GetString("auth-error-fuck"), e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -150,46 +151,46 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
switch (e.HttpRequestError)
|
||||
{
|
||||
case HttpRequestError.ConnectionError:
|
||||
PopupError(LocalisationService.GetString("auth-connection-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-connection-error"), e);
|
||||
DoRetryAuth = true;
|
||||
break;
|
||||
case HttpRequestError.NameResolutionError:
|
||||
PopupError(LocalisationService.GetString("auth-name-resolution-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-name-resolution-error"), e);
|
||||
DoRetryAuth = true;
|
||||
break;
|
||||
case HttpRequestError.SecureConnectionError:
|
||||
PopupError(LocalisationService.GetString("auth-secure-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-secure-error"), e);
|
||||
DoRetryAuth = true;
|
||||
break;
|
||||
case HttpRequestError.UserAuthenticationError:
|
||||
PopupError(LocalisationService.GetString("auth-user-authentication-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-user-authentication-error"), e);
|
||||
break;
|
||||
case HttpRequestError.Unknown:
|
||||
PopupError(LocalisationService.GetString("auth-unknown"), e);
|
||||
PopupError(LocalizationService.GetString("auth-unknown"), e);
|
||||
break;
|
||||
case HttpRequestError.HttpProtocolError:
|
||||
PopupError(LocalisationService.GetString("auth-http-protocol-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-http-protocol-error"), e);
|
||||
break;
|
||||
case HttpRequestError.ExtendedConnectNotSupported:
|
||||
PopupError(LocalisationService.GetString("auth-extended-connect-not-support"), e);
|
||||
PopupError(LocalizationService.GetString("auth-extended-connect-not-support"), e);
|
||||
break;
|
||||
case HttpRequestError.VersionNegotiationError:
|
||||
PopupError(LocalisationService.GetString("auth-version-negotiation-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-version-negotiation-error"), e);
|
||||
break;
|
||||
case HttpRequestError.ProxyTunnelError:
|
||||
PopupError(LocalisationService.GetString("auth-proxy-tunnel-error"), e);
|
||||
PopupError(LocalizationService.GetString("auth-proxy-tunnel-error"), e);
|
||||
break;
|
||||
case HttpRequestError.InvalidResponse:
|
||||
PopupError(LocalisationService.GetString("auth-invalid-response"), e);
|
||||
PopupError(LocalizationService.GetString("auth-invalid-response"), e);
|
||||
break;
|
||||
case HttpRequestError.ResponseEnded:
|
||||
PopupError(LocalisationService.GetString("auth-response-ended"), e);
|
||||
PopupError(LocalizationService.GetString("auth-response-ended"), e);
|
||||
break;
|
||||
case HttpRequestError.ConfigurationLimitExceeded:
|
||||
PopupError(LocalisationService.GetString("auth-configuration-limit-exceeded"), e);
|
||||
PopupError(LocalizationService.GetString("auth-configuration-limit-exceeded"), e);
|
||||
break;
|
||||
default:
|
||||
var authError = new Exception(LocalisationService.GetString("auth-error"), e);
|
||||
var authError = new Exception(LocalizationService.GetString("auth-error"), e);
|
||||
_logger.Error(authError);
|
||||
PopupMessageService.Popup(authError);
|
||||
break;
|
||||
@@ -245,7 +246,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
private async Task ReadAuthConfig()
|
||||
{
|
||||
var message = ViewHelperService.GetViewModel<InfoPopupViewModel>();
|
||||
message.InfoText = LocalisationService.GetString("auth-config-read");
|
||||
message.InfoText = LocalizationService.GetString("auth-config-read");
|
||||
message.IsInfoClosable = false;
|
||||
PopupMessageService.Popup(message);
|
||||
|
||||
@@ -318,7 +319,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var unexpectedError = new Exception(LocalisationService.GetString("auth-error"), e);
|
||||
var unexpectedError = new Exception(LocalizationService.GetString("auth-error"), e);
|
||||
_logger.Error(unexpectedError);
|
||||
return authTokenCredentials;
|
||||
}
|
||||
@@ -345,7 +346,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
|
||||
private void PopupError(string message, Exception e)
|
||||
{
|
||||
message = LocalisationService.GetString("auth-error-occured") + message;
|
||||
message = LocalizationService.GetString("auth-error-occured") + message;
|
||||
_logger.Error(new Exception(message, e));
|
||||
|
||||
var messageView = ViewHelperService.GetViewModel<InfoPopupViewModel>();
|
||||
@@ -385,7 +386,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
var message = accountInfoViewModel.ViewHelperService.GetViewModel<InfoPopupViewModel>();
|
||||
message.InfoText = LocalisationService.GetString("auth-try-auth-config");
|
||||
message.InfoText = LocalizationService.GetString("auth-try-auth-config");
|
||||
message.IsInfoClosable = false;
|
||||
accountInfoViewModel.PopupMessageService.Popup(message);
|
||||
|
||||
@@ -423,7 +424,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
{
|
||||
accountInfoViewModel.CurrentLogin = currProfile.Login;
|
||||
accountInfoViewModel.CurrentAuthServer = currProfile.AuthServer;
|
||||
var unexpectedError = new Exception(LocalisationService.GetString("auth-error"), ex);
|
||||
var unexpectedError = new Exception(LocalizationService.GetString("auth-error"), ex);
|
||||
accountInfoViewModel._logger.Error(unexpectedError);
|
||||
accountInfoViewModel.PopupMessageService.Popup(unexpectedError);
|
||||
errorRun = true;
|
||||
@@ -436,6 +437,8 @@ public partial class AccountInfoViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
accountInfoViewModel.IsLogged = true;
|
||||
|
||||
accountInfoViewModel.AuthServerName = accountInfoViewModel.GetServerAuthName(currProfile.AuthServer);
|
||||
|
||||
return currProfile;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public partial class ConfigurationViewModel : ViewModelBase
|
||||
using var loader = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
||||
loader.LoadingName = "Removing content";
|
||||
PopupService.Popup(loader);
|
||||
ContentService.RemoveAllContent(loader, CancellationService.Token);
|
||||
ContentService.RemoveAllContent(loader.CreateLoadingContext(), CancellationService.Token);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase, IContentHol
|
||||
[GenerateProperty] private FileService FileService { get; } = default!;
|
||||
[GenerateProperty] private PopupMessageService PopupService { get; } = default!;
|
||||
[GenerateProperty] private IServiceProvider ServiceProvider { get; }
|
||||
[GenerateProperty] private CancellationService CancellationService { get; set; } = default!;
|
||||
[GenerateProperty, DesignConstruct] private ViewHelperService ViewHelperService { get; } = default!;
|
||||
|
||||
|
||||
@@ -57,7 +58,11 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase, IContentHol
|
||||
loading.LoadingName = "Unpacking entry";
|
||||
PopupService.Popup(loading);
|
||||
|
||||
Task.Run(() => ContentService.Unpack(serverEntry.FileApi, myTempDir, loading));
|
||||
Task.Run(() =>
|
||||
{
|
||||
ContentService.Unpack(serverEntry.FileApi, myTempDir, loading.CreateLoadingContext());
|
||||
loading.Dispose();
|
||||
});
|
||||
ExplorerHelper.OpenFolder(tmpDir);
|
||||
}
|
||||
|
||||
@@ -74,7 +79,7 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase, IContentHol
|
||||
{
|
||||
var cur = ServiceProvider.GetService<ServerFolderContentEntry>()!;
|
||||
cur.Init(this, ServerText.ToRobustUrl());
|
||||
var curContent = cur.Go(new ContentPath(SearchText));
|
||||
var curContent = cur.Go(new ContentPath(SearchText), CancellationService.Token);
|
||||
if(curContent == null)
|
||||
throw new NullReferenceException($"{SearchText} not found in {ServerText}");
|
||||
|
||||
@@ -144,11 +149,11 @@ public interface IContentEntry
|
||||
public string IconPath { get; }
|
||||
public ContentPath FullPath => Parent?.FullPath.With(Name) ?? new ContentPath(Name);
|
||||
|
||||
public IContentEntry? Go(ContentPath path);
|
||||
public IContentEntry? Go(ContentPath path, CancellationToken cancellationToken);
|
||||
|
||||
public void GoCurrent()
|
||||
{
|
||||
var entry = Go(ContentPath.Empty);
|
||||
var entry = Go(ContentPath.Empty, CancellationToken.None);
|
||||
if(entry is not null) Holder.CurrentEntry = entry;
|
||||
}
|
||||
|
||||
@@ -178,7 +183,7 @@ public sealed class LazyContentEntry : IContentEntry
|
||||
_lazyEntry = entry;
|
||||
_lazyEntryInit = lazyEntryInit;
|
||||
}
|
||||
public IContentEntry? Go(ContentPath path)
|
||||
public IContentEntry? Go(ContentPath path, CancellationToken cancellationToken)
|
||||
{
|
||||
_lazyEntryInit?.Invoke();
|
||||
return _lazyEntry;
|
||||
@@ -196,13 +201,13 @@ public sealed class ExtContentExecutor
|
||||
_decompilerService = decompilerService;
|
||||
}
|
||||
|
||||
public bool TryExecute(RobustManifestItem manifestItem)
|
||||
public bool TryExecute(RobustManifestItem manifestItem, CancellationToken cancellationToken)
|
||||
{
|
||||
var ext = Path.GetExtension(manifestItem.Path);
|
||||
|
||||
if (ext == ".dll")
|
||||
{
|
||||
_decompilerService.OpenServerDecompiler(_root.ServerUrl);
|
||||
_decompilerService.OpenServerDecompiler(_root.ServerUrl, cancellationToken);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -231,9 +236,9 @@ public sealed partial class ManifestContentEntry : IContentEntry
|
||||
_extContentExecutor = executor;
|
||||
}
|
||||
|
||||
public IContentEntry? Go(ContentPath path)
|
||||
public IContentEntry? Go(ContentPath path, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_extContentExecutor.TryExecute(_manifestItem))
|
||||
if (_extContentExecutor.TryExecute(_manifestItem, cancellationToken))
|
||||
return null;
|
||||
|
||||
var ext = Path.GetExtension(_manifestItem.Path);
|
||||
@@ -319,7 +324,7 @@ public sealed partial class ServerFolderContentEntry : BaseFolderContentEntry
|
||||
{
|
||||
CreateContent(new ContentPath(path), item);
|
||||
}
|
||||
|
||||
|
||||
IsLoading = false;
|
||||
loading.Dispose();
|
||||
});
|
||||
@@ -433,11 +438,11 @@ public abstract class BaseFolderContentEntry : ViewModelBase, IContentEntry
|
||||
public IContentEntry? Parent { get; set; }
|
||||
public string? Name { get; private set; }
|
||||
|
||||
public IContentEntry? Go(ContentPath path)
|
||||
public IContentEntry? Go(ContentPath path, CancellationToken cancellationToken)
|
||||
{
|
||||
if (path.IsEmpty()) return this;
|
||||
if (_childs.TryGetValue(path.GetNext(), out var child))
|
||||
return child.Go(path);
|
||||
return child.Go(path, cancellationToken);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public partial class ServerOverviewModel : ViewModelBase
|
||||
tempItems.Add(new ServerListTabTemplate(ServiceProvider.GetService<HubServerListProvider>()!.With(record.MainUrl), record.Name));
|
||||
}
|
||||
|
||||
tempItems.Add(new ServerListTabTemplate(FavoriteServerListProvider, "Favorite"));
|
||||
tempItems.Add(new ServerListTabTemplate(FavoriteServerListProvider, LocalizationService.GetString("tab-favorite")));
|
||||
|
||||
Items = new ObservableCollection<ServerListTabTemplate>(tempItems);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public partial class AddFavoriteViewModel : PopupViewModelBase
|
||||
[GenerateProperty] private ServerOverviewModel ServerOverviewModel { get; }
|
||||
[GenerateProperty] private DebugService DebugService { get; }
|
||||
[GenerateProperty] private FavoriteServerListProvider FavoriteServerListProvider { get; }
|
||||
public override string Title => LocalisationService.GetString("popup-add-favorite");
|
||||
public override string Title => LocalizationService.GetString("popup-add-favorite");
|
||||
public override bool IsClosable => true;
|
||||
|
||||
[ObservableProperty] private string _ipInput;
|
||||
@@ -43,7 +43,7 @@ public partial class AddFavoriteViewModel : PopupViewModelBase
|
||||
try
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(IpInput))
|
||||
throw new Exception(LocalisationService.GetString("popup-add-favorite-invalid-ip"));
|
||||
throw new Exception(LocalizationService.GetString("popup-add-favorite-invalid-ip"));
|
||||
|
||||
var uri = IpInput.ToRobustUrl();
|
||||
FavoriteServerListProvider.AddFavorite(uri);
|
||||
|
||||
@@ -12,7 +12,7 @@ public sealed partial class EditServerNameViewModel : PopupViewModelBase
|
||||
{
|
||||
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
|
||||
[GenerateProperty] public ConfigurationService ConfigurationService { get; }
|
||||
public override string Title => LocalisationService.GetString("popup-edit-name");
|
||||
public override string Title => LocalizationService.GetString("popup-edit-name");
|
||||
public override bool IsClosable => true;
|
||||
|
||||
[ObservableProperty] private string _ipInput;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Nebula.Launcher.ViewModels.Popup;
|
||||
public sealed partial class ExceptionListViewModel : PopupViewModelBase
|
||||
{
|
||||
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
|
||||
public override string Title => LocalisationService.GetString("popup-exception");
|
||||
public override string Title => LocalizationService.GetString("popup-exception");
|
||||
public override bool IsClosable => true;
|
||||
|
||||
public ObservableCollection<Exception> Errors { get; } = new();
|
||||
|
||||
@@ -14,7 +14,7 @@ public partial class InfoPopupViewModel : PopupViewModelBase
|
||||
|
||||
[ObservableProperty] private string _infoText = "Test";
|
||||
|
||||
public override string Title => LocalisationService.GetString("popup-information");
|
||||
public override string Title => LocalizationService.GetString("popup-information");
|
||||
public bool IsInfoClosable { get; set; } = true;
|
||||
public override bool IsClosable => IsInfoClosable;
|
||||
|
||||
|
||||
@@ -45,6 +45,6 @@ public partial class IsLoginCredentialsNullPopupViewModel : PopupViewModelBase
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public override string Title => LocalisationService.GetString("popup-login-credentials-warning");
|
||||
public override string Title => LocalizationService.GetString("popup-login-credentials-warning");
|
||||
public override bool IsClosable => true;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Nebula.Launcher.Services;
|
||||
using Nebula.Launcher.Views.Popup;
|
||||
@@ -9,82 +11,121 @@ namespace Nebula.Launcher.ViewModels.Popup;
|
||||
|
||||
[ViewModelRegister(typeof(LoadingContextView), false)]
|
||||
[ConstructGenerator]
|
||||
public sealed partial class LoadingContextViewModel : PopupViewModelBase, ILoadingHandler
|
||||
public sealed partial class LoadingContextViewModel : PopupViewModelBase, ILoadingHandlerFactory, IConnectionSpeedHandler
|
||||
{
|
||||
public ObservableCollection<LoadingContext> LoadingContexts { get; } = [];
|
||||
public ObservableCollection<double> Values { get; } = [];
|
||||
[ObservableProperty] private string _speedText = "";
|
||||
[ObservableProperty] private bool _showSpeed;
|
||||
[ObservableProperty] private int _loadingColumnSize = 2;
|
||||
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
|
||||
[GenerateProperty] public CancellationService CancellationService { get; }
|
||||
|
||||
[ObservableProperty] private int _currJobs;
|
||||
[ObservableProperty] private int _resolvedJobs;
|
||||
[ObservableProperty] private string _message = string.Empty;
|
||||
|
||||
public string LoadingName { get; set; } = LocalisationService.GetString("popup-loading");
|
||||
public string LoadingName { get; set; } = LocalizationService.GetString("popup-loading");
|
||||
public bool IsCancellable { get; set; } = true;
|
||||
public override bool IsClosable => false;
|
||||
|
||||
public override string Title => LoadingName;
|
||||
public override string Title => LocalizationService.GetString("popup-loading");
|
||||
|
||||
public void SetJobsCount(int count)
|
||||
public void Cancel()
|
||||
{
|
||||
CurrJobs = count;
|
||||
}
|
||||
|
||||
public int GetJobsCount()
|
||||
{
|
||||
return CurrJobs;
|
||||
}
|
||||
|
||||
public void SetResolvedJobsCount(int count)
|
||||
{
|
||||
ResolvedJobs = count;
|
||||
}
|
||||
|
||||
public int GetResolvedJobsCount()
|
||||
{
|
||||
return ResolvedJobs;
|
||||
}
|
||||
|
||||
public void SetLoadingMessage(string message)
|
||||
{
|
||||
Message = message + "\n" + Message;
|
||||
}
|
||||
|
||||
public void Cancel(){
|
||||
if(!IsCancellable) return;
|
||||
if (!IsCancellable) return;
|
||||
CancellationService.Cancel();
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void PasteSpeed(int speed)
|
||||
{
|
||||
if (Values.Count == 0)
|
||||
{
|
||||
ShowSpeed = true;
|
||||
LoadingColumnSize = 1;
|
||||
}
|
||||
SpeedText = FileLoadingFormater.FormatBytes(speed) + " / s";
|
||||
Values.Add(speed);
|
||||
if(Values.Count > 10) Values.RemoveAt(0);
|
||||
}
|
||||
|
||||
public ILoadingHandler CreateLoadingContext(ILoadingFormater? loadingFormater = null)
|
||||
{
|
||||
var instance = new LoadingContext(this, loadingFormater ?? DefaultLoadingFormater.Instance);
|
||||
LoadingContexts.Add(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void RemoveContextInstance(LoadingContext loadingContext)
|
||||
{
|
||||
LoadingContexts.Remove(loadingContext);
|
||||
}
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitialiseInDesignMode()
|
||||
{
|
||||
SetJobsCount(5);
|
||||
SetResolvedJobsCount(2);
|
||||
string[] debugMessages = {
|
||||
"Debug: Starting phase 1...",
|
||||
"Debug: Loading assets...",
|
||||
"Debug: Connecting to server...",
|
||||
"Debug: Fetching user data...",
|
||||
"Debug: Applying configurations...",
|
||||
"Debug: Starting phase 2...",
|
||||
"Debug: Rendering UI...",
|
||||
"Debug: Preparing scene...",
|
||||
"Debug: Initializing components...",
|
||||
"Debug: Running diagnostics...",
|
||||
"Debug: Checking dependencies...",
|
||||
"Debug: Verifying files...",
|
||||
"Debug: Cleaning up cache...",
|
||||
"Debug: Finalizing setup...",
|
||||
"Debug: Setup complete.",
|
||||
"Debug: Ready for launch."
|
||||
};
|
||||
var context = CreateLoadingContext();
|
||||
context.SetJobsCount(5);
|
||||
context.SetResolvedJobsCount(2);
|
||||
context.SetLoadingMessage("message");
|
||||
|
||||
foreach (string message in debugMessages)
|
||||
var ctx1 = CreateLoadingContext(new FileLoadingFormater());
|
||||
ctx1.SetJobsCount(1020120);
|
||||
ctx1.SetResolvedJobsCount(12331);
|
||||
ctx1.SetLoadingMessage("File data");
|
||||
|
||||
for (var i = 0; i < 14; i++)
|
||||
{
|
||||
SetLoadingMessage(message);
|
||||
PasteSpeed(Random.Shared.Next(10000000));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class LoadingContext : ObservableObject, ILoadingHandler
|
||||
{
|
||||
private readonly LoadingContextViewModel _master;
|
||||
private readonly ILoadingFormater _loadingFormater;
|
||||
public string LoadingText => _loadingFormater.Format(this);
|
||||
|
||||
[ObservableProperty] private string _message = string.Empty;
|
||||
[ObservableProperty] private long _currJobs;
|
||||
[ObservableProperty] private long _resolvedJobs;
|
||||
|
||||
public LoadingContext(LoadingContextViewModel master, ILoadingFormater loadingFormater)
|
||||
{
|
||||
_master = master;
|
||||
_loadingFormater = loadingFormater;
|
||||
}
|
||||
|
||||
public void SetJobsCount(long count)
|
||||
{
|
||||
CurrJobs = count;
|
||||
OnPropertyChanged(nameof(LoadingText));
|
||||
}
|
||||
|
||||
public long GetJobsCount()
|
||||
{
|
||||
return CurrJobs;
|
||||
}
|
||||
|
||||
public void SetResolvedJobsCount(long count)
|
||||
{
|
||||
ResolvedJobs = count;
|
||||
OnPropertyChanged(nameof(LoadingText));
|
||||
}
|
||||
|
||||
public long GetResolvedJobsCount()
|
||||
{
|
||||
return ResolvedJobs;
|
||||
}
|
||||
|
||||
public void SetLoadingMessage(string message)
|
||||
{
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_master.RemoveContextInstance(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public partial class TfaViewModel : PopupViewModelBase
|
||||
{
|
||||
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
|
||||
[GenerateProperty] public AccountInfoViewModel AccountInfo { get; }
|
||||
public override string Title => LocalisationService.GetString("popup-twofa");
|
||||
public override string Title => LocalizationService.GetString("popup-twofa");
|
||||
public override bool IsClosable => true;
|
||||
|
||||
protected override void InitialiseInDesignMode()
|
||||
|
||||
@@ -186,13 +186,12 @@ public partial class ServerEntryModelView : ViewModelBase, IFilterConsumer, ILis
|
||||
|
||||
try
|
||||
{
|
||||
using var loadingContext = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
||||
loadingContext.LoadingName = "Loading instance...";
|
||||
((ILoadingHandler)loadingContext).AppendJob();
|
||||
using var viewModelLoading = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
||||
viewModelLoading.LoadingName = "Loading instance...";
|
||||
|
||||
PopupMessageService.Popup(loadingContext);
|
||||
PopupMessageService.Popup(viewModelLoading);
|
||||
_currentInstance =
|
||||
await GameRunnerPreparer.GetGameProcessStartInfoProvider(Address, loadingContext, CancellationService.Token);
|
||||
await GameRunnerPreparer.GetGameProcessStartInfoProvider(Address, viewModelLoading, CancellationService.Token);
|
||||
_logger.Log("Preparing instance...");
|
||||
_currentInstance.RegisterLogger(_currentContentLogConsumer);
|
||||
_currentInstance.RegisterLogger(new DebugLoggerBridge(DebugService.GetLogger($"PROCESS_{Random.Shared.Next(65535)}")));
|
||||
|
||||
Reference in New Issue
Block a user