diff options
-rw-r--r-- | include/components.hpp | 3 | ||||
-rw-r--r-- | include/window.hpp | 18 | ||||
-rw-r--r-- | src/components.cpp | 34 |
3 files changed, 41 insertions, 14 deletions
diff --git a/include/components.hpp b/include/components.hpp index 367b8a3..be967c8 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -234,10 +234,11 @@ struct Visible { struct Dialog { Dialog(int idx = 0) - : index(idx), rindex((idx == 9999) ? randGet() : idx) {} + : index(idx), rindex((idx == 9999) ? randGet() : idx), talking(false) {} int index; int rindex; + bool talking; }; diff --git a/include/window.hpp b/include/window.hpp index 55cbe1c..5cf05ea 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -1,3 +1,8 @@ +/** + * @file window.hpp + * Provides a system for handling the game's window. + */ + #ifndef WINDOW_HPP_ #define WINDOW_HPP_ @@ -7,9 +12,22 @@ #include <events.hpp> +/** + * @class WindowSystem + * Contains everything needed to create and update a window, using SDL. + * Also handles window resizing (WIP) and screenshots (WIP). + */ class WindowSystem : public entityx::System<WindowSystem>, public entityx::Receiver<WindowSystem> { private: + + /** + * SDL's object for the window. + */ SDL_Window *window; + + /** + * An OpenGL context, created when OpenGL is set up for use. + */ SDL_GLContext glContext; public: diff --git a/src/components.cpp b/src/components.cpp index d9b9b60..28358be 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -18,20 +18,24 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e position.x += direction.x * dt; position.y += direction.y * dt; - if (entity.has_component<Sprite>()) { - auto& fl = entity.component<Sprite>()->faceLeft; - if (direction.x != 0) - fl = (direction.x < 0); - } + if (entity.has_component<Dialog>() && entity.component<Dialog>()->talking) { + direction.x = 0; + } else { + if (entity.has_component<Sprite>()) { + auto& fl = entity.component<Sprite>()->faceLeft; + if (direction.x != 0) + fl = (direction.x < 0); + } - if (entity.has_component<Wander>()) { - auto& countdown = entity.component<Wander>()->countdown; + if (entity.has_component<Wander>()) { + auto& countdown = entity.component<Wander>()->countdown; - if (countdown > 0) { - countdown--; - } else { - countdown = 5000 + randGet() % 10 * 100; - direction.x = (randGet() % 3 - 1) * 0.02f; + if (countdown > 0) { + countdown--; + } else { + countdown = 5000 + randGet() % 10 * 100; + direction.x = (randGet() % 3 - 1) * 0.02f; + } } } }); @@ -152,6 +156,9 @@ void DialogSystem::receive(const MouseClickEvent &mce) auto exml = game::engine.getSystem<WorldSystem>()->getXML()->FirstChildElement("Dialog"); int newIndex; + if (e.has_component<Direction>()) + d.talking = true; + if (d.index == 9999) { ui::dialogBox(name.name, "", false, randomDialog[d.rindex % randomDialog.size()]); ui::waitForDialog(); @@ -170,7 +177,6 @@ void DialogSystem::receive(const MouseClickEvent &mce) game::briceUpdate(); } - auto cxml = exml->FirstChildElement("content"); const char *content; if (cxml == nullptr) { @@ -186,6 +192,8 @@ void DialogSystem::receive(const MouseClickEvent &mce) if (exml->QueryIntAttribute("nextid", &newIndex) == XML_NO_ERROR) d.index = newIndex; } + + d.talking = false; }).detach(); } |