mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 13:43:41 +00:00
Made the process of adding a custom Config file work via a Virtual function within Game.h
27 lines
539 B
C++
27 lines
539 B
C++
#pragma once
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
using json = nlohmann::json;
|
|
|
|
class ConfigLoader {
|
|
|
|
public:
|
|
ConfigLoader();
|
|
~ConfigLoader();
|
|
|
|
void init();
|
|
|
|
void setCustomConfig(const std::optional<std::string>& path);
|
|
|
|
json getFinalConfig();
|
|
|
|
private:
|
|
json baseConfig;
|
|
std::optional<json> customConfig;
|
|
json finalConfig;
|
|
|
|
json loadConfigFromJSON(const std::string& path);
|
|
json mergeConfigs(json baseConfig, json customConfig); //<! Merges 2 config.json files, prioritising the custom to the base one
|
|
};
|