59 lines
2.3 KiB
C++
59 lines
2.3 KiB
C++
#include <iostream>
|
|
#include "yamal.hpp"
|
|
|
|
std::string readFileToString(const std::string& filename) {
|
|
std::ifstream ifs(filename);
|
|
if (!ifs) {
|
|
throw std::runtime_error("Cannot open file: " + filename);
|
|
}
|
|
std::ostringstream oss;
|
|
oss << ifs.rdbuf(); // dump the whole stream buffer into oss
|
|
return oss.str();
|
|
}
|
|
|
|
int main(int argc, char* argv[]) {
|
|
yamal root; // = yamal_parser::parse(readFileToString("test.yaml"));
|
|
root.deserialize(readFileToString("data/room/02.yaml"));
|
|
|
|
/*root["room"]["name"] = "THE JAIL";
|
|
root["room"]["name"].setQuoted(true);
|
|
root["room"]["bgColor"] = "bright_blue";
|
|
root["room"]["connections"]["up"] = "null";
|
|
root["room"]["connections"]["down"] = "null";
|
|
root["room"]["connections"]["left"] = "null";
|
|
root["room"]["connections"]["right"] = "02.yaml";
|
|
root["room"]["itemColor1"] = "yellow";
|
|
root["tilemap"][0][0] = 00;
|
|
root["tilemap"][0][1] = 01;
|
|
root["tilemap"][1][0] = 10;
|
|
root["tilemap"][1][1] = 11;
|
|
root["tilemap"][0].setInline(true);
|
|
root["tilemap"][1].setInline(true);
|
|
root["enemies"][0]["animation"] = "jailer_1.yaml";
|
|
root["enemies"][0]["position"]["x"] = 1;
|
|
root["enemies"][0]["position"]["y"] = 13;
|
|
root["enemies"][0]["position"].setInline(true);
|
|
root["enemies"][0]["boundaries"]["position1"]["x"] = 1;
|
|
root["enemies"][0]["boundaries"]["position1"]["y"] = 1;
|
|
root["enemies"][0]["boundaries"]["position1"].setInline(true);
|
|
root["enemies"][0]["color"]= "white";
|
|
root["enemies"][1]["animation"] = "jailer_2.yaml";
|
|
root["enemies"][1]["position"]["x"] = 2;
|
|
root["enemies"][1]["position"]["y"] = 23;
|
|
root["enemies"][1]["position"].setInline(true);
|
|
root["enemies"][1]["boundaries"]["position1"]["x"] = 2;
|
|
root["enemies"][1]["boundaries"]["position1"]["y"] = 2;
|
|
root["enemies"][1]["boundaries"]["position1"].setInline(true);
|
|
root["enemies"][1]["color"]= "black";
|
|
root["items"].clearToVector();
|
|
root["items"].setInline(true);
|
|
|
|
root["room"].setComment("THE JAIL");
|
|
root["room"].setBlankLine(false);
|
|
root["tilemap"].setComment("Tilemap: 16 filas x 32 columnas (256x192 píxeles @ 8px/tile)");
|
|
root["tilemap"].appendComment("Índices de tiles (-1 = vacío)");
|
|
root["room"]["bgColor"].setInlineComment("Azul oscuro");*/
|
|
std::cout << root.serialize() << std::endl;
|
|
|
|
return 0;
|
|
} |