def on_checkbox(): if check_box.is_checked(): spin_ctrl.set_value(int(option["default"])) spin_ctrl.disable() LauncherSettings.set(name, "") else: spin_ctrl.enable()
def center_window(cls, args, env): # FIXME: does not really belong here (dependency loop) from launcher.launcher_config import LauncherConfig from launcher.launcher_settings import LauncherSettings width = (LauncherConfig.get("window_width") or LauncherSettings.get("window_width")) height = (LauncherConfig.get("window_height") or LauncherSettings.get("window_height")) try: width = int(width) except: width = 960 try: height = int(height) except: height = 540 from launcher.ui.launcher_window import LauncherWindow if LauncherWindow.current() is None: return main_w, main_h = LauncherWindow.current().get_size() main_x, main_y = LauncherWindow.current().get_position() x = main_x + (main_w - width) // 2 y = main_y + (main_h - height) // 2 # FIXME: re-implement without wx # if windows: # import wx # y += wx.SystemSettings_GetMetric(wx.SYS_CAPTION_Y) env[str("SDL_VIDEO_WINDOW_POS")] = str("{0},{1}".format(x, y)) args.append("--window-x={0}".format(x)) args.append("--window-y={0}".format(y))
def __init__(self, database): self.database = database database_cursor = self.database.cursor() database_cursor.execute( "SELECT uuid, update_stamp, have, id FROM game " "WHERE uuid IS NOT NULL") self.existing_games = {} for row in database_cursor: self.existing_games[row[0]] = row[1], row[2], row[3] database_cursor.execute( "SELECT uuid, update_stamp, have, id FROM game_variant") self.existing_variants = {} for row in database_cursor: self.existing_variants[row[0]] = row[1], row[2], row[3] self.file_stamps = FileDatabase.get_instance().get_last_event_stamps() cached_file_stamps = self.database.get_last_file_event_stamps() self.added_files = (self.file_stamps["last_file_insert"] != cached_file_stamps["last_file_insert"]) self.deleted_files = (self.file_stamps["last_file_delete"] != cached_file_stamps["last_file_delete"]) # print(LauncherSettings.get(Option.DATABASE_LOCKER), # cached_file_stamps["database_locker"]) # assert 0 if (LauncherSettings.get(Option.DATABASE_LOCKER) != cached_file_stamps["database_locker"]): # Assume that files could be deleted or removed... if LauncherSettings.get(Option.DATABASE_LOCKER) == "0": self.deleted_files = True else: self.added_files = True
def __init__(self, parent): self.parent = weakref.ref(parent) LauncherConfig.add_listener(self) LauncherSettings.add_listener(self) self.dirty = True self.do_update() parent.destroyed.connect(self.on_parent_destroyed)
def on_setting(self, key, _): if key in [ "config_search", "game_list_uuid", "database_show_games", "database_show_adult", "database_show_unpublished", ]: # if key == "game_list_uuid": self.update_search() if len(self.items) > 0: self.select_item(None) self.select_item(0) else: # self.select_item(None) if LauncherSettings.get(PARENT_UUID): LauncherSettings.set(PARENT_UUID, "") LauncherConfig.load_default_config() elif key == "__config_refresh": self.update_search() self.select_item(None) old_parent_uuid = LauncherSettings.get(PARENT_UUID) if old_parent_uuid: LauncherSettings.set(PARENT_UUID, "") LauncherSettings.set(PARENT_UUID, old_parent_uuid) elif key == PARENT_UUID or key == "config_path": if not (LauncherSettings.get(PARENT_UUID) or LauncherSettings.get("config_path")): self.select_item(None)
def __init__(self, parent): # fsui.VerticalItemView.__init__(self, parent) fsui.ItemChoice.__init__(self, parent) self.parent_uuid = "" self.items = [] # type: list [dict] # self.last_variants = LastVariants() self.icon = fsui.Image("launcher:/data/fsuae_config_16.png") self.adf_icon = fsui.Image("launcher:/data/adf_game_16.png") self.ipf_icon = fsui.Image("launcher:/data/ipf_game_16.png") self.cd_icon = fsui.Image("launcher:/data/cd_game_16.png") self.hd_icon = fsui.Image("launcher:/data/hd_game_16.png") # self.missing_icon = fsui.Image( # "launcher:/data/missing_game_16.png") self.missing_icon = fsui.Image("launcher:/data/16x16/delete_grey.png") self.missing_color = fsui.Color(0xA8, 0xA8, 0xA8) self.blank_icon = fsui.Image("launcher:/data/16x16/blank.png") self.bullet_icon = fsui.Image("launcher:/data/16x16/bullet.png") self.manual_download_icon = fsui.Image( "launcher:/data/16x16/arrow_down_yellow.png") self.auto_download_icon = fsui.Image( "launcher:/data/16x16/arrow_down_green.png") self.up_icon = fsui.Image("launcher:/data/16x16/thumb_up_mod.png") self.down_icon = fsui.Image("launcher:/data/16x16/thumb_down_mod.png") self.fav_icon = fsui.Image("launcher:/data/rating_fav_16.png") LauncherSettings.add_listener(self) self.on_setting("parent_uuid", LauncherSettings.get("parent_uuid"))
def update_search(self): search = LauncherSettings.get("config_search").strip().lower() print("search for", search) words = [] special = [] for word in search.split(" "): word = word.strip() if not word: continue if ":" in word[1:-1]: special.append(word) else: words.append(word) terms = GameNameUtil.extract_search_terms(" ".join(words)) terms.update(special) database = Database.get_instance() try: have = int(LauncherSettings.get("database_show_games")) except ValueError: # default is show all downloadable and locally available games have = 1 items = database.find_games_new( " ".join(terms), have=have, list_uuid=LauncherSettings.get("game_list_uuid"), ) self.set_items(items)
def __init__(self, parent): StatusElement.__init__(self, parent) self.error_icon = Image("launcher:res/16/error.png") self.warning_icon = Image("launcher:res/16/warning_3.png") self.notice_icon = Image("launcher:res/16/information.png") self.icons = [ self.error_icon, self.warning_icon, self.notice_icon, ] self.coordinates = [] self.warnings = [] self.game_notice = "" self.variant_notice = "" self.variant_warning = "" self.variant_error = "" self.joy_emu_conflict = "" self.using_joy_emu = False self.kickstart_file = "" self.x_kickstart_file_sha1 = "" self.update_available = "" self.__error = "" self.x_missing_files = "" self.download_page = "" self.download_file = "" self.amiga_model = "" self.amiga_model_calculated = "" self.chip_memory = "" self.chip_memory_calculated = 0 self.outdated_plugins = [] self.custom_config = set() self.custom_uae_config = set() self.settings_config_keys = set() plugin_manager = PluginManager.instance() for plugin in plugin_manager.plugins(): if plugin.outdated: self.outdated_plugins.append(plugin.name) ConfigBehavior(self, [ "x_game_notice", "x_variant_notice", "x_variant_warning", "x_variant_error", "x_joy_emu_conflict", "amiga_model", "x_kickstart_file_sha1", "kickstart_file", "download_page", "download_file", "x_missing_files", "__error", "chip_memory", "jit_compiler"]) SettingsBehavior(self, ["__update_available"]) LauncherConfig.add_listener(self) for key in JOYSTICK_KEYS: self.on_config(key, LauncherConfig.get(key)) for key in LauncherConfig.keys(): if LauncherConfig.is_custom_uae_option(key): self.on_config(key, LauncherConfig.get(key)) elif LauncherConfig.is_custom_option(key): self.on_config(key, LauncherConfig.get(key)) LauncherSettings.add_listener(self) for key in LauncherSettings.keys(): if LauncherConfig.is_config_only_option(key): self.on_setting(key, LauncherSettings.get(key))
def update_environment_with_centering_info(self, env): # FIXME: does not really belong here (dependency loop) from launcher.launcher_config import LauncherConfig from launcher.launcher_settings import LauncherSettings width = (LauncherConfig.get("window_width") or LauncherSettings.get("window_width")) height = (LauncherConfig.get("window_height") or LauncherSettings.get("window_height")) try: width = int(width) except: width = 960 try: height = int(height) except: height = 540 from launcher.ui.launcherwindow import LauncherWindow if LauncherWindow.current() is None: return main_w, main_h = LauncherWindow.current().get_size() main_x, main_y = LauncherWindow.current().get_position() x = main_x + (main_w - width) // 2 y = main_y + (main_h - height) // 2 # FIXME: REMOVE env["FSGS_WINDOW_X"] = str(x) env["FSGS_WINDOW_Y"] = str(y) # FIXME: REMOVE env["SDL_VIDEO_WINDOW_POS"] = str("{0},{1}".format(x, y)) env["FSGS_WINDOW_CENTER"] = "{0},{1}".format(main_x + main_w // 2, main_y + main_h // 2)
def update_info(self, value=None): if LauncherSettings.get("fullscreen") != "1": self.set_text("") return if value is None: value = LauncherSettings.get("monitor") x, y, w, h = GameDriver.screen_rect_for_monitor(value) # index = GameRunner.screen_index_for_monitor(value) refresh_rate = GameDriver.screen_refresh_rate_for_monitor(value) assume_refresh_rate = LauncherSettings.get("assume_refresh_rate") if assume_refresh_rate: refresh_rate_override = " (OVERRIDING {})".format(refresh_rate) try: refresh_rate = float(assume_refresh_rate) except ValueError: refresh_rate = 0.0 else: refresh_rate_override = "" if x or y: pos_str = " ({}, {})".format(x, y) else: pos_str = "" self.set_text( "{}x{}{} @ {}Hz{}".format( w, h, pos_str, refresh_rate, refresh_rate_override ) )
def config_startup_scan(cls): if cls._config_scanned: return cls._config_scanned = True configs_dir = FSGSDirectories.get_configurations_dir() print("config_startup_scan", configs_dir) print(LauncherSettings.settings) settings_mtime = LauncherSettings.get("configurations_dir_mtime") dir_mtime = cls.get_dir_mtime_str(configs_dir) if settings_mtime == dir_mtime + "+" + str(Database.VERSION): print("... mtime not changed", settings_mtime, dir_mtime) return database = Database.get_instance() file_database = FileDatabase.get_instance() print("... database.find_local_configurations") local_configs = Database.get_instance().find_local_configurations() print("... walk configs_dir") for dir_path, dir_names, file_names in os.walk(configs_dir): for file_name in file_names: if not file_name.endswith(".fs-uae"): continue path = Paths.join(dir_path, file_name) if path in local_configs: local_configs[path] = None # already exists in database continue name, ext = os.path.splitext(file_name) # search = ConfigurationScanner.create_configuration_search( # name) scanner = ConfigurationScanner() print("[startup] adding config", path) file_database.delete_file(path=path) with open(path, "rb") as f: sha1 = hashlib.sha1(f.read()).hexdigest() file_database.add_file(path=path, sha1=sha1) game_id = database.add_configuration( path=path, name=scanner.create_configuration_name(name) ) database.update_game_search_terms( game_id, scanner.create_search_terms(name) ) for path, config_id in local_configs.items(): if config_id is not None: print("[startup] removing configuration", path) database.delete_game(id=config_id) file_database.delete_file(path=path) print("... commit") database.commit() LauncherSettings.set( "configurations_dir_mtime", cls.get_dir_mtime_str(configs_dir) + "+" + str(Database.VERSION), )
def new_config(): if openretro or settings.get(Option.PLATFORMS_FEATURE): platform_id = LauncherConfig.get(Option.PLATFORM) else: platform_id = None LauncherConfig.load_default_config(platform=platform_id) # Settings.set("config_changed", "1") LauncherSettings.set("parent_uuid", "")
def __init__(self, parent, icons): print("FullscreenToggle.__init__") super().__init__(parent, icons) self.icons = icons self.tooltip_text = gettext("Set the initial volume for the emulator") self.fullscreen_mode = False self.on_setting("volume", app.settings["volume"], initial=True) LauncherSettings.add_listener(self)
def toggle_quick_settings_sidebar(self): print("Toggling settings sidebar") if self.quick_settings_panel.visible(): self.quick_settings_panel.hide() LauncherSettings.set(Option.QUICK_SETTINGS, "0") else: self.quick_settings_panel.show() LauncherSettings.set(Option.QUICK_SETTINGS, "1") self.layout.update()
def __init__(self, parent, icons): print("FullscreenToggle.__init__") super().__init__(parent, icons) self.icons = icons self.tooltip_text = gettext( "Toggle between windowed and full-screen mode") self.fullscreen_mode = False self.on_setting("fullscreen", app.settings["fullscreen"], initial=True) LauncherSettings.add_listener(self)
def config_startup_scan(cls): if cls._config_scanned: return cls._config_scanned = True configs_dir = FSGSDirectories.get_configurations_dir() print("config_startup_scan", configs_dir) print(LauncherSettings.settings) settings_mtime = LauncherSettings.get("configurations_dir_mtime") dir_mtime = cls.get_dir_mtime_str(configs_dir) if settings_mtime == dir_mtime + "+" + str(Database.VERSION): print("... mtime not changed", settings_mtime, dir_mtime) return database = Database.get_instance() file_database = FileDatabase.get_instance() print("... database.find_local_configurations") local_configs = Database.get_instance().find_local_configurations() print("... walk configs_dir") for dir_path, dir_names, file_names in os.walk(configs_dir): for file_name in file_names: if not file_name.endswith(".fs-uae"): continue path = Paths.join(dir_path, file_name) if path in local_configs: local_configs[path] = None # already exists in database continue name, ext = os.path.splitext(file_name) # search = ConfigurationScanner.create_configuration_search( # name) scanner = ConfigurationScanner() print("[startup] adding config", path) file_database.delete_file(path=path) with open(path, "rb") as f: sha1 = hashlib.sha1(f.read()).hexdigest() file_database.add_file(path=path, sha1=sha1) game_id = database.add_configuration( path=path, name=scanner.create_configuration_name(name)) database.update_game_search_terms( game_id, scanner.create_search_terms(name)) for path, config_id in local_configs.items(): if config_id is not None: print("[startup] removing configuration", path) database.delete_game(id=config_id) file_database.delete_file(path=path) print("... commit") database.commit() LauncherSettings.set( "configurations_dir_mtime", cls.get_dir_mtime_str(configs_dir) + "+" + str(Database.VERSION), )
def on_done(): # FIXME: these should be removed soon LauncherSettings.set("last_scan", str(time.time())) LauncherSettings.set("__config_refresh", str(time.time())) # this must be called from main, since callbacks are broadcast # when settings are changed LauncherSignal.broadcast("scan_done") LauncherConfig.update_kickstart()
def __init__(self, parent): self.windowed_icon = fsui.Image("launcher:res/windowed_16.png") self.fullscreen_icon = fsui.Image("launcher:res/fullscreen_16.png") fsui.ImageButton.__init__(self, parent, self.windowed_icon) self.set_tooltip( gettext("Toggle Between Windowed and Full-Screen Mode")) self.set_min_width(40) self.fullscreen_mode = False self.on_setting("fullscreen", app.settings["fullscreen"]) LauncherSettings.add_listener(self)
def get_preferred_joysticks(cls): prefs = [] if LauncherSettings.get("primary_joystick"): prefs.append( Device.create_cmp_id(LauncherSettings.get("primary_joystick"))) if LauncherSettings.get("secondary_joystick"): prefs.append( Device.create_cmp_id( LauncherSettings.get("secondary_joystick"))) return prefs
def __init__(self, parent, icons): super().__init__(parent, icons) self.icons = icons self.monitor = "" self.tooltip_text = gettext( "Monitor to display the emulator on (left, " "middle-left, middle-right, right)") # self.on_setting("fullscreen", app.settings["fullscreen"], initial=True) self.on_setting("monitor", app.settings["monitor"], initial=True) LauncherSettings.add_listener(self)
def __init__(self, parent): self.windowed_icon = fsui.Image("launcher:res/windowed_16.png") self.fullscreen_icon = fsui.Image("launcher:res/fullscreen_16.png") fsui.ImageButton.__init__(self, parent, self.windowed_icon) self.set_tooltip( gettext("Toggle Between Windowed and Full-Screen Mode") ) self.set_min_width(40) self.fullscreen_mode = False self.on_setting("fullscreen", app.settings["fullscreen"]) LauncherSettings.add_listener(self)
def _check_platform(self, platform_option): if LauncherSettings.get(platform_option) == "1": return True if platform_option in [Option.AMIGA_DATABASE, Option.CD32_DATABASE, Option.CDTV_DATABASE]: if LauncherSettings.get(platform_option) != "0": return True return False if openretro and platform_option in OPENRETRO_DEFAULT_DATABASES: if LauncherSettings.get(platform_option) == "0": return False return True return False
def get_preferred_joysticks(cls): prefs = [] if LauncherSettings.get("primary_joystick"): prefs.append( Device.create_cmp_id(LauncherSettings.get("primary_joystick")) ) if LauncherSettings.get("secondary_joystick"): prefs.append( Device.create_cmp_id( LauncherSettings.get("secondary_joystick") ) ) return prefs
def __init__(self, parent, names): parent.__settings_enable_behavior = self self._parent = weakref.ref(parent) self._names = set(names) LauncherSettings.add_listener(self) try: parent.destroyed.connect(self.on_parent_destroyed) except AttributeError: print("WARNING: SettingsBehavior without remove_listener " "implementation") for name in names: # Broadcast initial value self.on_setting(name, LauncherSettings.get(name))
def update_title(self): if Skin.fws(): # Just want to keep "FS-UAE Launcher" in the title return auth = LauncherSettings.get(Option.DATABASE_AUTH) if auth: username = LauncherSettings.get(Option.DATABASE_USERNAME) login_info = username else: login_info = gettext("Not logged in") app_name = "{} Launcher".format(Product.base_name) title = "{} {} ({})".format(app_name, Application.instance().version, login_info) self.set_title(title)
def create_menu(self): menu = fsui.PopupMenu() if LauncherSettings.get(Option.DATABASE_AUTH): menu.add_item(gettext("Update Game Database"), self.on_update_game_database) menu.add_item(gettext("Update File Database"), self.on_update_file_database) menu.add_separator() menu.add_item(gettext("ADF Creator"), self.on_adf_creator) menu.add_item(gettext("HDF Creator"), self.on_hdf_creator) if LauncherSettings.get(Option.NETPLAY_FEATURE) != "0": menu.add_item(gettext("Net Play"), self.on_net_play) menu.add_separator() menu.add_item( gettext("Import Kickstarts") + "...", self.on_import_kickstarts) menu.add_item( gettext("Amiga Forever Import") + "...", self.on_import_kickstarts) menu.add_separator() self.add_user_menu_content(menu) menu.add_separator() # menu.add_item( # gettext("Kickstarts & ROMs"), self.on_import_kickstarts) if LauncherSettings.get(Option.LAUNCHER_SETUP_WIZARD_FEATURE): menu.add_item( gettext("Setup Wizard") + "...", self.on_setup_wizard) menu.add_preferences_item(gettext("Settings"), self.on_settings_button) menu.add_separator() menu.add_item( gettext("About {name}").format(name="OpenRetro.org"), self.on_what_is_this, ) if fsgs_module.product == "OpenRetro": app_name = "OpenRetro Launcher" else: app_name = "FS-UAE Launcher" menu.add_about_item( gettext("About {name}").format(name=app_name), self.on_about) menu.add_separator() menu.add_about_item(gettext("Quit"), self.on_quit) return menu
def set_rating_for_variant(variant_uuid, rating): # FIXME: Do asynchronously, add to queue client = OGDClient() result = client.rate_variant(variant_uuid, like=rating) like_rating = result.get("like", 0) work_rating = result.get("work", 0) database = Database.instance() cursor = database.cursor() cursor.execute("DELETE FROM rating WHERE game_uuid = ?", (variant_uuid, )) cursor.execute( "INSERT INTO rating (game_uuid, work_rating, like_rating) " "VALUES (?, ?, ?)", (variant_uuid, work_rating, like_rating)) database.commit() LauncherSettings.set("__variant_rating", str(like_rating))
def kickstart_startup_scan(cls): if cls._kickstart_scanned: return cls._kickstart_scanned = True print("kickstart_startup_scan") kickstarts_dir = FSGSDirectories.get_kickstarts_dir() if LauncherSettings.get( "kickstarts_dir_mtime" ) == cls.get_dir_mtime_str(kickstarts_dir): print("... mtime not changed") else: file_database = FileDatabase.get_instance() print("... database.find_local_roms") local_roms = file_database.find_local_roms() print("... walk kickstarts_dir") for dir_path, dir_names, file_names in os.walk(kickstarts_dir): for file_name in file_names: if not file_name.lower().endswith( ".rom" ) and not file_name.lower().endswith(".bin"): continue path = Paths.join(dir_path, file_name) if path in local_roms: local_roms[path] = None # already exists in database continue print("[startup] adding kickstart", path) ROMManager.add_rom_to_database(path, file_database) print(local_roms) for path, file_id in local_roms.items(): if file_id is not None: print("[startup] removing kickstart", path) file_database.delete_file(id=file_id) print("... commit") file_database.commit() LauncherSettings.set( "kickstarts_dir_mtime", cls.get_dir_mtime_str(kickstarts_dir) ) amiga = Amiga.get_model_config("A500") for sha1 in amiga["kickstarts"]: if fsgs.file.find_by_sha1(sha1=sha1): break else: file_database = FileDatabase.get_instance() cls.amiga_forever_kickstart_scan() file_database.commit()
def _load_variant_2(self, variant_uuid, database_name, personal_rating, have): config = get_config(self) if config.get("variant_uuid") == variant_uuid: print("Variant {} is already loaded".format(variant_uuid)) game_database = fsgs.game_database(database_name) # game_database_client = GameDatabaseClient(game_database) # try: # variant_id = game_database_client.get_game_id(variant_uuid) # except Exception: # # game not found: # print("could not find game", repr(variant_uuid)) # Config.load_default_config() # return # values = game_database_client.get_final_game_values(variant_id) try: values = game_database.get_game_values_for_uuid(variant_uuid) except Exception: # game not found: traceback.print_exc() print("could not find game", repr(variant_uuid)) LauncherConfig.load_default_config() return # values["variant_uuid"] = variant_uuid # values["variant_rating"] = str(item["personal_rating"]) LauncherConfig.load_values(values, uuid=variant_uuid) # print("--->", config.get("variant_uuid")) # variant_rating = 0 # if item["work_rating"] is not None: # variant_rating = item["work_rating"] - 2 # if item["like_rating"]: # variant_rating = item["like_rating"] # Config.set("__variant_rating", str(variant_rating)) # LauncherConfig.set("variant_uuid", variant_uuid) LauncherConfig.set("__changed", "0") LauncherConfig.set("__database", database_name) LauncherSettings.set("__variant_rating", str(personal_rating)) if int(have) < self.AVAILABLE: print(" -- some files are missing --") LauncherConfig.set("x_missing_files", "1")
def finish(self): database_cursor = self.database.cursor() # variants left in this list must now be deleted for row in self.existing_variants.values(): variant_id = row[2] database_cursor.execute("DELETE FROM game_variant WHERE id = ?", (variant_id, )) # games left in this list must now be deleted for row in self.existing_games.values(): game_id = row[2] database_cursor.execute("DELETE FROM game WHERE id = ?", (game_id, )) database_cursor.execute( "SELECT count(*) FROM game WHERE uuid IS NOT NULL " "AND (have IS NULL OR have != (SELECT coalesce(max(have), 0) " "FROM game_variant WHERE game_uuid = game.uuid))") update_rows = database_cursor.fetchone()[0] print(update_rows, "game entries need update for have field") if update_rows > 0: database_cursor.execute( "UPDATE game SET have = (SELECT coalesce(max(have), 0) FROM " "game_variant WHERE game_uuid = game.uuid) WHERE uuid IS NOT " "NULL AND (have IS NULL OR have != (SELECT coalesce(max(" "have), 0) FROM game_variant WHERE game_uuid = game.uuid))") # FIXME: Remove this line? FileDatabase.get_instance().get_last_event_stamps() self.file_stamps["database_locker"] = LauncherSettings.get( Option.DATABASE_LOCKER) self.database.update_last_file_event_stamps(self.file_stamps)
def _check_platform(self, platform_option): if LauncherSettings.get(platform_option) == "1": return True if platform_option in [ Option.AMIGA_DATABASE, Option.CD32_DATABASE, Option.CDTV_DATABASE, ]: if LauncherSettings.get(platform_option) != "0": return True return False if openretro and platform_option in OPENRETRO_DEFAULT_DATABASES: if LauncherSettings.get(platform_option) == "0": return False return True return False
def kickstart_startup_scan(cls): if cls._kickstart_scanned: return cls._kickstart_scanned = True print("kickstart_startup_scan") kickstarts_dir = FSGSDirectories.get_kickstarts_dir() if LauncherSettings.get("kickstarts_dir_mtime") == \ cls.get_dir_mtime_str(kickstarts_dir): print("... mtime not changed") else: file_database = FileDatabase.get_instance() print("... database.find_local_roms") local_roms = file_database.find_local_roms() print("... walk kickstarts_dir") for dir_path, dir_names, file_names in os.walk(kickstarts_dir): for file_name in file_names: if not file_name.lower().endswith(".rom") and not \ file_name.lower().endswith(".bin"): continue path = Paths.join(dir_path, file_name) if path in local_roms: local_roms[path] = None # already exists in database continue print("[startup] adding kickstart", path) ROMManager.add_rom_to_database(path, file_database) print(local_roms) for path, file_id in local_roms.items(): if file_id is not None: print("[startup] removing kickstart", path) file_database.delete_file(id=file_id) print("... commit") file_database.commit() LauncherSettings.set( "kickstarts_dir_mtime", cls.get_dir_mtime_str(kickstarts_dir)) amiga = Amiga.get_model_config("A500") for sha1 in amiga["kickstarts"]: if fsgs.file.find_by_sha1(sha1=sha1): break else: file_database = FileDatabase.get_instance() cls.amiga_forever_kickstart_scan() file_database.commit()
def on_remove_button(self): path = self.list_view.get_item(self.list_view.get_index()) search_path = LauncherSettings.get("search_path") search_path = [x.strip() for x in search_path.split(";") if x.strip()] for i in range(len(search_path)): if search_path[i].startswith("-"): if path == search_path[i][1:]: # Already removed. break else: if search_path[i] == path: search_path.remove(search_path[i]) break default_paths = FSGSDirectories.get_default_search_path() if path in default_paths: search_path.append("-" + path) LauncherSettings.set("search_path", ";".join(search_path))
def _check_platform(self, platform_option): if LauncherSettings.get(platform_option) == "1": return True if Product.includes_amiga() and platform_option in [ Option.AMIGA_DATABASE, Option.CD32_DATABASE, Option.CDTV_DATABASE, ]: if LauncherSettings.get(platform_option) != "0": return True return False if (Product.is_openretro() and platform_option in OPENRETRO_DEFAULT_DATABASES): if LauncherSettings.get(platform_option) == "0": return False return True return False
def _update_game_database(self, database_name, game_database): game_database_client = GameDatabaseClient(game_database) synchronizer = GameDatabaseSynchronizer( self.context, game_database_client, on_status=self.on_status, stop_check=self.stop_check, platform_id=database_name) synchronizer.username = "******" synchronizer.password = LauncherSettings.get("database_auth") synchronizer.synchronize()
def update_settings(self): text = self.text_area.get_text() # FIXME: accessing values directly here, not very nice keys = list(app.settings.values.keys()) for key in keys: if key not in LauncherSettings.default_settings: LauncherSettings.set(key, "") del app.settings.values[key] for line in text.split("\n"): line = line.strip() parts = line.split("=", 1) if len(parts) == 2: key = parts[0].strip() # if key in Settings.default_settings: # continue value = parts[1].strip() app.settings[key] = value
def set_rating_for_variant(variant_uuid, rating): # FIXME: Do asynchronously, add to queue client = OGDClient() result = client.rate_variant(variant_uuid, like=rating) like_rating = result.get("like", 0) work_rating = result.get("work", 0) database = Database.instance() cursor = database.cursor() cursor.execute( "DELETE FROM rating WHERE game_uuid = ?", (variant_uuid,) ) cursor.execute( "INSERT INTO rating (game_uuid, work_rating, like_rating) " "VALUES (?, ?, ?)", (variant_uuid, work_rating, like_rating), ) database.commit() LauncherSettings.set("__variant_rating", str(like_rating))
def observe(observer, scheduler): print(" -- new listener") # def listener(key, value): # if key == # observer.on_next(value) # Broadcast initial value observer.on_next(LauncherSettings.get(key)) listener = SettingListener(key, observer) # HACK, BECAUSE LauncherSettings do not keep ref SettingObservable.listeners.append(listener) LauncherSettings.add_listener(listener) def dispose(): SettingObservable.listeners.remove(listener) LauncherSettings.remove_listener(listener) return Disposable(dispose)
def on_add_button(self): search_path = LauncherSettings.get("search_path") search_path = [x.strip() for x in search_path.split(";") if x.strip()] path = fsui.pick_directory(parent=self.get_window()) if path: for i in range(len(search_path)): if search_path[i].startswith("-"): if path == search_path[i][1:]: search_path.remove(search_path[i]) break else: if search_path[i] == path: # Already added. break else: default_paths = FSGSDirectories.get_default_search_path() if path not in default_paths: search_path.append(path) LauncherSettings.set("search_path", ";".join(search_path))
def _scan_thread(cls, database): if cls.scan_for_files: scanner = FileScanner( cls.paths, cls.purge_other_dirs, on_status=cls.on_status, stop_check=cls.stop_check, ) scanner.scan() if cls.stop_check(): return # if cls.scan_for_configs or # if cls.update_game_database: scanner = ConfigurationScanner( cls.paths, on_status=cls.on_status, stop_check=cls.stop_check ) scanner.scan(database) if cls.update_game_database: context = SynchronizerContext() synchronizer = MetaSynchronizer( context, on_status=cls.on_status, stop_check=cls.stop_check ) synchronizer.synchronize() synchronizer = GameRatingSynchronizer( context, database, on_status=cls.on_status, stop_check=cls.stop_check, ) synchronizer.username = "******" synchronizer.password = LauncherSettings.get("database_auth") synchronizer.synchronize() synchronizer = ListsSynchronizer( context, on_status=cls.on_status, stop_check=cls.stop_check ) synchronizer.synchronize() scanner = GameScanner( context, cls.paths, on_status=cls.on_status, stop_check=cls.stop_check, ) scanner.update_game_database() scanner = GameScanner( None, cls.paths, on_status=cls.on_status, stop_check=cls.stop_check ) scanner.scan(database)
def update_environment_with_centering_info(self, env): # FIXME: does not really belong here (dependency loop) from launcher.launcher_config import LauncherConfig from launcher.launcher_settings import LauncherSettings width = LauncherConfig.get("window_width") or LauncherSettings.get( "window_width" ) height = LauncherConfig.get("window_height") or LauncherSettings.get( "window_height" ) try: width = int(width) except: width = 960 try: height = int(height) except: height = 540 from launcher.ui.launcherwindow import LauncherWindow if LauncherWindow.current() is None: return main_w, main_h = LauncherWindow.current().get_size() main_x, main_y = LauncherWindow.current().get_position() x = main_x + (main_w - width) // 2 y = main_y + (main_h - height) // 2 # FIXME: REMOVE env["FSGS_WINDOW_X"] = str(x) env["FSGS_WINDOW_Y"] = str(y) # FIXME: REMOVE env["SDL_VIDEO_WINDOW_POS"] = str("{0},{1}".format(x, y)) env["FSGS_WINDOW_POS"] = str("{0},{1}".format(x, y)) env["FSGS_WINDOW_CENTER"] = "{0},{1}".format( main_x + main_w // 2, main_y + main_h // 2 )
def _update_game_database(self, database_name, game_database): game_database_client = GameDatabaseClient(game_database) synchronizer = GameDatabaseSynchronizer( self.context, game_database_client, on_status=self.on_status, stop_check=self.stop_check, platform_id=database_name, ) synchronizer.username = "******" synchronizer.password = LauncherSettings.get("database_auth") synchronizer.synchronize()
def __init__(self, database): self.database = database database_cursor = self.database.cursor() database_cursor.execute( "SELECT uuid, update_stamp, have, id FROM game " "WHERE uuid IS NOT NULL" ) self.existing_games = {} for row in database_cursor: self.existing_games[row[0]] = row[1], row[2], row[3] database_cursor.execute( "SELECT uuid, update_stamp, have, id FROM game_variant" ) self.existing_variants = {} for row in database_cursor: self.existing_variants[row[0]] = row[1], row[2], row[3] self.file_stamps = FileDatabase.get_instance().get_last_event_stamps() cached_file_stamps = self.database.get_last_file_event_stamps() self.added_files = ( self.file_stamps["last_file_insert"] != cached_file_stamps["last_file_insert"] ) self.deleted_files = ( self.file_stamps["last_file_delete"] != cached_file_stamps["last_file_delete"] ) # print(LauncherSettings.get(Option.DATABASE_LOCKER), # cached_file_stamps["database_locker"]) # assert 0 if ( LauncherSettings.get(Option.DATABASE_LOCKER) != cached_file_stamps["database_locker"] ): # Assume that files could be deleted or removed... if LauncherSettings.get(Option.DATABASE_LOCKER) == "0": self.deleted_files = True else: self.added_files = True
def load_settings(cls): if cls.settings_loaded: return cls.settings_loaded = True settings = Settings.instance() settings.load() path = settings.path # path = app.get_settings_path() print("loading last config from " + repr(path)) if not os.path.exists(path): print("settings file does not exist") # noinspection PyArgumentList cp = ConfigParser(interpolation=None) try: cp.read([path]) except Exception as e: print(repr(e)) return for key in LauncherSettings.old_keys: if app.settings.get(key): print("[SETTINGS] Removing old key", key) app.settings.set(key, "") if fsgs.config.add_from_argv(): print("[CONFIG] Configuration specified via command line") # Prevent the launcher from loading the last used game LauncherSettings.set("parent_uuid", "") elif LauncherSettings.get("config_path"): if LauncherConfig.load_file(LauncherSettings.get("config_path")): print("[CONFIG] Loaded last configuration file") else: print("[CONFIG] Failed to load last configuration file") LauncherConfig.load_default_config() else: pass # config = {} # try: # keys = cp.options("config") # except NoSectionError: # keys = [] # for key in keys: # config[key] = fs.from_utf8_str(cp.get("config", key)) # for key, value in config.items(): # print("loaded", key, value) # fsgs.config.values[key] = value # Argument --new-config[=<platform>] new_config = "--new-config" in sys.argv new_config_platform = None for platform_id in PLATFORM_IDS: if "--new-config=" + platform_id in sys.argv: new_config = True new_config_platform = platform_id if new_config: LauncherConfig.load_default_config(platform=new_config_platform) # Prevent the launcher from loading the last used game LauncherSettings.set("parent_uuid", "")
def __init__(self, parent): fsui.Group.__init__(self, parent) self.layout = fsui.HorizontalLayout() self.layout2 = fsui.VerticalLayout() self.layout.add(self.layout2, fill=True, expand=True) layout3 = fsui.HorizontalLayout() self.layout2.add(layout3, fill=True, expand=True) self.list_view = fsui.ListView(self) self.list_view.set_min_height(130) self.default_icon = fsui.Image("launcher:res/folder_16.png") layout3.add(self.list_view, expand=True, fill=True) layout3.add_spacer(10) vlayout = fsui.VerticalLayout() layout3.add(vlayout, fill=True) add_button = IconButton(self, "add_button.png") add_button.set_tooltip(gettext("Add Directory to Search Path")) # add_button.disable() add_button.activated.connect(self.on_add_button) vlayout.add(add_button) vlayout.add_spacer(10) self.remove_button = IconButton(self, "remove_button.png") self.remove_button.set_tooltip( gettext("Remove Directory from Search Path") ) self.remove_button.disable() self.remove_button.activated.connect(self.on_remove_button) vlayout.add(self.remove_button) # self.list_view.set_items(self.get_search_path()) self.repopulate_list() self.list_view.on_select_item = self.on_select_item LauncherSettings.add_listener(self)
def update_widgets(self): value = LauncherSettings.get("video_sync") vblank = value in ["1", "auto", "full", "vblank"] full = value in ["1", "auto", "full"] # self.full_sync_checkbox.enable(vblank) self.sync_method_group.label.enable(vblank) self.sync_method_group.widget.enable(vblank) self.sync_method_group.help_button.enable(vblank) self.sync_method_label.enable(vblank) # self.smooth_label.enable(vblank) self.low_latency_group.label.enable(full) self.low_latency_group.widget.enable(full) self.low_latency_group.help_button.enable(full)
def load_settings(cls): if cls.settings_loaded: return cls.settings_loaded = True settings = Settings.instance() settings.load() path = settings.path # path = app.get_settings_path() print("loading last config from " + repr(path)) if not os.path.exists(path): print("settings file does not exist") # noinspection PyArgumentList cp = ConfigParser(interpolation=None) try: cp.read([path]) except Exception as e: print(repr(e)) return for key in LauncherSettings.old_keys: if app.settings.get(key): print("[SETTINGS] Removing old key", key) app.settings.set(key, "") if fsgs.config.add_from_argv(): print("[CONFIG] Configuration specified via command line") # Prevent the launcher from loading the last used game LauncherSettings.set("parent_uuid", "") elif LauncherSettings.get("config_path"): if LauncherConfig.load_file(LauncherSettings.get("config_path")): print("[CONFIG] Loaded last configuration file") else: print("[CONFIG] Failed to load last configuration file") LauncherConfig.load_default_config() pass
def __init__(self, parent): fsui.Choice.__init__(self, parent) # FIXME: include in () what language is currently the automatic one selected_language = LauncherSettings.get("language") k = 0 selected_index = 0 for label, language_key, icon_name in LANGUAGE_ITEMS: self.add_item(label, fsui.Image( "workspace:res/16/flag-{0}.png".format(icon_name))) if language_key == selected_language: selected_index = k k += 1 if selected_index > 0: self.set_index(selected_index)
def expand_path(cls, path, default_dir=None): if path and path[0] == "$": cmp_path = path.upper().replace("\\", "/") if cmp_path.startswith("$BASE/"): return cls.join(cls.get_base_dir(), path[6:]) if cmp_path.startswith("$CONFIG/"): # FIXME: dependency loop, have FS-UAE Launcher register # this prefix with this class instead from launcher.launcher_settings import LauncherSettings config_path = LauncherSettings.get("config_path") if config_path: return cls.join(os.path.dirname(config_path), path[8:]) if cmp_path.startswith("$HOME/"): return cls.join(cls.get_home_dir(), path[6:]) # FIXME: $base_dir is deprecated if cmp_path.startswith("$BASE_DIR/"): return cls.join(cls.get_base_dir(), path[10:]) elif not os.path.isabs(path) and default_dir is not None: return os.path.join(default_dir, path) return path
def finish(self): database_cursor = self.database.cursor() # variants left in this list must now be deleted for row in self.existing_variants.values(): variant_id = row[2] database_cursor.execute( "DELETE FROM game_variant WHERE id = ?", (variant_id,) ) # games left in this list must now be deleted for row in self.existing_games.values(): game_id = row[2] database_cursor.execute( "DELETE FROM game WHERE id = ?", (game_id,) ) database_cursor.execute( "SELECT count(*) FROM game WHERE uuid IS NOT NULL " "AND (have IS NULL OR have != (SELECT coalesce(max(have), 0) " "FROM game_variant WHERE game_uuid = game.uuid))" ) update_rows = database_cursor.fetchone()[0] print(update_rows, "game entries need update for have field") if update_rows > 0: database_cursor.execute( "UPDATE game SET have = (SELECT coalesce(max(have), 0) FROM " "game_variant WHERE game_uuid = game.uuid) WHERE uuid IS NOT " "NULL AND (have IS NULL OR have != (SELECT coalesce(max(" "have), 0) FROM game_variant WHERE game_uuid = game.uuid))" ) # FIXME: Remove this line? FileDatabase.get_instance().get_last_event_stamps() self.file_stamps["database_locker"] = LauncherSettings.get( Option.DATABASE_LOCKER ) self.database.update_last_file_event_stamps(self.file_stamps)
def get_search_path(cls): paths = FSGSDirectories.get_default_search_path() search_path = LauncherSettings.get("search_path") for p in search_path.split(";"): p = p.strip() if not p: continue elif p[0] == "-": p = p[1:] if p in paths: paths.remove(p) else: if p not in paths: paths.append(p) # The Configurations dir is always scanned on startup (whenever # modification time has changed). If we don't include it here too # always, the result will be that the configs sometimes appear (on # startup) and disappear (on scan). if not FSGSDirectories.get_configurations_dir() in paths: paths.append(FSGSDirectories.get_configurations_dir()) # Likewise, we force the Kickstarts directory to always be scanned. if not FSGSDirectories.get_kickstarts_dir() in paths: paths.append(FSGSDirectories.get_kickstarts_dir()) return paths
def on_destroy(self): LauncherSettings.remove_listener(self)