Now have a nice panel to hold all the UI panels we'll use later.

This commit is contained in:
Zed A. Shaw 2024-11-11 12:23:40 -05:00
parent baaf56d4de
commit 9bc9c9007f
12 changed files with 123 additions and 83 deletions

View file

@ -104,7 +104,7 @@ inline void configure_tile(const sf::Sprite &sprite, sf::FloatRect &sp_bounds,
height_delta = bg_bounds.height > sp_bounds.width ? (bg_bounds.height - sp_bounds.height) / 2 : 0;
}
void SFMLRender::render_text(std::string &text, float x, float y) {
void SFMLRender::render_text(std::wstring &text, float x, float y) {
wchar_t last_tile = '#';
sf::FloatRect sp_bounds;
float width_delta = 0;
@ -141,24 +141,24 @@ void SFMLRender::render_text(std::string &text, float x, float y) {
});
}
void SFMLRender::draw_text_ui(Screen &screen, float x, float y) {
void SFMLRender::draw_text_ui(Panel &panel) {
sf::RectangleShape backing(
sf::Vector2f($ui_bounds.width * screen.dimx(),
$ui_bounds.height * screen.dimy()));
sf::Vector2f($ui_bounds.width * panel.width,
$ui_bounds.height * panel.height));
backing.setFillColor(sf::Color(0, 0, 0));
backing.setPosition(x, y);
backing.setPosition(panel.x, panel.y);
$window.draw(backing);
std::string screenout = screen.ToString();
std::wstring main_screen_utf8 = $converter.from_bytes(screenout);
$ui_text.setPosition(x, y);
$ui_text.setString(main_screen_utf8);
panel.render();
std::wstring panelout = panel.to_string();
$ui_text.setPosition(panel.x, panel.y);
$ui_text.setString(panelout);
$window.draw($ui_text);
}
void SFMLRender::draw_screen(Screen &screen, float x, float y) {
std::string screenout = screen.ToString();
render_text(screenout, GAME_MAP_POS+x, y);
void SFMLRender::draw_screen(Panel &panel, float x, float y) {
panel.render();
std::wstring panelout = panel.to_string();
render_text(panelout, panel.x + x, panel.y + y);
}