housekeeping, accessors, gui, etc

This commit is contained in:
scawful
2023-11-20 21:12:02 -05:00
parent 4ef2540d15
commit bbe76ac83c
12 changed files with 99 additions and 83 deletions

View File

@@ -14,6 +14,11 @@ namespace yaze {
namespace app {
namespace editor {
using ImGui::TableHeadersRow;
using ImGui::TableNextColumn;
using ImGui::TableNextRow;
using ImGui::TableSetupColumn;
absl::Status DungeonEditor::Update() {
if (!is_loaded_ && rom()->isLoaded()) {
for (int i = 0; i < 0x100; i++) {
@@ -29,14 +34,14 @@ absl::Status DungeonEditor::Update() {
ImGui::Separator();
if (ImGui::BeginTable("#DungeonEditTable", 3, toolset_table_flags_,
ImVec2(0, 0))) {
ImGui::TableSetupColumn("Room Selector");
TableSetupColumn("Room Selector");
ImGui::TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
ImGui::GetContentRegionAvail().x);
ImGui::TableSetupColumn("Object Selector");
ImGui::TableHeadersRow();
ImGui::TableNextRow();
ImGui::TableNextColumn();
TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
ImGui::GetContentRegionAvail().x);
TableSetupColumn("Object Selector");
TableHeadersRow();
TableNextRow();
TableNextColumn();
if (rom()->isLoaded()) {
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)9);
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
@@ -53,9 +58,9 @@ absl::Status DungeonEditor::Update() {
ImGui::EndChild();
}
ImGui::TableNextColumn();
TableNextColumn();
DrawDungeonTabView();
ImGui::TableNextColumn();
TableNextColumn();
DrawTileSelector();
ImGui::EndTable();
}

View File

@@ -59,7 +59,7 @@ absl::Status GfxGroupEditor::Update() {
ImGui::BeginGroup();
for (int i = 0; i < 8; i++) {
int sheet_id = rom()->main_blockset_ids[selected_blockset_][i];
auto &sheet = *rom()->BitmapManager()[sheet_id];
auto &sheet = *rom()->bitmap_manager()[sheet_id];
if (sheet_id != last_sheet_id_) {
last_sheet_id_ = sheet_id;
auto palette_group = rom()->GetPaletteGroup("ow_main");
@@ -109,7 +109,7 @@ absl::Status GfxGroupEditor::Update() {
ImGui::BeginGroup();
for (int i = 0; i < 4; i++) {
int sheet_id = rom()->room_blockset_ids[selected_roomset_][i];
auto &sheet = *rom()->BitmapManager()[sheet_id];
auto &sheet = *rom()->bitmap_manager()[sheet_id];
core::BitmapCanvasPipeline(roomset_canvas_, sheet, 256, 0x10 * 0x04,
0x20, true, false, 23);
}
@@ -152,7 +152,7 @@ absl::Status GfxGroupEditor::Update() {
ImGui::BeginGroup();
for (int i = 0; i < 4; i++) {
int sheet_id = rom()->spriteset_ids[selected_spriteset_][i];
auto sheet = *rom()->BitmapManager()[sheet_id];
auto sheet = *rom()->bitmap_manager()[sheet_id];
core::BitmapCanvasPipeline(spriteset_canvas_, sheet, 256,
0x10 * 0x04, 0x20, true, false, 24);
}

View File

@@ -120,7 +120,7 @@ absl::Status Tile16Editor::Update() {
if (transfer_started_ && !transfer_blockset_loaded_) {
PRINT_IF_ERROR(transfer_rom_.LoadAllGraphicsData())
graphics_bin_ = transfer_rom_.GetGraphicsBin();
graphics_bin_ = transfer_rom_.graphics_bin();
// Load the Link to the Past overworld.
PRINT_IF_ERROR(transfer_overworld_.Load(transfer_rom_))

View File

@@ -27,6 +27,11 @@ namespace app {
namespace editor {
using ImGui::Separator;
using ImGui::TableHeadersRow;
using ImGui::TableNextColumn;
using ImGui::TableNextRow;
using ImGui::TableSetupColumn;
using ImGui::Text;
absl::Status OverworldEditor::Update() {
// Initialize overworld graphics, maps, and palettes
@@ -43,14 +48,14 @@ absl::Status OverworldEditor::Update() {
Separator();
if (ImGui::BeginTable(kOWEditTable.data(), 2, kOWEditFlags, ImVec2(0, 0))) {
ImGui::TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
ImGui::GetContentRegionAvail().x);
ImGui::TableSetupColumn("Tile Selector");
ImGui::TableHeadersRow();
ImGui::TableNextRow();
ImGui::TableNextColumn();
TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
ImGui::GetContentRegionAvail().x);
TableSetupColumn("Tile Selector");
TableHeadersRow();
TableNextRow();
TableNextColumn();
DrawOverworldCanvas();
ImGui::TableNextColumn();
TableNextColumn();
DrawTileSelector();
ImGui::EndTable();
}
@@ -103,22 +108,22 @@ absl::Status OverworldEditor::DrawToolset() {
BUTTON_COLUMN(ICON_MD_ADD_LOCATION) // Transports
BUTTON_COLUMN(ICON_MD_MUSIC_NOTE) // Music
ImGui::TableNextColumn();
TableNextColumn();
if (ImGui::Button(ICON_MD_GRID_VIEW)) {
show_tile16 = !show_tile16;
}
ImGui::TableNextColumn();
TableNextColumn();
if (ImGui::Button(ICON_MD_TABLE_CHART)) {
show_gfx_group = !show_gfx_group;
}
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
ImGui::TableNextColumn(); // Palette
TableNextColumn(); // Palette
palette_editor_.DisplayPalette(palette_, overworld_.isLoaded());
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
ImGui::TableNextColumn(); // Experimental
TableNextColumn(); // Experimental
ImGui::Checkbox("Experimental", &show_experimental);
ImGui::EndTable();
@@ -150,45 +155,46 @@ void OverworldEditor::DrawOverworldMapSettings() {
for (const auto &name : kOverworldSettingsColumnNames)
ImGui::TableSetupColumn(name.data());
ImGui::TableNextColumn();
TableNextColumn();
ImGui::SetNextItemWidth(100.f);
ImGui::Combo("##world", &current_world_, kWorldList.data(), 3);
ImGui::TableNextColumn();
ImGui::Text("GFX");
TableNextColumn();
Text("GFX");
ImGui::SameLine();
ImGui::SetNextItemWidth(kInputFieldSize);
ImGui::InputText("##mapGFX", map_gfx_, kByteSize);
ImGui::TableNextColumn();
ImGui::Text("Palette");
TableNextColumn();
Text("Palette");
ImGui::SameLine();
ImGui::SetNextItemWidth(kInputFieldSize);
ImGui::InputText("##mapPal", map_palette_, kByteSize);
ImGui::TableNextColumn();
ImGui::Text("Spr GFX");
TableNextColumn();
Text("Spr GFX");
ImGui::SameLine();
ImGui::SetNextItemWidth(kInputFieldSize);
ImGui::InputText("##sprGFX", spr_gfx_, kByteSize);
ImGui::TableNextColumn();
ImGui::Text("Spr Palette");
TableNextColumn();
Text("Spr Palette");
ImGui::SameLine();
ImGui::SetNextItemWidth(kInputFieldSize);
ImGui::InputText("##sprPal", spr_palette_, kByteSize);
ImGui::TableNextColumn();
ImGui::Text("Msg ID");
TableNextColumn();
Text("Msg ID");
ImGui::SameLine();
ImGui::SetNextItemWidth(50.f);
ImGui::InputText("##msgid", spr_palette_, kMessageIdSize);
ImGui::TableNextColumn();
TableNextColumn();
ImGui::SetNextItemWidth(100.f);
ImGui::Combo("##world", &game_state_, "Part 0\0Part 1\0Part 2\0", 3);
// ImGui::Combo("##world", &game_state_, "Part 0\0Part 1\0Part 2\0", 3);
ImGui::Combo("##World", &game_state_, kGamePartComboString, 3);
ImGui::TableNextColumn();
TableNextColumn();
ImGui::Checkbox("Show grid", &opt_enable_grid); // TODO
ImGui::EndTable();
}
@@ -214,7 +220,7 @@ void OverworldEditor::DrawOverworldEntrances(ImVec2 canvas_p0,
if (ImGui::BeginDragDropSource()) {
ImGui::SetDragDropPayload("ENTRANCE_PAYLOAD", &each,
sizeof(zelda3::OverworldEntrance));
ImGui::Text("Moving Entrance ID: %s", str.c_str());
Text("Moving Entrance ID: %s", str.c_str());
ImGui::EndDragDropSource();
}
} else if (is_dragging_entrance_ && dragged_entrance_ == &each &&
@@ -412,7 +418,7 @@ void OverworldEditor::DrawTile8Selector() {
graphics_bin_canvas_.DrawContextMenu();
if (all_gfx_loaded_) {
// for (const auto &[key, value] : graphics_bin_) {
for (auto &[key, value] : rom()->BitmapManager()) {
for (auto &[key, value] : rom()->bitmap_manager()) {
int offset = 0x40 * (key + 1);
int top_left_y = graphics_bin_canvas_.GetZeroPoint().y + 2;
if (key >= 1) {
@@ -465,7 +471,7 @@ void OverworldEditor::DrawTileSelector() {
absl::Status OverworldEditor::LoadGraphics() {
// Load all of the graphics data from the game.
PRINT_IF_ERROR(rom()->LoadAllGraphicsData())
graphics_bin_ = rom()->GetGraphicsBin();
graphics_bin_ = rom()->graphics_bin();
// Load the Link to the Past overworld.
RETURN_IF_ERROR(overworld_.Load(*rom()))
@@ -549,12 +555,12 @@ absl::Status OverworldEditor::DrawExperimentalModal() {
ImGui::Begin("Experimental", &show_experimental);
gui::TextWithSeparators("PROTOTYPE OVERWORLD TILEMAP LOADER");
ImGui::Text("Please provide two files:");
ImGui::Text("One based on MAPn.DAT, which represents the overworld tilemap");
ImGui::Text("One based on MAPDATn.DAT, which is the tile32 configurations.");
ImGui::Text("Currently, loading CGX for this component is NOT supported. ");
ImGui::Text("Please load a US ROM of LTTP (JP ROM support coming soon).");
ImGui::Text(
Text("Please provide two files:");
Text("One based on MAPn.DAT, which represents the overworld tilemap");
Text("One based on MAPDATn.DAT, which is the tile32 configurations.");
Text("Currently, loading CGX for this component is NOT supported. ");
Text("Please load a US ROM of LTTP (JP ROM support coming soon).");
Text(
"Once you've loaded the files, you can click the button below to load "
"the tilemap into the editor");

View File

@@ -51,7 +51,10 @@ constexpr ImGuiTableFlags kOWEditFlags = ImGuiTableFlags_Reorderable |
ImGuiTableFlags_Resizable |
ImGuiTableFlags_SizingStretchSame;
constexpr absl::string_view kWorldList = "Light World\0Dark World\0Extra World";
constexpr absl::string_view kWorldList =
"Light World\0Dark World\0Extra World\0";
constexpr char *const kGamePartComboString[] = {"Part 0", "Part 1", "Part 2"};
constexpr absl::string_view kTileSelectorTab = "##TileSelectorTabBar";
constexpr absl::string_view kOWEditTable = "##OWEditTable";