Add some debug boxes around the fonts to figure out why they aren't vertically centered.
This commit is contained in:
parent
45ad16c010
commit
6b9c67beec
3 changed files with 24 additions and 9 deletions
|
@ -16,7 +16,6 @@ namespace gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CombatUI::render() {
|
void CombatUI::render() {
|
||||||
|
|
||||||
for(auto& [name, cell] : $layout.cells) {
|
for(auto& [name, cell] : $layout.cells) {
|
||||||
sf::RectangleShape button;
|
sf::RectangleShape button;
|
||||||
button.setPosition({float(cell.x + 10), float(cell.y + 10)});
|
button.setPosition({float(cell.x + 10), float(cell.y + 10)});
|
||||||
|
@ -28,9 +27,20 @@ namespace gui {
|
||||||
|
|
||||||
sf::Text label($font, name);
|
sf::Text label($font, name);
|
||||||
auto bounds = label.getLocalBounds();
|
auto bounds = label.getLocalBounds();
|
||||||
auto inner_cell = lel::center(bounds.size.x, bounds.size.y, cell);
|
fmt::println("CENTER w/h={},{} vs bounds={},{}",
|
||||||
label.setPosition({float(inner_cell.x), float(inner_cell.y)});
|
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);
|
$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);
|
window.draw(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(auto& [name, shape] : $label_boxes) {
|
||||||
|
window.draw(shape);
|
||||||
|
}
|
||||||
|
|
||||||
for(auto& label : $labels) {
|
for(auto& label : $labels) {
|
||||||
window.draw(label);
|
window.draw(label);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace gui {
|
||||||
GameLevel $level;
|
GameLevel $level;
|
||||||
sf::Font $font;
|
sf::Font $font;
|
||||||
std::unordered_map<std::string, sf::RectangleShape> $shapes;
|
std::unordered_map<std::string, sf::RectangleShape> $shapes;
|
||||||
|
std::unordered_map<std::string, sf::RectangleShape> $label_boxes;
|
||||||
std::vector<sf::Text> $labels;
|
std::vector<sf::Text> $labels;
|
||||||
CombatUI(GameLevel level);
|
CombatUI(GameLevel level);
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ inline void random_matrix(Matrix &out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("thrash matrix iterators", "[matrix]") {
|
TEST_CASE("thrash matrix iterators", "[matrix]") {
|
||||||
for(int count = 0; count < Random::uniform<int>(10,30); count++) {
|
for(int count = 0; count < 5; count++) {
|
||||||
size_t width = Random::uniform<size_t>(1, 100);
|
size_t width = Random::uniform<size_t>(1, 100);
|
||||||
size_t height = Random::uniform<size_t>(1, 100);
|
size_t height = Random::uniform<size_t>(1, 100);
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ TEST_CASE("thrash box distance iterators", "[matrix:distance]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("thrash box iterators", "[matrix]") {
|
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<size_t>(1, 25);
|
size_t width = Random::uniform<size_t>(1, 25);
|
||||||
size_t height = Random::uniform<size_t>(1, 33);
|
size_t height = Random::uniform<size_t>(1, 33);
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ TEST_CASE("thrash box iterators", "[matrix]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("thrash compass iterators", "[matrix:compass]") {
|
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<size_t>(1, 25);
|
size_t width = Random::uniform<size_t>(1, 25);
|
||||||
size_t height = Random::uniform<size_t>(1, 33);
|
size_t height = Random::uniform<size_t>(1, 33);
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ TEST_CASE("prototype line algorithm", "[matrix:line]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("prototype circle algorithm", "[matrix:circle]") {
|
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<size_t>(10, 13);
|
size_t width = Random::uniform<size_t>(10, 13);
|
||||||
size_t height = Random::uniform<size_t>(10, 15);
|
size_t height = Random::uniform<size_t>(10, 15);
|
||||||
int pos_mod = Random::uniform<int>(-3,3);
|
int pos_mod = Random::uniform<int>(-3,3);
|
||||||
|
@ -279,7 +279,7 @@ TEST_CASE("viewport iterator", "[matrix:viewport]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("random rectangle", "[matrix:rando_rect]") {
|
TEST_CASE("random rectangle", "[matrix:rando_rect]") {
|
||||||
for(int i = 0; i < 10; i++) {
|
for(int i = 0; i < 5; i++) {
|
||||||
shared_ptr<Map> map = make_map();
|
shared_ptr<Map> map = make_map();
|
||||||
map->invert_space();
|
map->invert_space();
|
||||||
auto wall_copy = map->walls();
|
auto wall_copy = map->walls();
|
||||||
|
@ -303,7 +303,7 @@ TEST_CASE("random rectangle", "[matrix:rando_rect]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("standard rectangle", "[matrix:rectangle]") {
|
TEST_CASE("standard rectangle", "[matrix:rectangle]") {
|
||||||
for(int i = 0; i < 20; i++) {
|
for(int i = 0; i < 5; i++) {
|
||||||
shared_ptr<Map> map = make_map();
|
shared_ptr<Map> map = make_map();
|
||||||
auto wall_copy = map->walls();
|
auto wall_copy = map->walls();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue