- add: Foolproof
This commit is contained in:
1
.idea/.idea.Nebula/.idea/avalonia.xml
generated
1
.idea/.idea.Nebula/.idea/avalonia.xml
generated
@@ -33,6 +33,7 @@
|
|||||||
<entry key="Nebula.Launcher/Views/Popup/ExceptionListView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
<entry key="Nebula.Launcher/Views/Popup/ExceptionListView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||||
<entry key="Nebula.Launcher/Views/Popup/ExceptionView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
<entry key="Nebula.Launcher/Views/Popup/ExceptionView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||||
<entry key="Nebula.Launcher/Views/Popup/InfoPopupView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
<entry key="Nebula.Launcher/Views/Popup/InfoPopupView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||||
|
<entry key="Nebula.Launcher/Views/Popup/IsLoginCredentialsNullPopupView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||||
<entry key="Nebula.Launcher/Views/Popup/LoadingContextView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
<entry key="Nebula.Launcher/Views/Popup/LoadingContextView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||||
<entry key="Nebula.Launcher/Views/Popup/LogPopupView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
<entry key="Nebula.Launcher/Views/Popup/LogPopupView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||||
<entry key="Nebula.Launcher/Views/Popup/MessagePopupView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
<entry key="Nebula.Launcher/Views/Popup/MessagePopupView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ account-auth-button = Authenticate
|
|||||||
account-auth-save = Save Profile
|
account-auth-save = Save Profile
|
||||||
account-auth-hello = Hello,
|
account-auth-hello = Hello,
|
||||||
account-auth-logout = Log out
|
account-auth-logout = Log out
|
||||||
|
auth-current-login-name = Current login: {$login}
|
||||||
|
auth-current-login-no-name = Profile not selected
|
||||||
|
|
||||||
auth-processing = Processing authentication request...
|
auth-processing = Processing authentication request...
|
||||||
auth-error = An authentication error has occurred.
|
auth-error = An authentication error has occurred.
|
||||||
@@ -45,6 +47,7 @@ config-remove-content-all = Remove all content
|
|||||||
filter-roleplay = Roleplay
|
filter-roleplay = Roleplay
|
||||||
filter-language = Language
|
filter-language = Language
|
||||||
favorite-add = Add to favorites
|
favorite-add = Add to favorites
|
||||||
|
popup-add-favorite-invalid-ip = Please enter a valid IP
|
||||||
servername-set = Set server name
|
servername-set = Set server name
|
||||||
servername-clear = Clear server name
|
servername-clear = Clear server name
|
||||||
twofa-enabled = You have two-factor authentication enabled. Please enter the code.
|
twofa-enabled = You have two-factor authentication enabled. Please enter the code.
|
||||||
@@ -56,4 +59,10 @@ serverentry-map = Map
|
|||||||
serverentry-preset = Preset
|
serverentry-preset = Preset
|
||||||
|
|
||||||
content-view-server = Server url
|
content-view-server = Server url
|
||||||
content-view-path = Path
|
content-view-path = Path
|
||||||
|
|
||||||
|
popup-login-credentials-warning = Warning! No credentials provided!
|
||||||
|
popup-login-credentials-warning-label = Warning! No credentials provided! The servers will not be able to let you in due to lack of authorization. Please keep this in mind.
|
||||||
|
popup-login-credentials-warning-go-auth = Go to auth page
|
||||||
|
popup-login-credentials-warning-cancel = Cancel
|
||||||
|
popup-login-credentials-warning-proceed = Proceed
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ account-auth-button = Аутентифицировать
|
|||||||
account-auth-save = Сохранить профиль
|
account-auth-save = Сохранить профиль
|
||||||
account-auth-hello = Привет,
|
account-auth-hello = Привет,
|
||||||
account-auth-logout = Выйти
|
account-auth-logout = Выйти
|
||||||
|
auth-current-login-name = Текущий профиль: {$login}
|
||||||
|
auth-current-login-no-name = Профиль не выбран
|
||||||
|
|
||||||
auth-processing = Обработка запроса аутентификации...
|
auth-processing = Обработка запроса аутентификации...
|
||||||
auth-error = Произошла ошибка аутентификации.
|
auth-error = Произошла ошибка аутентификации.
|
||||||
@@ -45,6 +47,7 @@ config-remove-content-all = Удалить весь контент
|
|||||||
filter-roleplay = Ролевая игра
|
filter-roleplay = Ролевая игра
|
||||||
filter-language = Язык
|
filter-language = Язык
|
||||||
favorite-add = Добавить в избранное
|
favorite-add = Добавить в избранное
|
||||||
|
popup-add-favorite-invalid-ip = Пожалуйста, введите валидный адрес
|
||||||
servername-set = Установить имя сервера
|
servername-set = Установить имя сервера
|
||||||
servername-clear = Очистить
|
servername-clear = Очистить
|
||||||
twofa-enabled = У вас включена двухфакторная аутентификация. Введите код.
|
twofa-enabled = У вас включена двухфакторная аутентификация. Введите код.
|
||||||
@@ -56,4 +59,10 @@ serverentry-map = Карта
|
|||||||
serverentry-preset = Режим
|
serverentry-preset = Режим
|
||||||
|
|
||||||
content-view-server = Сервер
|
content-view-server = Сервер
|
||||||
content-view-path = Путь
|
content-view-path = Путь
|
||||||
|
|
||||||
|
popup-login-credentials-warning = Предупреждение! Учетные данные не указаны!
|
||||||
|
popup-login-credentials-warning-label = Предупреждение! Учетные данные не указаны! Серверы не смогут пропустить вас из-за отсутствия авторизации. Пожалуйста, имейте это в виду.
|
||||||
|
popup-login-credentials-warning-go-auth = Перейти на страницу авторизации
|
||||||
|
popup-login-credentials-warning-cancel = Отмена
|
||||||
|
popup-login-credentials-warning-proceed = Продолжить
|
||||||
@@ -51,16 +51,15 @@ public partial class LocalisationService
|
|||||||
Initialise();
|
Initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetString(string locale)
|
public static string GetString(string locale, Dictionary<string, object>? options = null)
|
||||||
{
|
{
|
||||||
if (_currentMessageContext is null)
|
if (_currentMessageContext is null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("ERROR SHIT BITHC!");
|
|
||||||
return locale;
|
return locale;
|
||||||
}
|
}
|
||||||
var message = _currentMessageContext.GetMessage(locale);
|
var message = _currentMessageContext.GetMessage(locale);
|
||||||
if (message == null) return locale;
|
if (message == null) return locale;
|
||||||
return _currentMessageContext.Format(message, new Dictionary<string, object>());
|
return _currentMessageContext.Format(message, options ?? []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,17 @@ public partial class MainViewModel : ViewModelBase
|
|||||||
[ObservableProperty] private bool _popup;
|
[ObservableProperty] private bool _popup;
|
||||||
[ObservableProperty] private ListItemTemplate? _selectedListItem;
|
[ObservableProperty] private ListItemTemplate? _selectedListItem;
|
||||||
|
|
||||||
|
public bool IsLoggedIn => AuthService.SelectedAuth is not null;
|
||||||
|
public string LoginName => AuthService.SelectedAuth?.Login ?? string.Empty;
|
||||||
|
|
||||||
|
public string LoginText => Services.LocalisationService.GetString("auth-current-login-name",
|
||||||
|
new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "login", LoginName }
|
||||||
|
});
|
||||||
|
|
||||||
[GenerateProperty] private LocalisationService LocalisationService { get; }
|
[GenerateProperty] private LocalisationService LocalisationService { get; }
|
||||||
|
[GenerateProperty] private AuthService AuthService { get; }
|
||||||
[GenerateProperty] private DebugService DebugService { get; } = default!;
|
[GenerateProperty] private DebugService DebugService { get; } = default!;
|
||||||
[GenerateProperty] private PopupMessageService PopupMessageService { get; } = default!;
|
[GenerateProperty] private PopupMessageService PopupMessageService { get; } = default!;
|
||||||
[GenerateProperty] private ContentService ContentService { get; } = default!;
|
[GenerateProperty] private ContentService ContentService { get; } = default!;
|
||||||
@@ -136,6 +146,12 @@ public partial class MainViewModel : ViewModelBase
|
|||||||
CurrentPage = obj;
|
CurrentPage = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void InvokeChangeAuth()
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(IsLoggedIn));
|
||||||
|
OnPropertyChanged(nameof(LoginText));
|
||||||
|
}
|
||||||
|
|
||||||
public void PopupMessage(PopupViewModelBase viewModelBase)
|
public void PopupMessage(PopupViewModelBase viewModelBase)
|
||||||
{
|
{
|
||||||
if (CurrentPopup == null)
|
if (CurrentPopup == null)
|
||||||
@@ -163,6 +179,11 @@ public partial class MainViewModel : ViewModelBase
|
|||||||
Popup = true;
|
Popup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OpenAuthPage()
|
||||||
|
{
|
||||||
|
RequirePage<AccountInfoViewModel>();
|
||||||
|
}
|
||||||
|
|
||||||
public void OpenLink()
|
public void OpenLink()
|
||||||
{
|
{
|
||||||
Helper.OpenBrowser("https://durenko.tatar/nebula");
|
Helper.OpenBrowser("https://durenko.tatar/nebula");
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await a();
|
await a();
|
||||||
|
ViewHelperService.GetViewModel<MainViewModel>().InvokeChangeAuth();
|
||||||
}
|
}
|
||||||
catch (AuthException e)
|
catch (AuthException e)
|
||||||
{
|
{
|
||||||
@@ -200,6 +201,7 @@ public partial class AccountInfoViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
IsLogged = false;
|
IsLogged = false;
|
||||||
AuthService.ClearAuth();
|
AuthService.ClearAuth();
|
||||||
|
ViewHelperService.GetViewModel<MainViewModel>().InvokeChangeAuth();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAuthMenu()
|
private void UpdateAuthMenu()
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ public partial class AddFavoriteViewModel : PopupViewModelBase
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(IpInput))
|
||||||
|
throw new Exception(LocalisationService.GetString("popup-add-favorite-invalid-ip"));
|
||||||
|
|
||||||
var uri = IpInput.ToRobustUrl();
|
var uri = IpInput.ToRobustUrl();
|
||||||
FavoriteServerListProvider.AddFavorite(uri);
|
FavoriteServerListProvider.AddFavorite(uri);
|
||||||
Dispose();
|
Dispose();
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using Nebula.Launcher.Services;
|
||||||
|
using Nebula.Launcher.ViewModels.Pages;
|
||||||
|
using Nebula.Launcher.Views.Popup;
|
||||||
|
using Nebula.Shared.Services;
|
||||||
|
using Nebula.Shared.ViewHelper;
|
||||||
|
|
||||||
|
namespace Nebula.Launcher.ViewModels.Popup;
|
||||||
|
|
||||||
|
[ConstructGenerator, ViewModelRegister(typeof(IsLoginCredentialsNullPopupView))]
|
||||||
|
public partial class IsLoginCredentialsNullPopupViewModel : PopupViewModelBase
|
||||||
|
{
|
||||||
|
private ServerEntryModelView _entry;
|
||||||
|
|
||||||
|
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
|
||||||
|
[GenerateProperty, DesignConstruct] private ViewHelperService ViewHelperService { get; }
|
||||||
|
|
||||||
|
protected override void InitialiseInDesignMode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Initialise()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public IsLoginCredentialsNullPopupViewModel WithServerEntry(ServerEntryModelView entryModelView)
|
||||||
|
{
|
||||||
|
_entry = entryModelView;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Proceed()
|
||||||
|
{
|
||||||
|
_entry.RunInstanceIgnoreAuth();
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Cancel()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GotoAuthPage()
|
||||||
|
{
|
||||||
|
ViewHelperService.GetViewModel<MainViewModel>().RequirePage<AccountInfoViewModel>();
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Title => LocalisationService.GetString("popup-login-credentials-warning");
|
||||||
|
public override bool IsClosable => true;
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@ public partial class ServerEntryModelView : ViewModelBase, IFilterConsumer, ILis
|
|||||||
|
|
||||||
public LogPopupModelView CurrLog;
|
public LogPopupModelView CurrLog;
|
||||||
public RobustUrl Address { get; private set; }
|
public RobustUrl Address { get; private set; }
|
||||||
[GenerateProperty] private ConfigurationService ConfigurationService { get; } = default!;
|
[GenerateProperty] private AuthService AuthService { get; }
|
||||||
[GenerateProperty] private CancellationService CancellationService { get; } = default!;
|
[GenerateProperty] private CancellationService CancellationService { get; } = default!;
|
||||||
[GenerateProperty] private DebugService DebugService { get; } = default!;
|
[GenerateProperty] private DebugService DebugService { get; } = default!;
|
||||||
[GenerateProperty] private PopupMessageService PopupMessageService { get; } = default!;
|
[GenerateProperty] private PopupMessageService PopupMessageService { get; } = default!;
|
||||||
@@ -163,11 +163,26 @@ public partial class ServerEntryModelView : ViewModelBase, IFilterConsumer, ILis
|
|||||||
public void RunInstance()
|
public void RunInstance()
|
||||||
{
|
{
|
||||||
CurrLog.Clear();
|
CurrLog.Clear();
|
||||||
Task.Run(RunInstanceAsync);
|
Task.Run(async ()=> await RunInstanceAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void RunInstanceAsync()
|
public void RunInstanceIgnoreAuth()
|
||||||
{
|
{
|
||||||
|
CurrLog.Clear();
|
||||||
|
Task.Run(async ()=> await RunInstanceAsync(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RunInstanceAsync(bool ignoreLoginCredentials = false)
|
||||||
|
{
|
||||||
|
if (!ignoreLoginCredentials && AuthService.SelectedAuth is null)
|
||||||
|
{
|
||||||
|
var warningContext = ViewHelperService.GetViewModel<IsLoginCredentialsNullPopupViewModel>()
|
||||||
|
.WithServerEntry(this);
|
||||||
|
|
||||||
|
PopupMessageService.Popup(warningContext);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
using var loadingContext = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
using var loadingContext = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
||||||
loadingContext.LoadingName = "Loading instance...";
|
loadingContext.LoadingName = "Loading instance...";
|
||||||
((ILoadingHandler)loadingContext).AppendJob();
|
((ILoadingHandler)loadingContext).AppendJob();
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="clr-namespace:Nebula.Launcher.ViewModels"
|
xmlns:viewModels="clr-namespace:Nebula.Launcher.ViewModels"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:models1="clr-namespace:Nebula.Launcher.Models">
|
xmlns:models1="clr-namespace:Nebula.Launcher.Models"
|
||||||
|
xmlns:services="clr-namespace:Nebula.Launcher.Services">
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<viewModels:MainViewModel />
|
<viewModels:MainViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
@@ -120,7 +121,20 @@
|
|||||||
https://durenko.tatar/nebula/
|
https://durenko.tatar/nebula/
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</Button>
|
</Button>
|
||||||
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Text="{Binding VersionInfo}"/>
|
<StackPanel Spacing="5" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
Margin="0"
|
||||||
|
Padding="0"
|
||||||
|
CornerRadius="0"
|
||||||
|
Command="{Binding OpenAuthPage}">
|
||||||
|
<Panel>
|
||||||
|
<TextBlock Foreground="#777777" IsVisible="{Binding IsLoggedIn}" Text="{Binding LoginText}"/>
|
||||||
|
<TextBlock Foreground="#777777" IsVisible="{Binding !IsLoggedIn}" Text="{services:LocaledText auth-current-login-no-name}"/>
|
||||||
|
</Panel>
|
||||||
|
</Button>
|
||||||
|
<TextBlock>|</TextBlock>
|
||||||
|
<TextBlock Text="{Binding VersionInfo}"/>
|
||||||
|
</StackPanel>
|
||||||
</Panel>
|
</Panel>
|
||||||
</Label>
|
</Label>
|
||||||
</Border>
|
</Border>
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:popup="clr-namespace:Nebula.Launcher.ViewModels.Popup"
|
||||||
|
xmlns:controls="clr-namespace:Nebula.Launcher.Controls"
|
||||||
|
xmlns:services="clr-namespace:Nebula.Launcher.Services"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Nebula.Launcher.Views.Popup.IsLoginCredentialsNullPopupView"
|
||||||
|
x:DataType="popup:IsLoginCredentialsNullPopupViewModel">
|
||||||
|
<Design.DataContext>
|
||||||
|
<popup:IsLoginCredentialsNullPopupViewModel />
|
||||||
|
</Design.DataContext>
|
||||||
|
|
||||||
|
<StackPanel Margin="15" Orientation="Vertical" Spacing="15">
|
||||||
|
<TextBlock HorizontalAlignment="Center" Text="{services:LocaledText popup-login-credentials-warning-label}" TextWrapping="Wrap"/>
|
||||||
|
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal" Spacing="5">
|
||||||
|
<Border Background="{StaticResource DefaultSelected}" BoxShadow="{StaticResource DefaultShadow}">
|
||||||
|
<Button Command="{Binding GotoAuthPage}">
|
||||||
|
<TextBlock Text="{services:LocaledText popup-login-credentials-warning-go-auth}"/>
|
||||||
|
</Button>
|
||||||
|
</Border>
|
||||||
|
<Border Background="{StaticResource DefaultSelected}" BoxShadow="{StaticResource DefaultShadow}">
|
||||||
|
<Button Command="{Binding Cancel}">
|
||||||
|
<TextBlock Text="{services:LocaledText popup-login-credentials-warning-cancel}"/>
|
||||||
|
</Button>
|
||||||
|
</Border>
|
||||||
|
<Border Background="{StaticResource DefaultSelected}" BoxShadow="{StaticResource DefaultShadow}">
|
||||||
|
<Button Command="{Binding Proceed}">
|
||||||
|
<TextBlock Text="{services:LocaledText popup-login-credentials-warning-proceed}"/>
|
||||||
|
</Button>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Nebula.Launcher.Views.Popup;
|
||||||
|
|
||||||
|
public partial class IsLoginCredentialsNullPopupView : UserControl
|
||||||
|
{
|
||||||
|
public IsLoginCredentialsNullPopupView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user