将Desktop、Console、Plugin分离出去

This commit is contained in:
Mili 2023-03-31 20:09:44 +08:00
parent 800886062b
commit e6effd25c5
168 changed files with 4 additions and 9137 deletions

4
.gitignore vendored
View File

@ -363,5 +363,5 @@ MigrationBackup/
FodyWeavers.xsd
# FunGame Implement
FunGame.Implement/*.cs
FunGame.Implement/Implement/*.cs
Implement/*.cs
Implement/Implement/*.cs

View File

@ -1,30 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Milimoe</Company>
<Authors>Milimoe</Authors>
<Product>FunGame</Product>
<Title>FunGame.Console</Title>
<ApplicationIcon>logo.ico</ApplicationIcon>
<BaseOutputPath>..\bin\</BaseOutputPath>
<AssemblyName>FunGame</AssemblyName>
<RootNamespace>Milimoe.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<Content Include="logo.ico" />
</ItemGroup>
</Project>

View File

@ -1,2 +0,0 @@
Console.WriteLine("Hello, FunGame's Console!");
Console.ReadKey();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,6 +0,0 @@
namespace Milimoe.FunGame.Desktop.Controller
{
public class InventoryController
{
}
}

View File

@ -1,46 +0,0 @@
using Milimoe.FunGame.Core.Library.Common.Event;
using Milimoe.FunGame.Core.Library.Common.Architecture;
using Milimoe.FunGame.Desktop.Library;
using Milimoe.FunGame.Desktop.Model;
using Milimoe.FunGame.Core.Library.Exception;
namespace Milimoe.FunGame.Desktop.Controller
{
public class LoginController : BaseController
{
private readonly LoginModel LoginModel;
public LoginController()
{
LoginModel = new LoginModel();
}
public override void Dispose()
{
LoginModel.Dispose();
}
public static async Task<bool> LoginAccount(params object[]? objs)
{
bool result = false;
try
{
LoginEventArgs LoginEventArgs = new(objs);
if (RunTime.Login?.OnBeforeLoginEvent(LoginEventArgs) == Core.Library.Constant.EventResult.Fail) return false;
result = await LoginModel.LoginAccountAsync(objs);
if (result) RunTime.Login?.OnSucceedLoginEvent(LoginEventArgs);
else RunTime.Login?.OnFailedLoginEvent(LoginEventArgs);
RunTime.Login?.OnAfterLoginEvent(LoginEventArgs);
}
catch (Exception e)
{
RunTime.WritelnSystemInfo(e.GetErrorInfo());
}
return result;
}
}
}

View File

@ -1,107 +0,0 @@
using Milimoe.FunGame.Core.Library.Common.Event;
using Milimoe.FunGame.Core.Library.Common.Architecture;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Desktop.Model;
using Milimoe.FunGame.Desktop.UI;
using Milimoe.FunGame.Desktop.Library;
namespace Milimoe.FunGame.Desktop.Controller
{
public class MainController : BaseController
{
public bool Connected => Do<bool>(MainInvokeType.Connected);
private MainModel MainModel { get; }
private Main Main { get; }
public MainController(Main Main)
{
this.Main = Main;
MainModel = new MainModel(Main);
}
public override void Dispose()
{
MainModel.Dispose();
}
/**
* Model的方法
*/
private T Do<T>(MainInvokeType DoType, params object[] args)
{
object result = new();
switch(DoType)
{
case MainInvokeType.LogOut:
if (Main.OnBeforeLogoutEvent(new GeneralEventArgs()) == EventResult.Fail) return (T)result;
result = MainModel.LogOut();
break;
case MainInvokeType.IntoRoom:
string roomid = new("-1");
if (args != null && args.Length > 0) roomid = (string)args[0];
if (Main.OnBeforeIntoRoomEvent(new RoomEventArgs(roomid)) == EventResult.Fail) return (T)result;
result = MainModel.IntoRoom(roomid);
break;
case MainInvokeType.UpdateRoom:
result = MainModel.UpdateRoom();
break;
case MainInvokeType.QuitRoom:
roomid = new("-1");
if (args != null && args.Length > 0) roomid = (string)args[0];
if (Main.OnBeforeQuitRoomEvent(new RoomEventArgs(roomid)) == EventResult.Fail) return (T)result;
result = MainModel.QuitRoom(roomid);
break;
case MainInvokeType.CreateRoom:
if (Main.OnBeforeCreateRoomEvent(new RoomEventArgs()) == EventResult.Fail) return (T)result;
result = MainModel.CreateRoom();
break;
case MainInvokeType.Chat:
string msg = "";
if (args != null && args.Length > 0) msg = (string)args[0];
if (Main.OnBeforeSendTalkEvent(new SendTalkEventArgs(msg)) == EventResult.Fail) return (T)result;
if (msg.Trim() != "") result = MainModel.Chat(msg);
break;
default:
break;
}
return (T)result;
}
public bool LogOut()
{
return Do<bool>(MainInvokeType.LogOut);
}
public bool UpdateRoom()
{
return Do<bool>(MainInvokeType.UpdateRoom);
}
public bool IntoRoom(string roomid)
{
return Do<bool>(MainInvokeType.IntoRoom, roomid);
}
public bool QuitRoom(string roomid)
{
return Do<bool>(MainInvokeType.QuitRoom, roomid);
}
public bool CreateRoom()
{
return Do<bool>(MainInvokeType.CreateRoom);
}
public bool Chat(string msg)
{
return Do<bool>(MainInvokeType.Chat, msg);
}
}
}

View File

@ -1,51 +0,0 @@
using Milimoe.FunGame.Desktop.Library.Component;
using Milimoe.FunGame.Desktop.Library;
using Milimoe.FunGame.Desktop.Model;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Desktop.UI;
using Milimoe.FunGame.Core.Library.Common.Architecture;
using Milimoe.FunGame.Core.Library.Exception;
using Milimoe.FunGame.Core.Library.Common.Event;
namespace Milimoe.FunGame.Desktop.Controller
{
public class RegisterController : BaseController
{
private readonly Register Register;
private readonly RegisterModel RegModel;
public RegisterController(Register reg)
{
Register = reg;
RegModel = new RegisterModel(reg);
}
public override void Dispose()
{
RegModel.Dispose();
}
public async Task<bool> Reg(params object[]? objs)
{
bool result = false;
try
{
RegisterEventArgs RegEventArgs = new (objs);
if (Register.OnBeforeRegEvent(RegEventArgs) == EventResult.Fail) return false;
result = await RegModel.Reg(objs);
if (result) Register.OnSucceedRegEvent(RegEventArgs);
else Register.OnFailedRegEvent(RegEventArgs);
Register.OnAfterRegEvent(RegEventArgs);
}
catch (Exception e)
{
RunTime.WritelnSystemInfo(e.GetErrorInfo());
}
return result;
}
}
}

View File

@ -1,6 +0,0 @@
namespace Milimoe.FunGame.Desktop.Controller
{
public class RoomSettingController
{
}
}

View File

@ -1,119 +0,0 @@
using Milimoe.FunGame.Core.Library.Common.Event;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Desktop.Library;
using Milimoe.FunGame.Desktop.Model;
using Milimoe.FunGame.Desktop.UI;
namespace Milimoe.FunGame.Desktop.Controller
{
public class RunTimeController
{
public bool Connected => Do<bool>(RunTimeInvokeType.Connected);
private RunTimeModel RunTimeModel { get; }
private Main Main { get; }
public RunTimeController(Main Main)
{
this.Main = Main;
RunTimeModel = new RunTimeModel(Main);
}
/**
* Model的方法
*/
private T Do<T>(RunTimeInvokeType DoType, params object[] args)
{
object result = new();
switch (DoType)
{
case RunTimeInvokeType.GetServerConnection:
result = RunTimeModel.GetServerConnection();
break;
case RunTimeInvokeType.Connect:
result = RunTimeModel.Connect();
if ((ConnectResult)result != ConnectResult.Success)
{
Main.OnFailedConnectEvent(new GeneralEventArgs());
Main.OnAfterConnectEvent(new GeneralEventArgs());
}
break;
case RunTimeInvokeType.Connected:
result = RunTimeModel.Connected;
break;
case RunTimeInvokeType.Disconnect:
if (Main.OnBeforeDisconnectEvent(new GeneralEventArgs()) == EventResult.Fail) return (T)result;
RunTimeModel.Disconnect();
break;
case RunTimeInvokeType.Disconnected:
break;
case RunTimeInvokeType.AutoLogin:
break;
case RunTimeInvokeType.Close:
if (args != null && args.Length > 0)
{
RunTimeModel.Error((Exception)args[0]);
result = true;
}
else
result = RunTimeModel.Close();
break;
default:
break;
}
return (T)result;
}
public bool GetServerConnection()
{
return Do<bool>(RunTimeInvokeType.GetServerConnection);
}
public ConnectResult Connect()
{
return Do<ConnectResult>(RunTimeInvokeType.Connect);
}
public void Disconnect()
{
Do<object>(RunTimeInvokeType.Disconnect);
}
public void Disconnected()
{
Do<object>(RunTimeInvokeType.Disconnected);
}
public bool Close()
{
return Do<bool>(RunTimeInvokeType.Close);
}
public bool Error(Exception e)
{
return Do<bool>(RunTimeInvokeType.Close, e);
}
public async Task AutoLogin(params object[] objs)
{
try
{
Do<object>(RunTimeInvokeType.AutoLogin);
LoginController LoginController = new();
await LoginController.LoginAccount(objs);
LoginController.Dispose();
}
catch (Exception e)
{
RunTime.WriteGameInfo(e.GetErrorInfo());
}
}
}
}

View File

@ -1,6 +0,0 @@
namespace Milimoe.FunGame.Desktop.Controller
{
public class StoreController
{
}
}

View File

@ -1,6 +0,0 @@
namespace Milimoe.FunGame.Desktop.Controller
{
public class UserCenterController
{
}
}

View File

@ -1,72 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>Images\logo.ico</ApplicationIcon>
<Copyright></Copyright>
<PackageIcon>logo.ico</PackageIcon>
<Company>Milimoe</Company>
<BaseOutputPath>..\bin</BaseOutputPath>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<SignAssembly>False</SignAssembly>
<Authors>Milimoe</Authors>
<Product>FunGame</Product>
<Title>FunGame.Desktop</Title>
<PackageOutputPath>..\bin</PackageOutputPath>
<AssemblyVersion>1.0</AssemblyVersion>
<FileVersion>1.0</FileVersion>
<RootNamespace>Milimoe.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<Content Include="Images\logo.ico" />
</ItemGroup>
<ItemGroup>
<Compile Update="Library\Component\MinButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="UI\Login\Login.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FunGame.Core\FunGame.Core.csproj">
<CopyLocalSatelliteAssemblies>True</CopyLocalSatelliteAssemblies>
</ProjectReference>
<ProjectReference Include="..\FunGame.Implement\FunGame.Implement.csproj">
<CopyLocalSatelliteAssemblies>True</CopyLocalSatelliteAssemblies>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Update="Images\logo.ico">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
</Project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

Some files were not shown because too many files have changed in this diff Show More