Made childrenTag a dictionary which could have multiple items for filtering option

This commit is contained in:
Gyedo Jeon 2007-08-02 00:53:36 +00:00
parent a8ae4fa3f1
commit 4c6b2a4698

View File

@ -52,8 +52,8 @@ class TreeNode:
self.menuVar.set(0)
self._popupMenu = None
self.fSortChildren = False # [gjeon] flag for sorting children or not
self.fModeChildrenTag = 0 # [gjeon] 0: hide by given tag, 1: show by given tag
self.childrenTag = None
self.fModeChildrenTag = 0 # [gjeon] flag for using filter or not
self.childrenTag = None # [gjeon] filter dictionary for
# [gjeon] to set fSortChildren
def setFSortChildren(self, fSortChildren):
@ -303,9 +303,13 @@ class TreeNode:
self.kidKeys.append(key)
# [gjeon] to filter by given tag
if self.fModeChildrenTag:
if self.childrenTag:
#if not item.nodePath.hasTag('GameArea'):
if self.fModeChildrenTag != item.nodePath.hasTag(self.childrenTag):
showThisItem = False
for tagKey in self.childrenTag.keys():
if item.nodePath.hasTag(tagKey):
showThisItem = self.childrenTag[tagKey]
if not showThisItem:
self.kidKeys.remove(key)
# Remove unused children
@ -429,8 +433,13 @@ class TreeNode:
# Is it this node
if searchKey == self.item.GetKey():
# [gjeon] to filter by given tag
if self.fModeChildrenTag:
if self.childrenTag:
if self.fModeChildrenTag != self.item.nodePath.hasTag(self.childrenTag):
showThisItem = False
for tagKey in self.childrenTag.keys():
if item.nodePath.hasTag(tagKey):
showThisItem = self.childrenTag[tagKey]
if not showThisItem:
return None
return self
# Nope, check the children