diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/inventory.cpp | 2 | ||||
-rw-r--r-- | src/quest.cpp | 38 | ||||
-rw-r--r-- | src/systems/lua.cpp | 2 | ||||
-rw-r--r-- | src/systems/movement.cpp | 6 | ||||
-rw-r--r-- | src/ui.cpp | 4 | ||||
-rw-r--r-- | src/world.cpp | 7 |
6 files changed, 51 insertions, 8 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index 36cc041..41fe661 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -421,7 +421,7 @@ void InventorySystem::load(void) // check signature if (std::stoi(lines[0]) != 831998) - UserError("Save file signature is invalid... (delete it)"); + UserError("Inventory save file signature is invalid... (delete it)"); for (unsigned int i = 1; i < lines.size(); i += 3) { if (lines[i].size() > 0) { diff --git a/src/quest.cpp b/src/quest.cpp index 6017247..489d71e 100644 --- a/src/quest.cpp +++ b/src/quest.cpp @@ -1,8 +1,12 @@ #include <quest.hpp> #include <algorithm> +#include <iostream> +#include <fstream> #include <engine.hpp> +#include <error.hpp> +#include <fileio.hpp> #include <inventory.hpp> #include <tokens.hpp> @@ -82,3 +86,37 @@ bool QuestSystem::hasQuest(std::string title) return (std::find_if(std::begin(current), std::end(current), [&title](const Quest& q) { return (q.name == title); }) != std::end(current)); } + +void QuestSystem::save(void) +{ + std::ofstream s (game::config::xmlFolder + "quest.dat"); + + // signature? + s << "831998\n"; + + for (const auto& q : current) { + s << q.name << '\n' << q.desc << '\n'; + for (const auto& r : q.reqs) + s << r.first << ',' << std::to_string(r.second) << ','; + s << "Reward,"; + for (const auto& r : q.rewards) + s << r.first << ',' << std::to_string(r.second) << ','; + s << '\n'; + } +} + +void QuestSystem::load(void) +{ + std::ifstream sf (game::config::xmlFolder + "quest.dat"); + if (sf.good()) { + sf.close(); + auto lines = readFileA(game::config::xmlFolder + "quest.dat"); + + // check signature + if (std::stoi(lines[0]) != 831998) + UserError("Quest save file signature is invalid... (delete it)"); + + for (unsigned int i = 1; i < lines.size(); i += 3) + assign(lines[i], lines[i + 1], lines[i + 2]); + } +} diff --git a/src/systems/lua.cpp b/src/systems/lua.cpp new file mode 100644 index 0000000..b093aff --- /dev/null +++ b/src/systems/lua.cpp @@ -0,0 +1,2 @@ +#include <systems/lua.hpp> + diff --git a/src/systems/movement.cpp b/src/systems/movement.cpp index 7ff9966..4eb574d 100644 --- a/src/systems/movement.cpp +++ b/src/systems/movement.cpp @@ -75,14 +75,16 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e // make the entity wander // TODO initialX and range? if (entity.has_component<Wander>()) { - auto& countdown = entity.component<Wander>()->countdown; + auto vel = entity.component<Wander>()->script(); + direction.x = vel.x; + /*auto& countdown = entity.component<Wander>()->countdown; if (countdown > 0) { countdown--; } else { countdown = 5000 + randGet() % 10 * 100; direction.x = (randGet() % 3 - 1) * 0.004f; - } + }*/ } } }); @@ -793,8 +793,8 @@ void UISystem::putString(const vec2& p, const std::string& s, float wrap) for (auto c : word) { switch (c) { case '\n': - //offset.y -= FontSystem::getSize() * 1.05f; - //offset.x = p.x; + offset.y -= FontSystem::getSize() * 1.05f; + offset.x = p.x; break; case '\b': //offset.x -= add.x; diff --git a/src/world.cpp b/src/world.cpp index 7904c4f..9f57b87 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -350,9 +350,10 @@ void WorldSystem::loader(void) entity.assign<Dialog>(wxml, abcd); else if (tname == "Grounded") entity.assign<Grounded>(); // no need to pass xmls... - else if (tname == "Wander") - entity.assign<Wander>(); - else if (tname == "Hop") + else if (tname == "Wander") { + auto script = abcd->GetText(); + entity.assign<Wander>(script != nullptr ? script : ""); + } else if (tname == "Hop") entity.assign<Hop>(); else if (tname == "Health") entity.assign<Health>(wxml, abcd); |