def _on_submit(chosen_options: Dict[int, Tuple[CommonDialogOption]],
                       outcome: CommonChoiceOutcome) -> bool:
            try:
                if chosen_options is None or not chosen_options or CommonChoiceOutcome.is_error_or_cancel(
                        outcome):
                    self.log.debug('No options chosen.')
                    self.close()
                    return False

                self.log.debug('Chose options: {} with outcome: {}'.format(
                    pformat(chosen_options), pformat(outcome)))
                chosen_values: Dict[int, DialogOptionValueType] = dict()
                for chosen_option_index in chosen_options:
                    self.log.debug(
                        'Chosen option index: {}'.format(chosen_option_index))
                    chosen_option_options = chosen_options[chosen_option_index]
                    chosen_option_values: List[Any] = list()
                    for chosen_option_option in chosen_option_options:
                        chosen_option_values.append(chosen_option_option.value)
                        self.log.debug('Chose value for option: {}'.format(
                            chosen_option_option.value))
                        chosen_option_option.choose()
                    chosen_values[chosen_option_index] = tuple(
                        chosen_option_values)

                self.log.debug('Submitting choices: {}'.format(
                    pformat(chosen_values)))
                return on_submit(chosen_values)
            except Exception as ex:
                self.log.error('Error occurred on submitting a value.',
                               exception=ex)
            return False
コード例 #2
0
        def _on_save_as_template(_: str, template_name: str,
                                 outcome: CommonChoiceOutcome):
            if _ is None or template_name is None or CommonChoiceOutcome.is_error_or_cancel(
                    outcome):
                self.log.debug('No template name entered, dialog closed.')
                _reopen()
                return
            self.log.format_with_message('Template name entered.',
                                         template_name=template_name)
            if template_name in self._template_utils.template_library:

                def _on_yes(_) -> None:
                    self.log.debug('Saving template.')
                    self._template_utils.save_sliders_of(
                        sim_info, template_name)
                    _reopen()

                def _on_no(_) -> None:
                    self.log.debug('Cancelled saving template.')
                    _reopen()

                CommonOkCancelDialog(
                    CSFStringId.TEMPLATE_ALREADY_EXISTS_NAME,
                    CSFStringId.TEMPLATE_ALREADY_EXISTS_DESCRIPTION,
                    description_tokens=(template_name, ),
                    ok_text_identifier=CSFStringId.YES,
                    cancel_text_identifier=CSFStringId.NO,
                    mod_identity=self.mod_identity).show(
                        on_ok_selected=_on_yes, on_cancel_selected=_on_no)
                return

            self._template_utils.save_sliders_of(sim_info, template_name)
            _reopen()
コード例 #3
0
 def _on_submit(_new_speed: float, outcome: CommonChoiceOutcome):
     if _new_speed is None or CommonChoiceOutcome.is_error_or_cancel(
             outcome):
         on_completed(False)
         return
     self._clock_speed_multiplier = _new_speed
     on_completed(True)
コード例 #4
0
 def _on_chosen(chosen_option: CommonDialogOption,
                outcome: CommonChoiceOutcome) -> bool:
     if chosen_option is None or CommonChoiceOutcome.is_error_or_cancel(
             outcome):
         self.close()
         return False
     return chosen_option.choose()
コード例 #5
0
 def _on_chosen(choice: Union[Tuple[OutfitCategory, int], None],
                outcome: CommonChoiceOutcome) -> None:
     if choice is None or CommonChoiceOutcome.is_error_or_cancel(
             outcome):
         on_completed(False)
         return
     CommonOutfitUtils.set_current_outfit(sim_info, choice)
     on_completed(True)
コード例 #6
0
 def _on_chosen(chosen_options: Union[Tuple[CommonDialogOption], None], outcome: CommonChoiceOutcome) -> Any:
     if chosen_options is None or len(chosen_options) == 0 or CommonChoiceOutcome.is_error_or_cancel(outcome):
         self.close()
         return None
     chosen_values: List[DialogOptionValueType] = list()
     for chosen_option in chosen_options:
         chosen_values.append(chosen_option.value)
         chosen_option.choose()
     return on_submit(tuple(chosen_values))
コード例 #7
0
 def _on_submit(amount: int, outcome: CommonChoiceOutcome):
     if outcome == CommonChoiceOutcome.ERROR:
         self.run(sim_info, on_completed=on_completed)
         return
     elif CommonChoiceOutcome.is_error_or_cancel(outcome):
         on_completed(False)
         return
     CommonHouseholdUtils.get_household(sim_info).funds.add(amount, Consts_pb2.FUNDS_MONEY_CHEAT)
     on_completed(True)
     return True
コード例 #8
0
 def _on_submit(_new_milliseconds: int, outcome: CommonChoiceOutcome):
     if _new_milliseconds is None or CommonChoiceOutcome.is_error_or_cancel(
             outcome):
         on_completed(False)
         return
     from sims4.commands import execute
     execute(
         'clock._set_milliseconds_per_sim_second {0}'.format(
             _new_milliseconds), None)
     self._current_clock_speed_in_milliseconds = _new_milliseconds
     on_completed(True)
コード例 #9
0
 def _on_chosen(chosen_option: CommonDialogOption,
                outcome: CommonChoiceOutcome) -> bool:
     try:
         if chosen_option is None or CommonChoiceOutcome.is_error_or_cancel(
                 outcome):
             self.close()
             return False
         return chosen_option.choose()
     except Exception as ex:
         self.log.error('Error occurred on choosing a value.',
                        exception=ex)
     return False
コード例 #10
0
 def _on_slider_changed(slider_unique_identifier: str, amount: float,
                        outcome: CommonChoiceOutcome):
     if slider_unique_identifier is None or amount is None or CommonChoiceOutcome.is_error_or_cancel(
             outcome):
         self.log.debug(
             'No slider chosen, dialog closed, or no amount specified.')
         _reopen_dialog()
         return
     self.log.debug('Slider changed, attempting to apply.')
     self.slider_application_service.apply_slider_by_identifier(
         sim_info, slider_unique_identifier, amount)
     _reopen_dialog()
 def _on_submit(chosen_options: Union[Tuple[CommonDialogOption], None], outcome: CommonChoiceOutcome) -> bool:
     try:
         if chosen_options is None or len(chosen_options) == 0 or CommonChoiceOutcome.is_error_or_cancel(outcome):
             return self.close()
         chosen_values: List[DialogOptionValueType] = list()
         for chosen_option in chosen_options:
             chosen_values.append(chosen_option.value)
             chosen_option.choose()
         return on_submit(tuple(chosen_values))
     except Exception as ex:
         self.log.error('Error occurred on submitting a value.', exception=ex)
     return False
コード例 #12
0
 def _on_changed(chosen_motive_name: str, amount: float,
                 outcome: CommonChoiceOutcome):
     if chosen_motive_name is None or amount is None or CommonChoiceOutcome.is_error_or_cancel(
             outcome):
         self.log.debug('Cancelled changing motive level.')
         _reopen_dialog()
         return
     self.log.debug('Changing motive \'{}\' to amount {}'.format(
         chosen_motive_name, amount))
     self.motive_utils.change_motive_level(sim_info, chosen_motive_name,
                                           amount)
     _reopen_dialog()
コード例 #13
0
 def _on_submit(amount: int, outcome: CommonChoiceOutcome):
     if outcome == CommonChoiceOutcome.ERROR:
         self.run(sim_info, on_completed=on_completed)
         return
     elif CommonChoiceOutcome.is_error_or_cancel(outcome):
         on_completed(False)
         return
     CommonHouseholdUtils.get_household(sim_info).funds.try_remove(
         amount,
         Consts_pb2.FUNDS_MONEY_CHEAT,
         sim=CommonSimUtils.get_sim_instance(sim_info),
         require_full_amount=False)
     on_completed(True)
     return True
コード例 #14
0
 def _on_input_setting_changed(_skill: Skill, new_skill_level: int,
                               outcome: CommonChoiceOutcome):
     if new_skill_level is None or CommonChoiceOutcome.is_error_or_cancel(
             outcome):
         _reopen()
         return
     self.log.format_with_message('Setting skill level for Sim.',
                                  _skill=_skill,
                                  new_skill_level=new_skill_level)
     CommonSimSkillUtils.set_current_skill_level(
         sim_info, _skill, new_skill_level)
     if new_skill_level == 0:
         CommonSimSkillUtils.remove_skill(sim_info, _skill)
     _reopen()