def on_resize(self):
     width, height = self.get_size()
     # print("on_resize, size =", width, height)
     if self.is_maximized():
         if LauncherSettings.get("maximized") != "1":
             LauncherSettings.set("maximized", "1")
     else:
         if LauncherSettings.get("maximized") != "0":
             LauncherSettings.set("maximized", "0")
     if self.screenshots_panel is not None:
         available = width - 2 * 10 - self.game_info_panel.get_min_width()
         num_screenshots = int(
             (available - 22 + 22) / (Constants.SCREEN_SIZE[0] + 22))
         # print("Screenshots count:", num_screenshots)
         screenshots_panel_width = (
             (Constants.SCREEN_SIZE[0] + 22) * num_screenshots - 22 + 22)
         self.screenshots_panel.set_min_width(screenshots_panel_width)
     if width > CONFIGURATIONS_PANEL_WIDTH_THRESHOLD_2:
         configurations_width = (SCREENSHOT_WIDTH * 3 +
                                 SCREENSHOT_SPACING * 2 + MARGIN)
         self.configurations_panel.set_min_width(
             CONFIGURATIONS_PANEL_WIDTH_2)
     else:
         self.configurations_panel.set_min_width(
             CONFIGURATIONS_PANEL_WIDTH_1)
     super().on_resize()
Example #2
0
 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()
Example #3
0
 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()
Example #4
0
    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", "")
Example #5
0
    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", "")
Example #6
0
    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),
        )
Example #7
0
 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", "")
Example #8
0
    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 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()
Example #10
0
        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()
Example #11
0
        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()
Example #12
0
 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))
Example #13
0
    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")
Example #15
0
    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()
Example #16
0
 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))
Example #17
0
    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
Example #18
0
    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
Example #19
0
 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 on_setting(self, key, value):
     config = get_config(self)
     if key == "parent_uuid":
         self.parent_uuid = value
         if value:
             self.update_list(value)
         else:
             LauncherSettings.set("game_uuid", "")
             # self.set_items([gettext("Configuration")])
             self.set_items([])
             self.set_enabled(False)
     elif key == "__variant_rating":
         variant_uuid = config.get("variant_uuid")
         for item in self.items:
             if item["uuid"] == variant_uuid:
                 item["personal_rating"] = int(value or 0)
                 self.update()
                 break
Example #21
0
 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 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)
Example #23
0
 def _update_thread_function(cls):
     if System.windows:
         platform = "windows"
     elif System.macos:
         platform = "macosx"
     elif System.linux:
         platform = "linux"
     else:
         platform = "other"
     url = f"https://fs-uae.net/{cls.series()}/latest-{platform}"
     r = requests.get(url)
     r.raise_for_status()
     version_str = r.text.strip()
     print("Latest version available:", version_str)
     print("Current version:", VERSION)
     result = Version.compare(version_str, VERSION)
     print("Update check result: ", result)
     if result > 0 and version_str != "9.9.9":
         web_url = "https://fs-uae.net/{0}/download/".format(cls.series())
         LauncherSignal.broadcast("update_available", version_str, web_url)
         # FIXME: Thread safety...
         # FIXME: Use above signal instead
         LauncherSettings.set("__update_available", version_str)
Example #24
0
    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
Example #25
0
    def save_config():
        print("SaveButton.save_config")
        database = Database.get_instance()

        name = LauncherSettings.get("config_name").strip()
        if not name:
            print("no config_name")
            # FIXME: notify user
            return

        file_name = name + ".fs-uae"
        path = os.path.join(
            FSGSDirectories.get_configurations_dir(), file_name)
        with io.open(path, "w", encoding="UTF-8") as f:
            f.write("# FS-UAE configuration saved by FS-UAE Launcher\n")
            f.write("# Last saved: {0}\n".format(
                    datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")))
            f.write("\n[fs-uae]\n")
            keys = sorted(fsgs.config.values.keys())
            for key in keys:
                value = LauncherConfig.get(key)
                if key.startswith("__"):
                    continue
                if key in LauncherConfig.no_save_keys_set:
                    continue
                # elif key == "joystick_port_2_mode" and value == "nothing":
                #     continue
                # elif key == "joystick_port_3_mode" and value == "nothing":
                #     continue
                if value == LauncherConfig.default_config.get(key, ""):
                    continue
                if value:
                    f.write("{0} = {1}\n".format(key, value))

        # scanner = ConfigurationScanner()
        # search = ConfigurationScanner.create_configuration_search(name)
        # name = scanner.create_configuration_name(name)
        # print("adding", path)
        # # deleting the path from the database first in case it already exists
        # database.delete_configuration(path=path)
        # database.delete_file(path=path)
        # database.add_file(path=path)
        # database.add_configuration(
        #     path=path, uuid="", name=name, scan=0, search=search)

        file_database = FileDatabase.get_instance()
        scanner = ConfigurationScanner()
        print("[save config] 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_game(
            path=path, name=scanner.create_configuration_name(name))
        database.update_game_search_terms(
            game_id, scanner.create_search_terms(name))

        database.commit()
        file_database.commit()

        LauncherSettings.set("__config_refresh", str(time.time()))
        # Settings.set("config_changed", "0")
        LauncherConfig.set("__changed", "0")
Example #26
0
 def on_spin():
     val = spin_ctrl.get_value()
     val = max(option["min"], min(option["max"], val))
     LauncherSettings.set(name, str(val))
Example #27
0
 def reset_to_defaults(self):
     for option in self.options_on_page:
         LauncherSettings.set(option, "")
Example #28
0
 def on_spin():
     val = spin_ctrl.get_value()
     val = max(option["min"], min(option["max"], val))
     LauncherSettings.set(name, str(val))
Example #29
0
 def on_device_changed(self):
     value = self.device_choice.get_text()
     print("on_device_change", value)
     if value == get_keyboard_title():
         value = "keyboard"
     LauncherSettings.set(self.key, value)
Example #30
0
 def on_changed():
     index = choice.get_index()
     LauncherSettings.set(name, choice_values[index][0])
Example #31
0
    def save_config():
        print("SaveButton.save_config")
        database = Database.get_instance()

        name = LauncherSettings.get("config_name").strip()
        if not name:
            print("no config_name")
            # FIXME: notify user
            return

        file_name = name + ".fs-uae"
        path = os.path.join(FSGSDirectories.get_configurations_dir(),
                            file_name)
        with io.open(path, "w", encoding="UTF-8") as f:
            f.write("# FS-UAE configuration saved by FS-UAE Launcher\n")
            f.write("# Last saved: {0}\n".format(
                datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")))
            f.write("\n[fs-uae]\n")
            keys = sorted(fsgs.config.values.keys())
            for key in keys:
                value = LauncherConfig.get(key)
                if key.startswith("__"):
                    continue
                if key in LauncherConfig.no_save_keys_set:
                    continue
                # elif key == "joystick_port_2_mode" and value == "nothing":
                #     continue
                # elif key == "joystick_port_3_mode" and value == "nothing":
                #     continue
                if value == LauncherConfig.default_config.get(key, ""):
                    continue
                if value:
                    f.write("{0} = {1}\n".format(key, value))

        # scanner = ConfigurationScanner()
        # search = ConfigurationScanner.create_configuration_search(name)
        # name = scanner.create_configuration_name(name)
        # print("adding", path)
        # # deleting the path from the database first in case it already exists
        # database.delete_configuration(path=path)
        # database.delete_file(path=path)
        # database.add_file(path=path)
        # database.add_configuration(
        #     path=path, uuid="", name=name, scan=0, search=search)

        file_database = FileDatabase.get_instance()
        scanner = ConfigurationScanner()
        print("[save config] 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))

        database.commit()
        file_database.commit()

        LauncherSettings.set("__config_refresh", str(time.time()))
        # Settings.set("config_changed", "0")
        LauncherConfig.set("__changed", "0")
Example #32
0
 def on_changed(self):
     index = self.get_index()
     LauncherSettings.set("language", LANGUAGE_ITEMS[index][1])
Example #33
0
 def on_changed():
     index = choice.get_index()
     LauncherSettings.set(name, choice_values[index][0])
Example #34
0
 def new_config():
     LauncherConfig.load_default_config()
     # Settings.set("config_changed", "1")
     LauncherSettings.set("parent_uuid", "")
Example #35
0
 def __page_changed(self):
     index = self.get_index()
     LauncherSettings.set("last_settings_page", self.get_page_title(index))
 def on_search_changed(self):
     text = self.text_field.get_text()
     LauncherSettings.set("config_search", text)
 def on_changed(self):
     index = self.get_index()
     LauncherSettings.set("language", LANGUAGE_ITEMS[index][1])
 def on_search_changed(self):
     text = self.text_field.get_text()
     LauncherSettings.set("config_search", text)
Example #39
0
 def new_config():
     LauncherConfig.load_default_config()
     # Settings.set("config_changed", "1")
     LauncherSettings.set("parent_uuid", "")
Example #40
0
 def on_changed():
     val = text_field.get_text()
     LauncherSettings.set(name, val.strip())
Example #41
0
 def reset_to_defaults(self):
     for option in self.options_on_page:
         LauncherSettings.set(option, "")
Example #42
0
 def __setitem__(self, key, value):
     LauncherSettings.set(key, value)
 def __page_changed(self):
     index = self.get_index()
     LauncherSettings.set("last_settings_page", self.get_page_title(index))
Example #44
0
 def on_changed(self):
     LauncherSettings.set("video_sync", "1" if self.is_checked() else "")
Example #45
0
 def __item_changed(self, index):
     LauncherSettings.set("language", LANGUAGE_ITEMS[index][1])
Example #46
0
 def on_changed():
     val = text_field.get_text()
     LauncherSettings.set(name, val.strip())
Example #47
0
 def on_config_name_changed(self):
     text = self.config_name_field.get_text().strip()
     LauncherSettings.set("config_name", text)
     LauncherConfig.set("__changed", "1")