Apply params from config file

pull/28/head
FlightlessMango 4 years ago
parent ebc49ae8c5
commit 33f48c91be

@ -5,11 +5,7 @@
#include "config.h"
#include "overlay_params.h"
#include <vector>
std::vector<const char*> config_params;
void configParams(){
config_params.push_back("height");
}
std::unordered_map<std::string,std::string> options;
void parseConfigLine(std::string line, struct overlay_params *params){
if(line.find("#")!=std::string::npos)
@ -33,12 +29,10 @@ void parseConfigLine(std::string line, struct overlay_params *params){
{
return;
}
std::cout << "set option " << line.substr(0,equal) << " equal to " << line.substr(equal+1) << std::endl;
options.insert({line.substr(0,equal), line.substr(equal+1)});
}
void parseConfigFile(struct overlay_params *params) {
configParams();
std::string home = std::getenv("HOME");
std::string filePath = home + "/.local/share/MangoHud/MangoHud.conf";
std::ifstream stream(filePath);

@ -1 +1,5 @@
void parseConfigFile(struct overlay_params *params);
#include <unordered_map>
extern std::unordered_map<std::string,std::string> options;
void parseConfigFile(struct overlay_params *params);

@ -201,8 +201,26 @@ parse_overlay_env(struct overlay_params *params,
params->toggle_hud = 65481;
params->toggle_logging = 65471;
// Get config options
parseConfigFile(params);
for (auto& it : options) {
#define OVERLAY_PARAM_BOOL(name) \
if (it.first == #name) { \
params->enabled[OVERLAY_PARAM_ENABLED_##name] = \
strtol(it.second.c_str(), NULL, 0); \
continue; \
}
#define OVERLAY_PARAM_CUSTOM(name) \
if (it.first == #name) { \
params->name = parse_##name(it.second.c_str()); \
continue; \
}
OVERLAY_PARAMS
#undef OVERLAY_PARAM_BOOL
#undef OVERLAY_PARAM_CUSTOM
fprintf(stderr, "Unknown option '%s'\n", it.first.c_str());
}
if (!env)
return;

Loading…
Cancel
Save