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)
Exemple #2
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()
Exemple #3
0
    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.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: 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))
Exemple #4
0
 def start(cls):
     cls.pre_start()
     print("FSUAELauncherApplication.start")
     if cls.run_config_or_game():
         return False
     # window = LauncherWindow(fsgs)
     # window.show()
     LauncherWindow.open()
     return True
Exemple #5
0
    def start(cls):
        cls.pre_start()
        print("FSUAELauncherApplication.start")

        if cls.run_config_or_game():
            return False
        # window = LauncherWindow(fsgs)
        # window.show()
        LauncherWindow.open()
        return True
    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
        )
Exemple #7
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()
Exemple #8
0
    def start_local_game_other(cls, dialog=True, *, gscontext):
        config = gscontext.config
        if True:
            platform_id = config.get(Option.PLATFORM).lower()
            if not platform_id:
                platform_id = "amiga"
            platform_handler = PlatformHandler.create(platform_id)
        else:
            database_name = config.get("__database")
            variant_uuid = config.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

        print("DIALOG", dialog)

        if dialog:
            _dialog = LaunchDialog(
                LauncherWindow.current(),
                gettext("Launching Game"),
                task,
                gscontext=gscontext,
            )
            _dialog.show()
        else:
            # FIXME: Dialog is still needed. Fix!
            _dialog = LaunchDialog(
                LauncherWindow.current(),
                gettext("Launching Game"),
                task,
                gscontext=gscontext,
            )

        config.set(RUNNING__, "1")
        task.start()
    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.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: 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))
Exemple #10
0
    def start_local_game(cls, dialog=True, *, gscontext):
        config = gscontext.config
        print("START LOCAL GAME")
        print("x_missing_files", config.get("x_missing_files"))

        if config.get("x_missing_files"):
            if config.get("download_file"):
                if config.get("download_terms"
                              ) and not Downloader.check_terms_accepted(
                                  config.get("download_file"),
                                  config.get("download_terms"),
                              ):
                    from .ui.launcherwindow import LauncherWindow

                    terms_dialog = DownloadTermsDialog(
                        LauncherWindow.current(), fsgs)
                    if not terms_dialog.show_modal():
                        return

            elif config.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 = config.get(Option.PLATFORM).lower()
        # if platform_id in AMIGA_PLATFORMS:
        #     cls.start_local_game_amiga()
        # else:
        #     cls.start_local_game_other()
        cls.start_local_game_other(dialog=dialog, gscontext=gscontext)
Exemple #11
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()
Exemple #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()
Exemple #13
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()
Exemple #14
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()