Example #1
0
 def get_disabled_text(
         self, grandparent_sim_info: SimInfo,
         grandchild_sim_info: SimInfo) -> Union[LocalizedString, None]:
     if not CommonSimGenealogyUtils.has_mother(grandchild_sim_info):
         return CommonLocalizationUtils.create_localized_string(
             S4CMSimControlMenuStringId.
             SIM_NEEDS_TO_HAVE_A_RELATION_BEFORE_YOU_CAN_ADD_A_RELATION_TO_THEM,
             tokens=(grandchild_sim_info, S4CMSimControlMenuStringId.MOTHER,
                     self.get_display_name(grandparent_sim_info,
                                           grandchild_sim_info)))
     if CommonSimGenealogyUtils.is_father_of(grandparent_sim_info,
                                             grandchild_sim_info):
         return CommonLocalizationUtils.create_localized_string(
             S4CMSimControlMenuStringId.
             SIM_CANNOT_BE_BOTH_RELATION_AND_RELATION_OF_SIM,
             tokens=(grandparent_sim_info,
                     S4CMSimControlMenuStringId.FATHER,
                     self.get_display_name(grandchild_sim_info,
                                           grandparent_sim_info),
                     grandchild_sim_info))
     if CommonSimGenealogyUtils.is_mother_of(grandparent_sim_info,
                                             grandchild_sim_info):
         return CommonLocalizationUtils.create_localized_string(
             S4CMSimControlMenuStringId.
             SIM_CANNOT_BE_BOTH_RELATION_AND_RELATION_OF_SIM,
             tokens=(grandparent_sim_info,
                     S4CMSimControlMenuStringId.MOTHER,
                     self.get_display_name(grandchild_sim_info,
                                           grandparent_sim_info),
                     grandchild_sim_info))
     return super().get_disabled_text(grandparent_sim_info,
                                      grandchild_sim_info)
 def _on_none_chosen(_: Any, __: Any):
     try:
         CommonSimGenealogyUtils.remove_family_relations_with(
             sim_info, chosen_sim_info)
         CommonSimGenealogyUtils.remove_family_relations_with(
             chosen_sim_info, sim_info)
     except Exception as ex:
         self.log.error('Failed to remove family relations',
                        exception=ex)
     self.run_with_sims(sim_info,
                        chosen_sim_info,
                        on_completed=on_completed)
 def get_disabled_text(
         self, new_niece_or_nephew_sim_info: SimInfo,
         new_aunt_or_uncle_sim_info: SimInfo
 ) -> Union[LocalizedString, None]:
     if not CommonSimGenealogyUtils.has_mother(
             new_niece_or_nephew_sim_info
     ) and not CommonSimGenealogyUtils.has_father(
             new_niece_or_nephew_sim_info):
         return CommonLocalizationUtils.create_localized_string(
             S4CMSimControlMenuStringId.
             SIM_NEEDS_TO_HAVE_MOTHER_OR_FATHER_BEFORE_YOU_CAN_ADD_UNCLES_OR_AUNTS_TO_THEM,
             tokens=(new_niece_or_nephew_sim_info, ))
     return super().get_disabled_text(new_niece_or_nephew_sim_info,
                                      new_aunt_or_uncle_sim_info)
Example #4
0
 def _add_relationship_bits(self, new_brother_or_sister_sim_info: SimInfo,
                            sim_info: SimInfo) -> bool:
     from sims4controlmenu.dialogs.modify_sim_data.modify_relationships.operations.family_relationship_operations.mother import \
         S4CMSetSimAAsMotherToSimBOp
     from sims4controlmenu.dialogs.modify_sim_data.modify_relationships.operations.family_relationship_operations.father import \
         S4CMSetSimAAsFatherToSimBOp
     father_sim_info = CommonSimGenealogyUtils.get_father_sim_info(sim_info)
     if father_sim_info is not None:
         S4CMSetSimAAsFatherToSimBOp()._add_relationship_bits(
             father_sim_info, new_brother_or_sister_sim_info)
     mother_sim_info = CommonSimGenealogyUtils.get_mother_sim_info(sim_info)
     if mother_sim_info is not None:
         S4CMSetSimAAsMotherToSimBOp()._add_relationship_bits(
             mother_sim_info, new_brother_or_sister_sim_info)
     return super()._add_relationship_bits(new_brother_or_sister_sim_info,
                                           sim_info)
 def _run_with_sims(self, sim_info: SimInfo,
                    sim_info_list: Tuple[SimInfo]) -> bool:
     sim_id = CommonSimUtils.get_sim_id(sim_info)
     for other_sim_info in sim_info_list:
         other_sim_id = CommonSimUtils.get_sim_id(other_sim_info)
         # noinspection PyBroadException
         try:
             CommonSimGenealogyUtils.remove_family_relations_with(
                 sim_info, other_sim_info)
             CommonSimGenealogyUtils.remove_family_relations_with(
                 other_sim_info, sim_info)
             services.relationship_service().destroy_relationship(
                 sim_id, other_sim_id, notify_client=True)
             services.relationship_service().destroy_relationship(
                 other_sim_id, sim_id, notify_client=True)
         except:
             pass
     return True
Example #6
0
 def _update_family_tree(
     self,
     new_brother_or_sister_sim_info: SimInfo,
     sim_info: SimInfo,
     on_completed: Callable[[bool],
                            None] = CommonFunctionUtils.noop) -> bool:
     from sims4controlmenu.dialogs.modify_sim_data.modify_relationships.operations.family_relationship_operations.mother import \
         S4CMSetSimAAsMotherToSimBOp
     from sims4controlmenu.dialogs.modify_sim_data.modify_relationships.operations.family_relationship_operations.father import \
         S4CMSetSimAAsFatherToSimBOp
     father_sim_info = CommonSimGenealogyUtils.get_father_sim_info(sim_info)
     if father_sim_info is not None:
         S4CMSetSimAAsFatherToSimBOp()._update_family_tree(
             father_sim_info, new_brother_or_sister_sim_info)
     mother_sim_info = CommonSimGenealogyUtils.get_mother_sim_info(sim_info)
     if mother_sim_info is not None:
         S4CMSetSimAAsMotherToSimBOp()._update_family_tree(
             mother_sim_info, new_brother_or_sister_sim_info)
     return True
Example #7
0
 def run(
     self,
     grandparent_sim_info: SimInfo,
     grandchild_sim_info: SimInfo,
     on_completed: Callable[[bool],
                            None] = CommonFunctionUtils.noop) -> bool:
     from sims4controlmenu.dialogs.modify_sim_data.modify_relationships.operations.family_relationship_operations.father import \
         S4CMSetSimAAsFatherToSimBOp
     parent_sim_info = CommonSimGenealogyUtils.get_mother_sim_info(
         grandchild_sim_info)
     return S4CMSetSimAAsFatherToSimBOp().run(grandparent_sim_info,
                                              parent_sim_info,
                                              on_completed=on_completed)
 def _share_father(
     self,
     step_sibling_sim_info_a: SimInfo,
     step_sibling_sim_info_b: SimInfo,
     on_completed: Callable[[bool],
                            None] = CommonFunctionUtils.noop) -> bool:
     from sims4controlmenu.dialogs.modify_sim_data.modify_relationships.operations.family_relationship_operations.father import \
         S4CMSetSimAAsFatherToSimBOp
     father_sim_info = CommonSimGenealogyUtils.get_father_sim_info(
         step_sibling_sim_info_b)
     if father_sim_info is None:
         on_completed(False)
         return False
     return S4CMSetSimAAsFatherToSimBOp().run(father_sim_info,
                                              step_sibling_sim_info_a,
                                              on_completed=on_completed)