Integrating JSON, testing with externally-defining tile data.
This commit is contained in:
@@ -37,6 +37,11 @@ CPMAddPackage(
|
||||
URL https://git.redacted.cc/maxine/mcolor/archive/Prerelease-6.3.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME jjx
|
||||
URL https://git.redacted.cc/josh/jjx/archive/Prerelease-2.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME jlog
|
||||
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-17.zip
|
||||
|
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);
|
||||
|
@@ -201,7 +201,7 @@ namespace CaveGame::Core {
|
||||
|
||||
class Tile;
|
||||
|
||||
///
|
||||
|
||||
void RegisterTile(Tile* data);
|
||||
|
||||
std::vector<Tile*> GetAllTiles();
|
||||
|
@@ -5,7 +5,8 @@
|
||||
|
||||
namespace CaveGame::Core
|
||||
{
|
||||
|
||||
// TODO: Use unique_ptr?
|
||||
// TODO: Create singleton TileRegistry class
|
||||
std::array<Tile*, 65536> registered_tiles{};
|
||||
|
||||
std::vector<Tile*> GetAllTiles() {
|
||||
|
Reference in New Issue
Block a user