moved some files
This commit is contained in:
parent
c2e2785a32
commit
d24dbea501
@ -13,11 +13,16 @@ global using Directory = DTLib.Filesystem.Directory;
|
|||||||
global using Path = DTLib.Filesystem.Path;
|
global using Path = DTLib.Filesystem.Path;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Млаумчерб.Клиент.видимое;
|
||||||
|
|
||||||
namespace Млаумчерб.Клиент;
|
namespace Млаумчерб.Клиент;
|
||||||
|
|
||||||
public class Главне
|
public class Главне
|
||||||
{
|
{
|
||||||
|
public static readonly LauncherLogger Логгер = new();
|
||||||
|
|
||||||
|
public static Настройки Настройки = new();
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
@ -29,7 +34,7 @@ public class Главне
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Приложение.Логгер.LogError(nameof(Главне), ex);
|
Логгер.LogError(nameof(Главне), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using CliWrap;
|
using CliWrap;
|
||||||
using DTLib.Extensions;
|
using DTLib.Extensions;
|
||||||
|
using Млаумчерб.Клиент.видимое;
|
||||||
using Млаумчерб.Клиент.классы;
|
using Млаумчерб.Клиент.классы;
|
||||||
using static Млаумчерб.Клиент.классы.Пролетариат;
|
using static Млаумчерб.Клиент.классы.Пролетариат;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ public class GameVersionDescriptor
|
|||||||
string name = GetVersionDescriptorName(f);
|
string name = GetVersionDescriptorName(f);
|
||||||
propsList.Add(new GameVersionProps(name, null, f));
|
propsList.Add(new GameVersionProps(name, null, f));
|
||||||
}
|
}
|
||||||
var remoteVersions = await Network.GetDownloadableVersions();
|
var remoteVersions = await Сеть.GetDownloadableVersions();
|
||||||
propsList.AddRange(remoteVersions);
|
propsList.AddRange(remoteVersions);
|
||||||
return propsList;
|
return propsList;
|
||||||
}
|
}
|
||||||
@ -40,7 +41,7 @@ public class GameVersionDescriptor
|
|||||||
if (props.RemoteDescriptorUrl is null)
|
if (props.RemoteDescriptorUrl is null)
|
||||||
throw new NullReferenceException("can't download game version descriptor '"
|
throw new NullReferenceException("can't download game version descriptor '"
|
||||||
+ props.Name + "', because RemoteDescriptorUrl is null");
|
+ props.Name + "', because RemoteDescriptorUrl is null");
|
||||||
await Network.DownloadFileHTTP(props.RemoteDescriptorUrl, props.LocalDescriptorPath);
|
await Сеть.DownloadFileHTTP(props.RemoteDescriptorUrl, props.LocalDescriptorPath);
|
||||||
}
|
}
|
||||||
return new GameVersionDescriptor(props);
|
return new GameVersionDescriptor(props);
|
||||||
}
|
}
|
||||||
@ -48,13 +49,13 @@ public class GameVersionDescriptor
|
|||||||
private GameVersionDescriptor(GameVersionProps props)
|
private GameVersionDescriptor(GameVersionProps props)
|
||||||
{
|
{
|
||||||
_props = props;
|
_props = props;
|
||||||
WorkingDirectory = Path.Concat(Приложение.Настройки.путь_к_кубачу, Name);
|
WorkingDirectory = Path.Concat(Главне.Настройки.путь_к_кубачу, Name);
|
||||||
string descriptorText = File.ReadAllText(props.LocalDescriptorPath);
|
string descriptorText = File.ReadAllText(props.LocalDescriptorPath);
|
||||||
descriptor = JsonConvert.DeserializeObject<MinecraftVersionDescriptor>(descriptorText)
|
descriptor = JsonConvert.DeserializeObject<MinecraftVersionDescriptor>(descriptorText)
|
||||||
?? throw new Exception($"can't parse descriptor file '{props.LocalDescriptorPath}'");
|
?? throw new Exception($"can't parse descriptor file '{props.LocalDescriptorPath}'");
|
||||||
javaArgs = new JavaArguments(descriptor);
|
javaArgs = new JavaArguments(descriptor);
|
||||||
gameArgs = new GameArguments(descriptor);
|
gameArgs = new GameArguments(descriptor);
|
||||||
JavaExecutableFilePath = Path.Concat(Приложение.Настройки.путь_к_жабе, "bin",
|
JavaExecutableFilePath = Path.Concat(Главне.Настройки.путь_к_жабе, "bin",
|
||||||
OperatingSystem.IsWindows() ? "javaw.exe" : "javaw");
|
OperatingSystem.IsWindows() ? "javaw.exe" : "javaw");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,11 +64,11 @@ public class GameVersionDescriptor
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
downloadCts = new CancellationTokenSource();
|
downloadCts = new CancellationTokenSource();
|
||||||
if(Приложение.Настройки.скачать_жабу)
|
if(Главне.Настройки.скачать_жабу)
|
||||||
await Network.DownloadJava(descriptor.javaVersion, Приложение.Настройки.путь_к_жабе, force);
|
await Сеть.DownloadJava(descriptor.javaVersion, Главне.Настройки.путь_к_жабе, force);
|
||||||
await Network.DownloadAssets(descriptor.assetIndex, downloadCts.Token, force);
|
await Сеть.DownloadAssets(descriptor.assetIndex, downloadCts.Token, force);
|
||||||
await Network.DownloadVersionFile(descriptor.downloads.client.url, GetVersionJarFilePath(Name), force);
|
await Сеть.DownloadVersionFile(descriptor.downloads.client.url, GetVersionJarFilePath(Name), force);
|
||||||
await Network.DownloadLibraries(descriptor.libraries, GetLibrariesDir(), force);
|
await Сеть.DownloadLibraries(descriptor.libraries, GetLibrariesDir(), force);
|
||||||
// await Network.DownloadModpack(modpack, WorkingDirectory, force);
|
// await Network.DownloadModpack(modpack, WorkingDirectory, force);
|
||||||
_props.IsDownloaded = true;
|
_props.IsDownloaded = true;
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ public class GameVersionDescriptor
|
|||||||
.WithWorkingDirectory(WorkingDirectory.ToString())
|
.WithWorkingDirectory(WorkingDirectory.ToString())
|
||||||
.WithArguments(javaArgsList)
|
.WithArguments(javaArgsList)
|
||||||
.WithArguments(gameArgsList);
|
.WithArguments(gameArgsList);
|
||||||
Приложение.Логгер.LogInfo(nameof(GameVersionDescriptor),
|
Главне.Логгер.LogInfo(nameof(GameVersionDescriptor),
|
||||||
$"launching the game" +
|
$"launching the game" +
|
||||||
"\njava: " + command.TargetFilePath +
|
"\njava: " + command.TargetFilePath +
|
||||||
"\nworking_dir: " + command.WorkingDirPath +
|
"\nworking_dir: " + command.WorkingDirPath +
|
||||||
@ -99,7 +100,7 @@ public class GameVersionDescriptor
|
|||||||
gameCts = new();
|
gameCts = new();
|
||||||
commandTask = command.ExecuteAsync(gameCts.Token);
|
commandTask = command.ExecuteAsync(gameCts.Token);
|
||||||
var result = await commandTask;
|
var result = await commandTask;
|
||||||
Приложение.Логгер.LogInfo(nameof(GameVersionDescriptor), $"game exited with code {result.ExitCode}");
|
Главне.Логгер.LogInfo(nameof(GameVersionDescriptor), $"game exited with code {result.ExitCode}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
|||||||
@ -30,4 +30,19 @@
|
|||||||
<AvaloniaResource Include="капитал\**"/>
|
<AvaloniaResource Include="капитал\**"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="видимое\VersionItemView.axaml.cs">
|
||||||
|
<DependentUpon>VersionItemView.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="видимое\Окне.axaml.cs">
|
||||||
|
<DependentUpon>Окне.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="видимое\Приложение.axaml.cs">
|
||||||
|
<DependentUpon>Приложение.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
namespace Млаумчерб.Клиент;
|
using Млаумчерб.Клиент.видимое;
|
||||||
|
|
||||||
|
namespace Млаумчерб.Клиент;
|
||||||
|
|
||||||
public record Настройки
|
public record Настройки
|
||||||
{
|
{
|
||||||
@ -12,10 +14,10 @@ public record Настройки
|
|||||||
|
|
||||||
public static Настройки ЗагрузитьИзФайла(string имя_файла = "млаумчерб.настройки")
|
public static Настройки ЗагрузитьИзФайла(string имя_файла = "млаумчерб.настройки")
|
||||||
{
|
{
|
||||||
Приложение.Логгер.LogInfo(nameof(Настройки), $"попытка загрузить настройки из файла '{имя_файла}'");
|
Главне.Логгер.LogInfo(nameof(Настройки), $"попытка загрузить настройки из файла '{имя_файла}'");
|
||||||
if(!File.Exists(имя_файла))
|
if(!File.Exists(имя_файла))
|
||||||
{
|
{
|
||||||
Приложение.Логгер.LogInfo(nameof(Настройки), "файл не существует");
|
Главне.Логгер.LogInfo(nameof(Настройки), "файл не существует");
|
||||||
return new Настройки();
|
return new Настройки();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,15 +33,15 @@ public record Настройки
|
|||||||
$"Создан новый файл '{имя_файла}'.");
|
$"Создан новый файл '{имя_файла}'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Приложение.Логгер.LogInfo(nameof(Настройки), $"настройки загружены: {н}");
|
Главне.Логгер.LogInfo(nameof(Настройки), $"настройки загружены: {н}");
|
||||||
return н;
|
return н;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void СохранитьВФайл(string имя_файла = "млаумчерб.настройки")
|
public void СохранитьВФайл(string имя_файла = "млаумчерб.настройки")
|
||||||
{
|
{
|
||||||
Приложение.Логгер.LogInfo(nameof(Настройки), $"попытка сохранить настройки в файл '{имя_файла}'");
|
Главне.Логгер.LogInfo(nameof(Настройки), $"попытка сохранить настройки в файл '{имя_файла}'");
|
||||||
var текст = JsonConvert.SerializeObject(this, Formatting.Indented);
|
var текст = JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||||
File.WriteAllText(имя_файла, текст);
|
File.WriteAllText(имя_файла, текст);
|
||||||
Приложение.Логгер.LogInfo(nameof(Настройки), $"настройки сохранены: {текст}");
|
Главне.Логгер.LogInfo(nameof(Настройки), $"настройки сохранены: {текст}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,6 +4,7 @@ using MsBox.Avalonia;
|
|||||||
using MsBox.Avalonia.Dto;
|
using MsBox.Avalonia.Dto;
|
||||||
using MsBox.Avalonia.Enums;
|
using MsBox.Avalonia.Enums;
|
||||||
using MsBox.Avalonia.Models;
|
using MsBox.Avalonia.Models;
|
||||||
|
using Млаумчерб.Клиент.видимое;
|
||||||
|
|
||||||
namespace Млаумчерб.Клиент;
|
namespace Млаумчерб.Клиент;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ public static class Ошибки
|
|||||||
|
|
||||||
internal static async void ПоказатьСообщение(string context, string err)
|
internal static async void ПоказатьСообщение(string context, string err)
|
||||||
{
|
{
|
||||||
Приложение.Логгер.LogError(nameof(Ошибки), err);
|
Главне.Логгер.LogError(nameof(Ошибки), err);
|
||||||
var box = MessageBoxManager.GetMessageBoxCustom(new MessageBoxCustomParams
|
var box = MessageBoxManager.GetMessageBoxCustom(new MessageBoxCustomParams
|
||||||
{
|
{
|
||||||
ButtonDefinitions = new List<ButtonDefinition> { new() { Name = "пон" } },
|
ButtonDefinitions = new List<ButtonDefinition> { new() { Name = "пон" } },
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using Млаумчерб.Клиент.видимое;
|
||||||
using Млаумчерб.Клиент.классы;
|
using Млаумчерб.Клиент.классы;
|
||||||
using Timer = DTLib.Timer;
|
using Timer = DTLib.Timer;
|
||||||
|
|
||||||
namespace Млаумчерб.Клиент;
|
namespace Млаумчерб.Клиент;
|
||||||
|
|
||||||
public static class Network
|
public static class Сеть
|
||||||
{
|
{
|
||||||
private static HttpClient http = new();
|
private static HttpClient http = new();
|
||||||
private const string ASSET_SERVER_URL = "https://resources.download.minecraft.net/";
|
private const string ASSET_SERVER_URL = "https://resources.download.minecraft.net/";
|
||||||
@ -63,9 +64,9 @@ public static class Network
|
|||||||
File.Delete(indexFilePathTmp);
|
File.Delete(indexFilePathTmp);
|
||||||
|
|
||||||
// TODO: add something to Downloads ScrollList
|
// TODO: add something to Downloads ScrollList
|
||||||
Приложение.Логгер.LogInfo(nameof(DownloadAssets), $"started downloading asset index to '{indexFilePathTmp}'");
|
Главне.Логгер.LogInfo(nameof(DownloadAssets), $"started downloading asset index to '{indexFilePathTmp}'");
|
||||||
await DownloadFileHTTP(assetIndexProperties.url, indexFilePathTmp, null, ct);
|
await DownloadFileHTTP(assetIndexProperties.url, indexFilePathTmp, null, ct);
|
||||||
Приложение.Логгер.LogInfo(nameof(DownloadAssets), "finished downloading asset index");
|
Главне.Логгер.LogInfo(nameof(DownloadAssets), "finished downloading asset index");
|
||||||
|
|
||||||
string indexFileText = File.ReadAllText(indexFilePathTmp);
|
string indexFileText = File.ReadAllText(indexFilePathTmp);
|
||||||
AssetIndex assetIndex = JsonConvert.DeserializeObject<AssetIndex>(indexFileText)
|
AssetIndex assetIndex = JsonConvert.DeserializeObject<AssetIndex>(indexFileText)
|
||||||
@ -101,13 +102,13 @@ public static class Network
|
|||||||
long bytesPerSec = (currentSize - prevSize) / (timerDelay / 1000);
|
long bytesPerSec = (currentSize - prevSize) / (timerDelay / 1000);
|
||||||
float KbytesPerSec = bytesPerSec / 1024f;
|
float KbytesPerSec = bytesPerSec / 1024f;
|
||||||
prevSize = currentSize;
|
prevSize = currentSize;
|
||||||
Приложение.Логгер.LogDebug(nameof(DownloadAssets),
|
Главне.Логгер.LogDebug(nameof(DownloadAssets),
|
||||||
$"download progress {currentSizeM}Mb/{totalSizeM}Mb ({KbytesPerSec}Kb/s)");
|
$"download progress {currentSizeM}Mb/{totalSizeM}Mb ({KbytesPerSec}Kb/s)");
|
||||||
}
|
}
|
||||||
using Timer timer = new Timer(true, timerDelay, ReportProgress);
|
using Timer timer = new Timer(true, timerDelay, ReportProgress);
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
|
||||||
Приложение.Логгер.LogInfo(nameof(DownloadAssets), "started downloading assets");
|
Главне.Логгер.LogInfo(nameof(DownloadAssets), "started downloading assets");
|
||||||
int parallelDownloads = 32;
|
int parallelDownloads = 32;
|
||||||
var tasks = new Task[parallelDownloads];
|
var tasks = new Task[parallelDownloads];
|
||||||
var currentlyDownloadingFileHashes = new string[parallelDownloads];
|
var currentlyDownloadingFileHashes = new string[parallelDownloads];
|
||||||
@ -118,7 +119,7 @@ public static class Network
|
|||||||
string hashStart = hash.Substring(0, 2);
|
string hashStart = hash.Substring(0, 2);
|
||||||
var assetUrl = $"{ASSET_SERVER_URL}/{hashStart}/{hash}";
|
var assetUrl = $"{ASSET_SERVER_URL}/{hashStart}/{hash}";
|
||||||
IOPath assetFilePath = Path.Concat("assets", "objects", hashStart, hash);
|
IOPath assetFilePath = Path.Concat("assets", "objects", hashStart, hash);
|
||||||
Приложение.Логгер.LogDebug(nameof(DownloadAssets), $"downloading asset '{a.Key}' {hash}");
|
Главне.Логгер.LogDebug(nameof(DownloadAssets), $"downloading asset '{a.Key}' {hash}");
|
||||||
tasks[i] = DownloadFileHTTP(assetUrl, assetFilePath, AddBytesCountAtomic, ct);
|
tasks[i] = DownloadFileHTTP(assetUrl, assetFilePath, AddBytesCountAtomic, ct);
|
||||||
currentlyDownloadingFileHashes[i] = hash;
|
currentlyDownloadingFileHashes[i] = hash;
|
||||||
if (++i == parallelDownloads)
|
if (++i == parallelDownloads)
|
||||||
@ -132,7 +133,7 @@ public static class Network
|
|||||||
timer.Stop();
|
timer.Stop();
|
||||||
timer.InvokeAction();
|
timer.InvokeAction();
|
||||||
File.Move(indexFilePathTmp, indexFilePath, true);
|
File.Move(indexFilePathTmp, indexFilePath, true);
|
||||||
Приложение.Логгер.LogInfo(nameof(DownloadAssets), "finished downloading assets");
|
Главне.Логгер.LogInfo(nameof(DownloadAssets), "finished downloading assets");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<List<RemoteVersionDescriptorProps>> GetRemoteVersionDescriptorsAsync()
|
private static async Task<List<RemoteVersionDescriptorProps>> GetRemoteVersionDescriptorsAsync()
|
||||||
@ -149,7 +150,7 @@ public static class Network
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Приложение.Логгер.LogWarn(nameof(Network), ex);
|
Главне.Логгер.LogWarn(nameof(Сеть), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return descriptors;
|
return descriptors;
|
||||||
@ -4,6 +4,6 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Млаумчерб.Клиент"
|
xmlns:local="clr-namespace:Млаумчерб.Клиент"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Млаумчерб.Клиент.VersionItemView">
|
x:Class="Млаумчерб.Клиент.видимое.VersionItemView">
|
||||||
<TextBlock Name="text" Background="Transparent"/>
|
<TextBlock Name="text" Background="Transparent"/>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -2,7 +2,7 @@
|
|||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Млаумчерб.Клиент.классы;
|
using Млаумчерб.Клиент.классы;
|
||||||
|
|
||||||
namespace Млаумчерб.Клиент;
|
namespace Млаумчерб.Клиент.видимое;
|
||||||
|
|
||||||
public partial class VersionItemView : ListBoxItem
|
public partial class VersionItemView : ListBoxItem
|
||||||
{
|
{
|
||||||
@ -2,7 +2,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:gif="clr-namespace:Avalonia.Labs.Gif;assembly=Avalonia.Labs.Gif"
|
xmlns:gif="clr-namespace:Avalonia.Labs.Gif;assembly=Avalonia.Labs.Gif"
|
||||||
xmlns:local="clr-namespace:Млаумчерб"
|
xmlns:local="clr-namespace:Млаумчерб"
|
||||||
x:Class="Млаумчерб.Клиент.Окне"
|
x:Class="Млаумчерб.Клиент.видимое.Окне"
|
||||||
Name="window"
|
Name="window"
|
||||||
Title="млаумчерб"
|
Title="млаумчерб"
|
||||||
Icon="avares://млаумчерб/капитал/кубе.ico"
|
Icon="avares://млаумчерб/капитал/кубе.ico"
|
||||||
@ -6,7 +6,7 @@ using Avalonia.Platform.Storage;
|
|||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Млаумчерб.Клиент.классы;
|
using Млаумчерб.Клиент.классы;
|
||||||
|
|
||||||
namespace Млаумчерб.Клиент;
|
namespace Млаумчерб.Клиент.видимое;
|
||||||
|
|
||||||
public partial class Окне : Window
|
public partial class Окне : Window
|
||||||
{
|
{
|
||||||
@ -55,10 +55,10 @@ public partial class Окне : Window
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Приложение.Настройки = Настройки.ЗагрузитьИзФайла();
|
Главне.Настройки = Настройки.ЗагрузитьИзФайла();
|
||||||
Username = Приложение.Настройки.имя_пользователя;
|
Username = Главне.Настройки.имя_пользователя;
|
||||||
MemoryLimit = Приложение.Настройки.выделенная_память_мб;
|
MemoryLimit = Главне.Настройки.выделенная_память_мб;
|
||||||
Fullscreen = Приложение.Настройки.открывать_на_весь_экран;
|
Fullscreen = Главне.Настройки.открывать_на_весь_экран;
|
||||||
|
|
||||||
Directory.Create(Пролетариат.GetVersionDescriptorDir());
|
Directory.Create(Пролетариат.GetVersionDescriptorDir());
|
||||||
VersionComboBox.SelectedIndex = 0;
|
VersionComboBox.SelectedIndex = 0;
|
||||||
@ -69,8 +69,8 @@ public partial class Окне : Window
|
|||||||
foreach (var p in versions)
|
foreach (var p in versions)
|
||||||
{
|
{
|
||||||
VersionComboBox.Items.Add(new VersionItemView(p));
|
VersionComboBox.Items.Add(new VersionItemView(p));
|
||||||
if (Приложение.Настройки.последняя_запущенная_версия != null &&
|
if (Главне.Настройки.последняя_запущенная_версия != null &&
|
||||||
p.Name == Приложение.Настройки.последняя_запущенная_версия)
|
p.Name == Главне.Настройки.последняя_запущенная_версия)
|
||||||
VersionComboBox.SelectedIndex = VersionComboBox.Items.Count - 1;
|
VersionComboBox.SelectedIndex = VersionComboBox.Items.Count - 1;
|
||||||
}
|
}
|
||||||
VersionComboBox.IsEnabled = true;
|
VersionComboBox.IsEnabled = true;
|
||||||
@ -89,11 +89,11 @@ public partial class Окне : Window
|
|||||||
|
|
||||||
var selectedVersionView = (VersionItemView?)VersionComboBox.SelectedItem;
|
var selectedVersionView = (VersionItemView?)VersionComboBox.SelectedItem;
|
||||||
var selectedVersion = selectedVersionView?.Props;
|
var selectedVersion = selectedVersionView?.Props;
|
||||||
Приложение.Настройки.последняя_запущенная_версия = selectedVersion?.Name;
|
Главне.Настройки.последняя_запущенная_версия = selectedVersion?.Name;
|
||||||
Приложение.Настройки.имя_пользователя = Username;
|
Главне.Настройки.имя_пользователя = Username;
|
||||||
Приложение.Настройки.выделенная_память_мб = MemoryLimit;
|
Главне.Настройки.выделенная_память_мб = MemoryLimit;
|
||||||
Приложение.Настройки.открывать_на_весь_экран = Fullscreen;
|
Главне.Настройки.открывать_на_весь_экран = Fullscreen;
|
||||||
Приложение.Настройки.СохранитьВФайл();
|
Главне.Настройки.СохранитьВФайл();
|
||||||
if (selectedVersion == null)
|
if (selectedVersion == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ public partial class Окне : Window
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Launcher.LaunchFileInfoAsync(new FileInfo(Приложение.Логгер.LogfileName.ToString()))
|
Launcher.LaunchFileInfoAsync(new FileInfo(Главне.Логгер.LogfileName.ToString()))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<Application xmlns="https://github.com/avaloniaui"
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
x:Class="Млаумчерб.Клиент.Приложение"
|
x:Class="Млаумчерб.Клиент.видимое.Приложение"
|
||||||
RequestedThemeVariant="Dark">
|
RequestedThemeVariant="Dark">
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<SimpleTheme />
|
<SimpleTheme />
|
||||||
@ -2,15 +2,13 @@ using Avalonia;
|
|||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
namespace Млаумчерб.Клиент;
|
namespace Млаумчерб.Клиент.видимое;
|
||||||
|
|
||||||
public class Приложение : Application
|
public class Приложение : Application
|
||||||
{
|
{
|
||||||
public static readonly LauncherLogger Логгер = new();
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
Логгер.LogInfo(nameof(Приложение), "приложение запущено");
|
Главне.Логгер.LogInfo(nameof(Приложение), "приложение запущено");
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,6 +21,4 @@ public class Приложение : Application
|
|||||||
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Настройки Настройки = new();
|
|
||||||
}
|
}
|
||||||
@ -1,12 +1,14 @@
|
|||||||
namespace Млаумчерб.Клиент.классы;
|
using Млаумчерб.Клиент.видимое;
|
||||||
|
|
||||||
|
namespace Млаумчерб.Клиент.классы;
|
||||||
|
|
||||||
public static class Пролетариат
|
public static class Пролетариат
|
||||||
{
|
{
|
||||||
public static IOPath GetAssetIndexFilePath(string id) =>
|
public static IOPath GetAssetIndexFilePath(string id) =>
|
||||||
Path.Concat(Приложение.Настройки.путь_к_кубачу, $"assets/indexes/{id}.json");
|
Path.Concat(Главне.Настройки.путь_к_кубачу, $"assets/indexes/{id}.json");
|
||||||
|
|
||||||
public static IOPath GetVersionDescriptorDir() =>
|
public static IOPath GetVersionDescriptorDir() =>
|
||||||
Path.Concat(Приложение.Настройки.путь_к_кубачу, "version_descriptors");
|
Path.Concat(Главне.Настройки.путь_к_кубачу, "version_descriptors");
|
||||||
|
|
||||||
public static string GetVersionDescriptorName(IOPath path) =>
|
public static string GetVersionDescriptorName(IOPath path) =>
|
||||||
path.LastName().RemoveExtension().ToString();
|
path.LastName().RemoveExtension().ToString();
|
||||||
@ -15,11 +17,11 @@ public static class Пролетариат
|
|||||||
Path.Concat(GetVersionDescriptorDir(), Path.ReplaceRestrictedChars(name) + ".json");
|
Path.Concat(GetVersionDescriptorDir(), Path.ReplaceRestrictedChars(name) + ".json");
|
||||||
|
|
||||||
public static IOPath GetVersionDir() =>
|
public static IOPath GetVersionDir() =>
|
||||||
Path.Concat(Приложение.Настройки.путь_к_кубачу, "versions");
|
Path.Concat(Главне.Настройки.путь_к_кубачу, "versions");
|
||||||
|
|
||||||
public static IOPath GetVersionJarFilePath(string name) =>
|
public static IOPath GetVersionJarFilePath(string name) =>
|
||||||
Path.Concat(GetVersionDir(), name + ".jar");
|
Path.Concat(GetVersionDir(), name + ".jar");
|
||||||
|
|
||||||
public static IOPath GetLibrariesDir() =>
|
public static IOPath GetLibrariesDir() =>
|
||||||
Path.Concat(Приложение.Настройки.путь_к_кубачу, "libraries");
|
Path.Concat(Главне.Настройки.путь_к_кубачу, "libraries");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user