@ -14,6 +14,7 @@
# include <SFML/Window.hpp>
# include <SFML/System.hpp>
# include <SFML/Graphics.hpp>
# include <fmt/core.h>
# include "dbc.hpp"
@ -148,9 +149,42 @@ void GUI::burn() {
void GUI : : draw_screen ( bool clear , float map_off_x , float map_off_y ) {
if ( clear ) $ window . clear ( ) ;
std : : string screenout = $ screen . ToString ( ) ;
std : : string map_screenout = $ map_screen . ToString ( ) ;
std : : wstring main_screen_utf8 = $ converter . from_bytes ( screenout ) ;
$ ui_text . setString ( main_screen_utf8 ) ;
$ window . draw ( $ ui_text ) ;
$ map_text . setPosition ( GAME_MAP_POS + map_off_x , map_off_y ) ;
$ window . draw ( $ map_text ) ;
std : : wstring map_screen_utf8 = $ converter . from_bytes ( map_screenout ) ;
$ map_text . setString ( map_screen_utf8 ) ;
sf : : Texture ftext = $ font . getTexture ( MAP_FONT_SIZE ) ;
for ( size_t i = 0 ; i < map_screen_utf8 . size ( ) ; i + + ) {
wchar_t tile = map_screen_utf8 [ i ] ;
sf : : Glyph glyph = $ font . getGlyph ( tile , MAP_FONT_SIZE , false ) ;
sf : : Sprite sprite ( ftext ) ;
sprite . setTextureRect ( glyph . textureRect ) ;
auto pos = $ map_text . findCharacterPos ( i ) ;
sprite . setPosition ( pos ) ;
if ( tile = = L ' █ ' ) {
sprite . setColor ( sf : : Color ( 100 , 100 , 100 ) ) ;
} else if ( tile = = L ' ☺ ' ) {
sprite . setColor ( sf : : Color : : Blue ) ;
} else if ( tile = = L ' Ω ' ) {
sprite . setColor ( sf : : Color : : Red ) ;
} else if ( tile = = L ' · ' ) {
sprite . setColor ( color ( Value : : DARK_MID ) ) ;
} else if ( tile = = L ' \n ' | | tile = = L ' \r ' ) {
// skip newlines
continue ;
} else {
sprite . setColor ( color ( Value : : MID ) ) ;
}
$ window . draw ( sprite ) ;
}
$ window . display ( ) ;
}
@ -198,20 +232,13 @@ void GUI::render_scene() {
Render ( $ map_screen , $ map_view - > Render ( ) ) ;
Render ( $ screen , $ document - > Render ( ) ) ;
std : : string $ screenout = $ screen . ToString ( ) ;
std : : wstring main_screen_utf8 = $ converter . from_bytes ( $ screenout ) ;
$ ui_text . setString ( main_screen_utf8 ) ;
std : : string $ map_screenout = $ map_screen . ToString ( ) ;
std : : wstring map_screen_utf8 = $ converter . from_bytes ( $ map_screenout ) ;
$ map_text . setString ( map_screen_utf8 ) ;
draw_screen ( ) ;
}
int GUI : : main ( ) {
configure_world ( ) ;
create_renderer ( ) ;
run_systems ( ) ;
while ( $ window . isOpen ( ) ) {
render_scene ( ) ;
@ -219,7 +246,6 @@ int GUI::main() {
if ( handle_events ( ) ) {
run_systems ( ) ;
}
std : : this_thread : : sleep_for ( 10 ms ) ;
}