Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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()
Exemplo n.º 4
0
 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()
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
 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 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))
Exemplo n.º 9
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()
     LauncherConfig.set("variant_rating", str(like_rating))
Exemplo n.º 10
0
 def set_value_or_default(self, value):
     if self.port == 0:
         if value == "mouse":
             value = ""
     elif self.port == 1:
         if LauncherConfig.get("amiga_model").startswith("CD32"):
             default = "cd32 gamepad"
         else:
             default = "joystick"
         if value == default:
             value = ""
     else:
         if value == "nothing":
             value = ""
     if LauncherConfig.get(self.mode_option_key) != value:
         LauncherConfig.set(self.mode_option_key, value)
Exemplo n.º 11
0
    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()
Exemplo n.º 12
0
    def start_local_game_other(cls):
        if True:
            platform_id = LauncherConfig.get(Option.PLATFORM).lower()
            platform_handler = PlatformHandler.create(platform_id)
        else:
            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.launcherwindow import LauncherWindow
        dialog = LaunchDialog(LauncherWindow.current(),
                              gettext("Launching Game"), task)
        dialog.show()
        LauncherConfig.set("__running", "1")
        task.start()
Exemplo n.º 13
0
    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()
Exemplo n.º 14
0
    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 _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")
Exemplo n.º 16
0
 def on_changed():
     index = choice.get_index()
     LauncherConfig.set(key, choice_values[index][0])
Exemplo n.º 17
0
 def on_changed(self):
     LauncherConfig.set(Option.SAVE_DISK, "" if self.is_checked() else "0")
Exemplo n.º 18
0
    def start_local_game_amiga(cls):
        # make sure x_kickstart_file is initialized
        LauncherConfig.set_kickstart_from_model()

        # if not Config.get("x_kickstart_file"):  # or not \
        #     #  os.path.exists(Config.get("kickstart_file")):
        #     fsui.show_error(
        #         gettext("No kickstart found for this model. Use the 'Import "
        #                 "Kickstarts' function from the menu."))
        #     return
        cs = Amiga.get_model_config(
            LauncherConfig.get("amiga_model"))["ext_roms"]
        if len(cs) > 0:
            # extended kickstart ROM is needed
            if not LauncherConfig.get("x_kickstart_ext_file"):
                fsui.show_error(
                    gettext("No extended kickstart found for this model. "
                            "Try 'scan' function."))
                return

        config = LauncherConfig.copy()
        prepared_config = cls.prepare_config(config)

        model = LauncherConfig.get("amiga_model")
        if model.startswith("CD32"):
            platform = "CD32"
        elif model == "CDTV":
            platform = "CDTV"
        else:
            platform = "Amiga"
        name = LauncherSettings.get("config_name")
        uuid = LauncherConfig.get("x_game_uuid")

        from fsgs.SaveStateHandler import SaveStateHandler
        save_state_handler = SaveStateHandler(fsgs, name, platform, uuid)

        from fsgs.amiga.LaunchHandler import LaunchHandler
        launch_handler = LaunchHandler(fsgs, name, prepared_config,
                                       save_state_handler)

        from .ui.launcher_window import LauncherWindow
        task = AmigaLaunchTask(launch_handler)
        # dialog = LaunchDialog(MainWindow.instance, launch_handler)
        dialog = LaunchDialog(
            LauncherWindow.current(), gettext("Launching FS-UAE"), task)
        dialog.show()

        def on_show_license_information(license_text):
            unused(license_text)
            # FIXME: don't depend on wx here
            # noinspection PyUnresolvedReferences
            # import wx
            # license_dialog = wx.MessageDialog(
            #     dialog, license_text, _("Terms of Use"),
            #     wx.OK | wx.CANCEL | wx.CENTRE)
            # license_dialog.CenterOnParent()
            # result = license_dialog.ShowModal()
            # return result == wx.ID_OK
            # FIXME
            return True

        fsgs.file.on_show_license_information = on_show_license_information

        LauncherConfig.set("__running", "1")
        task.start()
Exemplo n.º 19
0
 def on_config_name_changed(self):
     text = self.config_name_field.get_text().strip()
     LauncherSettings.set("config_name", text)
     LauncherConfig.set("__changed", "1")
Exemplo n.º 20
0
    def start_local_game_amiga(cls):
        # make sure x_kickstart_file is initialized
        LauncherConfig.set_kickstart_from_model()

        # if not Config.get("x_kickstart_file"):  # or not \
        #     #  os.path.exists(Config.get("kickstart_file")):
        #     fsui.show_error(
        #         gettext("No kickstart found for this model. Use the 'Import "
        #                 "Kickstarts' function from the menu."))
        #     return
        cs = Amiga.get_model_config(
            LauncherConfig.get("amiga_model"))["ext_roms"]
        if len(cs) > 0:
            # extended kickstart ROM is needed
            if not LauncherConfig.get("x_kickstart_ext_file"):
                fsui.show_error(
                    gettext("No extended kickstart found for this model. "
                            "Try 'scan' function."))
                return

        config = LauncherConfig.copy()
        prepared_config = cls.prepare_config(config)

        model = LauncherConfig.get("amiga_model")
        if model.startswith("CD32"):
            platform = "CD32"
        elif model == "CDTV":
            platform = "CDTV"
        else:
            platform = "Amiga"
        name = LauncherSettings.get("config_name")
        uuid = LauncherConfig.get("x_game_uuid")

        from fsgs.saves import SaveHandler
        save_state_handler = SaveHandler(fsgs, name, platform, uuid)

        from fsgs.amiga.launchhandler import LaunchHandler
        launch_handler = LaunchHandler(fsgs, name, prepared_config,
                                       save_state_handler)

        from .ui.launcherwindow import LauncherWindow
        task = AmigaLaunchTask(launch_handler)
        # dialog = LaunchDialog(MainWindow.instance, launch_handler)
        dialog = LaunchDialog(LauncherWindow.current(),
                              gettext("Launching FS-UAE"), task)
        dialog.show()

        def on_show_license_information(license_text):
            unused(license_text)
            # FIXME: don't depend on wx here
            # noinspection PyUnresolvedReferences
            # import wx
            # license_dialog = wx.MessageDialog(
            #     dialog, license_text, _("Terms of Use"),
            #     wx.OK | wx.CANCEL | wx.CENTRE)
            # license_dialog.CenterOnParent()
            # result = license_dialog.ShowModal()
            # return result == wx.ID_OK
            # FIXME
            return True

        fsgs.file.on_show_license_information = on_show_license_information

        LauncherConfig.set("__running", "1")
        task.start()
Exemplo n.º 21
0
 def __closed(self):
     LauncherConfig.set("__running", "")
     self.cancel()
     return False
Exemplo n.º 22
0
 def __setitem__(self, key, value):
     LauncherConfig.set(key, value)
Exemplo n.º 23
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")
Exemplo n.º 24
0
 def on_text_changed(self):
     LauncherConfig.set("command", self.text_field.get_text())
Exemplo n.º 25
0
 def on_accuracy_changed(self):
     index = self.accuracy_choice.get_index()
     if index == 0:
         LauncherConfig.set("accuracy", "")
     else:
         LauncherConfig.set("accuracy", str(1 - index))
Exemplo n.º 26
0
 def on_autofire_button(self):
     if LauncherConfig.get(self.autofire_mode_option_key) == "1":
         LauncherConfig.set(self.autofire_mode_option_key, "")
     else:
         LauncherConfig.set(self.autofire_mode_option_key, "1")
Exemplo n.º 27
0
 def on_accuracy_changed(self):
     index = self.accuracy_choice.get_index()
     if index == 0:
         LauncherConfig.set("accuracy", "")
     else:
         LauncherConfig.set("accuracy", str(1 - index))
Exemplo n.º 28
0
 def on_changed():
     val = text_field.get_text()
     LauncherConfig.set(key, val.strip())
Exemplo n.º 29
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")
Exemplo n.º 30
0
 def on_changed():
     val = text_field.get_text()
     LauncherConfig.set(key, val.strip())
Exemplo n.º 31
0
 def on_changed(self):
     LauncherConfig.set(Option.SAVE_DISK, "" if self.is_checked() else "0")
Exemplo n.º 32
0
 def on_changed():
     index = choice.get_index()
     LauncherConfig.set(key, choice_values[index][0])