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"
10#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(
62 zelda3::Overworld* overworld, ImVec2 mouse_pos, int current_map);
63
79absl::StatusOr<zelda3::Sprite*> InsertSprite(
80 zelda3::Overworld* overworld, ImVec2 mouse_pos, int current_map,
81 int game_state, uint8_t sprite_id = 0);
82
97absl::StatusOr<zelda3::OverworldItem*> InsertItem(
98 zelda3::Overworld* overworld, ImVec2 mouse_pos, int current_map,
99 uint8_t item_id = 0);
100
107inline uint8_t GetParentMapId(const zelda3::OverworldMap* map, int current_map) {
108 uint8_t parent = map->parent();
109 return (parent == 0xFF) ? static_cast<uint8_t>(current_map) : parent;
110}
111
115inline ImVec2 SnapToEntityGrid(ImVec2 pos) {
116 return ImVec2(
117 static_cast<float>(static_cast<int>(pos.x / 16) * 16),
118 static_cast<float>(static_cast<int>(pos.y / 16) * 16)
119 );
120}
121
125inline ImVec2 ClampToOverworldBounds(ImVec2 pos) {
126 return ImVec2(
127 std::clamp(pos.x, 0.0f, 4080.0f), // 4096 - 16
128 std::clamp(pos.y, 0.0f, 4080.0f)
129 );
130}
131
132} // namespace editor
133} // namespace yaze
134
135#endif // YAZE_APP_EDITOR_OVERWORLD_ENTITY_OPERATIONS_H
136
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.
Main namespace for the application.
Definition controller.cc:20