-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.h
48 lines (43 loc) · 1.52 KB
/
config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include "controllers.h"
#ifdef _UI_SDL_EVENT_HANDLER_H_
#include "SDL_EventHandler.h"
#endif
#include "host.h"
#include "log.h"
#include "plugins/components/drawInterface.h"
#include "styles.h"
#include "viewManager.h"
#include "plugins/components/utils/color.h"
#include <fstream>
void loadJsonConfig(std::string configPath)
{
try {
std::ifstream configFile(configPath);
if (configFile.is_open()) {
nlohmann::json config = nlohmann::json::parse(configFile);
configFile.close();
if (config.contains("audio")) {
logInfo("----------- init audio -------------");
hostConfig(config["audio"]);
}
logInfo("----------- init controllers -------------");
lastPluginControllerInstance->config(config); // <--- not very nice!!!!
if (config.contains("controllers")) {
// TODO to be implemented...
}
// Should happen before views
if (config.contains("screen")) {
logInfo("----------- init screen / draw -------------");
ViewManager::get().draw.config(config["screen"]);
}
if (config.contains("views")) {
logInfo("----------- init views -------------");
ViewManager::get().config(config["views"]);
}
}
logInfo("----------- config done -------------");
} catch (const std::exception& e) {
logError("load json config: %s", e.what());
}
}