yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
catalog_tile_transfer.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GRAPHICS_CATALOG_TILE_TRANSFER_H_
2#define YAZE_APP_EDITOR_GRAPHICS_CATALOG_TILE_TRANSFER_H_
3
4#include <cstdint>
5#include <optional>
6#include <string>
7#include <vector>
8
9#include "absl/status/status.h"
10#include "absl/status/statusor.h"
11
12namespace yaze::zelda3 {
13struct GameData;
14}
15
16namespace yaze::editor {
17
18class GraphicsEditorState;
19class UndoManager;
20
22 int x = 0, y = 0, page = 0, page_tile = 0;
23 bool h = false, v = false;
24
25 bool operator==(const CatalogAssemblyCell&) const = default;
26};
27
35
37
39 // Keep these first four fields compatible with existing sheet consumers.
40 std::string id, title, source_path;
41 std::vector<uint8_t> indexed_pixels;
44 int bpp = 3, page = 0, page_count = 1;
45 // Logical asset dimensions; the editable source page remains 128x32.
46 int pixel_width = 128, pixel_height = 32;
47 std::vector<uint16_t> palette;
48 std::vector<CatalogAssemblyCell> assembly;
49 // A catalog describes detached art, never a native resource allocation.
50 bool resources_bound = false;
52 // Optional research provenance. Non-string values are ignored.
55 bool color_reduction = false;
56 // Planar page bytes, decoded at bpp and checked against the indexed page.
58};
59
60// Reads schema_version 1 references. Paths resolve relative to the catalog.
61// Sheet bytes and their local source ROM must match their recorded hashes.
62// Existing raw_path references retain their trusted, hash-checked source paths.
63// New source_kind "indexed-png" references require checked 128x32 pages inside
64// the catalog directory (or its explicit asset_root). Each page becomes one
65// source; asset_id and page identify its logical multi-page assembly. A page
66// binary_path must be 64 SNES planar tiles at the reference bpp that decode to
67// the page's indices. resources_bound must be false when present.
68// resource_kind ("overworld-tile", "dungeon-tile", "interior-tile",
69// "sprite-pose", "other-sheet") is explicit or derives from category.
70// Unrecognized fields are ignored. Entries without sheet payloads and
71// explicitly non-sheet references are skipped.
72absl::StatusOr<std::vector<CatalogSheetSource>> LoadCatalogSheetSources(
73 const std::string& filename);
74
76 std::optional<CatalogResourceKind> kind;
77 // Palette view: sources that declare their own palette.
78 bool palettes_only = false;
79 std::string group, category, search;
80};
81
82// Case-insensitive search covers names, IDs and provenance text.
84 const CatalogSourceFilter& filter);
85
86// ROM sheet writers accept 3bpp catalog pages only.
88
90 int width = 0, height = 0, bpp = 3;
91 std::vector<uint8_t> indexed_pixels;
92 std::vector<uint16_t> palette;
93};
94
95// Reconstructs the complete logical asset from page-local 8x8 cells, including
96// H/V flips. No page-local tile number is interpreted as a ROM tile ID.
97absl::StatusOr<CatalogAssetPreview> AssembleCatalogAsset(
98 const std::vector<CatalogSheetSource>& sources,
99 const std::string& asset_id);
100
102 uint16_t sheet_id;
103 std::vector<uint8_t> before_pixels, after_pixels;
104 std::vector<int> changed_tiles;
105 // UI binds owner and the store revision when retaining the preview.
108};
109
110// Copies the selected row-major 8x8 tile IDs in the supplied order into
111// contiguous destination tile IDs, or preserves their source bounding-box layout
112// when preserve_layout is true. Indices and unselected pixels survive.
113absl::StatusOr<CatalogTileTransferPlan> PreviewCatalogTileTransfer(
114 uint16_t destination_sheet, const std::vector<uint8_t>& destination_pixels,
115 const std::vector<uint8_t>& source_pixels,
116 const std::vector<int>& source_tiles, int first_destination_tile,
117 bool preserve_layout = false);
118
119// UI binds destination_owner and destination_revision when retaining a preview.
120// Apply requires that owner/revision, selected sheet, no floating selection,
121// matching before_pixels,
122// and an UndoManager.
123// Commits one GraphicsPixelEditAction; a no-op creates no history entry.
125 GraphicsEditorState& state,
126 UndoManager* undo_manager);
127
128} // namespace yaze::editor
129
130#endif // YAZE_APP_EDITOR_GRAPHICS_CATALOG_TILE_TRANSFER_H_
Shared state between GraphicsEditor panel components.
Manages undo/redo stacks for a single editor.
Editors are the view controllers for the application.
const char * CatalogResourceKindName(CatalogResourceKind kind)
absl::StatusOr< std::vector< CatalogSheetSource > > LoadCatalogSheetSources(const std::string &filename)
absl::Status ApplyCatalogTileTransfer(const CatalogTileTransferPlan &plan, GraphicsEditorState &state, UndoManager *undo_manager)
absl::StatusOr< CatalogAssetPreview > AssembleCatalogAsset(const std::vector< CatalogSheetSource > &sources, const std::string &asset_id)
absl::Status ValidateCatalogSourceForRomSheet(const CatalogSheetSource &source)
bool CatalogSourceMatches(const CatalogSheetSource &source, const CatalogSourceFilter &filter)
absl::StatusOr< CatalogTileTransferPlan > PreviewCatalogTileTransfer(uint16_t destination_sheet, const std::vector< uint8_t > &destination_pixels, const std::vector< uint8_t > &source_pixels, const std::vector< int > &source_tiles, int first_destination_tile, bool preserve_layout)
Zelda 3 specific classes and functions.
bool operator==(const CatalogAssemblyCell &) const =default
std::vector< CatalogAssemblyCell > assembly
std::optional< CatalogResourceKind > kind