Skip to content

Commit af9f7ec

Browse files
authored
Cleaned up inspector code and fixed renaming bug (#558)
1 parent e4d0956 commit af9f7ec

File tree

3 files changed

+314
-270
lines changed

3 files changed

+314
-270
lines changed

Sources/Overload/OvEditor/include/OvEditor/Panels/Inspector.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,42 +53,42 @@ namespace OvEditor::Panels
5353
*/
5454
void UnFocus();
5555

56-
/**
57-
* Unfocus the currently targeted actor without removing listeners attached to this actor
58-
*/
59-
void SoftUnFocus();
60-
6156
/**
6257
* Returns the currently selected actor
6358
*/
64-
OvCore::ECS::Actor* GetTargetActor() const;
65-
66-
/**
67-
* Create the actor inspector for the given actor
68-
*/
69-
void CreateActorInspector(OvCore::ECS::Actor& p_target);
70-
71-
/**
72-
* Draw the given component in inspector
73-
*/
74-
void DrawComponent(OvCore::ECS::Components::AComponent& p_component);
75-
76-
/**
77-
* Draw the given behaviour in inspector
78-
*/
79-
void DrawBehaviour(OvCore::ECS::Components::Behaviour& p_behaviour);
59+
OvTools::Utils::OptRef<OvCore::ECS::Actor> GetTargetActor() const;
8060

8161
/**
8262
* Refresh the inspector
8363
*/
8464
void Refresh();
8565

8666
private:
87-
OvCore::ECS::Actor* m_targetActor = nullptr;
88-
OvUI::Widgets::Layout::Group* m_actorInfo;
89-
OvUI::Widgets::Layout::Group* m_inspectorHeader;
90-
OvUI::Widgets::Selection::ComboBox* m_componentSelectorWidget;
91-
OvUI::Widgets::InputFields::InputText* m_scriptSelectorWidget;
67+
void _Populate();
68+
void _PopulateActorInfo();
69+
void _PopulateActorComponents();
70+
void _PopulateActorBehaviours();
71+
void _DrawAddComponentSection();
72+
void _DrawAddScriptSection();
73+
void _DrawComponent(OvCore::ECS::Components::AComponent& p_component);
74+
void _DrawBehaviour(OvCore::ECS::Components::Behaviour& p_behaviour);
75+
void _UpdateAddComponentButton();
76+
void _UpdateAddScriptButton();
77+
78+
private:
79+
OvTools::Utils::OptRef<OvCore::ECS::Actor> m_targetActor = std::nullopt;
80+
OvUI::Widgets::Layout::Group* m_content;
81+
82+
OvTools::Utils::OptRef<OvUI::Widgets::Buttons::Button> m_addComponentButton;
83+
OvTools::Utils::OptRef<OvUI::Widgets::Buttons::Button> m_addScriptButton;
84+
85+
// We store this here so that re-creating the inspector doesn't
86+
// reset the selected component.
87+
int m_selectedComponent = 0;
88+
89+
// Same as the selected component above, we want to keep the value
90+
// of the selected script even if the inspector is re-created
91+
std::string m_selectedScript;
9292

9393
uint64_t m_componentAddedListener = 0;
9494
uint64_t m_componentRemovedListener = 0;

Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ void OvEditor::Core::EditorActions::DuplicateActor(OvCore::ECS::Actor & p_toDupl
683683
DuplicateActor(*child, &newActor, false);
684684
}
685685

686-
void OvEditor::Core::EditorActions::SelectActor(OvCore::ECS::Actor & p_target)
686+
void OvEditor::Core::EditorActions::SelectActor(OvCore::ECS::Actor& p_target)
687687
{
688688
EDITOR_PANEL(Panels::Inspector, "Inspector").FocusActor(p_target);
689689
}
@@ -695,12 +695,12 @@ void OvEditor::Core::EditorActions::UnselectActor()
695695

696696
bool OvEditor::Core::EditorActions::IsAnyActorSelected() const
697697
{
698-
return EDITOR_PANEL(Panels::Inspector, "Inspector").GetTargetActor();
698+
return EDITOR_PANEL(Panels::Inspector, "Inspector").GetTargetActor().has_value();
699699
}
700700

701-
OvCore::ECS::Actor & OvEditor::Core::EditorActions::GetSelectedActor() const
701+
OvCore::ECS::Actor& OvEditor::Core::EditorActions::GetSelectedActor() const
702702
{
703-
return *EDITOR_PANEL(Panels::Inspector, "Inspector").GetTargetActor();
703+
return EDITOR_PANEL(Panels::Inspector, "Inspector").GetTargetActor().value();
704704
}
705705

706706
void OvEditor::Core::EditorActions::MoveToTarget(OvCore::ECS::Actor& p_target)

0 commit comments

Comments
 (0)