Map now displays and works, just need to refine the colors and the compass directions.
This commit is contained in:
parent
dca38397e7
commit
75646619b3
8 changed files with 77 additions and 74 deletions
|
@ -18,6 +18,9 @@ namespace gui {
|
|||
|
||||
MapViewUI::MapViewUI(GameLevel &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"))
|
||||
{
|
||||
}
|
||||
|
@ -27,49 +30,45 @@ namespace gui {
|
|||
}
|
||||
|
||||
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.layout(
|
||||
"[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");
|
||||
$gui.set<Textual>($log_to, {L"Welcome to the Game!", 25, {37, 36, 33}, 25});
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
void MapViewUI::render(sf::RenderWindow &window, int compass_dir) {
|
||||
void MapViewUI::save_map(int compass_dir) {
|
||||
(void)compass_dir;
|
||||
// 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");
|
||||
}
|
||||
|
||||
|
||||
void MapViewUI::render(sf::RenderWindow &window, int compass_dir) {
|
||||
window.draw(*$paper.sprite);
|
||||
|
||||
auto grid = $gui.entity("map_grid");
|
||||
// System::draw_map
|
||||
auto& map_text = $gui.get<Textual>(grid);
|
||||
map_text.update(L"MAP BROKEN");
|
||||
System::draw_map($level, $map_tiles, $entity_map, compass_dir);
|
||||
|
||||
System::render_map($map_tiles, $entity_map, *$map_render);
|
||||
|
||||
$map_sprite.setTexture($map_render->getTexture(), true);
|
||||
window.draw($map_sprite);
|
||||
|
||||
$gui.render(window);
|
||||
// $gui.debug_layout(window);
|
||||
}
|
||||
|
||||
void MapViewUI::save_map(const std::string& outfile, int compass_dir) {
|
||||
(void)compass_dir;
|
||||
std::wstring map_out = L"I'M BROKEN";
|
||||
|
||||
std::wofstream out(outfile, std::ios::binary);
|
||||
std::locale loc(std::locale::classic(), new std::codecvt_utf8<wchar_t>);
|
||||
out.imbue(loc);
|
||||
|
||||
out << map_out;
|
||||
dbc::check(out.good(), "failed to write map file");
|
||||
}
|
||||
|
||||
void MapViewUI::update() {
|
||||
if(auto text = $gui.get_if<Textual>($log_to)) {
|
||||
//BUG: I'm calling this what it is, fix it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue