public NativePlugin(string fileName) { _editorInterface.version = 1; _editorInterface.pluginID = NextPluginID; NextPluginID++; _editorInterface.GetEditorHandle = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.GetEditorHandleDelegate); _editorInterface.GetWindowHandle = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.GetWindowHandleDelegate); _editorInterface.RegisterScriptHeader = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.RegisterScriptHeaderDelegate); _editorInterface.UnregisterScriptHeader = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.UnregisterScriptHeaderDelegate); _dllHandle = NativeProxy.LoadLibrary(fileName); if (_dllHandle == IntPtr.Zero) { throw new AGSEditorException("Unable to load plugin '" + fileName + "'. It may depend on another DLL that is missing."); } _getPluginName = (AGS_GetPluginName)GetManagedDelegateForFunction("AGS_GetPluginName", typeof(AGS_GetPluginName), true); _editorStartup = (AGS_EditorStartup)GetManagedDelegateForFunction("AGS_EditorStartup", typeof(AGS_EditorStartup), true); _editorShutdown = (AGS_EditorShutdown)GetManagedDelegateForFunction("AGS_EditorShutdown", typeof(AGS_EditorShutdown), true); _editorProperties = (AGS_EditorProperties)GetManagedDelegateForFunction("AGS_EditorProperties", typeof(AGS_EditorProperties), false); _editorSaveGame = (AGS_EditorSaveGame)GetManagedDelegateForFunction("AGS_EditorSaveGame", typeof(AGS_EditorSaveGame), false); _editorLoadGame = (AGS_EditorLoadGame)GetManagedDelegateForFunction("AGS_EditorLoadGame", typeof(AGS_EditorLoadGame), false); _pluginName = Marshal.PtrToStringAnsi(_getPluginName()); _fileName = fileName; PluginLookup.Add(_editorInterface.pluginID, this); }
public ApplicationController() { _events = Factory.Events; _agsEditor = Factory.AGSEditor; _guiController = Factory.GUIController; _componentController = Factory.ComponentController; _nativeProxy = Factory.NativeProxy; _pluginEditorController = new AGSEditorController(_componentController, _agsEditor, _guiController); _events.GameLoad += new EditorEvents.GameLoadHandler(_events_GameLoad); _events.GamePostLoad += new EditorEvents.GamePostLoadHandler(_events_GamePostLoad); _events.GameSettingsChanged += new EditorEvents.ParameterlessDelegate(_events_GameSettingsChanged); _events.ImportedOldGame += new EditorEvents.ParameterlessDelegate(_events_ImportedOldGame); _events.RefreshAllComponentsFromGame += new EditorEvents.ParameterlessDelegate(_events_RefreshAllComponentsFromGame); _events.SavingGame += new EditorEvents.SavingGameHandler(_events_SavingGame); _events.SavingUserData += new EditorEvents.SavingUserDataHandler(_events_SavingUserData); _events.LoadedUserData += new EditorEvents.LoadedUserDataHandler(_events_LoadedUserData); _agsEditor.PreSaveGame += new AGSEditor.PreSaveGameHandler(_agsEditor_PreSaveGame); _guiController.OnEditorShutdown += new GUIController.EditorShutdownHandler(GUIController_OnEditorShutdown); _guiController.Initialize(_agsEditor); _agsEditor.DoEditorInitialization(); AGSColor.ColorMapper = new ColorMapper(_agsEditor); CreateComponents(); }
public ApplicationController() { _events = Factory.Events; _agsEditor = Factory.AGSEditor; _guiController = Factory.GUIController; _componentController = Factory.ComponentController; _nativeProxy = Factory.NativeProxy; _pluginEditorController = new AGSEditorController(_componentController, _agsEditor, _guiController); _events.GameLoad += new EditorEvents.GameLoadHandler(_events_GameLoad); _events.GamePostLoad += new EditorEvents.GamePostLoadHandler(_events_GamePostLoad); _events.GameSettingsChanged += new EditorEvents.ParameterlessDelegate(_events_GameSettingsChanged); _events.ImportedOldGame += new EditorEvents.ParameterlessDelegate(_events_ImportedOldGame); _events.RefreshAllComponentsFromGame += new EditorEvents.ParameterlessDelegate(_events_RefreshAllComponentsFromGame); _events.SavingGame += new EditorEvents.SavingGameHandler(_events_SavingGame); _events.SavingUserData += new EditorEvents.SavingUserDataHandler(_events_SavingUserData); _events.LoadedUserData += new EditorEvents.LoadedUserDataHandler(_events_LoadedUserData); _agsEditor.PreSaveGame += new AGSEditor.PreSaveGameHandler(_agsEditor_PreSaveGame); _guiController.OnEditorShutdown += new GUIController.EditorShutdownHandler(GUIController_OnEditorShutdown); _guiController.Initialize(_agsEditor); _agsEditor.DoEditorInitialization(); AGSColor.ColorMapper = new ColorMapper(_agsEditor); CreateComponents(); }
private void SendCommandAndSwitchWindows(string command) { ClearCurrentLineMarker(); ChangeDebugState(DebugState.Running); if (_engineWindowHandle != IntPtr.Zero) { NativeProxy.SetForegroundWindow(_engineWindowHandle); } _communicator.SendMessage("<Engine Command=\"" + command + "\" />"); }
public void Dispose() { if (_dllHandle != IntPtr.Zero) { if (_enabled) { StopPlugin(); } NativeProxy.FreeLibrary(_dllHandle); _dllHandle = IntPtr.Zero; } }
private Delegate GetManagedDelegateForFunction(string functionName, Type delegateType, bool mustExist) { IntPtr pAddressOfFunctionToCall = NativeProxy.GetProcAddress(_dllHandle, functionName); if (pAddressOfFunctionToCall == IntPtr.Zero) { if (mustExist) { throw new AGSEditorException("Function '" + functionName + "' not exported from plugin"); } return(null); } return(Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, delegateType)); }
private void SendCommandAndSwitchWindows(string command) { ClearCurrentLineMarker(); ChangeDebugState(DebugState.Running); if (_engineWindowHandle != IntPtr.Zero) { if (Utilities.IsMonoRunning()) { //Is there any way of doing this in mono? I couldn't find any. //I guess the user will have to bring the game back to focus by himself... } else { NativeProxy.SetForegroundWindow(_engineWindowHandle); } } _communicator.SendMessage("<Engine Command=\"" + command + "\" />"); }
private void WriteAndroidCfg(string outputDir) { string configPath = Path.Combine(outputDir, ANDROID_CFG); RuntimeSetup setup = Factory.AGSEditor.CurrentGame.DefaultSetup; int rotation = (int)setup.Rotation; NativeProxy.WritePrivateProfileString("misc", "config_enabled", "1", configPath); NativeProxy.WritePrivateProfileString("misc", "rotation", rotation.ToString(), configPath); NativeProxy.WritePrivateProfileString("misc", "translation", setup.Translation, configPath); NativeProxy.WritePrivateProfileString("controls", "mouse_method", "0", configPath); NativeProxy.WritePrivateProfileString("controls", "mouse_longclick", "1", configPath); NativeProxy.WritePrivateProfileString("compatibility", "clear_cache_on_room_change", "0", configPath); NativeProxy.WritePrivateProfileString("sound", "samplerate", "44100", configPath); NativeProxy.WritePrivateProfileString("sound", "enabled", "1", configPath); NativeProxy.WritePrivateProfileString("sound", "threaded", "1", configPath); NativeProxy.WritePrivateProfileString("sound", "cache_size", "64", configPath); NativeProxy.WritePrivateProfileString("midi", "enabled", "0", configPath); NativeProxy.WritePrivateProfileString("midi", "preload_patches", "0", configPath); NativeProxy.WritePrivateProfileString("video", "framedrop", "0", configPath); if (setup.GraphicsDriver == GraphicsDriver.Software) { NativeProxy.WritePrivateProfileString("graphics", "renderer", "0", configPath); } else { NativeProxy.WritePrivateProfileString("graphics", "renderer", "1", configPath); } if (setup.GraphicsFilter == "StdScale") { NativeProxy.WritePrivateProfileString("graphics", "smoothing", "0", configPath); } else { NativeProxy.WritePrivateProfileString("graphics", "smoothing", "1", configPath); } if (setup.FullscreenGameScaling == GameScaling.ProportionalStretch) { NativeProxy.WritePrivateProfileString("graphics", "scaling", "1", configPath); } else if (setup.FullscreenGameScaling == GameScaling.StretchToFit) { NativeProxy.WritePrivateProfileString("graphics", "scaling", "2", configPath); } else { NativeProxy.WritePrivateProfileString("graphics", "scaling", "0", configPath); } NativeProxy.WritePrivateProfileString("graphics", "super_sampling", "0", configPath); NativeProxy.WritePrivateProfileString("graphics", "smooth_sprites", setup.AAScaledSprites ? "1" : "0", configPath); NativeProxy.WritePrivateProfileString("debug", "show_fps", "0", configPath); NativeProxy.WritePrivateProfileString("debug", "logging", "0", configPath); }