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};
38
41 int room_id = 0;
42 std::vector<ProposalTile> tiles; // rect: 2 corners; path: >=2; point: 1
43 std::string label; // short text drawn on the canvas
44 std::string detail; // hover text
45};
46
48 std::string id;
49 std::string label;
50 uint32_t color_rgba = 0xFFFFFFFF; // 0xRRGGBBAA
51 bool visible = true;
52 std::vector<ProposalShape> shapes;
53};
54
56 int room_id = 0;
57 std::string label;
58};
59
61 std::string title;
62 std::string status;
63 std::vector<std::string> notes;
64 std::vector<ProposalRoom> rooms; // display order, left to right
65 std::vector<ProposalLayer> layers;
66};
67
68// Parses and validates overlay JSON. Rejects unknown formats/versions,
69// out-of-range rooms or tiles, shapes on rooms not listed in "rooms", and
70// malformed colors. `max_room_id` is inclusive.
71absl::StatusOr<DungeonProposalOverlay> ParseDungeonProposalOverlay(
72 std::string_view json_text, int max_room_id = kProposalDefaultMaxRoomId);
73
74// "#RRGGBB" or "#RRGGBBAA" -> 0xRRGGBBAA (alpha defaults to 0xFF).
75absl::StatusOr<uint32_t> ParseProposalColor(std::string_view text);
76
77// --- Geometry (room-local pixels, unscaled) --------------------------------
78
80 float x0 = 0, y0 = 0, x1 = 0, y1 = 0; // half-open [x0, x1) x [y0, y1)
81 bool operator==(const ProposalPixelRect&) const = default;
82};
83
84// Inclusive tile rectangle -> pixel rectangle covering every tile.
86
87// Center of a tile, in room-local pixels.
88void ProposalTileCenter(ProposalTile tile, float* x, float* y);
89
90// Left edge of room `index` when rooms are laid out left to right.
91float ProposalRoomOriginX(int index, float gap_pixels);
92
93// Distance from point (px, py) to segment (ax, ay)-(bx, by).
94float ProposalDistanceToSegment(float px, float py, float ax, float ay,
95 float bx, float by);
96
97// True when room-local pixel (px, py) is on `shape`, with `tolerance` pixels
98// of slack for paths and points.
99bool ProposalShapeHitTest(const ProposalShape& shape, float px, float py,
100 float tolerance);
101
102} // namespace yaze::editor
103
104#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 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
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
bool operator==(const ProposalTile &) const =default