summary refs log tree commit diff stats
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp index 505004d..ba40def 100644 --- a/main.cpp +++ b/main.cpp
@@ -405,7 +405,12 @@ public:
405 405
406 406
407 407
408 408 // Room Room
409 gen_.GeneratePaintingPuzzle("Panel_painting_flower", "flower_painting_gray");
410 gen_.GeneratePaintingPuzzle("Panel_painting_eye", "eye_painting_gray");
411 gen_.GeneratePaintingPuzzle("Panel_painting_snowman", "snowman_painting_gray");
412 gen_.GeneratePaintingPuzzle("Panel_painting_owl", "owl_painting_gray");
413 gen_.GeneratePaintingPuzzle("Panel_painting_panda", "panda_painting_gray");
409 414
410 415
411 416
@@ -578,6 +583,9 @@ public:
578 std::string name; 583 std::string name;
579 std::string question; 584 std::string question;
580 std::string answer; 585 std::string answer;
586 std::map<std::string, int> resource_id_by_path;
587 int last_id = 0;
588 bool need_to_output_resources = false;
581 while (std::getline(level1, line)) { 589 while (std::getline(level1, line)) {
582 if (line.substr(0, 18) == "[node name=\"Panel_") { 590 if (line.substr(0, 18) == "[node name=\"Panel_") {
583 std::string stripstart = line.substr(12); 591 std::string stripstart = line.substr(12);
@@ -604,6 +612,40 @@ public:
604 612
605 //std::cout << name << ": " << question << "? " << answer << "!" << std::endl; 613 //std::cout << name << ": " << question << "? " << answer << "!" << std::endl;
606 output << "answer = \"" << answer << "\"" << std::endl; 614 output << "answer = \"" << answer << "\"" << std::endl;
615 } else if (line.substr(0, 9) == "[gd_scene") {
616 std::string stripstart = line.substr(21);
617 std::string numstr = stripstart.substr(0, stripstart.find(" "));
618 int load_steps = std::atoi(numstr.c_str());
619 output << "[gd_scene load_steps=" << (load_steps + gen_.GetResources().size()) << " format=2]\n";
620 } else if (line.substr(0, 13) == "[ext_resource") {
621 std::string stripstart = line.substr(line.find("id=") + 3);
622 std::string numstr = stripstart.substr(0, stripstart.find("]"));
623 last_id = std::atoi(numstr.c_str());
624 need_to_output_resources = true;
625 output << line << "\n";
626 } else if (line.substr(0, 12) == "[node name=\"") {
627 std::string stripstart = line.substr(12);
628 std::string tempname = stripstart.substr(0, stripstart.find("\""));
629
630 if (gen_.IsNodeRandomized(tempname)) {
631 int id_pos = line.find("(") + 2;
632 auto [path, res_id] = gen_.GetNode(tempname);
633 if (res_id != 0) {
634 output << line.substr(0, id_pos) + std::to_string(res_id) + " )]\n";
635 } else {
636 output << line.substr(0, id_pos) + std::to_string(resource_id_by_path[path]) + " )]\n";
637 }
638 } else {
639 output << line << "\n";
640 }
641 } else if (line.empty() && need_to_output_resources) {
642 for (const auto& [path, type] : gen_.GetResources()) {
643 last_id++;
644 resource_id_by_path[path] = last_id;
645 output << "[ext_resource path=\"" << path << "\" type=\"" << type << "\" id=" << last_id << "]\n";
646 }
647 output << "\n";
648 need_to_output_resources = false;
607 } else { 649 } else {
608 output << line << "\n"; 650 output << line << "\n";
609 } 651 }