Skip to content
This repository has been archived by the owner on Nov 17, 2024. It is now read-only.

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Nov 1, 2024
1 parent 4eb6ad2 commit 245259e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions LunaHost/GUI/confighelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand All @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions LunaHost/GUI/confighelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 11 additions & 18 deletions LunaHost/GUI/pluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::wstring, bool> 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;
}
Expand All @@ -203,7 +197,6 @@ nlohmann::json pluginitem::dump() const
return {
{"path", path},
{"isQt", isQt},
{"isref", isref},
{"enable", enable},
{"vissetting", vissetting}};
}
Expand Down Expand Up @@ -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"];
Expand All @@ -282,7 +275,7 @@ std::optional<std::wstring> 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;
Expand Down
1 change: 0 additions & 1 deletion LunaHost/GUI/pluginmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ struct pluginitem
{
std::string path;
bool isQt;
bool isref;
bool enable;
bool vissetting;
pluginitem(const nlohmann::json &);
Expand Down

0 comments on commit 245259e

Please sign in to comment.