A bit of cleanup and testing of the panel, then some optimization to avoid re-rendering and multiple wchar converts.
This commit is contained in:
parent
6e848004c4
commit
7d3605f58b
5 changed files with 41 additions and 16 deletions
14
render.cpp
14
render.cpp
|
@ -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::wstring &text, float x, float y) {
|
||||
void SFMLRender::render_text(const std::wstring &text, float x, float y) {
|
||||
wchar_t last_tile = '#';
|
||||
sf::FloatRect sp_bounds;
|
||||
float width_delta = 0;
|
||||
|
@ -142,17 +142,23 @@ void SFMLRender::render_text(std::wstring &text, float x, float y) {
|
|||
});
|
||||
}
|
||||
|
||||
void SFMLRender::draw_text_ui(Panel &panel) {
|
||||
void SFMLRender::draw_text_ui(Panel &panel, bool with_border) {
|
||||
sf::RectangleShape backing(
|
||||
sf::Vector2f($ui_bounds.width * panel.width,
|
||||
$ui_bounds.height * panel.height));
|
||||
|
||||
backing.setFillColor(sf::Color(0, 0, 0));
|
||||
|
||||
if(with_border) {
|
||||
backing.setOutlineColor(color(Value::MID));
|
||||
backing.setOutlineThickness(5);
|
||||
}
|
||||
|
||||
backing.setPosition(panel.x, panel.y);
|
||||
$window.draw(backing);
|
||||
|
||||
panel.render();
|
||||
std::wstring panelout = panel.to_string();
|
||||
const std::wstring &panelout = panel.to_string();
|
||||
$ui_text.setPosition(panel.x, panel.y);
|
||||
$ui_text.setString(panelout);
|
||||
$window.draw($ui_text);
|
||||
|
@ -160,6 +166,6 @@ void SFMLRender::draw_text_ui(Panel &panel) {
|
|||
|
||||
void SFMLRender::draw_screen(Panel &panel, float x, float y) {
|
||||
panel.render();
|
||||
std::wstring panelout = panel.to_string();
|
||||
const std::wstring &panelout = panel.to_string();
|
||||
render_text(panelout, panel.x + x, panel.y + y);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue