Add SelectablePalettePipeline for updating palette

This commit is contained in:
Justin Scofield
2023-08-03 21:09:27 -04:00
parent d2789ff7b6
commit 7d0b09a589
11 changed files with 116 additions and 37 deletions

View File

@@ -33,7 +33,8 @@ absl::Status GraphicsEditor::Update() {
BEGIN_TABLE("#gfxEditTable", 4, kGfxEditFlags)
SETUP_COLUMN("Graphics (BIN, CGX, SCR)")
SETUP_COLUMN("Palette (COL)")
SETUP_COLUMN("Maps and Animations (SCR, PNL)")
ImGui::TableSetupColumn("Maps and Animations (SCR, PNL)",
ImGuiTableColumnFlags_WidthFixed);
SETUP_COLUMN("Preview")
TABLE_HEADERS()
NEXT_COLUMN()
@@ -47,15 +48,30 @@ absl::Status GraphicsEditor::Update() {
status_ = DrawPaletteControls();
NEXT_COLUMN()
core::BitmapCanvasPipeline(0x200, 0x200, 0x20, 6, scr_loaded_, cgx_bitmap_);
core::BitmapCanvasPipeline(0x200, 0x200, 0x20, scr_loaded_, cgx_bitmap_,
false, 0);
NEXT_COLUMN()
if (super_donkey_) {
status_ = DrawGraphicsBin();
if (refresh_graphics_) {
for (int i = 0; i < graphics_bin_.size(); i++) {
graphics_bin_[i].ApplyPalette(
col_file_palette_group_[current_palette_index_]);
rom_.UpdateBitmap(&graphics_bin_[i]);
}
refresh_graphics_ = false;
}
// Load the full graphics space from `super_donkey_1.bin`
core::GraphicsBinCanvasPipeline(0x100, 0x40, 0x20, num_sheets_to_load_, 3,
super_donkey_, graphics_bin_);
} else if (cgx_loaded_ && col_file_) {
core::BitmapCanvasPipeline(0x100, 16384, 0x20, 5, cgx_loaded_, cgx_bitmap_);
// Load the CGX graphics
core::BitmapCanvasPipeline(0x100, 16384, 0x20, cgx_loaded_, cgx_bitmap_,
true, 5);
} else {
core::BitmapCanvasPipeline(0x100, 16384, 0x20, 2, gfx_loaded_, bitmap_);
// Load the BIN/Clipboard Graphics
core::BitmapCanvasPipeline(0x100, 16384, 0x20, gfx_loaded_, bitmap_, true,
2);
}
END_TABLE()
@@ -170,15 +186,7 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
if (col_file_palette_group_.size() != 0) {
col_file_palette_group_.Clear();
}
for (int i = 0; i < col_data_.size(); i += 8) {
// Extract 8 colors from the col_data_ and make them into a palette
gfx::SNESPalette palette;
for (int j = 0; j < 8; j++) {
palette.AddColor(col_data_[i + j]);
}
// color.AddColor()
col_file_palette_group_.AddPalette(palette);
}
col_file_palette_group_ = gfx::CreatePaletteGroupFromColFile(col_data_);
col_file_palette_ = gfx::SNESPalette(col_data_);
col_file_ = true;
is_open_ = true;
@@ -195,7 +203,8 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
}
if (col_file_palette_.size() != 0) {
palette_editor_.DrawPortablePalette(col_file_palette_);
core::SelectablePalettePipeline(current_palette_index_, refresh_graphics_,
col_file_palette_);
}
return absl::OkStatus();
@@ -257,12 +266,6 @@ absl::Status GraphicsEditor::DrawMemoryEditor() {
return absl::OkStatus();
}
absl::Status GraphicsEditor::DrawGraphicsBin() {
core::GraphicsBinCanvasPipeline(0x100, 0x40, 0x20, num_sheets_to_load_, 3,
super_donkey_, graphics_bin_);
return absl::OkStatus();
}
absl::Status GraphicsEditor::DecompressImportData(int size) {
ASSIGN_OR_RETURN(import_data_, gfx::lc_lz2::DecompressV2(
temp_rom_.data(), current_offset_, size))
@@ -298,7 +301,7 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() {
auto converted_sheet = gfx::SnesTo8bppSheet(decompressed_data, 3);
graphics_bin_[i] =
gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight,
core::kTilesheetDepth, converted_sheet.data(), 0x1000);
core::kTilesheetDepth, converted_sheet);
if (col_file_) {
graphics_bin_[i].ApplyPalette(
col_file_palette_group_[current_palette_index_]);
@@ -323,7 +326,7 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() {
auto converted_sheet = gfx::SnesTo8bppSheet(decompressed_data, 3);
graphics_bin_[i] =
gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight,
core::kTilesheetDepth, converted_sheet.data(), 0x1000);
core::kTilesheetDepth, converted_sheet);
if (col_file_) {
graphics_bin_[i].ApplyPalette(
col_file_palette_group_[current_palette_index_]);

View File

@@ -73,7 +73,6 @@ class GraphicsEditor {
absl::Status DrawClipboardImport();
absl::Status DrawExperimentalFeatures();
absl::Status DrawMemoryEditor();
absl::Status DrawGraphicsBin();
absl::Status DecompressImportData(int size);
@@ -91,6 +90,7 @@ class GraphicsEditor {
uint64_t clipboard_offset_ = 0;
uint64_t clipboard_size_ = 0;
bool refresh_graphics_ = false;
bool open_memory_editor_ = false;
bool gfx_loaded_ = false;
bool is_open_ = false;

View File

@@ -301,8 +301,14 @@ void MasterEditor::DrawHelpMenu() {
if (open_rom_help) ImGui::OpenPopup("Open a ROM");
if (ImGui::BeginPopupModal("Open a ROM", nullptr,
ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("File -> Open");
ImGui::Text("Select a ROM file to open");
ImGui::Text("Supported ROMs:");
ImGui::Text("The Legend of Zelda: A Link to the Past");
ImGui::Text("US Version 1.0");
ImGui::Separator();
ImGui::Text("Must remove header before opening");
ImGui::Text("Header is 0x200 bytes of data at the beginning of the ROM");
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
open_rom_help = false;

View File

@@ -263,8 +263,8 @@ void OverworldEditor::DrawTileSelector() {
if (ImGui::BeginTabBar(kTileSelectorTab.data(),
ImGuiTabBarFlags_FittingPolicyScroll)) {
if (ImGui::BeginTabItem("Tile16")) {
core::BitmapCanvasPipeline(0x100, (8192 * 2), 0x20, 1,
map_blockset_loaded_, tile16_blockset_bmp_);
core::BitmapCanvasPipeline(0x100, (8192 * 2), 0x20, map_blockset_loaded_,
tile16_blockset_bmp_, true, 1);
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Tile8")) {
@@ -277,8 +277,8 @@ void OverworldEditor::DrawTileSelector() {
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Area Graphics")) {
core::BitmapCanvasPipeline(256, 0x10 * 0x40, 0x20, 3,
overworld_.isLoaded(), current_gfx_bmp_);
core::BitmapCanvasPipeline(256, 0x10 * 0x40, 0x20, overworld_.isLoaded(),
current_gfx_bmp_, true, 3);
ImGui::EndTabItem();
}
ImGui::EndTabBar();