コード例 #1
0
    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)
コード例 #2
0
 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
コード例 #3
0
    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))
コード例 #4
0
ファイル: FSUAE.py プロジェクト: jelmer/fs-uae-debian
    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))
コード例 #5
0
 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)
コード例 #6
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))
コード例 #7
0
 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
コード例 #8
0
ファイル: gamedriver.py プロジェクト: hroncok/fs-uae-launcher
    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)
コード例 #9
0
 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)
コード例 #10
0
 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))
コード例 #11
0
ファイル: FSUAE.py プロジェクト: glaubitz/fs-uae-debian
    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))
コード例 #12
0
ファイル: romram.py プロジェクト: EdwardBetts/fs-uae-launcher
 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()
コード例 #13
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()
コード例 #14
0
 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, ""))
コード例 #15
0
 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, ""))
コード例 #16
0
 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
コード例 #17
0
 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
コード例 #18
0
    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()
コード例 #19
0
    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()
コード例 #20
0
    def on_browse(self):
        if self.mode == self.CD_MODE:
            title = gettext("Choose CD-ROM Image")
            # default_dir = FSGSDirectories.get_cdroms_dir()
            media_type = "cd"
        elif self.mode == self.TAPE_MODE:
            title = gettext("Choose Tape Image")
            media_type = "tape"
        elif self.mode == self.CARTRIDGE_MODE:
            title = gettext("Choose Cartridge Image")
            media_type = "cartridge"
        else:
            title = gettext("Choose Floppy Image")
            # default_dir = FSGSDirectories.get_floppies_dir()
            media_type = "floppy"
        dialog = LauncherFilePicker(
            self.window, title, media_type, LauncherConfig.get(self.config_key))

        if not dialog.show_modal():
            return
        path = dialog.get_path()

        if self.mode == self.CD_MODE:
            fsgs.amiga.insert_cd(self.drive, path)
        elif self.mode == self.FLOPPY_MODE:
            fsgs.amiga.insert_floppy(self.drive, path)
        else:
            fsgs.config.set(self.config_key, Paths.contract_path(path))
コード例 #21
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)
コード例 #22
0
ファイル: modelgroup.py プロジェクト: hroncok/fs-uae-launcher
    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
コード例 #23
0
    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
コード例 #24
0
    def update_default_device(self, had_default=None):
        config = {}
        for port in range(4):
            key = "joystick_port_{0}".format(port)
            if self.port == port:
                config[key] = ""
            else:
                config[key] = LauncherConfig.get(key)
            key = "joystick_port_{0}_mode".format(port)
            config[key] = DeviceManager.get_calculated_port_mode(
                LauncherConfig, port)
        device = DeviceManager.get_device_for_port(config, self.port)
        default_description = gettext("Default ({0})").format(
            fix_device_name(device.name))
        # print("default_description = ", default_description)

        if had_default is None:
            had_default = (self.device_choice.get_index() == 0)
        # print("had default", had_default, self.device_choice.get_index())
        self.device_choice.set_item_text(0, default_description)
        # print("had_default", had_default)
        if had_default:
            # print("set text for", self.port, default_description)
            # self.device_choice.set_index(1)
            self.device_choice.set_text(default_description)
            self.device_choice.set_index(0)
コード例 #25
0
    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)])
コード例 #26
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()
コード例 #27
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", "")
コード例 #28
0
    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))
コード例 #29
0
    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)
コード例 #30
0
    def __init__(self, parent):
        StatusElement.__init__(self, parent)
        # self.set_min_width(140)
        self.layout = HorizontalLayout()
        self.icon = Image("launcher:res/16x16/world_link.png")
        self.right_icon = Image("launcher:res/16x16/drop_down_arrow.png")
        self.right_icon_disabled = Image(
            "launcher:res/16x16/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))
コード例 #31
0
 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)
コード例 #32
0
 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)
コード例 #33
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()
コード例 #34
0
    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
        )
コード例 #35
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)
コード例 #36
0
    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)
コード例 #37
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)
コード例 #38
0
 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))
コード例 #39
0
 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))
コード例 #40
0
    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)
コード例 #41
0
    def on_config(self, key, value):
        if key == "platform":
            self.layout.update()
            return

        if key == "amiga_model":
            value = LauncherConfig.get("joystick_port_{0}_mode".format(
                self.port))
            self.set_value_or_default(value)

        if key == self.mode_option_key or key == "amiga_model":
            value = DeviceManager.get_calculated_port_mode(
                LauncherConfig, self.port)
            for i, config in enumerate(self.joystick_mode_values):
                if config == value:
                    if self.mode_choice is not None:
                        self.mode_choice.set_index(i)
                        if self.port >= 4:
                            self.device_choice.enable(i != 0)
                    break
            else:
                print("FIXME: could not set mode")
        elif key == self.device_option_key or key == "amiga_model":
            # print(self.joystick_values)
            value_lower = value.lower()
            for i, name in enumerate(self.joystick_values):
                if value_lower == name.lower():
                    self.device_choice.set_index(i)
                    break
        elif key == self.autofire_mode_option_key:
            if self.autofire_button is not None:
                if value == "1":
                    self.autofire_button.set_tooltip(
                        gettext("Auto-Fire is On"))
                    self.autofire_button.set_icon_name(
                        "16x16/lightning_red.png")
                else:
                    self.autofire_button.set_tooltip(
                        gettext("Auto-Fire is Off"))
                    self.autofire_button.set_icon_name(
                        "16x16/lightning_off.png")

        # this is intended to catch all config changes for all ports (both
        # mode and device) to update the defaults
        if key.startswith("joystick_port_") or key == "amiga_model":
            self.update_default_device()
コード例 #42
0
    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),
                ]
            )
コード例 #43
0
    def __init__(self, parent, fsgc, port_gui_index):
        super().__init__(parent, [""], read_only=True)
        self.fsgc = fsgc
        self.port_gui_index = port_gui_index
        self.port = self.port_gui_index + 1
        self._platform = ""
        self._config_key = ""
        self.device_option_key = ""

        # AmigaEnableBehavior(self.device_choice)
        self.device_values = []
        self.rebuild_device_list()

        self.fsgc.signal.connect("config", self.on_config)
        # Must check platform before device option key
        self.on_config(Option.PLATFORM, self.fsgc.config.get(Option.PLATFORM))
        self.on_config(self.device_option_key,
                       LauncherConfig.get(self.device_option_key))
        # self.changed.connect(self.__changed)
        self.set_index(0)

        LauncherConfig.add_listener(self)
        LauncherSignal.add_listener("settings_updated", self)
        LauncherSignal.add_listener("device_list_updated", self)
コード例 #44
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")
コード例 #45
0
 def get(key):
     return LauncherConfig.get(key)
コード例 #46
0
def create_option_group(
        parent, options, option, key, option_type, option_text,
        use_checkbox, use_help_button, label_spacing):
    group = fsui.Group(parent)
    group.layout = fsui.HorizontalLayout()

    if use_checkbox:
        group.layout.add(
            OptionCheckBox(group, option_text + ":", options, key),
            margin_right=label_spacing)
    else:
        group.layout.add(
            fsui.Label(group, option_text + ":"),
            margin_right=label_spacing)

    choice_values = []

    if option_type == "boolean":
        group.layout.add_spacer(0, expand=True)
        group.layout.add(BooleanChoiceControl(
            group, options, key, use_checkbox=use_checkbox))

    elif option_type == "choice":
        group.layout.add_spacer(0, expand=True)
        choices = option["values"]
        # if use_checkbox:
        #     choices,insert(("", gettext("Auto")))
        group.layout.add(ChoiceControl(
            group, options, key, choices, use_checkbox=use_checkbox))

    elif option_type == "string":

        def on_changed():
            val = text_field.get_text()
            LauncherConfig.set(key, val.strip())

        text_field = fsui.TextField(group)
        # text_field.set_min_width(400)
        text_field.set_text(LauncherConfig.get(key))
        text_field.on_changed = on_changed
        group.layout.add(text_field, expand=True)

    elif option["type"].lower() == "integer" and "min" in option \
            and "max" in option:
        assert use_checkbox

        spin_ctrl = SpinValueControl(
            group, options, key, option["min"], option["max"])

        # current = LauncherConfig.get(key)
        # current_int = int(option["default"])
        # if current:
        #     try:
        #         current_int = int(current)
        #     except ValueError:
        #         pass
        # current_int = max(option["min"], min(option["max"], current_int))
        # check_box = fsui.CheckBox(group, gettext("Default"))
        # spin_ctrl = fsui.SpinCtrl(group, option["min"],
        #                           option["max"], current_int)
        # if current == "":
        #     check_box.check()
        #     spin_ctrl.disable()

        # def on_checkbox():
        #     if check_box.is_checked():
        #         spin_ctrl.set_value(int(option["default"]))
        #         spin_ctrl.disable()
        #         LauncherConfig.set(key, "")
        #     else:
        #         spin_ctrl.enable()
        #
        # check_box.on_changed = on_checkbox
        #
        # def on_spin():
        #     val = spin_ctrl.get_value()
        #     val = max(option["min"], min(option["max"], val))
        #     LauncherConfig.set(key, str(val))

        # spin_ctrl.on_changed = on_spin
        # group.layout.add(check_box)
        group.layout.add_spacer(0, expand=True)
        group.layout.add(spin_ctrl, margin_left=10)

    if choice_values:

        def on_changed():
            index = choice.get_index()
            LauncherConfig.set(key, choice_values[index][0])

        choice_labels = [x[1] for x in choice_values]
        choice = fsui.Choice(group, choice_labels)
        current = LauncherConfig.get(key)
        for i, value in enumerate(choice_values):
            if current == value[0]:
                choice.set_index(i)
                break
        choice.on_changed = on_changed
        group.layout.add_spacer(0, expand=True)
        group.layout.add(choice)
        group.widget = choice

    if use_help_button:
        help_button = HelpButton(
            parent, "https://fs-uae.net/options#" + key)
        group.layout.add(help_button, margin_left=10)

    return group
コード例 #47
0
ファイル: savebutton.py プロジェクト: glaubitz/fs-uae-debian
 def __init__(self, parent):
     super().__init__(parent, "save_button.png")
     self.set_tooltip(gettext("Save Config"))
     LauncherConfig.add_listener(self)
     self.on_config("__changed", LauncherConfig.get("__changed"))
コード例 #48
0
 def on_platform_settings_button(self):
     platform = LauncherConfig.get("platform")
     if platform:
         PlatformSettingsDialog.open(self.window, platform)
コード例 #49
0
 def on_platform_settings_button(self):
     platform = LauncherConfig.get("platform")
     if platform:
         PlatformSettingsDialog.open(self.window, platform)
コード例 #50
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()
コード例 #51
0
ファイル: savebutton.py プロジェクト: glaubitz/fs-uae-debian
    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")
コード例 #52
0
 def initialize_from_config(self):
     self.on_config("kickstart_file", LauncherConfig.get("kickstart_file"))
     self.on_config(
         "kickstart_ext_file", LauncherConfig.get("kickstart_ext_file")
     )
コード例 #53
0
 def on_changed(self):
     variant_uuid = LauncherConfig.get("variant_uuid", "")
     if not variant_uuid:
         return
     rating = self.index_to_rating(self.get_index())
     self.set_rating_for_variant(variant_uuid, rating)
コード例 #54
0
 def initialize_from_config(self):
     self.on_config(self.config_key, LauncherConfig.get(self.config_key))
コード例 #55
0
 def initialize_from_config(self):
     self.on_config(self.config_key, LauncherConfig.get(self.config_key))