From 3bdc48260f84e3a7f6641e7585143964acd4ae3e Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Tue, 25 Oct 2022 16:55:50 +0800 Subject: [PATCH] Improved CallbackEvent inspector --- SHADE_Managed/src/Editor/Editor.cxx | 46 +++++++++++++++++++---------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/SHADE_Managed/src/Editor/Editor.cxx b/SHADE_Managed/src/Editor/Editor.cxx index 018a9591..1097e203 100644 --- a/SHADE_Managed/src/Editor/Editor.cxx +++ b/SHADE_Managed/src/Editor/Editor.cxx @@ -197,7 +197,7 @@ namespace SHADE void Editor::renderScriptInInspector(Entity entity, Script^ script, int index) { // Constants - const std::string LABEL = Convert::ToNative(script->GetType()->Name); + const std::string LABEL = Convert::ToNative(script->GetType()->Name); // Header SHEditorUI::PushID(index); @@ -302,6 +302,10 @@ namespace SHADE title += ">"; if (SHEditorUI::CollapsingHeader(Convert::ToNative(title))) { + // Constants + const std::string LABEL = Convert::ToNative(field->Name); + SHEditorUI::PushID(LABEL); + ICallbackEvent^ callbackEvent = safe_cast(field->GetValue(object)); if (callbackEvent == nullptr) { @@ -313,27 +317,39 @@ namespace SHADE if (action->IsRuntimeAction) continue; - if (action->TargetObject == nullptr) - SHEditorUI::Text("Target Object"); - else - SHEditorUI::Text(Convert::ToNative(action->TargetObject->GetType()->Name)); + // Attempt to get the object if any + int entityId = static_cast(-1); + if (action->TargetObject) + { + Script^ script = safe_cast(action->TargetObject); + if (script) + { + entityId = static_cast(script->Owner.GetEntity()); + } + } + SHEditorUI::InputInt("", entityId); SHEditorUI::SameLine(); - - if (action->TargetMethodName == nullptr) - SHEditorUI::Text("Target Method Name"); - else - SHEditorUI::Text(Convert::ToNative(action->TargetMethodName)); + System::String^ methodName = ""; + if (action->TargetMethodName != nullptr) + { + methodName = action->TargetMethodName; + } + std::string methodNameNative = Convert::ToNative(methodName); + SHEditorUI::InputTextField("", methodNameNative); + SHEditorUI::SameLine(); + if (SHEditorUI::Button("-")) + { + callbackEvent->DeregisterAction(action); + break; + } } if (SHEditorUI::Button("Add Action")) { callbackEvent->RegisterAction(); } + + SHEditorUI::PopID(); } - // Needs to present - // - name and param list - // Needs to present for each callbackaction - // - object, methodinfo OR action - // - Ways to add or remove items } else {