Add palettes to GraphicsEditor, build housekeeping

This commit is contained in:
scawful
2023-07-09 22:35:10 -04:00
parent 003e3d5ab4
commit c0d94a5982
11 changed files with 26 additions and 13 deletions

View File

@@ -7,6 +7,7 @@
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "app/editor/palette_editor.h"
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_tile.h"
#include "app/gui/canvas.h"
@@ -70,6 +71,7 @@ absl::Status GraphicsEditor::DrawImport() {
gui::InputHex("Offset", &current_offset_);
gui::InputHex("Size ", &size);
gui::InputHex("Palette ", &current_palette_);
if (ImGui::Button("Super Donkey")) {
current_offset_ = 0x98219;
@@ -106,11 +108,16 @@ absl::Status GraphicsEditor::DecompressImportData(int size) {
std::cout << "Size of import data" << import_data_.size() << std::endl;
Bytes new_sheet;
bitmap_.Create(core::kTilesheetWidth, 0x2000, core::kTilesheetDepth,
import_data_.data(), 0x1000);
if (rom_.isLoaded()) {
auto palette_group = rom_.GetPaletteGroup("ow_main");
palette_ = palette_group.palettes[current_palette_];
bitmap_.ApplyPalette(palette_);
}
bitmap_.Create(core::kTilesheetWidth, core::kTilesheetHeight,
core::kTilesheetDepth, import_data_);
rom_.RenderBitmap(&bitmap_);
gfx_loaded_ = true;
return absl::OkStatus();

View File

@@ -8,6 +8,7 @@
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "app/editor/palette_editor.h"
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_tile.h"
#include "app/gui/canvas.h"
@@ -50,15 +51,20 @@ class GraphicsEditor {
int current_offset_ = 0;
int current_size_ = 0;
int current_palette_ = 0;
bool gfx_loaded_ = false;
ROM rom_;
ROM temp_rom_;
Bytes import_data_;
Bytes graphics_buffer_;
gfx::Bitmap bitmap_;
gui::Canvas import_canvas_;
gfx::BitmapTable bitmap_table_;
gfx::BitmapTable graphics_bin_;
PaletteEditor palette_editor_;
gfx::SNESPalette palette_;
ImGuiTableFlags gfx_edit_flags = ImGuiTableFlags_Reorderable |
ImGuiTableFlags_Resizable |

View File

@@ -333,7 +333,7 @@ absl::Status OverworldEditor::LoadGraphics() {
rom_.RenderBitmap(&current_gfx_bmp_);
// Create the tile16 blockset image
tile16_blockset_bmp_.Create(0x80, 8192, 0x80, overworld_.Tile16Blockset());
tile16_blockset_bmp_.Create(0x80, 0x2000, 0x80, overworld_.Tile16Blockset());
tile16_blockset_bmp_.ApplyPalette(palette_);
rom_.RenderBitmap(&tile16_blockset_bmp_);
map_blockset_loaded_ = true;

View File

@@ -164,7 +164,7 @@ void Canvas::DrawBitmap(const Bitmap &bitmap, int x_offset, int y_offset) {
}
// TODO: Add parameters for sizing and positioning
void Canvas::DrawBitmapTable(const BitmapTable gfx_bin) {
void Canvas::DrawBitmapTable(const BitmapTable &gfx_bin) {
for (const auto &[key, value] : gfx_bin) {
int offset = 0x40 * (key + 1);
int top_left_y = canvas_p0_.y + 2;

View File

@@ -30,7 +30,7 @@ class Canvas {
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0,
bool ready = true);
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
void DrawBitmapTable(const BitmapTable gfx_bin);
void DrawBitmapTable(const BitmapTable& gfx_bin);
void DrawOutline(int x, int y, int w, int h);
void DrawRect(int x, int y, int w, int h, ImVec4 color);
void DrawText(std::string text, int x, int y);