|
|
|
@ -79,15 +79,31 @@ void StatusUI::create_render() { |
|
|
|
|
set_renderer(status_rend); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
MapViewUI::MapViewUI(DinkyECS::World& world, LightRender& lights, Map& game_map) : |
|
|
|
|
Panel(GAME_MAP_PIXEL_POS, 0, 0, 0, true), |
|
|
|
|
$world(world), $lights(lights), $game_map(game_map) |
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MapViewUI::create_render() { |
|
|
|
|
set_renderer(Renderer([&] { |
|
|
|
|
System::draw_map($world, $game_map, $lights.lighting(), $canvas, width, height); |
|
|
|
|
return canvas($canvas); |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapViewUI::resize_canvas() { |
|
|
|
|
// set canvas to best size
|
|
|
|
|
$canvas = Canvas(width * 2, height * 4); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
GUI::GUI(DinkyECS::World &world, Map& game_map) : |
|
|
|
|
$world(world), |
|
|
|
|
$game_map(game_map), |
|
|
|
|
$status_ui(world), |
|
|
|
|
$lights(game_map.width(), game_map.height()), |
|
|
|
|
$world(world), |
|
|
|
|
$sounds("./assets"), |
|
|
|
|
$renderer() |
|
|
|
|
$map_view($world, $lights, $game_map), |
|
|
|
|
$sounds("./assets") |
|
|
|
|
{ |
|
|
|
|
// this needs a config file soon
|
|
|
|
|
// $sounds.load("ambient", "ambient_sound.mp3");
|
|
|
|
@ -101,8 +117,7 @@ GUI::GUI(DinkyECS::World &world, Map& game_map) : |
|
|
|
|
|
|
|
|
|
void GUI::resize_map(int new_size) { |
|
|
|
|
$renderer.resize_grid(new_size, $map_view); |
|
|
|
|
// set canvas to best size
|
|
|
|
|
$canvas = Canvas($map_view.width * 2, $map_view.height * 4); |
|
|
|
|
$map_view.resize_canvas(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GUI::save_world() { |
|
|
|
@ -113,11 +128,7 @@ void GUI::save_world() { |
|
|
|
|
void GUI::create_renderer() { |
|
|
|
|
$renderer.init_terminal(); |
|
|
|
|
|
|
|
|
|
$map_view.set_renderer(Renderer([&] { |
|
|
|
|
System::draw_map($world, $game_map, $lights.lighting(), $canvas, $map_view.width, $map_view.height); |
|
|
|
|
return canvas($canvas); |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
$map_view.create_render(); |
|
|
|
|
$status_ui.create_render(); |
|
|
|
|
$inventory_ui.create_render(); |
|
|
|
|
// don't activate this one
|
|
|
|
@ -186,7 +197,6 @@ bool GUI::handle_ui_events() { |
|
|
|
|
if(event.type == sf::Event::Closed) { |
|
|
|
|
shutdown(); |
|
|
|
|
} else if(event.type == sf::Event::KeyPressed) { |
|
|
|
|
|
|
|
|
|
if(KB::isKeyPressed(KB::Left)) { |
|
|
|
|
player_motion.dx = -1; |
|
|
|
|
event_happened = true; |
|
|
|
|