def reload_list(self):
        settings = self.enh_model.settings

        try:
            enhance_me = settings[self.prop_in_list]
            r_enhance_me = settings[self.prop_out_list]
        except KeyError as e:
            raise SettingsException('Key missing for enhancement gear', e)

        with SpeedUpTable(self):
            for gear in enhance_me:
                with QBlockSig(self):
                    self.table_add_gear(gear)
            for gear in r_enhance_me:
                with QBlockSig(self):
                    self.table_add_gear(gear, check_state=Qt.Unchecked)
        self.setSortingEnabled(True)
        return enhance_me, r_enhance_me
Esempio n. 2
0
 def table_add_gear(self, this_gear: Gear, check_state=Qt.Checked):
     top_lvl = super(TableEquipment,
                     self).table_add_gear(this_gear,
                                          check_state=check_state)
     idx_NAME = self.get_header_index(HEADER_NAME)
     gear_widget = self.itemWidget(top_lvl, idx_NAME)
     self.invalidated_gear.add(gear_widget.gear)
     gear_widget.chkInclude.stateChanged.connect(
         lambda: self.frmMain.invalidate_strategy())
     with QBlockSig(self):
         self.add_children(top_lvl)
 def MPThread_sig_done(self, ret):
     if isinstance(ret, Exception):
         return
     invalids = []
     with QBlockSig(self):
         for i in range(0, self.topLevelItemCount()):
             t_itm = self.topLevelItem(i)
             self.set_item_data(t_itm)
             invalids.append(t_itm)
     if len(invalids) > 0:
         self.invalidate_items(invalids)
     return invalids
 def table_add_gear(self,
                    this_gear: Gear,
                    check_state=Qt.Checked) -> QTreeWidgetItem:
     idx_NAME = self.get_header_index(HEADER_NAME)
     with QBlockSig(self):
         top_lvl = self.create_TreeWidgetItem(self, this_gear, check_state)
         master_gw: GearWidget = self.itemWidget(top_lvl, idx_NAME)
         self.addTopLevelItem(top_lvl)
         self.clearSelection()
     master_gw.chkInclude.stateChanged.connect(
         lambda x: self.gw_check_state_changed(master_gw, x))
     self.resizeColumnToContents(idx_NAME)
     return top_lvl
Esempio n. 5
0
 def invalidate_items(self, item_list: List[QTreeWidgetItem]):
     gear_set = super(TableEquipment, self).invalidate_items(item_list)
     self.invalidated_gear.update(gear_set)
     for itm in item_list:
         gw = self.itemWidget(itm, 0)
         gear = gw.gear
         parent_cost = int(round(gear.base_item_cost))
         str_monies = MONNIES_FORMAT.format(parent_cost)
         with QBlockSig(self):
             itm.setText(2, str_monies)
             for i in range(4, len(self.HEADERS)):
                 itm.setText(i, '')
             for i in range(0, itm.childCount()):
                 child = itm.child(i)
                 child_gw = self.itemWidget(child, 0)
                 child_gw.gear.set_base_item_cost(parent_cost)
                 child.setText(2, str_monies)
                 for i in range(4, len(self.HEADERS)):
                     child.setText(i, '')
     self.enh_model.invalidate_enahce_list()
     return gear_set
Esempio n. 6
0
    def cmdEquipCost_clicked(self):
        model = self.enh_model
        frmMain = self.frmMain

        send_fs_signal = model.fs_needs_update

        #if len(self.invalidated_gear) == 0:
        #    return  This is handled in model.calc_equip_costs

        try:
            model.calc_equip_costs(gear=self.invalidated_gear)
            self.invalidated_gear = set()
        except ValueError as f:
            print(fmt_traceback(f.__traceback__))
            frmMain.sig_show_message.emit(frmMain.WARNING, str(f))
            return
        except Invalid_FS_Parameters as e:
            frmMain.sig_show_message.emit(frmMain.WARNING, str(e))
            return

        if send_fs_signal:
            # This updates the UI to the fail stack list being updated from model.calc_equip_costs
            self.sig_fs_list_updated.emit()

        idx_NAME = self.get_header_index(HEADER_NAME)
        idx_CRONSTONE = self.get_header_index(HEADER_CRONSTONE)
        idx_FS = self.get_header_index(HEADER_FS)
        idx_COST = self.get_header_index(HEADER_COST)
        idx_MAT_COST = self.get_header_index(HEADER_MAT_COST)
        idx_NUM_FAILS = self.get_header_index(HEADER_NUM_FAILS)
        idx_PROBABILITY = self.get_header_index(HEADER_PROBABILITY)
        idx_USES_MEMFRAGS = self.get_header_index(HEADER_USES_MEMFRAGS)

        def populate_row(this_head, this_gear: Gear, eh_idx):

            cost_vec_l = this_gear.cost_vec[eh_idx]
            restore_cost_vec_min = this_gear.restore_cost_vec_min[eh_idx]
            idx_ = numpy.argmin(this_gear.cost_vec[eh_idx])

            gw: GearWidget = self.itemWidget(this_head, idx_NAME)

            gw.update_data()
            uses_crons = eh_idx in this_gear.cron_use
            if uses_crons:
                if gw.trinket is None:
                    gw.set_trinket(pix[STR_PIC_CRON])
            else:
                if gw.trinket is not None:
                    gw.set_trinket(None)

            this_head.setText(idx_CRONSTONE, str(uses_crons))
            this_head.setText(idx_FS, str(idx_))
            this_head.setText(idx_COST,
                              MONNIES_FORMAT.format(round(cost_vec_l[idx_])))
            this_head.setText(
                idx_MAT_COST,
                MONNIES_FORMAT.format(round(restore_cost_vec_min)))

            this_fail_map = numpy.array(this_gear.gear_type.map)[eh_idx]
            if uses_crons:
                avg_num_fails = (1 / this_gear.gear_type.map[eh_idx][idx_])
            else:
                avg_num_fails = this_gear.gear_type.p_num_atmpt_map[eh_idx][
                    idx_] - 1

            this_head.setText(idx_NUM_FAILS,
                              STR_TWO_DEC_FORMAT.format(avg_num_fails))
            this_head.setText(idx_PROBABILITY,
                              STR_PERCENT_FORMAT.format(this_fail_map[idx_]))
            if hasattr(this_gear, 'using_memfrags'):
                this_head.setText(idx_USES_MEMFRAGS,
                                  str(this_gear.using_memfrags))

        with QBlockSig(self):
            with SpeedUpTable(self):
                for i in range(0, self.topLevelItemCount()):
                    this_head = self.topLevelItem(i)
                    gear_widget = self.itemWidget(this_head, idx_NAME)
                    this_gear: Gear = gear_widget.gear
                    eh_idx = this_gear.get_enhance_lvl_idx()
                    populate_row(this_head, this_gear, eh_idx)
                    for j in range(0, this_head.childCount()):
                        this_child = this_head.child(j)
                        child_gear_widget = self.itemWidget(
                            this_child, idx_NAME)
                        child_gear = child_gear_widget.gear
                        eh_idx = child_gear.get_enhance_lvl_idx()
                        populate_row(this_child, this_gear, eh_idx)