9#include "imgui/imgui.h"
35 return "Dungeon Sprite";
49 auto* editor = ctx.editor;
51 auto* active_entity = editor->current_entity();
52 if (active_entity ==
nullptr) {
53 ImGui::TextDisabled(tr(
"No entity selected"));
57 ImGui::Text(tr(
"Type: %s"), GetEntityTypeLabel(active_entity->entity_type_));
68 ctx.editor->SetCurrentEntity(entity);
77 auto* editor = ctx.editor;
78 editor->SetCurrentEntity(entity);
89 editor->edit_entrance() =
114 if (!ctx || !entity) {
117 ctx.editor->SetCurrentEntity(entity);
126 auto* editor = ctx.editor;
134 if (ImGui::BeginPopupModal(
"Entity Insert Error",
nullptr,
135 ImGuiWindowFlags_AlwaysAutoResize)) {
136 ImGui::TextWrapped(
"%s", editor->insert_error().c_str());
138 if (ImGui::Button(tr(
"OK"), ImVec2(120.0f, 0.0f))) {
139 editor->insert_error().clear();
140 ImGui::CloseCurrentPopup();
146 if (editing_entity &&
150 editor->NotifyEntityModified(editing_entity);
154 if (editing_entity && editing_entity->entity_type_ ==
157 editor->edit_entrance();
158 editor->NotifyEntityModified(editing_entity);
162 if (editing_entity &&
164 if (editor->edit_item().deleted) {
165 (void)editor->DeleteSelectedItem();
169 editor->NotifyEntityModified(editing_entity);
174 if (editing_entity && editing_entity->entity_type_ ==
176 *
static_cast<zelda3::Sprite*
>(editing_entity) = editor->edit_sprite();
177 editor->NotifyEntityModified(editing_entity);
181 const bool exit_popup_open = ImGui::IsPopupOpen(
183 const bool entrance_popup_open = ImGui::IsPopupOpen(
186 const bool item_popup_open = ImGui::IsPopupOpen(
188 const bool sprite_popup_open = ImGui::IsPopupOpen(
190 if (!exit_popup_open && !entrance_popup_open && !item_popup_open &&
191 !sprite_popup_open) {
201 ctx.editor->pending_insert_type() = type;
202 ctx.editor->pending_insert_pos() = pos;
208 if (!ctx || !mutation_service)
211 auto* editor = ctx.editor;
212 if (editor->pending_insert_type().empty())
215 auto res = mutation_service->
InsertEntity(editor->pending_insert_type(),
216 editor->pending_insert_pos(),
217 current_map, game_state);
221 editor->NotifyEntityModified(res.entity);
223 editor->insert_error() = res.error_message;
224 ImGui::OpenPopup(
"Entity Insert Error");
227 editor->pending_insert_type().clear();
235 auto* editor = ctx.editor;
236 auto* active_entity = editor->current_entity();
240 if (ImGui::Selectable(
ICON_MD_EDIT " Edit Properties")) {
242 ImGui::CloseCurrentPopup();
248 editor->RequestJumpToRoom(exit->room_id_);
249 ImGui::CloseCurrentPopup();
251 }
else if (active_entity->entity_type_ ==
254 if (ImGui::Selectable(
ICON_MD_LINK " Jump to Entrance")) {
255 editor->RequestJumpToEntrance(entrance->entrance_id_);
256 ImGui::CloseCurrentPopup();
Editor-level service responsible for overworld entity mutations.
MutationResult InsertEntity(const std::string &type, ImVec2 pos, int map_id, int game_state)
Dispatches entity insertion based on type string.
Authoritative component for entity editing state and UI.
zelda3::GameEntity * editing_entity_
void SetPendingInsertion(const std::string &type, ImVec2 pos)
void OpenEditorFor(zelda3::GameEntity *entity)
static constexpr const char * kContextMenuPopupId
void DrawEntityContextMenu()
void Draw(bool *p_open) override
Draw the panel content.
void ProcessPendingInsertion(EntityMutationService *mutation_service, int current_map, int game_state)
void OpenContextMenuFor(zelda3::GameEntity *entity)
void SetActiveEntity(zelda3::GameEntity *entity)
Base class for all overworld and dungeon entities.
enum yaze::zelda3::GameEntity::EntityType entity_type_
Represents an overworld exit that transitions from dungeon to overworld.
A class for managing sprites in the overworld and underworld.
const char * GetEntityTypeLabel(zelda3::GameEntity::EntityType type)
bool DrawSpriteEditorPopup(zelda3::Sprite &sprite)
bool DrawOverworldEntrancePopup(zelda3::OverworldEntrance &entrance)
bool DrawItemEditorPopup(zelda3::OverworldItem &item)
OverworldWindowContext CurrentOverworldWindowContext()
bool DrawExitEditorPopup(zelda3::OverworldExit &exit)
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.
#define REGISTER_PANEL(PanelClass)
Auto-registration macro for panels with default constructors.