def app_main(): FSGSDirectories.initialize() Settings.instance().load() print("") print("Directories:") print("* base_dir =", FSGSDirectories.get_base_dir()) print("* cache_dir =", FSGSDirectories.get_cache_dir()) print("* cdroms_dir =", FSGSDirectories.get_cdroms_dir()) print("* configurations_dir =", FSGSDirectories.get_configurations_dir()) print("* controllers_dir =", FSGSDirectories.get_controllers_dir()) print("* covers_dir =", FSGSDirectories.get_covers_dir()) print("* data_dir =", FSGSDirectories.get_data_dir()) print("* downloads_dir =", FSGSDirectories.downloads_dir()) print("* floppies_dir =", FSGSDirectories.get_floppies_dir()) print("* hard_drives_dir =", FSGSDirectories.get_hard_drives_dir()) # print("* images_dir =", FSGSDirectories.get_images_dir()) print("* kickstarts_dir =", FSGSDirectories.get_kickstarts_dir()) print("* launcher_dir =", FSGSDirectories.get_launcher_dir()) print("* logs_dir =", FSGSDirectories.get_logs_dir()) print("* plugins_dir =", FSGSDirectories.get_plugins_dir()) # print("* portable_dir =", FSGSDirectories.portable_dir()) print("* save_states_dir =", FSGSDirectories.get_save_states_dir()) print("* screenshots_dir =", FSGSDirectories.get_screenshots_dir()) print("* screenshots_output_dir =", FSGSDirectories.screenshots_output_dir()) print("* themes_dir =", FSGSDirectories.get_themes_dir()) print("* titles_dir =", FSGSDirectories.get_titles_dir()) print("* whdload_dir =", FSGSDirectories.get_whdload_dir()) print("")
def use_audio_frequency(self): if Settings.instance()["audio_frequency"]: try: return int(Settings.instance()["audio_frequency"]) except ValueError: pass return 48000
def app_main(): FSGSDirectories.initialize() Settings.instance().verbose = False Settings.instance().load() print("base_dir", FSGSDirectories.get_base_dir()) print("cache_dir", FSGSDirectories.get_cache_dir()) print("cdroms_dir", FSGSDirectories.get_cdroms_dir()) print("configurations_dir", FSGSDirectories.get_configurations_dir()) print("controllers_dir", FSGSDirectories.get_controllers_dir()) print("covers_dir", FSGSDirectories.get_covers_dir()) print("data_dir", FSGSDirectories.get_data_dir()) print("downloads_dir", FSGSDirectories.downloads_dir()) print("floppies_dir", FSGSDirectories.get_floppies_dir()) print("hard_drives_dir", FSGSDirectories.get_hard_drives_dir()) # print("images_dir", FSGSDirectories.get_images_dir()) print("kickstarts_dir", FSGSDirectories.get_kickstarts_dir()) print("launcher_dir", FSGSDirectories.get_launcher_dir()) print("logs_dir", FSGSDirectories.get_logs_dir()) print("plugins_dir", FSGSDirectories.get_plugins_dir()) # print("portable_dir", FSGSDirectories.portable_dir()) print("save_states_dir", FSGSDirectories.get_save_states_dir()) print("screenshots_dir", FSGSDirectories.get_screenshots_dir()) print("screenshots_output_dir =", FSGSDirectories.screenshots_output_dir()) print("themes_dir", FSGSDirectories.get_themes_dir()) print("titles_dir", FSGSDirectories.get_titles_dir())
def activate(self, menu): if Settings.instance()["stretch"] == "1": Settings.instance()["stretch"] = "0" elif Settings.instance()["stretch"] == "0": Settings.instance()["stretch"] = "" else: Settings.instance()["stretch"] = "1" self.update_texture()
def save_settings(): extra = {} for key, value in fsgs.config.values.items(): if key.startswith("__"): # keys starting with __ are never saved continue extra["config/" + str(key)] = str(value) Settings.instance().save(extra=extra)
def update_texture(self): # TODO: Ideally, this class should listen for settings changes. if Settings.instance()["stretch"] == "1": texture = Texture.stretch elif Settings.instance()["stretch"] == "0": texture = Texture.square_pixels else: texture = Texture.aspect self.normal_texture = texture self.selected_texture = texture
def run(self): self.progressed("Logging out from oagd.net...") if not Settings.instance()["device_id"]: Settings.instance()["device_id"] = str(uuid4()) self.client.deauth(self.auth_token) Settings.instance()["database_username"] = "" # Settings.instance()["database_email"] = "" Settings.instance()["database_auth"] = "" Settings.instance()["database_password"] = ""
def prepare(self): print("AmigaRunner.prepare") # self.temp_dir = self.fsgs.temp_dir("amiga") # self.change_handler = GameChangeHandler(self.temp_dir) # self.firmware_dir = self.prepare_firmware("Amiga Firmware") # config = self.fsgs.config.copy() model = self.config["amiga_model"] if model.startswith("CD32"): platform = "CD32" elif model == "CDTV": platform = "CDTV" else: platform = "Amiga" # name = Settings.get("config_name") # name = self.fsgs.game.name # uuid = Config.get("x_game_uuid") # uuid = None from fsgs.SaveStateHandler import SaveStateHandler save_state_handler = SaveStateHandler(self.fsgs, self.get_name(), platform) self.config["joystick_port_0"] = self.ports[1].device_id or "" self.config["joystick_port_1"] = self.ports[0].device_id or "" self.launch_handler = LaunchHandler(self.fsgs, self.get_name(), self.config, save_state_handler, temp_dir=self.cwd.path) # self.change_handler.init(self.fsgs.get_game_state_dir(), # ignore=["*.uss", "*.sdf"]) # self.launch_handler.config["joystick_port_0"] = \ # self.inputs[1].device_id # self.launch_handler.config["joystick_port_1"] = \ # self.inputs[0].device_id if self.use_fullscreen(): self.launch_handler.config["fullscreen"] = "1" if not self.launch_handler.config.get("fullscreen_mode", ""): # Check if fullscreen mode is overridden by temporary setting. if Settings.instance()["__fullscreen_mode"]: self.launch_handler.config["fullscreen_mode"] = \ Settings.instance()["__fullscreen_mode"] else: self.launch_handler.config["fullscreen"] = "0" self.launch_handler.prepare()
def show_auto(self): if fullscreen(): geometry = screen_geometry() self.set_fullscreen(True, geometry) Settings.instance().set("__cursor_x", geometry[2]) Settings.instance().set("__cursor_y", geometry[3]) elif maximized(): x, y, w, h = screen_geometry() self.set_maximized(True, (x, y, 960, 540)) else: super().show()
def prepare(self): print("AmigaRunner.prepare") # self.temp_dir = self.fsgs.temp_dir("amiga") # self.change_handler = GameChangeHandler(self.temp_dir) # self.firmware_dir = self.prepare_firmware("Amiga Firmware") # config = self.fsgs.config.copy() model = self.config["amiga_model"] if model.startswith("CD32"): platform = "CD32" elif model == "CDTV": platform = "CDTV" else: platform = "Amiga" # name = Settings.get("config_name") # name = self.fsgs.game.name # uuid = Config.get("x_game_uuid") # uuid = None from fsgs.SaveStateHandler import SaveStateHandler save_state_handler = SaveStateHandler( self.fsgs, self.get_name(), platform) self.config["joystick_port_0"] = self.ports[1].device_id or "" self.config["joystick_port_1"] = self.ports[0].device_id or "" self.launch_handler = LaunchHandler( self.fsgs, self.get_name(), self.config, save_state_handler) # self.change_handler.init(self.fsgs.get_game_state_dir(), # ignore=["*.uss", "*.sdf"]) # self.launch_handler.config["joystick_port_0"] = \ # self.inputs[1].device_id # self.launch_handler.config["joystick_port_1"] = \ # self.inputs[0].device_id if self.use_fullscreen(): self.launch_handler.config["fullscreen"] = "1" if not self.launch_handler.config.get("fullscreen_mode", ""): # Check if fullscreen mode is overridden by temporary setting. if Settings.instance()["__fullscreen_mode"]: self.launch_handler.config["fullscreen_mode"] = \ Settings.instance()["__fullscreen_mode"] else: self.launch_handler.config["fullscreen"] = "0" self.launch_handler.prepare()
def render_top_right(self, selected=False): state = State.get() mouse_state = state.mouse_item == self mouse_pressed_state = mouse_state and state.mouse_press_item == self self.render_top_background( selected, style=TOP_ITEM_LEFT, mouse_state=mouse_state, mouse_pressed_state=mouse_pressed_state, ) gl.glDisable(gl.GL_DEPTH_TEST) fs_emu_blending(True) if Settings.instance()["video_sync"] == "1": r = 1.0 g = 1.0 b = 1.0 alpha = 1.0 else: r = 1.0 g = 1.0 b = 1.0 alpha = 0.33 x = self.x + 20 BitmapFont.title_font.render(self.title, x, self.y + 14, r=r, g=g, b=b, alpha=alpha) gl.glEnable(gl.GL_DEPTH_TEST)
def monitor(): value = check_argument("monitor") if not value: value = Settings.instance().get("monitor") if not value: value = "middle-left" return value
def use_audio_frequency(self): if self.options[Option.AUDIO_FREQUENCY]: try: return int(Settings.instance()[Option.AUDIO_FREQUENCY]) except ValueError: pass return 48000
def maximized(): if check_argument("window") == "1": return False value = check_argument("maximize") if not value: value = Settings.instance().get("arcade_maximized") return value != "0"
def __init__(self, fsgs): self.fsgs = fsgs self.args = [] self.env = {} self.emulator = "no-emulator" self.config = defaultdict(str) for key, value in Settings.instance().values.items(): # FIXME: re-enable this check? # if key in Config.config_keys: # print("... ignoring config key from settings:", key) # continue self.config[key] = value for key, value in self.fsgs.config.items(): self.config[key] = value self.ports = [] for port_info in self.PORTS: port = Port(port_info["description"]) port.types = port_info["types"] self.ports.append(port) self.__vsync = False self.__game_temp_file = None self.temp_root = TemporaryItem( root=None, prefix="fsgs-", suffix="tmp", directory=True) # self.cwd = self.create_temp_dir("cwd") # self.home = self.cwd # Default current working directory for the emulator. self.cwd = self.temp_dir("cwd") # Fake home directory for the emulator. self.home = self.temp_dir("home")
def __init__(self, fsgs): self.fsgs = fsgs self.args = [] self.env = {} self.emulator = "no-emulator" self.config = defaultdict(str) for key, value in Settings.instance().values.items(): # FIXME: re-enable this check? # if key in Config.config_keys: # print("... ignoring config key from settings:", key) # continue self.config[key] = value for key, value in self.fsgs.config.items(): self.config[key] = value self.ports = [] for port_info in self.PORTS: port = Port(port_info["description"]) port.types = port_info["types"] self.ports.append(port) self.__vsync = False self.__game_temp_file = None self.temp_root = TemporaryItem( root=None, prefix="fsgs-", suffix="tmp", dir=True) # self.cwd = self.create_temp_dir("cwd") # self.home = self.cwd # Default current working directory for the emulator. self.cwd = self.temp_dir("cwd") # Fake home directory for the emulator. self.home = self.temp_dir("home")
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 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 # FIXME: When the last loaded config was a game database config, any # options loaded via argv will be overwritten when the game config # is loaded from the database. We should be able to prevent this... fsgs.config.add_from_argv()
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 use_stretching(self): # if "--no-stretch" in sys.argv: # return False if Settings.instance()["keep_aspect"] == "1": return # if Settings.instance()["stretch"] == "0": # return False return True
def update_texture(self): # TODO: Ideally, this class should listen for settings changes. if Settings.instance()["keep_aspect"] == "0": texture = Texture.stretch else: texture = Texture.aspect self.normal_texture = texture self.selected_texture = texture
def use_fullscreen(self): # FIXME: not a very nice hack to hard-code application name here... if Application.instance(): if Application.instance().name == "fs-uae-arcade": return True if Settings.instance()["fullscreen"] == "0": return False return True
def init_options(self): for key, value in Settings.instance().values.items(): # FIXME: re-enable this check? # if key in Config.config_keys: # print("... ignoring config key from settings:", key) # continue self.options[key] = value for key, value in self.fsgc.config.items(): self.options[key] = value
def screenshots_output_dir(cls): path = Settings.instance()["screenshots_output_dir"] if not path: path = cls.portable_dir("screenshots_output_dir") if not path: path = os.path.join(get_documents_dir(), "Screenshots") if not os.path.exists(path): os.makedirs(path) return path
def fullscreen(): # If we have explicitly used --window as arguments, do # not enable fullscreen regardless of settings. if check_argument("window", ["maximize"]) in ["1", "maximize"]: return False # if check_argument("maximize") == "1": # return False value = check_argument("fullscreen") if not value: value = Settings.instance().get("arcade_fullscreen") return value != "0"
def openretro_server(): server = Settings.instance()["database_server"] if not server: server = default_openretro_server_from_file() if not server: server = default_openretro_server() if "://" in server: scheme, host = server.split("://") else: scheme = "http" host = server return scheme, host
def maximized(): # if check_argument("fullscreen") == "1": # return False # if check_argument("window") == "1": # return False # value = check_argument("window") == "maximize" value = check_argument("window", ["maximize"]) == "maximize" if value: return True else: value = Settings.instance().get("arcade_maximized") return value == "1"
def maybe_add_fake_joysticks(cls, env): settings = Settings.instance() if settings.get(Option.FAKE_JOYSTICKS): try: fake_joysticks = int(settings.get(Option.FAKE_JOYSTICKS)) except ValueError: print( "WARNING: fake_joysticks contains invalid value", repr(settings.get(Option.FAKE_JOYSTICKS)), ) else: env["FSGS_FAKE_JOYSTICKS"] = str(fake_joysticks)
def override_config(config: DefaultDict[str, str]): if should_disable_drive_click(): config[Option.FLOPPY_DRIVE_VOLUME_EMPTY] = "0" model = Settings.instance().get(Option.WHDLOAD_MODEL) if model: if model == "A1200": config[Option.AMIGA_MODEL] = "A1200" elif model == "A1200/NONCE": # The following slaves do not work with A1200 non-cycle-exact # (non-exhaustive list, only some random tests): # - Cyber World config[Option.AMIGA_MODEL] = "A1200" config[Option.ACCURACY] = "0" config[Option.CHIP_MEMORY] = "" config[Option.SLOW_MEMORY] = "" config[Option.FAST_MEMORY] = "8192"
def app_main(): args = [] for arg in sys.argv[1:]: if not arg.startswith("--"): args.append(arg) if len(args) == 0: print("Usage: fs-game-runner [options] <game_uuid | variant_uuid>") return game_or_variant_uuid = args[-1] print(game_or_variant_uuid) fsgs.load_game_by_uuid(game_or_variant_uuid) fsgs.config.add_from_argv() print("settings:fullscreen", Settings.instance()["fullscreen"]) print("config:fullscreen", fsgs.config.get("fullscreen")) fsgs.run_game()
def run(self): self.progressed("Logging into oagd.net...") if not Settings.instance()["device_id"]: Settings.instance()["device_id"] = str(uuid4()) try: result = self.client.auth(self.username, self.password, Settings.instance()["device_id"], get_device_name()) except UnauthorizedError: raise Task.Failure("Wrong e-mail address or password") Settings.instance()["database_username"] = result["username"] Settings.instance()["database_email"] = result["email"] Settings.instance()["database_auth"] = result["auth_token"] Settings.instance()["database_password"] = ""
def app_main(): args = [] for arg in sys.argv[1:]: if not arg.startswith("--"): args.append(arg) if len(args) == 0: print("Usage: fsgc [options] <game_uuid | variant_uuid>") return game_or_variant_uuid = args[-1] print(game_or_variant_uuid) fsgc = default_context() fsgc.load_game_by_uuid(game_or_variant_uuid) fsgc.config.add_from_argv() print("settings:fullscreen", Settings.instance()["fullscreen"]) print("config:fullscreen", fsgc.config.get("fullscreen")) # sys.exit(1) # fsgc.run_game() from fsgs.platform import Platform platform = Platform.create(fsgc.game.platform.id) driver = platform.driver(fsgc) from fsgs.input.enumeratehelper import EnumerateHelper device_helper = EnumerateHelper() device_helper.default_port_selection(driver.ports, driver.options) print("") for port in driver.ports: print("Port", port.index) print(" ", port.type, [x["type"] for x in port.types]) print(" ", port.device) print("") # sys.exit(1) driver.prepare() process = driver.run() process.wait() driver.finish()
def find_game_variants_new(self, game_uuid="", have=3): include_unpublished = False if Settings.instance()["database_show_unpublished"] == "1": include_unpublished = True cursor = self.internal_cursor() print("FIXME: not looking up ratings yet!") query = ("SELECT uuid, name, game_uuid, 0 as like_rating, " "0 as work_rating, have, database, published " "FROM game_variant WHERE " "game_uuid = ? AND have >= ?") if not include_unpublished: query += " AND (published = 1 OR published IS NULL)" query += " ORDER BY like_rating DESC, work_rating DESC, name" cursor.execute(query, (game_uuid, have)) result = [] for row in cursor: result.append(dict(row)) return result
def run(self): self.progressed("Logging into oagd.net...") if not Settings.instance()["device_id"]: Settings.instance()["device_id"] = str(uuid4()) try: result = self.client.auth( self.username, self.password, Settings.instance()["device_id"], get_device_name(), ) except UnauthorizedError: raise Task.Failure("Wrong e-mail address or password") Settings.instance()["database_username"] = result["username"] Settings.instance()["database_email"] = result["email"] Settings.instance()["database_auth"] = result["auth_token"] Settings.instance()["database_password"] = ""
def render_top_right(self, selected=False): state = State.get() mouse_state = state.mouse_item == self mouse_pressed_state = mouse_state and state.mouse_press_item == self self.render_top_background( selected, style=TOP_ITEM_LEFT, mouse_state=mouse_state, mouse_pressed_state=mouse_pressed_state) gl.glDisable(gl.GL_DEPTH_TEST) fs_emu_blending(True) if Settings.instance()["video_sync"] == "1": r = 1.0 g = 1.0 b = 1.0 alpha = 1.0 else: r = 1.0 g = 1.0 b = 1.0 alpha = 0.33 x = self.x + 20 BitmapFont.title_font.render(self.title, x, self.y + 14, r=r, g=g, b=b, alpha=alpha) gl.glEnable(gl.GL_DEPTH_TEST)
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 activate(self, menu): if Settings.instance()["video_sync"] == "1": Settings.instance()["video_sync"] = "" else: Settings.instance()["video_sync"] = "1"
def initialize_locale(language=None): global translations, _initialized _initialized = True if language is None: language = Settings.instance()["language"] print("[I18N] Initialize_locale language =", language) loc = language if not loc: try: loc, _charset = locale.getdefaultlocale() print("[I18N] Locale is", loc) except: print("[I18N] Exception while checking locale") loc = "" if not loc: loc = "" if not loc and sys.platform == "darwin": try: # noinspection PyUnresolvedReferences import CoreFoundation c_loc = CoreFoundation.CFLocaleCopyCurrent() loc = CoreFoundation.CFLocaleGetIdentifier(c_loc) except Exception: traceback.print_exc() print("[I18N] OS X locale", loc) dirs = [ os.path.join(fsboot.executable_dir(), "share"), os.path.join(fsboot.executable_dir(), "..", "share"), ] if sys.platform == "darwin": dirs.insert( 0, os.path.join(fsboot.executable_dir(), "..", "Resources")) locale_base = None for dir in dirs: check = os.path.join(dir, "fs-uae-launcher", "share-dir") print("[I18N] Checking", check) if not os.path.exists(check): continue locale_base = os.path.join(dir, "locale") break if not locale_base and getattr(sys, "frozen", False): locale_base = os.path.abspath( os.path.join( fsboot.executable_dir(), "..", "..", "Data", "Locale")) if locale_base: print("[I18N] bindtextdomain fs-uae-launcher:", locale_base) gettext_module.bindtextdomain("fs-uae-launcher", locale_base) mo_path = None if locale_base: print("[I18N] find translations for", loc, "in local directory", locale_base) try: mo_path = gettext_module.find( "fs-uae-launcher", locale_base, [loc]) except Exception as e: # a bug in openSUSE 12.2's gettext.py can cause an exception # in gettext.find (checking len of None). print(repr(e)) else: print("[I18N] No locale directory found") print("[I18N] Path to mo file:", mo_path) translations = gettext_module.translation( "fs-uae-launcher", locale_base, [loc], fallback=True) print("[I18N] Translations object:", translations)
def items(cls): return Settings.instance().values.items()
def keys(cls): return Settings.instance().values.keys()
def settings(self): if self._settings is None: from fsbc.settings import Settings self._settings = Settings.instance() return self._settings
def prepare(self): print("FSUAEAmigaDriver.prepare") # self.temp_dir = self.fsgc.temp_dir("amiga") # self.change_handler = GameChangeHandler(self.temp_dir) # self.firmware_dir = self.prepare_firmware("Amiga Firmware") # config = self.fsgc.config.copy() model = self.options[Option.AMIGA_MODEL] if model.startswith("CD32"): platform = "CD32" elif model == "CDTV": platform = "CDTV" else: platform = "Amiga" # name = Settings.get("config_name") # name = self.fsgc.game.name # uuid = Config.get("x_game_uuid") # uuid = None from fsgs.saves import SaveHandler save_state_handler = SaveHandler(self.fsgc, self.get_name(), platform) print( "[INPUT] joystick_port_1", self.options["joystick_port_1"], "->", self.ports[0].device_id or "none", ) print( "[INPUT] joystick_port_0", self.options["joystick_port_0"], "->", self.ports[1].device_id or "none", ) self.options["joystick_port_1"] = self.ports[0].device_id or "none" self.options["joystick_port_0"] = self.ports[1].device_id or "none" self.launch_handler = LaunchHandler( self.fsgc, self.get_name(), self.options, save_state_handler, temp_dir=self.cwd.path, ) # self.change_handler.init(self.fsgc.get_game_state_dir(), # ignore=["*.uss", "*.sdf"]) # self.launch_handler.config["joystick_port_0"] = \ # self.inputs[1].device_id # self.launch_handler.config["joystick_port_1"] = \ # self.inputs[0].device_id if self.use_fullscreen(): self.launch_handler.config["fullscreen"] = "1" if not self.launch_handler.config.get("fullscreen_mode", ""): # Check if fullscreen mode is overridden by temporary setting. if Settings.instance()["__fullscreen_mode"]: self.launch_handler.config[ "fullscreen_mode" ] = Settings.instance()["__fullscreen_mode"] if Settings.instance()["__arcade"]: # Remove window border when launched from FS-UAE Arcade in # order to reduce flickering self.launch_handler.config["window_border"] = "0" # Set fade out duration to 500, if not already specified. if not self.launch_handler.config.get("fade_out_duration", ""): self.launch_handler.config["fade_out_duration"] = "500" else: self.launch_handler.config["fullscreen"] = "0" self.launch_handler.prepare()
def initialize_qt_style(qapplication): # from fsui.qt import QStyleFactory, QPalette, QColor, Qt, QFont fusion_variant = "" launcher_theme = Settings.instance().get(Option.LAUNCHER_THEME) if launcher_theme == "standard": use_fusion_theme = False elif launcher_theme == "native": # native is an older deprecated name for standard use_fusion_theme = False elif launcher_theme == "fusion-adwaita": use_fusion_theme = True fusion_variant = "adwaita" elif launcher_theme == "fusion-plain": use_fusion_theme = True elif launcher_theme == "fusion-dark": use_fusion_theme = True fusion_variant = "dark" elif launcher_theme == "fusion-windows10": use_fusion_theme = True fusion_variant = "windows10" elif launcher_theme == "fws": use_fusion_theme = True fusion_variant = "fws" from fsui.qt.window import FwsWindow FwsWindow.set_default() else: use_fusion_theme = True if fstd.desktop.is_running_gnome_3(): fusion_variant = "adwaita" elif fstd.desktop.is_running_windows_10(): fusion_variant = "windows10" if "--launcher-theme=fusion-dark" in sys.argv: use_fusion_theme = True fusion_variant = "dark" font = qapplication.font() print("FONT: Default is {} {}".format(font.family(), font.pointSize())) if use_fusion_theme: # noinspection PyCallByClass,PyTypeChecker,PyArgumentList qapplication.setStyle(QStyleFactory.create("Fusion")) if fusion_variant == "adwaita": pa = QPalette() pa.setColor(QPalette.Window, QColor(232, 232, 231)) pa.setColor(QPalette.AlternateBase, QColor(232, 232, 231)) pa.setColor(QPalette.Button, QColor(232, 232, 231)) # pa.setColor(QPalette.Base, QColor(255, 255, 255)) pa.setColor( QPalette.Disabled, QPalette.Base, QColor(241, 241, 241) ) qapplication.setPalette(pa) elif fusion_variant == "fws" or fusion_variant == "windows10": pa = QPalette() pa.setColor(QPalette.Window, QColor(242, 242, 242)) pa.setColor(QPalette.AlternateBase, QColor(242, 242, 242)) pa.setColor(QPalette.Button, QColor(242, 242, 242)) qapplication.setPalette(pa) elif fusion_variant == "dark": pa = QPalette() pa.setColor(QPalette.Window, QColor(53, 53, 53)) pa.setColor(QPalette.WindowText, Qt.white) pa.setColor(QPalette.Base, QColor(25, 25, 25)) pa.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) pa.setColor(QPalette.ToolTipBase, Qt.white) pa.setColor(QPalette.ToolTipText, Qt.white) pa.setColor(QPalette.Text, Qt.white) pa.setColor(QPalette.Button, QColor(53, 53, 53)) pa.setColor(QPalette.ButtonText, Qt.white) pa.setColor(QPalette.BrightText, Qt.red) pa.setColor(QPalette.Link, QColor(42, 130, 218)) pa.setColor(QPalette.Highlight, QColor(42, 130, 218)) pa.setColor(QPalette.HighlightedText, Qt.black) qapplication.setPalette(pa) qapplication.setStyleSheet( "QToolTip { color: #ffffff; background-color: #2a82da; " "border: 1px solid white; }" ) try: launcher_font_size = int( Settings.instance().get("launcher_font_size") ) except ValueError: if fusion_variant == "fws": launcher_font_size = 13 else: launcher_font_size = 0 if launcher_font_size: print("FONT: Override size {}".format(launcher_font_size)) font.setPointSize(launcher_font_size) if fusion_variant == "fws": font = QFont("Roboto") font.setPointSizeF(10.5) font.setHintingPreference(QFont.PreferNoHinting) qapplication.setFont(font) import fsui if use_fusion_theme: fsui.theme = "fusion" fsui.theme_variant = fusion_variant
def use_stretching(self): if "--no-stretch" in sys.argv: return False if Settings.instance()["stretch"] == "0": return False return True