From c1f2c84e27f22a8b807838422686baa3fff2f171 Mon Sep 17 00:00:00 2001 From: Mili Date: Tue, 30 Aug 2022 23:51:07 +0800 Subject: [PATCH] Update Project --- FunGame.Core.Api/FunGame.Core.Api.csproj | 12 + .../Interface/ServerInterface.cs | 5 +- .../Model}/Entity/ActiveItem.cs | 2 +- .../Model}/Entity/ActiveSkill.cs | 2 +- .../Model}/Entity/Character.cs | 4 +- .../Model}/Entity/CharacterStatistics.cs | 2 +- .../Model}/Entity/GameStatistics.cs | 4 +- .../Model}/Entity/Item.cs | 2 +- .../Model}/Entity/PassiveItem.cs | 2 +- .../Model}/Entity/PassiveSkill.cs | 2 +- .../Model}/Entity/Room.cs | 2 +- .../Model}/Entity/Skill.cs | 2 +- .../Model}/Entity/Stock.cs | 2 +- .../Model}/Entity/User.cs | 2 +- .../Model}/Entity/UserStatistics.cs | 2 +- FunGame.Core.Api/Model/Enum/CommonEnums.cs | 97 ++++++++ .../Model}/Enum/SocketEnums.cs | 2 +- .../Util}/AssemblyHelper.cs | 34 ++- .../Util}/INIHelper.cs | 2 +- FunGame.Core/FunGame.Core.csproj | 5 + .../FunGame.Desktop.csproj | 5 + {FunGame => FunGame.Desktop}/Images/back.jpg | Bin {FunGame => FunGame.Desktop}/Images/exit.png | Bin .../Images/favicon.ico | Bin {FunGame => FunGame.Desktop}/Images/green.png | Bin {FunGame => FunGame.Desktop}/Images/logo.ico | Bin {FunGame => FunGame.Desktop}/Images/min.png | Bin {FunGame => FunGame.Desktop}/Images/red.png | Bin {FunGame => FunGame.Desktop}/Images/send.png | Bin .../Models/Component/ExitButton.Designer.cs | 2 +- .../Models/Component/ExitButton.cs | 6 +- .../Models/Component/ShowMessage.Designer.cs | 8 +- .../Models/Component/ShowMessage.cs | 4 +- .../Models/Component/ShowMessage.resx | 0 .../Models/Component/TextArea.Designer.cs | 2 +- .../Models/Component/TextArea.cs | 2 +- .../Models/Component/TextArea.resx | 0 .../Component/TransparentRect.Designer.cs | 2 +- .../Models/Component/TransparentRect.cs | 2 +- .../Models/Config/Config.cs | 6 +- .../Models/Config/Usercfg.cs | 2 +- .../Models/Enum/CommonEnums.cs | 4 +- FunGame.Desktop/Models/Enum/SocketEnums.cs | 27 +++ .../Properties/Resources.Designer.cs | 4 +- .../Properties/Resources.resx | 0 .../UI/Main/Main.Designer.cs | 36 +-- {FunGame => FunGame.Desktop}/UI/Main/Main.cs | 211 +++++++++++------- .../UI/Main/Main.resx | 105 +++++++++ {FunGame => FunGame.Desktop}/UI/Start.cs | 2 +- .../Utils}/WebHelper.cs | 13 +- FunGame.Plugin/FunGame.Plugin.csproj | 12 + FunGame.sln | 24 +- 52 files changed, 508 insertions(+), 158 deletions(-) create mode 100644 FunGame.Core.Api/FunGame.Core.Api.csproj rename {FunGame.Core => FunGame.Core.Api}/Interface/ServerInterface.cs (83%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/ActiveItem.cs (88%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/ActiveSkill.cs (95%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/Character.cs (96%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/CharacterStatistics.cs (97%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/GameStatistics.cs (96%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/Item.cs (92%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/PassiveItem.cs (88%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/PassiveSkill.cs (95%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/Room.cs (95%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/Skill.cs (90%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/Stock.cs (92%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/User.cs (96%) rename {FunGame/Models => FunGame.Core.Api/Model}/Entity/UserStatistics.cs (97%) create mode 100644 FunGame.Core.Api/Model/Enum/CommonEnums.cs rename {FunGame/Models => FunGame.Core.Api/Model}/Enum/SocketEnums.cs (94%) rename {FunGame/Utils/DataHelper => FunGame.Core.Api/Util}/AssemblyHelper.cs (72%) rename {FunGame/Utils/DataHelper => FunGame.Core.Api/Util}/INIHelper.cs (98%) rename FunGame/FunGame.csproj => FunGame.Desktop/FunGame.Desktop.csproj (88%) rename {FunGame => FunGame.Desktop}/Images/back.jpg (100%) rename {FunGame => FunGame.Desktop}/Images/exit.png (100%) rename {FunGame => FunGame.Desktop}/Images/favicon.ico (100%) rename {FunGame => FunGame.Desktop}/Images/green.png (100%) rename {FunGame => FunGame.Desktop}/Images/logo.ico (100%) rename {FunGame => FunGame.Desktop}/Images/min.png (100%) rename {FunGame => FunGame.Desktop}/Images/red.png (100%) rename {FunGame => FunGame.Desktop}/Images/send.png (100%) rename {FunGame => FunGame.Desktop}/Models/Component/ExitButton.Designer.cs (95%) rename {FunGame => FunGame.Desktop}/Models/Component/ExitButton.cs (92%) rename {FunGame => FunGame.Desktop}/Models/Component/ShowMessage.Designer.cs (95%) rename {FunGame => FunGame.Desktop}/Models/Component/ShowMessage.cs (98%) rename {FunGame => FunGame.Desktop}/Models/Component/ShowMessage.resx (100%) rename {FunGame => FunGame.Desktop}/Models/Component/TextArea.Designer.cs (95%) rename {FunGame => FunGame.Desktop}/Models/Component/TextArea.cs (98%) rename {FunGame => FunGame.Desktop}/Models/Component/TextArea.resx (100%) rename {FunGame => FunGame.Desktop}/Models/Component/TransparentRect.Designer.cs (95%) rename {FunGame => FunGame.Desktop}/Models/Component/TransparentRect.cs (98%) rename {FunGame => FunGame.Desktop}/Models/Config/Config.cs (94%) rename {FunGame => FunGame.Desktop}/Models/Config/Usercfg.cs (95%) rename {FunGame => FunGame.Desktop}/Models/Enum/CommonEnums.cs (97%) create mode 100644 FunGame.Desktop/Models/Enum/SocketEnums.cs rename {FunGame => FunGame.Desktop}/Properties/Resources.Designer.cs (97%) rename {FunGame => FunGame.Desktop}/Properties/Resources.resx (100%) rename {FunGame => FunGame.Desktop}/UI/Main/Main.Designer.cs (96%) rename {FunGame => FunGame.Desktop}/UI/Main/Main.cs (84%) rename {FunGame => FunGame.Desktop}/UI/Main/Main.resx (94%) rename {FunGame => FunGame.Desktop}/UI/Start.cs (91%) rename {FunGame/Utils/WebHelper => FunGame.Desktop/Utils}/WebHelper.cs (97%) create mode 100644 FunGame.Plugin/FunGame.Plugin.csproj diff --git a/FunGame.Core.Api/FunGame.Core.Api.csproj b/FunGame.Core.Api/FunGame.Core.Api.csproj new file mode 100644 index 0000000..f0d08ad --- /dev/null +++ b/FunGame.Core.Api/FunGame.Core.Api.csproj @@ -0,0 +1,12 @@ + + + + net6.0-windows + enable + enable + ..\bin + Milimoe + Milimoe + + + diff --git a/FunGame.Core/Interface/ServerInterface.cs b/FunGame.Core.Api/Interface/ServerInterface.cs similarity index 83% rename from FunGame.Core/Interface/ServerInterface.cs rename to FunGame.Core.Api/Interface/ServerInterface.cs index ce13dcc..bab149d 100644 --- a/FunGame.Core/Interface/ServerInterface.cs +++ b/FunGame.Core.Api/Interface/ServerInterface.cs @@ -4,10 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Core.Interface +namespace FunGame.Core.Api.Interface { /** - * 接口需要在FunGame.Core.Implement中创建新的类实现 + * 接口需要在FunGame.Core项目中Implement文件夹创建新的类实现 * 参考: * using FunGame.Core.Interface; @@ -28,7 +28,6 @@ namespace FunGame.Core.Interface public interface ServerInterface { - // 实现类:ServerInterfaceImpl public string RemoteServerIP(); } } diff --git a/FunGame/Models/Entity/ActiveItem.cs b/FunGame.Core.Api/Model/Entity/ActiveItem.cs similarity index 88% rename from FunGame/Models/Entity/ActiveItem.cs rename to FunGame.Core.Api/Model/Entity/ActiveItem.cs index 144b53c..7f9be78 100644 --- a/FunGame/Models/Entity/ActiveItem.cs +++ b/FunGame.Core.Api/Model/Entity/ActiveItem.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class ActiveItem : Item { diff --git a/FunGame/Models/Entity/ActiveSkill.cs b/FunGame.Core.Api/Model/Entity/ActiveSkill.cs similarity index 95% rename from FunGame/Models/Entity/ActiveSkill.cs rename to FunGame.Core.Api/Model/Entity/ActiveSkill.cs index 61392f2..f3e3f65 100644 --- a/FunGame/Models/Entity/ActiveSkill.cs +++ b/FunGame.Core.Api/Model/Entity/ActiveSkill.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class ActiveSkill : Skill { diff --git a/FunGame/Models/Entity/Character.cs b/FunGame.Core.Api/Model/Entity/Character.cs similarity index 96% rename from FunGame/Models/Entity/Character.cs rename to FunGame.Core.Api/Model/Entity/Character.cs index 04135b3..7d9f74c 100644 --- a/FunGame/Models/Entity/Character.cs +++ b/FunGame.Core.Api/Model/Entity/Character.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class Character { @@ -36,7 +36,7 @@ namespace FunGame.Models.Entity public Character() { - + } } } diff --git a/FunGame/Models/Entity/CharacterStatistics.cs b/FunGame.Core.Api/Model/Entity/CharacterStatistics.cs similarity index 97% rename from FunGame/Models/Entity/CharacterStatistics.cs rename to FunGame.Core.Api/Model/Entity/CharacterStatistics.cs index a611f4b..eddaaf8 100644 --- a/FunGame/Models/Entity/CharacterStatistics.cs +++ b/FunGame.Core.Api/Model/Entity/CharacterStatistics.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class CharacterStatistics { diff --git a/FunGame/Models/Entity/GameStatistics.cs b/FunGame.Core.Api/Model/Entity/GameStatistics.cs similarity index 96% rename from FunGame/Models/Entity/GameStatistics.cs rename to FunGame.Core.Api/Model/Entity/GameStatistics.cs index e13409a..b4f7aac 100644 --- a/FunGame/Models/Entity/GameStatistics.cs +++ b/FunGame.Core.Api/Model/Entity/GameStatistics.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class GameStatistics { @@ -29,7 +29,7 @@ namespace FunGame.Models.Entity public GameStatistics() { - + } } } diff --git a/FunGame/Models/Entity/Item.cs b/FunGame.Core.Api/Model/Entity/Item.cs similarity index 92% rename from FunGame/Models/Entity/Item.cs rename to FunGame.Core.Api/Model/Entity/Item.cs index 11cac8b..e484e90 100644 --- a/FunGame/Models/Entity/Item.cs +++ b/FunGame.Core.Api/Model/Entity/Item.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public abstract class Item { diff --git a/FunGame/Models/Entity/PassiveItem.cs b/FunGame.Core.Api/Model/Entity/PassiveItem.cs similarity index 88% rename from FunGame/Models/Entity/PassiveItem.cs rename to FunGame.Core.Api/Model/Entity/PassiveItem.cs index 1d88be2..24e72e5 100644 --- a/FunGame/Models/Entity/PassiveItem.cs +++ b/FunGame.Core.Api/Model/Entity/PassiveItem.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class PassiveItem : Item { diff --git a/FunGame/Models/Entity/PassiveSkill.cs b/FunGame.Core.Api/Model/Entity/PassiveSkill.cs similarity index 95% rename from FunGame/Models/Entity/PassiveSkill.cs rename to FunGame.Core.Api/Model/Entity/PassiveSkill.cs index 8dee862..edf6d99 100644 --- a/FunGame/Models/Entity/PassiveSkill.cs +++ b/FunGame.Core.Api/Model/Entity/PassiveSkill.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class PassiveSkill : Skill { diff --git a/FunGame/Models/Entity/Room.cs b/FunGame.Core.Api/Model/Entity/Room.cs similarity index 95% rename from FunGame/Models/Entity/Room.cs rename to FunGame.Core.Api/Model/Entity/Room.cs index 9b56d23..43f78ff 100644 --- a/FunGame/Models/Entity/Room.cs +++ b/FunGame.Core.Api/Model/Entity/Room.cs @@ -6,7 +6,7 @@ using System.Security.Policy; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class Room { diff --git a/FunGame/Models/Entity/Skill.cs b/FunGame.Core.Api/Model/Entity/Skill.cs similarity index 90% rename from FunGame/Models/Entity/Skill.cs rename to FunGame.Core.Api/Model/Entity/Skill.cs index 4b150f6..d3d8737 100644 --- a/FunGame/Models/Entity/Skill.cs +++ b/FunGame.Core.Api/Model/Entity/Skill.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public abstract class Skill { diff --git a/FunGame/Models/Entity/Stock.cs b/FunGame.Core.Api/Model/Entity/Stock.cs similarity index 92% rename from FunGame/Models/Entity/Stock.cs rename to FunGame.Core.Api/Model/Entity/Stock.cs index 3587f5f..0a33623 100644 --- a/FunGame/Models/Entity/Stock.cs +++ b/FunGame.Core.Api/Model/Entity/Stock.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class Stock { diff --git a/FunGame/Models/Entity/User.cs b/FunGame.Core.Api/Model/Entity/User.cs similarity index 96% rename from FunGame/Models/Entity/User.cs rename to FunGame.Core.Api/Model/Entity/User.cs index 38411a8..a87f7ff 100644 --- a/FunGame/Models/Entity/User.cs +++ b/FunGame.Core.Api/Model/Entity/User.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class User { diff --git a/FunGame/Models/Entity/UserStatistics.cs b/FunGame.Core.Api/Model/Entity/UserStatistics.cs similarity index 97% rename from FunGame/Models/Entity/UserStatistics.cs rename to FunGame.Core.Api/Model/Entity/UserStatistics.cs index 9132c53..43aa107 100644 --- a/FunGame/Models/Entity/UserStatistics.cs +++ b/FunGame.Core.Api/Model/Entity/UserStatistics.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Entity +namespace FunGame.Core.Api.Model.Entity { public class UserStatistics { diff --git a/FunGame.Core.Api/Model/Enum/CommonEnums.cs b/FunGame.Core.Api/Model/Enum/CommonEnums.cs new file mode 100644 index 0000000..00c4251 --- /dev/null +++ b/FunGame.Core.Api/Model/Enum/CommonEnums.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FunGame.Core.Api.Model.Enum +{ + /// + /// ſʵصState Type Result Method + /// FunGame.Core.ApiӿںʵʱҪͬӣInterfaceTypeInterfaceMethod + /// + public static class CommonEnums + { + #region State + + public enum StartMatch_State + { + Matching = 1, + Success = 2, + Enable = 3, + Cancel = 4 + } + + public enum CreateRoom_State + { + Creating = 1, + Success = 2 + } + + public enum RoomState + { + Created = 1, + Gaming = 2, + Close = 3, + Complete = 4 + } + + public enum OnlineState + { + Offline = 1, + Online = 2, + Matching = 3, + InRoom = 4, + Gaming = 5 + } + + #endregion + + #region Type + + public enum RoomType + { + Mix = 1, + Team = 2, + MixHasPass = 3, + TeamHasPass = 4 + } + + public enum InterfaceType + { + ServerInterface = 1 + } + + #endregion + + #region Result + + public enum MessageResult + { + OK = 1, + Cancel = 2, + Yes = 3, + No = 4, + Retry = 5 + } + + #endregion + + #region Method + + public enum WebHelperMethod + { + CreateSocket = 1, + CloseSocket = 2, + StartWebHelper = 3, + } + + public enum InterfaceMethod + { + GetServerIP = 1 + } + + #endregion + + } +} diff --git a/FunGame/Models/Enum/SocketEnums.cs b/FunGame.Core.Api/Model/Enum/SocketEnums.cs similarity index 94% rename from FunGame/Models/Enum/SocketEnums.cs rename to FunGame.Core.Api/Model/Enum/SocketEnums.cs index e3e6882..f737320 100644 --- a/FunGame/Models/Enum/SocketEnums.cs +++ b/FunGame.Core.Api/Model/Enum/SocketEnums.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Enum +namespace FunGame.Core.Api.Model.Enum { public static class SocketEnums { diff --git a/FunGame/Utils/DataHelper/AssemblyHelper.cs b/FunGame.Core.Api/Util/AssemblyHelper.cs similarity index 72% rename from FunGame/Utils/DataHelper/AssemblyHelper.cs rename to FunGame.Core.Api/Util/AssemblyHelper.cs index d9b548a..b89e63f 100644 --- a/FunGame/Utils/DataHelper/AssemblyHelper.cs +++ b/FunGame.Core.Api/Util/AssemblyHelper.cs @@ -4,16 +4,15 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Reflection; -using FunGame.Models.Config; -using FunGame.Models.Enum; using System.Diagnostics; +using FunGame.Core.Api.Model.Enum; -namespace FunGame.Utils.DataHelper +namespace FunGame.Core.Api.Util { /// - /// 在FunGame.Core中添加新接口和新实现时,需要: + /// 在FunGame.Core.Api中添加新接口和新实现时,需要: /// 1、在这里定义类名和方法名 - /// 2、在FunGame.Models.Enum.CommonEnums里同步添加InterfaceType和InterfaceMethod + /// 2、在FunGame.Core.Api.Model.Enum.CommonEnums里同步添加InterfaceType和InterfaceMethod /// public class AssemblyHelper { @@ -22,13 +21,26 @@ namespace FunGame.Utils.DataHelper */ public const string ServerInterface = "ServerInterface"; - public const string Implement = "Impl"; // 实现类的后缀(无需修改) - /** * 定义方法名 */ public const string GetRemoteServerIP = "RemoteServerIP"; + /** + * 定义需要反射的DLL + */ + public const string FUNGAME_CORE = "FunGame.Core"; + + /** + * 无需二次修改的 + */ + public const string Implement = "Impl"; // 实现类的后缀 + public static string PluginDocPath = System.Diagnostics.Process.GetCurrentProcess() + "/plugins/"; // 插件目录,反射插件DLL需要用LoadFile()方法 + + //////////////////////////////////////////////////////////////////// + /////////////// * 下 面 是 工 具 类 实 现 * //////////////// + /////////////////////////////////////////////////////////////////// + /** * 定义反射变量 */ @@ -78,9 +90,15 @@ namespace FunGame.Utils.DataHelper return ""; } + /// + /// 获取FUNGAME.CORE.DLL中指定方法的返回值 + /// + /// 接口代号 + /// 方法代号 + /// public object? GetFunGameCoreValue(int Interface, int Method) { - Assembly = Assembly.LoadFile(System.Windows.Forms.Application.StartupPath + @"FunGame.Core.dll"); // 要绝对路径 + Assembly = Assembly.Load(@FUNGAME_CORE); Type = GetFunGameCoreImplement(Interface); // 通过类名获取获取命名空间+类名称 string MethodName = GetMethodName(Method); // 获取方法名 if (Assembly != null && Type != null) this.Method = Type.GetMethod(MethodName); // 从Type中查找方法名 diff --git a/FunGame/Utils/DataHelper/INIHelper.cs b/FunGame.Core.Api/Util/INIHelper.cs similarity index 98% rename from FunGame/Utils/DataHelper/INIHelper.cs rename to FunGame.Core.Api/Util/INIHelper.cs index 0e38dda..7ee2a9b 100644 --- a/FunGame/Utils/DataHelper/INIHelper.cs +++ b/FunGame.Core.Api/Util/INIHelper.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; -namespace FunGame.Utils.DataHelper +namespace FunGame.Core.Api.Util { public class INIHelper { diff --git a/FunGame.Core/FunGame.Core.csproj b/FunGame.Core/FunGame.Core.csproj index b8bfeac..84570b2 100644 --- a/FunGame.Core/FunGame.Core.csproj +++ b/FunGame.Core/FunGame.Core.csproj @@ -6,10 +6,15 @@ enable Milimoe ..\bin + Milimoe + + + + diff --git a/FunGame/FunGame.csproj b/FunGame.Desktop/FunGame.Desktop.csproj similarity index 88% rename from FunGame/FunGame.csproj rename to FunGame.Desktop/FunGame.Desktop.csproj index e78eeb2..317ed0c 100644 --- a/FunGame/FunGame.csproj +++ b/FunGame.Desktop/FunGame.Desktop.csproj @@ -41,6 +41,11 @@ + + + + + True diff --git a/FunGame/Images/back.jpg b/FunGame.Desktop/Images/back.jpg similarity index 100% rename from FunGame/Images/back.jpg rename to FunGame.Desktop/Images/back.jpg diff --git a/FunGame/Images/exit.png b/FunGame.Desktop/Images/exit.png similarity index 100% rename from FunGame/Images/exit.png rename to FunGame.Desktop/Images/exit.png diff --git a/FunGame/Images/favicon.ico b/FunGame.Desktop/Images/favicon.ico similarity index 100% rename from FunGame/Images/favicon.ico rename to FunGame.Desktop/Images/favicon.ico diff --git a/FunGame/Images/green.png b/FunGame.Desktop/Images/green.png similarity index 100% rename from FunGame/Images/green.png rename to FunGame.Desktop/Images/green.png diff --git a/FunGame/Images/logo.ico b/FunGame.Desktop/Images/logo.ico similarity index 100% rename from FunGame/Images/logo.ico rename to FunGame.Desktop/Images/logo.ico diff --git a/FunGame/Images/min.png b/FunGame.Desktop/Images/min.png similarity index 100% rename from FunGame/Images/min.png rename to FunGame.Desktop/Images/min.png diff --git a/FunGame/Images/red.png b/FunGame.Desktop/Images/red.png similarity index 100% rename from FunGame/Images/red.png rename to FunGame.Desktop/Images/red.png diff --git a/FunGame/Images/send.png b/FunGame.Desktop/Images/send.png similarity index 100% rename from FunGame/Images/send.png rename to FunGame.Desktop/Images/send.png diff --git a/FunGame/Models/Component/ExitButton.Designer.cs b/FunGame.Desktop/Models/Component/ExitButton.Designer.cs similarity index 95% rename from FunGame/Models/Component/ExitButton.Designer.cs rename to FunGame.Desktop/Models/Component/ExitButton.Designer.cs index 25cafce..353a71f 100644 --- a/FunGame/Models/Component/ExitButton.Designer.cs +++ b/FunGame.Desktop/Models/Component/ExitButton.Designer.cs @@ -1,4 +1,4 @@ -namespace FunGame.Models.Component +namespace FunGame.Desktop.Models.Component { partial class ExitButton { diff --git a/FunGame/Models/Component/ExitButton.cs b/FunGame.Desktop/Models/Component/ExitButton.cs similarity index 92% rename from FunGame/Models/Component/ExitButton.cs rename to FunGame.Desktop/Models/Component/ExitButton.cs index 75862cf..e26ec76 100644 --- a/FunGame/Models/Component/ExitButton.cs +++ b/FunGame.Desktop/Models/Component/ExitButton.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Component +namespace FunGame.Desktop.Models.Component { public partial class ExitButton : Button { @@ -15,7 +15,7 @@ namespace FunGame.Models.Component InitializeComponent(); Anchor = System.Windows.Forms.AnchorStyles.None; BackColor = System.Drawing.Color.White; - BackgroundImage = global::FunGame.Properties.Resources.exit; + BackgroundImage = global::FunGame.Desktop.Properties.Resources.exit; FlatAppearance.BorderColor = System.Drawing.Color.White; FlatAppearance.BorderSize = 0; FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128))))); @@ -35,7 +35,7 @@ namespace FunGame.Models.Component InitializeComponent(); Anchor = System.Windows.Forms.AnchorStyles.None; BackColor = System.Drawing.Color.White; - BackgroundImage = global::FunGame.Properties.Resources.exit; + BackgroundImage = global::FunGame.Desktop.Properties.Resources.exit; FlatAppearance.BorderColor = System.Drawing.Color.White; FlatAppearance.BorderSize = 0; FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128))))); diff --git a/FunGame/Models/Component/ShowMessage.Designer.cs b/FunGame.Desktop/Models/Component/ShowMessage.Designer.cs similarity index 95% rename from FunGame/Models/Component/ShowMessage.Designer.cs rename to FunGame.Desktop/Models/Component/ShowMessage.Designer.cs index ebfa044..9ca76f6 100644 --- a/FunGame/Models/Component/ShowMessage.Designer.cs +++ b/FunGame.Desktop/Models/Component/ShowMessage.Designer.cs @@ -1,4 +1,4 @@ -namespace FunGame.Models.Component +namespace FunGame.Desktop.Models.Component { partial class ShowMessage { @@ -32,11 +32,11 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShowMessage)); this.MsgText = new System.Windows.Forms.Label(); this.LeftButton = new System.Windows.Forms.Button(); - this.Exit = new FunGame.Models.Component.ExitButton(this.components); + this.Exit = new FunGame.Desktop.Models.Component.ExitButton(this.components); this.RightButton = new System.Windows.Forms.Button(); this.MidButton = new System.Windows.Forms.Button(); this.Title = new System.Windows.Forms.Label(); - this.TransparentRect = new FunGame.Models.TransparentRect(); + this.TransparentRect = new FunGame.Desktop.Models.Component.TransparentRect(); this.TransparentRect.SuspendLayout(); this.SuspendLayout(); // @@ -129,7 +129,7 @@ this.TransparentRect.Name = "TransparentRect"; this.TransparentRect.Opacity = 125; this.TransparentRect.Radius = 20; - this.TransparentRect.ShapeBorderStyle = FunGame.Models.TransparentRect.ShapeBorderStyles.ShapeBSNone; + this.TransparentRect.ShapeBorderStyle = FunGame.Desktop.Models.Component.TransparentRect.ShapeBorderStyles.ShapeBSNone; this.TransparentRect.Size = new System.Drawing.Size(235, 170); this.TransparentRect.TabIndex = 103; this.TransparentRect.TabStop = false; diff --git a/FunGame/Models/Component/ShowMessage.cs b/FunGame.Desktop/Models/Component/ShowMessage.cs similarity index 98% rename from FunGame/Models/Component/ShowMessage.cs rename to FunGame.Desktop/Models/Component/ShowMessage.cs index 7b1aee2..f8bb91e 100644 --- a/FunGame/Models/Component/ShowMessage.cs +++ b/FunGame.Desktop/Models/Component/ShowMessage.cs @@ -7,9 +7,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using FunGame.Models.Enum; +using FunGame.Desktop.Models.Enum; -namespace FunGame.Models.Component +namespace FunGame.Desktop.Models.Component { public partial class ShowMessage : Form { diff --git a/FunGame/Models/Component/ShowMessage.resx b/FunGame.Desktop/Models/Component/ShowMessage.resx similarity index 100% rename from FunGame/Models/Component/ShowMessage.resx rename to FunGame.Desktop/Models/Component/ShowMessage.resx diff --git a/FunGame/Models/Component/TextArea.Designer.cs b/FunGame.Desktop/Models/Component/TextArea.Designer.cs similarity index 95% rename from FunGame/Models/Component/TextArea.Designer.cs rename to FunGame.Desktop/Models/Component/TextArea.Designer.cs index a532cac..9d5da02 100644 --- a/FunGame/Models/Component/TextArea.Designer.cs +++ b/FunGame.Desktop/Models/Component/TextArea.Designer.cs @@ -1,4 +1,4 @@ -namespace FunGame.Models +namespace FunGame.Desktop.Models.Component { partial class TextArea { diff --git a/FunGame/Models/Component/TextArea.cs b/FunGame.Desktop/Models/Component/TextArea.cs similarity index 98% rename from FunGame/Models/Component/TextArea.cs rename to FunGame.Desktop/Models/Component/TextArea.cs index 10f111f..0836bb6 100644 --- a/FunGame/Models/Component/TextArea.cs +++ b/FunGame.Desktop/Models/Component/TextArea.cs @@ -8,7 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace FunGame.Models +namespace FunGame.Desktop.Models.Component { [ToolboxBitmap(typeof(TextBox))] partial class TextArea : RichTextBox diff --git a/FunGame/Models/Component/TextArea.resx b/FunGame.Desktop/Models/Component/TextArea.resx similarity index 100% rename from FunGame/Models/Component/TextArea.resx rename to FunGame.Desktop/Models/Component/TextArea.resx diff --git a/FunGame/Models/Component/TransparentRect.Designer.cs b/FunGame.Desktop/Models/Component/TransparentRect.Designer.cs similarity index 95% rename from FunGame/Models/Component/TransparentRect.Designer.cs rename to FunGame.Desktop/Models/Component/TransparentRect.Designer.cs index a4b1e20..371ccee 100644 --- a/FunGame/Models/Component/TransparentRect.Designer.cs +++ b/FunGame.Desktop/Models/Component/TransparentRect.Designer.cs @@ -1,4 +1,4 @@ -namespace FunGame.Models +namespace FunGame.Desktop.Models.Component { partial class TransparentRect { diff --git a/FunGame/Models/Component/TransparentRect.cs b/FunGame.Desktop/Models/Component/TransparentRect.cs similarity index 98% rename from FunGame/Models/Component/TransparentRect.cs rename to FunGame.Desktop/Models/Component/TransparentRect.cs index dedcd89..d335e48 100644 --- a/FunGame/Models/Component/TransparentRect.cs +++ b/FunGame.Desktop/Models/Component/TransparentRect.cs @@ -7,7 +7,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace FunGame.Models +namespace FunGame.Desktop.Models.Component { partial class TransparentRect : GroupBox { diff --git a/FunGame/Models/Config/Config.cs b/FunGame.Desktop/Models/Config/Config.cs similarity index 94% rename from FunGame/Models/Config/Config.cs rename to FunGame.Desktop/Models/Config/Config.cs index 33540b9..ccbca07 100644 --- a/FunGame/Models/Config/Config.cs +++ b/FunGame.Desktop/Models/Config/Config.cs @@ -4,10 +4,9 @@ using System.Linq; using System.Security.AccessControl; using System.Text; using System.Threading.Tasks; -using FunGame.Models.Config; -using FunGame.Utils.DataHelper; +using FunGame.Core.Api.Util; -namespace FunGame.Models.Config +namespace FunGame.Desktop.Models.Config { public static class Config { @@ -26,6 +25,7 @@ namespace FunGame.Models.Config * WebHelper Configs */ public const string WebHelper_SetGreen = "-WebHelper .set green"; + public const string WebHelper_SetGreenAndPing = "-WebHelper .set greenandping"; public const string WebHelper_SetRed = "-WebHelper .set red"; public const string WebHelper_Disconnected = "-WebHelper .disconnected"; public const string WebHelper_GetUser = "-WebHelper .get user"; diff --git a/FunGame/Models/Config/Usercfg.cs b/FunGame.Desktop/Models/Config/Usercfg.cs similarity index 95% rename from FunGame/Models/Config/Usercfg.cs rename to FunGame.Desktop/Models/Config/Usercfg.cs index f92a09f..34e583d 100644 --- a/FunGame/Models/Config/Usercfg.cs +++ b/FunGame.Desktop/Models/Config/Usercfg.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Config +namespace FunGame.Desktop.Models.Config { public static class Usercfg { diff --git a/FunGame/Models/Enum/CommonEnums.cs b/FunGame.Desktop/Models/Enum/CommonEnums.cs similarity index 97% rename from FunGame/Models/Enum/CommonEnums.cs rename to FunGame.Desktop/Models/Enum/CommonEnums.cs index 925084c..4636b3b 100644 --- a/FunGame/Models/Enum/CommonEnums.cs +++ b/FunGame.Desktop/Models/Enum/CommonEnums.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace FunGame.Models.Enum +namespace FunGame.Desktop.Models.Enum { /// /// ſʵصState Type Result Method @@ -87,7 +87,7 @@ namespace FunGame.Models.Enum } public enum InterfaceMethod - { + { GetServerIP = 1 } diff --git a/FunGame.Desktop/Models/Enum/SocketEnums.cs b/FunGame.Desktop/Models/Enum/SocketEnums.cs new file mode 100644 index 0000000..0f700cf --- /dev/null +++ b/FunGame.Desktop/Models/Enum/SocketEnums.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FunGame.Desktop.Models.Enum +{ + public static class SocketEnums + { + public enum Type + { + GetNotice = 1, + Login = 2, + CheckLogin = 3, + Logout = 4, + HeartBeat = 5 + } + + public const string TYPE_UNKNOWN = "Unknown Type"; + public const string TYPE_GetNotice = "GetNotice"; + public const string TYPE_Login = "Login"; + public const string TYPE_CheckLogin = "CheckLogin"; + public const string TYPE_Logout = "Logout"; + public const string TYPE_HeartBeat = "HeartBeat"; + } +} diff --git a/FunGame/Properties/Resources.Designer.cs b/FunGame.Desktop/Properties/Resources.Designer.cs similarity index 97% rename from FunGame/Properties/Resources.Designer.cs rename to FunGame.Desktop/Properties/Resources.Designer.cs index 57c3a18..4d5b5c4 100644 --- a/FunGame/Properties/Resources.Designer.cs +++ b/FunGame.Desktop/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace FunGame.Properties { +namespace FunGame.Desktop.Properties { using System; @@ -39,7 +39,7 @@ namespace FunGame.Properties { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FunGame.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FunGame.Desktop.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/FunGame/Properties/Resources.resx b/FunGame.Desktop/Properties/Resources.resx similarity index 100% rename from FunGame/Properties/Resources.resx rename to FunGame.Desktop/Properties/Resources.resx diff --git a/FunGame/UI/Main/Main.Designer.cs b/FunGame.Desktop/UI/Main/Main.Designer.cs similarity index 96% rename from FunGame/UI/Main/Main.Designer.cs rename to FunGame.Desktop/UI/Main/Main.Designer.cs index a648471..cde0a3b 100644 --- a/FunGame/UI/Main/Main.Designer.cs +++ b/FunGame.Desktop/UI/Main/Main.Designer.cs @@ -1,7 +1,7 @@ -using FunGame.Models.Component; -using FunGame.Models.Config; +using FunGame.Desktop.Models.Component; +using FunGame.Desktop.Models.Config; -namespace FunGame +namespace FunGame.Desktop.UI { partial class Main { @@ -33,7 +33,7 @@ namespace FunGame { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main)); - this.Exit = new FunGame.Models.Component.ExitButton(this.components); + this.Exit = new FunGame.Desktop.Models.Component.ExitButton(this.components); this.Title = new System.Windows.Forms.Label(); this.MinForm = new System.Windows.Forms.Button(); this.Connection = new System.Windows.Forms.Label(); @@ -55,10 +55,10 @@ namespace FunGame this.QueryRoom = new System.Windows.Forms.Button(); this.RoomList = new System.Windows.Forms.ListBox(); this.Notice = new System.Windows.Forms.GroupBox(); - this.NoticeText = new FunGame.Models.TextArea(); + this.NoticeText = new FunGame.Desktop.Models.Component.TextArea(); this.InfoBox = new System.Windows.Forms.GroupBox(); - this.TransparentRectControl = new FunGame.Models.TransparentRect(); - this.GameInfo = new FunGame.Models.TextArea(); + this.TransparentRectControl = new FunGame.Desktop.Models.Component.TransparentRect(); + this.GameInfo = new FunGame.Desktop.Models.Component.TextArea(); this.QuitRoom = new System.Windows.Forms.Button(); this.CreateRoom = new System.Windows.Forms.Button(); this.Logout = new System.Windows.Forms.Button(); @@ -77,7 +77,7 @@ namespace FunGame // this.Exit.Anchor = System.Windows.Forms.AnchorStyles.None; this.Exit.BackColor = System.Drawing.Color.White; - this.Exit.BackgroundImage = global::FunGame.Properties.Resources.exit; + this.Exit.BackgroundImage = global::FunGame.Desktop.Properties.Resources.exit; this.Exit.FlatAppearance.BorderColor = System.Drawing.Color.White; this.Exit.FlatAppearance.BorderSize = 0; this.Exit.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128))))); @@ -110,7 +110,7 @@ namespace FunGame // this.MinForm.Anchor = System.Windows.Forms.AnchorStyles.None; this.MinForm.BackColor = System.Drawing.Color.White; - this.MinForm.BackgroundImage = global::FunGame.Properties.Resources.min; + this.MinForm.BackgroundImage = global::FunGame.Desktop.Properties.Resources.min; this.MinForm.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.MinForm.FlatAppearance.BorderColor = System.Drawing.Color.LightGray; this.MinForm.FlatAppearance.BorderSize = 0; @@ -131,10 +131,10 @@ namespace FunGame // this.Connection.BackColor = System.Drawing.Color.Transparent; this.Connection.Font = new System.Drawing.Font("LanaPixel", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.Connection.Location = new System.Drawing.Point(665, 425); + this.Connection.Location = new System.Drawing.Point(649, 424); this.Connection.Margin = new System.Windows.Forms.Padding(3); this.Connection.Name = "Connection"; - this.Connection.Size = new System.Drawing.Size(114, 23); + this.Connection.Size = new System.Drawing.Size(130, 23); this.Connection.TabIndex = 92; this.Connection.Text = "服务器连接失败"; this.Connection.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -142,7 +142,7 @@ namespace FunGame // Light // this.Light.BackColor = System.Drawing.Color.Transparent; - this.Light.Image = global::FunGame.Properties.Resources.red; + this.Light.Image = global::FunGame.Desktop.Properties.Resources.red; this.Light.Location = new System.Drawing.Point(777, 426); this.Light.Name = "Light"; this.Light.Size = new System.Drawing.Size(20, 20); @@ -152,7 +152,7 @@ namespace FunGame // this.SendTalkText.Anchor = System.Windows.Forms.AnchorStyles.None; this.SendTalkText.BackColor = System.Drawing.Color.Transparent; - this.SendTalkText.BackgroundImage = global::FunGame.Properties.Resources.send; + this.SendTalkText.BackgroundImage = global::FunGame.Desktop.Properties.Resources.send; this.SendTalkText.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.SendTalkText.FlatAppearance.BorderSize = 0; this.SendTalkText.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Teal; @@ -433,7 +433,7 @@ namespace FunGame this.TransparentRectControl.Name = "TransparentRectControl"; this.TransparentRectControl.Opacity = 125; this.TransparentRectControl.Radius = 20; - this.TransparentRectControl.ShapeBorderStyle = FunGame.Models.TransparentRect.ShapeBorderStyles.ShapeBSNone; + this.TransparentRectControl.ShapeBorderStyle = FunGame.Desktop.Models.Component.TransparentRect.ShapeBorderStyles.ShapeBSNone; this.TransparentRectControl.Size = new System.Drawing.Size(464, 343); this.TransparentRectControl.TabIndex = 2; this.TransparentRectControl.TabStop = false; @@ -559,7 +559,7 @@ namespace FunGame // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackgroundImage = global::FunGame.Properties.Resources.back; + this.BackgroundImage = global::FunGame.Desktop.Properties.Resources.back; this.ClientSize = new System.Drawing.Size(800, 450); this.Controls.Add(this.StopMatch); this.Controls.Add(this.Copyright); @@ -637,8 +637,8 @@ namespace FunGame private Button Store; private LinkLabel Copyright; private Button StopMatch; - private Models.TextArea GameInfo; - private Models.TextArea NoticeText; - private Models.TransparentRect TransparentRectControl; + private Models.Component.TextArea GameInfo; + private Models.Component.TextArea NoticeText; + private Models.Component.TransparentRect TransparentRectControl; } } \ No newline at end of file diff --git a/FunGame/UI/Main/Main.cs b/FunGame.Desktop/UI/Main/Main.cs similarity index 84% rename from FunGame/UI/Main/Main.cs rename to FunGame.Desktop/UI/Main/Main.cs index a0650f6..c04fdfc 100644 --- a/FunGame/UI/Main/Main.cs +++ b/FunGame.Desktop/UI/Main/Main.cs @@ -1,16 +1,17 @@ -using FunGame.Models.Component; -using FunGame.Models.Config; -using FunGame.Models.Entity; +using FunGame.Desktop.Models.Component; using System.Diagnostics; using System.Net.Sockets; using System.Net; using System.Windows.Forms; -using static FunGame.Models.Enum.CommonEnums; -using FunGame.Utils.WebHelper; -using FunGame.Models.Enum; -using FunGame.Utils.DataHelper; +using static FunGame.Desktop.Models.Enum.CommonEnums; +using System.Net.NetworkInformation; +using System.Text; +using FunGame.Core.Api.Model.Entity; +using FunGame.Desktop.Models.Enum; +using FunGame.Desktop.Models.Config; +using FunGame.Desktop.Utils; -namespace FunGame +namespace FunGame.Desktop.UI { public partial class Main : Form { @@ -79,36 +80,49 @@ namespace FunGame { case Config.WebHelper_SetGreen: Usercfg.FunGame_isRetrying = false; - WebHelper_Action = (Main? main) => + WebHelper_Action = (main) => { SetServerStatusLight(true); }; - if (this.InvokeRequired) - this.BeginInvoke(WebHelper_Action, this); + if (InvokeRequired) + BeginInvoke(WebHelper_Action, this); + else + WebHelper_Action(this); + Usercfg.FunGame_isConnected = true; + NOW_CONNECTEDRETRY = 0; + break; + case Config.WebHelper_SetGreenAndPing: + Usercfg.FunGame_isRetrying = false; + WebHelper_Action = (main) => + { + SetServerStatusLight(true, GetServerPing(Config.SERVER_IPADRESS)); + }; + if (InvokeRequired) + BeginInvoke(WebHelper_Action, this); else WebHelper_Action(this); Usercfg.FunGame_isConnected = true; NOW_CONNECTEDRETRY = 0; break; case Config.WebHelper_SetRed: - WebHelper_Action = (Main? main) => + WebHelper_Action = (main) => { SetServerStatusLight(false); }; - if (this.InvokeRequired) - this.BeginInvoke(WebHelper_Action, this); + if (InvokeRequired) + BeginInvoke(WebHelper_Action, this); else WebHelper_Action(this); Usercfg.FunGame_isConnected = false; break; case Config.WebHelper_Disconnected: Usercfg.FunGame_isRetrying = false; - WebHelper_Action = (Main? main) => + WebHelper_Action = (main) => { SetServerStatusLight(false); }; - if (this.InvokeRequired) - this.BeginInvoke(WebHelper_Action, this); + if (InvokeRequired) + BeginInvoke(WebHelper_Action, this); else WebHelper_Action(this); Usercfg.FunGame_isConnected = false; @@ -142,7 +156,7 @@ namespace FunGame } catch (Exception e) { - WritelnGameInfo(webHelper, (e.Message != null) ? e.Message + "\n" + e.StackTrace : "" + e.StackTrace); + WritelnGameInfo(webHelper, e.Message != null ? e.Message + "\n" + e.StackTrace : "" + e.StackTrace); GetMessage(webHelper, Config.WebHelper_SetRed); } return null; @@ -189,13 +203,13 @@ namespace FunGame { while (true) { - if (this.IsHandleCreated) + if (IsHandleCreated) { // 检查是否创建了窗口句柄,再Invoke委托。 break; } } - Main_Action = (Main? main) => + Main_Action = (main) => { if (!Usercfg.FunGame_isConnected) { @@ -209,7 +223,7 @@ namespace FunGame WritelnGameInfo("ERROR:无法连接至服务器,请检查网络并重启游戏再试。"); return; } - WebHelper_Action = (Main? main) => + WebHelper_Action = (main) => { try { @@ -217,13 +231,13 @@ namespace FunGame { if (WebHelper != null) { - WebHelper.WebHelpMethod((int)CommonEnums.WebHelperMethod.CloseSocket); + WebHelper.WebHelpMethod((int)WebHelperMethod.CloseSocket); WebHelper = null; } Usercfg.FunGame_isRetrying = true; Application.DoEvents(); WebHelper = new WebHelper(main); - WebHelper.WebHelpMethod((int)CommonEnums.WebHelperMethod.CreateSocket); // Invoke -> CreateSocket + WebHelper.WebHelpMethod((int)WebHelperMethod.CreateSocket); // Invoke -> CreateSocket } } catch @@ -233,7 +247,7 @@ namespace FunGame }; Task.Factory.StartNew(() => { - if (this.InvokeRequired) + if (InvokeRequired) { BeginInvoke(WebHelper_Action, main); } @@ -244,7 +258,7 @@ namespace FunGame }); } }; - if (this.InvokeRequired) + if (InvokeRequired) { Invoke(Main_Action, this); } @@ -385,7 +399,7 @@ namespace FunGame { if (Usercfg.FunGame_roomid.Equals("-1")) { - if (ShowMessage.YesNoMessage("已找到房间 -> [ " + roomid + " ]\n是否加入?", "已找到房间") == (int)CommonEnums.MessageResult.Yes) + if (ShowMessage.YesNoMessage("已找到房间 -> [ " + roomid + " ]\n是否加入?", "已找到房间") == (int)MessageResult.Yes) { SetRoomid(roomid); InRoom(); @@ -413,7 +427,7 @@ namespace FunGame { if (Usercfg.FunGame_roomid.Equals("-1")) { - if (ShowMessage.YesNoMessage("已找到房间 -> [ " + roomid + " ]\n是否加入?", "已找到房间") == (int)CommonEnums.MessageResult.Yes) + if (ShowMessage.YesNoMessage("已找到房间 -> [ " + roomid + " ]\n是否加入?", "已找到房间") == (int)MessageResult.Yes) { SetRoomid(roomid); InRoom(); @@ -440,7 +454,7 @@ namespace FunGame { switch (i) { - case (int)CommonEnums.StartMatch_State.Matching: + case (int)StartMatch_State.Matching: // 开始匹配 Usercfg.FunGame_isMatching = true; int loop = 0; @@ -460,20 +474,20 @@ namespace FunGame { StartMatch_Method(i, objs); }; - if (this.InvokeRequired) + if (InvokeRequired) { - Invoke(StartMatch_Action, (int)CommonEnums.StartMatch_State.Success, new object[] { roomid }); + Invoke(StartMatch_Action, (int)StartMatch_State.Success, new object[] { roomid }); } else { - StartMatch_Action((int)CommonEnums.StartMatch_State.Success, new object[] { roomid }); + StartMatch_Action((int)StartMatch_State.Success, new object[] { roomid }); } break; } } }); break; - case (int)CommonEnums.StartMatch_State.Success: + case (int)StartMatch_State.Success: Usercfg.FunGame_isMatching = false; // 匹配成功返回房间号 roomid = "-1"; @@ -492,21 +506,21 @@ namespace FunGame // 设置按钮可见性 InRoom(); // 创建委托,操作主界面 - StartMatch_Action = (int i, object[]? objs) => + StartMatch_Action = (i, objs) => { StartMatch_Method(i, objs); }; - if (this.InvokeRequired) + if (InvokeRequired) { - Invoke(StartMatch_Action, (int)CommonEnums.StartMatch_State.Enable, new object[] { true }); + Invoke(StartMatch_Action, (int)StartMatch_State.Enable, new object[] { true }); } else { - StartMatch_Action((int)CommonEnums.StartMatch_State.Enable, new object[] { true }); + StartMatch_Action((int)StartMatch_State.Enable, new object[] { true }); } MatchFunGame = null; break; - case (int)CommonEnums.StartMatch_State.Enable: + case (int)StartMatch_State.Enable: // 设置匹配过程中的各种按钮是否可用 bool isPause = false; if (objs != null) isPause = (bool)objs[0]; @@ -517,21 +531,21 @@ namespace FunGame RoomBox.Enabled = isPause; Login.Enabled = isPause; break; - case (int)CommonEnums.StartMatch_State.Cancel: + case (int)StartMatch_State.Cancel: WritelnGameInfo(GetNowShortTime() + " 终止匹配"); WritelnGameInfo("[ " + Usercfg.LoginUserName + " ] 已终止匹配。"); Usercfg.FunGame_isMatching = false; - StartMatch_Action = (int i, object[]? objs) => + StartMatch_Action = (i, objs) => { StartMatch_Method(i, objs); }; - if (this.InvokeRequired) + if (InvokeRequired) { - Invoke(StartMatch_Action, (int)CommonEnums.StartMatch_State.Enable, new object[] { true }); + Invoke(StartMatch_Action, (int)StartMatch_State.Enable, new object[] { true }); } else { - StartMatch_Action((int)CommonEnums.StartMatch_State.Enable, new object[] { true }); + StartMatch_Action((int)StartMatch_State.Enable, new object[] { true }); } MatchFunGame = null; StopMatch.Visible = false; @@ -565,17 +579,17 @@ namespace FunGame /// private void StopMatch_Click() { - StartMatch_Action = (int i, object[]? objs) => + StartMatch_Action = (i, objs) => { StartMatch_Method(i, objs); }; - if (this.InvokeRequired) + if (InvokeRequired) { - Invoke(StartMatch_Action, (int)CommonEnums.StartMatch_State.Cancel, new object[] { true }); + Invoke(StartMatch_Action, (int)StartMatch_State.Cancel, new object[] { true }); } else { - StartMatch_Action((int)CommonEnums.StartMatch_State.Cancel, new object[] { true }); + StartMatch_Action((int)StartMatch_State.Cancel, new object[] { true }); } } @@ -642,21 +656,21 @@ namespace FunGame } switch (i) { - case (int)CommonEnums.CreateRoom_State.Creating: - CreateRoom_Action = (int i, object[]? objs) => + case (int)CreateRoom_State.Creating: + CreateRoom_Action = (i, objs) => { CreateRoom_Method(i, objs); }; - if (this.InvokeRequired) + if (InvokeRequired) { - Invoke(CreateRoom_Action, (int)CommonEnums.CreateRoom_State.Success, new object[] { roomtype }); + Invoke(CreateRoom_Action, (int)CreateRoom_State.Success, new object[] { roomtype }); } else { - CreateRoom_Action((int)CommonEnums.CreateRoom_State.Success, new object[] { roomtype }); + CreateRoom_Action((int)CreateRoom_State.Success, new object[] { roomtype }); } break; - case (int)CommonEnums.CreateRoom_State.Success: + case (int)CreateRoom_State.Success: roomid = Convert.ToString(new Random().Next(1, 10000)); SetRoomid(roomid); InRoom(); @@ -671,17 +685,25 @@ namespace FunGame /// 设置服务器连接状态指示灯 /// /// - private void SetServerStatusLight(bool green) + private void SetServerStatusLight(bool green, int ping = 0) { if (green) { - Connection.Text = "服务器连接成功"; - this.Light.Image = global::FunGame.Properties.Resources.green; + if (ping > 0) + { + Connection.Text = "心跳延迟 " + ping + "ms"; + this.Light.Image = Properties.Resources.green; + } + else + { + Connection.Text = "服务器连接成功"; + this.Light.Image = Properties.Resources.green; + } } else { Connection.Text = "服务器连接失败"; - this.Light.Image = global::FunGame.Properties.Resources.red; + this.Light.Image = Properties.Resources.red; } } @@ -696,14 +718,14 @@ namespace FunGame /// private void Exit_Click(object sender, EventArgs e) { - if (ShowMessage.OKCancelMessage("你确定关闭游戏?", "退出") == (int)CommonEnums.MessageResult.OK) + if (ShowMessage.OKCancelMessage("你确定关闭游戏?", "退出") == (int)MessageResult.OK) { if (WebHelper != null) { - WebHelper.WebHelpMethod((int)CommonEnums.WebHelperMethod.CloseSocket); + WebHelper.WebHelpMethod((int)WebHelperMethod.CloseSocket); WebHelper = null; } - System.Environment.Exit(0); + Environment.Exit(0); } } @@ -718,8 +740,8 @@ namespace FunGame if (e.Button == MouseButtons.Left) { //获取鼠标左键按下时的位置 - this.LOCATION_X = e.Location.X; - this.LOCATION_Y = e.Location.Y; + LOCATION_X = e.Location.X; + LOCATION_Y = e.Location.Y; } } @@ -733,8 +755,8 @@ namespace FunGame if (e.Button == MouseButtons.Left) { //计算鼠标移动距离 - this.Left += e.Location.X - this.LOCATION_X; - this.Top += e.Location.Y - this.LOCATION_Y; + Left += e.Location.X - LOCATION_X; + Top += e.Location.Y - LOCATION_Y; } } @@ -760,9 +782,9 @@ namespace FunGame StartMatch.Visible = false; StopMatch.Visible = true; // 暂停其他按钮 - StartMatch_Method((int)CommonEnums.StartMatch_State.Enable, new object[] { false }); + StartMatch_Method((int)StartMatch_State.Enable, new object[] { false }); // 创建委托,开始匹配 - StartMatch_Action = (int i, object[]? objs) => + StartMatch_Action = (i, objs) => { StartMatch_Method(i, objs); }; @@ -770,13 +792,13 @@ namespace FunGame MatchFunGame = Task.Factory.StartNew(() => { - if (this.InvokeRequired) + if (InvokeRequired) { - Invoke(StartMatch_Action, (int)CommonEnums.StartMatch_State.Matching, null); + Invoke(StartMatch_Action, (int)StartMatch_State.Matching, null); } else { - StartMatch_Action((int)CommonEnums.StartMatch_State.Matching, null); + StartMatch_Action((int)StartMatch_State.Matching, null); } }); } @@ -815,17 +837,17 @@ namespace FunGame ShowMessage.WarningMessage("请勾选你要创建的房间类型!"); return; } - CreateRoom_Action = (int i, object[]? objs) => + CreateRoom_Action = (i, objs) => { CreateRoom_Method(i, objs); }; - if (this.InvokeRequired) + if (InvokeRequired) { - Invoke(CreateRoom_Action, (int)CommonEnums.CreateRoom_State.Creating, new object[] { roomtype }); + Invoke(CreateRoom_Action, (int)CreateRoom_State.Creating, new object[] { roomtype }); } else { - CreateRoom_Action((int)CommonEnums.CreateRoom_State.Creating, new object[] { roomtype }); + CreateRoom_Action((int)CreateRoom_State.Creating, new object[] { roomtype }); } } @@ -1061,7 +1083,7 @@ namespace FunGame /// private void MinForm_Click(object sender, EventArgs e) { - this.WindowState = FormWindowState.Minimized; + WindowState = FormWindowState.Minimized; } #endregion @@ -1102,31 +1124,31 @@ namespace FunGame case Config.FunGame_ShowStore: break; case Config.FunGame_CreateMix: - CreateRoom_Action = (int i, object[]? objs) => + CreateRoom_Action = (i, objs) => { CreateRoom_Method(i, objs); }; - if (this.InvokeRequired) + if (InvokeRequired) { - Invoke(CreateRoom_Action, (int)CommonEnums.CreateRoom_State.Creating, new object[] { Config.GameMode_Mix }); + Invoke(CreateRoom_Action, (int)CreateRoom_State.Creating, new object[] { Config.GameMode_Mix }); } else { - CreateRoom_Action((int)CommonEnums.CreateRoom_State.Creating, new object[] { Config.GameMode_Mix }); + CreateRoom_Action((int)CreateRoom_State.Creating, new object[] { Config.GameMode_Mix }); } break; case Config.FunGame_CreateTeam: - CreateRoom_Action = (int i, object[]? objs) => + CreateRoom_Action = (i, objs) => { CreateRoom_Method(i, objs); }; - if (this.InvokeRequired) + if (InvokeRequired) { - Invoke(CreateRoom_Action, (int)CommonEnums.CreateRoom_State.Creating, new object[] { Config.GameMode_Team }); + Invoke(CreateRoom_Action, (int)CreateRoom_State.Creating, new object[] { Config.GameMode_Team }); } else { - CreateRoom_Action((int)CommonEnums.CreateRoom_State.Creating, new object[] { Config.GameMode_Team }); + CreateRoom_Action((int)CreateRoom_State.Creating, new object[] { Config.GameMode_Team }); } break; case Config.FunGame_StartGame: @@ -1157,7 +1179,7 @@ namespace FunGame /// private string GetNowTime() { - DateTime now = System.DateTime.Now; + DateTime now = DateTime.Now; return now.AddMilliseconds(-now.Millisecond).ToString(); } @@ -1167,10 +1189,33 @@ namespace FunGame /// private string GetNowShortTime() { - DateTime now = System.DateTime.Now; + DateTime now = DateTime.Now; return now.AddMilliseconds(-now.Millisecond).ToString("T"); } + /// + /// 获取服务器的延迟 + /// + /// 服务器IP地址 + /// + private int GetServerPing(string addr) + { + Ping pingSender = new(); + PingOptions options = new() + { + DontFragment = true + }; + string data = "getserverping"; + byte[] buffer = Encoding.ASCII.GetBytes(data); + int timeout = 120; + PingReply reply = pingSender.Send(addr, timeout, buffer, options); + if (reply.Status == IPStatus.Success) + { + return Convert.ToInt32(reply.RoundtripTime); + } + return -1; + } + #endregion } } \ No newline at end of file diff --git a/FunGame/UI/Main/Main.resx b/FunGame.Desktop/UI/Main/Main.resx similarity index 94% rename from FunGame/UI/Main/Main.resx rename to FunGame.Desktop/UI/Main/Main.resx index e7db271..c10bec9 100644 --- a/FunGame/UI/Main/Main.resx +++ b/FunGame.Desktop/UI/Main/Main.resx @@ -57,6 +57,111 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + diff --git a/FunGame/UI/Start.cs b/FunGame.Desktop/UI/Start.cs similarity index 91% rename from FunGame/UI/Start.cs rename to FunGame.Desktop/UI/Start.cs index 0d89156..31a6a28 100644 --- a/FunGame/UI/Start.cs +++ b/FunGame.Desktop/UI/Start.cs @@ -1,4 +1,4 @@ -namespace FunGame.UI +namespace FunGame.Desktop.UI { internal static class Start { diff --git a/FunGame/Utils/WebHelper/WebHelper.cs b/FunGame.Desktop/Utils/WebHelper.cs similarity index 97% rename from FunGame/Utils/WebHelper/WebHelper.cs rename to FunGame.Desktop/Utils/WebHelper.cs index 9fa6bee..a2b0749 100644 --- a/FunGame/Utils/WebHelper/WebHelper.cs +++ b/FunGame.Desktop/Utils/WebHelper.cs @@ -5,13 +5,15 @@ using System.Net.Sockets; using System.Net; using System.Text; using System.Threading.Tasks; -using FunGame.Models.Config; -using FunGame.Models.Component; -using FunGame.Models.Entity; +using FunGame.Desktop.Models.Component; using System.ComponentModel.DataAnnotations; -using FunGame.Models.Enum; +using System.Net.NetworkInformation; +using FunGame.Core.Api.Model.Entity; +using FunGame.Desktop.Models.Enum; +using FunGame.Desktop.Models.Config; +using FunGame.Desktop.UI; -namespace FunGame.Utils.WebHelper +namespace FunGame.Desktop.Utils { public class WebHelper { @@ -156,6 +158,7 @@ namespace FunGame.Utils.WebHelper case (int)SocketEnums.Type.HeartBeat: if (WaitHeartBeat != null && !WaitHeartBeat.IsCompleted) WaitHeartBeat.Wait(1); Config.WebHelper_HeartBeatFaileds = 0; + main.GetMessage(this, Config.WebHelper_SetGreenAndPing); return true; } } diff --git a/FunGame.Plugin/FunGame.Plugin.csproj b/FunGame.Plugin/FunGame.Plugin.csproj new file mode 100644 index 0000000..fd56160 --- /dev/null +++ b/FunGame.Plugin/FunGame.Plugin.csproj @@ -0,0 +1,12 @@ + + + + net6.0-windows + enable + enable + ..\bin + Milimoe + Milimoe + + + diff --git a/FunGame.sln b/FunGame.sln index 2a2bce1..4f487f1 100644 --- a/FunGame.sln +++ b/FunGame.sln @@ -2,9 +2,23 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32804.467 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunGame", "FunGame\FunGame.csproj", "{BFFCC8D2-DF96-4DD3-81BA-552FAB33495A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunGame.Desktop", "FunGame.Desktop\FunGame.Desktop.csproj", "{BFFCC8D2-DF96-4DD3-81BA-552FAB33495A}" + ProjectSection(ProjectDependencies) = postProject + {842BB22E-4309-4ADD-93CD-A981CE10C30E} = {842BB22E-4309-4ADD-93CD-A981CE10C30E} + {CC6C83C6-5818-4565-8873-67587FED1D0A} = {CC6C83C6-5818-4565-8873-67587FED1D0A} + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunGame.Core", "FunGame.Core\FunGame.Core.csproj", "{CC6C83C6-5818-4565-8873-67587FED1D0A}" + ProjectSection(ProjectDependencies) = postProject + {842BB22E-4309-4ADD-93CD-A981CE10C30E} = {842BB22E-4309-4ADD-93CD-A981CE10C30E} + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunGame.Core.Api", "FunGame.Core.Api\FunGame.Core.Api.csproj", "{842BB22E-4309-4ADD-93CD-A981CE10C30E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunGame.Plugin", "FunGame.Plugin\FunGame.Plugin.csproj", "{A1132284-47F3-4C2D-89DB-C34B2354D9BB}" + ProjectSection(ProjectDependencies) = postProject + {842BB22E-4309-4ADD-93CD-A981CE10C30E} = {842BB22E-4309-4ADD-93CD-A981CE10C30E} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -20,6 +34,14 @@ Global {CC6C83C6-5818-4565-8873-67587FED1D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU {CC6C83C6-5818-4565-8873-67587FED1D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU {CC6C83C6-5818-4565-8873-67587FED1D0A}.Release|Any CPU.Build.0 = Release|Any CPU + {842BB22E-4309-4ADD-93CD-A981CE10C30E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {842BB22E-4309-4ADD-93CD-A981CE10C30E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {842BB22E-4309-4ADD-93CD-A981CE10C30E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {842BB22E-4309-4ADD-93CD-A981CE10C30E}.Release|Any CPU.Build.0 = Release|Any CPU + {A1132284-47F3-4C2D-89DB-C34B2354D9BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A1132284-47F3-4C2D-89DB-C34B2354D9BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A1132284-47F3-4C2D-89DB-C34B2354D9BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A1132284-47F3-4C2D-89DB-C34B2354D9BB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE