Add palettes to GraphicsEditor, build housekeeping
This commit is contained in:
Submodule assets/asm/alttp-hacker-workspace updated: ea81eb3425...2520fb70c3
@@ -28,7 +28,7 @@ set(
|
|||||||
${IMGUI_PATH}/imgui_draw.cpp
|
${IMGUI_PATH}/imgui_draw.cpp
|
||||||
${IMGUI_PATH}/imgui_widgets.cpp
|
${IMGUI_PATH}/imgui_widgets.cpp
|
||||||
${IMGUI_PATH}/backends/imgui_impl_sdl2.cpp
|
${IMGUI_PATH}/backends/imgui_impl_sdl2.cpp
|
||||||
${IMGUI_PATH}/backends/imgui_impl_sdlrenderer.cpp
|
${IMGUI_PATH}/backends/imgui_impl_sdlrenderer2.cpp
|
||||||
${IMGUI_PATH}/misc/cpp/imgui_stdlib.cpp
|
${IMGUI_PATH}/misc/cpp/imgui_stdlib.cpp
|
||||||
${IMGUI_FILE_DLG_PATH}/ImGuiFileDialog.cpp
|
${IMGUI_FILE_DLG_PATH}/ImGuiFileDialog.cpp
|
||||||
${IMGUI_COLOR_TEXT_EDIT_PATH}/TextEditor.cpp
|
${IMGUI_COLOR_TEXT_EDIT_PATH}/TextEditor.cpp
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
|
#include "app/editor/palette_editor.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/gui/canvas.h"
|
#include "app/gui/canvas.h"
|
||||||
@@ -70,6 +71,7 @@ absl::Status GraphicsEditor::DrawImport() {
|
|||||||
|
|
||||||
gui::InputHex("Offset", ¤t_offset_);
|
gui::InputHex("Offset", ¤t_offset_);
|
||||||
gui::InputHex("Size ", &size);
|
gui::InputHex("Size ", &size);
|
||||||
|
gui::InputHex("Palette ", ¤t_palette_);
|
||||||
|
|
||||||
if (ImGui::Button("Super Donkey")) {
|
if (ImGui::Button("Super Donkey")) {
|
||||||
current_offset_ = 0x98219;
|
current_offset_ = 0x98219;
|
||||||
@@ -106,11 +108,16 @@ absl::Status GraphicsEditor::DecompressImportData(int size) {
|
|||||||
std::cout << "Size of import data" << import_data_.size() << std::endl;
|
std::cout << "Size of import data" << import_data_.size() << std::endl;
|
||||||
|
|
||||||
Bytes new_sheet;
|
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_);
|
rom_.RenderBitmap(&bitmap_);
|
||||||
|
|
||||||
gfx_loaded_ = true;
|
gfx_loaded_ = true;
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
|
#include "app/editor/palette_editor.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/gui/canvas.h"
|
#include "app/gui/canvas.h"
|
||||||
@@ -50,15 +51,20 @@ class GraphicsEditor {
|
|||||||
|
|
||||||
int current_offset_ = 0;
|
int current_offset_ = 0;
|
||||||
int current_size_ = 0;
|
int current_size_ = 0;
|
||||||
|
int current_palette_ = 0;
|
||||||
bool gfx_loaded_ = false;
|
bool gfx_loaded_ = false;
|
||||||
|
|
||||||
ROM rom_;
|
ROM rom_;
|
||||||
ROM temp_rom_;
|
ROM temp_rom_;
|
||||||
Bytes import_data_;
|
Bytes import_data_;
|
||||||
|
Bytes graphics_buffer_;
|
||||||
|
|
||||||
gfx::Bitmap bitmap_;
|
gfx::Bitmap bitmap_;
|
||||||
gui::Canvas import_canvas_;
|
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 gfx_edit_flags = ImGuiTableFlags_Reorderable |
|
||||||
ImGuiTableFlags_Resizable |
|
ImGuiTableFlags_Resizable |
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
|||||||
rom_.RenderBitmap(¤t_gfx_bmp_);
|
rom_.RenderBitmap(¤t_gfx_bmp_);
|
||||||
|
|
||||||
// Create the tile16 blockset image
|
// 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_);
|
tile16_blockset_bmp_.ApplyPalette(palette_);
|
||||||
rom_.RenderBitmap(&tile16_blockset_bmp_);
|
rom_.RenderBitmap(&tile16_blockset_bmp_);
|
||||||
map_blockset_loaded_ = true;
|
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
|
// 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) {
|
for (const auto &[key, value] : gfx_bin) {
|
||||||
int offset = 0x40 * (key + 1);
|
int offset = 0x40 * (key + 1);
|
||||||
int top_left_y = canvas_p0_.y + 2;
|
int top_left_y = canvas_p0_.y + 2;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Canvas {
|
|||||||
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0,
|
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0,
|
||||||
bool ready = true);
|
bool ready = true);
|
||||||
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
|
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 DrawOutline(int x, int y, int w, int h);
|
||||||
void DrawRect(int x, int y, int w, int h, ImVec4 color);
|
void DrawRect(int x, int y, int w, int h, ImVec4 color);
|
||||||
void DrawText(std::string text, int x, int y);
|
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