25 api->SetTileQueryCallback(
35 if (x < 0 || y < 0 || x >= 512 || y >= 512) {
48 if (!tile_data.empty()) {
50 ImVec2(
static_cast<float>(x * 16),
static_cast<float>(y * 16)),
64 if (x < 0 || y < 0 || x >= 512 || y >= 512) {
83 "HandleEntityInsertion: queued type='%s' at pos=(%.0f,%.0f)",
93 LOG_ERROR(
"OverworldEditor",
"Cannot insert entity: overworld not loaded");
103 "ProcessPendingEntityInsertion: type='%s' at pos=(%.0f,%.0f) map=%d",
104 entity_type.c_str(), mouse_pos.x, mouse_pos.y,
current_map_);
106 if (entity_type ==
"entrance") {
109 auto* entrance = result.value();
116 LOG_DEBUG(
"OverworldEditor",
"Entrance inserted successfully at map=%d",
120 "Cannot insert entrance: " + std::string(result.status().message());
121 ImGui::OpenPopup(
"Entity Insert Error");
122 LOG_ERROR(
"OverworldEditor",
"Failed to insert entrance: %s",
123 result.status().message().data());
126 }
else if (entity_type ==
"hole") {
129 auto* entrance = result.value();
136 LOG_DEBUG(
"OverworldEditor",
"Hole inserted successfully at map=%d",
140 "Cannot insert hole: " + std::string(result.status().message());
141 ImGui::OpenPopup(
"Entity Insert Error");
142 LOG_ERROR(
"OverworldEditor",
"Failed to insert hole: %s",
143 result.status().message().data());
146 }
else if (entity_type ==
"exit") {
149 auto* exit = result.value();
156 LOG_DEBUG(
"OverworldEditor",
"Exit inserted successfully at map=%d",
160 "Cannot insert exit: " + std::string(result.status().message());
161 ImGui::OpenPopup(
"Entity Insert Error");
162 LOG_ERROR(
"OverworldEditor",
"Failed to insert exit: %s",
163 result.status().message().data());
166 }
else if (entity_type ==
"item") {
169 auto* item = result.value();
175 LOG_DEBUG(
"OverworldEditor",
"Item inserted successfully at map=%d",
179 "Cannot insert item: " + std::string(result.status().message());
180 ImGui::OpenPopup(
"Entity Insert Error");
181 LOG_ERROR(
"OverworldEditor",
"Failed to insert item: %s",
182 result.status().message().data());
185 }
else if (entity_type ==
"sprite") {
189 auto* sprite = result.value();
196 LOG_DEBUG(
"OverworldEditor",
"Sprite inserted successfully at map=%d",
200 "Cannot insert sprite: " + std::string(result.status().message());
201 ImGui::OpenPopup(
"Entity Insert Error");
202 LOG_ERROR(
"OverworldEditor",
"Failed to insert sprite: %s",
203 result.status().message().data());
207 LOG_WARN(
"OverworldEditor",
"Unknown entity type: %s", entity_type.c_str());
217 "Cannot edit tile16: overworld or blockset not loaded");
void set_dirty(bool dirty)
EditorDependencies dependencies_
bool map_blockset_loaded_
std::string insert_error_
void HandleTile16Edit()
Handle tile16 editing from context menu (MOUSE mode) Gets the tile16 under the cursor and opens the T...
zelda3::OverworldEntrance edit_entrance_
gfx::Tilemap tile16_blockset_
void ProcessPendingEntityInsertion()
Process any pending entity insertion request Called from Update() - needed because ImGui::OpenPopup()...
gui::Canvas ow_map_canvas_
void HandleEntityInsertion(const std::string &entity_type)
Handle entity insertion from context menu.
ImVec2 pending_insert_pos_
void SetupCanvasAutomation()
bool AutomationSetTile(int x, int y, int tile_id)
zelda3::Sprite edit_sprite_
std::string pending_insert_type_
std::unique_ptr< TilePaintingManager > tile_painting_
zelda3::Overworld overworld_
zelda3::GameEntity * current_entity_
zelda3::OverworldExit edit_exit_
int AutomationGetTile(int x, int y)
bool SelectItemByIdentity(const zelda3::OverworldItem &item_identity)
Select an overworld item using value identity matching.
bool OpenWindow(size_t session_id, const std::string &base_window_id)
void SetTilePaintCallback(TilePaintCallback callback)
CanvasAutomationAPI * GetAutomationAPI()
auto hover_mouse_pos() const
void set_current_world(int world)
void set_current_map(int i)
uint16_t GetTile(int x, int y) const
void SetTile(int x, int y, uint16_t tile_id)
#define LOG_DEBUG(category, format,...)
#define LOG_ERROR(category, format,...)
#define LOG_WARN(category, format,...)
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.
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.
std::vector< uint8_t > GetTilemapData(Tilemap &tilemap, int tile_id)
constexpr const char * kOverworld
std::string MakePopupId(size_t session_id, const std::string &editor_name, const std::string &popup_name)
Generate session-aware popup IDs to prevent conflicts in multi-editor layouts.
WorkspaceWindowManager * window_manager
static constexpr const char * kTile16Editor