|
|
@ -67,11 +67,6 @@ GUI::GUI() : $game_map(GAME_MAP_X, GAME_MAP_Y), |
|
|
|
$ui_text.setCharacterSize(UI_FONT_SIZE); |
|
|
|
$ui_text.setCharacterSize(UI_FONT_SIZE); |
|
|
|
$ui_text.setFillColor(color(Value::LIGHT_LIGHT)); |
|
|
|
$ui_text.setFillColor(color(Value::LIGHT_LIGHT)); |
|
|
|
|
|
|
|
|
|
|
|
$map_text.setFont($font); |
|
|
|
|
|
|
|
$map_text.setPosition(GAME_MAP_POS,0); |
|
|
|
|
|
|
|
$map_text.setCharacterSize(MAP_FONT_SIZE); |
|
|
|
|
|
|
|
$map_text.setFillColor(color(Value::MID)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$game_map.generate(); |
|
|
|
$game_map.generate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -135,18 +130,6 @@ void GUI::run_systems() { |
|
|
|
System::combat($world, player); |
|
|
|
System::combat($world, player); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GUI::burn() { |
|
|
|
|
|
|
|
for(int i = 0; i < 20; ++i) { |
|
|
|
|
|
|
|
$map_text.setFillColor(color(i % VALUES.size())); |
|
|
|
|
|
|
|
int x = Random::uniform<int>(-10,10); |
|
|
|
|
|
|
|
int y = Random::uniform<int>(-10,10); |
|
|
|
|
|
|
|
draw_screen(false, x, y); |
|
|
|
|
|
|
|
std::this_thread::sleep_for(2ms); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map_text.setFillColor(color(Value::MID)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GUI::draw_screen(bool clear, float map_off_x, float map_off_y) { |
|
|
|
void GUI::draw_screen(bool clear, float map_off_x, float map_off_y) { |
|
|
|
if(clear) $window.clear(); |
|
|
|
if(clear) $window.clear(); |
|
|
|
std::string screenout = $screen.ToString(); |
|
|
|
std::string screenout = $screen.ToString(); |
|
|
@ -156,17 +139,19 @@ void GUI::draw_screen(bool clear, float map_off_x, float map_off_y) { |
|
|
|
$window.draw($ui_text); |
|
|
|
$window.draw($ui_text); |
|
|
|
|
|
|
|
|
|
|
|
std::wstring map_screen_utf8 = $converter.from_bytes(map_screenout); |
|
|
|
std::wstring map_screen_utf8 = $converter.from_bytes(map_screenout); |
|
|
|
$map_text.setString(map_screen_utf8); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sf::Texture ftext = $font.getTexture(MAP_FONT_SIZE); |
|
|
|
sf::Texture ftext = $font.getTexture(MAP_FONT_SIZE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float y = 0.0f; |
|
|
|
|
|
|
|
float x = GAME_MAP_POS; |
|
|
|
|
|
|
|
const float line_spacing = $font.getLineSpacing(MAP_FONT_SIZE); |
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < map_screen_utf8.size(); i++) { |
|
|
|
for(size_t i = 0; i < map_screen_utf8.size(); i++) { |
|
|
|
wchar_t tile = map_screen_utf8[i]; |
|
|
|
wchar_t tile = map_screen_utf8[i]; |
|
|
|
sf::Glyph glyph = $font.getGlyph(tile, MAP_FONT_SIZE, false); |
|
|
|
sf::Glyph glyph = $font.getGlyph(tile, MAP_FONT_SIZE, false); |
|
|
|
sf::Sprite sprite(ftext); |
|
|
|
sf::Sprite sprite(ftext); |
|
|
|
sprite.setTextureRect(glyph.textureRect); |
|
|
|
sprite.setTextureRect(glyph.textureRect); |
|
|
|
auto pos = $map_text.findCharacterPos(i); |
|
|
|
sprite.setPosition({x, y}); |
|
|
|
sprite.setPosition(pos); |
|
|
|
|
|
|
|
if(tile == L'█') { |
|
|
|
if(tile == L'█') { |
|
|
|
sprite.setColor(sf::Color(100,100,100)); |
|
|
|
sprite.setColor(sf::Color(100,100,100)); |
|
|
|
} else if(tile == L'☺') { |
|
|
|
} else if(tile == L'☺') { |
|
|
@ -175,14 +160,19 @@ void GUI::draw_screen(bool clear, float map_off_x, float map_off_y) { |
|
|
|
sprite.setColor(sf::Color::Red); |
|
|
|
sprite.setColor(sf::Color::Red); |
|
|
|
} else if(tile == L'·') { |
|
|
|
} else if(tile == L'·') { |
|
|
|
sprite.setColor(color(Value::DARK_MID)); |
|
|
|
sprite.setColor(color(Value::DARK_MID)); |
|
|
|
} else if(tile == L'\n' || tile == L'\r') { |
|
|
|
} else if(tile == L'\r') { |
|
|
|
// skip newlines
|
|
|
|
continue; // skip these, just windows junk
|
|
|
|
|
|
|
|
} else if(tile == L'\n') { |
|
|
|
|
|
|
|
// newline
|
|
|
|
|
|
|
|
y += line_spacing; |
|
|
|
|
|
|
|
x = GAME_MAP_POS; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
sprite.setColor(color(Value::MID)); |
|
|
|
sprite.setColor(color(Value::MID)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$window.draw(sprite); |
|
|
|
$window.draw(sprite); |
|
|
|
|
|
|
|
x += glyph.advance; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$window.display(); |
|
|
|
$window.display(); |
|
|
|