Skip to content

Commit

Permalink
Merge pull request GarageGames#2324 from Areloch/TweakedguiTreeViewOb…
Browse files Browse the repository at this point in the history
…jectHandling

Tweaks some object handling of guiTreeViewObj
  • Loading branch information
Areloch authored May 4, 2019
2 parents ba2e9f1 + a937bf4 commit 5d1ff71
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
32 changes: 28 additions & 4 deletions Engine/source/gui/controls/guiTreeViewCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ void GuiTreeViewCtrl::Item::setObject(SimObject *obj)
{
if(!mState.test(InspectorData))
{
Con::errorf("Tried to set the object for item %d, which is not InspectorData!", mId);
return;
}

Expand All @@ -409,7 +408,6 @@ SimObject *GuiTreeViewCtrl::Item::getObject()
{
if(!mState.test(InspectorData))
{
Con::errorf("Tried to get the object for item %d, which is not InspectorData!", mId);
return NULL;
}

Expand Down Expand Up @@ -5101,12 +5099,13 @@ DefineEngineMethod( GuiTreeViewCtrl, editItem, bool, ( S32 itemId, const char* n
return(object->editItem(itemId, newText, newValue));
}

DefineEngineMethod( GuiTreeViewCtrl, removeItem, bool, (S32 itemId), ,
DefineEngineMethod( GuiTreeViewCtrl, removeItem, bool, (S32 itemId, bool deleteObjects), (0, true),
"Remove an item from the tree with the given id.\n\n"
"@param itemId TreeItemID of item to remove.\n"
"@param deleteObjects Whether the object on the item is deleted when the item is.\n"
"@return True if successful, false if not.")
{
return(object->removeItem(itemId));
return(object->removeItem(itemId, deleteObjects));
}

DefineEngineMethod( GuiTreeViewCtrl, removeAllChildren, void, (S32 itemId), ,
Expand Down Expand Up @@ -5335,6 +5334,31 @@ DefineEngineMethod( GuiTreeViewCtrl, findItemByObjectId, S32, (S32 objectId), ,
return(object->findItemByObjectId(objectId));
}

//------------------------------------------------------------------------------
S32 GuiTreeViewCtrl::getItemObject(S32 itemId)
{
GuiTreeViewCtrl::Item* item = getItem(itemId);
if (!item)
{
return 0;
}

SimObject* pObj = item->getObject();
if (pObj)
return pObj->getId();

return 0;
}

//------------------------------------------------------------------------------
DefineEngineMethod(GuiTreeViewCtrl, getItemObject, S32, (S32 itemId), ,
"Gets the object for a particular item.\n\n"
"@param itemId Item id you want the object id for."
"@return Object Id for the given tree item ID.")
{
return(object->getItemObject(itemId));
}

//------------------------------------------------------------------------------
bool GuiTreeViewCtrl::scrollVisibleByObjectId(S32 objID)
{
Expand Down
1 change: 1 addition & 0 deletions Engine/source/gui/controls/guiTreeViewCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
S32 findItemByName(const char *name);
S32 findItemByValue(const char *name);
S32 findItemByObjectId(S32 iObjId);
S32 getItemObject(S32 itemId);

void sortTree( bool caseSensitive, bool traverseHierarchy, bool parentsFirst );

Expand Down

0 comments on commit 5d1ff71

Please sign in to comment.