Add palettes to GraphicsEditor, build housekeeping
This commit is contained in:
@@ -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", ¤t_offset_);
|
||||
gui::InputHex("Size ", &size);
|
||||
gui::InputHex("Palette ", ¤t_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();
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -333,7 +333,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
rom_.RenderBitmap(¤t_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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Submodule src/lib/SDL updated: 5b904a103a...ac13ca9ab6
Submodule src/lib/SDL_mixer updated: 7f73f724f2...5ec6ceff78
Submodule src/lib/asar updated: 634d6baf7a...4d04c897b9
Submodule src/lib/imgui updated: f65bcf481a...d4ddc46e77
Reference in New Issue
Block a user