remove app namespace

This commit is contained in:
scawful
2024-12-28 21:28:51 -05:00
parent 3ebe17c7bd
commit e05e7c35db
174 changed files with 475 additions and 658 deletions

View File

@@ -0,0 +1,53 @@
#include "dungeon_map.h"
#include <fstream>
#include <vector>
#include "app/core/platform/file_dialog.h"
#include "app/core/platform/renderer.h"
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_tile.h"
namespace yaze {
namespace zelda3 {
namespace screen {
absl::Status LoadDungeonMapGfxFromBinary(Rom &rom,
std::array<gfx::Bitmap, 4> &sheets,
gfx::Tilesheet &tile16_sheet,
std::vector<uint8_t> &gfx_bin_data) {
std::string bin_file = core::FileDialogWrapper::ShowOpenFileDialog();
if (bin_file.empty()) {
return absl::InternalError("No file selected");
}
std::ifstream file(bin_file, std::ios::binary);
if (file.is_open()) {
// Read the gfx data into a buffer
std::vector<uint8_t> bin_data((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
auto converted_bin = gfx::SnesTo8bppSheet(bin_data, 4, 4);
gfx_bin_data = converted_bin;
tile16_sheet.clear();
if (LoadDungeonMapTile16(converted_bin, true).ok()) {
std::vector<std::vector<uint8_t>> gfx_sheets;
for (int i = 0; i < 4; i++) {
gfx_sheets.emplace_back(converted_bin.begin() + (i * 0x1000),
converted_bin.begin() + ((i + 1) * 0x1000));
sheets[i] = gfx::Bitmap(128, 32, 8, gfx_sheets[i]);
sheets[i].ApplyPalette(*rom.mutable_dungeon_palette(3));
core::Renderer::GetInstance().RenderBitmap(&sheets[i]);
}
} else {
return absl::InternalError("Failed to load dungeon map tile16");
}
file.close();
}
return absl::OkStatus();
}
} // namespace screen
} // namespace zelda3
} // namespace yaze

View File

@@ -4,8 +4,11 @@
#include <array>
#include <vector>
#include "absl/status/status.h"
#include "app/gfx/tilesheet.h"
#include "app/rom.h"
namespace yaze {
namespace app {
namespace zelda3 {
namespace screen {
@@ -38,8 +41,8 @@ struct DungeonMap {
DungeonMap(unsigned short boss_room, unsigned char nbr_of_floor,
unsigned char nbr_of_basement,
const std::vector<std::array<uint8_t, 25>>& floor_rooms,
const std::vector<std::array<uint8_t, 25>>& floor_gfx)
const std::vector<std::array<uint8_t, 25>> &floor_rooms,
const std::vector<std::array<uint8_t, 25>> &floor_gfx)
: boss_room(boss_room),
nbr_of_floor(nbr_of_floor),
nbr_of_basement(nbr_of_basement),
@@ -47,9 +50,17 @@ struct DungeonMap {
floor_gfx(floor_gfx) {}
};
absl::Status LoadDungeonMapTile16(const std::vector<uint8_t> &gfx_data,
bool bin_mode);
absl::Status LoadDungeonMapGfxFromBinary(Rom &rom,
std::array<gfx::Bitmap, 4> &sheets,
gfx::Tilesheet &tile16_sheet,
std::vector<uint8_t> &gfx_bin_data);
} // namespace screen
} // namespace zelda3
} // namespace app
} // namespace yaze
#endif // YAZE_APP_ZELDA3_SCREEN_DUNGEON_MAP_H

View File

@@ -7,7 +7,6 @@
#include "app/rom.h"
namespace yaze {
namespace app {
namespace zelda3 {
namespace screen {
@@ -93,5 +92,5 @@ absl::Status Inventory::BuildTileset() {
} // namespace screen
} // namespace zelda3
} // namespace app
} // namespace yaze

View File

@@ -8,7 +8,6 @@
#include "app/rom.h"
namespace yaze {
namespace app {
namespace zelda3 {
namespace screen {
@@ -40,7 +39,7 @@ class Inventory : public SharedRom {
} // namespace screen
} // namespace zelda3
} // namespace app
} // namespace yaze
#endif // YAZE_APP_ZELDA3_INVENTORY_H

View File

@@ -7,7 +7,6 @@
#include "app/rom.h"
namespace yaze {
namespace app {
namespace zelda3 {
namespace screen {
@@ -124,5 +123,5 @@ void TitleScreen::LoadTitleScreen() {
} // namespace screen
} // namespace zelda3
} // namespace app
} // namespace yaze

View File

@@ -9,7 +9,6 @@
#include "app/rom.h"
namespace yaze {
namespace app {
namespace zelda3 {
namespace screen {
@@ -77,7 +76,7 @@ class TitleScreen {
} // namespace screen
} // namespace zelda3
} // namespace app
} // namespace yaze
#endif // YAZE_APP_ZELDA3_SCREEN_H