def show(self): # quit if there are no players if len(self.players) == 0: dialog = QMessageBox(self.dialog) dialog.setWindowTitle("No Player Files") dialog.setText("No player files detected. Reselect the Starbound folder?") dialog.setInformativeText(self.player_folder) dialog.setIcon(QMessageBox.Warning) dialog.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel) answer = dialog.exec() if answer == QMessageBox.Yes: Config().remove_config() new_setup_dialog(self.dialog) dialog = QMessageBox(self.dialog) dialog.setWindowTitle("Restart Starcheat") dialog.setText("Please restart Starcheat to see changes.") dialog.setIcon(QMessageBox.Information) dialog.exec() else: self.dialog.exec()
def show(self): # quit if there are no players if len(self.players) == 0: dialog = QMessageBox(self.dialog) dialog.setWindowTitle("No Player Files") dialog.setText("No player files detected. Reselect the Starbound folder?") dialog.setInformativeText(self.player_folder) dialog.setIcon(QMessageBox.Warning) dialog.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel) answer = dialog.exec() if answer == QMessageBox.Yes: Config().remove_config() new_setup_dialog(self.dialog) dialog = QMessageBox(self.dialog) dialog.setWindowTitle("Restart starcheat") dialog.setText("Please restart starcheat to see changes.") dialog.setIcon(QMessageBox.Information) dialog.exec() else: self.dialog.exec()
def __init__(self): # check for new starcheat version online in seperate thread update_result = [None] update_thread = Thread(target=update_check_worker, args=[update_result], daemon=True) update_thread.start() """Display the main starcheat window.""" self.app = QApplication(sys.argv) self.window = StarcheatMainWindow(self) self.ui = qt_mainwindow.Ui_MainWindow() self.ui.setupUi(self.window) logging.info("Main window init") self.players = None self.filename = None self.item_browser = None # remember the last selected item browser category self.remember_browser = "<all>" self.options_dialog = None # connect action menu self.ui.actionSave.triggered.connect(self.save) self.ui.actionReload.triggered.connect(self.reload) self.ui.actionOpen.triggered.connect(self.open_file) self.ui.actionQuit.triggered.connect(self.app.closeAllWindows) self.ui.actionOptions.triggered.connect(self.new_options_dialog) self.ui.actionItemBrowser.triggered.connect(self.new_item_browser) self.ui.actionAbout.triggered.connect(self.new_about_dialog) self.ui.actionExport.triggered.connect(self.export_save) self.ui.actionExportJSON.triggered.connect(self.export_json) self.ui.actionImportJSON.triggered.connect(self.import_json) self.ui.actionMods.triggered.connect(self.new_mods_dialog) self.ui.actionImageBrowser.triggered.connect( self.new_image_browser_dialog) # set up bag tables bags = ("wieldable", "head", "chest", "legs", "back", "main_bag", "action_bar", "tile_bag", "essentials", "mouse") for bag in bags: logging.debug("Setting up %s bag", bag) self.bag_setup(getattr(self.ui, bag), bag) # signals self.ui.blueprints_button.clicked.connect(self.new_blueprint_edit) self.ui.appearance_button.clicked.connect(self.new_appearance_dialog) self.ui.techs_button.clicked.connect(self.new_techs_dialog) self.ui.name.textChanged.connect(self.set_name) self.ui.male.clicked.connect(self.set_gender) self.ui.female.clicked.connect(self.set_gender) self.ui.description.textChanged.connect(self.set_description) self.ui.pixels.valueChanged.connect(self.set_pixels) self.ui.health.valueChanged.connect( lambda: self.set_stat_slider("health")) self.ui.energy.valueChanged.connect( lambda: self.set_stat_slider("energy")) self.ui.health_button.clicked.connect(lambda: self.max_stat("health")) self.ui.energy_button.clicked.connect(lambda: self.max_stat("energy")) self.ui.name_button.clicked.connect(self.random_name) self.ui.copy_uuid_button.clicked.connect(self.copy_uuid) self.window.setWindowModified(False) logging.debug("Showing main window") self.window.show() # launch first setup if we need to if not new_setup_dialog(self.window): logging.error("Config/index creation failed") return logging.info("Starbound folder: %s", Config().read("starbound_folder")) logging.info("Checking assets hash") if not check_index_valid(self.window): logging.error("Index creation failed") return logging.info("Loading assets database") self.assets = assets.Assets(Config().read("assets_db"), Config().read("starbound_folder")) self.items = self.assets.items() # populate species combobox for species in self.assets.species().get_species_list(): self.ui.race.addItem(species) self.ui.race.currentTextChanged.connect(self.update_species) # populate game mode combobox for mode in sorted(self.assets.player().mode_types.values()): self.ui.game_mode.addItem(mode) self.ui.game_mode.currentTextChanged.connect(self.set_game_mode) # launch open file dialog self.player = None logging.debug("Open file dialog") open_player = self.open_file() # we *need* at least an initial save file if not open_player: logging.warning("No player file selected") return self.ui.name.setFocus() # block for update check result (should be ready now) update_thread.join() if update_result[0]: update_check_dialog(self.window, update_result[0]) sys.exit(self.app.exec_())
def __init__(self): """Display the main starcheat window.""" self.app = QApplication(sys.argv) self.window = StarcheatMainWindow(self) self.ui = qt_mainwindow.Ui_MainWindow() self.ui.setupUi(self.window) logging.info("Main window init") # launch first setup if we need to if not new_setup_dialog(self.window): logging.warning("Config/index creation failed") return logging.info("Starbound folder: %s", Config().read("starbound_folder")) self.filename = None logging.debug("Loading assets database") self.assets = assets.Assets(Config().read("assets_db"), Config().read("starbound_folder")) self.items = self.assets.items() self.item_browser = None # remember the last selected item browser category self.remember_browser = "<all>" self.options_dialog = None # connect action menu self.ui.actionSave.triggered.connect(self.save) self.ui.actionReload.triggered.connect(self.reload) self.ui.actionOpen.triggered.connect(self.open_file) self.ui.actionQuit.triggered.connect(self.app.closeAllWindows) self.ui.actionOptions.triggered.connect(self.new_options_dialog) self.ui.actionItemBrowser.triggered.connect(self.new_item_browser) self.ui.actionAbout.triggered.connect(self.new_about_dialog) self.ui.actionExport.triggered.connect(self.export_save) self.ui.actionExportJSON.triggered.connect(self.export_json) self.ui.actionImportJSON.triggered.connect(self.import_json) self.ui.actionMods.triggered.connect(self.new_mods_dialog) # populate species combobox for species in self.assets.species().get_species_list(): self.ui.race.addItem(species) # populate game mode combobox for mode in self.assets.player().mode_types.values(): self.ui.game_mode.addItem(mode) # set up bag tables bags = "wieldable", "head", "chest", "legs", "back", "main_bag", "action_bar", "tile_bag" for b in bags: logging.debug("Setting up %s bag", b) item_edit = getattr(self, "new_" + b + "_item_edit") getattr(self.ui, b).cellDoubleClicked.connect(item_edit) # TODO: still issues with drag drop between tables getattr(self.ui, b).setDragDropMode(QtWidgets.QAbstractItemView.InternalMove) self.ui.blueprints_button.clicked.connect(self.new_blueprint_edit) self.ui.appearance_button.clicked.connect(self.new_appearance_dialog) self.ui.techs_button.clicked.connect(self.new_techs_dialog) self.ui.name.textChanged.connect(self.set_name) self.ui.race.currentTextChanged.connect(self.update_species) self.ui.male.clicked.connect(self.set_gender) self.ui.female.clicked.connect(self.set_gender) self.ui.description.textChanged.connect(self.set_description) self.ui.pixels.valueChanged.connect(self.set_pixels) self.ui.game_mode.currentTextChanged.connect(self.set_game_mode) self.ui.energy_regen.valueChanged.connect(self.set_energy_regen) # set up stat signals self.ui.health.valueChanged.connect(lambda: self.set_stat_slider("health")) self.ui.max_health.valueChanged.connect(lambda: self.set_stat("health")) self.ui.energy.valueChanged.connect(lambda: self.set_stat_slider("energy")) self.ui.max_energy.valueChanged.connect(lambda: self.set_stat("energy")) self.ui.max_food.valueChanged.connect(lambda: self.set_stat("food")) self.ui.max_breath.valueChanged.connect(lambda: self.set_stat("breath")) self.ui.max_warmth.valueChanged.connect(lambda: self.set_stat("warmth")) self.ui.health_button.clicked.connect(lambda: self.max_stat("health")) self.ui.energy_button.clicked.connect(lambda: self.max_stat("energy")) self.ui.food_button.clicked.connect(lambda: self.max_stat("food")) self.ui.breath_button.clicked.connect(lambda: self.max_stat("breath")) # launch open file dialog self.player = None logging.debug("Open file dialog") open_player = self.open_file() # we *need* at least an initial save file if not open_player: logging.warning("No player file selected") return self.ui.name.setFocus() self.window.setWindowModified(False) logging.debug("Showing main window") self.window.show() sys.exit(self.app.exec_())
def __init__(self): # check for new starcheat version online in seperate thread update_result = [None] update_thread = Thread(target=update_check_worker, args=[update_result], daemon=True) update_thread.start() """Display the main starcheat window.""" self.app = QApplication(sys.argv) self.window = StarcheatMainWindow(self) self.ui = qt_mainwindow.Ui_MainWindow() self.ui.setupUi(self.window) logging.info("Main window init") self.players = None self.filename = None self.item_browser = None # remember the last selected item browser category self.remember_browser = "<all>" self.options_dialog = None self.preview_armor = True self.preview_bg = "#ffffff" # connect action menu self.ui.actionSave.triggered.connect(self.save) self.ui.actionReload.triggered.connect(self.reload) self.ui.actionOpen.triggered.connect(self.open_file) self.ui.actionQuit.triggered.connect(self.app.closeAllWindows) self.ui.actionOptions.triggered.connect(self.new_options_dialog) self.ui.actionItemBrowser.triggered.connect(self.new_item_browser) self.ui.actionAbout.triggered.connect(self.new_about_dialog) self.ui.actionMods.triggered.connect(self.new_mods_dialog) self.ui.actionImageBrowser.triggered.connect(self.new_image_browser_dialog) self.ui.actionExportPlayerBinary.triggered.connect(self.export_save) self.ui.actionExportPlayerJSON.triggered.connect(self.export_json) self.ui.actionImportPlayerBinary.triggered.connect(self.import_save) self.ui.actionImportPlayerJSON.triggered.connect(self.import_json) # set up bag tables bags = ("wieldable", "head", "chest", "legs", "back", "main_bag", "action_bar", "object_bag", "tile_bag", "essentials", "mouse") for bag in bags: logging.debug("Setting up %s bag", bag) self.bag_setup(getattr(self.ui, bag), bag) self.preview_setup() # signals self.ui.blueprints_button.clicked.connect(self.new_blueprint_edit) self.ui.appearance_button.clicked.connect(self.new_appearance_dialog) self.ui.techs_button.clicked.connect(self.new_techs_dialog) self.ui.quests_button.clicked.connect(self.new_quests_dialog) self.ui.ship_button.clicked.connect(self.new_ship_dialog) self.ui.name.textChanged.connect(self.set_name) self.ui.male.clicked.connect(self.set_gender) self.ui.female.clicked.connect(self.set_gender) self.ui.description.textChanged.connect(self.set_description) self.ui.pixels.valueChanged.connect(self.set_pixels) self.ui.health.valueChanged.connect(lambda: self.set_stat_slider("health")) self.ui.energy.valueChanged.connect(lambda: self.set_stat_slider("energy")) self.ui.health_button.clicked.connect(lambda: self.max_stat("health")) self.ui.energy_button.clicked.connect(lambda: self.max_stat("energy")) self.ui.copy_uuid_button.clicked.connect(self.copy_uuid) self.window.setWindowModified(False) logging.debug("Showing main window") self.window.show() # launch first setup if we need to if not new_setup_dialog(self.window): logging.error("Config/index creation failed") return logging.info("Starbound folder: %s", Config().read("starbound_folder")) logging.info("Checking assets hash") if not check_index_valid(self.window): logging.error("Index creation failed") return logging.info("Loading assets database") self.assets = Assets(Config().read("assets_db"), Config().read("starbound_folder")) self.items = self.assets.items() # populate species combobox for species in self.assets.species().get_species_list(): self.ui.race.addItem(species) self.ui.race.currentTextChanged.connect(self.update_species) # populate game mode combobox for mode in sorted(self.assets.player().mode_types.values()): self.ui.game_mode.addItem(mode) self.ui.game_mode.currentTextChanged.connect(self.set_game_mode) # launch open file dialog self.player = None logging.debug("Open file dialog") open_player = self.open_file() # we *need* at least an initial save file if not open_player: logging.warning("No player file selected") return self.ui.name.setFocus() # block for update check result (should be ready now) update_thread.join() if update_result[0]: update_check_dialog(self.window, update_result[0]) sys.exit(self.app.exec_())
def __init__(self): """Display the main starcheat window.""" self.app = QApplication(sys.argv) self.window = StarcheatMainWindow(self) self.ui = qt_mainwindow.Ui_MainWindow() self.ui.setupUi(self.window) logging.info("Main window init") # launch first setup if we need to if not new_setup_dialog(self.window): logging.warning("Config/index creation failed") return logging.info("Starbound folder: %s", Config().read("starbound_folder")) self.filename = None logging.debug("Loading assets database") self.assets = assets.Assets(Config().read("assets_db"), Config().read("starbound_folder")) self.items = self.assets.items() self.item_browser = None # remember the last selected item browser category self.remember_browser = "<all>" self.options_dialog = None # connect action menu self.ui.actionSave.triggered.connect(self.save) self.ui.actionReload.triggered.connect(self.reload) self.ui.actionOpen.triggered.connect(self.open_file) self.ui.actionQuit.triggered.connect(self.app.closeAllWindows) self.ui.actionOptions.triggered.connect(self.new_options_dialog) self.ui.actionItemBrowser.triggered.connect(self.new_item_browser) self.ui.actionAbout.triggered.connect(self.new_about_dialog) self.ui.actionExport.triggered.connect(self.export_save) self.ui.actionExportJSON.triggered.connect(self.export_json) self.ui.actionImportJSON.triggered.connect(self.import_json) self.ui.actionMods.triggered.connect(self.new_mods_dialog) # populate species combobox for species in self.assets.species().get_species_list(): self.ui.race.addItem(species) # populate game mode combobox for mode in self.assets.player().mode_types.values(): self.ui.game_mode.addItem(mode) # set up bag tables bags = "wieldable", "head", "chest", "legs", "back", "main_bag", "action_bar", "tile_bag" for b in bags: logging.debug("Setting up %s bag", b) item_edit = getattr(self, "new_" + b + "_item_edit") getattr(self.ui, b).cellDoubleClicked.connect(item_edit) # TODO: still issues with drag drop between tables getattr(self.ui, b).setDragDropMode( QtWidgets.QAbstractItemView.InternalMove) self.ui.blueprints_button.clicked.connect(self.new_blueprint_edit) self.ui.appearance_button.clicked.connect(self.new_appearance_dialog) self.ui.techs_button.clicked.connect(self.new_techs_dialog) self.ui.name.textChanged.connect(self.set_name) self.ui.race.currentTextChanged.connect(self.update_species) self.ui.male.clicked.connect(self.set_gender) self.ui.female.clicked.connect(self.set_gender) self.ui.description.textChanged.connect(self.set_description) self.ui.pixels.valueChanged.connect(self.set_pixels) self.ui.game_mode.currentTextChanged.connect(self.set_game_mode) self.ui.energy_regen.valueChanged.connect(self.set_energy_regen) # set up stat signals self.ui.health.valueChanged.connect( lambda: self.set_stat_slider("health")) self.ui.max_health.valueChanged.connect( lambda: self.set_stat("health")) self.ui.energy.valueChanged.connect( lambda: self.set_stat_slider("energy")) self.ui.max_energy.valueChanged.connect( lambda: self.set_stat("energy")) self.ui.max_food.valueChanged.connect(lambda: self.set_stat("food")) self.ui.max_breath.valueChanged.connect( lambda: self.set_stat("breath")) self.ui.max_warmth.valueChanged.connect( lambda: self.set_stat("warmth")) self.ui.health_button.clicked.connect(lambda: self.max_stat("health")) self.ui.energy_button.clicked.connect(lambda: self.max_stat("energy")) self.ui.food_button.clicked.connect(lambda: self.max_stat("food")) self.ui.breath_button.clicked.connect(lambda: self.max_stat("breath")) # launch open file dialog self.player = None logging.debug("Open file dialog") open_player = self.open_file() # we *need* at least an initial save file if not open_player: logging.warning("No player file selected") return self.ui.name.setFocus() self.window.setWindowModified(False) logging.debug("Showing main window") self.window.show() sys.exit(self.app.exec_())