I can now load a json config file name .tarpit.json to configure everything. It now works to configure the sounds used.
parent
268d8abf52
commit
90f4f727ba
@ -0,0 +1,9 @@ |
|||||||
|
{ |
||||||
|
"audio": { |
||||||
|
"you_died": "./assets/you_died.wav", |
||||||
|
"build_works": "./assets/build_works.wav", |
||||||
|
"build_failed": "./assets/build_failed.wav", |
||||||
|
"building": "./assets/building.wav" |
||||||
|
}, |
||||||
|
"build_cmd": "meson compile -C builddir" |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
#include <iostream> |
||||||
|
#include <fstream> |
||||||
|
#include <fmt/core.h> |
||||||
|
#include <nlohmann/json.hpp> |
||||||
|
using json = nlohmann::json; |
||||||
|
|
||||||
|
using namespace fmt; |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
int main(int argc, char *argv[]) { |
||||||
|
if(argc != 2) { |
||||||
|
println("USAGE: jsontest [jsonfile]"); |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
ifstream infile(argv[1]); |
||||||
|
json data = json::parse(infile); |
||||||
|
|
||||||
|
json::string_t s2 = data["happy"].template get<std::string>(); |
||||||
|
|
||||||
|
for(auto &el : data.items()) { |
||||||
|
cout << el.key() << "=" << el.value() << "\n"; |
||||||
|
} |
||||||
|
|
||||||
|
println("DATA HAPPY {}", s2); |
||||||
|
return 0; |
||||||
|
} |
Loading…
Reference in new issue