diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/main.cpp | 5 | ||||
-rw-r--r-- | core/modules.cpp | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/core/main.cpp b/core/main.cpp index 5d324e0..20b8501 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -1,6 +1,9 @@ #include "commonheaders.h" + +PLUGINLINK pluglink; + class EvilCore: public wxApp { public: @@ -10,7 +13,9 @@ public: bool EvilCore::OnInit() { void load_modules(); + void run_plugins(); load_modules(); + run_plugins(); while(true) sleep(10); return 0; diff --git a/core/modules.cpp b/core/modules.cpp index d094311..b509c6f 100644 --- a/core/modules.cpp +++ b/core/modules.cpp @@ -2,6 +2,8 @@ std::list<plugin*> plugins; +extern PLUGINLINK pluglink; + void load_modules() { wxStandardPaths *pth = new wxStandardPaths; @@ -50,7 +52,10 @@ void load_modules() lib_path += filename; wxDynamicLibrary *plug = new wxDynamicLibrary(lib_path); if(!plug->IsLoaded()) + { wxMessageBox(_T("Failed to load plugin") ,_T("Error"), wxOK | wxICON_ERROR); + wxLogDebug(_T("Failed to load plugin\n")); + } bool is_plugin = true; plugin::exported_functions_s *funcs = new plugin::exported_functions_s; if((funcs->Load = (load)plug->GetSymbol(_T("load"))) == NULL) @@ -74,6 +79,15 @@ void load_modules() while(dir.GetNext(&filename)); } +void run_plugins() +{ + if(!plugins.empty()) + for(std::list<plugin*>::iterator i = plugins.begin(); i != plugins.end(); i++) + { + (*i)->get_exported_functions()->Load(&pluglink); + (*i)->get_exported_functions()->OnModulesLoaded(); + } +} plugin::plugin(wxDynamicLibrary *lib, PLUGININFO *info, exported_functions_s *funcs) { @@ -84,3 +98,7 @@ plugin::plugin(wxDynamicLibrary *lib, PLUGININFO *info, exported_functions_s *fu if(funcs) exported_funcs = funcs; } +const plugin::exported_functions_s* plugin::get_exported_functions() +{ + return exported_funcs; +} |