Add BitmapCanvasPipeline, more CgxViewer updates
This commit is contained in:
@@ -30,9 +30,10 @@ absl::Status GraphicsEditor::Update() {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
BEGIN_TABLE("#gfxEditTable", 3, kGfxEditFlags)
|
||||
BEGIN_TABLE("#gfxEditTable", 4, kGfxEditFlags)
|
||||
SETUP_COLUMN("Graphics (BIN, CGX, SCR)")
|
||||
SETUP_COLUMN("Palette (COL)")
|
||||
SETUP_COLUMN("Maps and Animations (SCR, PNL)")
|
||||
SETUP_COLUMN("Preview")
|
||||
TABLE_HEADERS()
|
||||
NEXT_COLUMN()
|
||||
@@ -44,13 +45,16 @@ absl::Status GraphicsEditor::Update() {
|
||||
NEXT_COLUMN()
|
||||
status_ = DrawPaletteControls();
|
||||
|
||||
NEXT_COLUMN()
|
||||
core::BitmapCanvasPipeline(0x200, 0x200, 0x20, 6, scr_loaded_, cgx_bitmap_);
|
||||
|
||||
NEXT_COLUMN()
|
||||
if (super_donkey_) {
|
||||
status_ = DrawGraphicsBin();
|
||||
} else if (cgx_loaded_ && col_file_) {
|
||||
status_ = DrawCgxViewer();
|
||||
core::BitmapCanvasPipeline(0x100, 16384, 0x20, 5, cgx_loaded_, cgx_bitmap_);
|
||||
} else {
|
||||
status_ = DrawDecompressedData();
|
||||
core::BitmapCanvasPipeline(0x100, 16384, 0x20, 2, gfx_loaded_, bitmap_);
|
||||
}
|
||||
END_TABLE()
|
||||
|
||||
@@ -66,7 +70,11 @@ absl::Status GraphicsEditor::DrawToolset() {
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Button(ICON_MD_MEMORY)) {
|
||||
open_memory_editor_ = true;
|
||||
if (!open_memory_editor_) {
|
||||
open_memory_editor_ = true;
|
||||
} else {
|
||||
open_memory_editor_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
TEXT_COLUMN("Open Memory Editor") // Separator
|
||||
@@ -81,21 +89,31 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
||||
|
||||
ImGui::InputText("##CGXFile", cgx_file_name_, sizeof(cgx_file_name_));
|
||||
ImGui::SameLine();
|
||||
core::FileDialogPipeline("ImportCgxKey", ".CGX,.cgx\0", "Open CGX", [&]() {
|
||||
strncpy(cgx_file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(cgx_file_path_));
|
||||
strncpy(cgx_file_name_,
|
||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||
sizeof(cgx_file_name_));
|
||||
RETURN_IF_ERROR(temp_rom_.LoadFromFile(cgx_file_path_, /*z3_load=*/false))
|
||||
cgx_viewer_.LoadCgx(temp_rom_);
|
||||
auto all_tiles_data = cgx_viewer_.GetCgxData();
|
||||
cgx_bitmap_.Create(core::kTilesheetWidth, 8192, core::kTilesheetDepth,
|
||||
all_tiles_data.data(), all_tiles_data.size());
|
||||
is_open_ = true;
|
||||
cgx_loaded_ = true;
|
||||
});
|
||||
|
||||
core::FileDialogPipeline(
|
||||
"ImportCgxKey", ".CGX,.cgx\0", "Open CGX", [&]() -> auto {
|
||||
strncpy(cgx_file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(cgx_file_path_));
|
||||
strncpy(cgx_file_name_,
|
||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||
sizeof(cgx_file_name_));
|
||||
status_ = temp_rom_.LoadFromFile(cgx_file_path_, /*z3_load=*/false);
|
||||
cgx_viewer_.LoadCgx(temp_rom_);
|
||||
auto all_tiles_data = cgx_viewer_.GetCgxData();
|
||||
cgx_bitmap_.Create(core::kTilesheetWidth, 8192, core::kTilesheetDepth,
|
||||
all_tiles_data.data(), all_tiles_data.size());
|
||||
if (col_file_) {
|
||||
cgx_bitmap_.ApplyPalette(col_file_palette_);
|
||||
rom_.RenderBitmap(&cgx_bitmap_);
|
||||
}
|
||||
is_open_ = true;
|
||||
cgx_loaded_ = true;
|
||||
});
|
||||
core::ButtonPipe("Copy File Path",
|
||||
[&]() -> auto { ImGui::SetClipboardText(cgx_file_path_); });
|
||||
|
||||
CLEAR_AND_RETURN_STATUS(status_)
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
@@ -109,26 +127,18 @@ absl::Status GraphicsEditor::DrawFileImport() {
|
||||
|
||||
ImGui::InputText("##ROMFile", file_path_, sizeof(file_path_));
|
||||
ImGui::SameLine();
|
||||
// Open the file dialog when the user clicks the "Browse" button
|
||||
if (ImGui::Button("Open BIN")) {
|
||||
ImGuiFileDialog::Instance()->OpenDialog("ImportDlgKey", "Choose File",
|
||||
".bin,.hex\0", ".");
|
||||
}
|
||||
|
||||
// Draw the file dialog
|
||||
if (ImGuiFileDialog::Instance()->Display("ImportDlgKey")) {
|
||||
// If the user made a selection, copy the filename to the file_path_ buffer
|
||||
if (ImGuiFileDialog::Instance()->IsOk()) {
|
||||
strncpy(file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(file_path_));
|
||||
RETURN_IF_ERROR(temp_rom_.LoadFromFile(file_path_))
|
||||
is_open_ = true;
|
||||
}
|
||||
core::FileDialogPipeline(
|
||||
"ImportDlgKey", ".bin,.hex\0", "Open BIN", [&]() -> auto {
|
||||
strncpy(file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(file_path_));
|
||||
status_ = temp_rom_.LoadFromFile(file_path_);
|
||||
is_open_ = true;
|
||||
});
|
||||
|
||||
// Close the modal
|
||||
ImGuiFileDialog::Instance()->Close();
|
||||
}
|
||||
core::ButtonPipe("Copy File Path",
|
||||
[&]() -> auto { ImGui::SetClipboardText(file_path_); });
|
||||
|
||||
gui::InputHex("Offset", ¤t_offset_);
|
||||
gui::InputHex("Size ", &size);
|
||||
@@ -150,32 +160,23 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
|
||||
ImGui::InputText("##ColFile", col_file_name_, sizeof(col_file_name_));
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Open COL")) {
|
||||
ImGuiFileDialog::Instance()->OpenDialog("ImportColKey", "Choose File",
|
||||
".COL,.col", ".");
|
||||
}
|
||||
core::FileDialogPipeline(
|
||||
"ImportColKey", ".COL,.col,.BAK,.bak\0", "Open COL", [&]() -> auto {
|
||||
strncpy(col_file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(col_file_path_));
|
||||
strncpy(col_file_name_,
|
||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||
sizeof(col_file_name_));
|
||||
status_ = temp_rom_.LoadFromFile(col_file_path_, /*z3_load=*/false);
|
||||
auto col_data_ = gfx::GetColFileData(temp_rom_.data());
|
||||
col_file_palette_ = gfx::SNESPalette(col_data_);
|
||||
col_file_ = true;
|
||||
is_open_ = true;
|
||||
});
|
||||
|
||||
if (ImGuiFileDialog::Instance()->Display("ImportColKey")) {
|
||||
if (ImGuiFileDialog::Instance()->IsOk()) {
|
||||
strncpy(col_file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(col_file_path_));
|
||||
strncpy(col_file_name_,
|
||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||
sizeof(col_file_name_));
|
||||
RETURN_IF_ERROR(temp_rom_.LoadFromFile(col_file_path_, /*z3_load=*/false))
|
||||
auto col_data_ = gfx::GetColFileData(temp_rom_.data());
|
||||
col_file_palette_ = gfx::SNESPalette(col_data_);
|
||||
col_file_ = true;
|
||||
is_open_ = true;
|
||||
|
||||
if (cgx_loaded_) {
|
||||
cgx_bitmap_.ApplyPalette(col_file_palette_);
|
||||
rom_.RenderBitmap(&cgx_bitmap_);
|
||||
}
|
||||
}
|
||||
ImGuiFileDialog::Instance()->Close();
|
||||
}
|
||||
core::ButtonPipe("Copy File Path",
|
||||
[&]() -> auto { ImGui::SetClipboardText(col_file_path_); });
|
||||
|
||||
if (rom_.isLoaded()) {
|
||||
gui::TextWithSeparators("ROM Palette");
|
||||
@@ -185,7 +186,6 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
|
||||
}
|
||||
|
||||
if (col_file_palette_.size() != 0) {
|
||||
ImGuiFileDialog::Instance()->prDrawFileListView(ImVec2(0, 200));
|
||||
palette_editor_.DrawPortablePalette(col_file_palette_);
|
||||
}
|
||||
|
||||
@@ -231,36 +231,6 @@ absl::Status GraphicsEditor::DrawMemoryEditor() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawCgxViewer() {
|
||||
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)5);
|
||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||
import_canvas_.DrawBackground(ImVec2(0x100 + 1, (8192 * 2) + 1));
|
||||
import_canvas_.DrawContextMenu();
|
||||
import_canvas_.DrawBitmap(cgx_bitmap_, 2, cgx_loaded_);
|
||||
import_canvas_.DrawTileSelector(32);
|
||||
import_canvas_.DrawGrid(32.0f);
|
||||
import_canvas_.DrawOverlay();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawDecompressedData() {
|
||||
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)2);
|
||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||
import_canvas_.DrawBackground(ImVec2(0x100 + 1, (8192 * 2) + 1));
|
||||
import_canvas_.DrawContextMenu();
|
||||
import_canvas_.DrawBitmap(bitmap_, 2, gfx_loaded_);
|
||||
import_canvas_.DrawTileSelector(32);
|
||||
import_canvas_.DrawGrid(32.0f);
|
||||
import_canvas_.DrawOverlay();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawGraphicsBin() {
|
||||
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)3);
|
||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||
@@ -276,7 +246,7 @@ absl::Status GraphicsEditor::DrawGraphicsBin() {
|
||||
top_left_y = super_donkey_canvas_.GetZeroPoint().y + 0x40 * key;
|
||||
}
|
||||
super_donkey_canvas_.GetDrawList()->AddImage(
|
||||
(void*)value.GetTexture(),
|
||||
(void*)value.texture(),
|
||||
ImVec2(super_donkey_canvas_.GetZeroPoint().x + 2, top_left_y),
|
||||
ImVec2(super_donkey_canvas_.GetZeroPoint().x + 0x100,
|
||||
super_donkey_canvas_.GetZeroPoint().y + offset));
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "app/core/pipeline.h"
|
||||
#include "app/editor/palette_editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
@@ -70,8 +71,6 @@ class GraphicsEditor {
|
||||
absl::Status DrawClipboardImport();
|
||||
absl::Status DrawExperimentalFeatures();
|
||||
absl::Status DrawMemoryEditor();
|
||||
absl::Status DrawCgxViewer();
|
||||
absl::Status DrawDecompressedData();
|
||||
absl::Status DrawGraphicsBin();
|
||||
|
||||
absl::Status DecompressImportData(int size);
|
||||
@@ -89,6 +88,7 @@ class GraphicsEditor {
|
||||
bool super_donkey_ = false;
|
||||
bool col_file_ = false;
|
||||
bool cgx_loaded_ = false;
|
||||
bool scr_loaded_ = false;
|
||||
|
||||
char file_path_[256] = "";
|
||||
char col_file_path_[256] = "";
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/constants.h"
|
||||
#include "app/core/pipeline.h"
|
||||
#include "app/editor/assembly_editor.h"
|
||||
#include "app/editor/dungeon_editor.h"
|
||||
#include "app/editor/graphics_editor.h"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/core/pipeline.h"
|
||||
#include "app/editor/palette_editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
@@ -210,7 +211,7 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
if (overworld_.isLoaded()) {
|
||||
DrawOverworldMaps();
|
||||
DrawOverworldEntrances();
|
||||
DrawOverworldSprites();
|
||||
// DrawOverworldSprites();
|
||||
// User has selected a tile they want to draw from the blockset.
|
||||
if (!blockset_canvas_.Points().empty()) {
|
||||
int x = blockset_canvas_.Points().front().x / 32;
|
||||
@@ -232,19 +233,6 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Tile 16 Selector
|
||||
// Displays all the tiles in the game.
|
||||
void OverworldEditor::DrawTile16Selector() {
|
||||
blockset_canvas_.DrawBackground(ImVec2(0x100 + 1, (8192 * 2) + 1));
|
||||
blockset_canvas_.DrawContextMenu();
|
||||
blockset_canvas_.DrawBitmap(tile16_blockset_bmp_, 2, map_blockset_loaded_);
|
||||
blockset_canvas_.DrawTileSelector(32);
|
||||
blockset_canvas_.DrawGrid(32.0f);
|
||||
blockset_canvas_.DrawOverlay();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Tile 8 Selector
|
||||
// Displays all the individual tiles that make up a tile16.
|
||||
void OverworldEditor::DrawTile8Selector() {
|
||||
@@ -259,7 +247,7 @@ void OverworldEditor::DrawTile8Selector() {
|
||||
top_left_y = graphics_bin_canvas_.GetZeroPoint().y + 0x40 * key;
|
||||
}
|
||||
graphics_bin_canvas_.GetDrawList()->AddImage(
|
||||
(void *)value.GetTexture(),
|
||||
(void *)value.texture(),
|
||||
ImVec2(graphics_bin_canvas_.GetZeroPoint().x + 2, top_left_y),
|
||||
ImVec2(graphics_bin_canvas_.GetZeroPoint().x + 0x100,
|
||||
graphics_bin_canvas_.GetZeroPoint().y + offset));
|
||||
@@ -271,29 +259,12 @@ void OverworldEditor::DrawTile8Selector() {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Displays the graphics tilesheets that are available on the current selected
|
||||
// overworld map.
|
||||
void OverworldEditor::DrawAreaGraphics() {
|
||||
current_gfx_canvas_.DrawBackground(ImVec2(256 + 1, 0x10 * 0x40 + 1));
|
||||
current_gfx_canvas_.DrawContextMenu();
|
||||
current_gfx_canvas_.DrawTileSelector(32);
|
||||
current_gfx_canvas_.DrawBitmap(current_gfx_bmp_, 2, overworld_.isLoaded());
|
||||
current_gfx_canvas_.DrawGrid(32.0f);
|
||||
current_gfx_canvas_.DrawOverlay();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OverworldEditor::DrawTileSelector() {
|
||||
if (ImGui::BeginTabBar(kTileSelectorTab.data(),
|
||||
ImGuiTabBarFlags_FittingPolicyScroll)) {
|
||||
if (ImGui::BeginTabItem("Tile16")) {
|
||||
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)2);
|
||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||
DrawTile16Selector();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
core::BitmapCanvasPipeline(0x100, (8192 * 2), 0x20, 1,
|
||||
map_blockset_loaded_, tile16_blockset_bmp_);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Tile8")) {
|
||||
@@ -306,12 +277,8 @@ void OverworldEditor::DrawTileSelector() {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Area Graphics")) {
|
||||
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)3);
|
||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||
DrawAreaGraphics();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
core::BitmapCanvasPipeline(256, 0x10 * 0x40, 0x20, 3,
|
||||
overworld_.isLoaded(), current_gfx_bmp_);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
@@ -328,14 +295,16 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
// Load the Link to the Past overworld.
|
||||
RETURN_IF_ERROR(overworld_.Load(rom_))
|
||||
palette_ = overworld_.AreaPalette();
|
||||
current_gfx_bmp_.Create(0x80, 0x200, 0x40, overworld_.AreaGraphics());
|
||||
current_gfx_bmp_.ApplyPalette(palette_);
|
||||
rom_.RenderBitmap(¤t_gfx_bmp_);
|
||||
|
||||
// Create the area graphics image
|
||||
core::BuildAndRenderBitmapPipeline(0x80, 0x200, 0x40,
|
||||
overworld_.AreaGraphics(), rom_,
|
||||
current_gfx_bmp_, palette_);
|
||||
|
||||
// Create the tile16 blockset image
|
||||
tile16_blockset_bmp_.Create(0x80, 0x2000, 0x80, overworld_.Tile16Blockset());
|
||||
tile16_blockset_bmp_.ApplyPalette(palette_);
|
||||
rom_.RenderBitmap(&tile16_blockset_bmp_);
|
||||
core::BuildAndRenderBitmapPipeline(0x80, 0x2000, 0x80,
|
||||
overworld_.Tile16Blockset(), rom_,
|
||||
tile16_blockset_bmp_, palette_);
|
||||
map_blockset_loaded_ = true;
|
||||
|
||||
// Copy the tile16 data into individual tiles.
|
||||
@@ -363,19 +332,18 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
// Render the bitmaps of each tile.
|
||||
for (int id = 0; id < 4096; id++) {
|
||||
tile16_individual_.emplace_back();
|
||||
tile16_individual_[id].Create(0x10, 0x10, 0x80,
|
||||
tile16_individual_data_[id]);
|
||||
tile16_individual_[id].ApplyPalette(palette_);
|
||||
rom_.RenderBitmap(&tile16_individual_[id]);
|
||||
core::BuildAndRenderBitmapPipeline(0x10, 0x10, 0x80,
|
||||
tile16_individual_data_[id], rom_,
|
||||
tile16_individual_[id], palette_);
|
||||
}
|
||||
|
||||
// Render the overworld maps loaded from the ROM.
|
||||
for (int i = 0; i < core::kNumOverworldMaps; ++i) {
|
||||
overworld_.SetCurrentMap(i);
|
||||
auto palette = overworld_.AreaPalette();
|
||||
maps_bmp_[i].Create(0x200, 0x200, 0x200, overworld_.BitmapData());
|
||||
maps_bmp_[i].ApplyPalette(palette);
|
||||
rom_.RenderBitmap(&(maps_bmp_[i]));
|
||||
core::BuildAndRenderBitmapPipeline(0x200, 0x200, 0x200,
|
||||
overworld_.BitmapData(), rom_,
|
||||
maps_bmp_[i], palette);
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/core/pipeline.h"
|
||||
#include "app/editor/palette_editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
@@ -75,9 +76,7 @@ class OverworldEditor : public SharedROM {
|
||||
void DrawOverworldEdits() const;
|
||||
void DrawOverworldCanvas();
|
||||
|
||||
void DrawTile16Selector();
|
||||
void DrawTile8Selector();
|
||||
void DrawAreaGraphics();
|
||||
void DrawTileSelector();
|
||||
absl::Status LoadGraphics();
|
||||
absl::Status LoadSpriteGraphics();
|
||||
|
||||
Reference in New Issue
Block a user