def create_context(self):
        item = self.items[0]
        variant_uuid = item.configurations[0][0]
        database_name = item.configurations[0][2]
        print("\nitem:\n", item.configurations)
        print("\nitem[0]:\n", item.configurations[0])
        print("\n\nvariant_uuid =", variant_uuid, "\n\n")

        # print("configurations: ", item.configurations)
        # configs = sort_configurations(item.configurations)

        # configs = item.configurations
        # config = configs[0]
        # self.context = GameContext.create_for_game(
        #     item.platform, item.name, config)

        values = fsgs.game.set_from_variant_uuid(database_name, variant_uuid)

        # print("")
        # for key in sorted(values.keys()):
        #     print(" * {0} = {1}".format(key, values[key]))
        # print("")

        self.platform_handler = PlatformHandler.create(fsgs.game.platform.id)
        loader = self.platform_handler.get_loader(fsgs)
        fsgs.config.load(loader.load_values(values))
示例#2
0
 def get_item_text(self, index):
     item = self.items[index]
     name = item[str("name")]
     platform = item[str("platform")] or ""
     if "[" in name:
         name, extra = name.split("[", 1)
         name = name.strip()
         extra = " \u00b7 " + extra.strip(" ]")
     else:
         extra = ""
     if fsui.toolkit == "wx":
         sep = "\n"
     else:
         sep = " \u00b7 "
         name = name.replace("\n", " \u00b7 ")
     if platform == "Amiga" and not openretro:
         platform = ""
     elif platform:
         platform = sep + PlatformHandler.get_platform_name(platform)
         # if not extra:
         #     sep = ""
         # return "{0}{1}{2}{3}".format(name, sep, extra, "")
     # else:
     text = "{0}{1}{2}".format(name, extra, platform) or "Missing Name"
     return text
    def start(self):
        assert self.thread is None

        platform_handler = PlatformHandler.create(self.fsgs.game.platform.id)
        self.runner = platform_handler.get_runner(self.fsgs)

        device_helper = EnumerateHelper()
        device_helper.default_port_selection(self.runner.ports)

        self.thread = threading.Thread(target=self._thread)
        self.thread.start()
示例#4
0
def app_main():
    from launcher.launcherapp import LauncherApp

    launcherapp = LauncherApp()

    gscontext = FSGameSystemContext()
    print("\n\n\n")
    # print(gscontext.config.items())
    config = gscontext.config
    config.set("amiga_model", "A4000")

    amigaforeverdir = os.path.join(
        FSGSDirectories.get_base_dir(), "AmigaForever"
    )
    amigafilesdir = os.path.join(amigaforeverdir, "Amiga Files")
    shareddir = os.path.join(amigafilesdir, "Shared")
    romdir = os.path.join(shareddir, "rom")
    systemdir = os.path.join(shareddir, "dir", "System")
    workdir = os.path.join(shareddir, "dir", "Work")
    config.set(
        "kickstart_file", os.path.join(romdir, "amiga-os-310-a4000.rom")
    )
    # FIXME: Shouldn't be necessary...
    config.set(
        "x_kickstart_file", os.path.join(romdir, "amiga-os-310-a4000.rom")
    )
    config.set("hard_drive_0", systemdir)
    config.set("hard_drive_1", workdir)

    # config.set("hard_drive_2", os.path.join(FSGSDirectories.get_base_dir(), "Work"))

    # config.set("zorro_iii_memory", "65536")
    config.set("graphics_card", "uaegfx")

    config.set("window_width", "800")
    config.set("window_height", "600")
    config.set("legacy", "1")

    print(gscontext.config.items())
    # sys.exit(1)
    # gscontext.config.set()

    platform_handler = PlatformHandler.create("amiga")
    driver = platform_handler.get_runner(gscontext)

    device_helper = EnumerateHelper()
    device_helper.default_port_selection(driver.ports, driver.options)

    driver.prepare()
    driver.install()
    # set_progress("__run__")
    driver.run()
    driver.wait()
    driver.finish()
示例#5
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()
示例#6
0
def create_driver_for_config(config, settings=None):
    platform = config.get("platform", "").lower()
    if not platform:
        platform = "amiga"
    platform = PlatformHandler.create(platform)
    fsgc = FSGameSystemContext()

    fsgc.config.load(config)

    if settings:
        fsgc._settings = settings

    driver = platform.driver(fsgc)
    return driver
    def run_game(self):
        from fsgamesys.platforms.platform import PlatformHandler

        platform_handler = PlatformHandler.create(self.game.platform.id)
        runner = platform_handler.get_runner(self)

        from fsgamesys.input.enumeratehelper import EnumerateHelper

        device_helper = EnumerateHelper()
        device_helper.default_port_selection(runner.ports, runner.options)

        runner.prepare()
        process = runner.run()
        process.wait()
        runner.finish()
示例#8
0
    def load_values(cls, values, uuid=""):
        # print("loading config values", values)
        platform_id = values.get("platform", "").lower()

        if platform_id in ["amiga", "cdtv", "cd32"]:
            value_config_loader = ValueConfigLoader(uuid=uuid)
            value_config_loader.load_values(values)
            config = value_config_loader.get_config()
            cls.load(config)
            values["__config_name"] = config.get("__config_name")
        else:
            print("Warning: Non-Amiga game loaded")
            platform_handler = PlatformHandler.create(platform_id)
            loader = platform_handler.get_loader(fsgs)
            fsgs.config.load(loader.load_values(values))
        cls.post_load_values(values)
    def run_config_in_background(config):
        print(config)

        gscontext = FSGameSystemContext()
        gscontext.config.set(config.items())

        platform_handler = PlatformHandler.create("amiga")
        driver = platform_handler.get_runner(gscontext)

        device_helper = EnumerateHelper()
        device_helper.default_port_selection(driver.ports, driver.options)

        driver.prepare()
        driver.install()

        # import sys
        # sys.exit(1)

        # set_progress("__run__")
        driver.run()

        Thread(None, runhelper_cleanup_thread, args=(driver,)).start()
 def get_item_text(self, index):
     item = self.items[index]
     name = item[str("name")]
     platform_id = item[str("platform")] or ""
     if "[" in name:
         name, extra = name.split("[", 1)
         name = name.strip()
         extra = " \u00b7 " + extra.strip(" ]")
     else:
         extra = ""
     sep = " \u00b7 "
     name = name.replace("\n", " \u00b7 ")
     if platform_id == Product.default_platform_id:
         platform = ""
     elif platform_id == "Amiga" and not openretro:
         platform = ""
     elif platform_id:
         platform = sep + PlatformHandler.get_platform_name(platform_id)
     else:
         platform = ""
     text = "{0}{1}{2}".format(name, extra, platform) or "Missing Name"
     return text
    def load_game_variant(self, variant_uuid):
        # game_database = fsgs.get_game_database()
        # values = game_database.get_game_values_for_uuid(variant_uuid)

        from .Database import Database

        database = Database.instance()
        try:
            database_name = database.find_game_database_for_game_variant(
                variant_uuid
            )
        except LookupError:
            return False

        try:
            values = self.game.set_from_variant_uuid(
                database_name, variant_uuid
            )
        except KeyError:
            # It is possible that the variant is found without game entry,
            # which raises a KeyError.
            return False
        if not values:
            return False

        # print("")
        # for key in sorted(values.keys()):
        #     print(" * {0} = {1}".format(key, values[key]))
        # print("")

        from fsgamesys.platforms.platform import PlatformHandler

        platform_handler = PlatformHandler.create(self.game.platform.id)
        loader = platform_handler.get_loader(self)
        self.config.load(loader.load_values(values))
        return True
示例#12
0
    def load_database_values(self, values, *, database_name, game_uuid,
                             variant_uuid):
        print("-" * 79)
        print("ConfigLoader.load_database_values")
        # LauncherConfig.set("__changed", "0")
        # LauncherConfig.set("__database", database_name)

        # self.load_values(values, uuid=variant_uuid)

        platform_id = values.get("platform", "").lower()
        if platform_id in ["", "amiga", "cdtv", "cd32"]:
            value_config_loader = ValueConfigLoader(uuid=variant_uuid)
            value_config_loader.load_values(values)
            new_config = value_config_loader.get_config()
        else:
            platform_handler = PlatformHandler.create(platform_id)
            # FIXME:
            fsgs = None
            loader = platform_handler.get_loader(fsgs)
            new_config = loader.load_values(values)

        # self._config.set(__CHANGED, "0")
        # self._config.set(__DATABASE_NAME, database_name)
        # self._config.set_multiple()
        new_config[CHANGED__] = 0
        new_config[DATABASE_NAME__] = database_name
        new_config[GAME_UUID__] = game_uuid
        # VariantBrowser expects parent_uuid to be set
        new_config[PARENT_UUID] = game_uuid
        new_config[VARIANT_UUID__] = variant_uuid
        from pprint import pprint

        pprint(new_config)

        # self._config.clear()
        self._config.clear_and_set(new_config.items())
示例#13
0
 def __init__(self):
     PlatformHandler.__init__(self)
    def name(self):
        from .platform import PlatformHandler

        return PlatformHandler.get_platform_name(self._id)
示例#15
0
    def __init__(self, platform):
        AutoExpandItem.__init__(self)
        self._platform = platform
        # using self.platform for "description"

        # self.sort_title = ""
        # try:
        #    self.title, self.subtitle, self.sort_title = {
        #        "Amiga": (
        #            "Amiga",
        #            "Commodore Amiga",
        #            "Commodore 2"),
        #        "amstrad-cpc": (
        #            "Amstrad CPC",
        #            "Color Personal Computer",
        #            ""),
        #        "apple-II": (
        #            "Apple II",
        #            "II/Plus/e/c",
        #            ""),
        #        "arcade": (
        #            "Arcade Video Games",
        #            "Multiple Arcade Machines",
        #            ""),
        #        "atari-2600": (
        #            "Atari 2600",
        #            "Video Computer System",
        #            "Atari 1"),
        #        "atari-8-bit": (
        #            "Atari 8-Bit",
        #            "Atari 400/800/XL/XE",
        #            "Atari 2"),
        #        "atari-5200": (
        #            "Atari 5200",
        #            "Atari 5200 SuperSystem",
        #            "Atari 3"),
        #        "atari-7800": (
        #            "Atari 7800",
        #            "Atari 7800 ProSystem",
        #            "Atari 4"),
        #        "atari-st": (
        #            "Atari ST",
        #            "Atari ST/STE",
        #            "Atari 5"),
        #        "bbc-micro": (
        #            "BBC Micro",
        #            "Acorn BCC Micro",
        #            ""),
        #        "commodore-64": (
        #            "Commodore 64",
        #            "",
        #            "Commodore 1"),
        #        "game-boy": (
        #            "Game Boy",
        #            "",
        #            "Nintendo 2"),
        #        "game-boy-color": (
        #            "Game Boy Color",
        #            "",
        #            "Nintendo 5"),
        #        "game-boy-advance": (
        #            "Game Boy Advance",
        #            "",
        #            "Nintendo 6"),
        #        "game-cube": (
        #            "GameCube",
        #            "Nintendo GameCube",
        #            "Nintendo 7"),
        #        "game-gear": (
        #            "Game Gear",
        #            "Sega Game Gear",
        #            "Sega 3"),
        #        "lynx": (
        #            "Atari Lynx",
        #            "",
        #            "Atari 6"),
        #        "nintendo": (
        #            "Nintendo",
        #            "",
        #            "Nintendo 1"),
        #        "nintendo-64": (
        #            "Nintendo 64",
        #            "",
        #            "Nintendo 4"),
        #        "DOS": (
        #            "DOS",
        #            "IBM PC Compatible",
        #            "PC 1"),
        #        "master-system": (
        #            "Master System",
        #            "Sega Master System / Mark III",
        #            "Sega 1"),
        #        "mega-drive": (
        #            "Mega Drive",
        #            "Sega Mega Drive / Genesis",
        #            "Sega 2"),
        #        "playstation": (
        #            "PlayStation",
        #            "Sony PlayStation",
        #            ""),
        #        "playstation-2": (
        #            "PlayStation 2",
        #            "Sony PlayStation 2",
        #            ""),
        #        "super-nintendo": (
        #            "Super Nintendo",
        #            "Entertainment System",
        #            "Nintendo 3"),
        #        "turbografx-16": (
        #            "TurboGrafx-16",
        #            "Entertainment SuperSystem",
        #            ""),
        #        "wii": (
        #            "Wii",
        #            "Nintendo Wii",
        #            "Nintendo 8"),
        #        "windows": (
        #            "Windows",
        #            "IBM PC Compatible",
        #            "PC 2"),
        #        "zx-spectrum": (
        #            "ZX Spectrum",
        #            "Sinclair ZX Spectrum",
        #            ""),
        #    }[platform]
        # except KeyError:
        #    self.title = platform
        self.platform = platform
        self.path_title = platform

        self.title = PlatformHandler.get_platform_name(platform)
        self.path_title = self.title

        # self.title = ""
        # self.title = "CHOOSE PLATFORM: " + self.title
        # self.subtitle = ""
        self.subtitle = "CHOOSE PLATFORM"

        # if not self.sort_title:
        #     self.sort_title = self.title

        # FIXME: for now, test using just title as sort title
        self.sort_title = self.title
def render_bottom_bar_text(item):
    strength = 0.9
    x = 544
    y = 290

    title = item.title.upper()
    title = title.strip()
    if "[" in title:
        title, subtitle = title.rsplit("[", 1)
        title = title.strip()
        subtitle = subtitle.strip()
        if subtitle.endswith("]"):
            subtitle = subtitle[:-1]
    else:
        subtitle = ""
    if title:
        Render.get().text(
            title,
            Font.title_font,
            x,
            y,
            1920 - x - 170,
            shadow=True,
            color=(1.0, 1.0, 1.0, 1.0 * strength),
        )
        if subtitle:
            color = (0x6E / 0xFF, 0x8B / 0xFF, 0x96 / 0xFF, 0.75)
            tw, th = Render.get().measure_text(title, Font.title_font)
            Render.get().text(
                subtitle,
                Font.title_font,
                x + tw + 20,
                y,
                1920 - x - 170,
                shadow=True,
                color=color,
            )

    color = (0xC4 / 0xFF, 0xD7 / 0xFF, 0xDE / 0xFF, 1.0)
    year_text = str(
        getattr(State.get().current_menu.selected_item, "year", "")
        or "").upper()
    if year_text:
        tw, th = Render.get().measure_text(year_text, Font.title_font)
        Render.get().text(
            year_text,
            Font.title_font,
            1920 - 30 - tw,
            y,
            0,
            shadow=True,
            color=color,
        )
    color = (0x6E / 0xFF, 0x8B / 0xFF, 0x96 / 0xFF, 1.0)
    y = 258
    text_str = ""
    companies = set()
    publisher_text = (getattr(State.get().current_menu.selected_item,
                              "publisher", "") or "").upper()
    for text in publisher_text.split("/"):
        text = text.strip()
        if text:
            if text not in companies:
                text_str = text_str + u" \u00b7 " + text
                companies.add(text)
    developer_text = (getattr(State.get().current_menu.selected_item,
                              "developer", "") or "").upper()
    for text in developer_text.split("/"):
        text = text.strip()
        if text:
            if text not in companies:
                text_str = text_str + u" \u00b7 " + text
                companies.add(text)
    if len(text_str) > 3:
        text_str = text_str[3:]  # remove initial middle dot
        tw, th = Render.get().measure_text(text_str, Font.subtitle_font)
        Render.get().text(
            text_str,
            Font.subtitle_font,
            1920 - 30 - tw,
            y,
            0,
            shadow=True,
            color=color,
        )

    platform_str = str(
        getattr(State.get().current_menu.selected_item, "platform", "") or "")
    if platform_str:
        platform_str = PlatformHandler.get_platform_name(platform_str).upper()
    if len(platform_str) >= 3:
        # tw, th = Render.get().measure_text(platform_str, Font.subtitle_font)
        Render.get().text(platform_str,
                          Font.subtitle_font,
                          x,
                          y,
                          0,
                          shadow=True,
                          color=color)
    return