def MPThread_sig_done(self, thread: QThread, ret): if isinstance(ret, Exception): return with QBlockSig(self): for i in range(self.rowCount()): self.set_item_data(i) self.model_invalidate_func() self.main_invalidate_func()
def fs_gear_sig_gear_changed(self, gw: GearWidget): model = self.enh_model settings = model.settings item_store: ItemStore = settings[settings.P_ITEM_STORE] this_gear: Gear = gw.gear model.update_costs([this_gear]) with QBlockSig(self): self.fs_gear_set_costs(this_gear, item_store, gw.row()) self.main_invalidate_func()
def reload_list(self): model = self.enh_model fs_exceptions = model.settings[model.settings.P_FS_EXCEPTIONS] index_FS = self.get_header_index(HEADER_FS) index_GEAR = self.get_header_index(HEADER_GEAR) index_COST = self.get_header_index(HEADER_COST) index_CUMULATIVE_COST = self.get_header_index(HEADER_CUMULATIVE_COST) index_PROBABILITY = self.get_header_index(HEADER_PROBABILITY) index_CUMULATIVE_PROBABILITY = self.get_header_index( HEADER_CUMULATIVE_PROBABILITY) with SpeedUpTable(self): with QBlockSig(self): clear_table(self) fs_items = model.primary_fs_gear fs_cost = model.primary_fs_cost cum_fs_cost = model.primary_cum_fs_cost cum_fs_probs = model.cum_fs_probs fs_probs = model.fs_probs fs_exception_boxes = self.fs_exception_boxes for i, this_gear in enumerate(fs_items): rc = self.rowCount() self.insertRow(rc) self.setRowHeight(rc, 32) twi = QTableWidgetItem(str(i + 1)) self.setItem(rc, index_FS, twi) if this_gear is None: twi = QTableWidgetItem('Free!') self.setItem(rc, index_GEAR, twi) elif i in fs_exceptions: self.add_custom_fs_combobox(model, fs_exception_boxes, i) else: two = GearWidget(this_gear, model, edit_able=False, display_full_name=True) two.add_to_table(self, rc, col=index_GEAR) twi = monnies_twi_factory(fs_cost[i]) self.setItem(rc, index_COST, twi) twi = monnies_twi_factory(cum_fs_cost[i]) self.setItem(rc, index_CUMULATIVE_COST, twi) twi = QTableWidgetItem(STR_PERCENT_FORMAT.format(fs_probs[i])) self.setItem(rc, index_PROBABILITY, twi) twi = QTableWidgetItem( STR_PERCENT_FORMAT.format(cum_fs_probs[i])) self.setItem(rc, index_CUMULATIVE_PROBABILITY, twi) if model.dragon_scale_30: if not 19 in fs_exceptions: self.removeCellWidget(19, index_GEAR) itm = self.item(19, index_GEAR) itm.setText('Dragon Scale x30') itm.setIcon(pix.get_icon(STR_PIC_DRAGON_SCALE)) if model.dragon_scale_350: if not 39 in fs_exceptions: self.removeCellWidget(39, index_GEAR) self.item(39, index_GEAR).setText('Dragon Scale x350')
def table_add_gear(self, this_gear: Gear, check_state=Qt.Checked): idx_NAME = self.get_header_index(HEADER_NAME) top_lvl = super(TableFSSecondary, self).table_add_gear(this_gear, check_state=check_state) gw: GearWidget = self.itemWidget(top_lvl, idx_NAME) gw.model_edit_func = self.enh_model.edit_fs_secondary_item with QBlockSig(self): self.add_children(top_lvl)
def set_item_data(self, row): idx_BASE_ITEM_COST = self.get_header_index(HEADER_BASE_ITEM_COST) idx_HEADER_NAME = self.get_header_index(HEADER_NAME) item_store = self.enh_model.item_store() this_gear = self.cellWidget(row, idx_HEADER_NAME).gear twi = monnies_twi_factory(this_gear.base_item_cost) with QBlockSig(self): self.setItem(row, idx_BASE_ITEM_COST, twi) if item_store.price_is_overridden(this_gear, -1): twi.setForeground(COLOR_CUSTOM_PRICE)
def reload_list(self): model = self.enh_model settings = model.settings clear_table(self) try: fail_stackers = settings[self.prop_in_list] r_fail_stackers = settings[self.prop_out_list] except KeyError as e: raise SettingsException( 'Fail-stacking material is missing from the settings file', e) with SpeedUpTable(self): for gear in fail_stackers: with QBlockSig(self): self.table_FS_add_gear(gear) for gear in r_fail_stackers: with QBlockSig(self): self.table_FS_add_gear(gear, check_state=Qt.Unchecked) self.setSortingEnabled(True)
def MPThread_sig_done(self, ret): if isinstance(ret, Exception): return idx_BASE_ITEM_COST = self.get_header_index(HEADER_BASE_ITEM_COST) idx_NAME = self.get_header_index(HEADER_NAME) with QBlockSig(self): for i in range(0, self.rowCount()): gw = self.cellWidget(i, idx_NAME) this_gear = gw.gear itm = self.item(i, idx_BASE_ITEM_COST) itm.setText( MONNIES_FORMAT.format(int(round( this_gear.base_item_cost)))) self.model_invalidate_func() self.main_invalidate_func()
def reload_list(self): model = self.enh_model index_FS = self.get_header_index(HEADER_FS) index_GEAR = self.get_header_index(HEADER_GEAR) index_COST = self.get_header_index(HEADER_COST) index_CUMULATIVE_COST = self.get_header_index(HEADER_CUMULATIVE_COST) index_PROBABILITY = self.get_header_index(HEADER_PROBABILITY) index_CUMULATIVE_PROBABILITY = self.get_header_index(HEADER_CUMULATIVE_PROBABILITY) #exchange_dict = dict_box_list([x for x in model.fs_exchange if x.active], lambda x: x.effective_fs_level() - 1) exchange_dict: Dict[int, FailStackItemExchange] = {x.effective_fs_level()-1: x for x in model.fs_exchange if x.active} with SpeedUpTable(self): with QBlockSig(self): clear_table(self) fs_items = model.primary_fs_gear fs_cost = model.primary_fs_cost cum_fs_cost = model.primary_cum_fs_cost cum_fs_probs = model.cum_fs_probs fs_probs = model.fs_probs for i, this_gear in enumerate(fs_items): rc = self.rowCount() self.insertRow(rc) self.setRowHeight(rc, 32) twi = QTableWidgetItem(str(i+1)) self.setItem(rc, index_FS, twi) if this_gear is None: twi = QTableWidgetItem('Free!') self.setItem(rc, index_GEAR, twi) else: two = GearWidget(this_gear, model, edit_able=False, display_full_name=True) two.add_to_table(self, rc, col=index_GEAR) twi = monnies_twi_factory(fs_cost[i]) self.setItem(rc, index_COST, twi) twi = monnies_twi_factory(cum_fs_cost[i]) self.setItem(rc, index_CUMULATIVE_COST, twi) twi = QTableWidgetItem(STR_PERCENT_FORMAT.format(fs_probs[i])) self.setItem(rc, index_PROBABILITY, twi) twi = QTableWidgetItem(STR_PERCENT_FORMAT.format(cum_fs_probs[i])) self.setItem(rc, index_CUMULATIVE_PROBABILITY, twi) if i in exchange_dict: item = exchange_dict[i] widget = make_material_list_widget([(x.item_id, x.amount) for x in item.exchange_items.values()], show_names=True, item_store=model.item_store()) self.removeCellWidget(rc, index_GEAR) self.setCellWidget(rc, index_GEAR, widget) self.resizeColumnsToContents()
def update_gw(self): gear = self.fsl.secondary_gear tree = self.treeWidget() idx_NAME = tree.get_header_index(HEADER_NAME) if gear is not None: this_gw = GearWidget( gear, self.model, edit_able=False, display_full_name=False, enhance_overlay=False, check_state=Qt.Checked if self.checked else Qt.Unchecked) this_gw.chkInclude.stateChanged.connect( self.gear_widget_chkInclude_stateChanged) with QBlockSig(tree): self.setText(idx_NAME, '') tree.setItemWidget(self, idx_NAME, this_gw) tree.updateGeometry() if self.checked: self.check_error() else: tree.removeItemWidget(self, idx_NAME)
def cmdFSUpdateMP_callback(self, thread: QThread, ret): model = self.enh_model frmMain = self.frmMain idx_NAME = self.HEADERS.index(HEADER_NAME) if isinstance(ret, Exception): print(ret) frmMain.sig_show_message.emit(frmMain.CRITICAL, 'Error contacting central market') else: settings = model.settings item_store: ItemStore = settings[settings.P_ITEM_STORE] with QBlockSig(self): for i in range(self.rowCount()): this_gear: Gear = self.cellWidget(i, idx_NAME).gear self.fs_gear_set_costs(this_gear, item_store, i) frmMain.sig_show_message.emit(frmMain.REGULAR, 'Fail stacking prices updated') thread.wait(2000) if thread.isRunning(): thread.terminate() self.mp_threads.remove(thread)
def cmdFSRefresh_clicked(self, fsl: FailStackList): model: Enhance_model = self.enh_model settings = model.settings with SpeedUpTable(self): with QBlockSig(self): clear_table(self) if not fsl.validate(): return clear_table(self) try: if model.fs_needs_update: model.calcFS() else: model.calc_fs_secondary() except Invalid_FS_Parameters as e: self.frmMain.show_warning_msg(str(e)) return if not fsl.has_ran(): fsl.set_primary_data(model.primary_fs_gear, model.primary_fs_cost, model.primary_cum_fs_cost) fsl.evaluate_map() index_FS = self.get_header_index(HEADER_FS) index_GEAR = self.get_header_index(HEADER_GEAR) index_COST = self.get_header_index(HEADER_COST) index_CUMULATIVE_COST = self.get_header_index(HEADER_CUMULATIVE_COST) index_PROBABILITY = self.get_header_index(HEADER_PROBABILITY) index_CUMULATIVE_PROBABILITY = self.get_header_index( HEADER_CUMULATIVE_PROBABILITY) with SpeedUpTable(self): fs_items = fsl.gear_list fs_cost = fsl.fs_cost cum_fs_cost = fsl.fs_cum_cost this_gear = fsl.secondary_gear bti_m_o = this_gear.gear_type.bt_start - 1 prv_num = fsl.starting_pos for i, num in enumerate(fsl.secondary_map): fsg = this_gear.gear_type.get_fs_gain(bti_m_o + i) for j in range(0, num): rc = self.rowCount() self.insertRow(rc) self.setItem(rc, index_FS, QTableWidgetItem(str(prv_num))) two = GearWidget(fs_items[prv_num], model, edit_able=False, display_full_name=True) two.add_to_table(self, rc, col=index_GEAR) this_cost = numpy.sum(fs_cost[prv_num:prv_num + fsg]) twi = monnies_twi_factory(this_cost) self.setItem(rc, index_COST, twi) this_cum_cost = cum_fs_cost[min( len(cum_fs_cost) - 1, prv_num + fsg)] twi = monnies_twi_factory(this_cum_cost) self.setItem(rc, index_CUMULATIVE_COST, twi) prv_num += fsg if prv_num > settings[settings.P_NUM_FS]: return
def table_FS_add_gear(self, this_gear: Gear, check_state=Qt.Checked): frmMain = self.frmMain model = self.enh_model settings = model.settings rc = self.rowCount() with SpeedUpTable(self): self.insertRow(rc) with QBlockSig(self): # If the rows are not initialized then the context menus will bug out for i in range(0, self.columnCount()): twi = QTableWidgetItem('') self.setItem(rc, i, twi) twi_gt = QTableWidgetItem( ) # Hidden behind the combo box displays number (for sorting?) twi_lvl = QTableWidgetItem( ) # Hidden behind the combo box displays number (for sorting?) f_two = GearWidget(this_gear, model, default_icon=pix.get_icon(STR_LENS_PATH), check_state=check_state, edit_able=True) f_two.sig_error.connect(self.frmMain.sig_show_message) f_two.context_menu = QMenu( f_two ) # Don't want upgrade / downgrade options on this type of gear self.make_menu(f_two.context_menu) f_two.create_Cmbs(self) cmb_gt = f_two.cmbType cmb_enh = f_two.cmbLevel cmb_gt.currentTextChanged.connect( lambda x: set_cell_color_compare(twi_gt, x)) cmb_enh.currentTextChanged.connect(lambda x: set_cell_lvl_compare( twi_lvl, x, this_gear.gear_type)) with QBlockSig(self): f_two.add_to_table(self, rc, col=0) self.setCellWidget(rc, 1, cmb_gt) twi = monnies_twi_factory(this_gear.base_item_cost) self.setItem(rc, 2, twi) self.setCellWidget(rc, 3, cmb_enh) self.setItem(rc, 1, twi_gt) self.setItem(rc, 3, twi_lvl) set_cell_lvl_compare(twi_lvl, cmb_enh.currentText(), this_gear.gear_type) set_cell_color_compare(twi_gt, cmb_gt.currentText()) f_two.chkInclude.stateChanged.connect( lambda x: self.gw_check_state_changed(f_two, x)) self.clearSelection() self.selectRow(rc) with QBlockSig(self): self.cellWidget(rc, 1).currentTextChanged.connect( frmMain.invalidate_fs_list) self.cellWidget(rc, 3).currentTextChanged.connect( frmMain.invalidate_fs_list) self.resizeColumnToContents(0) f_two.sig_gear_changed.connect(self.fs_gear_sig_gear_changed)
def update_genome(self): tree = self.treeWidget() idx_GENOME = tree.get_header_index(HEADER_GENOME) with QBlockSig(self.treeWidget()): self.setText(idx_GENOME, str(self.fsl.get_gnome()))
def update_num_fs(self): tree = self.treeWidget() idx_NUM_FS = tree.get_header_index(HEADER_NUM_FS) with QBlockSig(self.treeWidget()): self.setText(idx_NUM_FS, str(self.fsl.num_fs))