def __init__(self, parent, known_blueprints, new_blueprints): """Blueprint library management dialog.""" self.dialog = QDialog(parent) self.ui = qt_blueprints.Ui_Dialog() self.ui.setupUi(self.dialog) assets_db_file = Config().read("assets_db") starbound_folder = Config().read("starbound_folder") self.assets = Assets(assets_db_file, starbound_folder) self.blueprints = self.assets.blueprints() self.known_blueprints = known_blueprints self.new_blueprints = new_blueprints # populate known list self.ui.known_blueprints.clear() for blueprint in self.known_blueprints: if blueprint is not None: self.ui.known_blueprints.addItem(BlueprintItem(blueprint)) self.ui.known_blueprints.sortItems(0) # populate initial available list self.ui.available_blueprints.clear() for blueprint in self.blueprints.get_all_blueprints(): self.ui.available_blueprints.addItem(blueprint[6]) # populate category combobox for cat in self.blueprints.get_categories(): self.ui.category.addItem(cat) if len(self.new_blueprints) == 0: self.ui.clear_new_button.setEnabled(False) self.ui.add_button.clicked.connect(self.add_blueprint) self.ui.remove_button.clicked.connect(self.remove_blueprint) self.ui.filter.textChanged.connect(self.update_available_list) self.ui.category.currentTextChanged.connect(self.update_available_list) self.ui.available_blueprints.itemSelectionChanged.connect( self.update_blueprint_info) self.ui.clear_new_button.clicked.connect(self.clear_new_blueprints) self.ui.available_blueprints.setCurrentRow(0) self.ui.filter.setFocus() self.update_blueprint_info()
def __init__(self, parent, known_blueprints): """Blueprint library management dialog.""" # BUG: some of the tier weapons are not importing correctly and showing # as duplicates in the available list # UPDATE: okay i think that's just caused by stripping the data? self.dialog = QDialog(parent) self.ui = qt_blueprints.Ui_Dialog() self.ui.setupUi(self.dialog) assets_db_file = Config().read("assets_db") starbound_folder = Config().read("starbound_folder") self.assets = assets.Assets(assets_db_file, starbound_folder) self.blueprints = self.assets.blueprints() self.known_blueprints = known_blueprints # populate known list self.ui.known_blueprints.clear() for blueprint in self.known_blueprints: self.ui.known_blueprints.addItem(BlueprintItem(blueprint)) self.ui.known_blueprints.sortItems(0) # populate initial available list self.ui.available_blueprints.clear() for blueprint in self.blueprints.get_all_blueprints(): self.ui.available_blueprints.addItem(blueprint[4]) # populate category combobox for cat in self.blueprints.get_categories(): self.ui.category.addItem(cat) self.ui.add_button.clicked.connect(self.add_blueprint) self.ui.remove_button.clicked.connect(self.remove_blueprint) self.ui.filter.textChanged.connect(self.update_available_list) self.ui.category.currentTextChanged.connect(self.update_available_list) self.ui.filter.setFocus()