def ExecResourceSelectDialog(resourceType,
                             infoText=None,
                             filter=_allPassFilter):
    dialog = UniversalSelectDialog()
    if infoText:
        dialog._infoLabel.setText(infoText)
    else:
        dialog._infoLabel.setText("Select Resource File")
    dialog._tree.clear()
    if resourceType == ResourceType.Image or resourceType == ResourceType.Sound:
        addList = [
            (dialog._tree.invisibleRootItem(),
             GetEventManager().getAssetsModel().getResourcesTree()),
        ]
    elif resourceType == ResourceType.SoundEvent:
        dialog._preview.setHidden(True)
        addList = [
            (dialog._tree.invisibleRootItem(),
             GetEventManager().getSoundEventsModel().getResourceTree()),
        ]
    elif resourceType == ResourceType.Entity:
        dialog._preview.setHidden(True)
        addList = [
            (dialog._tree.invisibleRootItem(),
             GetEventManager().getAssetsModel().getEntitiesTree()),
        ]
    else:
        raise RuntimeError("Unknown resource type: {0}".format(resourceType))
    while addList:
        currItem, currNode = addList.pop()
        if not currNode.isDir():
            if _isFileTypeResourceTypeMatch(currNode._type, resourceType):
                treeItem = QTreeWidgetItem(currItem)
                treeItem.setText(0, currNode.getBaseName())
                treeItem._node = currNode
                treeItem.setIcon(
                    0,
                    dialog.style().standardIcon(QStyle.SP_FileIcon))
                if filter(currNode):
                    treeItem.setDisabled(True)
        else:
            treeItem = QTreeWidgetItem(currItem)
            treeItem.setText(0, currNode.getBaseName())
            treeItem._node = currNode
            treeItem.setIcon(0, dialog.style().standardIcon(QStyle.SP_DirIcon))
            for childNode in currNode:
                addList.append((treeItem, childNode))
    _hideEmptyDirs(dialog._tree.invisibleRootItem())
    dialog._tree.sortItems(1, QtCore.Qt.DescendingOrder)
    dialog.exec()
    return dialog.getSelectResult()
Пример #2
0
 def _buildTree(self, parentItem, rootNode):
     for node in rootNode:
         if node.isDir():
             treeItem = QTreeWidgetItem(parentItem)
             treeItem.setText(0, node.getBaseName())
             treeItem.setIcon(0,
                              self.style().standardIcon(QStyle.SP_DirIcon))
             treeItem._node = node
             self._buildTree(treeItem, node)
         else:
             treeItem = QTreeWidgetItem(parentItem)
             treeItem.setText(0, node.getBaseName())
             treeItem.setIcon(0,
                              self.style().standardIcon(QStyle.SP_FileIcon))
             treeItem._node = node
def ExecSelectFromChildrenEntities(entity):
    dialog = UniversalSelectDialog()
    dialog._preview.setHidden(True)
    dialog._infoLabel.setText("Select Entity From Children")

    addList = [
        (dialog._tree.invisibleRootItem(), entity),
    ]
    while addList:
        rootItem, currEnt = addList.pop()
        currItem = QTreeWidgetItem(rootItem)
        currItem._node = currEnt
        if currEnt == entity:
            currItem.setText(0, "{0} (this)".format(entity.getName()))
        else:
            if currEnt.isInternal():
                currItem.setText(0, currEnt.getName())
            else:
                currItem.setText(
                    0, "{0} {1}".format(currEnt.getName(),
                                        currEnt.getNameSuffix()))
        for childEnt in currEnt.getChildren():
            addList.append((currItem, childEnt))

    dialog._tree.sortItems(1, QtCore.Qt.DescendingOrder)
    dialog.exec()
    return dialog.getSelectResult()
Пример #4
0
 def _buildTree(self, parentItem, rootNode):
     for node in rootNode:
         if node.isDir():
             treeItem = QTreeWidgetItem(parentItem)
             treeItem.setText(0, node.getBaseName())
             treeItem.setIcon(0,
                              self.style().standardIcon(QStyle.SP_DirIcon))
             treeItem._node = node
             if node.getRelativePath() in self._expandedItems:
                 treeItem.setExpanded(True)
             self._buildTree(treeItem, node)
         else:
             treeItem = QTreeWidgetItem(parentItem)
             treeItem.setText(0, node.getBaseName())
             treeItem.setIcon(0,
                              self.style().standardIcon(QStyle.SP_FileIcon))
             treeItem._node = node
Пример #5
0
 def _buildTree(self, rootItem, moduleLogics):
     for module in moduleLogics:
         moduleItem = QTreeWidgetItem(rootItem)
         moduleItem.setText(0, module.getName())
         moduleItem.setIcon(0, self.style().standardIcon(QStyle.SP_DirIcon))
         for logic in module.getLogics():
             item = QTreeWidgetItem(moduleItem)
             item.setText(0, logic.getName())
             item._node = logic
def ExecEntityLogicSelectDialog():
    dialog = UniversalSelectDialog()
    dialog._preview.setHidden(True)
    dialog._infoLabel.setText("Select Entity Logic")

    rootItem = dialog._tree.invisibleRootItem()
    logicsModel = GetEventManager().getEntityLogicsModel()
    for module in logicsModel.getLogics():
        moduleItem = QTreeWidgetItem(rootItem)
        moduleItem.setText(0, module.getName())
        moduleItem.setIcon(0, dialog.style().standardIcon(QStyle.SP_DirIcon))
        for logic in module.getLogics():
            logicItem = QTreeWidgetItem(moduleItem)
            logicItem.setText(0, logic.getName())
            logicItem.setIcon(0,
                              dialog.style().standardIcon(QStyle.SP_FileIcon))
            logicItem._node = logic

    dialog._tree.sortItems(1, QtCore.Qt.DescendingOrder)
    dialog.exec()
    return dialog.getSelectResult()