mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-04 23:06:25 +00:00
added tomlplusplus and start of config parsing
This commit is contained in:
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -7,3 +7,9 @@
|
||||
[submodule "include/cpp-httplib"]
|
||||
path = include/cpp-httplib
|
||||
url = https://github.com/yhirose/cpp-httplib.git
|
||||
[submodule "include/tomlplusplus"]
|
||||
path = include/tomlplusplus
|
||||
url = https://github.com/marzer/tomlplusplus.git
|
||||
[submodule "include/easyloggingpp"]
|
||||
path = include/easyloggingpp
|
||||
url = https://github.com/amrayn/easyloggingpp.git
|
||||
|
||||
@@ -17,17 +17,21 @@ endif(WIN32)
|
||||
|
||||
set(wxUSE_STL ON)
|
||||
set(wxBUILD_SHARED OFF)
|
||||
set(build_static_lib ON)
|
||||
set(wxBUILD_MSVC_MULTIPROC ON)
|
||||
set(wxBUILD_USE_STATIC_RUNTIME ON)
|
||||
|
||||
add_subdirectory(include/wxWidgets)
|
||||
add_subdirectory(include/rapidjson)
|
||||
add_subdirectory(include/cpp-httplib)
|
||||
add_subdirectory(include/tomlplusplus)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
src/main.cpp include/easylogging++.h
|
||||
src/main.cpp include/easyloggingpp/src/easylogging++.cc
|
||||
src/Launcher.cpp include/Launcher.h
|
||||
src/Logger.cpp include/Logger.h
|
||||
src/gui/Gui.cpp include/Json.h
|
||||
@@ -48,4 +52,5 @@ else(WIN32) #MINGW
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -s --static")
|
||||
target_link_libraries(${PROJECT_NAME} discord-rpc ssl crypto ws2_32 ssp crypt32 z)
|
||||
endif(WIN32)
|
||||
add_definitions(-DELPP_NO_DEFAULT_LOG_FILE)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE "include")
|
||||
@@ -4,8 +4,7 @@
|
||||
///
|
||||
|
||||
#pragma once
|
||||
#define ELPP_NO_DEFAULT_LOG_FILE
|
||||
#include "easylogging++.h"
|
||||
#include <easyloggingpp/src/easylogging++.h>
|
||||
|
||||
class Log {
|
||||
public:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1
include/easyloggingpp
Submodule
1
include/easyloggingpp
Submodule
Submodule include/easyloggingpp added at 8489989bb2
1
include/tomlplusplus
Submodule
1
include/tomlplusplus
Submodule
Submodule include/tomlplusplus added at 8e669aa699
@@ -3,8 +3,40 @@
|
||||
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
|
||||
///
|
||||
|
||||
|
||||
#include <tomlplusplus/toml.hpp>
|
||||
#include <filesystem>
|
||||
#include "Launcher.h"
|
||||
#include "Logger.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void Launcher::loadConfig() {
|
||||
|
||||
if(fs::exists("Launcher.cfg")){
|
||||
std::ifstream cfg("Launcher.cfg");
|
||||
if(cfg.is_open()) {
|
||||
auto Size = fs::file_size("Launcher.cfg");
|
||||
std::string Buffer(Size, 0);
|
||||
cfg.read(&Buffer[0], std::streamsize(Size));
|
||||
cfg.close();
|
||||
toml::table config = toml::parse(cfg);
|
||||
LOG(INFO) << "Parsing";
|
||||
if(config["Port"].is_value()) {
|
||||
/*auto Port = config["Port"].as_integer()->get();
|
||||
LOG(INFO) << Port;*/
|
||||
LOG(INFO) << "Got port";
|
||||
}
|
||||
}else LOG(FATAL) << "Failed to open Launcher.cfg!";
|
||||
} else {
|
||||
std::ofstream cfg("Launcher.cfg");
|
||||
if(cfg.is_open()){
|
||||
cfg <<
|
||||
R"(Port = 4444
|
||||
Build = "Default"
|
||||
)";
|
||||
cfg.close();
|
||||
}else{
|
||||
LOG(FATAL) << "Failed to write config on disk!";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,6 @@
|
||||
int main(int argc, char* argv[]) {
|
||||
Launcher launcher(argc, argv);
|
||||
launcher.checkLocalKey();
|
||||
|
||||
launcher.loadConfig();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user