Add some debug boxes around the fonts to figure out why they aren't vertically centered.

This commit is contained in:
Zed A. Shaw 2025-02-15 22:54:00 -05:00
parent 45ad16c010
commit 6b9c67beec
3 changed files with 24 additions and 9 deletions

View file

@ -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);
}