Example #1
0
    def _add_dock_type(self, dock_type: DockType,
                       type_params: DockRandoParams):
        self.type_checks[dock_type] = defaultdict(dict)

        type_box = Foldable(dock_type.long_name)
        type_box.setObjectName(f"type_box {dock_type.short_name}")
        type_layout = QtWidgets.QHBoxLayout()
        type_layout.setObjectName(f"type_layout {dock_type.short_name}")
        type_box.set_content_layout(type_layout)

        self.dock_types_group.layout().addWidget(type_box)

        def add_group(name: str, desc: str, weaknesses: dict[DockWeakness,
                                                             bool]):
            group = QtWidgets.QGroupBox()
            group.setObjectName(f"{name}_group {dock_type.short_name}")
            group.setTitle(desc)
            layout = QtWidgets.QVBoxLayout()
            group.setLayout(layout)

            for weakness, enabled in weaknesses.items():
                check = QtWidgets.QCheckBox()
                check.setObjectName(
                    f"{name}_check {dock_type.short_name} {weakness.name}")
                check.setText(weakness.long_name)
                check.setEnabled(enabled)
                signal_handling.on_checked(
                    check,
                    self._persist_weakness_setting(name, dock_type, weakness))
                layout.addWidget(check)
                self.type_checks[dock_type][weakness][name] = check

            type_layout.addWidget(group)

        def keyfunc(weakness: DockWeakness):
            if weakness == type_params.unlocked:
                return 0
            return len(weakness.long_name)

        change_from = {
            weakness: True
            for weakness in sorted(type_params.change_from, key=keyfunc)
        }
        change_to = {
            weakness: weakness != type_params.unlocked
            for weakness in sorted(type_params.change_to, key=keyfunc)
        }
        add_group("can_change_from", "Doors to Change", change_from)
        add_group("can_change_to", "Change Doors To", change_to)
Example #2
0
    def _create_categories_boxes(self, item_database: ItemDatabase, size_policy):
        self._boxes_for_category = {}

        categories = set()
        for major_item in item_database.major_items.values():
            if not major_item.hide_from_gui:
                categories.add(major_item.item_category)

        all_categories = list(item_database.item_categories.values())
        for major_item_category in sorted(categories, key=lambda it: all_categories.index(it)):
            category_box = Foldable(major_item_category.long_name)
            category_box.setObjectName(f"category_box {major_item_category}")
            category_layout = QtWidgets.QGridLayout()
            category_layout.setObjectName(f"category_layout {major_item_category}")
            category_box.set_content_layout(category_layout)

            self.item_pool_layout.addWidget(category_box)
            self._boxes_for_category[major_item_category.name] = category_box, category_layout, {}
Example #3
0
    def create_template_editor(self, name: str):
        template_box = Foldable(name)
        template_box.setObjectName(f"template_box {name}")
        template_layout = QtWidgets.QVBoxLayout()
        template_layout.setObjectName(f"template_layout {name}")
        template_box.set_content_layout(template_layout)

        edit_template_button = QtWidgets.QPushButton()
        edit_template_button.setText("Edit")
        edit_template_button.clicked.connect(functools.partial(self.edit_template, name))
        template_layout.addWidget(edit_template_button)

        self.editor_for_template[name] = TemplateEditor(
            template_name=name,
            foldable=template_box,
            edit_button=edit_template_button,
            template_layout=template_layout,
            visualizer=None,
            connections_layout=None,
        )
        self.editor_for_template[name].create_visualizer(self.db)

        self.tab_template_layout.addWidget(template_box)