yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_proposal_overlay.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_DUNGEON_PROPOSAL_OVERLAY_H_
2#define YAZE_APP_EDITOR_DUNGEON_DUNGEON_PROPOSAL_OVERLAY_H_
3
4#include <cstdint>
5#include <string>
6#include <string_view>
7#include <vector>
8
9#include "absl/status/statusor.h"
10
11namespace yaze::editor {
12
13// A read-only "proposal overlay": annotations drawn over real room renders so
14// a layout change can be reviewed before anyone edits the ROM. Nothing here
15// touches room data. Format: docs/internal/plans/dungeon-proposal-preview.md
16//
17// Coordinates are local 8-pixel room tiles (0-63). Rectangles are inclusive.
18
19inline constexpr int kProposalOverlayVersion = 1;
20inline constexpr std::string_view kProposalOverlayFormat =
21 "yaze-dungeon-proposal-overlay";
22inline constexpr int kProposalRoomTiles = 64;
23inline constexpr int kProposalTilePixels = 8;
24inline constexpr int kProposalDefaultMaxRoomId = 0x127; // 296 rooms
25
27 int x = 0;
28 int y = 0;
29 bool operator==(const ProposalTile&) const = default;
30};
31
33 kRect, // filled area: tiles = [x0, y0, x1, y1], inclusive
34 kPath, // polyline through tile centers: tiles = [[x, y], ...]
35 kMarker, // labeled point: tile = [x, y]
36 kRemove, // "removed here" cross: tile = [x, y]
37 kActor, // abstract 16px actor at tile origin + pixel offset, with facing
38 kObject, // suggested object footprint; annotation only, never a ROM edit
39};
40
42
45 int room_id = 0;
46 std::vector<ProposalTile> tiles; // rect: 2 corners; path: >=2; point: 1
47 std::string label; // short text drawn on the canvas
48 std::string detail; // hover text
49 ProposalTile pixel_offset; // actor only: 0..7 pixels within tile
51 int object_id = 0;
52 int object_size = 0;
53 int object_list = 0; // serialized object list, not a BG number
54 ProposalTile footprint; // object width/height in 8px tiles
55};
56
58 std::string id;
59 std::string label;
60 uint32_t color_rgba = 0xFFFFFFFF; // 0xRRGGBBAA
61 bool visible = true;
62 std::vector<ProposalShape> shapes;
63};
64
66 int room_id = 0;
67 std::string label;
68};
69
71 std::string id;
72 std::string label;
73 std::string detail;
74 std::vector<std::string> layer_ids;
75};
76
78 std::string title;
79 std::string status;
80 std::vector<std::string> notes;
81 std::vector<ProposalRoom> rooms; // display order, left to right
82 std::vector<ProposalLayer> layers;
83 std::vector<ProposalStep> steps; // optional ordered cutscene/route preview
84};
85
86// Parses and validates overlay JSON. Rejects unknown formats/versions,
87// out-of-range rooms or tiles, shapes on rooms not listed in "rooms", and
88// malformed colors. `max_room_id` is inclusive.
89absl::StatusOr<DungeonProposalOverlay> ParseDungeonProposalOverlay(
90 std::string_view json_text, int max_room_id = kProposalDefaultMaxRoomId);
91
92// "#RRGGBB" or "#RRGGBBAA" -> 0xRRGGBBAA (alpha defaults to 0xFF).
93absl::StatusOr<uint32_t> ParseProposalColor(std::string_view text);
94
95// --- Geometry (room-local pixels, unscaled) --------------------------------
96
98 float x0 = 0, y0 = 0, x1 = 0, y1 = 0; // half-open [x0, x1) x [y0, y1)
99 bool operator==(const ProposalPixelRect&) const = default;
100};
101
102// Inclusive tile rectangle -> pixel rectangle covering every tile.
104
105// Center of a tile, in room-local pixels.
106void ProposalTileCenter(ProposalTile tile, float* x, float* y);
107
108// Actor/object anchors are tile origins, unlike path/marker tile centers.
109// The actor's 16px outline is an authoring marker, not its collision box.
111
112// Negative step selects all layers; a selected step shows its referenced
113// layers. The caller must also honor each layer's visibility checkbox.
115 std::string_view layer_id, int step);
116
117// Left edge of room `index` when rooms are laid out left to right.
118float ProposalRoomOriginX(int index, float gap_pixels);
119
120// Distance from point (px, py) to segment (ax, ay)-(bx, by).
121float ProposalDistanceToSegment(float px, float py, float ax, float ay,
122 float bx, float by);
123
124// True when room-local pixel (px, py) is on `shape`, with `tolerance` pixels
125// of slack for paths and points.
126bool ProposalShapeHitTest(const ProposalShape& shape, float px, float py,
127 float tolerance);
128
129} // namespace yaze::editor
130
131#endif // YAZE_APP_EDITOR_DUNGEON_DUNGEON_PROPOSAL_OVERLAY_H_
Editors are the view controllers for the application.
float ProposalRoomOriginX(int index, float gap_pixels)
absl::StatusOr< DungeonProposalOverlay > ParseDungeonProposalOverlay(std::string_view json_text, int max_room_id)
ProposalPixelRect ProposalFootprintToPixels(const ProposalShape &shape)
ProposalPixelRect ProposalTileRectToPixels(ProposalTile a, ProposalTile b)
constexpr int kProposalDefaultMaxRoomId
constexpr int kProposalOverlayVersion
absl::StatusOr< uint32_t > ParseProposalColor(std::string_view text)
void ProposalTileCenter(ProposalTile tile, float *x, float *y)
constexpr std::string_view kProposalOverlayFormat
constexpr int kProposalRoomTiles
constexpr int kProposalTilePixels
bool ProposalLayerInStep(const DungeonProposalOverlay &overlay, std::string_view layer_id, int step)
float ProposalDistanceToSegment(float px, float py, float ax, float ay, float bx, float by)
bool ProposalShapeHitTest(const ProposalShape &shape, float px, float py, float tolerance)
std::vector< ProposalShape > shapes
bool operator==(const ProposalPixelRect &) const =default
std::vector< ProposalTile > tiles
std::vector< std::string > layer_ids
bool operator==(const ProposalTile &) const =default