Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#5406: Auto-select the first objective entity when opening the object…
…ives editor
  • Loading branch information
codereader committed Dec 25, 2020
1 parent 62a4ab7 commit 9f7eede
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 15 additions & 0 deletions plugins/dm.objectives/ObjectivesEditor.cpp
Expand Up @@ -192,6 +192,16 @@ void ObjectivesEditor::populateWidgets()
);
GlobalSceneGraph().root()->traverse(finder);

// Select the first entity in the list for convenience
wxDataViewItemArray children;
_objectiveEntityList->GetChildren(_objectiveEntityList->GetRoot(), children);

if (!children.empty())
{
_objectiveEntityView->Select(children.front());
handleEntitySelectionChange();
}

// Set the worldspawn entity and populate the active-at-start column
_worldSpawn = finder.getWorldSpawn();
if (_worldSpawn != NULL)
Expand Down Expand Up @@ -331,6 +341,11 @@ void ObjectivesEditor::_onStartActiveCellToggled(wxDataViewEvent& ev)

// Callback for objective entity selection changed in list box
void ObjectivesEditor::_onEntitySelectionChanged(wxDataViewEvent& ev)
{
handleEntitySelectionChange();
}

void ObjectivesEditor::handleEntitySelectionChange()
{
// Clear the objectives list
_objectiveList->Clear();
Expand Down
5 changes: 2 additions & 3 deletions plugins/dm.objectives/ObjectivesEditor.h
Expand Up @@ -62,9 +62,6 @@ class ObjectivesEditor :
// Widget construction helpers
void setupEntitiesPanel();
void setupObjectivesPanel();
void createObjectiveEditPanel();
void createLogicPanel();
void createButtons();

// callbacks
void _onCancel(wxCommandEvent& ev);
Expand All @@ -83,6 +80,8 @@ class ObjectivesEditor :
void _onEditLogic(wxCommandEvent& ev);
void _onEditObjConditions(wxCommandEvent& ev);

void handleEntitySelectionChange();

// Populate the dialog widgets with appropriate state from the map
void populateWidgets();
void populateActiveAtStart();
Expand Down

0 comments on commit 9f7eede

Please sign in to comment.