def get_players(self): players_found = {} player_files = [ x for x in os.listdir(self.player_folder) if x.endswith(".player") ] total = 0 progress = QProgressDialog("Reading player files...", None, 0, len(player_files), self.dialog) progress.setWindowTitle("Reading...") progress.setWindowModality(QtCore.Qt.ApplicationModal) progress.forceShow() progress.setValue(total) try: for f in player_files: try: player = saves.PlayerSave( os.path.join(self.player_folder, f)) players_found[player.get_uuid()] = player except saves.WrongSaveVer: logging.info("Save file %s is not compatible", f) total += 1 progress.setValue(total) except FileNotFoundError: logging.exception("Could not open %s", self.player_folder) self.players = players_found self.populate()
def reload(self): """Reload the currently open save file and update GUI values.""" logging.info("Reloading file %s", self.player.filename) self.player = saves.PlayerSave(self.player.filename) self.update() self.ui.statusbar.showMessage("Reloaded " + self.player.filename, 3000) self.window.setWindowModified(False)
def get_players(self): players_found = {} try: file_list = os.listdir(self.player_folder) except FileNotFoundError: dialog = QMessageBox(self.dialog) dialog.setWindowTitle("Missing Player Folder") dialog.setText("Starbound player folder does not exist.") dialog.setInformativeText( "You may need to run Starbound for the first time.") dialog.setStandardButtons(QMessageBox.Close) dialog.setIcon(QMessageBox.Critical) dialog.exec() self.players = [] return player_files = [x for x in file_list if x.endswith(".player")] total = 0 progress = QProgressDialog("Reading player files...", None, 0, len(player_files), self.dialog) progress.setWindowTitle("Reading...") progress.setWindowModality(QtCore.Qt.ApplicationModal) progress.forceShow() progress.setValue(total) try: for f in player_files: try: player = saves.PlayerSave( os.path.join(self.player_folder, f)) uuid = player.get_uuid() preview = self.assets.species().render_player(player) players_found[uuid] = {} players_found[uuid]["player"] = player players_found[uuid]["preview"] = preview players_found[uuid]["playTime"] = player.get_play_time() except: logging.exception("Save file not compatible: %s", f) total += 1 progress.setValue(total) except FileNotFoundError: logging.exception("Could not open %s", self.player_folder) self.players = players_found self.populate()
def get_players(self): players_found = {} try: for f in os.listdir(self.player_folder): if f.endswith(".player"): try: player = saves.PlayerSave( os.path.join(self.player_folder, f)) players_found[player.get_name()] = player except saves.WrongSaveVer: logging.info("Save file %s is not compatible", f) except FileNotFoundError: logging.exception("Could not open %s", self.player_folder) self.players = players_found