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, 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 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_default_device(self, had_default=None): config = {"platform": self._platform} for port in range(1, 4 + 1): key = "{}_port_{}".format(self._platform, port) if self.port == port: config[key] = "" else: config[key] = LauncherConfig.get(key) key = "{}_port_{}_type".format(self._platform, port) config[key] = LauncherConfig.get(key) # config[key] = DeviceManager.get_calculated_port_mode( # LauncherConfig, port) device = DeviceManager.get_non_amiga_device_for_port(config, self.port) default_description = "{} (*)".format(fix_device_name(device.name)) # print("default_description = ", default_description) if had_default is None: had_default = (self.get_index() == 0) # print("had default", had_default, self.get_index()) self.set_item_text(0, default_description) # print("had_default", had_default) if had_default: # print("set text for", self.port, default_description) # self.set_index(1) self.set_text(default_description) self.set_index(0)
def update_config_key(self): if self.mode == self.CD_MODE: self.config_key = "cdrom_drive_{}".format(self.drive) self.config_key_sha1 = "x_cdrom_drive_{}_sha1".format(self.drive) self.config_key_implicit = "__implicit_cdrom_drive_count" elif self.mode == self.TAPE_MODE: self.config_key = "tape_drive_{}".format(self.drive) self.config_key_sha1 = "x_tape_drive_{}_sha1".format(self.drive) self.config_key_implicit = "__implicit_tape_drive_count" elif self.mode == self.CARTRIDGE_MODE: if self.drive == 0: self.config_key = Option.CARTRIDGE_SLOT self.config_key_sha1 = "x_cartridge_slot_sha1" else: self.config_key = "cartridge_drive_{}".format(self.drive) self.config_key_sha1 = "x_cartridge_drive_{}_sha1".format( self.drive) self.config_key_implicit = "__implicit_cartridge_drive_count" else: self.config_key = "floppy_drive_{}".format(self.drive) self.config_key_sha1 = "x_floppy_drive_{}_sha1".format(self.drive) self.config_key_implicit = \ "__implicit_uae_floppy{}type".format(self.drive) self.on_config(self.config_key, LauncherConfig.get(self.config_key)) self.on_config(self.config_key_implicit, LauncherConfig.get(self.config_key_implicit))
def on_browse_button(self, extended=False): default_dir = FSGSDirectories.get_kickstarts_dir() if extended: title = gettext("Choose Extended ROM") key = "kickstart_ext_file" else: title = gettext("Choose Kickstart ROM") key = "kickstart_file" dialog = LauncherFilePicker(self.get_window(), title, "rom", LauncherConfig.get(key)) if not dialog.show_modal(): return path = dialog.get_path() checksum_tool = ChecksumTool(self.get_window()) sha1 = checksum_tool.checksum_rom(path) dir_path, file = os.path.split(path) if extended: self.ext_text_field.set_text(file) else: self.text_field.set_text(file) if os.path.normcase(os.path.normpath(dir_path)) == \ os.path.normcase(os.path.normpath(default_dir)): path = file if extended: LauncherConfig.set_multiple([("kickstart_ext_file", path), ("x_kickstart_ext_file", path), ("x_kickstart_ext_file_sha1", sha1)]) else: LauncherConfig.set_multiple([("kickstart_file", path), ("x_kickstart_file", path), ("x_kickstart_file_sha1", sha1)])
def set_config_handlers(self): if self.mode_choice is not None: self.mode_choice.on_changed = self.on_mode_changed self.device_choice.on_changed = self.on_device_changed LauncherConfig.add_listener(self) LauncherSignal.add_listener("settings_updated", self) LauncherSignal.add_listener("device_list_updated", self)
def __init__(self, parent): parent.__amiga_enable_behavior = self self._parent = weakref.ref(parent) LauncherConfig.add_listener(self) # FIXME: We need to disconnect the listener parent.destroyed.connect(self.on_destroy)
def on_activate_item(self, item): path = LauncherConfig.get(self.file_key.format(item)) sha1 = LauncherConfig.get(self.sha1_key.format(item)) if self.cd_mode: pass else: fsgs.amiga.insert_floppy_in_free_drive(path, sha1=sha1)
def initialize_from_config(self): self.on_config(self.device_option_key, LauncherConfig.get(self.device_option_key)) self.on_config(self.mode_option_key, LauncherConfig.get(self.mode_option_key)) self.on_config(self.autofire_mode_option_key, LauncherConfig.get(self.autofire_mode_option_key))
def get_initial_text(): text = "" # FIXME: accessing values directly here, not very nice keys = app.settings.values.keys() for key in sorted(keys): if key in LauncherSettings.default_settings: continue # if key in LauncherConfig.config_keys: # # print("(settings) ignoring key", key) # text += "\n# {0} is ignored here " \ # "(use config dialog instead)\n".format(key) if LauncherConfig.is_config_only_option(key): text += ( "\n# {0} will here function as a global config " "default and may cause\nunexpected problems. It is " "recommended to only use this as a per-config " "option.\n".format(key) ) value = app.settings[key] if LauncherConfig.get(key): text += ( "\n# {0} is overridden by current " "configuration\n".format(key) ) text += "{0} = {1}\n".format(key, value) if LauncherConfig.get(key): text += "\n" if key in LauncherConfig.config_keys: text += "\n" return text
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 get_initial_text(): text = "" # FIXME: accessing values directly here, not very nice keys = app.settings.values.keys() for key in sorted(keys): if key in LauncherSettings.default_settings: continue # if key in LauncherConfig.config_keys: # # print("(settings) ignoring key", key) # text += "\n# {0} is ignored here " \ # "(use config dialog instead)\n".format(key) if LauncherConfig.is_config_only_option(key): text += ("\n# {0} will here function as a global config " "default and may cause\nunexpected problems. It is " "recommended to only use this as a per-config " "option.\n".format(key)) value = app.settings[key] if LauncherConfig.get(key): text += "\n# {0} is overridden by current " \ "configuration\n".format(key) text += "{0} = {1}\n".format(key, value) if LauncherConfig.get(key): text += "\n" if key in LauncherConfig.config_keys: text += "\n" return text
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 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 on_model_changed(self): print("ModelGroup.on_model_change\n") index = self.model_choice.get_index() model = self.model_ids[index] if model == "A500": # The default model (A500) can be specified with the empty string model = "" LauncherConfig.set("amiga_model", model)
def load_variant(self, item): try: self._load_variant(item) # raise Exception() except Exception: traceback.print_exc() LauncherConfig.load_default_config() LauncherConfig.load({"__error": "Error Loading Configuration"}) self.select_item(None)
def __init__(self, parent, platforms): self.platforms = set(platforms) parent.__platform_behavior = self self._parent = weakref.ref(parent) self.on_config("platform", LauncherConfig.get("platform")) LauncherConfig.add_listener(self) # FIXME: We need to disconnect the listener parent.destroyed.connect(self.on_destroy)
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): 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 on_changed(self): index = self.get_index() value = self.device_values[index] if value != "none": # Reset to default device for other ports using the same device. for port in range(1, 4 + 1): if self.port == port: continue key = "{}_port_{}".format(self._platform, port) if LauncherConfig.get(key) == value: LauncherConfig.set(key, "") LauncherConfig.set(self.device_option_key, value)
def add_config_warnings(self): # FIXME: move such warnings to config model code instead if (self.chip_memory_calculated and self.chip_memory_calculated < 2048 and self.amiga_model_calculated in ["A1200", "A4000"]): text = gettext("{amiga_model} with < 2 MB chip memory").format( amiga_model=self.amiga_model) self.warnings.append((WARNING_LEVEL, text, "")) if LauncherConfig.get("amiga_model") == "A4000/OS4": if LauncherConfig.get("jit_compiler") == "1": text = gettext( "JIT compiler with a PPC-only OS is not recommended") self.warnings.append((WARNING_LEVEL, text, ""))
def browse(self, dir_mode): default_dir = FSGSDirectories.get_hard_drives_dir() dialog = LauncherFilePicker( self.get_window(), gettext("Choose Hard Drive"), "hd", LauncherConfig.get(self.config_key), dir_mode=dir_mode, ) if not dialog.show_modal(): dialog.destroy() return path = dialog.get_path() dialog.destroy() checksum_tool = ChecksumTool(self.get_window()) sha1 = "" if dir_mode: print("not calculating HD checksums for directories") else: size = os.path.getsize(path) if size < 64 * 1024 * 1024: sha1 = checksum_tool.checksum(path) else: print("not calculating HD checksums HD files > 64MB") full_path = path # FIXME: use contract function dir_path, file = os.path.split(path) self.text_field.set_text(file) if os.path.normcase(os.path.normpath(dir_path)) == os.path.normcase( os.path.normpath(default_dir) ): path = file self.text_field.set_text(path) values = [(self.config_key, path), (self.config_key_sha1, sha1)] if self.index == 0: # whdload_args = "" # dummy, ext = os.path.splitext(path) # if not dir_mode and ext.lower() in Archive.extensions: # try: # whdload_args = self.calculate_whdload_args(full_path) # except Exception: # traceback.print_exc() # values.append(("x_whdload_args", whdload_args)) values.extend( whdload.generate_config_for_archive( full_path, model_config=False ).items() ) LauncherConfig.set_multiple(values)
def __init__(self, parent, names): parent.__config_enable_behavior = self self._parent = weakref.ref(parent) self._names = set(names) LauncherConfig.add_listener(self) try: parent.destroyed.connect(self.on_parent_destroyed) except AttributeError: print("WARNING: ConfigBehavior without remove_listener " "implementation") for name in names: # Broadcast initial value self.on_config(name, LauncherConfig.get(name))
def function(): if progress == "__run__": self.cancel_button.disable() # Hide dialog after 1.5 seconds. The reason for delaying it # is to avoid "confusing" flickering if/when the dialog is # only shown for a split second. # fsui.call_later(1500, hide_function) LauncherConfig.set( "__progress", gettext("Running: Emulator")) else: self.sub_title_label.set_text(progress) LauncherConfig.set( "__progress", "Preparing: {}".format(progress))
def add_config_warnings(self): # FIXME: move such warnings to config model code instead if self.chip_memory_calculated and \ self.chip_memory_calculated < 2048 and \ self.amiga_model_calculated in ["A1200", "A4000"]: text = gettext("{amiga_model} with < 2 MB chip memory").format( amiga_model=self.amiga_model) self.warnings.append((WARNING_LEVEL, text, "")) if LauncherConfig.get("amiga_model") == "A4000/OS4": if LauncherConfig.get("jit_compiler") == "1": text = gettext( "JIT compiler with a PPC-only OS is not recommended") self.warnings.append((WARNING_LEVEL, text, ""))
def new_config(config): settings = Settings().instance() if Product.default_platform_id: platform_id = Product.default_platform_id elif openretro or settings.get(Option.PLATFORMS_FEATURE): platform_id = config.get(Option.PLATFORM) else: platform_id = None LauncherConfig.load_default_config(platform=platform_id) # Settings.set("config_changed", "1") settings.set(PARENT_UUID, "")
def on_device_changed(self): index = self.device_choice.get_index() value = self.joystick_values[index] if value != "none": # Reset to default device for other ports using the same device. for port in range(4): if self.port == port: continue key = "joystick_port_{0}".format(port) if LauncherConfig.get(key) == value: LauncherConfig.set(key, "") LauncherConfig.set(self.device_option_key, value)
def create_list(self): items = [] if self.cd_mode: max_items = Amiga.MAX_CDROM_IMAGES else: max_items = Amiga.MAX_FLOPPY_IMAGES for i in range(max_items): path = LauncherConfig.get(self.file_key.format(i)) sha1 = LauncherConfig.get(self.sha1_key.format(i)) if not path: continue items.append((path, sha1)) return items
def start_local_game(cls): print("START LOCAL GAME") print("x_missing_files", LauncherConfig.get("x_missing_files")) if LauncherConfig.get("x_missing_files"): if LauncherConfig.get("download_file"): if LauncherConfig.get("download_terms") and not \ Downloader.check_terms_accepted( LauncherConfig.get("download_file"), LauncherConfig.get("download_terms")): from .ui.launcherwindow import LauncherWindow dialog = DownloadTermsDialog(LauncherWindow.current(), fsgs) if not dialog.show_modal(): return elif LauncherConfig.get("download_page"): from .ui.launcherwindow import LauncherWindow # fsui.show_error(_("This game must be downloaded first.")) DownloadGameWindow(LauncherWindow.current(), fsgs).show() return else: fsui.show_error( gettext("This game variant cannot be started " "because you don't have all required files.")) return platform_id = LauncherConfig.get(Option.PLATFORM).lower() if platform_id in AMIGA_PLATFORMS: cls.start_local_game_amiga() else: cls.start_local_game_other()
def start_local_game(cls): print("START LOCAL GAME") print("x_missing_files", LauncherConfig.get("x_missing_files")) if LauncherConfig.get("x_missing_files"): if LauncherConfig.get("download_file"): if LauncherConfig.get("download_terms") and not \ Downloader.check_terms_accepted( LauncherConfig.get("download_file"), LauncherConfig.get("download_terms")): from .ui.launcher_window import LauncherWindow dialog = DownloadTermsDialog(LauncherWindow.current(), fsgs) if not dialog.show_modal(): return elif LauncherConfig.get("download_page"): from .ui.launcher_window import LauncherWindow # fsui.show_error(_("This game must be downloaded first.")) DownloadGameWindow(LauncherWindow.current(), fsgs).show() return else: fsui.show_error( gettext("This game variant cannot be started " "because you don't have all required files.")) return platform_id = LauncherConfig.get("platform").lower() amiga_platform = platform_id in ["", "amiga", "cdtv", "cd32"] if amiga_platform: cls.start_local_game_amiga() else: cls.start_local_game_other()
def browse(self, dir_mode): default_dir = FSGSDirectories.get_hard_drives_dir() dialog = LauncherFilePicker( self.get_window(), gettext("Choose Hard Drive"), "hd", LauncherConfig.get(self.config_key), dir_mode=dir_mode, ) if not dialog.show_modal(): dialog.destroy() return path = dialog.get_path() dialog.destroy() checksum_tool = ChecksumTool(self.get_window()) sha1 = "" if dir_mode: print("not calculating HD checksums for directories") else: size = os.path.getsize(path) if size < 64 * 1024 * 1024: sha1 = checksum_tool.checksum(path) else: print("not calculating HD checksums HD files > 64MB") full_path = path # FIXME: use contract function dir_path, file = os.path.split(path) self.text_field.set_text(file) if os.path.normcase(os.path.normpath(dir_path)) == os.path.normcase( os.path.normpath(default_dir)): path = file self.text_field.set_text(path) values = [(self.config_key, path), (self.config_key_sha1, sha1)] if self.index == 0: # whdload_args = "" # dummy, ext = os.path.splitext(path) # if not dir_mode and ext.lower() in Archive.extensions: # try: # whdload_args = self.calculate_whdload_args(full_path) # except Exception: # traceback.print_exc() # values.append(("x_whdload_args", whdload_args)) values.extend( whdload.generate_config_for_archive( full_path, model_config=False).items()) LauncherConfig.set_multiple(values)
def set_rating_for_variant(variant_uuid, rating): # FIXME: Do asynchronously, add to queue client = OAGDClient() client.rate_variant(variant_uuid, like=rating) like_rating = client.get("like", 0) work_rating = client.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() LauncherConfig.set("variant_rating", str(like_rating))
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() LauncherConfig.set("variant_rating", str(like_rating))
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 set_new_config(self, items): if self.cd_mode: max_items = Amiga.MAX_CDROM_IMAGES else: max_items = Amiga.MAX_FLOPPY_IMAGES set_list = [] for i in range(max(max_items, len(items))): if i >= max_items: break elif i >= len(items): path, sha1 = "", "" else: path, sha1 = items[i] set_list.append((self.file_key.format(i), path)) set_list.append((self.sha1_key.format(i), sha1)) LauncherConfig.set_multiple(set_list)
def update_sub_models(self, model_id, sub_model_id): sub_model_index = 0 model_id_s = model_id + "/" self.sub_model_ids.clear() self.sub_model_titles.clear() for i, config in enumerate(Amiga.models): if config["id"] == model_id: self.sub_model_ids.append("") self.sub_model_titles.append(config["subtitle"]) elif config["id"].startswith(model_id_s): self.sub_model_ids.append(config["id"].split("/", 1)[1]) self.sub_model_titles.append(config["subtitle"]) else: continue if sub_model_id == self.sub_model_ids[-1]: sub_model_index = len(self.sub_model_ids) - 1 self.sub_model_choice.clear() for title in self.sub_model_titles: self.sub_model_choice.add_item(title) self.sub_model_choice.enable( LauncherConfig.get(Option.PLATFORM) in AMIGA_PLATFORMS and len(self.sub_model_ids) > 1 ) return sub_model_index
def start_local_game_other(cls): database_name = LauncherConfig.get("__database") variant_uuid = LauncherConfig.get("variant_uuid") assert variant_uuid fsgs.game.set_from_variant_uuid(database_name, variant_uuid) platform_handler = PlatformHandler.create(fsgs.game.platform.id) runner = platform_handler.get_runner(fsgs) task = RunnerTask(runner) from .ui.launcher_window import LauncherWindow dialog = LaunchDialog( LauncherWindow.current(), gettext("Launching Game"), task) dialog.show() LauncherConfig.set("__running", "1") task.start()
def on_ext_rom_type_changed(self): index = self.ext_rom_type_choice.get_index() if index == 0: if LauncherConfig.get("kickstart_ext_file") == "": return LauncherConfig.set("kickstart_ext_file", "") else: LauncherConfig.set("kickstart_ext_file", LauncherConfig.get("x_kickstart_ext_file")) LauncherConfig.update_kickstart()
def __init__(self, parent): StatusElement.__init__(self, parent) # self.set_min_width(140) self.layout = HorizontalLayout() self.icon = Image("launcher:res/16/world_link.png") self.right_icon = Image("launcher:res/16/drop_down_arrow.png") self.right_icon_disabled = Image( "launcher:res/16/drop_down_arrow_disabled.png") # self.inactive_icon = self.active_icon.grey_scale() self.text = gettext("Web Links") LauncherConfig.add_listener(self) self.on_config("protection", LauncherConfig.get("protection")) self.have = set() for key in url_keys: self.on_config(key, LauncherConfig.get(key))
def on_left_down(self): if len(self.have) == 0: return menu = Menu() for key, description in url_descriptions: value = LauncherConfig.get(key, "") if value: menu.add_item(description, create_open_url_function(value)) self.popup_menu(menu)
def on_browse_button(self, extended=False): default_dir = FSGSDirectories.get_kickstarts_dir() if extended: title = gettext("Choose Extended ROM") key = "kickstart_ext_file" else: title = gettext("Choose Kickstart ROM") key = "kickstart_file" dialog = LauncherFilePicker( self.get_window(), title, "rom", LauncherConfig.get(key) ) if not dialog.show_modal(): return path = dialog.get_path() checksum_tool = ChecksumTool(self.get_window()) sha1 = checksum_tool.checksum_rom(path) dir_path, file = os.path.split(path) if extended: self.ext_text_field.set_text(file) else: self.text_field.set_text(file) if os.path.normcase(os.path.normpath(dir_path)) == os.path.normcase( os.path.normpath(default_dir) ): path = file if extended: LauncherConfig.set_multiple( [ ("kickstart_ext_file", path), ("x_kickstart_ext_file", path), ("x_kickstart_ext_file_sha1", sha1), ] ) else: LauncherConfig.set_multiple( [ ("kickstart_file", path), ("x_kickstart_file", path), ("x_kickstart_file_sha1", sha1), ] )
def update_config(self): text = self.text_area.get_text() update_config = {} # First mark all unknown config values as cleared for key in list(fsgs.config.values.keys()): if key not in LauncherConfig.default_config: update_config[key] = "" # Then we overwrite with specific values for line in text.split("\n"): line = line.strip() parts = line.split("=", 1) if len(parts) == 2: key = parts[0].strip() # if key in Config.no_custom_config: # continue value = parts[1].strip() update_config[key] = value # Finally, set everything at once LauncherConfig.set_multiple(update_config.items())
def multi_select(cls, parent=None): default_dir = FSGSDirectories.get_cdroms_dir() dialog = LauncherFilePicker( parent, gettext("Select Multiple CD-ROMs"), "cd", multiple=True ) if not dialog.show_modal(): return paths = dialog.get_paths() paths.sort() # checksum_tool = ChecksumTool(parent) for i, path in enumerate(paths): # sha1 = checksum_tool.checksum(path) sha1 = "" print("FIXME: not calculating CD checksum just yet") path = Paths.contract_path(path, default_dir) if i < 1: LauncherConfig.set_multiple( [ ("cdrom_drive_{0}".format(i), path), ("x_cdrom_drive_{0}_sha1".format(i), sha1), ] ) LauncherConfig.set_multiple( [ ("cdrom_image_{0}".format(i), path), ("x_cdrom_image_{0}_sha1".format(i), sha1), ] ) # blank the rest of the drives for i in range(len(paths), 1): LauncherConfig.set_multiple( [ ("cdrom_drive_{0}".format(i), ""), ("x_cdrom_drive_{0}_sha1".format(i), ""), ] ) # Config.set("x_cdrom_drive_{0}_sha1".format(i), "") # Config.set("x_cdrom_drive_{0}_name".format(i), "") # blank the rest of the image list for i in range(len(paths), Amiga.MAX_CDROM_IMAGES): LauncherConfig.set_multiple( [ ("cdrom_image_{0}".format(i), ""), ("x_cdrom_image_{0}_sha1".format(i), ""), ] )
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 on_sub_model_changed(self): print("ModelGroup.on_sub_model_change\n") if self.sub_model_updating: print("sub model list is currently updating") return index = self.sub_model_choice.get_index() # if index == 0: # # The default model (A500) can be specified with the empty string # model = "" # else: model = self.model_ids[self.model_choice.get_index()] sub_model = self.sub_model_ids[index] if sub_model: LauncherConfig.set("amiga_model", model + "/" + sub_model) else: LauncherConfig.set("amiga_model", model) if Amiga.is_cd_based(LauncherConfig): FloppyManager.clear_all() else: CDManager.clear_all()
def on_config(self, key, value): if key in JOYSTICK_KEYS: prev_value = self.using_joy_emu devices = DeviceManager.get_devices_for_ports(LauncherConfig) for device in devices: if device.id == "keyboard": self.using_joy_emu = True break else: self.using_joy_emu = False if prev_value != self.using_joy_emu: self.rebuild_warnings_and_refresh() elif key.startswith("__"): pass # elif LauncherConfig.is_implicit_option(key): # pass elif LauncherConfig.is_custom_uae_option(key): changed = False if value: if key not in self.custom_uae_config: self.custom_uae_config.add(key) changed = True else: if key in self.custom_uae_config: self.custom_uae_config.remove(key) changed = True if changed: self.rebuild_warnings_and_refresh() elif LauncherConfig.is_custom_option(key): changed = False if value: if key not in self.custom_config: self.custom_config.add(key) changed = True else: if key in self.custom_config: self.custom_config.remove(key) changed = True if changed: self.rebuild_warnings_and_refresh()
def do_update(self): if not self.dirty: return self.dirty = False print("ImplicitConfigHandler.do_update") implicit = ImplicitConfig(ConfigProxy(), SettingsProxy()) # failed = False try: expand_config(implicit, ExpandFunctions()) except Exception: traceback.print_exc() print("expand_config failed") # failed = True implicit_config = { key: "" for key in LauncherConfig.keys() if key.startswith("__implicit_")} for key, value in implicit.items(): implicit_config["__implicit_" + key] = value LauncherConfig.set_multiple(list(implicit_config.items())) if self.parent().config_browser: self.parent().config_browser.update_from_implicit(implicit)