def update_layout_description(self, description: LayoutDescription): self.layout_description = description self.layout_info_tab.show() self.export_log_button.setEnabled(description.permalink.spoiler) title_text = """ <p> Permalink: <span style='font-weight:600;'>{description.permalink.as_str}</span><br/> Seed Hash: {description.shareable_word_hash} ({description.shareable_hash})<br/> Preset Name: {description.permalink.preset.name} </p> """.format(description=description) self.layout_title_label.setText(title_text) categories = list( preset_describer.describe(description.permalink.preset)) self.layout_description_left_label.setText( preset_describer.merge_categories(categories[::2])) self.layout_description_right_label.setText( preset_describer.merge_categories(categories[1::2])) # Game Spoiler has_spoiler = description.permalink.spoiler self.pickup_tab.setEnabled(has_spoiler) if has_spoiler: pickup_names = { pickup.name for pickup in description.patches.pickup_assignment.values() } else: pickup_names = {} self.layout_info_tab.removeTab( self.layout_info_tab.indexOf(self.pickup_tab)) self.pickup_spoiler_pickup_combobox.clear() self.pickup_spoiler_pickup_combobox.addItem("None") for pickup_name in sorted(pickup_names): self.pickup_spoiler_pickup_combobox.addItem(pickup_name) for pickup_button in self.pickup_spoiler_buttons: pickup = description.patches.pickup_assignment.get( pickup_button.pickup_index) if pickup is not None: pickup_button.item_name = pickup.name if has_spoiler else "????" else: pickup_button.item_name = "Nothing" if not pickup_button.item_is_hidden: pickup_button.setText(pickup_button.item_name)
def on_preset_changed(self, preset: Preset): self._has_preset = True self.window.create_preset_description.setText(preset.description) self._action_delete.setEnabled(preset.base_preset_name is not None) create_preset_combo = self.window.create_preset_combo create_preset_combo.setCurrentIndex(create_preset_combo.findText(preset.name)) categories = list(preset_describer.describe(preset)) left_categories = categories[::2] right_categories = categories[1::2] self.window.create_describe_left_label.setText(preset_describer.merge_categories(left_categories)) self.window.create_describe_right_label.setText(preset_describer.merge_categories(right_categories))
def on_preset_changed(self, preset: Optional[VersionedPreset]): can_generate = False if preset is None: description = "Please select a preset from the list, not a game." else: try: raw_preset = preset.get_preset() can_generate = True description = f"<p style='font-weight:600;'>{raw_preset.name}</p><p>{raw_preset.description}</p>" description += preset_describer.merge_categories( preset_describer.describe(raw_preset)) except InvalidPreset as e: logging.exception(f"Invalid preset for {preset.name}") description = ( f"Preset {preset.name} can't be used as it contains the following error:" f"\n{e.original_exception}\n" f"\nPlease open edit the preset file with id {preset.uuid} manually or delete this preset." ) self.window.create_preset_description.setText(description) for btn in [ self.window.create_generate_button, self.window.create_generate_race_button ]: btn.setEnabled(can_generate)
def _update_current_player(self): description = self.layout_description current_player = self.current_player_index preset = description.permalink.get_preset(current_player) self.permalink_edit.setText(description.permalink.as_base64_str) title_text = """ <p> Seed Hash: {description.shareable_word_hash} ({description.shareable_hash})<br/> Preset Name: {preset.name} </p> """.format(description=description, preset=preset) self.layout_title_label.setText(title_text) categories = list(preset_describer.describe(preset)) self.layout_description_left_label.setText( preset_describer.merge_categories(categories[::2])) self.layout_description_right_label.setText( preset_describer.merge_categories(categories[1::2])) # Game Spoiler has_spoiler = description.permalink.spoiler self.pickup_tab.setEnabled(has_spoiler) patches = description.all_patches[current_player] if has_spoiler: pickup_names = { pickup.pickup.name for pickup in patches.pickup_assignment.values() } game_description = default_database.game_description_for( preset.game) self._create_pickup_spoilers(game_description) starting_area = game_description.world_list.area_by_area_location( patches.starting_location) extra_items = item_names.additional_starting_items( preset.configuration, game_description.resource_database, patches.starting_items) self.spoiler_starting_location_label.setText( "Starting Location: {}".format( game_description.world_list.area_name(starting_area))) self.spoiler_starting_items_label.setText( "Random Starting Items: {}".format( ", ".join(extra_items) if extra_items else "None")) self._update_show_all_button_state() else: pickup_names = {} self.layout_info_tab.removeTab( self.layout_info_tab.indexOf(self.pickup_tab)) self.spoiler_starting_location_label.setText("Starting Location") self.spoiler_starting_items_label.setText("Random Starting Items") self.pickup_spoiler_pickup_combobox.clear() self.pickup_spoiler_pickup_combobox.addItem("None") for pickup_name in sorted(pickup_names): self.pickup_spoiler_pickup_combobox.addItem(pickup_name) for pickup_button in self.pickup_spoiler_buttons: pickup_target = patches.pickup_assignment.get( pickup_button.pickup_index) pickup_button.target_player = None if pickup_target is not None: pickup_button.item_name = pickup_target.pickup.name if has_spoiler else "????" if has_spoiler and description.permalink.player_count > 1: pickup_button.target_player = pickup_target.player pickup_button.player_names = self._player_names else: pickup_button.item_name = "Nothing" if not pickup_button.item_is_hidden: pickup_button.setText(pickup_button.item_name)