part of client logic moved to new project
This commit is contained in:
parent
0eab3ba8f3
commit
89ddbc19d9
@ -7,31 +7,26 @@ public partial class LauncherWindow : Window
|
|||||||
{
|
{
|
||||||
public LauncherWindow()
|
public LauncherWindow()
|
||||||
{
|
{
|
||||||
try
|
InitializeComponent();
|
||||||
{
|
LogBox.Text = Logger.Buffer;
|
||||||
InitializeComponent();
|
Logger.MessageSent += LogHandler;
|
||||||
LogBox.Text = Logger.Buffer;
|
LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Путь.Разд)+1);
|
||||||
Logger.MessageSent += LogHandler;
|
LogfileLabel.PointerPressed += (_,_)=>
|
||||||
LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Путь.Разд)+1);
|
Process.Start("explorer.exe", LauncherLogger.LogfileDir);
|
||||||
LogfileLabel.PointerPressed += (_,_)=>
|
LogfileLabel.PointerEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
|
||||||
Process.Start("explorer.exe", LauncherLogger.LogfileDir);
|
LogfileLabel.PointerLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite;
|
||||||
LogfileLabel.PointerEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
|
LibraryButton.TabGrid = LibraryGrid;
|
||||||
LogfileLabel.PointerLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite;
|
DownloadsButton.TabGrid = DownloadsGrid;
|
||||||
LibraryButton.TabGrid = LibraryGrid;
|
LogButton.TabGrid = LogGrid;
|
||||||
DownloadsButton.TabGrid = DownloadsGrid;
|
SettingsButton.TabGrid = SettingsGrid;
|
||||||
LogButton.TabGrid = LogGrid;
|
LibraryButton.Click += SelectTab;
|
||||||
SettingsButton.TabGrid = SettingsGrid;
|
DownloadsButton.Click += SelectTab;
|
||||||
LibraryButton.Click += SelectTab;
|
LogButton.Click += SelectTab;
|
||||||
DownloadsButton.Click += SelectTab;
|
SettingsButton.Click += SelectTab;
|
||||||
LogButton.Click += SelectTab;
|
ProgramGrid.IsVisible = false;
|
||||||
SettingsButton.Click += SelectTab;
|
SelectTab(LibraryButton, null);
|
||||||
ProgramGrid.IsVisible = false;
|
FillProgramsPanel();
|
||||||
SelectTab(LibraryButton, null);
|
Logger.Log("launcher started");
|
||||||
FillProgramsPanel();
|
|
||||||
Logger.Log("launcher started");
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{ LogError("LAUNCHER WINDOW INIT",ex); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogHandler(string m) => Dispatcher.UIThread.InvokeAsync(()=>LogBox.Text += m);
|
void LogHandler(string m) => Dispatcher.UIThread.InvokeAsync(()=>LogBox.Text += m);
|
||||||
@ -21,9 +21,16 @@
|
|||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.15" Condition="'$(Configuration)' == 'Debug'" />
|
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.15" Condition="'$(Configuration)' == 'Debug'" />
|
||||||
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4" />
|
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.dll" />
|
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.dll" />
|
||||||
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Dtsod.dll" />
|
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Dtsod.dll" />
|
||||||
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Network.dll" />
|
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Network.dll" />
|
||||||
|
<ProjectReference Include="..\Launcher.Client\Launcher.Client.csproj"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resources\*" />
|
<EmbeddedResource Include="Resources\*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@ -8,6 +8,8 @@ global using DTLib;
|
|||||||
global using DTLib.Dtsod;
|
global using DTLib.Dtsod;
|
||||||
global using DTLib.Filesystem;
|
global using DTLib.Filesystem;
|
||||||
global using DTLib.Extensions;
|
global using DTLib.Extensions;
|
||||||
|
global using Launcher.Client;
|
||||||
|
global using static Launcher.Client.LauncherClient;
|
||||||
global using static Launcher.Client.Avalonia.LauncherMain;
|
global using static Launcher.Client.Avalonia.LauncherMain;
|
||||||
using Launcher.Client.Avalonia.GUI;
|
using Launcher.Client.Avalonia.GUI;
|
||||||
|
|
||||||
@ -15,31 +17,24 @@ namespace Launcher.Client.Avalonia;
|
|||||||
|
|
||||||
public static class LauncherMain
|
public static class LauncherMain
|
||||||
{
|
{
|
||||||
public static LauncherConfig Config;
|
|
||||||
public static readonly LauncherLogger Logger = new();
|
|
||||||
public static LauncherWindow CurrentLauncherWindow;
|
public static LauncherWindow CurrentLauncherWindow;
|
||||||
|
|
||||||
|
public static AppBuilder BuildAvaloniaApp() =>
|
||||||
|
AppBuilder.Configure<App>()
|
||||||
|
.UsePlatformDetect()
|
||||||
|
.LogToTrace();
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Config = new LauncherConfig();
|
LauncherClient.Init();
|
||||||
Directory.Create("descriptors");
|
|
||||||
Directory.Create("icons");
|
|
||||||
Directory.Create("backgrounds");
|
|
||||||
Directory.Create("installed");
|
|
||||||
Directory.Create("settings");
|
|
||||||
File.WriteAllText($"descriptors{Путь.Разд}default.descriptor.template",
|
|
||||||
EmbeddedResources.ReadText("Launcher.Client.Avalonia.Resources.default.descriptor.template"));
|
|
||||||
|
|
||||||
var traceHandler = new ConsoleTraceListener();
|
var traceHandler = new ConsoleTraceListener();
|
||||||
Trace.AutoFlush = true;
|
Trace.AutoFlush = true;
|
||||||
Trace.Listeners.Add(traceHandler);
|
Trace.Listeners.Add(traceHandler);
|
||||||
|
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||||
AppBuilder.Configure<App>()
|
throw new Exception("aaa");
|
||||||
.UsePlatformDetect()
|
|
||||||
.LogToTrace()
|
|
||||||
.StartWithClassicDesktopLifetime(args);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
@ -21,7 +21,10 @@ public partial class App : Application
|
|||||||
_Main(e.Args);
|
_Main(e.Args);
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{ LogError("STARTUP",ex); }
|
{
|
||||||
|
LogError("STARTUP",ex);
|
||||||
|
Shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6,31 +6,26 @@ public partial class LauncherWindow : Window
|
|||||||
{
|
{
|
||||||
public LauncherWindow()
|
public LauncherWindow()
|
||||||
{
|
{
|
||||||
try
|
InitializeComponent();
|
||||||
{
|
LogBox.Text = Logger.Buffer;
|
||||||
InitializeComponent();
|
Logger.MessageSent += LogHandler;
|
||||||
LogBox.Text = Logger.Buffer;
|
LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Путь.Разд)+1);
|
||||||
Logger.MessageSent += LogHandler;
|
LogfileLabel.MouseLeftButtonDown += (_,_)=>
|
||||||
LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Путь.Разд)+1);
|
Process.Start("explorer.exe", LauncherLogger.LogfileDir);
|
||||||
LogfileLabel.MouseLeftButtonDown += (_,_)=>
|
LogfileLabel.MouseEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
|
||||||
Process.Start("explorer.exe", LauncherLogger.LogfileDir);
|
LogfileLabel.MouseLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite;
|
||||||
LogfileLabel.MouseEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
|
LibraryButton.TabGrid = LibraryGrid;
|
||||||
LogfileLabel.MouseLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite;
|
DownloadsButton.TabGrid = DownloadsGrid;
|
||||||
LibraryButton.TabGrid = LibraryGrid;
|
LogButton.TabGrid = LogGrid;
|
||||||
DownloadsButton.TabGrid = DownloadsGrid;
|
SettingsButton.TabGrid = SettingsGrid;
|
||||||
LogButton.TabGrid = LogGrid;
|
LibraryButton.Click += SelectTab;
|
||||||
SettingsButton.TabGrid = SettingsGrid;
|
DownloadsButton.Click += SelectTab;
|
||||||
LibraryButton.Click += SelectTab;
|
LogButton.Click += SelectTab;
|
||||||
DownloadsButton.Click += SelectTab;
|
SettingsButton.Click += SelectTab;
|
||||||
LogButton.Click += SelectTab;
|
ProgramGrid.Visibility = Visibility.Hidden;
|
||||||
SettingsButton.Click += SelectTab;
|
SelectTab(LibraryButton, null);
|
||||||
ProgramGrid.Visibility = Visibility.Hidden;
|
FillProgramsPanel();
|
||||||
SelectTab(LibraryButton, null);
|
Logger.Log("launcher started");
|
||||||
FillProgramsPanel();
|
|
||||||
Logger.Log("launcher started");
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{ LogError("LAUNCHER WINDOW INIT",ex); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogHandler(string m) => Dispatcher.Invoke(()=>LogBox.Text += m);
|
void LogHandler(string m) => Dispatcher.Invoke(()=>LogBox.Text += m);
|
||||||
@ -25,6 +25,7 @@
|
|||||||
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.dll" />
|
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.dll" />
|
||||||
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Dtsod.dll" />
|
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Dtsod.dll" />
|
||||||
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Network.dll" />
|
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Network.dll" />
|
||||||
|
<ProjectReference Include="..\Launcher.Client\Launcher.Client.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -9,27 +9,20 @@ global using System.Text;
|
|||||||
global using System.Collections.Generic;
|
global using System.Collections.Generic;
|
||||||
global using System.Linq;
|
global using System.Linq;
|
||||||
global using System.Windows;
|
global using System.Windows;
|
||||||
global using static Launcher.Client.WPF.LauncherMain;
|
global using Launcher.Client;
|
||||||
|
global using static Launcher.Client.LauncherClient;
|
||||||
|
global using static Launcher.Client.WPF.LauncherMain;
|
||||||
using Launcher.Client.WPF.GUI;
|
using Launcher.Client.WPF.GUI;
|
||||||
|
|
||||||
namespace Launcher.Client.WPF;
|
namespace Launcher.Client.WPF;
|
||||||
|
|
||||||
public static class LauncherMain
|
public static class LauncherMain
|
||||||
{
|
{
|
||||||
public static LauncherConfig Config;
|
|
||||||
public static readonly LauncherLogger Logger = new();
|
|
||||||
public static LauncherWindow CurrentLauncherWindow;
|
public static LauncherWindow CurrentLauncherWindow;
|
||||||
|
|
||||||
public static void _Main(string[] args)
|
public static void _Main(string[] args)
|
||||||
{
|
{
|
||||||
Config = new LauncherConfig();
|
LauncherClient.Init();
|
||||||
Directory.Create("descriptors");
|
|
||||||
Directory.Create("icons");
|
|
||||||
Directory.Create("backgrounds");
|
|
||||||
Directory.Create("installed");
|
|
||||||
Directory.Create("settings");
|
|
||||||
File.WriteAllText($"descriptors{Путь.Разд}default.descriptor.template",
|
|
||||||
EmbeddedResources.ReadText("Launcher.Client.WPF.Resources.default.descriptor.template"));
|
|
||||||
CurrentLauncherWindow = new LauncherWindow();
|
CurrentLauncherWindow = new LauncherWindow();
|
||||||
CurrentLauncherWindow.Show();
|
CurrentLauncherWindow.Show();
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
24
Launcher.Client/Launcher.Client.csproj
Normal file
24
Launcher.Client/Launcher.Client.csproj
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
|
<Nullable>disable</Nullable>
|
||||||
|
<RootNamespace>Launcher.Client</RootNamespace>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Configurations>Debug;Release</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.dll" />
|
||||||
|
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Dtsod.dll" />
|
||||||
|
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Network.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Resources\default.descriptor.template" />
|
||||||
|
<EmbeddedResource Include="Resources\launcher.dtsod" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
31
Launcher.Client/LauncherClient.cs
Normal file
31
Launcher.Client/LauncherClient.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
global using System;
|
||||||
|
global using System.Diagnostics;
|
||||||
|
global using System.Net;
|
||||||
|
global using System.Text;
|
||||||
|
global using System.Collections.Generic;
|
||||||
|
global using System.Linq;
|
||||||
|
global using DTLib;
|
||||||
|
global using DTLib.Dtsod;
|
||||||
|
global using DTLib.Filesystem;
|
||||||
|
global using DTLib.Extensions;
|
||||||
|
|
||||||
|
namespace Launcher.Client;
|
||||||
|
|
||||||
|
public static class LauncherClient
|
||||||
|
{
|
||||||
|
public static LauncherConfig Config;
|
||||||
|
public static readonly LauncherLogger Logger = new();
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
Logger.Log("launcher starting...");
|
||||||
|
Config = new LauncherConfig();
|
||||||
|
Directory.Create("descriptors");
|
||||||
|
Directory.Create("icons");
|
||||||
|
Directory.Create("backgrounds");
|
||||||
|
Directory.Create("installed");
|
||||||
|
Directory.Create("settings");
|
||||||
|
File.WriteAllText($"descriptors{Путь.Разд}default.descriptor.template",
|
||||||
|
EmbeddedResources.ReadText("Launcher.Client.Resources.default.descriptor.template"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace Launcher.Client.WPF;
|
namespace Launcher.Client;
|
||||||
|
|
||||||
public class LauncherConfig
|
public class LauncherConfig
|
||||||
{
|
{
|
||||||
@ -21,7 +21,7 @@ public class LauncherConfig
|
|||||||
{
|
{
|
||||||
// читает дефолтный конфиг из ресурсов
|
// читает дефолтный конфиг из ресурсов
|
||||||
DtsodV23 updatedConfig;
|
DtsodV23 updatedConfig;
|
||||||
DtsodV23 updatedDefault = new(EmbeddedResources.ReadText("Launcher.Client.WPF.Resources.launcher.dtsod"));
|
DtsodV23 updatedDefault = new(EmbeddedResources.ReadText("Launcher.Client.Resources.launcher.dtsod"));
|
||||||
// проверка и обновление конфига
|
// проверка и обновление конфига
|
||||||
if (File.Exists(configFile))
|
if (File.Exists(configFile))
|
||||||
{
|
{
|
||||||
@ -1,15 +1,14 @@
|
|||||||
using DTLib.Loggers;
|
using DTLib.Logging;
|
||||||
|
|
||||||
namespace Launcher.Client.WPF;
|
namespace Launcher.Client;
|
||||||
|
|
||||||
public class LauncherLogger : ConsoleLogger
|
public class LauncherLogger : ConsoleLogger
|
||||||
{
|
{
|
||||||
public const string LogfileDir = "launcher-logs";
|
public const string LogfileDir = "launcher-logs";
|
||||||
public LauncherLogger() : base(LogfileDir,"launcher-client-wpf")
|
public LauncherLogger() : base(LogfileDir,"launcher-client") {}
|
||||||
{ }
|
|
||||||
|
|
||||||
private readonly StringBuilder _buffer = new();
|
private readonly StringBuilder _buffer = new();
|
||||||
public string Buffer
|
public string Buffer
|
||||||
{
|
{
|
||||||
get { lock (_buffer) return _buffer.ToString(); }
|
get { lock (_buffer) return _buffer.ToString(); }
|
||||||
}
|
}
|
||||||
@ -10,6 +10,7 @@ global using System.Text;
|
|||||||
global using System.Threading;
|
global using System.Threading;
|
||||||
global using System.Linq;
|
global using System.Linq;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using DTLib.Logging;
|
||||||
|
|
||||||
namespace Launcher.Server;
|
namespace Launcher.Server;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ static class Server
|
|||||||
{
|
{
|
||||||
static readonly Socket mainSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
static readonly Socket mainSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
static DtsodV23 config;
|
static DtsodV23 config;
|
||||||
private static readonly DTLib.Loggers.ConsoleLogger Logger = new("logs", "launcher-server");
|
private static readonly ConsoleLogger Logger = new("logs", "launcher-server");
|
||||||
|
|
||||||
static readonly object manifestLocker = new();
|
static readonly object manifestLocker = new();
|
||||||
|
|
||||||
@ -29,7 +30,6 @@ static class Server
|
|||||||
Console.InputEncoding = Encoding.Unicode;
|
Console.InputEncoding = Encoding.Unicode;
|
||||||
Console.OutputEncoding = Encoding.Unicode;
|
Console.OutputEncoding = Encoding.Unicode;
|
||||||
PublicLog.LogEvent += Logger.Log;
|
PublicLog.LogEvent += Logger.Log;
|
||||||
PublicLog.LogNoTimeEvent += Logger.Log;
|
|
||||||
config = new DtsodV23(File.ReadAllText("launcher-server.dtsod"));
|
config = new DtsodV23(File.ReadAllText("launcher-server.dtsod"));
|
||||||
Logger.Log("b", "local address: <", "c", config["local_ip"], "b",
|
Logger.Log("b", "local address: <", "c", config["local_ip"], "b",
|
||||||
">\npublic address: <", "c", OldNetwork.GetPublicIP(), "b",
|
">\npublic address: <", "c", OldNetwork.GetPublicIP(), "b",
|
||||||
@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.1.32104.313
|
VisualStudioVersion = 17.1.32104.313
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "launcher-server", "launcher-server\launcher-server.csproj", "{1F4D14EB-AF48-4B6C-A91B-B294D4281173}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher.Server", "Launcher.Server\Launcher.Server.csproj", "{1F4D14EB-AF48-4B6C-A91B-B294D4281173}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "launcher-client-wpf", "launcher-client-wpf\launcher-client-wpf.csproj", "{A1F770F3-F6B1-4854-9BF0-093F85064B88}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher.Client.WPF", "Launcher.Client.WPF\Launcher.Client.WPF.csproj", "{A1F770F3-F6B1-4854-9BF0-093F85064B88}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{F567AA49-E96B-43BD-95B5-A71F9FCB64E1}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{F567AA49-E96B-43BD-95B5-A71F9FCB64E1}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
@ -13,7 +13,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution
|
|||||||
README.md = README.md
|
README.md = README.md
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "launcher-client-avalonia", "launcher-client-avalonia\launcher-client-avalonia.csproj", "{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher.Client.Avalonia", "Launcher.Client.Avalonia\Launcher.Client.Avalonia.csproj", "{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher.Client", "Launcher.Client\Launcher.Client.csproj", "{87427137-840D-4D09-A101-9481110682BD}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -33,6 +35,10 @@ Global
|
|||||||
{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}.Release|Any CPU.Build.0 = Release|Any CPU
|
{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{87427137-840D-4D09-A101-9481110682BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{87427137-840D-4D09-A101-9481110682BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{87427137-840D-4D09-A101-9481110682BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{87427137-840D-4D09-A101-9481110682BD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -1,65 +0,0 @@
|
|||||||
namespace Launcher.Client.Avalonia;
|
|
||||||
|
|
||||||
public class LauncherConfig
|
|
||||||
{
|
|
||||||
|
|
||||||
public record struct Server(IPEndPoint EndPoint, string Domain)
|
|
||||||
{
|
|
||||||
public Server(string domain, int port) : this
|
|
||||||
(new IPEndPoint(Dns.GetHostAddresses(domain)[0], port), domain)
|
|
||||||
{ }
|
|
||||||
public Server(IPAddress address, int port) : this
|
|
||||||
(new IPEndPoint(address, port), "")
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
|
|
||||||
public const int Version=1;
|
|
||||||
public Server[] ServerAddresses;
|
|
||||||
|
|
||||||
const string configFile = "launcher.dtsod";
|
|
||||||
public LauncherConfig()
|
|
||||||
{
|
|
||||||
// читает дефолтный конфиг из ресурсов
|
|
||||||
DtsodV23 updatedConfig;
|
|
||||||
DtsodV23 updatedDefault = new(EmbeddedResources.ReadText("Launcher.Client.Avalonia.Resources.launcher.dtsod"));
|
|
||||||
// проверка и обновление конфига
|
|
||||||
if (File.Exists(configFile))
|
|
||||||
{
|
|
||||||
DtsodV23 oldConfig = new(File.ReadAllText(configFile));
|
|
||||||
updatedConfig = DtsodConverter.UpdateByDefault(oldConfig, updatedDefault);
|
|
||||||
}
|
|
||||||
else updatedConfig = updatedDefault;
|
|
||||||
|
|
||||||
// парсит парсит полученный дтсод в LauncherConfig
|
|
||||||
List<object> serversD = updatedConfig["server"];
|
|
||||||
ServerAddresses = new Server[serversD.Count];
|
|
||||||
ushort i = 0;
|
|
||||||
foreach (DtsodV23 serverD in serversD)
|
|
||||||
{
|
|
||||||
int port = serverD["port"];
|
|
||||||
// server must have <domain> or <ip> property
|
|
||||||
ServerAddresses[i++] = serverD.TryGetValue("domain", out dynamic dom)
|
|
||||||
? new Server(dom, port)
|
|
||||||
: new Server(IPAddress.Parse(serverD["ip"]), port);
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
// записывает обновлённый конфиг в файл
|
|
||||||
public void WriteToFile()
|
|
||||||
{
|
|
||||||
StringBuilder b = new();
|
|
||||||
b.Append("version: ").Append(Version).Append(";\n");
|
|
||||||
foreach (var server in ServerAddresses)
|
|
||||||
{
|
|
||||||
b.Append("$server: {\n\t");
|
|
||||||
if (server.Domain == "")
|
|
||||||
b.Append("ip: \"").Append(server.EndPoint.Address);
|
|
||||||
else b.Append("domain: \"").Append(server.Domain);
|
|
||||||
b.Append("\";\n\tport: ")
|
|
||||||
.Append(server.EndPoint.Port)
|
|
||||||
.Append(";\n};\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
using DTLib.Loggers;
|
|
||||||
|
|
||||||
namespace Launcher.Client.Avalonia;
|
|
||||||
|
|
||||||
public class LauncherLogger : ConsoleLogger
|
|
||||||
{
|
|
||||||
public const string LogfileDir = "launcher-logs";
|
|
||||||
public LauncherLogger() : base(LogfileDir,"launcher-client-wpf")
|
|
||||||
{ }
|
|
||||||
|
|
||||||
private readonly StringBuilder _buffer = new();
|
|
||||||
public string Buffer
|
|
||||||
{
|
|
||||||
get { lock (_buffer) return _buffer.ToString(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public event Action<string> MessageSent;
|
|
||||||
|
|
||||||
public override void Log(params string[] msg)
|
|
||||||
{
|
|
||||||
base.Log(msg);
|
|
||||||
StringBuilder strb = new();
|
|
||||||
if (msg.Length == 1) strb.Append(msg[0]);
|
|
||||||
else for (int i = 1; i < msg.Length; i += 2)
|
|
||||||
strb.Append(msg[i]);
|
|
||||||
strb.Append('\n');
|
|
||||||
string msgConnected = strb.ToString();
|
|
||||||
MessageSent?.Invoke(msgConnected);
|
|
||||||
lock (_buffer) _buffer.Append(msgConnected);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
[assembly:ThemeInfo(
|
|
||||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
|
||||||
//(used if a resource is not found in the page,
|
|
||||||
// or application resource dictionaries)
|
|
||||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
|
||||||
//(used if a resource is not found in the page,
|
|
||||||
// app, or any theme specific resource dictionaries)
|
|
||||||
)]
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
name: ""; #label, which displays in launcher
|
|
||||||
directory: ""; #name of program' directory on server and client
|
|
||||||
description: ""; #desctiption, which displays in launcher
|
|
||||||
icon: ""; #name of the icon file
|
|
||||||
background: ""; #name of the background file
|
|
||||||
launchcommand: ""; #command, which starts the program
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
version: 1;
|
|
||||||
|
|
||||||
$server: {
|
|
||||||
ip: "127.0.0.1";
|
|
||||||
port: 25000;
|
|
||||||
};
|
|
||||||
Loading…
Reference in New Issue
Block a user