diff --git a/assets/config.json b/assets/config.json index a4af630..41d4c80 100644 --- a/assets/config.json +++ b/assets/config.json @@ -30,7 +30,8 @@ "blood_splatter": "assets/blood_splatter-256.png", "trash_button": "assets/trash_button.png", "axe_ranger": "assets/axe_ranger-256.png", - "hairy_spider": "assets/hairy_spider-256.png" + "hairy_spider": "assets/hairy_spider-256.png", + "down_the_well": "assets/down_the_well.jpg" }, "enemy": { "HEARING_DISTANCE": 5 diff --git a/assets/down_the_well.jpg b/assets/down_the_well.jpg new file mode 100644 index 0000000..6208691 Binary files /dev/null and b/assets/down_the_well.jpg differ diff --git a/guecs.cpp b/guecs.cpp index b4fccba..61cb7b8 100644 --- a/guecs.cpp +++ b/guecs.cpp @@ -98,7 +98,9 @@ namespace guecs { }); } - void UI::mouse(float x, float y) { + bool UI::mouse(float x, float y) { + int action_count = 0; + $world.query([&](auto ent, auto& cell, auto &clicked) { if((x >= cell.x && x <= cell.x + cell.w) && (y >= cell.y && y <= cell.y + cell.h)) @@ -108,8 +110,12 @@ namespace guecs { } else { clicked.action(ent, {}); } + + action_count++; } }); + + return action_count > 0; } Clickable make_action(DinkyECS::World& target, Events::GUI event) { diff --git a/guecs.hpp b/guecs.hpp index c73df59..d39e9fe 100644 --- a/guecs.hpp +++ b/guecs.hpp @@ -156,7 +156,7 @@ namespace guecs { void init(); void render(sf::RenderWindow& window); - void mouse(float x, float y); + bool mouse(float x, float y); template void set(DinkyECS::Entity ent, Comp val) { diff --git a/gui_fsm.cpp b/gui_fsm.cpp index 76ecc6f..bb5db2f 100644 --- a/gui_fsm.cpp +++ b/gui_fsm.cpp @@ -162,6 +162,7 @@ namespace gui { dbc::log("Nothing to close."); break; case STAIRS_DOWN: + $main_ui.show_level(); state(State::NEXT_LEVEL); break; case STOP_COMBAT: @@ -177,7 +178,7 @@ namespace gui { using enum Event; switch(ev) { - case TICK: + case STAIRS_DOWN: next_level(); state(State::IDLE); default: diff --git a/main.cpp b/main.cpp index 316fc5b..42ca456 100644 --- a/main.cpp +++ b/main.cpp @@ -13,6 +13,7 @@ int main() { // ZED: need to sort out how to deal with this in the FSM if(main.in_state(gui::State::IDLE) + || main.in_state(gui::State::NEXT_LEVEL) || main.in_state(gui::State::MAPPING) || main.in_state(gui::State::IN_COMBAT)) { diff --git a/main_ui.cpp b/main_ui.cpp index 880c444..c01d61f 100644 --- a/main_ui.cpp +++ b/main_ui.cpp @@ -69,14 +69,29 @@ namespace gui { $rayview.init_shaders(); $rayview.set_position(RAY_VIEW_X, RAY_VIEW_Y); $rayview.position_camera($player.x + 0.5, $player.y + 0.5); + + auto st = textures::get("down_the_well"); + st.sprite->setPosition({RAY_VIEW_X, RAY_VIEW_Y}); + st.sprite->setScale({0.5, 0.5}); + $overlay_ui.render(); } + void MainUI::show_level() { + $show_level = true; + } + void MainUI::draw() { auto start = std::chrono::high_resolution_clock::now(); - if($needs_render) $rayview.render(); - $rayview.draw($window); + if($show_level) { + auto st = textures::get("down_the_well"); + $window.draw(*st.sprite); + $overlay_ui.show_label("middle", "INTO THE WELL YOU GO..."); + } else { + if($needs_render) $rayview.render(); + $rayview.draw($window); + } auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration(end - start); @@ -136,6 +151,9 @@ namespace gui { } void MainUI::mouse(int x, int y) { + $show_level = false; + $level.world->send(Events::GUI::STAIRS_DOWN, $level.player, {}); + $overlay_ui.close_label("middle"); $overlay_ui.$gui.mouse(x, y); } } diff --git a/main_ui.hpp b/main_ui.hpp index ff1e806..f0bd2f9 100644 --- a/main_ui.hpp +++ b/main_ui.hpp @@ -11,6 +11,7 @@ namespace gui { class MainUI { public: + bool $show_level = false; bool $needs_render = true; Point $player{0,0}; Stats $stats; @@ -38,6 +39,7 @@ namespace gui { void draw(); void dirty(); + void show_level(); void dead_entity(DinkyECS::Entity entity); }; }