From 4ab5ee8a68fd6b297c45baea3bd9c5f81e9053aa Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 12 Apr 2024 00:34:26 -0400 Subject: [PATCH] Add context info about bitmaps to canvas --- src/app/editor/modules/tile16_editor.cc | 9 +++++---- src/app/editor/modules/tile16_editor.h | 4 ++-- src/app/gfx/bitmap.h | 7 ++++--- src/app/gui/canvas.cc | 6 +++++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/app/editor/modules/tile16_editor.cc b/src/app/editor/modules/tile16_editor.cc index 3dd7b30e..a0c87c12 100644 --- a/src/app/editor/modules/tile16_editor.cc +++ b/src/app/editor/modules/tile16_editor.cc @@ -11,6 +11,7 @@ #include "app/gfx/bitmap.h" #include "app/gfx/snes_palette.h" #include "app/gfx/snes_tile.h" +#include "app/gfx/tilesheet.h" #include "app/gui/canvas.h" #include "app/gui/icons.h" #include "app/gui/input.h" @@ -89,6 +90,7 @@ absl::Status Tile16Editor::DrawTile16Editor() { TableNextColumn(); RETURN_IF_ERROR(UpdateTile16Edit()); + RETURN_IF_ERROR(DrawTileEditControls()); ImGui::EndTable(); } @@ -172,7 +174,7 @@ absl::Status Tile16Editor::UpdateTile16Edit() { ImVec2(ImGui::GetContentRegionAvail().x, 0x175), true)) { tile8_source_canvas_.DrawBackground(); - tile8_source_canvas_.DrawContextMenu(); + tile8_source_canvas_.DrawContextMenu(¤t_gfx_bmp_); if (tile8_source_canvas_.DrawTileSelector(32)) { RETURN_IF_ERROR( current_gfx_individual_[current_tile8_].ApplyPaletteWithTransparent( @@ -200,7 +202,7 @@ absl::Status Tile16Editor::UpdateTile16Edit() { if (ImGui::BeginChild("Tile16 Editor Options", ImVec2(ImGui::GetContentRegionAvail().x, 0x50), true)) { tile16_edit_canvas_.DrawBackground(); - tile16_edit_canvas_.DrawContextMenu(); + tile16_edit_canvas_.DrawContextMenu(¤t_tile16_bmp_); tile16_edit_canvas_.DrawBitmap(current_tile16_bmp_, 0, 0, 4.0f); if (!tile8_source_canvas_.points().empty()) { if (tile16_edit_canvas_.DrawTilePainter( @@ -214,7 +216,6 @@ absl::Status Tile16Editor::UpdateTile16Edit() { tile16_edit_canvas_.DrawOverlay(); } ImGui::EndChild(); - RETURN_IF_ERROR(DrawTileEditControls()); return absl::OkStatus(); } @@ -277,7 +278,7 @@ absl::Status Tile16Editor::LoadTile8() { int gfx_position = x + (y * 0x100); // Get the pixel value from the current gfx data - uint8_t value = tile8_gfx_data_[gfx_position]; + uint8_t value = current_gfx_bmp_.data()[gfx_position]; if (value & 0x80) { value -= 0x88; diff --git a/src/app/editor/modules/tile16_editor.h b/src/app/editor/modules/tile16_editor.h index d5f4d7d4..a15d7811 100644 --- a/src/app/editor/modules/tile16_editor.h +++ b/src/app/editor/modules/tile16_editor.h @@ -13,6 +13,7 @@ #include "app/gfx/bitmap.h" #include "app/gfx/snes_palette.h" #include "app/gfx/snes_tile.h" +#include "app/gfx/tilesheet.h" #include "app/gui/canvas.h" #include "app/gui/icons.h" #include "app/gui/pipeline.h" @@ -106,6 +107,7 @@ class Tile16Editor : public GfxContext, public SharedROM { ImVec2(core::kTilesheetWidth * 4, core::kTilesheetHeight * 0x10 * 4), gui::CanvasGridSize::k32x32}; gfx::Bitmap current_gfx_bmp_; + std::vector current_tilesheets_; gui::Canvas transfer_canvas_; gfx::Bitmap transfer_blockset_bmp_; @@ -129,8 +131,6 @@ class Tile16Editor : public GfxContext, public SharedROM { ROM transfer_rom_; absl::Status transfer_status_; - - core::TaskManager> task_manager_; }; } // namespace editor diff --git a/src/app/gfx/bitmap.h b/src/app/gfx/bitmap.h index 3195124b..c2d50dc1 100644 --- a/src/app/gfx/bitmap.h +++ b/src/app/gfx/bitmap.h @@ -48,10 +48,11 @@ class Bitmap { int height); absl::Status ApplyPalette(const SnesPalette &palette); - absl::Status ApplyPaletteWithTransparent(const SnesPalette &palette, int index, - int length = 7); + absl::Status ApplyPaletteWithTransparent(const SnesPalette &palette, + int index, int length = 7); void ApplyPalette(const std::vector &palette); - absl::Status ApplyPaletteFromPaletteGroup(const SnesPalette &palette, int palette_id); + absl::Status ApplyPaletteFromPaletteGroup(const SnesPalette &palette, + int palette_id); void WriteToPixel(int position, uchar value) { if (pixel_data_ == nullptr) { diff --git a/src/app/gui/canvas.cc b/src/app/gui/canvas.cc index 07cbab49..66107522 100644 --- a/src/app/gui/canvas.cc +++ b/src/app/gui/canvas.cc @@ -115,7 +115,7 @@ void Canvas::DrawContextMenu(gfx::Bitmap *bitmap) { scrolling_.y = 0; } ImGui::MenuItem("Show Grid", nullptr, &enable_grid_); - ImGui::Selectable("Show Labels", &enable_hex_tile_labels_); + ImGui::Selectable("Show Position Labels", &enable_hex_tile_labels_); if (ImGui::BeginMenu("Canvas Properties")) { ImGui::Text("Canvas Size: %.0f x %.0f", canvas_sz_.x, canvas_sz_.y); ImGui::Text("Global Scale: %.1f", global_scale_); @@ -127,6 +127,10 @@ void Canvas::DrawContextMenu(gfx::Bitmap *bitmap) { ImGui::Text("Size: %.0f x %.0f", scaled_sz.x, scaled_sz.y); ImGui::Text("Pitch: %s", absl::StrFormat("%d", bitmap->surface()->pitch).c_str()); + ImGui::Text("BitsPerPixel: %d", + bitmap->surface()->format->BitsPerPixel); + ImGui::Text("BytesPerPixel: %d", + bitmap->surface()->format->BytesPerPixel); ImGui::EndMenu(); } }