feat: parse AppSettings for BaseUrl and fixes
This commit is contained in:
parent
b3e5853224
commit
1f765381c3
|
|
@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.4)
|
|||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# TODO: This shouldn't be necessary.
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
|
||||
project(Kiseki.Patcher VERSION 1.0.0)
|
||||
|
||||
option(COMPILE_PLAYER "Include player-specific code" OFF)
|
||||
|
|
|
|||
|
|
@ -43,12 +43,14 @@ add_library(Kiseki.Patcher SHARED ${SOURCE} ${HEADER})
|
|||
|
||||
# Packages
|
||||
find_package(CURL CONFIG REQUIRED)
|
||||
find_package(rapidjson CONFIG REQUIRED)
|
||||
find_package(pugixml CONFIG REQUIRED)
|
||||
|
||||
find_path(DETOURS_INCLUDE_DIRS "detours/detours.h")
|
||||
find_library(DETOURS_LIBRARY detours REQUIRED)
|
||||
|
||||
target_include_directories(Kiseki.Patcher PRIVATE Header ${DETOURS_INCLUDE_DIRS})
|
||||
target_link_libraries(Kiseki.Patcher PRIVATE CURL::libcurl ${DETOURS_LIBRARY})
|
||||
target_link_libraries(Kiseki.Patcher PRIVATE CURL::libcurl ${DETOURS_LIBRARY} pugixml::static pugixml::pugixml rapidjson)
|
||||
|
||||
# Target-specific linking and compile options
|
||||
if(COMPILE_PLAYER)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <discord_rpc.h>
|
||||
#include <discord_register.h>
|
||||
#include <rapidjson/document.h>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <map>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <pugixml.hpp>
|
||||
|
||||
#include "Globals.hpp"
|
||||
|
||||
|
|
@ -30,4 +31,5 @@ public:
|
|||
static std::string getISOTimestamp();
|
||||
static std::pair<bool, std::map<std::string, std::string>> parseURL(const std::string url);
|
||||
static std::pair<bool, std::string> httpGet(const std::string url);
|
||||
static std::string getBaseUrl();
|
||||
};
|
||||
|
|
@ -211,3 +211,27 @@ std::pair<bool, std::string> Helpers::httpGet(const std::string url)
|
|||
|
||||
return std::make_pair(true, data);
|
||||
}
|
||||
|
||||
std::string Helpers::getBaseUrl()
|
||||
{
|
||||
std::string path = Helpers::getModulePath();
|
||||
path = path.substr(0, path.find_last_of("\\/"));
|
||||
|
||||
pugi::xml_document document;
|
||||
pugi::xml_parse_result result = document.load_file((path + "\\AppSettings.xml").c_str());
|
||||
|
||||
if (!result)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
pugi::xml_node settings = document.child("Settings");
|
||||
pugi::xml_node baseUrl = settings.child("BaseUrl");
|
||||
|
||||
if (!baseUrl)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return baseUrl.child_value();
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
"curl",
|
||||
"detours",
|
||||
"discord-rpc",
|
||||
"pugixml",
|
||||
"rapidjson"
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue