| 1016 | } |
| 1017 | |
| 1018 | static bool Load(std::map<String, PluginArrayPtr>& plugins, String& errmsg) |
| 1019 | { |
| 1020 | if (plugins.find(L"EDITOR_SCRIPT") != plugins.end()) |
| 1021 | { |
| 1022 | for (auto plugin : *plugins[L"EDITOR_SCRIPT"]) |
| 1023 | { |
| 1024 | if (!plugin->m_disabled && plugin->GetExtendedPropertyValue(_T("GenerateUnpacker")).has_value()) |
| 1025 | { |
| 1026 | std::vector<String> namesArray; |
| 1027 | std::vector<int> idArray; |
| 1028 | int validFuncs = plugin::GetMethodsFromScript(plugin->m_lpDispatch, namesArray, idArray); |
| 1029 | for (int i = 0; i < validFuncs; ++i) |
| 1030 | { |
| 1031 | if (namesArray[i] == L"PluginOnEvent" || namesArray[i] == L"ShowSettingsDialog") |
| 1032 | continue; |
| 1033 | if (plugins.find(L"FILE_PACK_UNPACK") == plugins.end()) |
| 1034 | plugins[L"FILE_PACK_UNPACK"].reset(new PluginArray); |
| 1035 | PluginInfoPtr pluginNew(new PluginInfo()); |
| 1036 | IDispatch* pDispatch = new UnpackerGeneratedFromEditorScript(*plugin, namesArray[i], idArray[i]); |
| 1037 | pDispatch->AddRef(); |
| 1038 | pluginNew->MakeInfo(plugin->m_filepath, namesArray[i], pDispatch); |
| 1039 | plugins[L"FILE_PACK_UNPACK"]->push_back(pluginNew); |
| 1040 | } |
| 1041 | } |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | std::list<Info> internalPlugins; |
| 1046 | for (auto locationType : {LocationType::InstallationPath, LocationType::AppDataPath, LocationType::DocumentsPath}) |
| 1047 | { |
| 1048 | if (!LoadFromXML(locationType, internalPlugins, errmsg)) |
| 1049 | return false; |
| 1050 | } |
| 1051 | |
| 1052 | for (auto& info : internalPlugins) |
| 1053 | { |
| 1054 | String event = info.m_event; |
| 1055 | String name = info.m_name; |
| 1056 | if (plugins.find(event) == plugins.end()) |
| 1057 | plugins[event].reset(new PluginArray); |
| 1058 | PluginInfoPtr pluginNew(new PluginInfo()); |
| 1059 | IDispatch* pDispatch = new InternalPlugin(std::move(info)); |
| 1060 | pDispatch->AddRef(); |
| 1061 | if (pluginNew->MakeInfo(GetPluginXMLPath(info.m_locationType), name, pDispatch) > 0) |
| 1062 | plugins[event]->push_back(pluginNew); |
| 1063 | } |
| 1064 | |
| 1065 | if (plugins.find(L"FILE_PACK_UNPACK") != plugins.end()) |
| 1066 | { |
| 1067 | for (auto plugin : *plugins[L"FILE_PACK_UNPACK"]) |
| 1068 | { |
| 1069 | if (!plugin->m_disabled && plugin->GetExtendedPropertyValue(_T("GenerateEditorScript")).has_value()) |
| 1070 | { |
| 1071 | if (plugins.find(L"EDITOR_SCRIPT") == plugins.end()) |
| 1072 | plugins[L"EDITOR_SCRIPT"].reset(new PluginArray); |
| 1073 | PluginInfoPtr pluginNew(new PluginInfo()); |
| 1074 | IDispatch* pDispatch = new EditorScriptGeneratedFromUnpacker(*plugin, plugin->m_name, plugin->m_hasArgumentsProperty); |
| 1075 | pDispatch->AddRef(); |
nothing calls this directly
no test coverage detected