Exemplo n.º 1
0
        def _on_bit_chosen(
                _: Any,
                chosen_operation: S4CMSetSimAAsRelationToSimBOperation):
            if _ is None or chosen_operation is None:
                return
            if chosen_operation.has_relation(grandparent_sim_info,
                                             grandchild_sim_info):
                on_completed(True)
                return

            def _on_yes_selected(_: Any):
                chosen_operation.run(grandparent_sim_info,
                                     grandchild_sim_info,
                                     on_completed=on_completed)

            def _on_no_selected(_: Any):
                self.run(grandchild_sim_info,
                         grandparent_sim_info,
                         on_completed=on_completed)

            confirmation = CommonOkCancelDialog(
                S4CMStringId.CONFIRMATION,
                S4CMSimControlMenuStringId.
                SIM_WILL_BECOME_RELATIONSHIP_TO_SIM_CONFIRMATION_TEXT,
                description_tokens=(grandparent_sim_info,
                                    chosen_operation.get_display_name(
                                        grandchild_sim_info,
                                        grandparent_sim_info),
                                    grandchild_sim_info),
                ok_text_identifier=S4CMStringId.YES,
                cancel_text_identifier=S4CMStringId.NO)
            confirmation.show(on_ok_selected=_on_yes_selected,
                              on_cancel_selected=_on_no_selected)
            return True
Exemplo n.º 2
0
    def run(
        self,
        sim_info: SimInfo,
        on_completed: Callable[[bool],
                               None] = CommonFunctionUtils.noop) -> bool:
        if CommonOccultUtils.is_robot(sim_info):
            on_completed(False)
            return False

        def _on_ok_selected(_: Any):
            # trait_Humanoid_Robots_MainTrait
            trait_id = CommonTraitId.OCCULT_ROBOT
            result = CommonTraitUtils.add_trait(sim_info, trait_id)
            on_completed(result)

        def _on_cancel_selected(_: Any):
            on_completed(False)

        confirmation = CommonOkCancelDialog(
            S4CMStringId.CONFIRMATION,
            S4CMSimControlMenuStringId.BECOME_SERVO_CONFIRMATION_DESCRIPTION,
        )
        confirmation.show(on_ok_selected=_on_ok_selected,
                          on_cancel_selected=_on_cancel_selected)
        return True
    def run(
        self,
        sim_info: SimInfo,
        on_completed: Callable[[bool],
                               None] = CommonFunctionUtils.noop) -> bool:
        def _on_close() -> None:
            on_completed(False)

        def _on_yes_selected(_: Any):
            from sims4controlmenu.dialogs.modify_sim_data.modify_skills.operations.set_skill_level import \
                S4CMSetSkillLevelsSimOp
            skill_manager = CommonResourceUtils.get_instance_manager(
                Types.STATISTIC)
            sim = CommonSimUtils.get_sim_instance(sim_info)
            for skill in skill_manager.get_ordered_types(
                    only_subclasses_of=Skill):
                skill: Skill = skill
                if not S4CMSetSkillLevelsSimOp(
                )._is_skill_allowed_for_modification(sim_info, skill):
                    continue
                if not skill.can_add(sim):
                    self.verbose_log.format_with_message(
                        'Failed, Skill is not allowed for Sim.',
                        skill=skill,
                        sim=sim_info)
                    continue
                CommonSimSkillUtils.set_current_skill_level(
                    sim_info, skill, int(skill.max_level))

            CommonBasicNotification(
                S4CMSimModifySkillsStringId.MAXED_ALL_SKILLS_TITLE,
                S4CMSimModifySkillsStringId.MAXED_ALL_SKILLS_DESCRIPTION,
                title_tokens=(sim, ),
                description_tokens=(sim, )).show(icon=IconInfoData(
                    obj_instance=sim))
            _on_close()

        def _on_no_selected(_: Any):
            _on_close()

        confirmation = CommonOkCancelDialog(
            S4CMStringId.CONFIRMATION,
            S4CMSimModifySkillsStringId.
            ARE_YOU_SURE_YOU_WANT_TO_MAX_ALL_SKILLS_FOR_SIM,
            description_tokens=(CommonSimUtils.get_sim_instance(sim_info), ),
            ok_text_identifier=S4CMStringId.YES,
            cancel_text_identifier=S4CMStringId.NO,
            mod_identity=self.mod_identity)
        confirmation.show(on_ok_selected=_on_yes_selected,
                          on_cancel_selected=_on_no_selected)
        return True
Exemplo n.º 4
0
        def _on_randomize_slider_category(category_name: str,
                                          category: CSFSliderCategory):
            self.log.debug(
                'Confirming reset of sliders in category {}.'.format(
                    category_name))

            def _on_confirm(_) -> None:
                self.log.debug(
                    'Randomizing all sliders in category {}.'.format(
                        category_name))
                for slider in sorted_sliders:
                    if category not in slider.categories:
                        continue
                    self.slider_application_service.apply_random(
                        sim_info, slider)
                _reopen_dialog()

            def _on_cancel(_) -> None:
                self.log.debug(
                    'Cancelled randomization of sliders in category {}.'.
                    format(category_name))
                _reopen_dialog()

            CommonOkCancelDialog(CSFStringId.CONFIRMATION,
                                 CSFStringId.RANDOMIZE_SLIDER_CONFIRMATION,
                                 mod_identity=self.mod_identity).show(
                                     on_ok_selected=_on_confirm,
                                     on_cancel_selected=_on_cancel)
        def _on_apply_template_to_sim() -> None:
            self.log.debug('Confirming all sliders reset.')
            if CSFSliderTemplateDialog._SELECTED_TEMPLATE is None:

                def _on_acknowledge(_) -> None:
                    _reopen()

                CommonOkDialog(CSFStringId.NO_TEMPLATE_SELECTED,
                               CSFStringId.PLEASE_SELECT_A_TEMPLATE,
                               mod_identity=self.mod_identity).show(
                                   on_acknowledged=_on_acknowledge)
                return

            def _on_confirm(_) -> None:
                self.log.debug('Applying template to Sim.')
                CSFSliderTemplateDialog._SELECTED_TEMPLATE.apply_to_sim(
                    sim_info)
                _reopen()

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

            CommonOkCancelDialog(
                CSFStringId.CONFIRMATION,
                CSFStringId.APPLY_TEMPLATE_TO_SIM_CONFIRMATION_DESCRIPTION,
                description_tokens=(sim_info, ),
                mod_identity=self.mod_identity).show(
                    on_ok_selected=_on_confirm, on_cancel_selected=_on_cancel)
        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()
Exemplo n.º 7
0
        def _on_force_all_chosen(_: str, picked_option: Union[int, bool]):
            if picked_option is None:
                return
            if picked_option == -1:
                self._data_store.set_value_by_key(_, None)
                _reopen()
                return

            @CommonExceptionHandler.catch_exceptions(self.mod_identity)
            def _on_ok(_d):
                self.log.debug('Ok chosen {}, \'{}\''.format(picked_option, _))
                self._data_store.set_value_by_key(_, picked_option)
                self.log.format_with_message(
                    'set value with', val=self._data_store.get_value_by_key(_))

                for sim_info in CommonSimUtils.get_instanced_sim_info_for_all_sims_generator(
                ):
                    _CGSUpdateGenderOptions()._update_gender_options(sim_info)
                _reopen()

            def _on_cancel(_d):
                self.log.debug('Cancel chosen')
                _reopen()

            CommonOkCancelDialog(
                CGSStringId.PLEASE_CONFIRM_NAME,
                CGSStringId.PLEASE_CONFIRM_DESCRIPTION,
                ok_text_identifier=CGSStringId.YES_UPDATE_ALL_SIMS,
                cancel_text_identifier=CGSStringId.NO).show(
                    on_ok_selected=_on_ok, on_cancel_selected=_on_cancel)
Exemplo n.º 8
0
        def _on_chosen(_: str, picked_option: bool):
            if picked_option is None:
                return
            if picked_option == -1:
                self._data_store.set_value_by_key(_, None)
                _reopen()
                return

            def _on_ok(_d):
                self._data_store.set_value_by_key(_, picked_option)

                for sim_info in CommonSimUtils.get_instanced_sim_info_for_all_sims_generator(
                ):
                    _CGSUpdateGenderOptions()._update_gender_options(sim_info)
                _reopen()

            def _on_cancel(_d):
                _reopen()

            CommonOkCancelDialog(
                CGSStringId.PLEASE_CONFIRM_NAME,
                CGSStringId.PLEASE_CONFIRM_DESCRIPTION,
                ok_text_identifier=CGSStringId.YES_UPDATE_ALL_SIMS,
                cancel_text_identifier=CGSStringId.NO).show(
                    on_ok_selected=_on_ok, on_cancel_selected=_on_cancel)
    def run(
        self,
        sim_info: SimInfo,
        on_completed: Callable[[bool],
                               None] = CommonFunctionUtils.noop) -> bool:
        def _on_close() -> None:
            on_completed(False)

        def _on_yes_selected(_: Any):
            skill_manager = CommonResourceUtils.get_instance_manager(
                Types.STATISTIC)
            sim = CommonSimUtils.get_sim_instance(sim_info)
            for skill in skill_manager.get_ordered_types(
                    only_subclasses_of=Skill):
                skill: Skill = skill
                if not CommonSimSkillUtils.has_skill(sim_info, skill):
                    continue
                CommonSimSkillUtils.remove_skill(sim_info, skill)

            CommonBasicNotification(
                S4CMSimModifySkillsStringId.REMOVED_ALL_SKILLS_TITLE,
                S4CMSimModifySkillsStringId.REMOVED_ALL_SKILLS_DESCRIPTION,
                title_tokens=(sim, ),
                description_tokens=(sim, )).show(icon=IconInfoData(
                    obj_instance=sim))
            _on_close()

        def _on_no_selected(_: Any):
            _on_close()

        confirmation = CommonOkCancelDialog(
            S4CMStringId.CONFIRMATION,
            S4CMSimModifySkillsStringId.
            ARE_YOU_SURE_YOU_WANT_TO_REMOVE_ALL_SKILLS_FROM_SIM,
            description_tokens=(CommonSimUtils.get_sim_instance(sim_info), ),
            ok_text_identifier=S4CMStringId.YES,
            cancel_text_identifier=S4CMStringId.NO,
            mod_identity=self.mod_identity)
        confirmation.show(on_ok_selected=_on_yes_selected,
                          on_cancel_selected=_on_no_selected)
        return True
Exemplo n.º 10
0
        def _on_chosen(_buff_id: int, chosen_buff: Buff):
            if chosen_buff is None:
                on_completed(False)
                return

            def _on_yes_selected(_: Any):
                CommonBuffUtils.remove_buff(sim_info, _buff_id)
                # noinspection PyUnresolvedReferences
                CommonBasicNotification(
                    S4CMSimControlMenuStringId.REMOVED_BUFF_TITLE,
                    S4CMSimControlMenuStringId.REMOVED_BUFF_DESCRIPTION,
                    title_tokens=(chosen_buff.buff_name(sim_info),
                                  str(_buff_id)),
                    description_tokens=(
                        CommonSimUtils.get_sim_instance(sim_info),
                        chosen_buff.buff_name(sim_info), str(_buff_id),
                        CommonBuffUtils.get_buff_name(chosen_buff))).show(
                            icon=IconInfoData(obj_instance=CommonSimUtils.
                                              get_sim_instance(sim_info)))
                _reopen()

            def _on_no_selected(_: Any):
                _reopen()

            # noinspection PyUnresolvedReferences
            confirmation = CommonOkCancelDialog(
                S4CMStringId.CONFIRMATION,
                S4CMSimControlMenuStringId.
                ARE_YOU_SURE_YOU_WANT_TO_REMOVE_BUFF,
                description_tokens=(chosen_buff.buff_name(sim_info),
                                    str(_buff_id),
                                    CommonBuffUtils.get_buff_name(chosen_buff),
                                    CommonSimUtils.get_sim_instance(sim_info)),
                ok_text_identifier=S4CMStringId.YES,
                cancel_text_identifier=S4CMStringId.NO,
                mod_identity=self.mod_identity)
            confirmation.show(on_ok_selected=_on_yes_selected,
                              on_cancel_selected=_on_no_selected)
Exemplo n.º 11
0
        def _on_reset_all_sliders() -> None:
            self.log.debug('Confirming all sliders reset.')

            def _on_confirm(_) -> None:
                self.log.debug('Resetting all sliders.')
                self.slider_application_service.reset_all_sliders(sim_info)
                _reopen_dialog()

            def _on_cancel(_) -> None:
                self.log.debug('Cancelled resetting of all sliders.')
                _reopen_dialog()

            CommonOkCancelDialog(
                CSFStringId.CONFIRMATION,
                CSFStringId.ARE_YOU_SURE_YOU_WANT_TO_RESET_ALL_SLIDERS,
                mod_identity=self.mod_identity).show(
                    on_ok_selected=_on_confirm, on_cancel_selected=_on_cancel)
Exemplo n.º 12
0
        def _on_min_all_motives() -> None:
            def _on_confirm(_) -> None:
                self.log.debug(
                    'Setting all motives to their minimum! Sim Death incoming!'
                )
                self.motive_utils.min_all_motives(sim_info)
                _reopen_dialog()

            def _on_cancel(_) -> None:
                self.log.debug(
                    'Cancelled setting all motives to minimum. That was a close one!'
                )
                _reopen_dialog()

            self.log.debug(
                'Showing confirmation for setting all motives to minimum.')

            CommonOkCancelDialog(
                CMStringId.CONFIRMATION,
                CMStringId.SET_ALL_MOTIVE_LEVELS_TO_MINIMUM_CONFIRMATION,
                description_tokens=(sim_info, ),
                mod_identity=self.mod_identity).show(
                    on_ok_selected=_on_confirm, on_cancel_selected=_on_cancel)