aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/core/tree_item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic/core/tree_item.cpp')
-rw-r--r--engines/titanic/core/tree_item.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp
index 31deab860d..ffcee40c6a 100644
--- a/engines/titanic/core/tree_item.cpp
+++ b/engines/titanic/core/tree_item.cpp
@@ -88,6 +88,26 @@ CTreeItem *CTreeItem::scan(CTreeItem *item) const {
return nullptr;
}
+CTreeItem *CTreeItem::findChildInstanceOf(ClassDef *classDef) const {
+ for (CTreeItem *treeItem = _firstChild; treeItem; treeItem = treeItem->getNextSibling()) {
+ if (treeItem->isInstanceOf(classDef))
+ return treeItem;
+ }
+
+ return nullptr;
+}
+
+CTreeItem *CTreeItem::findNextInstanceOf(ClassDef *classDef, CTreeItem *startItem) const {
+ CTreeItem *treeItem = startItem ? startItem->getNextSibling() : getFirstChild();
+
+ for (; treeItem; treeItem = treeItem->getNextSibling()) {
+ if (treeItem->isInstanceOf(classDef))
+ return treeItem;
+ }
+
+ return nullptr;
+}
+
void CTreeItem::addUnder(CTreeItem *newParent) {
if (newParent->_firstChild)
addSibling(newParent->getLastSibling());