- tweak: Many tweaks!
This commit is contained in:
26
.vscode/launch.json
vendored
Normal file
26
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||
// Use hover for the description of the existing attributes
|
||||
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/Nebula.Launcher/bin/Debug/net9.0/Nebula.Launcher.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/Nebula.Launcher",
|
||||
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||
"console": "internalConsole",
|
||||
"stopAtEntry": false
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach"
|
||||
}
|
||||
]
|
||||
}
|
||||
41
.vscode/tasks.json
vendored
Normal file
41
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/Nebula.Launcher/Nebula.Launcher.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "publish",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"publish",
|
||||
"${workspaceFolder}/Nebula.Launcher/Nebula.Launcher.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "watch",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"watch",
|
||||
"run",
|
||||
"--project",
|
||||
"${workspaceFolder}/Nebula.Launcher/Nebula.Launcher.csproj"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -42,4 +42,5 @@ public partial class LocalisationService
|
||||
{
|
||||
Initialise();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
14
Nebula.Launcher/ViewModels/ContentView/ContentViewBase.cs
Normal file
14
Nebula.Launcher/ViewModels/ContentView/ContentViewBase.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Nebula.Launcher.ViewModels.Pages;
|
||||
|
||||
namespace Nebula.Launcher.ViewModels.ContentView;
|
||||
public abstract class ContentViewBase : ViewModelBase, IDisposable
|
||||
{
|
||||
public virtual void InitialiseWithData(ContentPath path, Stream stream)
|
||||
{
|
||||
}
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -53,9 +53,6 @@ public partial class AccountInfoViewModel : ViewModelBase, IViewModelPage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private CurrentAuthInfo? _currAuthTemp;
|
||||
|
||||
public string AuthItemSelect
|
||||
{
|
||||
set => CurrentAuthServer = value;
|
||||
@@ -65,6 +62,8 @@ public partial class AccountInfoViewModel : ViewModelBase, IViewModelPage
|
||||
protected override void InitialiseInDesignMode()
|
||||
{
|
||||
AddAccount(new AuthLoginPassword("Binka", "12341", ""));
|
||||
AddAccount(new AuthLoginPassword("Binka", "12341", ""));
|
||||
|
||||
AuthUrls.Add("https://cinka.ru");
|
||||
AuthUrls.Add("https://cinka.ru");
|
||||
}
|
||||
@@ -177,6 +176,7 @@ public partial class AccountInfoViewModel : ViewModelBase, IViewModelPage
|
||||
AuthUrls.Clear();
|
||||
var authUrls = ConfigurationService.GetConfigValue(LauncherConVar.AuthServers)!;
|
||||
foreach (var url in authUrls) AuthUrls.Add(url);
|
||||
if(authUrls.Length > 0) CurrentAuthServer = authUrls[0];
|
||||
|
||||
var currProfile = ConfigurationService.GetConfigValue(LauncherConVar.AuthCurrent);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Nebula.Launcher.Services;
|
||||
using Nebula.Launcher.ViewModels.ContentView;
|
||||
using Nebula.Launcher.ViewModels.Popup;
|
||||
using Nebula.Launcher.Views.Pages;
|
||||
using Nebula.Shared.Models;
|
||||
@@ -33,6 +34,10 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase , IViewModel
|
||||
|
||||
private ContentEntry? _selectedEntry;
|
||||
[ObservableProperty] private string _serverText = "";
|
||||
[ObservableProperty] private ContentViewBase? _contentView;
|
||||
public bool IsCustomContenView => ContentView != null;
|
||||
|
||||
|
||||
[GenerateProperty] private ContentService ContentService { get; } = default!;
|
||||
[GenerateProperty] private CancellationService CancellationService { get; } = default!;
|
||||
[GenerateProperty] private FileService FileService { get; } = default!;
|
||||
@@ -43,16 +48,26 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase , IViewModel
|
||||
|
||||
public ObservableCollection<ContentEntry> Entries { get; } = new();
|
||||
|
||||
private Dictionary<string, Type> _contentContainers = new();
|
||||
|
||||
public ContentEntry? SelectedEntry
|
||||
{
|
||||
get => _selectedEntry;
|
||||
set
|
||||
{
|
||||
SearchText = value?.GetPath().ToString() ?? "";
|
||||
ContentView = null;
|
||||
|
||||
if (value is { Item: not null })
|
||||
{
|
||||
if (FileService.ContentFileApi.TryOpen(value.Item.Value.Hash, out var stream))
|
||||
{
|
||||
var ext = Path.GetExtension(value.Item.Value.Path);
|
||||
if(TryGetContentViewer(ext, out var contentViewBase)){
|
||||
contentViewBase.InitialiseWithData(value.GetPath(), stream);
|
||||
ContentView = contentViewBase;
|
||||
return;
|
||||
}
|
||||
|
||||
var myTempFile = Path.Combine(Path.GetTempPath(), "tempie" + ext);
|
||||
|
||||
@@ -83,6 +98,17 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase , IViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetContentViewer(string type,[NotNullWhen(true)] out ContentViewBase? contentViewBase){
|
||||
contentViewBase = null;
|
||||
if(!_contentContainers.TryGetValue(type, out var contentViewType) ||
|
||||
!contentViewType.IsAssignableTo(typeof(ContentViewBase)))
|
||||
return false;
|
||||
|
||||
|
||||
contentViewBase = (ContentViewBase)Activator.CreateInstance(contentViewType)!;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected override void InitialiseInDesignMode()
|
||||
{
|
||||
@@ -144,15 +170,10 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase , IViewModel
|
||||
if (SelectedEntry == null || !SelectedEntry.GetRoot().TryGetEntry(path, out var centry))
|
||||
throw new Exception("Not found! " + oriPath.Path);
|
||||
|
||||
if (appendHistory) AppendHistory(SearchText);
|
||||
SearchText = oriPath.Path;
|
||||
|
||||
SelectedEntry = centry;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
SearchText = oriPath.Path;
|
||||
PopupService.Popup(e);
|
||||
}
|
||||
}
|
||||
@@ -170,11 +191,12 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase , IViewModel
|
||||
|
||||
private async Task<ContentEntry> CreateEntry(string serverUrl)
|
||||
{
|
||||
var rurl = serverUrl.ToRobustUrl();
|
||||
var info = await ContentService.GetBuildInfo(rurl, CancellationService.Token);
|
||||
var loading = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
||||
loading.LoadingName = "Loading entry";
|
||||
PopupService.Popup(loading);
|
||||
|
||||
var rurl = serverUrl.ToRobustUrl();
|
||||
var info = await ContentService.GetBuildInfo(rurl, CancellationService.Token);
|
||||
var items = await ContentService.EnsureItems(info.RobustManifestInfo, loading,
|
||||
CancellationService.Token);
|
||||
|
||||
|
||||
@@ -40,14 +40,14 @@ public partial class ServerListViewModel : ViewModelBase, IViewModelPage
|
||||
//Design think
|
||||
protected override void InitialiseInDesignMode()
|
||||
{
|
||||
ServerViewContainer = new ServerViewContainer(this, RestService, CancellationService, DebugService, ViewHelperService);
|
||||
ServerViewContainer = new ServerViewContainer(this, ViewHelperService);
|
||||
HubErrors.Add(new Exception("UVI"));
|
||||
}
|
||||
|
||||
//real think
|
||||
protected override void Initialise()
|
||||
{
|
||||
ServerViewContainer = new ServerViewContainer(this, RestService, CancellationService, DebugService, ViewHelperService);
|
||||
ServerViewContainer = new ServerViewContainer(this, ViewHelperService);
|
||||
|
||||
foreach (var info in HubService.ServerList) UnsortedServers.Add(info);
|
||||
|
||||
@@ -142,10 +142,7 @@ public partial class ServerListViewModel : ViewModelBase, IViewModelPage
|
||||
}
|
||||
|
||||
public class ServerViewContainer(
|
||||
ServerListViewModel serverListViewModel,
|
||||
RestService restService,
|
||||
CancellationService cancellationService,
|
||||
DebugService debugService,
|
||||
ServerListViewModel serverListViewModel,
|
||||
ViewHelperService viewHelperService
|
||||
)
|
||||
{
|
||||
@@ -210,13 +207,6 @@ public class ServerComparer : IComparer<ServerHubInfo>, IComparer<ServerStatus>,
|
||||
|
||||
public int Compare((RobustUrl, ServerStatus) x, (RobustUrl, ServerStatus) y)
|
||||
{
|
||||
if (ReferenceEquals(x, y))
|
||||
return 0;
|
||||
if (ReferenceEquals(null, y))
|
||||
return 1;
|
||||
if (ReferenceEquals(null, x))
|
||||
return -1;
|
||||
|
||||
return Compare(x.Item2, y.Item2);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ namespace Nebula.Launcher.ViewModels.Popup;
|
||||
public sealed partial class LoadingContextViewModel : PopupViewModelBase, ILoadingHandler
|
||||
{
|
||||
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
|
||||
[GenerateProperty] public CancellationService CancellationService { get; }
|
||||
|
||||
[ObservableProperty] private int _currJobs;
|
||||
|
||||
@@ -40,6 +41,11 @@ public sealed partial class LoadingContextViewModel : PopupViewModelBase, ILoadi
|
||||
return ResolvedJobs;
|
||||
}
|
||||
|
||||
public void Cancel(){
|
||||
CancellationService.Cancel();
|
||||
Dispose();
|
||||
}
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ public partial class ServerEntryModelView : ViewModelBase
|
||||
|
||||
private ServerInfo? _serverInfo = null;
|
||||
|
||||
private string _lastError = "";
|
||||
|
||||
public async Task<ServerInfo?> GetServerInfo()
|
||||
{
|
||||
if (_serverInfo == null)
|
||||
@@ -232,6 +234,9 @@ public partial class ServerEntryModelView : ViewModelBase
|
||||
|
||||
DebugService.Log("PROCESS EXIT WITH CODE " + Process.ExitCode);
|
||||
|
||||
if(Process.ExitCode != 0)
|
||||
PopupMessageService.Popup($"Game exit with code {Process.ExitCode}.\nReason: {_lastError}");
|
||||
|
||||
Process.Dispose();
|
||||
Process = null;
|
||||
}
|
||||
@@ -240,6 +245,7 @@ public partial class ServerEntryModelView : ViewModelBase
|
||||
{
|
||||
if (e.Data != null)
|
||||
{
|
||||
_lastError = e.Data;
|
||||
DebugService.Error(e.Data);
|
||||
CurrLog.Append(e.Data);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<pages:AccountInfoViewModel />
|
||||
</Design.DataContext>
|
||||
<Grid
|
||||
ColumnDefinitions="*,1*"
|
||||
ColumnDefinitions="3*,2*"
|
||||
Margin="15"
|
||||
RowDefinitions="*">
|
||||
<StackPanel Grid.Column="1" Grid.Row="0">
|
||||
@@ -40,7 +40,7 @@
|
||||
<Border
|
||||
BoxShadow="0 1 15 -2 #121212"
|
||||
CornerRadius="0,10,0,10"
|
||||
Margin="5,5,5,5"
|
||||
Margin="5,5,5,0"
|
||||
VerticalAlignment="Center">
|
||||
<Border.Background>
|
||||
<LinearGradientBrush EndPoint="50%,100%" StartPoint="50%,0%">
|
||||
@@ -50,7 +50,6 @@
|
||||
</Border.Background>
|
||||
<Panel>
|
||||
<StackPanel Margin="10,5,5,5" Orientation="Horizontal">
|
||||
<Label>Name:</Label>
|
||||
<Label>
|
||||
<TextBlock Text="{Binding Login}" />
|
||||
</Label>
|
||||
@@ -107,19 +106,19 @@
|
||||
<Label VerticalAlignment="Center">
|
||||
Login:
|
||||
</Label>
|
||||
<TextBox Text="{Binding CurrentLogin}" />
|
||||
<TextBox Text="{Binding CurrentLogin}" MinWidth="200" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label HorizontalAlignment="Left" VerticalAlignment="Center">
|
||||
Password:
|
||||
</Label>
|
||||
<TextBox PasswordChar="#" Text="{Binding CurrentPassword}" />
|
||||
<TextBox PasswordChar="#" MinWidth="200" Text="{Binding CurrentPassword}" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label VerticalAlignment="Center">
|
||||
Auth server:
|
||||
</Label>
|
||||
<TextBox Text="{Binding CurrentAuthServer}" />
|
||||
<TextBox MinWidth="200" Text="{Binding CurrentAuthServer}" />
|
||||
<Button Command="{Binding ExpandAuthUrlCommand}" VerticalAlignment="Stretch">
|
||||
<Label>+</Label>
|
||||
</Button>
|
||||
@@ -136,7 +135,7 @@
|
||||
ItemsSource="{Binding AuthUrls}"
|
||||
Margin="5"
|
||||
SelectedItem="{Binding AuthItemSelect}"
|
||||
SelectionMode="Toggle">
|
||||
SelectionMode="Single">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Label>
|
||||
@@ -155,6 +154,14 @@
|
||||
<Label>Auth</Label>
|
||||
</Button>
|
||||
</Border>
|
||||
<Border BoxShadow="{StaticResource DefaultShadow}">
|
||||
<Button
|
||||
Command="{Binding SaveProfileCommand}"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Center">
|
||||
<Label>Save profile</Label>
|
||||
</Button>
|
||||
</Border>
|
||||
<Button Command="{Binding ExpandAuthViewCommand}" HorizontalAlignment="Right">
|
||||
<Label>
|
||||
>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</Label>
|
||||
</StackPanel>
|
||||
|
||||
<Button HorizontalAlignment="Right" VerticalAlignment="Center">
|
||||
<Button HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding Cancel}">
|
||||
<Label>Cancel</Label>
|
||||
</Button>
|
||||
</Panel>
|
||||
|
||||
Reference in New Issue
Block a user