Compare commits
No commits in common. "c0239a9c294f7e45f32d03970294209871562e53" and "1ecc8ccc181f2dbdb85d3cb95697a883f962dac3" have entirely different histories.
c0239a9c29
...
1ecc8ccc18
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<packageSources>
|
|
||||||
<!-- avalonia nightly feed -->
|
|
||||||
<add key="avalonia-nightly" value="https://nuget-feed-nightly.avaloniaui.net/v3/index.json" protocolVersion="3" />
|
|
||||||
</packageSources>
|
|
||||||
</configuration>
|
|
||||||
@ -1,4 +1,7 @@
|
|||||||
namespace Млаумчерб.Клиент;
|
using DTLib.Filesystem;
|
||||||
|
using DTLib.Logging;
|
||||||
|
|
||||||
|
namespace Млаумчерб.Клиент;
|
||||||
|
|
||||||
public class LauncherLogger : FileLogger
|
public class LauncherLogger : FileLogger
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,6 @@ global using DTLib.Logging;
|
|||||||
global using DTLib.Filesystem;
|
global using DTLib.Filesystem;
|
||||||
global using File = DTLib.Filesystem.File;
|
global using File = DTLib.Filesystem.File;
|
||||||
global using Directory = DTLib.Filesystem.Directory;
|
global using Directory = DTLib.Filesystem.Directory;
|
||||||
global using Path = DTLib.Filesystem.Path;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
using System.Threading;
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks;
|
using DTLib.Filesystem;
|
||||||
using CliWrap;
|
using Path = DTLib.Filesystem.Path;
|
||||||
using DTLib.Extensions;
|
|
||||||
using Млаумчерб.Клиент.классы;
|
|
||||||
|
|
||||||
namespace Млаумчерб.Клиент;
|
namespace Млаумчерб.Клиент;
|
||||||
|
|
||||||
@ -13,7 +11,6 @@ public interface IGame
|
|||||||
Progress<NetworkTransferResult> BeginUpdate();
|
Progress<NetworkTransferResult> BeginUpdate();
|
||||||
void EndUpdate();
|
void EndUpdate();
|
||||||
Task Launch();
|
Task Launch();
|
||||||
void Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MinecraftVersion : IGame
|
public class MinecraftVersion : IGame
|
||||||
@ -21,13 +18,6 @@ public class MinecraftVersion : IGame
|
|||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
public IOPath InstallationDirectory { get; }
|
public IOPath InstallationDirectory { get; }
|
||||||
|
|
||||||
private IOPath JavawFilePath;
|
|
||||||
|
|
||||||
private JavaArguments javaArgs;
|
|
||||||
private GameArguments gameArgs;
|
|
||||||
private CancellationTokenSource? cts;
|
|
||||||
private CommandTask<CommandResult> commandTask;
|
|
||||||
|
|
||||||
public MinecraftVersion(string name)
|
public MinecraftVersion(string name)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
@ -44,28 +34,8 @@ public class MinecraftVersion : IGame
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Launch()
|
public Task Launch()
|
||||||
{
|
{
|
||||||
var javaArgsList = javaArgs.FillPlaceholders([]);
|
throw new NotImplementedException();
|
||||||
var gameArgsList = gameArgs.FillPlaceholders([]);
|
|
||||||
var command = Cli.Wrap(JavawFilePath.ToString())
|
|
||||||
.WithWorkingDirectory(InstallationDirectory.ToString())
|
|
||||||
.WithArguments(javaArgsList)
|
|
||||||
.WithArguments(gameArgsList);
|
|
||||||
Приложение.Логгер.LogInfo(nameof(MinecraftVersion),
|
|
||||||
$"launching the game" +
|
|
||||||
"\njava: " + command.TargetFilePath +
|
|
||||||
"\nworking_dir: " + command.WorkingDirPath +
|
|
||||||
"\njava_arguments: \n\t" + javaArgsList.MergeToString("\n\t") +
|
|
||||||
"\ngame_arguments: \n\t" + gameArgsList.MergeToString("\n\t"));
|
|
||||||
cts = new();
|
|
||||||
commandTask = command.ExecuteAsync(cts.Token);
|
|
||||||
var result = await commandTask;
|
|
||||||
Приложение.Логгер.LogInfo(nameof(MinecraftVersion), $"game exited with code {result.ExitCode}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
cts?.Cancel();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17,8 +17,7 @@
|
|||||||
<PackageReference Include="Avalonia.Desktop" Version="11.*" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.*" />
|
||||||
<PackageReference Include="Avalonia.Themes.Simple" Version="11.*" />
|
<PackageReference Include="Avalonia.Themes.Simple" Version="11.*" />
|
||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.*" />
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.*" />
|
||||||
<PackageReference Include="Avalonia.Labs.Gif" Version="11.2.999-cibuild-00051673"/>
|
<PackageReference Include="AvaloniaGif-Unofficial" Version="1.0.0" />
|
||||||
<PackageReference Include="CliWrap" Version="3.6.6" />
|
|
||||||
<PackageReference Include="DTLib" Version="1.3.*" />
|
<PackageReference Include="DTLib" Version="1.3.*" />
|
||||||
<PackageReference Include="DTLib.Ben.Demystifier" Version="1.0.*" />
|
<PackageReference Include="DTLib.Ben.Demystifier" Version="1.0.*" />
|
||||||
<PackageReference Include="DTLib.Logging" Version="1.3.*" />
|
<PackageReference Include="DTLib.Logging" Version="1.3.*" />
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using DTLib.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Млаумчерб.Клиент;
|
namespace Млаумчерб.Клиент;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
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.Gif;assembly=Avalonia.Gif"
|
||||||
xmlns:local="clr-namespace:Млаумчерб"
|
xmlns:local="clr-namespace:Млаумчерб"
|
||||||
x:Class="Млаумчерб.Клиент.Окне"
|
x:Class="Млаумчерб.Клиент.Окне"
|
||||||
Name="window"
|
Name="window"
|
||||||
@ -98,7 +98,7 @@
|
|||||||
<Button Classes="menu_button button_no_border" Click="OpenSourceRepository">source code</Button>
|
<Button Classes="menu_button button_no_border" Click="OpenSourceRepository">source code</Button>
|
||||||
<gif:GifImage
|
<gif:GifImage
|
||||||
Width="30" Height="30" Stretch="Uniform"
|
Width="30" Height="30" Stretch="Uniform"
|
||||||
Source="avares://млаумчерб/капитал/лисик.gif"/>
|
SourceUri="avares://млаумчерб/капитал/лисик.gif"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using DTLib.Ben.Demystifier;
|
using DTLib.Ben.Demystifier;
|
||||||
|
using DTLib.Logging;
|
||||||
using MsBox.Avalonia;
|
using MsBox.Avalonia;
|
||||||
using MsBox.Avalonia.Dto;
|
using MsBox.Avalonia.Dto;
|
||||||
using MsBox.Avalonia.Enums;
|
using MsBox.Avalonia.Enums;
|
||||||
|
|||||||
@ -17,8 +17,7 @@ public class Os
|
|||||||
public class Rule
|
public class Rule
|
||||||
{
|
{
|
||||||
[JsonRequired] public string action { get; set; } = "";
|
[JsonRequired] public string action { get; set; } = "";
|
||||||
public Os? os { get; set; }
|
[JsonRequired] public Os os { get; set; } = null!;
|
||||||
public Dictionary<string, bool>? features { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Classifiers
|
public class Classifiers
|
||||||
@ -81,18 +80,6 @@ public class JavaVersion
|
|||||||
[JsonRequired] public int majorVersion { get; set; }
|
[JsonRequired] public int majorVersion { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ArgValue
|
|
||||||
{
|
|
||||||
[JsonRequired] public string value { get; set; } = "";
|
|
||||||
public List<Rule> rules { get; set; } = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ArgumentsNew
|
|
||||||
{
|
|
||||||
[JsonRequired] public List<ArgValue> jvm { get; set; } = new();
|
|
||||||
[JsonRequired] public List<ArgValue> game { get; set; } = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MinecraftVersionDescriptor
|
public class MinecraftVersionDescriptor
|
||||||
{
|
{
|
||||||
[JsonRequired] public string id { get; set; } = "";
|
[JsonRequired] public string id { get; set; } = "";
|
||||||
@ -107,52 +94,5 @@ public class MinecraftVersionDescriptor
|
|||||||
[JsonRequired] public List<Library> libraries { get; set; } = null!;
|
[JsonRequired] public List<Library> libraries { get; set; } = null!;
|
||||||
[JsonRequired] public AssetIndex assetIndex { get; set; } = null!;
|
[JsonRequired] public AssetIndex assetIndex { get; set; } = null!;
|
||||||
[JsonRequired] public string assets { get; set; } = "";
|
[JsonRequired] public string assets { get; set; } = "";
|
||||||
public string? minecraftArguments { get; set; }
|
// public string minecraftArguments { get; set; }
|
||||||
public ArgumentsNew? arguments { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Буржуазия
|
|
||||||
{
|
|
||||||
public static bool CheckOs(Os os)
|
|
||||||
{
|
|
||||||
return os.name switch
|
|
||||||
{
|
|
||||||
"osx" => OperatingSystem.IsWindows(),
|
|
||||||
"linux" => OperatingSystem.IsLinux(),
|
|
||||||
"windows" => OperatingSystem.IsWindows(),
|
|
||||||
_ => throw new ArgumentOutOfRangeException(os.name)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool CheckRules(ICollection<Rule> rules, ICollection<string> enabled_features)
|
|
||||||
{
|
|
||||||
bool allowed = false;
|
|
||||||
foreach (var r in rules)
|
|
||||||
{
|
|
||||||
if (r.os == null || CheckOs(r.os))
|
|
||||||
{
|
|
||||||
if (r.features != null)
|
|
||||||
{
|
|
||||||
foreach (var feature in enabled_features)
|
|
||||||
{
|
|
||||||
if(r.features.TryGetValue(feature, out bool is_enabled))
|
|
||||||
{
|
|
||||||
if (is_enabled)
|
|
||||||
{
|
|
||||||
if (r.action == "allow")
|
|
||||||
allowed = true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r.action == "allow")
|
|
||||||
allowed = true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return allowed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,89 +1,6 @@
|
|||||||
using DTLib.Extensions;
|
namespace Млаумчерб.Клиент.классы;
|
||||||
|
|
||||||
namespace Млаумчерб.Клиент.классы;
|
|
||||||
|
|
||||||
public class Пролетариат
|
public class Пролетариат
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ArgumentsWithPlaceholders
|
|
||||||
{
|
|
||||||
protected List<string> raw_args = new();
|
|
||||||
|
|
||||||
public List<string> FillPlaceholders(Dictionary<string, string> values)
|
|
||||||
{
|
|
||||||
List<string> result = new();
|
|
||||||
foreach (var a in raw_args)
|
|
||||||
{
|
|
||||||
var f = a;
|
|
||||||
int begin = a.IndexOf('$');
|
|
||||||
if (begin != -1)
|
|
||||||
{
|
|
||||||
int keyBegin = begin + 2;
|
|
||||||
int end = a.IndexOf('}', keyBegin);
|
|
||||||
if (end != -1)
|
|
||||||
{
|
|
||||||
var key = a.Substring(keyBegin, end - keyBegin);
|
|
||||||
if (!values.TryGetValue(key, out var v))
|
|
||||||
throw new Exception($"can't find value for placeholder '{key}'");
|
|
||||||
f = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.Add(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class JavaArguments : ArgumentsWithPlaceholders
|
|
||||||
{
|
|
||||||
private static readonly string[] _initial_arguments =
|
|
||||||
[
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
private static readonly string[] _enabled_features =
|
|
||||||
[
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
public JavaArguments(MinecraftVersionDescriptor d)
|
|
||||||
{
|
|
||||||
raw_args.AddRange(_initial_arguments);
|
|
||||||
if (d.arguments is not null)
|
|
||||||
{
|
|
||||||
foreach (var av in d.arguments.jvm)
|
|
||||||
{
|
|
||||||
if(Буржуазия.CheckRules(av.rules, _enabled_features))
|
|
||||||
raw_args.Add(av.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GameArguments : ArgumentsWithPlaceholders
|
|
||||||
{
|
|
||||||
private static readonly string[] _enabled_features =
|
|
||||||
[
|
|
||||||
"has_custom_resolution"
|
|
||||||
];
|
|
||||||
|
|
||||||
public GameArguments(MinecraftVersionDescriptor d)
|
|
||||||
{
|
|
||||||
if (d.minecraftArguments is not null)
|
|
||||||
{
|
|
||||||
raw_args.AddRange(d.minecraftArguments.SplitToList(' ', quot: '"'));
|
|
||||||
}
|
|
||||||
else if (d.arguments is not null)
|
|
||||||
{
|
|
||||||
foreach (var av in d.arguments.game)
|
|
||||||
{
|
|
||||||
if(Буржуазия.CheckRules(av.rules, _enabled_features))
|
|
||||||
raw_args.Add(av.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -2,11 +2,6 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Млаумчерб.Клиент", "Млаумчерб.Клиент\Млаумчерб.Клиент.csproj", "{9B9D8B05-255F-49C3-89EC-3F43A66491D3}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Млаумчерб.Клиент", "Млаумчерб.Клиент\Млаумчерб.Клиент.csproj", "{9B9D8B05-255F-49C3-89EC-3F43A66491D3}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionFolder", "SolutionFolder", "{A3217C18-CC0D-4CE8-9C48-1BDEC1E1B333}"
|
|
||||||
ProjectSection(SolutionItems) = preProject
|
|
||||||
nuget.config = nuget.config
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user