mirror of
https://github.com/project-redbud/FunGame-Desktop.git
synced 2025-04-22 04:59:34 +08:00
加载插件测试
This commit is contained in:
parent
d5a5425fcc
commit
950ae5e467
@ -1,17 +1,18 @@
|
|||||||
using Milimoe.FunGame.Core.Api.Transmittal;
|
using Milimoe.FunGame.Core.Api.Transmittal;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Plugin;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.Model
|
namespace Milimoe.FunGame.Desktop.Model
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 运行时单例
|
/// 运行时单例
|
||||||
/// 插件接口可以从这里拿Socket和窗体
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RunTime
|
public class RunTime
|
||||||
{
|
{
|
||||||
public static Core.Model.RoomList RoomList { get; } = new();
|
public static Core.Model.RoomList RoomList { get; } = new();
|
||||||
public static Core.Model.Session Session { get; } = new();
|
public static Core.Model.Session Session { get; } = new();
|
||||||
public static Core.Model.FunGameConfig Config { get; } = new();
|
public static Core.Model.FunGameConfig Config { get; } = new();
|
||||||
|
public static Dictionary<string, BasePlugin> Plugins { get; } = new();
|
||||||
public static Core.Library.Common.Network.Socket? Socket { get; set; } = null;
|
public static Core.Library.Common.Network.Socket? Socket { get; set; } = null;
|
||||||
public static Controller.RunTimeController? Controller { get; set; } = null;
|
public static Controller.RunTimeController? Controller { get; set; } = null;
|
||||||
public static UI.Main? Main { get; set; } = null;
|
public static UI.Main? Main { get; set; } = null;
|
||||||
|
@ -2,6 +2,7 @@ using System.Diagnostics;
|
|||||||
using Milimoe.FunGame.Core.Api.Utility;
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Plugin;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Library.Exception;
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
using Milimoe.FunGame.Desktop.Controller;
|
using Milimoe.FunGame.Desktop.Controller;
|
||||||
@ -64,6 +65,9 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 加载插件
|
||||||
|
LoadPlugins();
|
||||||
|
// 自动连接服务器
|
||||||
if (Config.FunGame_isAutoConnect) InvokeController_Connect();
|
if (Config.FunGame_isAutoConnect) InvokeController_Connect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -831,6 +835,25 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载所有插件
|
||||||
|
/// </summary>
|
||||||
|
private void LoadPlugins()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PluginLoader.LoadPlugins(RunTime.Plugins);
|
||||||
|
foreach (KeyValuePair<string, BasePlugin> kv in RunTime.Plugins)
|
||||||
|
{
|
||||||
|
GetMessage("Load: " + kv.Value.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
GetMessage(e.GetErrorInfo(), TimeType.None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示FunGame信息
|
/// 显示FunGame信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -861,13 +884,21 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void ExitFunGame()
|
private void ExitFunGame()
|
||||||
{
|
{
|
||||||
|
bool exit = false;
|
||||||
TaskUtility.StartAndAwaitTask(() =>
|
TaskUtility.StartAndAwaitTask(() =>
|
||||||
{
|
{
|
||||||
if (ShowMessage(ShowMessageType.OKCancel, "你确定关闭游戏?", "退出") == MessageResult.OK)
|
if (ShowMessage(ShowMessageType.OKCancel, "你确定关闭游戏?", "退出") == MessageResult.OK)
|
||||||
{
|
{
|
||||||
InvokeController_Disconnect();
|
InvokeController_Disconnect();
|
||||||
|
exit = true;
|
||||||
}
|
}
|
||||||
}).OnCompleted(() => Environment.Exit(0));
|
}).OnCompleted(() =>
|
||||||
|
{
|
||||||
|
if (exit)
|
||||||
|
{
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user