yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
entity_operations.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_OVERWORLD_ENTITY_OPERATIONS_H
2#define YAZE_APP_EDITOR_OVERWORLD_ENTITY_OPERATIONS_H
3
4#include "absl/status/statusor.h"
5#include "imgui/imgui.h"
11
12namespace yaze {
13namespace editor {
14
43absl::StatusOr<zelda3::OverworldEntrance*> InsertEntrance(
44 zelda3::Overworld* overworld, ImVec2 mouse_pos, int current_map,
45 bool is_hole = false);
46
61absl::StatusOr<zelda3::OverworldExit*> InsertExit(zelda3::Overworld* overworld,
62 ImVec2 mouse_pos,
63 int current_map);
64
80absl::StatusOr<zelda3::Sprite*> InsertSprite(zelda3::Overworld* overworld,
81 ImVec2 mouse_pos, int current_map,
82 int game_state,
83 uint8_t sprite_id = 0);
84
99absl::StatusOr<zelda3::OverworldItem*> InsertItem(zelda3::Overworld* overworld,
100 ImVec2 mouse_pos,
101 int current_map,
102 uint8_t item_id = 0);
103
110inline uint8_t GetParentMapId(const zelda3::OverworldMap* map,
111 int current_map) {
112 uint8_t parent = map->parent();
113 return (parent == 0xFF) ? static_cast<uint8_t>(current_map) : parent;
114}
115
119inline ImVec2 SnapToEntityGrid(ImVec2 pos) {
120 return ImVec2(static_cast<float>(static_cast<int>(pos.x / 16) * 16),
121 static_cast<float>(static_cast<int>(pos.y / 16) * 16));
122}
123
127inline ImVec2 ClampToOverworldBounds(ImVec2 pos) {
128 return ImVec2(std::clamp(pos.x, 0.0f, 4080.0f), // 4096 - 16
129 std::clamp(pos.y, 0.0f, 4080.0f));
130}
131
132} // namespace editor
133} // namespace yaze
134
135#endif // YAZE_APP_EDITOR_OVERWORLD_ENTITY_OPERATIONS_H
Represents a single Overworld map screen.
absl::StatusOr< zelda3::OverworldItem * > InsertItem(zelda3::Overworld *overworld, ImVec2 mouse_pos, int current_map, uint8_t item_id)
Insert a new item at the specified position.
absl::StatusOr< zelda3::OverworldEntrance * > InsertEntrance(zelda3::Overworld *overworld, ImVec2 mouse_pos, int current_map, bool is_hole)
Flat helper functions for entity insertion/manipulation.
absl::StatusOr< zelda3::OverworldExit * > InsertExit(zelda3::Overworld *overworld, ImVec2 mouse_pos, int current_map)
Insert a new exit at the specified position.
ImVec2 SnapToEntityGrid(ImVec2 pos)
Snap position to 16x16 grid (standard entity positioning)
absl::StatusOr< zelda3::Sprite * > InsertSprite(zelda3::Overworld *overworld, ImVec2 mouse_pos, int current_map, int game_state, uint8_t sprite_id)
Insert a new sprite at the specified position.
ImVec2 ClampToOverworldBounds(ImVec2 pos)
Clamp position to valid overworld bounds.
uint8_t GetParentMapId(const zelda3::OverworldMap *map, int current_map)
Helper to get parent map ID for multi-area maps.