8#include "imgui/imgui.h"
34 return "Dungeon Sprite";
48 auto* editor = ctx.editor;
50 auto* active_entity = editor->current_entity();
51 if (active_entity ==
nullptr) {
52 ImGui::TextDisabled(
"No entity selected");
56 ImGui::Text(
"Type: %s", GetEntityTypeLabel(active_entity->entity_type_));
67 ctx.editor->SetCurrentEntity(entity);
76 auto* editor = ctx.editor;
77 editor->SetCurrentEntity(entity);
88 editor->edit_entrance() =
113 if (!ctx || !entity) {
116 ctx.editor->SetCurrentEntity(entity);
125 auto* editor = ctx.editor;
133 if (ImGui::BeginPopupModal(
"Entity Insert Error",
nullptr,
134 ImGuiWindowFlags_AlwaysAutoResize)) {
135 ImGui::TextWrapped(
"%s", editor->insert_error().c_str());
137 if (ImGui::Button(
"OK", ImVec2(120.0f, 0.0f))) {
138 editor->insert_error().clear();
139 ImGui::CloseCurrentPopup();
145 if (editing_entity &&
149 editor->NotifyEntityModified(editing_entity);
153 if (editing_entity && editing_entity->entity_type_ ==
156 editor->edit_entrance();
157 editor->NotifyEntityModified(editing_entity);
161 if (editing_entity &&
163 if (editor->edit_item().deleted) {
164 (void)editor->DeleteSelectedItem();
168 editor->NotifyEntityModified(editing_entity);
173 if (editing_entity && editing_entity->entity_type_ ==
175 *
static_cast<zelda3::Sprite*
>(editing_entity) = editor->edit_sprite();
176 editor->NotifyEntityModified(editing_entity);
180 const bool exit_popup_open = ImGui::IsPopupOpen(
182 const bool entrance_popup_open = ImGui::IsPopupOpen(
185 const bool item_popup_open = ImGui::IsPopupOpen(
187 const bool sprite_popup_open = ImGui::IsPopupOpen(
189 if (!exit_popup_open && !entrance_popup_open && !item_popup_open &&
190 !sprite_popup_open) {
200 ctx.editor->pending_insert_type() = type;
201 ctx.editor->pending_insert_pos() = pos;
207 if (!ctx || !mutation_service)
210 auto* editor = ctx.editor;
211 if (editor->pending_insert_type().empty())
214 auto res = mutation_service->
InsertEntity(editor->pending_insert_type(),
215 editor->pending_insert_pos(),
216 current_map, game_state);
220 editor->NotifyEntityModified(res.entity);
222 editor->insert_error() = res.error_message;
223 ImGui::OpenPopup(
"Entity Insert Error");
226 editor->pending_insert_type().clear();
234 auto* editor = ctx.editor;
235 auto* active_entity = editor->current_entity();
239 if (ImGui::Selectable(
ICON_MD_EDIT " Edit Properties")) {
241 ImGui::CloseCurrentPopup();
247 editor->RequestJumpToRoom(exit->room_id_);
248 ImGui::CloseCurrentPopup();
250 }
else if (active_entity->entity_type_ ==
253 if (ImGui::Selectable(
ICON_MD_LINK " Jump to Entrance")) {
254 editor->RequestJumpToEntrance(entrance->entrance_id_);
255 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.