2022-03-17 15:53:45 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include "../debug/Log.hpp"
|
|
|
|
#include <unordered_map>
|
|
|
|
#include "../defines.hpp"
|
|
|
|
#include <vector>
|
2022-03-17 16:56:33 +01:00
|
|
|
#include <deque>
|
2022-03-17 15:53:45 +01:00
|
|
|
|
|
|
|
struct SConfigValue {
|
|
|
|
int64_t intValue = -1;
|
|
|
|
float floatValue = -1;
|
|
|
|
std::string strValue = "";
|
|
|
|
};
|
|
|
|
|
2022-03-17 16:56:33 +01:00
|
|
|
struct SMonitorRule {
|
|
|
|
std::string name = "";
|
|
|
|
Vector2D resolution = Vector2D(1280,720);
|
|
|
|
Vector2D offset = Vector2D(0,0);
|
|
|
|
float mfact = 0.5;
|
|
|
|
float scale = 1;
|
|
|
|
};
|
|
|
|
|
2022-03-17 15:53:45 +01:00
|
|
|
class CConfigManager {
|
|
|
|
public:
|
|
|
|
CConfigManager();
|
|
|
|
|
|
|
|
void tick();
|
2022-03-17 17:08:54 +01:00
|
|
|
void init();
|
2022-03-17 15:53:45 +01:00
|
|
|
|
|
|
|
int getInt(std::string);
|
|
|
|
float getFloat(std::string);
|
|
|
|
std::string getString(std::string);
|
|
|
|
|
2022-03-17 16:56:33 +01:00
|
|
|
SMonitorRule getMonitorRuleFor(std::string);
|
|
|
|
|
2022-03-17 15:53:45 +01:00
|
|
|
private:
|
|
|
|
std::unordered_map<std::string, SConfigValue> configValues;
|
|
|
|
time_t lastModifyTime = 0; // for reloading the config if changed
|
|
|
|
|
|
|
|
std::string currentCategory = ""; // For storing the category of the current item
|
|
|
|
|
|
|
|
std::string parseError = ""; // For storing a parse error to display later
|
|
|
|
|
|
|
|
bool isFirstLaunch = true; // For exec-once
|
|
|
|
|
2022-03-17 16:56:33 +01:00
|
|
|
std::deque<SMonitorRule> m_dMonitorRules;
|
|
|
|
|
2022-03-17 15:53:45 +01:00
|
|
|
// internal methods
|
|
|
|
void loadConfigLoadVars();
|
|
|
|
SConfigValue getConfigValueSafe(std::string);
|
|
|
|
void parseLine(std::string&);
|
|
|
|
void configSetValueSafe(const std::string&, const std::string&);
|
|
|
|
void handleRawExec(const std::string&, const std::string&);
|
2022-03-17 16:56:33 +01:00
|
|
|
void handleMonitor(const std::string&, const std::string&);
|
2022-03-19 17:48:18 +01:00
|
|
|
void handleBind(const std::string&, const std::string&);
|
2022-03-17 15:53:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
inline std::unique_ptr<CConfigManager> g_pConfigManager;
|