Exemplo n.º 1
0
    def __init__(self, options: Options, patch_data: dict, word_hash: str,
                 spoiler: bool, games: list[RandovaniaGame]):
        super().__init__(options, patch_data, word_hash, spoiler, games)

        self._base_output_name = f"Prime Randomizer - {word_hash}"
        per_game = options.options_for_game(self._game)
        assert isinstance(per_game, PrimePerGameOptions)

        # Input
        self.input_file_button.clicked.connect(self._on_input_file_button)

        # Output
        self.output_file_button.clicked.connect(self._on_output_file_button)

        # Output format
        self.setup_multi_format(per_game.output_format)

        # Echoes input
        self.echoes_file_button.clicked.connect(self._on_echoes_file_button)

        # Echoes ISO input
        if RandovaniaGame.METROID_PRIME_ECHOES in games:
            self._use_echoes_models = RandovaniaGame.METROID_PRIME_ECHOES in per_game.use_external_models
            self.echoes_models_check.setChecked(self._use_echoes_models)
            self._on_echoes_models_check()
            self.echoes_models_check.clicked.connect(
                self._on_echoes_models_check)

            echoes_options = options.options_for_game(
                RandovaniaGame.METROID_PRIME_ECHOES)
            assert isinstance(echoes_options, EchoesPerGameOptions)
            if echoes_options.input_path is not None:
                self.echoes_file_edit.setText(str(echoes_options.input_path))

        else:
            self._use_echoes_models = False
            self.echoes_models_check.hide()
            self.echoes_file_edit.hide()
            self.echoes_file_label.hide()
            self.echoes_file_button.hide()

        if per_game.input_path is not None:
            self.input_file_edit.setText(str(per_game.input_path))

        if per_game.output_directory is not None:
            output_path = per_game.output_directory.joinpath(
                self.default_output_name)
            self.output_file_edit.setText(str(output_path))

        add_field_validation(
            accept_button=self.accept_button,
            fields={
                self.input_file_edit:
                lambda: is_file_validator(self.input_file),
                self.output_file_edit:
                lambda: output_file_validator(self.output_file),
                self.echoes_file_edit:
                lambda: self._use_echoes_models and is_file_validator(
                    self.echoes_file),
            })
Exemplo n.º 2
0
def test_save_options(skip_qtbot, tmp_path, is_prime_multi):
    options = Options(tmp_path)
    games = [RandovaniaGame.METROID_PRIME]
    if is_prime_multi:
        games.append(RandovaniaGame.METROID_PRIME_ECHOES)
    window = PrimeGameExportDialog(options, {}, "MyHash", True, games)
    window.output_file_edit.setText("somewhere/game.iso")

    if is_prime_multi:
        skip_qtbot.mouseClick(window.echoes_models_check, QtCore.Qt.LeftButton)
        window.echoes_file_edit.setText("somewhere/echoes.iso")

    # Run
    window.save_options()

    # Assert
    assert options.options_for_game(
        RandovaniaGame.METROID_PRIME).output_directory == Path("somewhere")
    if is_prime_multi:
        assert options.options_for_game(
            RandovaniaGame.METROID_PRIME).use_external_models == {
                RandovaniaGame.METROID_PRIME_ECHOES
            }
        assert options.options_for_game(
            RandovaniaGame.METROID_PRIME_ECHOES).input_path == Path(
                "somewhere/echoes.iso")
Exemplo n.º 3
0
    def __init__(self, options: Options, patch_data: dict, word_hash: str, spoiler: bool, games: list[RandovaniaGame]):
        super().__init__(options, patch_data, word_hash, spoiler, games)

        self.default_output_name = f"Echoes Randomizer - {word_hash}"
        self._prompt_input_file = check_extracted_game(self.input_file_edit, self.input_file_button,
                                                       self._contents_file_path)

        per_game = options.options_for_game(self._game)
        assert isinstance(per_game, EchoesPerGameOptions)

        # Input
        self.input_file_button.clicked.connect(self._on_input_file_button)

        # Output
        self.output_file_button.clicked.connect(self._on_output_file_button)

        # Prime input
        self.prime_file_button.clicked.connect(self._on_prime_file_button)

        if RandovaniaGame.METROID_PRIME in games:
            self._use_prime_models = RandovaniaGame.METROID_PRIME in per_game.use_external_models
            self.prime_models_check.setChecked(self._use_prime_models)
            self._on_prime_models_check()
            self.prime_models_check.clicked.connect(self._on_prime_models_check)

            prime_options = options.options_for_game(RandovaniaGame.METROID_PRIME)
            assert isinstance(prime_options, PrimePerGameOptions)
            if prime_options.input_path is not None:
                self.prime_file_edit.setText(str(prime_options.input_path))

        else:
            self._use_prime_models = False
            self.prime_models_check.hide()
            self.prime_file_edit.hide()
            self.prime_file_label.hide()
            self.prime_file_button.hide()

        if self._prompt_input_file and per_game.input_path is not None:
            self.input_file_edit.setText(str(per_game.input_path))

        if per_game.output_directory is not None:
            output_path = per_game.output_directory.joinpath(f"{self.default_output_name}.iso")
            self.output_file_edit.setText(str(output_path))

        add_field_validation(
            accept_button=self.accept_button,
            fields={
                self.input_file_edit: lambda: echoes_input_validator(self.input_file, self._prompt_input_file,
                                                                     self.input_file_edit),
                self.output_file_edit: lambda: output_file_validator(self.output_file),
                self.prime_file_edit: lambda: self._use_prime_models and is_file_validator(self.prime_file),
            }
        )
Exemplo n.º 4
0
    def __init__(self, options: Options, patch_data: dict, word_hash: str,
                 spoiler: bool, games: list[RandovaniaGame]):
        super().__init__(options, patch_data, word_hash, spoiler, games)

        self._base_output_name = f"SM Randomizer - {word_hash}"
        per_game = options.options_for_game(self._game)
        assert isinstance(per_game, SuperMetroidPerGameOptions)

        # Input
        self.input_file_button.clicked.connect(self._on_input_file_button)

        # Output
        self.output_file_button.clicked.connect(self._on_output_file_button)

        # Output format
        self.setup_multi_format(per_game.output_format)

        if per_game.input_path is not None:
            self.input_file_edit.setText(str(per_game.input_path))

        if per_game.output_directory is not None:
            output_path = per_game.output_directory.joinpath(
                self.default_output_name)
            self.output_file_edit.setText(str(output_path))

        add_field_validation(
            accept_button=self.accept_button,
            fields={
                self.input_file_edit:
                lambda: not self.input_file.is_file(),
                self.output_file_edit:
                lambda: output_file_validator(self.output_file),
            })
def test_save_options(skip_qtbot, tmp_path):
    options = Options(tmp_path)
    window = SuperMetroidGameExportDialog(options, {}, "MyHash", True, [])
    window.output_file_edit.setText("somewhere/game.smc")

    # Run
    window.save_options()

    # Assert
    assert options.options_for_game(
        RandovaniaGame.SUPER_METROID).output_directory == Path("somewhere")
def test_save_options(skip_qtbot, tmp_path):
    options = Options(tmp_path)

    window = CSGameExportDialog(options, {}, "MyHash", True, [])
    window.output_file_edit.setText("somewhere/foo")

    # Run
    window.save_options()

    # Assert
    assert options.options_for_game(
        RandovaniaGame.CAVE_STORY).output_directory == Path("somewhere/foo")
def test_save_options(skip_qtbot, tmp_path):
    options = Options(tmp_path)

    window = DreadGameExportDialog(options, {}, "MyHash", True, [])
    window.atmosphere_radio.setChecked(True)

    # Run
    window.save_options()

    # Assert
    game_options = options.options_for_game(RandovaniaGame.METROID_DREAD)
    assert isinstance(game_options, DreadPerGameOptions)
    assert game_options.target_platform == DreadModPlatform.ATMOSPHERE
Exemplo n.º 8
0
    def __init__(self, options: Options, patch_data: dict, word_hash: str,
                 spoiler: bool, games: list[RandovaniaGame]):
        super().__init__(options, patch_data, word_hash, spoiler, games)

        per_game = options.options_for_game(self._game)
        assert isinstance(per_game, CSPerGameOptions)

        # Output
        self.output_file_button.clicked.connect(self._on_output_file_button)

        if per_game.output_directory is not None:
            output_path = per_game.output_directory
            self.output_file_edit.setText(str(output_path))

        add_field_validation(
            accept_button=self.accept_button,
            fields={
                self.output_file_edit:
                lambda: is_directory_validator(self.output_file_edit),
            })
Exemplo n.º 9
0
    def __init__(self, options: Options, patch_data: dict, word_hash: str, spoiler: bool, games: list[RandovaniaGame]):
        super().__init__(options, patch_data, word_hash, spoiler, games)

        per_game = options.options_for_game(self._game)
        assert isinstance(per_game, DreadPerGameOptions)

        self._validate_input_file()
        self._validate_custom_path()

        # Input
        self.input_file_edit.textChanged.connect(self._on_input_file_change)
        self.input_file_button.clicked.connect(self._on_input_file_button)

        # Target Platform
        if per_game.target_platform == DreadModPlatform.ATMOSPHERE:
            self.atmosphere_radio.setChecked(True)
        else:
            self.ryujinx_radio.setChecked(True)

        self.atmosphere_radio.toggled.connect(self._on_update_target_platform)
        self.ryujinx_radio.toggled.connect(self._on_update_target_platform)
        self._on_update_target_platform()

        # Small Size
        self.exlaunch_check.setChecked(per_game.reduce_mod_size)

        # Output to SD
        self.sd_non_removable.clicked.connect(self.refresh_drive_list)
        self.sd_refresh_button.clicked.connect(self.refresh_drive_list)
        self.tab_sd_card.serialize_options = lambda: {
            "drive": serialize_path(self.sd_combo.currentData()),
            "non_removable": self.sd_non_removable.isChecked(),
            "mod_manager": self.sd_mod_manager_check.isChecked(),
        }
        self.tab_sd_card.restore_options = self.sd_restore_options
        self.tab_sd_card.is_valid = lambda: self.sd_combo.currentData() is not None

        # Output to FTP
        self.tab_ftp.is_valid = self.ftp_is_valid
        self.ftp_test_button.setVisible(False)
        self.ftp_anonymous_check.clicked.connect(self.ftp_on_anonymous_check)
        add_validation(self.ftp_username_edit,
                       lambda: self.ftp_anonymous_check.isChecked() or self.ftp_username_edit.text(),
                       self.update_accept_validation)
        add_validation(self.ftp_password_edit,
                       lambda: self.ftp_anonymous_check.isChecked() or self.ftp_password_edit.text(),
                       self.update_accept_validation)
        add_validation(self.ftp_ip_edit, lambda: self.ftp_ip_edit.text(), self.update_accept_validation)
        self.ftp_port_edit.setValidator(QtGui.QIntValidator(1, 65535, self))

        self.tab_ftp.serialize_options = lambda: {
            "anonymous": self.ftp_anonymous_check.isChecked(),
            "username": self.ftp_username_edit.text(),
            "password": self.ftp_password_edit.text(),
            "ip": self.ftp_ip_edit.text(),
            "port": self.ftp_port_edit.text(),
        }
        self.tab_ftp.restore_options = self.ftp_restore_options
        update_validation(self.ftp_username_edit)
        update_validation(self.ftp_ip_edit)
        self.ftp_on_anonymous_check()

        # Output to Ryujinx
        self.update_ryujinx_ui()
        self.tab_ryujinx.serialize_options = lambda: {}
        self.tab_ryujinx.restore_options = lambda p: None
        self.tab_ryujinx.is_valid = lambda: True

        # Output to Custom
        self.custom_path_edit.textChanged.connect(self._on_custom_path_change)
        self.custom_path_button.clicked.connect(self._on_custom_path_button)
        self.tab_custom_path.serialize_options = lambda: {
            "path": serialize_path(path_in_edit(self.custom_path_edit)),
        }
        self.tab_custom_path.restore_options = self.custom_restore_options
        self.tab_custom_path.is_valid = lambda: not self.custom_path_edit.has_error

        self._output_tab_by_name = {
            "sd": self.tab_sd_card,
            "ftp": self.tab_ftp,
            "ryujinx": self.tab_ryujinx,
            "custom": self.tab_custom_path,
        }

        # Restore options
        if per_game.input_directory is not None:
            self.input_file_edit.setText(str(per_game.input_directory))

        if per_game.output_preference is not None:
            output_preference = json.loads(per_game.output_preference)
            tab_options = output_preference["tab_options"]

            for tab_name, the_tab in self._output_tab_by_name.items():
                if tab_name == output_preference.get("selected_tab"):
                    index = self.output_tab_widget.indexOf(the_tab)
                    if self.output_tab_widget.isTabVisible(index):
                        self.output_tab_widget.setCurrentIndex(index)

                try:
                    if tab_name in tab_options:
                        the_tab.restore_options(tab_options[tab_name])
                except Exception:
                    logging.exception("Unable to restore preferences for output")

        # Accept
        self.output_tab_widget.currentChanged.connect(self.update_accept_validation)
        self.sd_combo.currentIndexChanged.connect(self.update_accept_validation)

        self.update_accept_validation()