Context menu for the script inspector will now work even when collapsed

This commit is contained in:
Kah Wei 2022-09-28 15:33:32 +08:00
parent 3730c2125f
commit 94a7258eb3
2 changed files with 26 additions and 9 deletions

View File

@ -142,15 +142,7 @@ namespace SHADE
SHEditorUI::Indent(); SHEditorUI::Indent();
{ {
// Right Click Menu // Right Click Menu
if (SHEditorUI::BeginPopupContextItem("scriptContextMenu")) renderScriptContextMenu(entity, script);
{
if (SHEditorUI::Selectable("Delete Script", ICON_MD_DELETE))
{
// Mark script for removal
ScriptStore::RemoveScript(entity, script);
}
SHEditorUI::EndPopup();
}
// Go through all fields and output them // Go through all fields and output them
auto fields = ReflectionUtilities::GetInstanceFields(script); auto fields = ReflectionUtilities::GetInstanceFields(script);
@ -171,6 +163,10 @@ namespace SHADE
SHEditorUI::Unindent(); SHEditorUI::Unindent();
SHEditorUI::PopID(); SHEditorUI::PopID();
} }
else
{
renderScriptContextMenu(entity, script);
}
SHEditorUI::PopID(); SHEditorUI::PopID();
} }
void Editor::renderFieldInInspector(Reflection::FieldInfo^ field, Object^ object) void Editor::renderFieldInInspector(Reflection::FieldInfo^ field, Object^ object)
@ -220,4 +216,19 @@ namespace SHADE
} }
} }
} }
void Editor::renderScriptContextMenu(Entity entity, Script^ script)
{
// Right Click Menu
if (SHEditorUI::BeginPopupContextItem("scriptContextMenu"))
{
if (SHEditorUI::Selectable("Delete Script", ICON_MD_DELETE))
{
// Mark script for removal
ScriptStore::RemoveScript(entity, script);
}
SHEditorUI::EndPopup();
}
}
} }

View File

@ -67,5 +67,11 @@ namespace SHADE
/// The object that contains the data of the field to render. /// The object that contains the data of the field to render.
/// </param> /// </param>
static void renderFieldInInspector(System::Reflection::FieldInfo^ field, Object^ object); static void renderFieldInInspector(System::Reflection::FieldInfo^ field, Object^ object);
/// <summary>
/// Renders a context menu when right clicked for the scripts
/// </summary>
/// <param name="entity">The Entity to render the Scripts of.</param>
/// <param name="script">The Script to render the inspector for.</param>
static void renderScriptContextMenu(Entity entity, Script^ script);
}; };
} }