Integrating JSON, testing with externally-defining tile data.
This commit is contained in:
11
ClientApp/data/items/base_items.json
Normal file
11
ClientApp/data/items/base_items.json
Normal file
@@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
}
|
||||
]
|
23
ClientApp/data/tiles/base_tiles.json
Normal file
23
ClientApp/data/tiles/base_tiles.json
Normal file
@@ -0,0 +1,23 @@
|
||||
[
|
||||
{
|
||||
"mnemonic-id" : "stone",
|
||||
"display-name" : "",
|
||||
"solid": true,
|
||||
"does-random-ticc": false,
|
||||
"does-forced-ticc": false,
|
||||
"color": "#FFFFFF",
|
||||
"pallet": []
|
||||
},
|
||||
{
|
||||
"mnemonic-id" : "stone",
|
||||
"display-name" : "",
|
||||
"solid": true,
|
||||
"does-random-ticc": false,
|
||||
"does-forced-ticc": false,
|
||||
"color": "#FFFFFF",
|
||||
"pallet": [],
|
||||
"random-ticc-func": "zzyyzz",
|
||||
"forced-ticc-func": "zzyyzz",
|
||||
"drops" : null
|
||||
}
|
||||
]
|
@@ -22,9 +22,33 @@
|
||||
#include <Core/Tile.hpp>
|
||||
#include <JGL/logger/logger.h>
|
||||
|
||||
std::string read_file(const std::string& file_path)
|
||||
{
|
||||
std::ifstream file(file_path, std::ios::binary);
|
||||
if (!file)
|
||||
throw std::runtime_error("We couldn't find the file: " + file_path);
|
||||
|
||||
std::streamsize file_size;
|
||||
file.seekg(0, std::ios::end);
|
||||
file_size = file.tellg();
|
||||
file.seekg(0, std::ios::beg);
|
||||
|
||||
std::string file_content(file_size, '\0');
|
||||
file.read(&file_content[0], file_size);
|
||||
file.close();
|
||||
|
||||
return file_content;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
|
||||
std::string content = read_file("data/tiles/base_tiles.json");
|
||||
|
||||
auto [text, parse_error] = json::parse(content);
|
||||
|
||||
|
||||
|
||||
// Hide logs from engine components so we can focus on CaveGame.
|
||||
JGL::Logger::Warning.EnableConsole(false);
|
||||
|
Reference in New Issue
Block a user