|
|
|
@ -28,13 +28,10 @@ sf::Color SFMLRender::color(Value val) { |
|
|
|
|
return VALUES[size_t(val)]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SFMLRender::SFMLRender(Canvas &canvas, Screen &map_screen, Screen &screen) : |
|
|
|
|
SFMLRender::SFMLRender() : |
|
|
|
|
$window(sf::VideoMode(VIDEO_X,VIDEO_Y), "Roguish"), |
|
|
|
|
$map_font_size(0), |
|
|
|
|
$line_spacing(0), |
|
|
|
|
$canvas(canvas), |
|
|
|
|
$map_screen(map_screen), |
|
|
|
|
$screen(screen), |
|
|
|
|
$default_fg(color(Value::LIGHT_MID)), |
|
|
|
|
$default_bg(color(Value::BLACK)), |
|
|
|
|
$ansi($default_fg, $default_bg) |
|
|
|
@ -44,7 +41,9 @@ SFMLRender::SFMLRender(Canvas &canvas, Screen &map_screen, Screen &screen) : |
|
|
|
|
$ui_text.setFont($font); |
|
|
|
|
$ui_text.setPosition(0,0); |
|
|
|
|
$ui_text.setCharacterSize(UI_FONT_SIZE); |
|
|
|
|
$ui_text.setFillColor(color(Value::LIGHT_LIGHT)); |
|
|
|
|
$ui_text.setFillColor(color(Value::LIGHT_MID)); |
|
|
|
|
sf::Glyph glyph = $font.getGlyph(L'H', UI_FONT_SIZE, false); |
|
|
|
|
$ui_bounds = glyph.bounds; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sf::Sprite &SFMLRender::get_text_sprite(wchar_t tile) { |
|
|
|
@ -96,13 +95,6 @@ bool SFMLRender::resize_map(int new_size, Point &view_port) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SFMLRender::draw_main_ui() { |
|
|
|
|
std::string screenout = $screen.ToString(); |
|
|
|
|
std::wstring main_screen_utf8 = $converter.from_bytes(screenout); |
|
|
|
|
$ui_text.setString(main_screen_utf8); |
|
|
|
|
$window.draw($ui_text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline void configure_tile(const sf::Sprite &sprite, sf::FloatRect &sp_bounds, sf::FloatRect bg_bounds, float &width_delta, float &height_delta) { |
|
|
|
|
// should look into caching all this instead of calcing it each time
|
|
|
|
|
sp_bounds = sprite.getLocalBounds(); |
|
|
|
@ -149,11 +141,24 @@ void SFMLRender::render_text(std::string &text, float x, float y) { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SFMLRender::draw_screen(bool clear, float map_off_x, float map_off_y) { |
|
|
|
|
if(clear) $window.clear(); |
|
|
|
|
draw_main_ui(); |
|
|
|
|
void SFMLRender::draw_text_ui(Screen &screen, float x, float y) { |
|
|
|
|
sf::RectangleShape backing( |
|
|
|
|
sf::Vector2f($ui_bounds.width * screen.dimx() * 1.4, |
|
|
|
|
$ui_bounds.height * screen.dimy() * 1.6)); |
|
|
|
|
|
|
|
|
|
backing.setFillColor(sf::Color(0, 0, 0)); |
|
|
|
|
backing.setPosition(x, 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); |
|
|
|
|
$window.draw($ui_text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string map_screenout = $map_screen.ToString(); |
|
|
|
|
render_text(map_screenout, GAME_MAP_POS+map_off_x, map_off_y); |
|
|
|
|
$window.display(); |
|
|
|
|
void SFMLRender::draw_screen(Screen &screen, float x, float y) { |
|
|
|
|
std::string screenout = screen.ToString(); |
|
|
|
|
render_text(screenout, GAME_MAP_POS+x, y); |
|
|
|
|
} |
|
|
|
|