diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-04-27 21:28:33 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-04-27 21:28:33 -0400 |
commit | 00de7a4b0aa48c3cb42c45e0f203902ca034b94c (patch) | |
tree | e364575a000af4a9c65b2e43f5ec565bb2df4bf8 /src | |
parent | ef1ea79375ce865d78fb7da4244aee65d25c04b3 (diff) |
important textls
Diffstat (limited to 'src')
-rw-r--r-- | src/components.cpp | 32 | ||||
-rw-r--r-- | src/ui.cpp | 22 | ||||
-rw-r--r-- | src/world.cpp | 2 |
3 files changed, 45 insertions, 11 deletions
diff --git a/src/components.cpp b/src/components.cpp index d89e195..dcb1551 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -50,11 +50,9 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e fl = (direction.x < 0); } - // make the entity wander - // TODO initialX and range? - if (entity.has_component<Aggro>()) { - auto ppos = game::engine.getSystem<PlayerSystem>()->getPosition(); - if (ppos.x > position.x && ppos.x < position.x + entity.component<Solid>()->width) { + auto ppos = game::engine.getSystem<PlayerSystem>()->getPosition(); + if (ppos.x > position.x && ppos.x < position.x + entity.component<Solid>()->width) { + if (entity.has_component<Aggro>()) { auto dim = entity.component<Solid>(); ev.emit<AttackEvent>(vec2(position.x + dim->width, position.y + dim->height), AttackType::ShortSlash, false); @@ -64,9 +62,27 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e toFight = entity; h = 0; }*/ - } else - direction.x = (ppos.x > position.x) ? .01 : -.01; - } else if (entity.has_component<Wander>()) { + } else if (entity.has_component<Trigger>()) { + static bool triggering = false; + if (!triggering) { + triggering = true; + std::thread([&](entityx::Entity e) { + UISystem::fadeToggle(); + UISystem::waitForCover(); + UISystem::dialogImportant(e.component<Trigger>()->text); + UISystem::waitForDialog(); + UISystem::fadeToggle(); + e.destroy(); + triggering = false; + }, entity).detach(); + } + return; + } + } + + // make the entity wander + // TODO initialX and range? + if (entity.has_component<Wander>()) { auto& countdown = entity.component<Wander>()->countdown; if (countdown > 0) { @@ -618,6 +618,20 @@ namespace ui { fclose(bmp); } + + bool handleGLEvent(SDL_Event& e) { + switch (e.type) { + case SDL_MOUSEBUTTONDOWN: + if ((UISystem::isDialog() | pageTexReady) && (e.button.button & SDL_BUTTON_RIGHT)) + UISystem::advanceDialog(); + return true; + break; + default: + break; + } + + return false; + } } using namespace ui; @@ -658,8 +672,6 @@ void InputSystem::receive(const MainSDLEvent& event) case SDL_MOUSEBUTTONDOWN: ev.emit<MouseClickEvent>(mouse, e.button.button); - UISystem::advanceDialog(); - if (UISystem::isDialog() || pageTexReady) { if ((e.button.button & SDL_BUTTON_RIGHT)) UISystem::advanceDialog(); @@ -974,6 +986,10 @@ void UISystem::render(void) } if (!importantText.empty()) { - putStringCentered(offset, importantText); + FontSystem::setFontSize(24); + FontSystem::setFontZ(-9.0f); + putStringCentered(vec2(offset.x, 400), importantText); + FontSystem::setFontZ(-6.0f); + FontSystem::setFontSize(16); } } diff --git a/src/world.cpp b/src/world.cpp index 648507a..e251706 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -389,6 +389,8 @@ void WorldSystem::load(const std::string& file) entity.assign<Aggro>(wxml, abcd); else if (tname == "Animation") entity.assign<Animate>(wxml, abcd); + else if (tname == "Trigger") + entity.assign<Trigger>(wxml, abcd); abcd = abcd->NextSiblingElement(); } |