Exemple #1
0
 def _on_chosen(_: str, picked_option: bool):
     if picked_option is None:
         _on_close()
         return
     value = not CommonSimGenderOptionUtils.can_reproduce(
         self._sim_info)
     CommonSimGenderOptionUtils.update_can_reproduce(
         self._sim_info, value)
     _reopen()
    def can_reproduce(sim_info: SimInfo) -> bool:
        """can_reproduce(sim_info)

        Determine if a pet sim can reproduce.

        .. note:: Use :func:`~can_impregnate` and :func:`~can_be_impregnated` for Human Sims.
        .. note:: Will return False if the pet sim has the PREGNANCY_OPTIONS_PET_CAN_NOT_REPRODUCE trait.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim can reproduce. False, if the Sim can not reproduce.
        :rtype: bool
        """
        from sims4communitylib.utils.sims.common_sim_gender_option_utils import CommonSimGenderOptionUtils
        return CommonSimGenderOptionUtils.can_reproduce(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 #4
0
    def _settings_pet(self, on_close: Callable[[], Any] = None) -> None:
        def _reopen() -> None:
            self._settings_pet(on_close=on_close)

        def _on_close(*_, **__) -> None:
            if on_close is not None:
                on_close()

        def _on_chosen(_: str, picked_option: bool):
            if picked_option is None:
                _on_close()
                return
            value = not CommonSimGenderOptionUtils.can_reproduce(
                self._sim_info)
            CommonSimGenderOptionUtils.update_can_reproduce(
                self._sim_info, value)
            _reopen()

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

        current_selected = CGSStringId.NATURAL
        can_reproduce = CommonSimGenderOptionUtils.can_reproduce(
            self._sim_info)
        if not can_reproduce:
            current_selected = CGSStringId.FIXED

        option_dialog.add_option(
            CommonDialogToggleOption(
                'Reproductive Settings',
                can_reproduce,
                CommonDialogOptionContext(
                    CGSStringId.REPRODUCTIVE_SETTINGS,
                    CGSStringId.CGS_CURRENT,
                    description_tokens=(current_selected, ),
                    icon=CommonIconUtils.load_question_mark_icon()),
                on_chosen=_on_chosen))

        option_dialog.show(sim_info=self._sim_info)
Exemple #5
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)