コード例 #1
0
    def set_henchman_box(self):

        currentbox = QVBoxLayout()
        currentsquad = None

        for squad in self.mainwindow.wbid.squadlist:
            for henchman in squad.henchmanlist:
                if self.mainwindow.currentunit is henchman:
                    currentsquad = squad
                    break
                    break

        if currentsquad != None:
            tabs = QTabWidget()

            for henchman in currentsquad.henchmanlist:

                self.configfile = {
                    'namebox': {
                        'row': 0,
                        'column': 0,
                        'width': 1,
                        'height': 1,
                        'children': {
                            'namelabel': {
                                'row':
                                0,
                                'column':
                                0,
                                'width':
                                1,
                                'height':
                                1,
                                'text':
                                f"Name: <b>{henchman.name}</b>",
                                'tooltip':
                                "Name",
                                'connect':
                                self.create_method_change_name(henchman),
                            },
                            'catlabel': {
                                'row': 1,
                                'column': 0,
                                'width': 1,
                                'height': 1,
                                'text':
                                f"Category: <b>{henchman.category}</b>",
                                'tooltip': "Category",
                                'connect': "",
                            },
                            'pricelabel': {
                                'row': 2,
                                'column': 0,
                                'width': 1,
                                'height': 1,
                                'text': f"Price: <b>{henchman.price}</b>",
                                'tooltip': "Price",
                                'connect': "",
                            },
                            'advlabel': {
                                'row': 0,
                                'column': 1,
                                'width': 1,
                                'height': 1,
                                'text':
                                f"Advance: <b>{henchman.get_current_advance()}</b>",
                                'tooltip':
                                f"Next is Advance <b>{henchman.get_next_advance()}</b> at experience <b> {henchman.get_xpneeded()} </b>",
                                'connect': "",
                            },
                            'explabel': {
                                'row': 1,
                                'column': 1,
                                'width': 1,
                                'height': 1,
                                'text':
                                f"Experience: <b>{henchman.experience}</b>",
                                'tooltip':
                                f"This characters current experience",
                                'connect':
                                self.create_method_change_experience(),
                            },
                            'maxlabel': {
                                'row': 2,
                                'column': 1,
                                'width': 1,
                                'height': 1,
                                'text': f"Maximum: <b>{henchman.maxcount}</b>",
                                'tooltip': "Maximum",
                                'connect': "",
                            },
                            'levellabel': {
                                'row': 0,
                                'column': 2,
                                'width': 1,
                                'height': 1,
                                'text':
                                f"<b>{henchman.get_levelup_notification()}</b>",
                                'tooltip': "",
                                'connect': self.create_method_levelup(),
                            },
                            'eventslabel': {
                                'row': 1,
                                'column': 2,
                                'width': 1,
                                'height': 1,
                                'text': f"Events",
                                'tooltip':
                                f"This characters history: <br/>{henchman.get_historystring()}",
                                'connect': "",
                            },
                            # 'removelabel': {'row': 2, 'column': 2, 'width': 1, 'height': 1, 'text': f"<b>Remove</b>", 'tooltip': f"Remove this character", 'connect': self.remove_unit(),},
                        }
                    },
                    'skillbox': {
                        'row': 1,
                        'column': 0,
                        'width': 1,
                        'height': 1,
                    },
                    'listbox': {
                        'row': 2,
                        'column': 0,
                        'width': 4,
                        'height': 1,
                    },
                }

                unitbox = QGridLayout()
                config = self.configfile['namebox']
                unitbox.addWidget(self.set_namebox(), config['row'],
                                  config['column'], config['width'],
                                  config['height'])
                config = self.configfile['skillbox']
                unitbox.addWidget(self.set_skillbox(), config['row'],
                                  config['column'], config['width'],
                                  config['height'])
                config = self.configfile['listbox']
                unitbox.addWidget(self.set_listbox(), config['row'],
                                  config['column'], config['width'],
                                  config['height'])

                unitwidget = QWidget()
                unitwidget.setLayout(unitbox)
                tabs.addTab(
                    unitwidget,
                    f"{henchman.name}",
                )

                # set default tab to currentunit
                lenght = tabs.__len__()
                if henchman is self.mainwindow.currentunit:
                    tabs.setCurrentIndex(lenght - 1)

            tabs.addTab(QWidget(), f"+")

            tabs.currentChanged.connect(self.onclick)

            buttonwidget = self.set_buttonwidget()

            currentbox.addWidget(tabs)
            currentbox.addWidget(buttonwidget)

            return currentbox