Esempio n. 1
0
 def allowed_games(self) -> List[RandovaniaGame]:
     dev_features = self.dev_features or ""
     return [
         game for game in RandovaniaGame.sorted_all_games()
         if game.data.defaults_available_in_game_sessions
         or game.value in dev_features
     ]
Esempio n. 2
0
    def update_items(self):
        self.clear()

        tree_item: dict[Any, QtWidgets.QTreeWidgetItem] = {}
        for game in RandovaniaGame.sorted_all_games():
            if not game.data.development_state.can_view(
                    self.show_experimental):
                continue

            root = QtWidgets.QTreeWidgetItem(self)
            root.setText(0, game.long_name)
            root.setExpanded(True)
            tree_item[game] = root

        self.preset_to_item = {}

        # Included presets
        for preset in self.window_manager.preset_manager.included_presets.values(
        ):
            if not preset.game.data.development_state.can_view(
                    self.show_experimental):
                continue

            item = QtWidgets.QTreeWidgetItem(tree_item[preset.game])
            item.setText(0, preset.name)
            item.setExpanded(True)
            item.setData(0, Qt.UserRole, preset.uuid)
            self.preset_to_item[preset.uuid] = item

        # Custom Presets
        for preset in self.window_manager.preset_manager.custom_presets.values(
        ):
            if not preset.game.data.development_state.can_view(
                    self.show_experimental):
                continue

            item = QtWidgets.QTreeWidgetItem(tree_item[preset.game])
            item.setText(0, preset.name)
            item.setData(0, Qt.UserRole, preset.uuid)
            self.preset_to_item[preset.uuid] = item

        # Set parents after, so don't have issues with order
        for preset in sorted(
                self.window_manager.preset_manager.custom_presets.values(),
                key=lambda it: it.name):
            if preset.base_preset_uuid in self.preset_to_item:
                root_item = tree_item[preset.game]
                self_item = self.preset_to_item[preset.uuid]
                target_parent = parent_item = self.preset_to_item[
                    preset.base_preset_uuid]

                while parent_item != root_item:
                    if parent_item == self_item:
                        # LOOP DETECTED!
                        target_parent = root_item
                        break
                    parent_item = parent_item.parent()

                root_item.removeChild(self_item)
                target_parent.addChild(self_item)
Esempio n. 3
0
    def _on_first_show(self):
        self._index_for_game = {}

        for game in RandovaniaGame.sorted_all_games():
            if game.gui.help_widget is None:
                continue

            index = self.addTab(game.gui.help_widget(), game.long_name)
            self.setTabVisible(
                index,
                game.data.development_state.can_view(
                    self._experimental_visible))
            self._index_for_game[game] = index
Esempio n. 4
0
    def _on_first_show(self):
        self._index_for_game = {}
        self._layout_for_index = {}
        self._games_with_widget = set()

        for game in RandovaniaGame.sorted_all_games():
            if game.gui.help_widget is None:
                continue

            widget = QtWidgets.QWidget()
            widget.game = game
            widget_layout = QtWidgets.QVBoxLayout(widget)
            widget_layout.setContentsMargins(0, 0, 0, 0)

            index = self.addTab(widget, game.long_name)
            self.setTabVisible(
                index,
                game.data.development_state.can_view(
                    self._experimental_visible))
            self._index_for_game[game] = index
            self._layout_for_index[index] = widget_layout

        self.currentChanged.connect(self.ensure_current_game_has_widget)
        self.ensure_current_game_has_widget()
    def update_items(self):
        if self.expanded_connected:
            self.itemExpanded.disconnect(self.on_item_expanded)
            self.itemCollapsed.disconnect(self.on_item_collapsed)
            self.expanded_connected = False

        self.clear()

        self.root_tree_items = {}

        for game in RandovaniaGame.sorted_all_games():
            if not game.data.development_state.can_view(
                    self.show_experimental):
                continue

            root = QtWidgets.QTreeWidgetItem(self)
            root.setText(0, game.long_name)
            root.setExpanded(self.options.is_game_expanded(game))
            self.root_tree_items[game] = root

        self.preset_to_item = {}

        # Included presets
        for preset in self.window_manager.preset_manager.included_presets.values(
        ):
            if not preset.game.data.development_state.can_view(
                    self.show_experimental):
                continue

            item = QtWidgets.QTreeWidgetItem(self.root_tree_items[preset.game])
            item.setText(0, preset.name)
            item.setData(0, Qt.UserRole, preset.uuid)
            self.preset_to_item[preset.uuid] = item

        # Custom Presets
        for preset in self.window_manager.preset_manager.custom_presets.values(
        ):
            if not preset.game.data.development_state.can_view(
                    self.show_experimental):
                continue

            item = QtWidgets.QTreeWidgetItem(self.root_tree_items[preset.game])
            item.setText(0, preset.name)
            item.setData(0, Qt.UserRole, preset.uuid)
            self.preset_to_item[preset.uuid] = item

        # Set parents after, so don't have issues with order
        for preset in sorted(
                self.window_manager.preset_manager.custom_presets.values(),
                key=lambda it: it.name):
            if preset.base_preset_uuid in self.preset_to_item:
                root_item = self.root_tree_items[preset.game]
                self_item = self.preset_to_item[preset.uuid]
                target_parent = parent_item = self.preset_to_item[
                    preset.base_preset_uuid]

                while parent_item != root_item:
                    if parent_item == self_item:
                        # LOOP DETECTED!
                        target_parent = root_item
                        break
                    parent_item = parent_item.parent()

                root_item.removeChild(self_item)
                target_parent.addChild(self_item)

        for preset_uuid, item in self.preset_to_item.items():
            item.setExpanded(
                not self.options.is_preset_uuid_hidden(preset_uuid))

        self.itemExpanded.connect(self.on_item_expanded)
        self.itemCollapsed.connect(self.on_item_collapsed)
        self.expanded_connected = True
Esempio n. 6
0
    def __init__(self, options: Options, preset_manager: PresetManager,
                 network_client, preview: bool):
        super().__init__()
        self.setupUi(self)
        self.setWindowTitle("Randovania {}".format(VERSION))
        self._is_preview_mode = preview
        self.setAcceptDrops(True)
        common_qt_lib.set_default_window_icon(self)

        self.setup_about_text()
        self.setup_welcome_text()
        self.browse_racetime_label.setText(
            self.browse_racetime_label.text().replace("color:#0000ff;", ""))

        self._preset_manager = preset_manager
        self.network_client = network_client

        if preview:
            debug.set_level(2)

        if randovania.is_frozen():
            self.menu_bar.removeAction(self.menu_edit.menuAction())

        # Signals
        self.options_changed_signal.connect(self.on_options_changed)
        self.GameDetailsSignal.connect(self._open_game_details)
        self.InitPostShowSignal.connect(self.initialize_post_show)

        self.intro_play_now_button.clicked.connect(
            lambda: self.main_tab_widget.setCurrentWidget(self.tab_play))
        self.open_faq_button.clicked.connect(self._open_faq)
        self.open_database_viewer_button.clicked.connect(
            partial(self._open_data_visualizer_for_game,
                    RandovaniaGame.METROID_PRIME_ECHOES))

        self.import_permalink_button.clicked.connect(self._import_permalink)
        self.import_game_file_button.clicked.connect(self._import_spoiler_log)
        self.browse_racetime_button.clicked.connect(self._browse_racetime)
        self.create_new_seed_button.clicked.connect(
            lambda: self.main_tab_widget.setCurrentWidget(self.tab_create_seed
                                                          ))

        # Menu Bar
        self.game_menus = []
        self.menu_action_edits = []

        for game in RandovaniaGame.sorted_all_games():
            # Sub-Menu in Open Menu
            game_menu = QtWidgets.QMenu(self.menu_open)
            game_menu.setTitle(_t(game.long_name))
            game_menu.game = game

            if game.data.development_state.can_view(False):
                self.menu_open.addAction(game_menu.menuAction())
            self.game_menus.append(game_menu)

            game_trick_details_menu = QtWidgets.QMenu(game_menu)
            game_trick_details_menu.setTitle(_t("Trick Details"))
            self._setup_trick_difficulties_menu_on_show(
                game_trick_details_menu, game)

            game_data_visualizer_action = QtGui.QAction(game_menu)
            game_data_visualizer_action.setText(_t("Data Visualizer"))
            game_data_visualizer_action.triggered.connect(
                partial(self._open_data_visualizer_for_game, game))

            game_menu.addAction(game_trick_details_menu.menuAction())
            game_menu.addAction(game_data_visualizer_action)

            # Data Editor
            action = QtGui.QAction(self)
            action.setText(_t(game.long_name))
            self.menu_internal.addAction(action)
            action.triggered.connect(
                partial(self._open_data_editor_for_game, game))
            self.menu_action_edits.append(action)

        self.menu_action_edit_existing_database.triggered.connect(
            self._open_data_editor_prompt)
        self.menu_action_validate_seed_after.triggered.connect(
            self._on_validate_seed_change)
        self.menu_action_timeout_generation_after_a_time_limit.triggered.connect(
            self._on_generate_time_limit_change)
        self.menu_action_dark_mode.triggered.connect(
            self._on_menu_action_dark_mode)
        self.menu_action_experimental_games.triggered.connect(
            self._on_menu_action_experimental_games)
        self.menu_action_open_auto_tracker.triggered.connect(
            self._open_auto_tracker)
        self.menu_action_previously_generated_games.triggered.connect(
            self._on_menu_action_previously_generated_games)
        self.menu_action_log_files_directory.triggered.connect(
            self._on_menu_action_log_files_directory)
        self.menu_action_layout_editor.triggered.connect(
            self._on_menu_action_layout_editor)

        # Setting this event only now, so all options changed trigger only once
        options.on_options_changed = self.options_changed_signal.emit
        self._options = options

        self.main_tab_widget.setCurrentIndex(0)