|
|
|
@ -5,6 +5,7 @@ |
|
|
|
|
#include <string> // for string, operator<< |
|
|
|
|
#include <thread> // for sleep_for |
|
|
|
|
#include <array> |
|
|
|
|
#include <algorithm> |
|
|
|
|
|
|
|
|
|
#include <ftxui/dom/elements.hpp> // for hflow, paragraph, separator, hbox, vbox, filler, operator|, border, Element |
|
|
|
|
#include <ftxui/dom/node.hpp> // for Render |
|
|
|
@ -50,10 +51,13 @@ GUI::GUI(DinkyECS::World &world, Map& game_map) : |
|
|
|
|
void GUI::resize_map(int new_size) { |
|
|
|
|
if($renderer.resize_map(new_size)) { |
|
|
|
|
auto bounds = $renderer.$base_glyph.bounds; |
|
|
|
|
$view_port = { |
|
|
|
|
size_t(std::ceil((VIDEO_X - GAME_MAP_POS) / bounds.width)), |
|
|
|
|
size_t(std::ceil(VIDEO_Y / bounds.height)) |
|
|
|
|
}; |
|
|
|
|
int view_x = std::ceil((VIDEO_X - GAME_MAP_POS) / bounds.width); |
|
|
|
|
int view_y = std::ceil(VIDEO_Y / bounds.height); |
|
|
|
|
|
|
|
|
|
// don't allow resizing beyond/below game map size
|
|
|
|
|
if(view_x > GAME_MAP_X || view_y > GAME_MAP_Y) return; |
|
|
|
|
|
|
|
|
|
$view_port = {size_t(view_x), size_t(view_y)}; |
|
|
|
|
|
|
|
|
|
// set canvas to best size
|
|
|
|
|
$canvas = Canvas($view_port.x * 2, $view_port.y * 4); |
|
|
|
|