diff --git a/combat_ui.cpp b/combat_ui.cpp index 895f651..06c5b87 100644 --- a/combat_ui.cpp +++ b/combat_ui.cpp @@ -16,7 +16,6 @@ namespace gui { } void CombatUI::render() { - for(auto& [name, cell] : $layout.cells) { sf::RectangleShape button; button.setPosition({float(cell.x + 10), float(cell.y + 10)}); @@ -28,9 +27,20 @@ namespace gui { sf::Text label($font, name); auto bounds = label.getLocalBounds(); - auto inner_cell = lel::center(bounds.size.x, bounds.size.y, cell); - label.setPosition({float(inner_cell.x), float(inner_cell.y)}); + fmt::println("CENTER w/h={},{} vs bounds={},{}", + cell.w, cell.h, bounds.size.x, bounds.size.y); + auto label_cell = lel::center(bounds.size.x, bounds.size.y, cell); + label.setPosition({float(label_cell.x), float(label_cell.y)}); $labels.push_back(label); + + + sf::RectangleShape label_box; + label_box.setPosition({float(label_cell.x), float(label_cell.y)}); + label_box.setSize({float(label_cell.w), float(label_cell.h)}); + label_box.setFillColor({10, 10, 10}); + label_box.setOutlineColor({100,100,100}); + label_box.setOutlineThickness(1.0); + $label_boxes.insert_or_assign("Z" + name, label_box); } } @@ -39,6 +49,10 @@ namespace gui { window.draw(shape); } + for(auto& [name, shape] : $label_boxes) { + window.draw(shape); + } + for(auto& label : $labels) { window.draw(label); } diff --git a/combat_ui.hpp b/combat_ui.hpp index d5b5326..00b9974 100644 --- a/combat_ui.hpp +++ b/combat_ui.hpp @@ -17,6 +17,7 @@ namespace gui { GameLevel $level; sf::Font $font; std::unordered_map $shapes; + std::unordered_map $label_boxes; std::vector $labels; CombatUI(GameLevel level); diff --git a/tests/matrix.cpp b/tests/matrix.cpp index 44f40a8..ba672e1 100644 --- a/tests/matrix.cpp +++ b/tests/matrix.cpp @@ -87,7 +87,7 @@ inline void random_matrix(Matrix &out) { } TEST_CASE("thrash matrix iterators", "[matrix]") { - for(int count = 0; count < Random::uniform(10,30); count++) { + for(int count = 0; count < 5; count++) { size_t width = Random::uniform(1, 100); size_t height = Random::uniform(1, 100); @@ -128,7 +128,7 @@ TEST_CASE("thrash box distance iterators", "[matrix:distance]") { } TEST_CASE("thrash box iterators", "[matrix]") { - for(int count = 0; count < 20; count++) { + for(int count = 0; count < 5; count++) { size_t width = Random::uniform(1, 25); size_t height = Random::uniform(1, 33); @@ -159,7 +159,7 @@ TEST_CASE("thrash box iterators", "[matrix]") { } TEST_CASE("thrash compass iterators", "[matrix:compass]") { - for(int count = 0; count < 20; count++) { + for(int count = 0; count < 5; count++) { size_t width = Random::uniform(1, 25); size_t height = Random::uniform(1, 33); @@ -225,7 +225,7 @@ TEST_CASE("prototype line algorithm", "[matrix:line]") { } TEST_CASE("prototype circle algorithm", "[matrix:circle]") { - for(int count = 0; count < 2; count++) { + for(int count = 0; count < 5; count++) { size_t width = Random::uniform(10, 13); size_t height = Random::uniform(10, 15); int pos_mod = Random::uniform(-3,3); @@ -279,7 +279,7 @@ TEST_CASE("viewport iterator", "[matrix:viewport]") { } TEST_CASE("random rectangle", "[matrix:rando_rect]") { - for(int i = 0; i < 10; i++) { + for(int i = 0; i < 5; i++) { shared_ptr map = make_map(); map->invert_space(); auto wall_copy = map->walls(); @@ -303,7 +303,7 @@ TEST_CASE("random rectangle", "[matrix:rando_rect]") { } TEST_CASE("standard rectangle", "[matrix:rectangle]") { - for(int i = 0; i < 20; i++) { + for(int i = 0; i < 5; i++) { shared_ptr map = make_map(); auto wall_copy = map->walls();