yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
graphics_edit_context.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GRAPHICS_GRAPHICS_EDIT_CONTEXT_H_
2#define YAZE_APP_EDITOR_GRAPHICS_GRAPHICS_EDIT_CONTEXT_H_
3
4#include <array>
5#include <cstdint>
6#include <functional>
7#include <optional>
8#include <string>
9#include <vector>
10
11#include "absl/status/statusor.h"
15
16namespace yaze::zelda3 {
17class Room;
18class RoomObject;
19struct GameData;
20} // namespace yaze::zelda3
21
22namespace yaze::editor {
23
24// Addresses for raw 3bpp indices. Index zero is fixed transparency/backdrop and
25// deliberately has no writable address. Every nonzero entry must be proven.
27 const zelda3::GameData* owner = nullptr;
28 uint8_t row = 0;
29 uint8_t half_offset = 0;
30 std::array<std::optional<zelda3::PaletteColorAddress>, 8> colors{};
31};
32
33// A source editor supplies the resolved colors for raw sheet indices. The
34// Graphics editor never infers a palette from a sheet ID in this workflow.
36 uint16_t sheet_id = 0;
37 uint16_t tile_index = 0;
38 std::string label;
40 // Pattern uses of this source tile: bits 0/1/2/3 = normal/H/V/HV.
41 // Zero means the source editor did not supply orientation information.
43 std::optional<GraphicsPaletteAddressing> writable_palette;
45 "No loader-owned palette address mapping.";
46
47 std::string SourceOrientationLabel() const;
48};
49
50// Read-only validation against the owning session's current palette model.
51// No fallback RGB lookup or palette/pixel mutation is performed.
53 const zelda3::GameData* owner);
55 GraphicsEditTarget& target, const zelda3::GameData* owner,
56 const zelda3::PaletteAddressMap& addresses, int row, int half_offset);
57
58// Session-local navigation and preview state, not ROM/project data. Callbacks
59// belong to editors in the same EditorSet and are cleared on ROM replacement.
60// Each surface can supply its own live renderer without another graphics cache.
62 const zelda3::GameData* owner = nullptr;
63 std::string label;
64 std::string limitation;
66 std::vector<GraphicsEditTarget> targets;
67 size_t selected_target = 0;
68 std::function<absl::StatusOr<usage_preview::PreviewImage>()> render_preview;
69 std::function<void()> return_to_source;
71 // Re-resolve display colors through the source loader without replacing
72 // the selected raw sheet/tile or pending pixel edits.
73 std::function<absl::Status(GraphicsEditContext&)> refresh_palettes;
74 // Authoritative mutation boundary: resolve the owning live model, including
75 // assignments and tile definitions. A cached preview is insufficient.
76 // Missing callback means palette/pixel commands are unsupported.
77 std::function<absl::Status(GraphicsEditContext&)> resolve_live_source;
78 std::optional<uint64_t> palette_revision;
79 std::string palette_error;
80};
81
82// Applies fresh colors only when the source still addresses the same tiles.
83// A source assignment change requires reopening rather than silently redirecting
84// a pending stroke or paste to a different sheet.
86 GraphicsEditContext refreshed);
87
88// The room must already have its entrance context applied and be prepared for
89// rendering. Animated spans are omitted until they have explicit source maps.
90absl::StatusOr<GraphicsEditContext> MakeDungeonGraphicsEditContext(
91 const zelda3::Room& room, const zelda3::RoomObject& object,
92 const zelda3::GameData* owner);
93
94} // namespace yaze::editor
95
96#endif // YAZE_APP_EDITOR_GRAPHICS_GRAPHICS_EDIT_CONTEXT_H_
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Editors are the view controllers for the application.
absl::Status UpdateGraphicsContextPalettes(GraphicsEditContext &context, GraphicsEditContext refreshed)
void ResolveGraphicsPaletteAddressing(GraphicsEditTarget &target, const zelda3::GameData *owner, const zelda3::PaletteAddressMap &addresses, int row, int half_offset)
absl::StatusOr< GraphicsEditContext > MakeDungeonGraphicsEditContext(const zelda3::Room &room, const zelda3::RoomObject &object, const zelda3::GameData *owner)
absl::Status ValidateGraphicsPaletteAddressing(const GraphicsEditTarget &target, const zelda3::GameData *owner)
Zelda 3 specific classes and functions.
std::array< std::optional< PaletteColorAddress >, 128 > PaletteAddressMap
zelda3::ResolvedGraphicsContext resolved
std::vector< GraphicsEditTarget > targets
std::function< absl::StatusOr< usage_preview::PreviewImage >()> render_preview
std::function< absl::Status(GraphicsEditContext &) resolve_live_source)
std::optional< uint64_t > palette_revision
std::function< absl::Status(GraphicsEditContext &) refresh_palettes)
std::optional< GraphicsPaletteAddressing > writable_palette
std::array< std::optional< zelda3::PaletteColorAddress >, 8 > colors