mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 02:23:01 +08:00
update vs solution
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
#include "Configer.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <Windows.h>
|
||||
|
||||
#include "json.h"
|
||||
|
||||
using namespace MeoAssistance;
|
||||
|
||||
json::object Configer::dataObj;
|
||||
json::object Configer::handleObj;
|
||||
|
||||
std::string Configer::m_curDir;
|
||||
|
||||
bool Configer::reload()
|
||||
{
|
||||
std::string filename = getResDir() + "config.json";
|
||||
std::ifstream ifs(filename, std::ios::in);
|
||||
if (!ifs.is_open()) {
|
||||
return false;
|
||||
}
|
||||
std::stringstream iss;
|
||||
iss << ifs.rdbuf();
|
||||
ifs.close();
|
||||
std::string content(iss.str());
|
||||
|
||||
auto ret = json::parser::parse(content);
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto root = std::move(ret).value();
|
||||
dataObj = root["data"].as_object();
|
||||
handleObj = root["handle"].as_object();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Configer::getCurDir()
|
||||
{
|
||||
if (m_curDir.empty()) {
|
||||
char exepath_buff[_MAX_PATH] = { 0 };
|
||||
::GetModuleFileNameA(NULL, exepath_buff, _MAX_PATH);
|
||||
std::string exepath(exepath_buff);
|
||||
m_curDir = exepath.substr(0, exepath.find_last_of('\\') + 1);
|
||||
}
|
||||
return m_curDir;
|
||||
}
|
||||
|
||||
std::string Configer::getResDir()
|
||||
{
|
||||
return getCurDir() + "resource\\";
|
||||
}
|
||||
Reference in New Issue
Block a user