From 772c893afe82b3029b26f31dc5d471cf41c8be09 Mon Sep 17 00:00:00 2001 From: Color_yr <26276037+Coloryr@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:41:11 +0800 Subject: [PATCH] =?UTF-8?q?up=20=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ColorMC.Core/Asm/NettyServer.cs | 86 ++--- src/ColorMC.Core/CoreMain.cs | 46 ++- src/ColorMC.Core/Game/GameHandel.cs | 24 ++ src/ColorMC.Core/Game/GameLaunch.cs | 149 ++------ src/ColorMC.Core/Helpers/UrlHelper.cs | 1 - src/ColorMC.Core/Net/Apis/ForgeAPI.cs | 1 - src/ColorMC.Core/Objs/VersionObj.cs | 8 +- src/ColorMC.Core/Utils/Comparer.cs | 1 - src/ColorMC.Gui/App.axaml.cs | 21 -- src/ColorMC.Gui/ColorMC.Gui.csproj | 6 + .../Resource/Language/gui_zh-cn.json | 1 + .../JoystickSettingControl.axaml} | 13 +- .../Main/JoystickSettingControl.axaml.cs | 11 + .../UI/Controls/Main/MainControl.axaml | 3 + src/ColorMC.Gui/UI/Flyouts/MainFlyout.cs | 37 +- .../Model/Custom/CustomControlPanelModel.cs | 2 +- .../UI/Model/GameLog/GameLogTabModel.cs | 2 +- .../UI/Model/Items/GameItemModel.cs | 13 + .../UI/Model/Items/InputAxisButtonModel.cs | 10 +- .../JoystickSettingModel.cs} | 21 +- src/ColorMC.Gui/UI/Model/Main/MainModel.cs | 2 +- .../UI/Model/NetFrp/NetFrpTab4Model.cs | 1 - .../UI/Model/ServerPack/ServerPackModel.cs | 2 - .../UI/Model/Setting/SettingModel.cs | 2 +- .../UI/Model/Setting/SettingTab8Model.cs | 1 - src/ColorMC.Gui/UIBinding/BaseBinding.cs | 343 ++++++++---------- src/ColorMC.Gui/UIBinding/GameBinding.cs | 4 +- src/ColorMC.Gui/UIBinding/WebBinding.cs | 1 - .../GameJoystick.cs} | 176 +++++---- .../{Joystick => Utils}/GameSocket.cs | 16 +- src/ColorMC.Gui/Utils/Hook/INative.cs | 8 +- src/ColorMC.Gui/Utils/Hook/Win32Native.cs | 9 +- .../{Joystick => Utils}/InputControl.cs | 2 +- src/ColorMC.Launcher/Program.cs | 2 +- src/ColorMC.Test/Program.cs | 1 - src/ColorMC.Test/TestItem.cs | 16 +- 36 files changed, 481 insertions(+), 561 deletions(-) create mode 100644 src/ColorMC.Core/Game/GameHandel.cs rename src/ColorMC.Gui/UI/Controls/{GameWindow/GameWindowControl.axaml => Main/JoystickSettingControl.axaml} (81%) create mode 100644 src/ColorMC.Gui/UI/Controls/Main/JoystickSettingControl.axaml.cs rename src/ColorMC.Gui/UI/Model/{ControlSelectModel.cs => Main/JoystickSettingModel.cs} (82%) rename src/ColorMC.Gui/{UI/Controls/GameWindow/GameWindowControl.axaml.cs => Utils/GameJoystick.cs} (85%) rename src/ColorMC.Gui/{Joystick => Utils}/GameSocket.cs (86%) rename src/ColorMC.Gui/{Joystick => Utils}/InputControl.cs (98%) diff --git a/src/ColorMC.Core/Asm/NettyServer.cs b/src/ColorMC.Core/Asm/NettyServer.cs index 581afc1c7..00ecac98f 100644 --- a/src/ColorMC.Core/Asm/NettyServer.cs +++ b/src/ColorMC.Core/Asm/NettyServer.cs @@ -2,7 +2,6 @@ using DotNetty.Transport.Bootstrapping; using DotNetty.Transport.Channels; using DotNetty.Transport.Channels.Sockets; -using System.Collections.Concurrent; using System.Net; using System.Net.NetworkInformation; @@ -10,42 +9,29 @@ namespace ColorMC.Core.Asm; public static class NettyServer { - private static IEventLoopGroup bossGroup; - private static IEventLoopGroup workerGroup; - private static ServerBootstrap bootstrap; - private static IChannel boundChannel; + private static IEventLoopGroup s_bossGroup; + private static IEventLoopGroup s_workerGroup; + private static ServerBootstrap s_bootstrap; + private static IChannel s_channel; - private static List channels = []; + private static readonly List s_channels = []; - public static Action? GetPack; - - /// - /// 获取操作系统已用的端口号 - /// - /// - public static List PortIsUsed() + private static List PortIsUsed() { - //获取本地计算机的网络连接和通信统计数据的信息 - IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); - - //返回本地计算机上的所有Tcp监听程序 - IPEndPoint[] ipsTCP = ipGlobalProperties.GetActiveTcpListeners(); - - //返回本地计算机上的所有UDP监听程序 - IPEndPoint[] ipsUDP = ipGlobalProperties.GetActiveUdpListeners(); - - //返回本地计算机上的Internet协议版本4(IPV4 传输控制协议(TCP)连接的信息。 - TcpConnectionInformation[] tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections(); + var ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); + var ipsTCP = ipGlobalProperties.GetActiveTcpListeners(); + var ipsUDP = ipGlobalProperties.GetActiveUdpListeners(); + var tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections(); var allPorts = new List(); - foreach (IPEndPoint ep in ipsTCP) allPorts.Add(ep.Port); - foreach (IPEndPoint ep in ipsUDP) allPorts.Add(ep.Port); - foreach (TcpConnectionInformation conn in tcpConnInfoArray) allPorts.Add(conn.LocalEndPoint.Port); + foreach (var ep in ipsTCP) allPorts.Add(ep.Port); + foreach (var ep in ipsUDP) allPorts.Add(ep.Port); + foreach (var conn in tcpConnInfoArray) allPorts.Add(conn.LocalEndPoint.Port); return allPorts; } - public static int GetFirstAvailablePort() + private static int GetFirstAvailablePort() { var portUsed = PortIsUsed(); if (portUsed.Count > 50000) @@ -66,18 +52,18 @@ public static int GetFirstAvailablePort() public static async Task RunServerAsync() { - if (boundChannel != null) + if (s_channel != null) { - return (boundChannel.LocalAddress as IPEndPoint)!.Port; + return (s_channel.LocalAddress as IPEndPoint)!.Port; } - bossGroup = new MultithreadEventLoopGroup(1); - workerGroup = new MultithreadEventLoopGroup(); + s_bossGroup = new MultithreadEventLoopGroup(1); + s_workerGroup = new MultithreadEventLoopGroup(); try { - bootstrap = new(); - bootstrap.Group(bossGroup, workerGroup); - bootstrap.Channel(); - bootstrap + s_bootstrap = new(); + s_bootstrap.Group(s_bossGroup, s_workerGroup); + s_bootstrap.Channel(); + s_bootstrap .ChildHandler(new ActionChannelInitializer(channel => { IChannelPipeline pipeline = channel.Pipeline; @@ -85,7 +71,7 @@ public static async Task RunServerAsync() })); int port = GetFirstAvailablePort(); - boundChannel = await bootstrap.BindAsync(port); + s_channel = await s_bootstrap.BindAsync(port); ColorMCCore.Stop += Stop; return port; @@ -96,17 +82,21 @@ public static async Task RunServerAsync() } } - public static async void Stop() + private static async void Stop() { - await boundChannel.CloseAsync(); + await s_channel.CloseAsync(); await Task.WhenAll( - bossGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1)), - workerGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1))); + s_bossGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1)), + s_workerGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1))); } + /// + /// 发送数据到所有客户端 + /// + /// public static void SendMessage(IByteBuffer byteBuffer) { - foreach (var item in channels.ToArray()) + foreach (var item in s_channels.ToArray()) { try { @@ -116,29 +106,29 @@ public static void SendMessage(IByteBuffer byteBuffer) } } catch - { - + { + } } } - public class EchoServerHandler : ChannelHandlerAdapter + private class EchoServerHandler : ChannelHandlerAdapter { public override void ChannelActive(IChannelHandlerContext ctx) { - channels.Add(ctx.Channel); + s_channels.Add(ctx.Channel); } public override void ChannelInactive(IChannelHandlerContext ctx) { - channels.Remove(ctx.Channel); + s_channels.Remove(ctx.Channel); } public override void ChannelRead(IChannelHandlerContext context, object message) { if (message is IByteBuffer buffer) { - GetPack?.Invoke(buffer); + ColorMCCore.NettyPack?.Invoke(context.Channel, buffer); } } diff --git a/src/ColorMC.Core/CoreMain.cs b/src/ColorMC.Core/CoreMain.cs index d02181636..586f2c03d 100644 --- a/src/ColorMC.Core/CoreMain.cs +++ b/src/ColorMC.Core/CoreMain.cs @@ -1,11 +1,15 @@ using ColorMC.Core.Config; using ColorMC.Core.Downloader; +using ColorMC.Core.Game; using ColorMC.Core.Helpers; using ColorMC.Core.LaunchPath; using ColorMC.Core.Net; using ColorMC.Core.Objs; using ColorMC.Core.Objs.Login; using ColorMC.Core.Utils; +using DotNetty.Buffers; +using DotNetty.Transport.Channels; +using System.Collections.Concurrent; using System.Diagnostics; namespace ColorMC.Core; @@ -69,10 +73,6 @@ public static class ColorMCCore /// public static event Action? OnError; /// - /// 游戏进程日志回调 - /// - public static event Action? OnProcessLog; - /// /// 游戏日志回调 /// public static event Action? OnGameLog; @@ -81,6 +81,16 @@ public static class ColorMCCore /// public static event Action? OnLanguageReload; + /// + /// 收到游戏数据包 + /// + public static Action? NettyPack; + + /// + /// 游戏退出事件 + /// + public static event Action GameExit; + /// /// 手机端启动 /// @@ -120,6 +130,9 @@ public static class ColorMCCore /// internal static event Action? Stop; + internal static ConcurrentDictionary Games = []; + + /// /// 初始化阶段1 /// @@ -174,13 +187,30 @@ public static void GameLog(GameSettingObj obj, string? text) OnGameLog?.Invoke(obj, text); } - public static void GameLog(Process? process, string? text) + public static void LanguageReload(LanguageType type) { - OnProcessLog?.Invoke(process, text); + OnLanguageReload?.Invoke(type); } - public static void LanguageReload(LanguageType type) + public static void OnGameExit(GameSettingObj obj, LoginObj obj1, int code) { - OnLanguageReload?.Invoke(type); + Games.TryRemove(obj.UUID, out _); + GameExit?.Invoke(obj, obj1, code); + } + + public static void KillGame(string uuid) + { + if (Games.TryGetValue(uuid, out var handel)) + { + handel.Kill(); + } + } + + internal static void AddGame(string uuid, IGameHandel handel) + { + if (!Games.TryAdd(uuid, handel)) + { + Games[uuid] = handel; + } } } \ No newline at end of file diff --git a/src/ColorMC.Core/Game/GameHandel.cs b/src/ColorMC.Core/Game/GameHandel.cs new file mode 100644 index 000000000..39caeb97b --- /dev/null +++ b/src/ColorMC.Core/Game/GameHandel.cs @@ -0,0 +1,24 @@ +using System.Diagnostics; + +namespace ColorMC.Core.Game; + +public interface IGameHandel +{ + public string UUID { get; } + public bool IsExit { get; } + public IntPtr Handel { get; } + public void Kill(); +} + +public class DesktopGameHandel(Process process, string uuid) : IGameHandel +{ + public Process Process => process; + public string UUID => uuid; + public bool IsExit => process.HasExited; + public IntPtr Handel => process.MainWindowHandle; + + public void Kill() + { + process.Kill(); + } +} \ No newline at end of file diff --git a/src/ColorMC.Core/Game/GameLaunch.cs b/src/ColorMC.Core/Game/GameLaunch.cs index b5770067a..292160349 100644 --- a/src/ColorMC.Core/Game/GameLaunch.cs +++ b/src/ColorMC.Core/Game/GameLaunch.cs @@ -11,7 +11,6 @@ using Newtonsoft.Json.Linq; using System.Diagnostics; using System.Text; -using static ColorMC.Core.Objs.Minecraft.GameArgObj.Arguments; namespace ColorMC.Core.Game; @@ -28,11 +27,6 @@ public static class Launch public const string GAME_DIR = "%GAME_DIR%"; public const string GAME_BASE_DIR = "%GAME_BASE_DIR%"; - /// - /// 取消启动 - /// - private static CancellationToken s_cancel; - /// /// 获取Forge安装参数 /// @@ -80,7 +74,7 @@ public static List MakeInstallForgeArg(this GameSettingObj obj, bool v2) jvm.Add("-cp"); jvm.Add(cp); - var arg = MakeV2GameArg(obj); + //var arg = MakeV2GameArg(obj); jvm.Add("io.github.zekerzhayard.forgewrapper.installer.Main"); var forge1 = obj.Loader == Loaders.NeoForge @@ -423,7 +417,6 @@ private static async Task> JvmArgAsync(GameSettingObj obj, bool v2, GameHelper.ReadyColorMCASM(); jvm.Add("-Dcolormc.mixin.port=" + mixinport); jvm.Add("-Dcolormc.mixin.uuid=" + obj.UUID); - jvm.Add("-Dcolormc.mixin.jar=" + GameHelper.ColorMCASM); jvm.Add($"-javaagent:{GameHelper.ColorMCASM}"); } @@ -1006,22 +999,6 @@ private static async Task> MakeArgAsync(GameSettingObj obj, LoginOb return list; } - /// - /// 进程日志 - /// - private static void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e) - { - ColorMCCore.GameLog(sender as Process, e.Data); - } - - /// - /// 进程日志 - /// - private static void Process_OutputDataReceived(object sender, DataReceivedEventArgs e) - { - ColorMCCore.GameLog(sender as Process, e.Data); - } - /// /// 启动游戏 /// @@ -1030,14 +1007,13 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA /// 使用的Java /// 启动错误 /// - public static async Task StartGameAsync(this GameSettingObj obj, LoginObj login, + public static async Task StartGameAsync(this GameSettingObj obj, LoginObj login, WorldObj? world, ColorMCCore.Request request, ColorMCCore.LaunchP pre, ColorMCCore.UpdateState state, ColorMCCore.UpdateSelect select, ColorMCCore.NoJava nojava, ColorMCCore.LoginFail loginfail, ColorMCCore.GameLaunch update2, int? mixinport, CancellationToken token) { - s_cancel = token; var stopwatch = new Stopwatch(); //版本号检测 @@ -1081,7 +1057,7 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA login.Save(); } - if (s_cancel.IsCancellationRequested) + if (token.IsCancellationRequested) { return null; } @@ -1116,7 +1092,7 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA //检查游戏文件 stopwatch.Restart(); stopwatch.Start(); - var res = await CheckHelpers.CheckGameFileAsync(obj, login, update2, s_cancel); + var res = await CheckHelpers.CheckGameFileAsync(obj, login, update2, token); stopwatch.Stop(); temp = string.Format(LanguageHelper.Get("Core.Launch.Info5"), obj.Name, stopwatch.Elapsed.ToString()); @@ -1183,7 +1159,7 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA path = jvm.GetPath(); } - if (s_cancel.IsCancellationRequested) + if (token.IsCancellationRequested) { return null; } @@ -1217,7 +1193,7 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA ColorMCCore.GameLog(obj, LanguageHelper.Get("Core.Launch.Info3")); ColorMCCore.GameLog(obj, path); - if (s_cancel.IsCancellationRequested) + if (token.IsCancellationRequested) { return null; } @@ -1269,7 +1245,7 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA } } - if (s_cancel.IsCancellationRequested) + if (token.IsCancellationRequested) { return null; } @@ -1314,7 +1290,7 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA res1.BeginOutputReadLine(); res1.BeginErrorReadLine(); - await res1.WaitForExitAsync(s_cancel); + await res1.WaitForExitAsync(token); stopwatch.Stop(); string temp1 = string.Format(LanguageHelper.Get("Core.Launch.Info8"), obj.Name, stopwatch.Elapsed.ToString()); @@ -1344,7 +1320,7 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA } } - if (s_cancel.IsCancellationRequested) + if (token.IsCancellationRequested) { return null; } @@ -1393,6 +1369,11 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA } } + if (token.IsCancellationRequested) + { + return null; + } + //启动进程 Process? process; @@ -1428,8 +1409,19 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; - process.OutputDataReceived += Process_OutputDataReceived; - process.ErrorDataReceived += Process_ErrorDataReceived; + process.OutputDataReceived += (a, b) => + { + ColorMCCore.GameLog(obj, b.Data); + }; + process.ErrorDataReceived += (a, b) => + { + ColorMCCore.GameLog(obj, b.Data); + }; + process.Exited += (a, b) => + { + ColorMCCore.OnGameExit(obj, login, process.ExitCode); + process.Dispose(); + }; process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); @@ -1440,6 +1432,9 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA ColorMCCore.GameLog(obj, temp); Logs.Info(temp); + var handel = new DesktopGameHandel(process, obj.UUID); + ColorMCCore.AddGame(obj.UUID, handel); + //启动后执行 if ((obj.JvmArg?.LaunchPost == true || ConfigUtils.Config.DefaultJvmArg.LaunchPost)) { @@ -1474,88 +1469,6 @@ private static void Process_OutputDataReceived(object sender, DataReceivedEventA } } - return process; + return handel; } - - //public delegate int DLaunch(int argc, - // string[] argv, /* main argc, argc */ - // int jargc, string[] jargv, /* java args */ - // int appclassc, string[] appclassv, /* app classpath */ - // string fullversion, /* full version defined */ - // string dotversion, /* dot version defined */ - // string pname, /* program name */ - // string lname, /* launcher name */ - // bool javaargs, /* JAVA_ARGS */ - // bool cpwildcard, /* classpath wildcard*/ - // bool javaw, /* windows-only javaw */ - // int ergo /* ergonomics class policy */ - //); - - //private static int s_argLength; - //private static string[] s_args; - - ///// - ///// native启动 - ///// - ///// Java信息 - ///// 启动参数 - //public static int NativeLaunch(JavaInfo info, List args) - //{ - // string path; - // if (SystemInfo.Os == OsType.Android) - // { - // path = info.Path; - // } - // else - // { - // var info1 = new FileInfo(info.Path); - // path = info1.Directory?.Parent?.FullName!; - // } - - // var local = SystemInfo.Os switch - // { - // OsType.Windows => PathHelper.GetFile(path, "jli.dll"), - // OsType.Linux => PathHelper.GetFile(path, "libjli.so"), - // OsType.MacOS => PathHelper.GetFile(path, "libjli.dylib"), - // OsType.Android => PathHelper.GetFile(path, "libjli.so"), - // _ => throw new NotImplementedException(), - // }; - // if (File.Exists(local)) - // { - // local = Path.GetFullPath(local); - // } - - // //加载运行库 - // var temp = NativeLoader.Loader.LoadLibrary(local); - // var temp1 = NativeLoader.Loader.GetProcAddress(temp, "JLI_Launch", false); - // var inv = Marshal.GetDelegateForFunctionPointer(temp1); - - // var args1 = new string[args.Count + 1]; - // args1[0] = "java"; - - // for (int i = 1; i < args1.Length; i++) - // { - // args1[i] = args[i - 1]; - // } - - // s_argLength = args1.Length; - // s_args = args1; - - // //启动游戏 - // try - // { - // var res = inv(s_argLength, s_args, 0, null!, 0, null!, - // info.Version, "1.8", "java", "java", false, true, false, 0); - - // var res1 = NativeLoader.Loader.CloseLibrary(temp); - - // return res; - // } - // catch (Exception e) - // { - // ColorMCCore.OnError?.Invoke("Error", e, false); - // } - - // return -1; - //} } diff --git a/src/ColorMC.Core/Helpers/UrlHelper.cs b/src/ColorMC.Core/Helpers/UrlHelper.cs index 05bbf0504..6de2f18b4 100644 --- a/src/ColorMC.Core/Helpers/UrlHelper.cs +++ b/src/ColorMC.Core/Helpers/UrlHelper.cs @@ -1,7 +1,6 @@ using ColorMC.Core.Net; using ColorMC.Core.Objs; using ColorMC.Core.Objs.Login; -using ColorMC.Core.Objs.Minecraft; using ColorMC.Core.Objs.OptiFine; using ColorMC.Core.Objs.ServerPack; using ColorMC.Core.Utils; diff --git a/src/ColorMC.Core/Net/Apis/ForgeAPI.cs b/src/ColorMC.Core/Net/Apis/ForgeAPI.cs index 43a6a7759..f1f95347b 100644 --- a/src/ColorMC.Core/Net/Apis/ForgeAPI.cs +++ b/src/ColorMC.Core/Net/Apis/ForgeAPI.cs @@ -3,7 +3,6 @@ using ColorMC.Core.Objs.Loader; using ColorMC.Core.Utils; using Newtonsoft.Json; -using System.Text.RegularExpressions; using System.Xml; namespace ColorMC.Core.Net.Apis; diff --git a/src/ColorMC.Core/Objs/VersionObj.cs b/src/ColorMC.Core/Objs/VersionObj.cs index 0e665cc45..611252b52 100644 --- a/src/ColorMC.Core/Objs/VersionObj.cs +++ b/src/ColorMC.Core/Objs/VersionObj.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ColorMC.Core.Objs; +namespace ColorMC.Core.Objs; public record VersionStrObj { diff --git a/src/ColorMC.Core/Utils/Comparer.cs b/src/ColorMC.Core/Utils/Comparer.cs index 4d2817e7c..bbc03c339 100644 --- a/src/ColorMC.Core/Utils/Comparer.cs +++ b/src/ColorMC.Core/Utils/Comparer.cs @@ -1,4 +1,3 @@ -using ColorMC.Core.Helpers; using ColorMC.Core.Objs; using ColorMC.Core.Objs.CurseForge; using ColorMC.Core.Objs.Minecraft; diff --git a/src/ColorMC.Gui/App.axaml.cs b/src/ColorMC.Gui/App.axaml.cs index c05807c94..3eb25acb4 100644 --- a/src/ColorMC.Gui/App.axaml.cs +++ b/src/ColorMC.Gui/App.axaml.cs @@ -26,7 +26,6 @@ using ColorMC.Gui.UI.Controls.GameEdit; using ColorMC.Gui.UI.Controls.GameExport; using ColorMC.Gui.UI.Controls.GameLog; -using ColorMC.Gui.UI.Controls.GameWindow; using ColorMC.Gui.UI.Controls.Main; using ColorMC.Gui.UI.Controls.NetFrp; using ColorMC.Gui.UI.Controls.ServerPack; @@ -87,7 +86,6 @@ public App() public readonly static Dictionary GameLogWindows = []; public readonly static Dictionary GameExportWindows = []; public readonly static Dictionary GameCloudWindows = []; - public readonly static Dictionary GameWindows = []; public static readonly SelfCrossFade CrossFade300 = new(TimeSpan.FromMilliseconds(300)); public static readonly SelfCrossFade CrossFade200 = new(TimeSpan.FromMilliseconds(200)); @@ -720,25 +718,6 @@ public static void ShowNetFrp() } } - public static void ShowGameWindow(GameSettingObj obj, Process process) - { - if (SystemInfo.Os != OsType.Windows) - { - return; - } - - if (GameWindows.TryGetValue(obj.UUID, out var win1)) - { - win1.Window.TopActivate(); - } - else - { - var con = new GameWindowControl(obj, process); - GameWindows.Add(obj.UUID, con); - AWindow(con); - } - } - public static void ShowError(string? data, Exception? e, bool close = false) { Dispatcher.UIThread.Post(() => diff --git a/src/ColorMC.Gui/ColorMC.Gui.csproj b/src/ColorMC.Gui/ColorMC.Gui.csproj index 0d26db9c1..f98a48e54 100644 --- a/src/ColorMC.Gui/ColorMC.Gui.csproj +++ b/src/ColorMC.Gui/ColorMC.Gui.csproj @@ -318,8 +318,14 @@ + + JoystickSettingControl.axaml + AddUserControl.axaml + + + diff --git a/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json b/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json index 3814666c1..7f96ffa27 100644 --- a/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json +++ b/src/ColorMC.Gui/Resource/Language/gui_zh-cn.json @@ -30,6 +30,7 @@ "MainWindow.Flyouts.Text13": "强行停止", "MainWindow.Flyouts.Text14": "云同步", "MainWindow.Flyouts.Text15": "创建快捷启动", + "MainWindow.Flyouts.Text16": "手柄设置", "MainWindow.Live2d.Flyouts.Text1": "播放动画", "MainWindow.Live2d.Flyouts.Text2": "切换表情", "MainWindow.Live2d.Error1": "Live2D模型不存在", diff --git a/src/ColorMC.Gui/UI/Controls/GameWindow/GameWindowControl.axaml b/src/ColorMC.Gui/UI/Controls/Main/JoystickSettingControl.axaml similarity index 81% rename from src/ColorMC.Gui/UI/Controls/GameWindow/GameWindowControl.axaml rename to src/ColorMC.Gui/UI/Controls/Main/JoystickSettingControl.axaml index 9ca0c140d..7e9bff6a3 100644 --- a/src/ColorMC.Gui/UI/Controls/GameWindow/GameWindowControl.axaml +++ b/src/ColorMC.Gui/UI/Controls/Main/JoystickSettingControl.axaml @@ -1,13 +1,13 @@ +