mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-11-27 07:44:02 +08:00
up
This commit is contained in:
parent
4eb6ad29a2
commit
245259e0cc
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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
|
@ -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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -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<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;
|
||||
|
@ -16,7 +16,6 @@ struct pluginitem
|
||||
{
|
||||
std::string path;
|
||||
bool isQt;
|
||||
bool isref;
|
||||
bool enable;
|
||||
bool vissetting;
|
||||
pluginitem(const nlohmann::json &);
|
||||
|
Loading…
Reference in New Issue
Block a user