diff --git a/CMakeLists.txt b/CMakeLists.txt index d437562..c94a1e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,9 +60,9 @@ include_directories(include) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version) include(generate_product_version) -set(VERSION_MAJOR 3) -set(VERSION_MINOR 16) -set(VERSION_PATCH 3) +set(VERSION_MAJOR 5) +set(VERSION_MINOR 0) +set(VERSION_PATCH 0) set(VERSION_REVISION 0) if(BUILD_CORE) diff --git a/LunaHost/GUI/confighelper.cpp b/LunaHost/GUI/confighelper.cpp index cec85ef..181eddb 100644 --- a/LunaHost/GUI/confighelper.cpp +++ b/LunaHost/GUI/confighelper.cpp @@ -25,7 +25,7 @@ void writefile(const wchar_t *fname, const std::string &s) confighelper::confighelper() { - configpath = std::filesystem::current_path() / (x64 ? "config64.json" : "config32.json"); + configpath = std::filesystem::current_path() / "config.json"; try { configs = nlohmann::json::parse(readfile(configpath.c_str())); @@ -35,9 +35,9 @@ confighelper::confighelper() configs = {}; } - if (configs.find("plugins") == configs.end()) + if (configs.find(pluginkey) == configs.end()) { - configs["plugins"] = {}; + configs[pluginkey] = {}; } } confighelper::~confighelper() diff --git a/LunaHost/GUI/confighelper.h b/LunaHost/GUI/confighelper.h index 6888ce6..b21922e 100644 --- a/LunaHost/GUI/confighelper.h +++ b/LunaHost/GUI/confighelper.h @@ -32,4 +32,7 @@ T safequeryjson(const nlohmann::json &js, const std::string &key, const T &defau } return js[key]; } + +constexpr auto pluginkey = x64 ? "plugins64" : "plugins32"; + #endif \ No newline at end of file diff --git a/LunaHost/GUI/pluginmanager.cpp b/LunaHost/GUI/pluginmanager.cpp index 75b9730..2c181ba 100644 --- a/LunaHost/GUI/pluginmanager.cpp +++ b/LunaHost/GUI/pluginmanager.cpp @@ -148,53 +148,47 @@ bool Pluginmanager::dispatch(TextThread &thread, std::wstring &sentence) void Pluginmanager::add(const pluginitem &item) { - configs->configs["plugins"].push_back(item.dump()); + configs->configs[pluginkey].push_back(item.dump()); } int Pluginmanager::count() { - return configs->configs["plugins"].size(); + return configs->configs[pluginkey].size(); } pluginitem Pluginmanager::get(int i) { - return pluginitem{configs->configs["plugins"][i]}; + return pluginitem{configs->configs[pluginkey][i]}; } void Pluginmanager::set(int i, const pluginitem &item) { - configs->configs["plugins"][i] = item.dump(); + configs->configs[pluginkey][i] = item.dump(); } pluginitem::pluginitem(const nlohmann::json &js) { path = js["path"]; isQt = safequeryjson(js, "isQt", false); - isref = safequeryjson(js, "isref", false); enable = safequeryjson(js, "enable", true); vissetting = safequeryjson(js, "vissetting", true); } std::wstring pluginitem::wpath() { auto wp = StringToWideString(path); - if (isref) - return std::filesystem::absolute(wp); - else - return wp; + return std::filesystem::absolute(wp); } -std::pair castabs2ref(const std::wstring &p) +std::wstring castabs2ref(const std::wstring &p) { auto curr = std::filesystem::current_path().wstring(); if (startWith(p, curr)) { - return {p.substr(curr.size() + 1), true}; + return p.substr(curr.size() + 1); } - return {p, false}; + return p; } pluginitem::pluginitem(const std::wstring &pabs, bool _isQt) { isQt = _isQt; - auto [p, _isref] = castabs2ref(pabs); - isref = _isref; - path = WideStringToString(p); + path = WideStringToString(castabs2ref(pabs)); enable = true; vissetting = true; } @@ -203,7 +197,6 @@ nlohmann::json pluginitem::dump() const return { {"path", path}, {"isQt", isQt}, - {"isref", isref}, {"enable", enable}, {"vissetting", vissetting}}; } @@ -268,7 +261,7 @@ void Pluginmanager::remove(const std::wstring &wss) unload(wss); auto s = WideStringToString(wss); - auto &plgs = configs->configs["plugins"]; + auto &plgs = configs->configs[pluginkey]; auto it = std::remove_if(plgs.begin(), plgs.end(), [&](auto &t) { std::string p=t["path"]; @@ -282,7 +275,7 @@ std::optional Pluginmanager::selectpluginfile() } void Pluginmanager::swaprank(int a, int b) { - auto &plgs = configs->configs["plugins"]; + auto &plgs = configs->configs[pluginkey]; auto _b = plgs[b]; plgs[b] = plgs[a]; plgs[a] = _b; diff --git a/LunaHost/GUI/pluginmanager.h b/LunaHost/GUI/pluginmanager.h index db5c00e..374a9d4 100644 --- a/LunaHost/GUI/pluginmanager.h +++ b/LunaHost/GUI/pluginmanager.h @@ -16,7 +16,6 @@ struct pluginitem { std::string path; bool isQt; - bool isref; bool enable; bool vissetting; pluginitem(const nlohmann::json &);