Removed the hackery that was being done with the plugin configuration dialogs on...
[dolphin.git] / Source / Core / Common / Src / Plugin.cpp
blob271b044ac34bf5f2be9b272321cf836216c6ae77
1 // Copyright (C) 2003 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
18 // --------------------------------------------------------------------------------------------
19 // This is the common Plugin class that links to the functions that are
20 // common to all plugins. This class is inherited by all plugin classes. But it's only created
21 // directly in PluginManager.cpp when we check if a plugin is valid or not.
22 // --------------------------------------------------------------------------------------------
24 #include "Plugin.h"
26 namespace Common
29 CPlugin::~CPlugin()
31 m_hInstLib.Unload();
34 CPlugin::CPlugin(const char* _szName) : valid(false)
36 m_GetDllInfo = NULL;
37 m_DllConfig = NULL;
38 m_DllDebugger = NULL;
39 m_SetDllGlobals = NULL;
40 m_Initialize = NULL;
41 m_Shutdown = NULL;
42 m_DoState = NULL;
43 m_EmuStateChange = NULL;
45 if (m_hInstLib.Load(_szName))
47 m_GetDllInfo = reinterpret_cast<TGetDllInfo>
48 (m_hInstLib.Get("GetDllInfo"));
49 m_DllConfig = reinterpret_cast<TDllConfig>
50 (m_hInstLib.Get("DllConfig"));
51 m_DllDebugger = reinterpret_cast<TDllDebugger>
52 (m_hInstLib.Get("DllDebugger"));
53 m_SetDllGlobals = reinterpret_cast<TSetDllGlobals>
54 (m_hInstLib.Get("SetDllGlobals"));
55 m_Initialize = reinterpret_cast<TInitialize>
56 (m_hInstLib.Get("Initialize"));
57 m_Shutdown = reinterpret_cast<TShutdown>
58 (m_hInstLib.Get("Shutdown"));
59 m_DoState = reinterpret_cast<TDoState>
60 (m_hInstLib.Get("DoState"));
61 m_EmuStateChange = reinterpret_cast<TEmuStateChange>
62 (m_hInstLib.Get("EmuStateChange"));
64 // Check if the plugin has all the functions it should have
65 if (m_GetDllInfo != 0 &&
66 m_DllConfig != 0 &&
67 m_DllDebugger != 0 &&
68 m_SetDllGlobals != 0 &&
69 m_Initialize != 0 &&
70 m_Shutdown != 0 &&
71 m_DoState != 0 &&
72 m_EmuStateChange != 0)
73 valid = true;
76 // Save the filename for this plugin
77 Filename = _szName;
80 void *CPlugin::LoadSymbol(const char *sym)
82 return m_hInstLib.Get(sym);
85 // GetInfo: Get DLL info
86 bool CPlugin::GetInfo(PLUGIN_INFO& _pluginInfo)
88 if (m_GetDllInfo != NULL) {
89 m_GetDllInfo(&_pluginInfo);
90 return true;
92 return false;
95 // Config: Open the Config window
96 void CPlugin::Config(void *_hwnd)
98 if (m_DllConfig != NULL)
99 m_DllConfig(_hwnd);
102 // Debug: Open the Debugging window
103 void *CPlugin::Debug(void *Parent, bool Show)
105 return m_DllDebugger(Parent, Show);
108 void CPlugin::SetGlobals(PLUGIN_GLOBALS* _pluginGlobals) {
109 if (m_SetDllGlobals != NULL)
110 m_SetDllGlobals(_pluginGlobals);
113 void CPlugin::DoState(unsigned char **ptr, int mode) {
114 if (m_DoState != NULL)
115 m_DoState(ptr, mode);
118 void CPlugin::EmuStateChange(PLUGIN_EMUSTATE newState) {
119 if (m_EmuStateChange != NULL)
120 m_EmuStateChange(newState);
123 void CPlugin::Initialize(void *init)
125 if (m_Initialize != NULL)
126 m_Initialize(init);
129 void CPlugin::Shutdown()
131 if (m_Shutdown != NULL)
132 m_Shutdown();
135 } // Namespace