yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
tile16_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_TILE16EDITOR_H
2#define YAZE_APP_EDITOR_TILE16EDITOR_H
3
4#include <algorithm>
5#include <array>
6#include <chrono>
7#include <functional>
8#include <map>
9#include <optional>
10#include <string>
11#include <utility>
12#include <vector>
13
14#include "absl/status/status.h"
18#include "app/gfx/core/bitmap.h"
22#include "app/gui/core/input.h"
24#include "imgui/imgui.h"
25#include "rom/rom.h"
26#include "util/log.h"
27#include "util/notify.h"
30
31namespace yaze {
32namespace zelda3 {
33struct GameData;
34} // namespace zelda3
35
36namespace editor {
37
38// ============================================================================
39// Tile16 Editor Constants
40// ============================================================================
41
42constexpr int kTile16Size = 16; // 16x16 pixel tile
43constexpr int kTile8Size = 8; // 8x8 pixel sub-tile
44constexpr int kTilesheetEditorWidth = 0x100; // 256 pixels wide
45constexpr int kTilesheetEditorHeight = 0x4000; // 16384 pixels tall
46constexpr int kTile16CanvasSize = 0x20; // 32 pixels
47constexpr int kTile8CanvasHeight = 0x175; // 373 pixels
48constexpr int kNumScratchSlots = 4; // 4 scratch space slots
49constexpr int kNumPalettes = 8; // 8 palette buttons (0-7)
50constexpr int kTile8PixelCount = 64; // 8x8 = 64 pixels
51constexpr int kTile16PixelCount = 256; // 16x16 = 256 pixels
52
53enum class Tile16EditMode {
54 kPaint = 0,
55 kPick = 1,
56 kUsageProbe = 2,
57};
58
64
70
71// ============================================================================
72// Tile16 Editor
73// ============================================================================
74//
75// ARCHITECTURE OVERVIEW:
76// ----------------------
77// The Tile16Editor provides a popup window for editing individual 16x16 tiles
78// used in the overworld tileset. Each Tile16 is composed of four 8x8 sub-tiles
79// (Tile8) arranged in a 2x2 grid.
80//
81// EDITING WORKFLOW:
82// -----------------
83// 1. Select a Tile16 from the blockset canvas (left panel)
84// 2. Edit by clicking on the tile8 source canvas to select sub-tiles
85// 3. Place selected tile8s into the four quadrants of the Tile16
86// 4. Changes are held as "pending" until explicitly committed or discarded
87// 5. Commit saves to ROM; Discard reverts to original
88//
89// PENDING CHANGES SYSTEM:
90// -----------------------
91// To prevent accidental ROM modifications, all edits are staged:
92// - pending_tile16_changes_: Maps tile ID -> modified Tile16 data
93// - pending_tile16_bitmaps_: Maps tile ID -> preview bitmap
94// - has_pending_changes(): Returns true if any tiles are modified
95// - CommitAllChanges(): Writes all pending changes to ROM
96// - DiscardAllChanges(): Reverts all pending changes
97//
98// PALETTE COORDINATION:
99// ---------------------
100// The overworld uses a 256-color palette organized as 16 rows of 16 colors.
101// Different graphics sheets map to different palette regions:
102//
103// Sheet Index | Palette Region | Purpose
104// ------------|----------------|------------------------
105// 0, 3, 4 | AUX1 (row 10+) | Main blockset graphics
106// 1, 2 | MAIN (row 2+) | Main area graphics
107// 5, 6 | AUX2 (row 10+) | Secondary blockset
108// 7 | ANIMATED | Animated tiles
109//
110// Key palette methods:
111// - GetPaletteSlotForSheet(): Get base palette slot for a sheet
112// - GetActualPaletteSlot(): Combine palette button + sheet to get final slot
113// - GetActualPaletteSlotForCurrentTile16(): Get slot for current editing tile
114// - ApplyPaletteToCurrentTile16Bitmap(): Apply correct colors to preview
115//
116// INTEGRATION WITH OVERWORLD:
117// ---------------------------
118// The Tile16Editor communicates with OverworldEditor via:
119// - set_palette(): Called when overworld area changes (updates colors)
120// - on_changes_committed_: Callback invoked after CommitAllChanges()
121// - The callback triggers RefreshTile16Blockset() and RefreshOverworldMap()
122//
123// See README.md in this directory for complete documentation.
124// ============================================================================
125
135 public:
136 Tile16Editor(Rom* rom, gfx::Tilemap* tile16_blockset)
137 : rom_(rom), tile16_blockset_(tile16_blockset) {}
138 absl::Status Initialize(gfx::Bitmap& tile16_blockset_bmp,
139 gfx::Bitmap& current_gfx_bmp,
140 std::array<uint8_t, 0x200>& all_tiles_types);
141
142 absl::Status Update();
143
150 absl::Status UpdateAsPanel();
151
158 void DrawContextMenu();
159
160 void DrawTile16Editor();
161 absl::Status UpdateBlockset();
162
163 // Scratch space for tile16 layouts
164 void DrawScratchSpace();
165 absl::Status SaveLayoutToScratch(int slot);
166 absl::Status LoadLayoutFromScratch(int slot);
167
168 absl::Status DrawToCurrentTile16(ImVec2 pos,
169 const gfx::Bitmap* source_tile = nullptr);
170 absl::Status HandleTile16CanvasClick(const ImVec2& tile_position,
171 bool left_click, bool right_click);
172
173 absl::Status UpdateTile16Edit();
174
175 absl::Status LoadTile8();
176
177 absl::Status SetCurrentTile(int id);
178
179 // Request a tile switch - shows confirmation dialog if current tile has pending changes
180 void RequestTileSwitch(int target_tile_id);
181
182 // New methods for clipboard and scratch space
183 absl::Status CopyTile16ToClipboard(int tile_id);
184 absl::Status PasteTile16FromClipboard();
185 absl::Status SaveTile16ToScratchSpace(int slot);
186 absl::Status LoadTile16FromScratchSpace(int slot);
187 absl::Status ClearScratchSpace(int slot);
188
189 // Advanced editing features
190 absl::Status FlipTile16Horizontal();
191 absl::Status FlipTile16Vertical();
192 absl::Status RotateTile16();
193 absl::Status FillTile16WithTile8(int tile8_id);
194 absl::Status ClearTile16();
195
196 // Palette management
197 absl::Status CyclePalette(bool forward = true);
198 absl::Status ApplyPaletteToAll(uint8_t palette_id);
199 absl::Status ApplyPaletteToQuadrant(int quadrant, uint8_t palette_id);
200 absl::Status PreviewPaletteChange(uint8_t palette_id);
201
202 // History and undo system
203 absl::Status Undo();
204 absl::Status Redo();
205 void SaveUndoState();
206
207 // Live preview system
208 void EnableLivePreview(bool enable) { live_preview_enabled_ = enable; }
209 absl::Status UpdateLivePreview();
210
211 // Validation and integrity checks
212 absl::Status ValidateTile16Data();
213 bool IsTile16Valid(int tile_id) const;
214
215 // ===========================================================================
216 // Integration with Overworld System
217 // ===========================================================================
218 // These methods handle the connection between tile editing and ROM data.
219 // The workflow is: Edit -> Pending -> Commit -> ROM
220
222 absl::Status SaveTile16ToROM();
223
225 absl::Status UpdateOverworldTilemap();
226
228 absl::Status CommitChangesToBlockset();
229
232 absl::Status CommitChangesToOverworld();
233
235 absl::Status DiscardChanges();
236
237 // ===========================================================================
238 // Pending Changes System
239 // ===========================================================================
240 // All tile edits are staged in memory before being written to ROM.
241 // This prevents accidental modifications and allows preview before commit.
242 //
243 // Usage:
244 // 1. Edit tiles normally (changes go to pending_tile16_changes_)
245 // 2. Check has_pending_changes() to show save/discard UI
246 // 3. User clicks Save -> CommitAllChanges()
247 // 4. User clicks Discard -> DiscardAllChanges()
248 //
249 // The on_changes_committed_ callback notifies OverworldEditor to refresh.
250
252 bool has_pending_changes() const { return !pending_tile16_changes_.empty(); }
253
256 return static_cast<int>(pending_tile16_changes_.size());
257 }
258
260 bool is_tile_modified(int tile_id) const {
261 return pending_tile16_changes_.find(tile_id) !=
263 }
264
266 const gfx::Bitmap* GetPendingTileBitmap(int tile_id) const {
267 auto it = pending_tile16_bitmaps_.find(tile_id);
268 return it != pending_tile16_bitmaps_.end() ? &it->second : nullptr;
269 }
270
272 absl::Status CommitAllChanges();
273
275 void DiscardAllChanges();
276
279
282
283 // ===========================================================================
284 // Palette Coordination System
285 // ===========================================================================
286 // The overworld uses a 256-color palette organized as 16 rows of 16 colors.
287 // Different graphics sheets map to different palette regions based on how
288 // the SNES PPU organizes tile graphics.
289 //
290 // Palette Structure (256 colors = 16 rows × 16 colors):
291 // Row 0: Transparent/system colors
292 // Row 1: HUD colors (0x10-0x1F)
293 // Rows 2-6: MAIN/BG palettes for main graphics (sheets 1-2)
294 // Rows 7: ANIMATED palette (sheet 7)
295 // Rows 10+: AUX palettes for blockset graphics (sheets 0, 3-6)
296 //
297 // The palette button (0-7) selects which of the 8 available sub-palettes
298 // to use, and the sheet index determines the base offset.
299
301 absl::Status UpdateTile8Palette(int tile8_id);
302
304 absl::Status RefreshAllPalettes();
305
307 void DrawPaletteSettings();
308
312 int GetPaletteSlotForSheet(int sheet_index) const;
313
323 int GetActualPaletteSlot(int palette_button, int sheet_index) const;
324
328 int GetPaletteBaseForSheet(int sheet_index) const;
329
333 int GetSheetIndexForTile8(int tile8_id) const;
334
338
344 const gfx::SnesPalette& source, int target_row) const;
345
349 int GetEncodedPaletteRow(uint8_t pixel_value) const;
350
351 // ROM data access and modification
352 absl::Status UpdateROMTile16Data();
353 absl::Status RefreshTile16Blockset();
355 absl::Status RegenerateTile16BitmapFromROM();
356 absl::Status UpdateBlocksetBitmap();
357 absl::Status PickTile8FromTile16(const ImVec2& position);
358
359 // Manual tile8 input controls
361
362 void SetRom(Rom* rom) { rom_ = rom; }
363 Rom* rom() const { return rom_; }
366
367 // Set the palette from overworld to ensure color consistency
368 void set_palette(const gfx::SnesPalette& palette) {
369 palette_ = palette;
370
371 // Store the complete 256-color overworld palette
372 if (palette.size() >= 256) {
373 overworld_palette_ = palette;
375 "Tile16 editor received complete overworld palette with %zu colors",
376 palette.size());
377 } else {
378 util::logf("Warning: Received incomplete palette with %zu colors",
379 palette.size());
380 overworld_palette_ = palette;
381 }
382
383 // CRITICAL FIX: Load tile8 graphics now that we have the proper palette
385 auto status = LoadTile8();
386 if (!status.ok()) {
387 util::logf("Failed to load tile8 graphics with new palette: %s",
388 status.message().data());
389 } else {
391 "Successfully loaded tile8 graphics with complete overworld "
392 "palette");
393 }
394 }
395
396 util::logf("Tile16 editor palette coordination complete");
397 }
398
399 // Callback for when changes are committed to notify parent editor
400 void set_on_changes_committed(std::function<absl::Status()> callback) {
401 on_changes_committed_ = callback;
402 }
403
406 void set_on_current_tile_changed(std::function<void(int)> callback) {
407 on_current_tile_changed_ = std::move(callback);
408 }
409
410 // Accessors for testing and external use
411 int current_palette() const { return current_palette_; }
412 void set_current_palette(int palette) {
413 current_palette_ = static_cast<uint8_t>(std::clamp(palette, 0, 7));
414 }
415 int current_tile16() const { return current_tile16_; }
416 int current_tile8() const { return current_tile8_; }
417 int active_quadrant() const { return active_quadrant_; }
418 void set_active_quadrant(int quadrant) {
419 active_quadrant_ = std::clamp(quadrant, 0, 3);
420 }
423
424 // Diagnostic function to analyze tile8 source data format
425 void AnalyzeTile8SourceData() const;
426
427 private:
428 Rom* rom_ = nullptr;
431 bool x_flip = false;
432 bool y_flip = false;
433 bool priority_tile = false;
434
438 uint8_t current_palette_ = 0;
441
442 // Clipboard for Tile16 graphics and metadata
444
445 // Scratch space for Tile16 graphics and metadata (4 slots)
446 std::array<Tile16ScratchData, 4> scratch_space_;
447
448 // Layout scratch space for tile16 arrangements (4 slots of 8x8 grids)
450 std::array<std::array<int, 8>, 8> tile_layout; // 8x8 grid of tile16 IDs
451 bool in_use = false;
452 std::string name = "Empty";
453 };
454 std::array<LayoutScratch, 4> layout_scratch_;
455
456 // Undo/Redo system (unified UndoManager framework)
458 std::optional<Tile16Snapshot> pending_undo_before_;
459
462 void FinalizePendingUndo();
463
465 void RestoreFromSnapshot(const Tile16Snapshot& snapshot);
466
467 // Live preview system
470 bool preview_dirty_ = false;
472 tile8_preview_bmp_; // Persistent preview to keep arena commands valid
473
474 // Selection system
475 std::vector<int> selected_tiles_;
477 bool multi_select_mode_ = false;
478
479 // Advanced editing state
480 bool auto_tile_mode_ = false;
482 bool show_tile_info_ = true;
484 int tile8_stamp_size_ = 1; // ZScream parity: 1x, 2x, 4x tile8 stamping.
486
489
490 // Palette management settings
492 int current_palette_group_ = 0; // 0=overworld_main, 1=aux1, 2=aux2, etc.
494 0xFF; // Default 8-bit mask (preserve full palette index)
496 false; // Disabled by default to preserve palette offsets
497
498 // Performance tracking
499 std::chrono::steady_clock::time_point last_edit_time_;
500 bool batch_mode_ = false;
501
502 // Pending changes system for batch preview/commit workflow
503 std::map<int, gfx::Tile16> pending_tile16_changes_;
504 std::map<int, gfx::Bitmap> pending_tile16_bitmaps_;
506 int pending_tile_switch_target_ = -1; // Target tile for pending switch
509 std::chrono::steady_clock::time_point last_rom_write_time_{};
510
511 // Navigation controls for expanded tile support
512 int jump_to_tile_id_ = 0; // Input field for jump to tile ID
513 bool scroll_to_current_ = false; // Flag to scroll to current tile
514 int current_page_ = 0; // Current page (64 tiles per page)
515 static constexpr int kTilesPerPage = 64; // 8x8 tiles per page
516 static constexpr int kTilesPerRow = 8; // Tiles per row in grid
517
520
521 std::array<uint8_t, 0x200> all_tiles_types_;
522
523 // Tile16 blockset for selecting the tile to edit
531
532 // Canvas for editing the selected tile - optimized for 2x2 grid of 8x8 tiles
533 // (16x16 total)
535 "Tile16EditCanvas",
536 ImVec2(64, 64), // Fixed 64x64 display size (16x16 pixels at 4x scale)
537 gui::CanvasGridSize::k8x8, 8.0F}; // 8x8 grid with 4x scale for clarity
539
540 // Tile8 canvas to get the tile to drawing in the tile16_edit_canvas_
546
547 gui::Table tile_edit_table_{"##TileEditTable", 3, ImGuiTableFlags_Borders,
548 ImVec2(0, 0)};
549
551 std::vector<zelda3::Tile8PixelData> current_gfx_individual_;
552
555 gfx::SnesPalette overworld_palette_; // Complete 256-color overworld palette
556
557 absl::Status status_;
558
559 // Callback to notify parent editor when changes are committed
560 std::function<absl::Status()> on_changes_committed_;
561 std::function<void(int)> on_current_tile_changed_;
562
563 // Instance variable to store current tile16 data for proper persistence
565
566 // Apply the active palette (overworld area if available) to the current
567 // tile16 bitmap using sheet-aware offsets.
569
570 // Resolve the best available 256-color palette source for tile previews.
572
573 // Detect whether bitmap pixels already encode non-zero palette rows.
574 bool BitmapHasEncodedPaletteRows(const gfx::Bitmap& bitmap) const;
575
576 // Build a 16x16 bitmap for a tile from TileInfo metadata using the shared
577 // palette/index transform path.
578 absl::Status BuildTile16BitmapFromData(const gfx::Tile16& tile_data,
579 gfx::Bitmap* output_bitmap) const;
580
581 // Copy a 16x16 tile bitmap into the blockset preview and atlas at tile_id.
582 void CopyTileBitmapToBlockset(int tile_id, const gfx::Bitmap& tile_bitmap);
583
584 // Rebuild and render reverse-usage highlight overlays (ZScream parity).
585 absl::Status RebuildTile8UsageCache();
587
588 // Handle keyboard shortcuts (shared between Update and UpdateAsPanel)
590
591 bool HasCurrentGfxBitmap() const {
592 return current_gfx_bmp_ != nullptr && current_gfx_bmp_->is_active();
593 }
594
597 }
598
599 // Copy current tile16 bitmap pixels into the blockset atlas at the given
600 // tile position. Consolidates the repeated 16x16 copy loops.
601 void CopyTile16ToAtlas(int tile_id);
602
603 // Draw the top header row and mode toggle buttons for the editor.
604 void DrawEditorHeader(bool show_debug_info);
605 void DrawEditorHeaderToggles(bool* show_debug_info,
606 bool* show_advanced_controls);
607
608 // Draw the sticky staged-state strip (pending/commit/discard controls).
609 void DrawStagedStateBar(bool has_pending, bool current_tile_pending,
610 int pending_count);
611
612 // Draw brush palette controls and tile palette metadata controls.
613 absl::Status DrawBrushAndTilePaletteControls(bool show_debug_info);
614
615 // Draw the Tile8 source column and handle source selection interaction.
616 absl::Status DrawTile8SourcePanel();
617 absl::Status HandleTile8SourceSelection(bool right_clicked);
618
619 // Draw primary local edit controls in the right action column.
620 absl::Status DrawPrimaryActionControls();
621
622 // Draw sticky action rail pinned to the bottom of the editor.
623 absl::Status DrawBottomActionRail(bool has_pending, bool current_tile_pending,
624 int pending_count);
625};
626
627} // namespace editor
628} // namespace yaze
629
630#endif // YAZE_APP_EDITOR_TILE16EDITOR_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Allows the user to view and edit in game palettes.
Popup window to edit Tile16 data.
absl::Status DrawTile8SourcePanel()
absl::Status SaveTile16ToScratchSpace(int slot)
const gfx::SnesPalette * ResolveDisplayPalette() const
Tile16Editor(Rom *rom, gfx::Tilemap *tile16_blockset)
std::map< int, gfx::Tile16 > pending_tile16_changes_
absl::Status LoadLayoutFromScratch(int slot)
zelda3::GameData * game_data() const
void FinalizePendingUndo()
Finalize any pending undo snapshot by capturing current state as "after" and pushing a Tile16EditActi...
std::chrono::steady_clock::time_point last_edit_time_
util::NotifyValue< uint32_t > notify_tile16
void DrawContextMenu()
Draw context menu with editor actions.
absl::Status CyclePalette(bool forward=true)
absl::Status HandleTile16CanvasClick(const ImVec2 &tile_position, bool left_click, bool right_click)
std::chrono::steady_clock::time_point last_rom_write_time_
absl::Status FillTile16WithTile8(int tile8_id)
gfx::Tilemap * tile16_blockset_
bool BitmapHasEncodedPaletteRows(const gfx::Bitmap &bitmap) const
absl::Status CommitAllChanges()
Write all pending changes to ROM and notify parent.
std::map< int, gfx::Bitmap > pending_tile16_bitmaps_
std::array< Tile16ScratchData, 4 > scratch_space_
absl::Status SaveTile16ToROM()
Write current tile16 data directly to ROM (bypasses pending system)
void RestoreFromSnapshot(const Tile16Snapshot &snapshot)
Restore editor state from a Tile16Snapshot (used by undo actions).
absl::Status ApplyPaletteToAll(uint8_t palette_id)
void DiscardAllChanges()
Discard all pending changes (revert to ROM state)
int GetActualPaletteSlotForCurrentTile16() const
Get the palette slot for the current tile being edited.
void set_current_palette(int palette)
std::array< uint8_t, 0x200 > all_tiles_types_
absl::Status RegenerateTile16BitmapFromROM()
std::function< void(int)> on_current_tile_changed_
void set_active_quadrant(int quadrant)
absl::Status DiscardChanges()
Discard current tile's changes (single tile)
absl::Status PasteTile16FromClipboard()
gui::TileSelectorWidget blockset_selector_
int pending_changes_count() const
Get count of tiles with pending changes.
absl::Status SaveLayoutToScratch(int slot)
absl::Status LoadTile16FromScratchSpace(int slot)
int GetPaletteSlotForSheet(int sheet_index) const
Get base palette slot for a graphics sheet.
gfx::SnesPalette CreateRemappedPaletteForViewing(const gfx::SnesPalette &source, int target_row) const
Create a remapped palette for viewing with user-selected palette.
int GetActualPaletteSlot(int palette_button, int sheet_index) const
Calculate actual palette slot from button + sheet.
absl::Status FlipTile16Horizontal()
gfx::Bitmap * tile16_blockset_bmp_
void SetGameData(zelda3::GameData *game_data)
std::vector< zelda3::Tile8PixelData > current_gfx_individual_
void set_edit_mode(Tile16EditMode mode)
gfx::SnesPalette overworld_palette_
static constexpr int kTilesPerPage
absl::Status DrawBrushAndTilePaletteControls(bool show_debug_info)
int GetEncodedPaletteRow(uint8_t pixel_value) const
Get the encoded palette row for a pixel value.
static constexpr int kTilesPerRow
void EnableLivePreview(bool enable)
Tile16EditMode edit_mode() const
absl::Status SetCurrentTile(int id)
absl::Status UpdateTile8Palette(int tile8_id)
Update palette for a specific tile8.
zelda3::Tile8UsageIndex tile8_usage_cache_
absl::Status UpdateAsPanel()
Update the editor content without MenuBar (for WindowContent usage)
absl::Status RefreshTile16Blockset()
Tile16ClipboardData clipboard_tile16_
const gfx::Bitmap * GetPendingTileBitmap(int tile_id) const
Get preview bitmap for a pending tile (nullptr if not modified)
zelda3::GameData * game_data_
absl::Status RefreshAllPalettes()
Refresh all tile8 palettes after a palette change.
bool HasTile16BlocksetBitmap() const
void DrawPaletteSettings()
Draw palette settings UI.
absl::Status ApplyPaletteToQuadrant(int quadrant, uint8_t palette_id)
absl::Status UpdateOverworldTilemap()
Update the overworld tilemap to reflect tile changes.
absl::Status CommitChangesToBlockset()
Commit pending changes to the blockset atlas.
std::array< LayoutScratch, 4 > layout_scratch_
absl::Status UpdateROMTile16Data()
std::optional< Tile16Snapshot > pending_undo_before_
void DrawStagedStateBar(bool has_pending, bool current_tile_pending, int pending_count)
bool IsTile16Valid(int tile_id) const
gfx::Tile16 * GetCurrentTile16Data()
void MarkCurrentTileModified()
Mark the current tile as having pending changes.
absl::Status RebuildTile8UsageCache()
bool has_pending_changes() const
Check if any tiles have uncommitted changes.
absl::Status CommitChangesToOverworld()
Single-tile commit: ROM + blockset + parent refresh callback. Prefer CommitAllChanges() from the main...
absl::Status UpdateBlocksetBitmap()
void DiscardCurrentTileChanges()
Discard only the current tile's pending changes.
void RequestTileSwitch(int target_tile_id)
void DrawEditorHeaderToggles(bool *show_debug_info, bool *show_advanced_controls)
absl::Status DrawToCurrentTile16(ImVec2 pos, const gfx::Bitmap *source_tile=nullptr)
absl::Status HandleTile8SourceSelection(bool right_clicked)
absl::Status Initialize(gfx::Bitmap &tile16_blockset_bmp, gfx::Bitmap &current_gfx_bmp, std::array< uint8_t, 0x200 > &all_tiles_types)
void CopyTileBitmapToBlockset(int tile_id, const gfx::Bitmap &tile_bitmap)
absl::Status PreviewPaletteChange(uint8_t palette_id)
absl::Status CopyTile16ToClipboard(int tile_id)
absl::Status DrawPrimaryActionControls()
absl::Status ClearScratchSpace(int slot)
bool is_tile_modified(int tile_id) const
Check if a specific tile has pending changes.
std::function< absl::Status()> on_changes_committed_
absl::Status BuildTile16BitmapFromData(const gfx::Tile16 &tile_data, gfx::Bitmap *output_bitmap) const
void DrawEditorHeader(bool show_debug_info)
int GetPaletteBaseForSheet(int sheet_index) const
Get palette base row for a graphics sheet.
int GetSheetIndexForTile8(int tile8_id) const
Determine which graphics sheet contains a tile8.
absl::Status DrawBottomActionRail(bool has_pending, bool current_tile_pending, int pending_count)
absl::Status PickTile8FromTile16(const ImVec2 &position)
std::vector< int > selected_tiles_
void CopyTile16ToAtlas(int tile_id)
void set_palette(const gfx::SnesPalette &palette)
util::NotifyValue< uint8_t > notify_palette
void set_on_current_tile_changed(std::function< void(int)> callback)
void set_on_changes_committed(std::function< absl::Status()> callback)
Manages undo/redo stacks for a single editor.
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:67
bool is_active() const
Definition bitmap.h:384
Shared graphical context across editors.
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Tile composition of four 8x8 tiles.
Definition snes_tile.h:142
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:150
Reusable tile selector built on top of Canvas.
A class to manage a value that can be modified and notify when it changes.
Definition notify.h:13
constexpr int kTile16PixelCount
constexpr int kTile8PixelCount
constexpr int kTile16CanvasSize
constexpr int kTile8Size
constexpr int kTilesheetEditorHeight
constexpr int kTile16Size
constexpr int kNumScratchSlots
constexpr int kTile8CanvasHeight
constexpr int kNumPalettes
constexpr int kTilesheetEditorWidth
constexpr int kTilesheetHeight
Definition snes_tile.h:17
constexpr int kTilesheetWidth
Definition snes_tile.h:16
void logf(const absl::FormatSpec< Args... > &format, Args &&... args)
Definition log.h:115
std::array< std::vector< Tile8UsageHit >, kMaxTile8UsageId > Tile8UsageIndex
std::array< std::array< int, 8 >, 8 > tile_layout
Snapshot of a Tile16's editable state for undo/redo.
Tilemap structure for SNES tile-based graphics management.
Definition tilemap.h:118