123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using GameEditorPlugin.Win32.Editor;
- using GameEditorPlugin.Win32.Runtime;
- using System;
- using System.IO;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- using CommonAI.Zone.ZoneEditor;
- namespace CommonAIEditor.Plugins.Win32
- {
- public partial class Win32ScenePlugin : ISceneEditorPlugin
- {
- private Win32EditorPanel panel;
- public Win32ScenePlugin()
- {
- panel = new Win32EditorPanel(this);
- }
- //------------------------------------------------------------------------------
- public bool EnableRight { get { return true; } }
- public event PluginMessageHandler OnGetPluginMessage;
- public event CallAddSceneObject CallAddObject;
- public event CallResetSceneObject CallResetObject;
- public Control AsControl()
- {
- return panel;
- }
-
- public void SendMessage(object dt)
- {
- //string xml = EditorMessageDecoder.EncodeMessage(dt);
- //object data = EditorMessageDecoder.DecodeMessage(xml);
- panel.OnMsgReceived(dt);
- }
- class Win32EditorPanel : EditorDisplayPanel
- {
- private readonly Win32ScenePlugin plugin;
- public Win32EditorPanel(Win32ScenePlugin plugin)
- {
- this.plugin = plugin;
- }
- public override void SendToEditor(object data)
- {
- if (plugin.OnGetPluginMessage != null)
- {
- plugin.OnGetPluginMessage.Invoke(data);
- }
- }
- protected override T CallAddObjectData<T>(Action<T> callback)
- {
- if (plugin.CallAddObject != null)
- {
- return plugin.CallAddObject.Invoke(typeof(T), (t) => { callback.Invoke(t as T); }) as T;
- }
- return null;
- }
- protected override T CallResetObjectData<T>(string name, Action<T> callback)
- {
- if (plugin.CallResetObject != null)
- {
- return plugin.CallResetObject.Invoke(name, (t) => { if (t is T) { callback.Invoke(t as T); } }) as T;
- }
- return null;
- }
- }
- }
- public class Win32EditorGamePlugin : IGameEditorPlugin
- {
- [DllImport("user32.dll", SetLastError = true)]
- static extern void SwitchToThisWindow(IntPtr hWnd, bool turnOn);
- public string Name { get { return "Win32"; } }
- public string PluginDLL { get { return EditorPlugin.PluginDLL; } set { } }
- public string DataRoot { get { return Editor.EditorRootDir; } set { } }
- public ISceneEditorPlugin CreateScenePlugin(IGameEditorPlugin default_plugin)
- {
- return new Win32ScenePlugin();
- }
- public bool AcceptResource(IGameEditorPlugin d, string filename)
- {
- return true;
- }
- public void RunModelView(IGameEditorPlugin d, string[] filepath)
- {
- }
- public void RunTest(IGameEditorPlugin d, string data_dir, int sceneID, int actorTemplateID)
- {
- FormRuntimeGameLocal test = new FormRuntimeGameLocal(new DirectoryInfo(data_dir), sceneID);
- test.Show();
- }
- public void RunLocalPlay(IGameEditorPlugin d, DirectoryInfo data_dir, int sceneID, bool recorder)
- {
- new FormRuntimeGameLocal(data_dir, sceneID, recorder).Show();
- }
- public void RunServerPlay(IGameEditorPlugin d, DirectoryInfo data_dir, int sceneID)
- {
- new GameEditorPluginServer.Server.FormServer(data_dir, sceneID).Show();
- }
- }
- }
|