DTLib added as nuget packages

This commit is contained in:
2023-11-17 17:58:27 +06:00
parent e3a3fb5e5e
commit 518ac74dc7
17 changed files with 155 additions and 137 deletions

View File

@@ -1,5 +1,6 @@
using Avalonia.Interactivity;
using Avalonia.Threading;
using DTLib.Logging;
namespace Launcher.Client.Avalonia.GUI;
@@ -10,9 +11,9 @@ public partial class LauncherWindow : Window
InitializeComponent();
LogBox.Text = Logger.Buffer;
Logger.MessageSent += LogHandler;
LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Путь.Разд)+1);
LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Path.Sep)+1);
LogfileLabel.PointerPressed += (_,_)=>
Process.Start("explorer.exe", LauncherLogger.LogfileDir);
Process.Start("explorer.exe", LauncherLogger.LogfileDir.ToString()!);
LogfileLabel.PointerEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
LogfileLabel.PointerLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite;
LibraryButton.TabGrid = LibraryGrid;
@@ -26,14 +27,14 @@ public partial class LauncherWindow : Window
ProgramGrid.IsVisible = false;
SelectTab(LibraryButton, null);
FillProgramsPanel();
Logger.Log("launcher started");
Logger.LogInfo(nameof(LauncherWindow),"launcher started");
try
{
throw new Exception("aaa");
}
catch (Exception ex)
{
LogError("main window", ex);
LogError(nameof(LauncherWindow), ex);
}
}
@@ -58,15 +59,15 @@ public partial class LauncherWindow : Window
private void FillProgramsPanel()
{
Logger.Log("reading descriptors...");
string[] descriptors = Directory.GetFiles("descriptors");
Logger.LogInfo(nameof(LauncherWindow),"reading descriptors...");
var descriptors = Directory.GetFiles("descriptors");
Programs = new Program[descriptors.Length];
for (ushort i = 0; i < descriptors.Length; i++)
{
string descriptor = descriptors[i];
var descriptor = descriptors[i];
if(descriptor.EndsWith(".descriptor"))
{
Logger.Log('\t'+descriptor);
Logger.LogInfo(nameof(LauncherWindow), descriptor.ToString());
Programs[i] = new Program(descriptors[i]);
ProgramsPanel.Children.Add(Programs[i].ProgramLabel);
Programs[i].ProgramSelectedEvent += SelectProgram;
@@ -92,7 +93,7 @@ public partial class LauncherWindow : Window
NameLabel.Content = selectedProg.Name;
DescriptionBox.Text = selectedProg.Description;
BackgroundImage.Source = new Bitmap(
$"{Directory.GetCurrent()}{Путь.Разд}backgrounds{Путь.Разд}{selectedProg.BackgroundFile}");
$"{Directory.GetCurrent()}{Path.Sep}backgrounds{Path.Sep}{selectedProg.BackgroundFile}");
ProgramSettingsViever.Content = selectedProg.SettingsPanel;
DisplayingProgram = selectedProg;
}

View File

@@ -9,6 +9,6 @@ public partial class ProgramLabel : UserControl
InitializeComponent();
NameLabel.Content = label;
IconImage.Source = new Bitmap(
$"{Directory.GetCurrent()}{Путь.Разд}icons{Путь.Разд}{icon}");
$"{Directory.GetCurrent()}{Path.Sep}icons{Path.Sep}{icon}");
}
}

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RootNamespace>Launcher.Client.Avalonia</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<DebugType>full</DebugType>
@@ -24,9 +24,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DTLib\DTLib.Network\DTLib.Network.csproj" />
<ProjectReference Include="..\..\DTLib\DTLib.Dtsod\DTLib.Dtsod.csproj" />
<ProjectReference Include="..\..\DTLib\DTLib\DTLib.csproj" />
<ProjectReference Include="..\Launcher.Client\Launcher.Client.csproj" />
</ItemGroup>

View File

@@ -11,6 +11,8 @@ global using DTLib.Extensions;
global using Launcher.Client;
global using static Launcher.Client.LauncherClient;
global using static Launcher.Client.Avalonia.LauncherMain;
using DTLib.Ben.Demystifier;
using DTLib.Logging;
using Launcher.Client.Avalonia.GUI;
namespace Launcher.Client.Avalonia;
@@ -43,8 +45,8 @@ public static class LauncherMain
public static void LogError(string context, Exception ex)
{
string errmsg = $"{ex.Message}\n{ex.StackTrace}";
string errmsg = ex.ToStringDemystified();
MessageBox.Show($"{context} ERROR", errmsg);
Logger.Log(errmsg);
Logger.LogError("Main", errmsg);
}
}

View File

@@ -23,7 +23,7 @@ public class Program
public event Action<Program> ProgramSelectedEvent;
public Program(string descriptorFile)
public Program(IOPath descriptorFile)
{
DtsodV23 descriptor= new(File.ReadAllText(descriptorFile));
Name = descriptor["name"];
@@ -38,7 +38,7 @@ public class Program
ProgramLabel = new ProgramLabel(Name, IconFile);
ProgramLabel.PointerPressed += (_, _) => ProgramSelectedEvent?.Invoke(this);
SettingsFile = $"settings{Путь.Разд}{Directory}.settings";
SettingsFile = $"settings{Path.Sep}{Directory}.settings";
Settings = File.Exists(SettingsFile)
? DtsodConverter.UpdateByDefault(
new DtsodV23(File.ReadAllText(SettingsFile)),