def on_preset_changed(self, preset: Preset): for extra_tab in self._extra_tabs: extra_tab.on_preset_changed(preset) # Variables config = preset.configuration # Title common_qt_lib.set_edit_if_different(self.name_edit, preset.name) # Trick Level trick_level_configuration = preset.configuration.trick_level self.trick_level_minimal_logic_check.setChecked( trick_level_configuration.minimal_logic) for trick, slider in self._slider_for_trick.items(): assert self._slider_for_trick[trick] is slider slider.setValue( trick_level_configuration.level_for_trick(trick).as_number) slider.setEnabled(not trick_level_configuration.minimal_logic) # Damage set_combo_with_value(self.damage_strictness_combo, config.damage_strictness) self.energy_tank_capacity_spin_box.setValue(config.energy_per_tank) self.dangerous_tank_check.setChecked(config.dangerous_energy_tank) if self.game_enum == RandovaniaGame.PRIME2: self.safe_zone_logic_heal_check.setChecked( config.safe_zone.fully_heal) self.safe_zone_regen_spin.setValue( config.safe_zone.heal_per_second) self.varia_suit_spin_box.setValue(config.varia_suit_damage) self.dark_suit_spin_box.setValue(config.dark_suit_damage) # Elevator set_combo_with_value(self.elevators_combo, config.elevators) # Starting Area self.on_preset_changed_starting_area(preset) # Location Pool available_locations = config.available_locations set_combo_with_value(self.randomization_mode_combo, available_locations.randomization_mode) self._during_batch_check_update = True for node, check in self._location_pool_for_node.items(): check.setChecked( node.pickup_index not in available_locations.excluded_indices) check.setEnabled(available_locations.randomization_mode == RandomizationMode.FULL or node.major_location) self._during_batch_check_update = False
def _on_permalink_changed(self, value: str): common_qt_lib.set_error_border_stylesheet(self.permalink_edit, False) common_qt_lib.set_edit_if_different(self.permalink_edit, self.permalink_edit.text().strip()) self.accept_button.setEnabled(False) self.import_error_label.setText("") try: # Ignoring return value: we only want to know if it's valid self.get_permalink_from_field() self.accept_button.setEnabled(True) except ValueError as e: self.import_error_label.setText(f"Invalid permalink: {e}") common_qt_lib.set_error_border_stylesheet(self.permalink_edit, True)
def _on_permalink_changed(self, value: str): common_qt_lib.set_error_border_stylesheet(self.permalink_edit, False) common_qt_lib.set_edit_if_different(self.permalink_edit, self.permalink_edit.text().strip()) self.accept_button.setEnabled(False) self.import_error_label.setText("") try: # Ignoring return value: we only want to know if it's valid new_permalink = self.get_permalink_from_field() if new_permalink.as_base64_str != self.permalink_edit.text(): raise ValueError( "Imported permalink is different from text field.") self.accept_button.setEnabled(True) except (ValueError, UnsupportedPermalink) as e: if isinstance(e, UnsupportedPermalink): msg = f"Unsupported permalink: {e}" else: msg = f"Invalid permalink: {e}" self.import_error_label.setText(msg) common_qt_lib.set_error_border_stylesheet(self.permalink_edit, True)
def on_preset_changed(self, preset: Preset): self._main_rules.on_preset_changed(preset) self._game_patches.on_preset_changed(preset) # Variables layout_config = preset.layout_configuration patcher_config = preset.patcher_configuration # Title common_qt_lib.set_edit_if_different(self.name_edit, preset.name) # Trick Level trick_level_configuration = preset.layout_configuration.trick_level_configuration trick_level = trick_level_configuration.global_level set_combo_with_value(self.logic_combo_box, trick_level) self.logic_level_label.setText( _get_trick_level_description(trick_level)) for (trick, checkbox), slider in zip(self._checkbox_for_trick.items(), self._slider_for_trick.values()): assert self._slider_for_trick[trick] is slider has_specific_level = trick_level_configuration.has_specific_level_for_trick( trick) checkbox.setEnabled( trick_level != LayoutTrickLevel.MINIMAL_RESTRICTIONS) slider.setEnabled(has_specific_level) slider.setValue( trick_level_configuration.level_for_trick(trick).as_number) checkbox.setChecked(has_specific_level) # Damage set_combo_with_value(self.damage_strictness_combo, layout_config.damage_strictness) self.energy_tank_capacity_spin_box.setValue( layout_config.energy_per_tank) self.varia_suit_spin_box.setValue(patcher_config.varia_suit_damage) self.dark_suit_spin_box.setValue(patcher_config.dark_suit_damage) # Elevator set_combo_with_value(self.elevators_combo, layout_config.elevators) # Sky Temple Keys keys = layout_config.sky_temple_keys if isinstance(keys.value, int): self.skytemple_slider.setValue(keys.value) data = int else: data = keys set_combo_with_value(self.skytemple_combo, data) # Starting Area starting_locations = layout_config.starting_location.locations self._during_batch_check_update = True for world in self.game_description.world_list.worlds: for area in world.areas: is_checked = AreaLocation( world.world_asset_id, area.area_asset_id) in starting_locations self._starting_location_for_area[ area.area_asset_id].setChecked(is_checked) self._during_batch_check_update = False # Location Pool available_locations = layout_config.available_locations set_combo_with_value(self.randomization_mode_combo, available_locations.randomization_mode) self._during_batch_check_update = True for node, check in self._location_pool_for_node.items(): check.setChecked( node.pickup_index not in available_locations.excluded_indices) check.setEnabled(available_locations.randomization_mode == RandomizationMode.FULL or node.major_location) self._during_batch_check_update = False # Translator Gates translator_configuration = preset.layout_configuration.translator_configuration for gate, combo in self._combo_for_gate.items(): set_combo_with_value( combo, translator_configuration.translator_requirement[gate]) # Hints set_combo_with_value(self.hint_sky_temple_key_combo, preset.layout_configuration.hints.sky_temple_keys) # Beam Configuration self.on_preset_changed_beam_configuration(preset)
def on_preset_changed(self, preset: Preset): self._main_rules.on_preset_changed(preset) self._game_patches.on_preset_changed(preset) # Variables layout_config = preset.layout_configuration patcher_config = preset.patcher_configuration # Title common_qt_lib.set_edit_if_different(self.name_edit, preset.name) # Trick Level trick_level_configuration = preset.layout_configuration.trick_level_configuration self.trick_level_minimal_logic_check.setChecked( trick_level_configuration.minimal_logic) for trick, slider in self._slider_for_trick.items(): assert self._slider_for_trick[trick] is slider slider.setValue( trick_level_configuration.level_for_trick(trick).as_number) slider.setEnabled(not trick_level_configuration.minimal_logic) # Damage set_combo_with_value(self.damage_strictness_combo, layout_config.damage_strictness) self.energy_tank_capacity_spin_box.setValue( layout_config.energy_per_tank) self.safe_zone_logic_heal_check.setChecked( layout_config.safe_zone.fully_heal) self.safe_zone_regen_spin.setValue( layout_config.safe_zone.heal_per_second) self.varia_suit_spin_box.setValue(patcher_config.varia_suit_damage) self.dark_suit_spin_box.setValue(patcher_config.dark_suit_damage) # Elevator set_combo_with_value(self.elevators_combo, layout_config.elevators) # Sky Temple Keys keys = layout_config.sky_temple_keys if isinstance(keys.value, int): self.skytemple_slider.setValue(keys.value) data = int else: data = keys set_combo_with_value(self.skytemple_combo, data) # Starting Area starting_locations = layout_config.starting_location.locations self._during_batch_check_update = True for world in self.game_description.world_list.worlds: for is_dark_world in [False, True]: all_areas = True no_areas = True areas = [ area for area in world.areas if area.in_dark_aether == is_dark_world ] correct_name = world.correct_name(is_dark_world) for area in areas: if area.valid_starting_location: is_checked = AreaLocation( world.world_asset_id, area.area_asset_id) in starting_locations if is_checked: no_areas = False else: all_areas = False self._starting_location_for_area[ area.area_asset_id].setChecked(is_checked) if all_areas: self._starting_location_for_world[ correct_name].setCheckState(Qt.Checked) elif no_areas: self._starting_location_for_world[ correct_name].setCheckState(Qt.Unchecked) else: self._starting_location_for_world[ correct_name].setCheckState(Qt.PartiallyChecked) self._during_batch_check_update = False # Location Pool available_locations = layout_config.available_locations set_combo_with_value(self.randomization_mode_combo, available_locations.randomization_mode) self._during_batch_check_update = True for node, check in self._location_pool_for_node.items(): check.setChecked( node.pickup_index not in available_locations.excluded_indices) check.setEnabled(available_locations.randomization_mode == RandomizationMode.FULL or node.major_location) self._during_batch_check_update = False # Translator Gates translator_configuration = preset.layout_configuration.translator_configuration for gate, combo in self._combo_for_gate.items(): set_combo_with_value( combo, translator_configuration.translator_requirement[gate]) # Hints set_combo_with_value(self.hint_sky_temple_key_combo, preset.layout_configuration.hints.sky_temple_keys) # Beam Configuration self.on_preset_changed_beam_configuration(preset)