diff --git a/assets/map_tiles.json b/assets/map_tiles.json index 677aecf..3523cd8 100644 --- a/assets/map_tiles.json +++ b/assets/map_tiles.json @@ -8,121 +8,121 @@ { "centered": false, "display": 8284, - "x": 32, + "x": 64, "y": 0 }, { "centered": false, "display": 11590, - "x": 64, + "x": 128, "y": 0 }, { "centered": false, "display": 10899, - "x": 96, + "x": 192, "y": 0 }, { "centered": false, "display": 9256, - "x": 128, + "x": 256, "y": 0 }, { "centered": false, "display": 9608, - "x": 160, + "x": 320, "y": 0 }, { "centered": false, "display": 10747, - "x": 192, + "x": 384, "y": 0 }, { "centered": false, "display": 8285, - "x": 224, + "x": 448, "y": 0 }, { "centered": true, "display": 1003, - "x": 256, + "x": 512, "y": 0 }, { "centered": true, "display": 3848, - "x": 288, + "x": 576, "y": 0 }, { "centered": true, "display": 85, "x": 0, - "y": 32 + "y": 64 }, { "centered": true, "display": 8687, - "x": 32, - "y": 32 + "x": 64, + "y": 64 }, { "centered": true, "display": 10949, - "x": 64, - "y": 32 + "x": 128, + "y": 64 }, { "centered": true, "display": 8793, - "x": 96, - "y": 32 + "x": 192, + "y": 64 }, { "centered": true, "display": 95, - "x": 128, - "y": 32 + "x": 256, + "y": 64 }, { "centered": true, "display": 1898, - "x": 160, - "y": 32 + "x": 320, + "y": 64 }, { "centered": true, "display": 42586, - "x": 192, - "y": 32 + "x": 384, + "y": 64 }, { "centered": true, "display": 2189, - "x": 224, - "y": 32 + "x": 448, + "y": 64 }, { "centered": true, "display": 41981, - "x": 256, - "y": 32 + "x": 512, + "y": 64 }, { "centered": true, "display": 2220, - "x": 288, - "y": 32 + "x": 576, + "y": 64 }, { "centered": true, "display": 1218, "x": 0, - "y": 64 + "y": 128 } ] diff --git a/assets/map_tiles.png b/assets/map_tiles.png index f750379..1c87bb7 100644 Binary files a/assets/map_tiles.png and b/assets/map_tiles.png differ diff --git a/constants.hpp b/constants.hpp index 5087749..8e9d7f6 100644 --- a/constants.hpp +++ b/constants.hpp @@ -15,8 +15,8 @@ constexpr const int RAY_VIEW_Y=0; constexpr const int GLOW_LIMIT=220; constexpr const int LIGHT_MULTIPLIER=2.5; constexpr const float AIMED_AT_BRIGHTNESS=0.2f; -constexpr const int MAP_TILE_DIM=32; -constexpr const int ICONGEN_MAP_TILE_DIM=32; +constexpr const int MAP_TILE_DIM=64; +constexpr const int ICONGEN_MAP_TILE_DIM=64; constexpr const int BOSS_VIEW_WIDTH=1080; constexpr const int BOSS_VIEW_HEIGHT=SCREEN_HEIGHT; diff --git a/gui/fsm.cpp b/gui/fsm.cpp index d7e6315..24a9fe5 100644 --- a/gui/fsm.cpp +++ b/gui/fsm.cpp @@ -347,7 +347,7 @@ namespace gui { if(!sound::playing("ambient_1")) sound::play("ambient_1", true); $debug_ui.debug(); shaders::reload(); - $map_ui.save_map("map.txt", $main_ui.$compass_dir); + $map_ui.save_map($main_ui.$compass_dir); break; case KEY::O: autowalking = true; diff --git a/gui/map_view.cpp b/gui/map_view.cpp index ac65a87..076aaa1 100644 --- a/gui/map_view.cpp +++ b/gui/map_view.cpp @@ -18,6 +18,9 @@ namespace gui { MapViewUI::MapViewUI(GameLevel &level) : $level(level), + $map_render(std::make_shared()), + $map_sprite($map_render->getTexture()), + $map_tiles(matrix::make(12,11)), $paper(textures::get("full_screen_paper")) { } @@ -27,47 +30,43 @@ 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(grid, - {L"Loading...", 65, {27, 26, 23, 150}, 10}); - $log_to = $gui.entity("log_view"); $gui.set($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; - 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(grid); - map_text.update(L"MAP BROKEN"); - $gui.render(window); - // $gui.debug_layout(window); - } + void MapViewUI::render(sf::RenderWindow &window, int compass_dir) { + window.draw(*$paper.sprite); - void MapViewUI::save_map(const std::string& outfile, int compass_dir) { - (void)compass_dir; - std::wstring map_out = L"I'M BROKEN"; + System::draw_map($level, $map_tiles, $entity_map, compass_dir); - std::wofstream out(outfile, std::ios::binary); - std::locale loc(std::locale::classic(), new std::codecvt_utf8); - out.imbue(loc); + System::render_map($map_tiles, $entity_map, *$map_render); - out << map_out; - dbc::check(out.good(), "failed to write map file"); + $map_sprite.setTexture($map_render->getTexture(), true); + window.draw($map_sprite); + + $gui.render(window); + // $gui.debug_layout(window); } void MapViewUI::update() { diff --git a/gui/map_view.hpp b/gui/map_view.hpp index ed00a22..0f3ac8e 100644 --- a/gui/map_view.hpp +++ b/gui/map_view.hpp @@ -1,6 +1,7 @@ #pragma once #include "levelmanager.hpp" #include "textures.hpp" +#include "matrix.hpp" #include #include @@ -8,10 +9,14 @@ namespace gui { class MapViewUI { public: guecs::UI $gui; - GameLevel $level; DinkyECS::Entity $log_to; - textures::SpriteTexture $paper; + EntityGrid $entity_map; std::deque $messages; + GameLevel $level; + std::shared_ptr $map_render; + sf::Sprite $map_sprite; + matrix::Matrix $map_tiles; + textures::SpriteTexture $paper; MapViewUI(GameLevel &level); void init(); @@ -19,6 +24,6 @@ namespace gui { void update_level(GameLevel &level); void log(std::wstring msg); void update(); - void save_map(const std::string& outfile, int compass_dir); + void save_map(int compass_dir); }; } diff --git a/tests/map.cpp b/tests/map.cpp index 2ae63f1..7eadb91 100644 --- a/tests/map.cpp +++ b/tests/map.cpp @@ -101,7 +101,6 @@ TEST_CASE("map image test", "[map-sprite]") { player_pos.location.y = it.y; System::draw_map(level, map_tiles, entity_map, 2); - // on level start make one render texture with the base map System::render_map(map_tiles, entity_map, *render); #ifdef TEST_RENDER diff --git a/tools/icongen.cpp b/tools/icongen.cpp index 16ba758..4d25ac7 100644 --- a/tools/icongen.cpp +++ b/tools/icongen.cpp @@ -83,6 +83,7 @@ struct MapTileBuilder { } void run_real_textures(MapConfig &config) { + textures::init(); sf::Vector2u crop{$size.x * (unsigned int)config.it.width, ($size.y) * ((unsigned int)config.it.y + 1)}; $render = std::make_shared(crop); $render->clear({0,0,0,0}); @@ -248,7 +249,6 @@ json& component_display(json& val) { } int main() { - textures::init(); MapConfig config; load_config(config, false, "./assets/tiles.json", [](json& val) -> json& {