-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.cpp
More file actions
28 lines (23 loc) · 924 Bytes
/
Copy pathsettings.cpp
File metadata and controls
28 lines (23 loc) · 924 Bytes
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
#include "settings.h"
#include <fstream>
#include <nlohmann/json.hpp>
// Function to load settings from a JSON file
Settings loadSettings(const std::string& filename) {
std::ifstream file(filename);
nlohmann::json j;
file >> j;
Settings settings;
settings.targetFPS = j["fps"];
settings.backGroundColors = j["background-colors"].get<std::vector<std::array<float, 4>>>();
settings.stars.radius = j["stars"]["radius"];
settings.stars.segments = j["stars"]["segments"];
settings.stars.color = j["stars"]["color"].get<std::array<float, 4>>();
settings.stars.count = j["stars"]["count"];
settings.stars.minSpeed = j["stars"]["min-speed"];
settings.stars.maxSpeed = j["stars"]["max-speed"];
settings.lineColor = j["line-color"].get<std::array<float, 4>>();
settings.lineMinWidth = j["line-min-width"];
settings.lineMaxWidth = j["line-max-width"];
settings.mouseRadius = j["mouse-radius"];
return settings;
}