7#include "absl/strings/str_format.h"
8#include "absl/strings/string_view.h"
18#include "imgui/imgui.h"
41 int current_tile8 = 0;
42 int tile_data_offset = 0;
43 for (
int i = 0; i < 4; ++i) {
44 for (
int j = 0; j < 32; j++) {
45 std::vector<uint8_t> tile_data(64, 0);
46 int tile_index = current_tile8 + j;
49 sheets_[i].Get8x8Tile(tile_index, x, y, tile_data, tile_data_offset);
56 return absl::OkStatus();
60 if (ImGui::BeginTabBar(
"##ScreenEditorTabBar")) {
61 if (ImGui::BeginTabItem(
"Dungeon Maps")) {
75 if (ImGui::BeginTabItem(
"Inventory Menu")) {
76 static bool create =
false;
77 if (!create &&
rom()->is_loaded()) {
85 if (ImGui::BeginTable(
"InventoryScreen", 3, ImGuiTableFlags_Resizable)) {
86 ImGui::TableSetupColumn(
"Canvas");
87 ImGui::TableSetupColumn(
"Tiles");
88 ImGui::TableSetupColumn(
"Palette");
89 ImGui::TableHeadersRow();
91 ImGui::TableNextColumn();
98 ImGui::TableNextColumn();
105 ImGui::TableNextColumn();
116 if (ImGui::BeginTable(
"InventoryToolset", 8, ImGuiTableFlags_SizingFixedFit,
118 ImGui::TableSetupColumn(
"#drawTool");
119 ImGui::TableSetupColumn(
"#sep1");
120 ImGui::TableSetupColumn(
"#zoomOut");
121 ImGui::TableSetupColumn(
"#zoomIN");
122 ImGui::TableSetupColumn(
"#sep2");
123 ImGui::TableSetupColumn(
"#bg2Tool");
124 ImGui::TableSetupColumn(
"#bg3Tool");
125 ImGui::TableSetupColumn(
"#itemTool");
127 ImGui::TableNextColumn();
131 ImGui::TableNextColumn();
135 ImGui::TableNextColumn();
137 ImGui::TableNextColumn();
141 ImGui::TableNextColumn();
145 ImGui::TableNextColumn();
147 ImGui::TableNextColumn();
151 ImGui::TableNextColumn();
162 if (ImGui::BeginTabBar(
"##DungeonMapTabs")) {
164 current_dungeon.nbr_of_floor + current_dungeon.nbr_of_basement;
165 for (
int i = 0; i < nbr_floors; i++) {
166 int basement_num = current_dungeon.nbr_of_basement - i;
167 std::string tab_name = absl::StrFormat(
"Basement %d", basement_num);
168 if (i >= current_dungeon.nbr_of_basement) {
169 tab_name = absl::StrFormat(
"Floor %d",
170 i - current_dungeon.nbr_of_basement + 1);
173 if (ImGui::BeginTabItem(tab_name.c_str())) {
178 auto boss_room = current_dungeon.boss_room;
180 if (current_dungeon.floor_rooms[
floor_number][j] != 0x0F) {
181 int tile16_id = current_dungeon.floor_gfx[
floor_number][j];
182 int posX = ((j % 5) * 32);
183 int posY = ((j / 5) * 32);
187 (posX * 2), (posY * 2), 4.0f);
189 if (current_dungeon.floor_rooms[
floor_number][j] == boss_room) {
222 const ImVec2 button_size = ImVec2(130, 0);
225 if (ImGui::Button(
"Add Floor", button_size) &&
226 current_dungeon.nbr_of_floor < 8) {
227 current_dungeon.nbr_of_floor++;
231 if (ImGui::Button(
"Remove Floor", button_size) &&
232 current_dungeon.nbr_of_floor > 0) {
233 current_dungeon.nbr_of_floor--;
238 if (ImGui::Button(
"Add Basement", button_size) &&
239 current_dungeon.nbr_of_basement < 8) {
240 current_dungeon.nbr_of_basement++;
244 if (ImGui::Button(
"Remove Basement", button_size) &&
245 current_dungeon.nbr_of_basement > 0) {
246 current_dungeon.nbr_of_basement--;
250 if (ImGui::Button(
"Copy Floor", button_size)) {
254 if (ImGui::Button(
"Paste Floor", button_size)) {
260 if (ImGui::BeginChild(
"##DungeonMapTiles", ImVec2(0, 0),
true)) {
303 if (ImGui::Button(
"Modify Tile16")) {
327 static std::vector<std::string> dungeon_names = {
328 "Sewers/Sanctuary",
"Hyrule Castle",
"Eastern Palace",
329 "Desert Palace",
"Tower of Hera",
"Agahnim's Tower",
330 "Palace of Darkness",
"Swamp Palace",
"Skull Woods",
331 "Thieves' Town",
"Ice Palace",
"Misery Mire",
332 "Turtle Rock",
"Ganon's Tower"};
334 if (ImGui::BeginTable(
"DungeonMapsTable", 4,
335 ImGuiTableFlags_Resizable |
336 ImGuiTableFlags_Reorderable |
337 ImGuiTableFlags_Hideable)) {
338 ImGui::TableSetupColumn(
"Dungeon");
339 ImGui::TableSetupColumn(
"Map");
340 ImGui::TableSetupColumn(
"Rooms Gfx");
341 ImGui::TableSetupColumn(
"Tiles Gfx");
342 ImGui::TableHeadersRow();
344 ImGui::TableNextColumn();
345 for (
int i = 0; i < dungeon_names.size(); i++) {
349 if (ImGui::IsItemClicked()) {
354 ImGui::TableNextColumn();
357 ImGui::TableNextColumn();
360 ImGui::TableNextColumn();
373 ImGui::Text(
"For use with custom inserted graphics assembly patches.");
374 if (ImGui::Button(
"Load GFX from BIN file"))
LoadBinaryGfx();
382 if (!bin_file.empty()) {
383 std::ifstream file(bin_file, std::ios::binary);
384 if (file.is_open()) {
386 std::vector<uint8_t> bin_data((std::istreambuf_iterator<char>(file)),
387 std::istreambuf_iterator<char>());
393 std::vector<std::vector<uint8_t>> gfx_sheets;
394 for (
int i = 0; i < 4; i++) {
395 gfx_sheets.emplace_back(converted_bin.begin() + (i * 0x1000),
396 converted_bin.begin() + ((i + 1) * 0x1000));
398 sheets_[i].SetPalette(*
rom()->mutable_dungeon_palette(3));
403 status_ = absl::InternalError(
"Failed to load dungeon map tile16");
411 if (ImGui::BeginTabItem(
"Title Screen")) {
417 if (ImGui::BeginTabItem(
"Naming Screen")) {
423 if (ImGui::BeginTabItem(
"Overworld Map")) {
429 static bool show_bg1 =
true;
430 static bool show_bg2 =
true;
431 static bool show_bg3 =
true;
433 static bool drawing_bg1 =
true;
434 static bool drawing_bg2 =
false;
435 static bool drawing_bg3 =
false;
437 ImGui::Checkbox(
"Show BG1", &show_bg1);
439 ImGui::Checkbox(
"Show BG2", &show_bg2);
441 ImGui::Checkbox(
"Draw BG1", &drawing_bg1);
443 ImGui::Checkbox(
"Draw BG2", &drawing_bg2);
445 ImGui::Checkbox(
"Draw BG3", &drawing_bg3);
ResourceLabelManager * resource_label()
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath.
void RenderBitmap(gfx::Bitmap *bitmap)
void DrawTitleScreenEditor()
void DrawDungeonMapsRoomGfx()
std::vector< gfx::Bitmap > tile8_individual_
gfx::SnesPalette palette_
gfx::Tilemap tile16_blockset_
gui::Canvas tilemap_canvas_
std::array< gfx::TileInfo, 4 > current_tile16_info
absl::Status Load() override
absl::Status Update() override
gui::Canvas screen_canvas_
void Initialize() override
gui::Canvas current_tile_canvas_
void DrawDungeonMapsEditor()
void DrawInventoryToolset()
void DrawOverworldMapEditor()
zelda3::Inventory inventory_
EditingMode current_mode_
zelda3::DungeonMapLabels dungeon_map_labels_
bool paste_button_pressed
gui::Canvas tilesheet_canvas_
void DrawNamingScreenEditor()
void DrawDungeonMapsTabs()
std::vector< zelda3::DungeonMap > dungeon_maps_
void DrawInventoryMenuEditor()
Represents a bitmap image.
#define ICON_MD_MORE_VERT
#define PRINT_IF_ERROR(expression)
#define RETURN_IF_ERROR(expression)
#define ASSIGN_OR_RETURN(type_variable_name, expression)
Editors are the view controllers for the application.
constexpr uint32_t kRedPen
void ModifyTile16(Tilemap &tilemap, const std::vector< uint8_t > &data, const TileInfo &top_left, const TileInfo &top_right, const TileInfo &bottom_left, const TileInfo &bottom_right, int sheet_offset, int tile_id)
void UpdateTile16(Tilemap &tilemap, int tile_id)
void RenderTile16(Tilemap &tilemap, int tile_id)
std::vector< uint8_t > SnesTo8bppSheet(std::span< uint8_t > sheet, int bpp, int num_sheets)
bool InputHexWord(const char *label, uint16_t *data, float input_width, bool no_step)
bool InputTileInfo(const char *label, gfx::TileInfo *tile_info)
IMGUI_API bool DisplayPalette(gfx::SnesPalette &palette, bool loaded)
bool InputHexByte(const char *label, uint8_t *data, float input_width, bool no_step)
std::string HexByte(uint8_t byte, HexStringParams params)
absl::Status LoadDungeonMapTile16(gfx::Tilemap &tile16_blockset, Rom &rom, const std::vector< uint8_t > &gfx_data, bool bin_mode)
Load the dungeon map tile16 from the ROM.
absl::Status SaveDungeonMapTile16(gfx::Tilemap &tile16_blockset, Rom &rom)
Save the dungeon map tile16 to the ROM.
absl::StatusOr< std::vector< DungeonMap > > LoadDungeonMaps(Rom &rom, DungeonMapLabels &dungeon_map_labels)
Load the dungeon maps from the ROM.
Main namespace for the application.
void SelectableLabelWithNameEdit(bool selected, const std::string &type, const std::string &key, const std::string &defaultValue)