|
|
@ -18,6 +18,9 @@ namespace gui { |
|
|
|
|
|
|
|
|
|
|
|
MapViewUI::MapViewUI(GameLevel &level) : |
|
|
|
MapViewUI::MapViewUI(GameLevel &level) : |
|
|
|
$level(level), |
|
|
|
$level(level), |
|
|
|
|
|
|
|
$map_render(std::make_shared<sf::RenderTexture>()), |
|
|
|
|
|
|
|
$map_sprite($map_render->getTexture()), |
|
|
|
|
|
|
|
$map_tiles(matrix::make(12,11)), |
|
|
|
$paper(textures::get("full_screen_paper")) |
|
|
|
$paper(textures::get("full_screen_paper")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
@ -27,47 +30,43 @@ namespace gui { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MapViewUI::init() { |
|
|
|
void MapViewUI::init() { |
|
|
|
//auto top_right = overlay.entity("top_right");
|
|
|
|
|
|
|
|
//auto cell = overlay.cell_for(top_right);
|
|
|
|
|
|
|
|
$gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); |
|
|
|
$gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); |
|
|
|
$gui.layout( |
|
|
|
$gui.layout( |
|
|
|
"[log_view| *%(200)map_grid | _ ]" |
|
|
|
"[log_view| *%(200)map_grid | _ ]" |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
auto grid = $gui.entity("map_grid"); |
|
|
|
|
|
|
|
$gui.set<Textual>(grid, |
|
|
|
|
|
|
|
{L"Loading...", 65, {27, 26, 23, 150}, 10}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$log_to = $gui.entity("log_view"); |
|
|
|
$log_to = $gui.entity("log_view"); |
|
|
|
$gui.set<Textual>($log_to, {L"Welcome to the Game!", 25, {37, 36, 33}, 25}); |
|
|
|
$gui.set<Textual>($log_to, {L"Welcome to the Game!", 25, {37, 36, 33}, 25}); |
|
|
|
|
|
|
|
|
|
|
|
$paper.sprite->setPosition({0, 0}); |
|
|
|
$paper.sprite->setPosition({0, 0}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto map_cell = $gui.cell_for("map_grid"); |
|
|
|
|
|
|
|
$map_sprite.setPosition({(float)map_cell.x, (float)map_cell.y + 30}); |
|
|
|
|
|
|
|
|
|
|
|
$gui.init(); |
|
|
|
$gui.init(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MapViewUI::render(sf::RenderWindow &window, int compass_dir) { |
|
|
|
void MapViewUI::save_map(int compass_dir) { |
|
|
|
(void)compass_dir; |
|
|
|
(void)compass_dir; |
|
|
|
window.draw(*$paper.sprite); |
|
|
|
// confirm we get two different maps
|
|
|
|
|
|
|
|
auto out_img = $map_render->getTexture().copyToImage(); |
|
|
|
|
|
|
|
bool worked = out_img.saveToFile("tmp/map_render.png"); |
|
|
|
|
|
|
|
dbc::check(worked, "failed to render map"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
auto grid = $gui.entity("map_grid"); |
|
|
|
|
|
|
|
// System::draw_map
|
|
|
|
|
|
|
|
auto& map_text = $gui.get<Textual>(grid); |
|
|
|
|
|
|
|
map_text.update(L"MAP BROKEN"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$gui.render(window); |
|
|
|
void MapViewUI::render(sf::RenderWindow &window, int compass_dir) { |
|
|
|
// $gui.debug_layout(window);
|
|
|
|
window.draw(*$paper.sprite); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MapViewUI::save_map(const std::string& outfile, int compass_dir) { |
|
|
|
System::draw_map($level, $map_tiles, $entity_map, compass_dir); |
|
|
|
(void)compass_dir; |
|
|
|
|
|
|
|
std::wstring map_out = L"I'M BROKEN"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::wofstream out(outfile, std::ios::binary); |
|
|
|
System::render_map($map_tiles, $entity_map, *$map_render); |
|
|
|
std::locale loc(std::locale::classic(), new std::codecvt_utf8<wchar_t>); |
|
|
|
|
|
|
|
out.imbue(loc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out << map_out; |
|
|
|
$map_sprite.setTexture($map_render->getTexture(), true); |
|
|
|
dbc::check(out.good(), "failed to write map file"); |
|
|
|
window.draw($map_sprite); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$gui.render(window); |
|
|
|
|
|
|
|
// $gui.debug_layout(window);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MapViewUI::update() { |
|
|
|
void MapViewUI::update() { |
|
|
|