Esempio n. 1
0
def update_hint_locations(game: RandovaniaGame,
                          hint_tree_widget: QtWidgets.QTreeWidget):
    game_description = default_database.game_description_for(game)

    used_hint_types = set()

    hint_tree_widget.clear()
    hint_tree_widget.setSortingEnabled(False)

    hint_type_tree = collections.defaultdict(dict)

    # First figure out which areas uses what hints.
    # This lets us use detect which hint types are used
    for world in game_description.world_list.worlds:
        for area in world.areas:
            hint_types = {}

            for node in area.nodes:
                if isinstance(node, LogbookNode):
                    used_hint_types.add(node.lore_type)
                    if node.required_translator is not None:
                        hint_types[node.lore_type] = node.required_translator.short_name
                    else:
                        hint_types[node.lore_type] = "✓"

            if hint_types:
                hint_type_tree[world.correct_name(area.in_dark_aether)][area.name] = hint_types

    number_for_hint_type = {
        hint_type: i + 1
        for i, hint_type in enumerate(sorted(used_hint_types, key=lambda it: it.long_name))
    }

    for world_name, area_hints in hint_type_tree.items():
        world_item = QtWidgets.QTreeWidgetItem(hint_tree_widget)
        world_item.setText(0, world_name)
        world_item.setExpanded(True)

        for area_name, hint_types in area_hints.items():
            area_item = QtWidgets.QTreeWidgetItem(world_item)
            area_item.setText(0, area_name)

            for hint_type, text in hint_types.items():
                area_item.setText(number_for_hint_type[hint_type], text)
                used_hint_types.add(hint_type)

    hint_tree_widget.resizeColumnToContents(0)
    hint_tree_widget.setSortingEnabled(True)
    hint_tree_widget.sortByColumn(0, QtCore.Qt.AscendingOrder)

    for hint_type in used_hint_types:
        hint_tree_widget.headerItem().setText(number_for_hint_type[hint_type], hint_type.long_name)
Esempio n. 2
0
def update_hint_locations(game: RandovaniaGame,
                          hint_tree_widget: QtWidgets.QTreeWidget):
    game_description = default_database.game_description_for(game)

    number_for_hint_type = {
        hint_type: i + 1
        for i, hint_type in enumerate(LoreType)
    }
    used_hint_types = set()

    hint_tree_widget.clear()
    hint_tree_widget.setSortingEnabled(False)

    # TODO: This ignores the Dark World names. But there's currently no logbook nodes in Dark World.
    for world in game_description.world_list.worlds:

        world_item = QtWidgets.QTreeWidgetItem(hint_tree_widget)
        world_item.setText(0, world.name)
        world_item.setExpanded(True)

        for area in world.areas:
            hint_types = {}

            for node in area.nodes:
                if isinstance(node, LogbookNode):
                    if node.required_translator is not None:
                        hint_types[
                            node.
                            lore_type] = node.required_translator.short_name
                    else:
                        hint_types[node.lore_type] = "✓"

            if hint_types:
                area_item = QtWidgets.QTreeWidgetItem(world_item)
                area_item.setText(0, area.name)

                for hint_type, text in hint_types.items():
                    area_item.setText(number_for_hint_type[hint_type], text)
                    used_hint_types.add(hint_type)

    hint_tree_widget.resizeColumnToContents(0)
    hint_tree_widget.setSortingEnabled(True)
    hint_tree_widget.sortByColumn(0, QtCore.Qt.AscendingOrder)

    for hint_type in used_hint_types:
        hint_tree_widget.headerItem().setText(number_for_hint_type[hint_type],
                                              hint_type.long_name)
Esempio n. 3
0
class Ui_Dialog(object):
    def setupUi(self, Dialog):
        if not Dialog.objectName():
            Dialog.setObjectName(u"Dialog")
        Dialog.resize(688, 530)
        Dialog.setMinimumSize(QSize(600, 0))
        Dialog.setMaximumSize(QSize(1000000, 16777215))
        self.verticalLayout = QVBoxLayout(Dialog)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.verticalFrame = QFrame(Dialog)
        self.verticalFrame.setObjectName(u"verticalFrame")
        self.verticalFrame.setMaximumSize(QSize(250, 16777215))
        self.verticalLayout_2 = QVBoxLayout(self.verticalFrame)
        self.verticalLayout_2.setObjectName(u"verticalLayout_2")
        self.label = QLabel(self.verticalFrame)
        self.label.setObjectName(u"label")

        self.verticalLayout_2.addWidget(self.label)

        self.treeWidget = QTreeWidget(self.verticalFrame)
        QTreeWidgetItem(self.treeWidget)
        QTreeWidgetItem(self.treeWidget)
        QTreeWidgetItem(self.treeWidget)
        self.treeWidget.setObjectName(u"treeWidget")
        font = QFont()
        font.setFamilies([u"Segoe UI"])
        font.setPointSize(10)
        self.treeWidget.setFont(font)
        self.treeWidget.setFrameShape(QFrame.VLine)
        self.treeWidget.setFrameShadow(QFrame.Plain)
        self.treeWidget.setTabKeyNavigation(True)
        self.treeWidget.setAlternatingRowColors(False)

        self.verticalLayout_2.addWidget(self.treeWidget)

        self.horizontalLayout.addWidget(self.verticalFrame)

        self.line = QFrame(Dialog)
        self.line.setObjectName(u"line")
        self.line.setFrameShape(QFrame.VLine)
        self.line.setFrameShadow(QFrame.Sunken)

        self.horizontalLayout.addWidget(self.line)

        self.stackedWidget = QStackedWidget(Dialog)
        self.stackedWidget.setObjectName(u"stackedWidget")
        self.page = QWidget()
        self.page.setObjectName(u"page")
        self.verticalLayout_3 = QVBoxLayout(self.page)
        self.verticalLayout_3.setObjectName(u"verticalLayout_3")
        self.groupBox = QGroupBox(self.page)
        self.groupBox.setObjectName(u"groupBox")
        self.formLayout_4 = QFormLayout(self.groupBox)
        self.formLayout_4.setObjectName(u"formLayout_4")
        self.label_2 = QLabel(self.groupBox)
        self.label_2.setObjectName(u"label_2")

        self.formLayout_4.setWidget(0, QFormLayout.LabelRole, self.label_2)

        self.comboBox = QComboBox(self.groupBox)
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.comboBox.setObjectName(u"comboBox")

        self.formLayout_4.setWidget(0, QFormLayout.FieldRole, self.comboBox)

        self.verticalLayout_3.addWidget(self.groupBox)

        self.groupBox_2 = QGroupBox(self.page)
        self.groupBox_2.setObjectName(u"groupBox_2")
        self.formLayout_3 = QFormLayout(self.groupBox_2)
        self.formLayout_3.setObjectName(u"formLayout_3")
        self.label_3 = QLabel(self.groupBox_2)
        self.label_3.setObjectName(u"label_3")

        self.formLayout_3.setWidget(1, QFormLayout.LabelRole, self.label_3)

        self.spinBox = QSpinBox(self.groupBox_2)
        self.spinBox.setObjectName(u"spinBox")
        self.spinBox.setValue(11)

        self.formLayout_3.setWidget(1, QFormLayout.FieldRole, self.spinBox)

        self.label_4 = QLabel(self.groupBox_2)
        self.label_4.setObjectName(u"label_4")

        self.formLayout_3.setWidget(0, QFormLayout.LabelRole, self.label_4)

        self.fontComboBox = QFontComboBox(self.groupBox_2)
        self.fontComboBox.setObjectName(u"fontComboBox")

        self.formLayout_3.setWidget(0, QFormLayout.FieldRole,
                                    self.fontComboBox)

        self.verticalLayout_3.addWidget(self.groupBox_2)

        self.stackedWidget.addWidget(self.page)
        self.page_2 = QWidget()
        self.page_2.setObjectName(u"page_2")
        self.verticalLayout_5 = QVBoxLayout(self.page_2)
        self.verticalLayout_5.setObjectName(u"verticalLayout_5")
        self.verticalLayout_4 = QVBoxLayout()
        self.verticalLayout_4.setObjectName(u"verticalLayout_4")

        self.verticalLayout_5.addLayout(self.verticalLayout_4)

        self.stackedWidget.addWidget(self.page_2)

        self.horizontalLayout.addWidget(self.stackedWidget)

        self.verticalLayout.addLayout(self.horizontalLayout)

        self.buttonBox = QDialogButtonBox(Dialog)
        self.buttonBox.setObjectName(u"buttonBox")
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Apply
                                          | QDialogButtonBox.Close
                                          | QDialogButtonBox.Save)

        self.verticalLayout.addWidget(self.buttonBox)

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)

        self.stackedWidget.setCurrentIndex(0)

        QMetaObject.connectSlotsByName(Dialog)

    # setupUi

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(
            QCoreApplication.translate("Dialog", u"Dialog", None))
        self.label.setText(
            QCoreApplication.translate("Dialog", u"Preferences", None))
        ___qtreewidgetitem = self.treeWidget.headerItem()
        ___qtreewidgetitem.setText(
            0, QCoreApplication.translate("Dialog", u"General", None))

        __sortingEnabled = self.treeWidget.isSortingEnabled()
        self.treeWidget.setSortingEnabled(False)
        ___qtreewidgetitem1 = self.treeWidget.topLevelItem(0)
        ___qtreewidgetitem1.setText(
            0, QCoreApplication.translate("Dialog", u"Appearance", None))
        ___qtreewidgetitem2 = self.treeWidget.topLevelItem(1)
        ___qtreewidgetitem2.setText(
            0, QCoreApplication.translate("Dialog", u"Behavior", None))
        ___qtreewidgetitem3 = self.treeWidget.topLevelItem(2)
        ___qtreewidgetitem3.setText(
            0, QCoreApplication.translate("Dialog", u"Advanced", None))
        self.treeWidget.setSortingEnabled(__sortingEnabled)

        self.groupBox.setTitle(
            QCoreApplication.translate("Dialog", u"Theme", None))
        self.label_2.setText(
            QCoreApplication.translate("Dialog", u"Window style", None))
        self.comboBox.setItemText(
            0, QCoreApplication.translate("Dialog", u"Native", None))
        self.comboBox.setItemText(
            1, QCoreApplication.translate("Dialog", u"Fusion", None))
        self.comboBox.setItemText(
            2, QCoreApplication.translate("Dialog", u"Fusion dark", None))

        self.groupBox_2.setTitle(
            QCoreApplication.translate("Dialog", u"Accessibility", None))
        self.label_3.setText(
            QCoreApplication.translate("Dialog", u"Font size", None))
        self.label_4.setText(
            QCoreApplication.translate("Dialog", u"Font", None))