- tweak: Compact view
This commit is contained in:
@@ -26,6 +26,7 @@ public partial class ServerListViewModel : ViewModelBase
|
|||||||
//Design think
|
//Design think
|
||||||
protected override void InitialiseInDesignMode()
|
protected override void InitialiseInDesignMode()
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("SOSAL");
|
||||||
ServerInfos.Add(CreateServerView(new ServerHubInfo("ss14://localhost",
|
ServerInfos.Add(CreateServerView(new ServerHubInfo("ss14://localhost",
|
||||||
new ServerStatus("Nebula", "TestCraft", ["16+", "RU"], "super", 12, 55, 1, false, DateTime.Now, 20), [])));
|
new ServerStatus("Nebula", "TestCraft", ["16+", "RU"], "super", 12, 55, 1, false, DateTime.Now, 20), [])));
|
||||||
ServerInfos.Add(CreateServerView(new ServerHubInfo("ss14://localhost",
|
ServerInfos.Add(CreateServerView(new ServerHubInfo("ss14://localhost",
|
||||||
@@ -37,6 +38,7 @@ public partial class ServerListViewModel : ViewModelBase
|
|||||||
//real think
|
//real think
|
||||||
protected override void Initialise()
|
protected override void Initialise()
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("SOSAL!!");
|
||||||
foreach (var info in HubService.ServerList) UnsortedServers.Add(info);
|
foreach (var info in HubService.ServerList) UnsortedServers.Add(info);
|
||||||
|
|
||||||
HubService.HubServerChangedEventArgs += HubServerChangedEventArgs;
|
HubService.HubServerChangedEventArgs += HubServerChangedEventArgs;
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Avalonia;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using Nebula.Launcher.Services;
|
using Nebula.Launcher.Services;
|
||||||
using Nebula.Launcher.ViewModels.Popup;
|
using Nebula.Launcher.ViewModels.Popup;
|
||||||
using Nebula.Launcher.Views;
|
using Nebula.Launcher.Views;
|
||||||
using Nebula.Shared.Models;
|
using Nebula.Shared.Models;
|
||||||
using Nebula.Shared.Services;
|
using Nebula.Shared.Services;
|
||||||
|
using Nebula.Shared.Utils;
|
||||||
|
|
||||||
namespace Nebula.Launcher.ViewModels;
|
namespace Nebula.Launcher.ViewModels;
|
||||||
|
|
||||||
@@ -28,10 +35,49 @@ public partial class ServerEntryModelView : ViewModelBase
|
|||||||
[GenerateProperty] private RunnerService RunnerService { get; } = default!;
|
[GenerateProperty] private RunnerService RunnerService { get; } = default!;
|
||||||
[GenerateProperty] private PopupMessageService PopupMessageService { get; } = default!;
|
[GenerateProperty] private PopupMessageService PopupMessageService { get; } = default!;
|
||||||
[GenerateProperty] private ViewHelperService ViewHelperService { get; } = default!;
|
[GenerateProperty] private ViewHelperService ViewHelperService { get; } = default!;
|
||||||
|
[GenerateProperty] private RestService RestService { get; } = default!;
|
||||||
|
|
||||||
|
[ObservableProperty] private string _description = "...";
|
||||||
|
[ObservableProperty] private bool _expandInfo = false;
|
||||||
public bool RunVisible => Process == null;
|
public bool RunVisible => Process == null;
|
||||||
|
|
||||||
public ServerHubInfo ServerHubInfo { get; set; } = default!;
|
private ServerInfo? _serverInfo = null;
|
||||||
|
|
||||||
|
public async Task<ServerInfo?> GetServerInfo()
|
||||||
|
{
|
||||||
|
if (_serverInfo == null)
|
||||||
|
{
|
||||||
|
var result =
|
||||||
|
await RestService.GetAsync<ServerInfo>(ServerHubInfo.Address.ToRobustUrl().InfoUri, CancellationService.Token);
|
||||||
|
if (result.Value == null) return null;
|
||||||
|
_serverInfo = result.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _serverInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ServerHubInfo _serverHubInfo = default!;
|
||||||
|
public ServerHubInfo ServerHubInfo
|
||||||
|
{
|
||||||
|
get => _serverHubInfo;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Tags.Clear();
|
||||||
|
foreach (var tag in value.StatusData.Tags)
|
||||||
|
{
|
||||||
|
Tags.Add(tag);
|
||||||
|
}
|
||||||
|
foreach (var tag in value.InferredTags)
|
||||||
|
{
|
||||||
|
Tags.Add(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
_serverHubInfo = value;
|
||||||
|
OnPropertyChanged(nameof(ServerHubInfo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<string> Tags { get; } = [];
|
||||||
|
|
||||||
private Process? Process
|
private Process? Process
|
||||||
{
|
{
|
||||||
@@ -45,7 +91,9 @@ public partial class ServerEntryModelView : ViewModelBase
|
|||||||
|
|
||||||
protected override void InitialiseInDesignMode()
|
protected override void InitialiseInDesignMode()
|
||||||
{
|
{
|
||||||
|
Description = "Server of meow girls! Nya~ \nNyaMeow\nOOOINK!!";
|
||||||
|
ServerHubInfo = new ServerHubInfo("ss14://localhost",
|
||||||
|
new ServerStatus("Ameba", "Locala", ["rp:hrp", "18+"], "Antag", 15, 5, 1, false, DateTime.Now, 100), ["meow:rp"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Initialise()
|
protected override void Initialise()
|
||||||
@@ -164,6 +212,18 @@ public partial class ServerEntryModelView : ViewModelBase
|
|||||||
Process?.CloseMainWindow();
|
Process?.CloseMainWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void ExpandInfoRequired()
|
||||||
|
{
|
||||||
|
ExpandInfo = !ExpandInfo;
|
||||||
|
if (Avalonia.Controls.Design.IsDesignMode)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var info = await GetServerInfo();
|
||||||
|
Description = info != null ? info.Desc : "Server offline";
|
||||||
|
}
|
||||||
|
|
||||||
private static string FindDotnetPath()
|
private static string FindDotnetPath()
|
||||||
{
|
{
|
||||||
var pathEnv = Environment.GetEnvironmentVariable("PATH");
|
var pathEnv = Environment.GetEnvironmentVariable("PATH");
|
||||||
|
|||||||
@@ -1,37 +1,51 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
<UserControl
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
d:DesignHeight="300"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
d:DesignWidth="800"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
mc:Ignorable="d"
|
||||||
xmlns:viewModels="clr-namespace:Nebula.Launcher.ViewModels"
|
x:Class="Nebula.Launcher.Views.ServerEntryView"
|
||||||
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
|
x:DataType="viewModels:ServerEntryModelView"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="100"
|
xmlns="https://github.com/avaloniaui"
|
||||||
x:Class="Nebula.Launcher.Views.ServerEntryView"
|
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
|
||||||
x:DataType="viewModels:ServerEntryModelView">
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||||
|
xmlns:viewModels="clr-namespace:Nebula.Launcher.ViewModels"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<viewModels:ServerEntryModelView />
|
<viewModels:ServerEntryModelView />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
|
|
||||||
<Grid
|
<Border CornerRadius="10" Margin="0,5,0,5">
|
||||||
ColumnDefinitions="*,120"
|
<Grid ColumnDefinitions="30,*,80,120" RowDefinitions="35,*,*">
|
||||||
Margin="0,5,0,5"
|
<Border
|
||||||
RowDefinitions="30,*">
|
BorderThickness="0,0,0,2"
|
||||||
<Border
|
CornerRadius="10"
|
||||||
BorderThickness="2,0,0,0"
|
Grid.Column="1"
|
||||||
CornerRadius="10,0,0,0"
|
Grid.ColumnSpan="2"
|
||||||
Grid.Column="0"
|
Grid.Row="0"
|
||||||
Grid.Row="0"
|
IsVisible="{Binding ExpandInfo}" />
|
||||||
Padding="10,0,0,0">
|
<Button
|
||||||
<Label VerticalAlignment="Center">
|
Command="{Binding ExpandInfoRequired}"
|
||||||
<TextBlock Text="{Binding ServerHubInfo.StatusData.Name}" />
|
CornerRadius="10,0,0,10"
|
||||||
</Label>
|
Grid.Column="0"
|
||||||
</Border>
|
Grid.Row="0"
|
||||||
<Border
|
Grid.RowSpan="3"
|
||||||
BorderThickness="2,0,2,0"
|
VerticalAlignment="Stretch">
|
||||||
CornerRadius="0,10,0,0"
|
<Label VerticalAlignment="Center">
|
||||||
Grid.Column="1"
|
^
|
||||||
Grid.Row="0"
|
</Label>
|
||||||
Padding="5">
|
</Button>
|
||||||
|
<ScrollViewer
|
||||||
|
Grid.Column="1"
|
||||||
|
Grid.Row="0"
|
||||||
|
Margin="5">
|
||||||
|
<Label VerticalAlignment="Center">
|
||||||
|
<TextBlock Text="{Binding ServerHubInfo.StatusData.Name}" />
|
||||||
|
</Label>
|
||||||
|
</ScrollViewer>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
|
Grid.Column="2"
|
||||||
|
Grid.Row="0"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
VerticalAlignment="Center">
|
VerticalAlignment="Center">
|
||||||
@@ -43,106 +57,123 @@
|
|||||||
<TextBlock Text="{Binding ServerHubInfo.StatusData.SoftMaxPlayers}" />
|
<TextBlock Text="{Binding ServerHubInfo.StatusData.SoftMaxPlayers}" />
|
||||||
</Label>
|
</Label>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
|
||||||
|
|
||||||
<Border
|
<Panel
|
||||||
BorderThickness="2,0,0,0"
|
Grid.Column="3"
|
||||||
CornerRadius="0,0,10,10"
|
Grid.Row="0"
|
||||||
Grid.Column="0"
|
Margin="5,0,0,0">
|
||||||
Grid.ColumnSpan="2"
|
<Button
|
||||||
Grid.Row="1"
|
Command="{Binding RunInstance}"
|
||||||
MinHeight="50">
|
CornerRadius="10,10,10,10"
|
||||||
<Border.Background>
|
HorizontalAlignment="Stretch"
|
||||||
<ImageBrush Stretch="UniformToFill"
|
IsVisible="{Binding RunVisible}"
|
||||||
asyncImageLoader:ImageBrushLoader.Source="https://t4.ftcdn.net/jpg/00/81/55/69/360_F_81556974_8sF8cKszJaRfBGd5sDt1RXE2QbzDtQqs.jpg" />
|
VerticalAlignment="Stretch">
|
||||||
</Border.Background>
|
<Label HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
|
Play
|
||||||
|
</Label>
|
||||||
|
</Button>
|
||||||
|
<Grid Grid.ColumnDefinitions="*,*" IsVisible="{Binding !RunVisible}">
|
||||||
|
<Button
|
||||||
|
Command="{Binding ReadLog}"
|
||||||
|
CornerRadius="10,0,0,10"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Margin="0,0,1,0"
|
||||||
|
VerticalAlignment="Stretch">
|
||||||
|
<Label HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
|
Log
|
||||||
|
</Label>
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
Command="{Binding StopInstance}"
|
||||||
|
CornerRadius="10,0,10,0"
|
||||||
|
Grid.Column="1"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Margin="1,0,0,0"
|
||||||
|
VerticalAlignment="Stretch">
|
||||||
|
<Label HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
|
Stop
|
||||||
|
</Label>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</Panel>
|
||||||
|
|
||||||
<Border
|
<Border
|
||||||
BorderThickness="0,2,2,0"
|
BorderThickness="0,0,0,0"
|
||||||
CornerRadius="0,0,10,10"
|
Grid.Column="1"
|
||||||
IsVisible="True"
|
Grid.ColumnSpan="3"
|
||||||
Margin="0,0,0,0"
|
Grid.Row="1"
|
||||||
Opacity="40"
|
IsVisible="{Binding ExpandInfo}"
|
||||||
Padding="0">
|
Margin="5">
|
||||||
<UniformGrid Margin="15,5,15,0">
|
<Label FontSize="12">
|
||||||
<UniformGrid.Styles>
|
<TextBlock Text="{Binding Description}" />
|
||||||
<Style Selector="Label">
|
|
||||||
<Setter Property="FontSize" Value="8" />
|
|
||||||
</Style>
|
|
||||||
</UniformGrid.Styles>
|
|
||||||
<Label>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<TextBlock Margin="0,0,5,0">RoundStart:</TextBlock>
|
|
||||||
<TextBlock Text="{Binding ServerHubInfo.StatusData.RoundStartTime}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Label>
|
|
||||||
<Label>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<TextBlock Margin="0,0,5,0">Map:</TextBlock>
|
|
||||||
<TextBlock Text="{Binding ServerHubInfo.StatusData.Map}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Label>
|
|
||||||
<Label>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<TextBlock Margin="0,0,5,0">Preset:</TextBlock>
|
|
||||||
<TextBlock Text="{Binding ServerHubInfo.StatusData.Preset}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Label>
|
|
||||||
<Label>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<TextBlock Margin="0,0,5,0">PanicBunker:</TextBlock>
|
|
||||||
<TextBlock Text="{Binding ServerHubInfo.StatusData.PanicBunker}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Label>
|
|
||||||
<Label>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<TextBlock Margin="0,0,5,0">Round Id:</TextBlock>
|
|
||||||
<TextBlock Text="{Binding ServerHubInfo.StatusData.RoundId}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Label>
|
|
||||||
<Label>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<TextBlock Margin="0,0,5,0">Run Level:</TextBlock>
|
|
||||||
<TextBlock Text="{Binding ServerHubInfo.StatusData.RunLevel}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Label>
|
|
||||||
</UniformGrid>
|
|
||||||
</Border>
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
<Panel Grid.Column="1" Grid.Row="1">
|
|
||||||
<Button
|
|
||||||
Command="{Binding RunInstance}"
|
|
||||||
CornerRadius="10,0,10,10"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
IsVisible="{Binding RunVisible}"
|
|
||||||
VerticalAlignment="Stretch">
|
|
||||||
<Label HorizontalAlignment="Center" VerticalAlignment="Center">
|
|
||||||
Play
|
|
||||||
</Label>
|
</Label>
|
||||||
</Button>
|
</Border>
|
||||||
<Grid Grid.ColumnDefinitions="*,*" IsVisible="{Binding !RunVisible}">
|
<Border
|
||||||
<Button
|
BorderThickness="0,2,0,0"
|
||||||
Command="{Binding ReadLog}"
|
CornerRadius="10"
|
||||||
CornerRadius="10,0,0,10"
|
Grid.Column="1"
|
||||||
HorizontalAlignment="Stretch"
|
Grid.ColumnSpan="3"
|
||||||
Margin="0,0,1,0"
|
Grid.Row="2"
|
||||||
VerticalAlignment="Stretch">
|
IsVisible="{Binding ExpandInfo}"
|
||||||
<Label HorizontalAlignment="Center" VerticalAlignment="Center">
|
Margin="5,15,15,5">
|
||||||
Log
|
<StackPanel Margin="5" Spacing="4">
|
||||||
</Label>
|
<StackPanel Orientation="Horizontal">
|
||||||
</Button>
|
<Label FontSize="10" VerticalAlignment="Center">Tags:</Label>
|
||||||
<Button
|
<ItemsControl ItemsSource="{Binding Tags}">
|
||||||
Command="{Binding StopInstance}"
|
<ItemsControl.ItemTemplate>
|
||||||
CornerRadius="0,0,10,0"
|
<DataTemplate DataType="{x:Type system:String}">
|
||||||
Grid.Column="1"
|
<Border
|
||||||
HorizontalAlignment="Stretch"
|
Background="#121212"
|
||||||
Margin="1,0,0,0"
|
CornerRadius="8"
|
||||||
VerticalAlignment="Stretch">
|
HorizontalAlignment="Center"
|
||||||
<Label HorizontalAlignment="Center" VerticalAlignment="Center">
|
Margin="1,1,1,1"
|
||||||
Stop
|
VerticalAlignment="Center">
|
||||||
</Label>
|
<Label FontSize="10" Margin="5,0,5,0">
|
||||||
</Button>
|
<TextBlock Text="{Binding}" />
|
||||||
</Grid>
|
</Label>
|
||||||
</Panel>
|
</Border>
|
||||||
</Grid>
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<StackPanel
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
</ItemsControl>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Label FontSize="10" VerticalAlignment="Center">Map:</Label>
|
||||||
|
<Border
|
||||||
|
Background="#121212"
|
||||||
|
CornerRadius="8"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Margin="1,1,1,1"
|
||||||
|
VerticalAlignment="Center">
|
||||||
|
<Label FontSize="10" Margin="5,0,5,0">
|
||||||
|
<TextBlock Text="{Binding ServerHubInfo.StatusData.Map}" />
|
||||||
|
</Label>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Label FontSize="10" VerticalAlignment="Center">Preset:</Label>
|
||||||
|
<Border
|
||||||
|
Background="#121212"
|
||||||
|
CornerRadius="8"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Margin="1,1,1,1"
|
||||||
|
VerticalAlignment="Center">
|
||||||
|
<Label FontSize="10" Margin="5,0,5,0">
|
||||||
|
<TextBlock Text="{Binding ServerHubInfo.StatusData.Preset}" />
|
||||||
|
</Label>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
Reference in New Issue
Block a user