def uses_toilet_standing(sim_info: SimInfo) -> bool:
        """uses_toilet_standing(sim_info)

        Determine if a sim uses the toilet while standing.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim uses toilets while standing. False, if the Sim does not use toilets while standing.
        :rtype: bool
        """
        from sims4communitylib.utils.sims.common_sim_gender_option_utils import CommonSimGenderOptionUtils
        return CommonSimGenderOptionUtils.uses_toilet_standing(sim_info)
    def swap_gender(sim_info: SimInfo, update_gender_options: bool=True) -> bool:
        """swap_gender(sim_info, update_gender_options=True)

        Swap the Gender of a Sim to it's opposite. i.e. Change a Sim from Male to Female or from Female to Male.

        :param sim_info: An instance of a Sim.
        :type sim_info: SimInfo
        :param update_gender_options: If True, gender option traits such as Toilet Usage, Clothing Preference, Pregnancy, and Body Frame will be updated to reflect the vanilla settings for each gender\
        For example, if a Human Sim is swapping from Female to Male, their gender options will be updated to Toilet Standing, Cannot Be Impregnated, Can Impregnate, Mens Wear clothing preference, and Masculine Frame.\
        If False, gender option traits will not be updated.\
        Default is True.
        :type update_gender_options: bool, optional
        :return: True, if the Gender of the Sim was swapped successfully. False, if not.
        :rtype: bool
        """
        from sims4communitylib.utils.sims.common_sim_gender_option_utils import CommonSimGenderOptionUtils
        result = False
        frame = CommonSimGenderOptionUtils.has_masculine_frame(sim_info)
        prefers_menswear = CommonSimGenderOptionUtils.prefers_menswear(sim_info)
        can_impregnate = CommonSimGenderOptionUtils.can_impregnate(sim_info)
        can_be_impregnated = CommonSimGenderOptionUtils.can_be_impregnated(sim_info)
        can_reproduce = CommonSimGenderOptionUtils.can_reproduce(sim_info)
        uses_toilet_standing = CommonSimGenderOptionUtils.uses_toilet_standing(sim_info)
        has_breasts = CommonSimGenderOptionUtils.has_breasts(sim_info)
        saved_outfits = sim_info.save_outfits()
        current_outfit = CommonOutfitUtils.get_current_outfit(sim_info)
        if CommonGenderUtils.is_male(sim_info):
            result = CommonGenderUtils.set_gender(sim_info, Gender.FEMALE)
            if update_gender_options:
                CommonSimGenderOptionUtils.update_gender_options_to_vanilla_female(sim_info)
        elif CommonGenderUtils.is_female(sim_info):
            result = CommonGenderUtils.set_gender(sim_info, Gender.MALE)
            if update_gender_options:
                CommonSimGenderOptionUtils.update_gender_options_to_vanilla_male(sim_info)
        if not update_gender_options:
            CommonSimGenderOptionUtils.update_body_frame(sim_info, frame)
            CommonSimGenderOptionUtils.update_clothing_preference(sim_info, prefers_menswear)
            CommonSimGenderOptionUtils.update_can_impregnate(sim_info, can_impregnate)
            CommonSimGenderOptionUtils.update_can_be_impregnated(sim_info, can_be_impregnated)
            CommonSimGenderOptionUtils.update_can_reproduce(sim_info, can_reproduce)
            CommonSimGenderOptionUtils.update_toilet_usage(sim_info, uses_toilet_standing)
            CommonSimGenderOptionUtils.update_has_breasts(sim_info, has_breasts)
            sim_info.load_outfits(saved_outfits)
            CommonOutfitUtils.resend_outfits(sim_info)
            CommonOutfitUtils.set_current_outfit(sim_info, current_outfit)
        return result
Exemple #3
0
 def _update_gender_options(self, sim_info: SimInfo):
     update_outfits = False
     if self._setting_utils.force_all_sims_to_male(
     ) and not CommonGenderUtils.is_male(sim_info):
         CommonGenderUtils.swap_gender(sim_info,
                                       update_gender_options=False)
         update_outfits = True
     elif self._setting_utils.force_all_sims_to_female(
     ) and not CommonGenderUtils.is_female(sim_info):
         CommonGenderUtils.swap_gender(sim_info,
                                       update_gender_options=False)
         update_outfits = True
     if CommonGenderUtils.is_male(sim_info):
         if CommonSpeciesUtils.is_pet(sim_info):
             if self._setting_utils.all_male_options.can_reproduce(
             ) and not CommonSimGenderOptionUtils.can_reproduce(sim_info):
                 CommonSimGenderOptionUtils.update_can_reproduce(
                     sim_info, True)
             if self._setting_utils.all_male_options.cannot_reproduce(
             ) and not CommonSimGenderOptionUtils.can_not_reproduce(
                     sim_info):
                 CommonSimGenderOptionUtils.update_can_reproduce(
                     sim_info, False)
         elif CommonSpeciesUtils.is_human(sim_info):
             if self._setting_utils.all_male_options.use_toilet_standing(
             ) and not CommonSimGenderOptionUtils.uses_toilet_standing(
                     sim_info):
                 CommonSimGenderOptionUtils.update_toilet_usage(
                     sim_info, True)
                 update_outfits = True
             if self._setting_utils.all_male_options.use_toilet_sitting(
             ) and not CommonSimGenderOptionUtils.uses_toilet_sitting(
                     sim_info):
                 CommonSimGenderOptionUtils.update_toilet_usage(
                     sim_info, False)
                 update_outfits = True
             if self._setting_utils.all_male_options.prefer_menswear(
             ) and not CommonSimGenderOptionUtils.prefers_menswear(
                     sim_info):
                 CommonSimGenderOptionUtils.update_clothing_preference(
                     sim_info, True)
             if self._setting_utils.all_male_options.prefer_womenswear(
             ) and not CommonSimGenderOptionUtils.prefers_womenswear(
                     sim_info):
                 CommonSimGenderOptionUtils.update_clothing_preference(
                     sim_info, False)
             if self._setting_utils.all_male_options.force_masculine_body_frame(
             ) and not CommonSimGenderOptionUtils.has_masculine_frame(
                     sim_info):
                 CommonSimGenderOptionUtils.update_body_frame(
                     sim_info, True)
             if self._setting_utils.all_male_options.force_feminine_body_frame(
             ) and not CommonSimGenderOptionUtils.has_feminine_frame(
                     sim_info):
                 CommonSimGenderOptionUtils.update_body_frame(
                     sim_info, False)
             if self._setting_utils.all_male_options.can_impregnate(
             ) and not CommonSimGenderOptionUtils.can_impregnate(sim_info):
                 CommonSimGenderOptionUtils.update_can_impregnate(
                     sim_info, True)
             if self._setting_utils.all_male_options.cannot_impregnate(
             ) and not CommonSimGenderOptionUtils.can_not_impregnate(
                     sim_info):
                 CommonSimGenderOptionUtils.update_can_impregnate(
                     sim_info, False)
             if self._setting_utils.all_male_options.can_be_impregnated(
             ) and not CommonSimGenderOptionUtils.can_be_impregnated(
                     sim_info):
                 CommonSimGenderOptionUtils.update_can_be_impregnated(
                     sim_info, True)
             if self._setting_utils.all_male_options.cannot_be_impregnated(
             ) and not CommonSimGenderOptionUtils.can_not_be_impregnated(
                     sim_info):
                 CommonSimGenderOptionUtils.update_can_be_impregnated(
                     sim_info, False)
             if self._setting_utils.all_male_options.force_breasts_on(
             ) and not CommonSimGenderOptionUtils.has_breasts(sim_info):
                 CommonSimGenderOptionUtils.update_has_breasts(
                     sim_info, True)
                 update_outfits = True
             if self._setting_utils.all_male_options.force_breasts_off(
             ) and CommonSimGenderOptionUtils.has_breasts(sim_info):
                 CommonSimGenderOptionUtils.update_has_breasts(
                     sim_info, False)
                 update_outfits = True
     elif CommonGenderUtils.is_female(sim_info):
         if CommonSpeciesUtils.is_pet(sim_info):
             if self._setting_utils.all_female_options.can_reproduce(
             ) and not CommonSimGenderOptionUtils.can_reproduce(sim_info):
                 CommonSimGenderOptionUtils.update_can_reproduce(
                     sim_info, True)
             if self._setting_utils.all_female_options.cannot_reproduce(
             ) and not CommonSimGenderOptionUtils.can_not_reproduce(
                     sim_info):
                 CommonSimGenderOptionUtils.update_can_reproduce(
                     sim_info, False)
         elif CommonSpeciesUtils.is_human(sim_info):
             if self._setting_utils.all_female_options.use_toilet_standing(
             ) and not CommonSimGenderOptionUtils.uses_toilet_standing(
                     sim_info):
                 CommonSimGenderOptionUtils.update_toilet_usage(
                     sim_info, True)
                 update_outfits = True
             if self._setting_utils.all_female_options.use_toilet_sitting(
             ) and not CommonSimGenderOptionUtils.uses_toilet_sitting(
                     sim_info):
                 CommonSimGenderOptionUtils.update_toilet_usage(
                     sim_info, False)
                 update_outfits = True
             if self._setting_utils.all_female_options.prefer_menswear(
             ) and not CommonSimGenderOptionUtils.prefers_menswear(
                     sim_info):
                 CommonSimGenderOptionUtils.update_clothing_preference(
                     sim_info, True)
             if self._setting_utils.all_female_options.prefer_womenswear(
             ) and not CommonSimGenderOptionUtils.prefers_womenswear(
                     sim_info):
                 CommonSimGenderOptionUtils.update_clothing_preference(
                     sim_info, False)
             if self._setting_utils.all_female_options.force_masculine_body_frame(
             ) and not CommonSimGenderOptionUtils.has_masculine_frame(
                     sim_info):
                 CommonSimGenderOptionUtils.update_body_frame(
                     sim_info, True)
             if self._setting_utils.all_female_options.force_feminine_body_frame(
             ) and not CommonSimGenderOptionUtils.has_feminine_frame(
                     sim_info):
                 CommonSimGenderOptionUtils.update_body_frame(
                     sim_info, False)
             if self._setting_utils.all_female_options.can_impregnate(
             ) and not CommonSimGenderOptionUtils.can_impregnate(sim_info):
                 CommonSimGenderOptionUtils.update_can_impregnate(
                     sim_info, True)
             if self._setting_utils.all_female_options.cannot_impregnate(
             ) and not CommonSimGenderOptionUtils.can_not_impregnate(
                     sim_info):
                 CommonSimGenderOptionUtils.update_can_impregnate(
                     sim_info, False)
             if self._setting_utils.all_female_options.can_be_impregnated(
             ) and not CommonSimGenderOptionUtils.can_be_impregnated(
                     sim_info):
                 CommonSimGenderOptionUtils.update_can_be_impregnated(
                     sim_info, True)
             if self._setting_utils.all_female_options.cannot_be_impregnated(
             ) and not CommonSimGenderOptionUtils.can_not_be_impregnated(
                     sim_info):
                 CommonSimGenderOptionUtils.update_can_be_impregnated(
                     sim_info, False)
             if self._setting_utils.all_female_options.force_breasts_on(
             ) and not CommonSimGenderOptionUtils.has_breasts(sim_info):
                 CommonSimGenderOptionUtils.update_has_breasts(
                     sim_info, True)
                 update_outfits = True
             if self._setting_utils.all_female_options.force_breasts_off(
             ) and CommonSimGenderOptionUtils.has_breasts(sim_info):
                 CommonSimGenderOptionUtils.update_has_breasts(
                     sim_info, False)
                 update_outfits = True
     if update_outfits:
         CommonOutfitUtils.update_outfits(sim_info)
Exemple #4
0
    def _settings_human(self, on_close: Callable[[], Any] = None) -> None:
        def _on_close() -> None:
            if on_close is not None:
                on_close()

        def _reopen():
            self._settings_human(on_close=on_close)

        option_dialog = CommonChooseObjectOptionDialog(
            CommonStringId.CUSTOM_GENDER_SETTINGS,
            CGSStringId.CGS_CUSTOM_GENDER_SETTINGS_DESCRIPTION,
            mod_identity=self.mod_identity,
            on_close=_on_close)

        option_dialog.add_option(
            CommonDialogActionOption(
                CommonDialogOptionContext(
                    CGSStringId.GLOBAL_SETTINGS_NAME,
                    CGSStringId.GLOBAL_SETTINGS_DESCRIPTION),
                on_chosen=CGSGlobalSettingsDialog(self._sim_info,
                                                  on_close=_reopen).open))

        def _set_to_vanilla_gender_chosen():
            if CommonGenderUtils.is_male(self._sim_info):
                CommonSimGenderOptionUtils.update_gender_options_to_vanilla_male(
                    self._sim_info)
            else:
                CommonSimGenderOptionUtils.update_gender_options_to_vanilla_female(
                    self._sim_info)
            _reopen()

        option_dialog.add_option(
            CommonDialogActionOption(CommonDialogOptionContext(
                CGSStringId.CGS_SET_TO_VANILLA_GENDER_OPTIONS_NAME,
                CGSStringId.CGS_SET_TO_VANILLA_GENDER_OPTIONS_DESCRIPTION,
                icon=CommonIconUtils.load_arrow_right_icon()),
                                     on_chosen=_set_to_vanilla_gender_chosen))

        def _on_gender_chosen():
            CommonGenderUtils.swap_gender(self._sim_info,
                                          update_gender_options=False)
            _reopen()

        current_gender_string = CGSStringId.MALE
        if CommonGenderUtils.is_female(self._sim_info):
            current_gender_string = CGSStringId.FEMALE

        option_dialog.add_option(
            CommonDialogActionOption(CommonDialogOptionContext(
                CGSStringId.CGS_SWAP_GENDER_NAME,
                CGSStringId.CGS_SWAP_GENDER_DESCRIPTION,
                title_tokens=(current_gender_string, ),
                icon=CommonIconUtils.load_arrow_right_icon()),
                                     on_chosen=_on_gender_chosen))

        def _on_physical_frame_chosen():
            value = not CommonSimGenderOptionUtils.has_masculine_frame(
                self._sim_info)
            CommonSimGenderOptionUtils.update_body_frame(self._sim_info, value)
            _reopen()

        current_body_frame = CommonStringId.FEMININE
        if CommonSimGenderOptionUtils.has_masculine_frame(self._sim_info):
            current_body_frame = CommonStringId.MASCULINE

        option_dialog.add_option(
            CommonDialogActionOption(CommonDialogOptionContext(
                CommonStringId.PHYSICAL_FRAME,
                CGSStringId.CGS_CURRENT,
                description_tokens=(current_body_frame, ),
                icon=CommonIconUtils.load_arrow_right_icon()),
                                     on_chosen=_on_physical_frame_chosen))

        current_clothing = CommonStringId.FEMININE
        if CommonSimGenderOptionUtils.prefers_menswear(self._sim_info):
            current_clothing = CommonStringId.MASCULINE

        def _on_clothing_preference_chosen():
            value = not CommonSimGenderOptionUtils.prefers_menswear(
                self._sim_info)
            CommonSimGenderOptionUtils.update_clothing_preference(
                self._sim_info, value)
            _reopen()

        option_dialog.add_option(
            CommonDialogActionOption(CommonDialogOptionContext(
                CommonStringId.CLOTHING_PREFERENCE,
                CGSStringId.CGS_CURRENT,
                description_tokens=(current_clothing, ),
                icon=CommonIconUtils.load_arrow_right_icon()),
                                     on_chosen=_on_clothing_preference_chosen))

        def _on_toggle_breasts_chosen(option_identifier: str,
                                      has_breasts: bool):
            self.log.format(option_identifier=option_identifier,
                            has_breasts=has_breasts)

            def _on_acknowledged(_):
                _reopen()

            CommonSimGenderOptionUtils.update_has_breasts(
                self._sim_info, has_breasts)
            CommonOkDialog(
                CGSStringId.CGS_SETTING_SAVE_RELOAD_ALERT_NAME,
                CGSStringId.CGS_SETTING_SAVE_RELOAD_ALERT_DESCRIPTION).show(
                    on_acknowledged=_on_acknowledged)

        has_vanilla_breasts = False
        if CommonGenderUtils.is_female(self._sim_info):
            has_vanilla_breasts = not CommonTraitUtils.has_trait(
                self._sim_info, CommonTraitId.BREASTS_FORCE_OFF)

        option_dialog.add_option(
            CommonDialogToggleOption(
                'ToggleBreasts',
                CommonTraitUtils.has_trait(self._sim_info,
                                           CommonTraitId.BREASTS_FORCE_ON)
                or has_vanilla_breasts,
                CommonDialogOptionContext(
                    CGSStringId.CGS_TOGGLE_BREASTS_NAME,
                    CGSStringId.CGS_TOGGLE_BREASTS_DESCRIPTION),
                on_chosen=_on_toggle_breasts_chosen))

        option_dialog.add_option(
            CommonDialogActionOption(CommonDialogOptionContext(
                CGSStringId.CGS_PREGNANCY_OPTIONS_NAME,
                CGSStringId.CGS_PREGNANCY_OPTIONS_DESCRIPTION,
                icon=CommonIconUtils.load_arrow_navigate_into_icon()),
                                     on_chosen=lambda *_, **__: self.
                                     _pregnancy_options(on_close=_reopen)))

        title = CGSStringId.CGS_TOGGLE_CAN_USE_TOILET_STANDING_NAME
        if CommonSimGenderOptionUtils.uses_toilet_standing(self._sim_info):
            title = CommonLocalizationUtils.create_localized_string(
                title, text_color=CommonLocalizedStringColor.GREEN)
            icon = CommonIconUtils.load_checked_square_icon()
        else:
            icon = CommonIconUtils.load_unchecked_square_icon()
        text = CGSStringId.CGS_TOGGLE_CAN_USE_TOILET_STANDING_DESCRIPTION

        def _on_toilet_usage_chosen():
            value = not CommonSimGenderOptionUtils.uses_toilet_standing(
                self._sim_info)
            CommonSimGenderOptionUtils.update_toilet_usage(
                self._sim_info, value)
            _reopen()

        option_dialog.add_option(
            CommonDialogActionOption(CommonDialogOptionContext(title,
                                                               text,
                                                               icon=icon),
                                     on_chosen=_on_toilet_usage_chosen))

        option_dialog.show(sim_info=self._sim_info)
Exemple #5
0
 def _on_toilet_usage_chosen():
     value = not CommonSimGenderOptionUtils.uses_toilet_standing(
         self._sim_info)
     CommonSimGenderOptionUtils.update_toilet_usage(
         self._sim_info, value)
     _reopen()