Ejemplo n.º 1
0
 def show_dialog(self, **kwargs):
     self.title = lambda **_: LocalizationHelperTuning.get_raw_text(
         'Tuning Error Notifier')
     self.text = lambda **_: LocalizationHelperTuning.get_raw_text(
         'XML tuning errors matching your filters were detected.  Press OK to view these in your web browser, or Cancel to ignore.'
     )
     super().show_dialog(**kwargs)
Ejemplo n.º 2
0
def register_custom_career(opt_sim: OptionalSimInfoParam = None,
                           _connection=None):
    sim_info = get_optional_target(opt_sim,
                                   target_type=OptionalSimInfoParam,
                                   _connection=_connection)

    def on_response(dialog):
        if not dialog.accepted:
            return
        name = dialog.text_input_responses.get(Career.TEXT_INPUT_NEW_NAME)
        description = dialog.text_input_responses.get(
            Career.TEXT_INPUT_NEW_DESCRIPTION)
        sim_info.career_tracker.set_custom_career_data(
            custom_name=name, custom_description=description)

    register_dialog_data = Career.REGISTER_CAREER_DIALOG_DATA
    dialog = register_dialog_data.register_career_dialog(
        sim_info, SingleSimResolver(sim_info))
    text_input_overrides = None
    if sim_info.career_tracker.has_custom_career:
        text_input_overrides = {}
        custom_career_data = sim_info.career_tracker.custom_career_data
        text_input_overrides[
            Career.
            TEXT_INPUT_NEW_NAME] = lambda *_, **__: LocalizationHelperTuning.get_raw_text(
                custom_career_data.get_custom_career_name())
        text_input_overrides[
            Career.
            TEXT_INPUT_NEW_DESCRIPTION] = lambda *_, **__: LocalizationHelperTuning.get_raw_text(
                custom_career_data.get_custom_career_description())
    dialog.show_dialog(on_response=on_response,
                       text_input_overrides=text_input_overrides)
    return True
 def _get_name(cls,
               inst,
               target=DEFAULT,
               context=DEFAULT,
               track=None,
               **interaction_parameters):
     if track is None:
         return inst.create_localized_string(inst.display_name)
     tag_set = None
     if track in ObjectRelationshipTrack.OBJECT_BASED_FRIENDSHIP_TRACKS:
         tag_set = ObjectRelationshipTrack.OBJECT_BASED_FRIENDSHIP_TRACKS[
             track]
     if tag_set is not None:
         relationship_service = services.relationship_service()
         relationship = relationship_service.get_object_relationship(
             context.sim.id, tag_set)
         if relationship is not None:
             object_name = relationship.get_object_rel_name()
             if object_name:
                 if cls.custom_name_string_wrapper is not None:
                     return cls.custom_name_string_wrapper(
                         LocalizationHelperTuning.get_raw_text(object_name))
                 return LocalizationHelperTuning.get_raw_text(object_name)
     if track in cls.object_variant_mapping:
         return cls.create_localized_string(
             cls.object_variant_mapping[track].display_name,
             context=context,
             target=target)
     return inst.create_localized_string(inst.display_name)
Ejemplo n.º 4
0
def show_notif(sim, text):
    title = "{} said".format(
        Distributor.instance().get_distributor_with_active_sim_matching_sim_id(
            sim.id).client._account.persona_name)
    notification = UiDialogNotification.TunableFactory().default(
        sim,
        text=lambda **_: LocalizationHelperTuning.get_raw_text(text),
        title=lambda **_: LocalizationHelperTuning.get_raw_text(title))
    notification.show_dialog(icon_override=(None, sim))
Ejemplo n.º 5
0
 def get_non_active_display(cls, token_data):
     if token_data.token_property == GlobalPolicyTokenType.NAME:
         return LocalizationHelperTuning.get_raw_text(
             token_data.global_policy.display_name())
     if token_data.token_property == GlobalPolicyTokenType.PROGRESS:
         return LocalizationHelperTuning.get_raw_text(
             cls.GLOBAL_POLICY_TOKEN_NON_ACTIVE())
     logger.error(
         'Invalid Global Policy Property {} tuned on the Global Policy token.'
         .format(token_data.property))
Ejemplo n.º 6
0
 def name(self):
     if self._name is not None:
         if self._localized_custom_name is None:
             self._localized_custom_name = LocalizationHelperTuning.get_raw_text(
                 self._name)
     if self._localized_custom_name is not None:
         return self._localized_custom_name
     if self.club_seed is not None:
         return self.club_seed.name
     return LocalizationHelperTuning.get_raw_text('')
Ejemplo n.º 7
0
def show_notification(text, title=None):
    client = services.client_manager().get_first_client()
    if title is None:
        title = 'Neutron Core'

    localized_title = lambda **_: LocalizationHelperTuning.get_raw_text(title)
    localized_text = lambda **_: LocalizationHelperTuning.get_raw_text(text)

    notification = UiDialogNotification.TunableFactory().default(
        client.active_sim, text=localized_text, title=localized_title)
    notification.show_dialog()
Ejemplo n.º 8
0
def mp_chat(target_id=None, _connection=None):
    try:
        target_id = int(target_id)

        ts4mp_log("chat", target_id)
        distributor = Distributor.instance(
        ).get_distributor_with_active_sim_matching_sim_id(target_id)

        client = distributor.client
        ts4mp_log("chat", client)

        def enter_dialog_callback(dialog):
            if not dialog.accepted:
                ts4mp_log("chat", "Dialog was not accepted.")
                return
            dialog_text = dialog.text_input_responses.get("dialog")
            ts4mp_log("chat", 'Showing message')

            distributor = Distributor.instance(
            ).get_distributor_with_active_sim_matching_sim_id(target_id)
            if distributor is not None:
                client = distributor.client
                ts4mp_log("chat", 'Showing message')

                show_notif(client.active_sim, dialog_text)

        localized_title = lambda **_: LocalizationHelperTuning.get_raw_text(
            "Say Something")
        localized_text = lambda **_: LocalizationHelperTuning.get_raw_text(
            "Say something to anybody who's listening.")
        localized_fname = lambda **_: LocalizationHelperTuning.get_raw_text(
            "Type your message here!")
        localized_lname = lambda **_: LocalizationHelperTuning.get_raw_text(
            "Type your emote here!")

        text_input_1 = UiTextInput(sort_order=0)
        text_input_1.default_text = localized_fname
        text_input_1.title = None
        text_input_1.max_length = 100
        text_input_1.initial_value = localized_fname
        text_input_1.length_restriction = Scum_TextInputLengthName()

        inputs = AttributeDict({'dialog': text_input_1})
        dialog = UiDialogTextInputOkCancel.TunableFactory().default(
            client.active_sim,
            text=localized_text,
            title=localized_title,
            text_inputs=inputs,
            is_special_dialog=True)
        ts4mp_log("chat", "Dialog id: {}".format(dialog.dialog_id))
        dialog.add_listener(enter_dialog_callback)
        dialog.show_dialog()
    except Exception as e:
        ts4mp_log('chat', e)
Ejemplo n.º 9
0
 def _apply_to_subject_and_target(self, subject, target, resolver):
     degree_tracker = subject.degree_tracker
     if degree_tracker is None:
         return
     empty_list_counter = 0
     first_list_entry = True
     active_scholarship_list = degree_tracker.get_scholarships_list_by_status(
         ScholarshipStatus.ACTIVE, subject, first_list_entry)
     if active_scholarship_list is None:
         active_scholarship_list = LocalizationHelperTuning.get_raw_text('')
         empty_list_counter += 1
     else:
         first_list_entry = False
     pending_scholarships_list = degree_tracker.get_scholarships_list_by_status(
         ScholarshipStatus.PENDING, subject, first_list_entry)
     if pending_scholarships_list is None:
         pending_scholarships_list = LocalizationHelperTuning.get_raw_text(
             '')
         empty_list_counter += 1
     else:
         first_list_entry = False
     accepted_scholarships_list = degree_tracker.get_scholarships_list_by_status(
         ScholarshipStatus.ACCEPTED, subject, first_list_entry)
     if accepted_scholarships_list is None:
         accepted_scholarships_list = LocalizationHelperTuning.get_raw_text(
             '')
         empty_list_counter += 1
     else:
         first_list_entry = False
     rejected_scholarships_list = degree_tracker.get_scholarships_list_by_status(
         ScholarshipStatus.REJECTED, subject, first_list_entry)
     if rejected_scholarships_list is None:
         rejected_scholarships_list = LocalizationHelperTuning.get_raw_text(
             '')
         empty_list_counter += 1
     else:
         first_list_entry = False
     if empty_list_counter >= self.SCHOLARSHIP_STATUS_CATEGORIES_AMOUNT:
         dialog = self.SCHOLARSHIP_STATUS_NO_SCHOLARSHIPS_NOTIFICATION(
             subject, None)
         dialog.show_dialog(
             secondary_icon_override=IconInfoData(obj_instance=subject),
             additional_tokens=(subject, ))
         return
     dialog = self.SCHOLARSHIP_STATUS_NOTIFICATION(subject, None)
     dialog.show_dialog(
         secondary_icon_override=IconInfoData(obj_instance=subject),
         additional_tokens=(subject, active_scholarship_list,
                            pending_scholarships_list,
                            accepted_scholarships_list,
                            rejected_scholarships_list))
Ejemplo n.º 10
0
 def get_active_policy_display(self, token_data):
     if token_data.token_property == GlobalPolicyTokenType.NAME:
         return LocalizationHelperTuning.get_raw_text(self.display_name())
     if token_data.token_property == GlobalPolicyTokenType.PROGRESS:
         progress_percentage_str = str(
             int(
                 round(
                     float(self.progress_value) /
                     float(self.progress_max_value), 2) * 100))
         return LocalizationHelperTuning.get_raw_text(
             progress_percentage_str)
     logger.error(
         'Invalid Global Policy Property {} tuned on the Global Policy token.'
         .format(token_data.property))
Ejemplo n.º 11
0
def ui_dialog_notification_test(*all_text: str, _connection=None):
    client = services.client_manager().get(_connection)
    all_text_str = ' '.join(all_text)
    if '/' in all_text:
        (title, text) = all_text_str.split('/')
        notification = UiDialogNotification.TunableFactory().default(
            client.active_sim,
            text=lambda **_: LocalizationHelperTuning.get_raw_text(text),
            title=lambda **_: LocalizationHelperTuning.get_raw_text(title))
    else:
        notification = UiDialogNotification.TunableFactory().default(
            client.active_sim,
            text=lambda **_: LocalizationHelperTuning.get_raw_text(all_text_str
                                                                   ))
    notification.show_dialog(icon_override=IconInfoData(
        obj_instance=client.active_sim))
Ejemplo n.º 12
0
 def show_festival_info(cls):
     if cls.festival_dynamic_sign_info is None:
         return
     ui_info = cls.festival_dynamic_sign_info
     festival_info = UI_pb2.DynamicSignView()
     festival_info.drama_node_guid = cls.guid64
     festival_info.name = ui_info.festival_name
     lot_id = cls.get_travel_lot_id()
     persistence_service = services.get_persistence_service()
     zone_id = persistence_service.resolve_lot_id_into_zone_id(lot_id, ignore_neighborhood_id=True)
     zone_protobuff = persistence_service.get_zone_proto_buff(zone_id)
     if zone_protobuff is not None:
         festival_info.venue = LocalizationHelperTuning.get_raw_text(zone_protobuff.name)
     festival_info.time = ui_info.festival_time
     festival_info.image = sims4.resources.get_protobuff_for_key(ui_info.display_image)
     festival_info.background_image = sims4.resources.get_protobuff_for_key(ui_info.background_image)
     festival_info.action_label = ui_info.travel_to_festival_text
     running_nodes = services.drama_scheduler_service().get_running_nodes_by_class(cls)
     active_sim_info = services.active_sim_info()
     if all(active_node.is_during_pre_festival() for active_node in running_nodes):
         festival_info.disabled_tooltip = ui_info.festival_not_started_tooltip
     elif any(active_node.is_on_festival_street() for active_node in running_nodes):
         festival_info.disabled_tooltip = ui_info.on_street_tooltip
     elif active_sim_info.is_in_travel_group():
         festival_info.disabled_tooltip = ui_info.on_vacation_tooltip
     for activity in ui_info.activity_info:
         with ProtocolBufferRollback(festival_info.activities) as activity_msg:
             activity_msg.name = activity.activity_name
             activity_msg.description = activity.activity_description
             activity_msg.icon = create_icon_info_msg(IconInfoData(activity.icon))
     distributor = Distributor.instance()
     distributor.add_op(active_sim_info, GenericProtocolBufferOp(Operation.DYNAMIC_SIGN_VIEW, festival_info))
Ejemplo n.º 13
0
 def _do_behavior(self):
     royalty_payment = self.royalty_payment
     recipient = self.interaction.get_participant(
         royalty_payment.royalty_recipient)
     if recipient is None:
         logger.error(
             "Trying to set up a royalty payment but interaction, {}, doesn't have the participant type {}.",
             self.interaction, royalty_payment.royalty_recipient)
     royalty_tracker = recipient.sim_info.royalty_tracker
     if royalty_tracker is None:
         logger.error(
             'Trying to set up a royalty payment but the sim has a None royalty tracker.'
         )
     participant = self.interaction.get_participant(
         royalty_payment.royalty_subject)
     if participant is None:
         logger.error(
             "Trying to set up a royalty payment but the royalty subject, {}, doesn't exist in this interaction.",
             royalty_payment.royalty_subject)
     if isinstance(participant, (str, LocalizedString)):
         display_name = LocalizationHelperTuning.get_raw_text(participant)
     else:
         display_name = LocalizationHelperTuning.get_object_name(
             participant)
     royalty_tracker.start_royalty(
         royalty_payment.royalty_type, royalty_payment.guid64, display_name,
         royalty_payment.payment_multipliers.get_multiplier(
             self.interaction.get_resolver()))
Ejemplo n.º 14
0
def show_client_connection_failure():
    title = "Connection failed. Perhaps the host and port you specified is incorrect?"

    notification = UiDialogNotification.TunableFactory().default(
        services.get_active_sim(),
        title=lambda **_: LocalizationHelperTuning.get_raw_text(title))
    notification.show_dialog(icon_override=(None, services.get_active_sim()))
Ejemplo n.º 15
0
def show_client_connect_on_server():
    title = "A client has connected successfully!"

    notification = UiDialogNotification.TunableFactory().default(
        services.get_active_sim(),
        title=lambda **_: LocalizationHelperTuning.get_raw_text(title))
    notification.show_dialog(icon_override=(None, services.get_active_sim()))
Ejemplo n.º 16
0
 def create_from_string(string_text: str) -> LocalizedString:
     """
         Create a LocalizedString from a string.
     :param string_text: The string to localize. The resulting LocalizedString will be '{0.String}'
     :return: A LocalizedString created from the specified string.
     """
     return LocalizationHelperTuning.get_raw_text(string_text)
Ejemplo n.º 17
0
 def build_msg(self, **kwargs):
     message = super().build_msg(**kwargs)
     message.dialog_type = Dialog_pb2.UiDialogMessage.MULTI_PICKER
     if self.text_input is not None:
         text_input_overrides = {}
         (text_name, text) = self.existing_text
         text_input_overrides = {}
         if text:
             text_input_overrides[text_name] = lambda *_, **__: LocalizationHelperTuning.get_raw_text(text)
         self.text_input.build_msg(self, message, name=text_name, text_input_overrides=text_input_overrides if text_input_overrides else None)
     context = InteractionContext(self._owner(), InteractionSource.SCRIPT, Priority.Low)
     multi_picker_msg = Dialog_pb2.UiDialogMultiPicker()
     for picker_data in self.pickers:
         aop = AffordanceObjectPair(picker_data.picker_interaction, None, picker_data.picker_interaction, None)
         result = aop.interaction_factory(context)
         if not result:
             continue
         interaction = result.interaction
         picker_tuning = picker_data.picker_interaction.picker_dialog
         if picker_tuning.title is None:
             title = lambda *_, **__: interaction.get_name(apply_name_modifiers=False)
         else:
             title = self.picker_dialog.title
         dialog = picker_tuning(self._owner(), title=title, resolver=interaction.get_resolver(context=context))
         interaction._setup_dialog(dialog)
         dialog.add_listener(interaction._on_picker_selected)
         self._picker_dialogs[dialog.dialog_id] = dialog
         new_message = dialog.build_msg()
         multi_picker_item = multi_picker_msg.multi_picker_items.add()
         multi_picker_item.picker_data = new_message.picker_data
         multi_picker_item.picker_id = new_message.dialog_id
         multi_picker_item.disabled_tooltip = picker_data.disabled_tooltip
     message.multi_picker_data = multi_picker_msg
     return message
Ejemplo n.º 18
0
def show_server_host_attempt():
    title = "Attempting to host the game."

    notification = UiDialogNotification.TunableFactory().default(
        services.get_active_sim(),
        title=lambda **_: LocalizationHelperTuning.get_raw_text(title))
    notification.show_dialog(icon_override=(None, services.get_active_sim()))
Ejemplo n.º 19
0
 def get_state_strings(self, first_string=None):
     obj = self.owner
     int_token = 0
     for state_int_data in self.state_value_numbers:
         state_value = state_int_data.state_value
         if state_value is None:
             continue
         if obj.has_state(state_value.state):
             if obj.get_state(state_value.state) is state_value:
                 int_token = state_int_data.number
                 break
     bullet_points = [] if first_string is None else [first_string]
     for state_string_datas in self.state_value_strings:
         for state_string_data in state_string_datas:
             state_value = state_string_data.state_value
             if state_value is None:
                 continue
             if obj.has_state(state_value.state) and obj.get_state(
                     state_value.state) is state_value:
                 bullet_point = state_string_data.text(int_token)
                 bullet_points.append(bullet_point)
                 break
     if bullet_points:
         if len(bullet_points) == 1:
             return LocalizationHelperTuning.get_raw_text(bullet_points[0])
         else:
             return LocalizationHelperTuning.get_bulleted_list(
                 None, *bullet_points)
Ejemplo n.º 20
0
def show_unsuccessful_server_host():
    title = "Nobody connected to the host in time."

    notification = UiDialogNotification.TunableFactory().default(
        services.get_active_sim(),
        title=lambda **_: LocalizationHelperTuning.get_raw_text(title))
    notification.show_dialog(icon_override=(None, services.get_active_sim()))
Ejemplo n.º 21
0
 def set_custom_description(self, description):
     if self.allow_description:
         self.owner.custom_description = description if description else None
         self._call_name_changed_callback()
         if self.owner.update_object_tooltip() is None and isinstance(self.owner, ClientObjectMixin):
             _set_recipe_decription(self.owner, LocalizationHelperTuning.get_raw_text(description))
         return True
     return False
Ejemplo n.º 22
0
 def name(self):
     if self._pet_familiar_id is None:
         return LocalizationHelperTuning.get_raw_text(self._name)
     pet_familiar = services.sim_info_manager().get(self._pet_familiar_id)
     if pet_familiar is None:
         logger.error("Attempting to get the name of a pet familiar that doesn't exist.")
         return
     return LocalizationHelperTuning.get_sim_name(pet_familiar)
Ejemplo n.º 23
0
 def set_custom_name(self, name):
     if self.allow_name:
         self.owner.custom_name = name if name else None
         self._call_name_changed_callback()
         if self.owner.update_object_tooltip() is None and isinstance(self.owner, ClientObjectMixin):
             _set_recipe_name(self.owner, LocalizationHelperTuning.get_raw_text(name))
         return True
     return False
Ejemplo n.º 24
0
 def show_dialog(self, **kwargs):
     self.title = lambda **_: LocalizationHelperTuning.get_raw_text(
         'Tuning Error Notifier')
     self.text = lambda **_: LocalizationHelperTuning.get_raw_text(
         'XML tuning errors matching your filters were detected.  Press the Report button below to view these in your web browser.'
     )
     # noinspection PySetFunctionToLiteral
     response_command = make_immutable_slots_class(
         set(['arguments', 'command']))({
             'arguments': (),
             'command': 'tuning_notifier.report'
         })
     response = UiDialogResponse(
         dialog_response_id=ButtonType.DIALOG_RESPONSE_OK,
         ui_request=UiDialogResponse.UiDialogUiRequest.SEND_COMMAND,
         response_command=response_command,
         text=lambda **_: LocalizationHelperTuning.get_raw_text('Report'))
     self.ui_responses = (response, )
     super().show_dialog(**kwargs)
 def set_custom_name(self, name):
     if self.allow_name:
         self.owner.custom_name = name if name else None
         self._call_name_changed_callback()
         if self.owner.update_object_tooltip() is None and isinstance(
                 self.owner, ClientObjectMixin):
             _set_recipe_name(self.owner,
                              LocalizationHelperTuning.get_raw_text(name))
         return True
     return False
 def set_custom_description(self, description):
     if self.allow_description:
         self.owner.custom_description = description if description else None
         self._call_name_changed_callback()
         if self.owner.update_object_tooltip() is None and isinstance(
                 self.owner, ClientObjectMixin):
             _set_recipe_decription(
                 self.owner,
                 LocalizationHelperTuning.get_raw_text(description))
         return True
     return False
 def picker_rows_gen(cls, inst, target, context, **kwargs):
     inst_or_cls = inst if inst is not None else cls
     for state_value in inst_or_cls._get_valid_state_values_gen():
         if state_value._display_data is not None:
             state_name = state_value.display_name or LocalizationHelperTuning.get_raw_text(
                 state_value.__name__)
             row_tooltip = None if state_value.display_description is None else lambda *_, tooltip=state_value.display_description: tooltip
             yield ObjectPickerRow(
                 name=state_name,
                 row_description=state_value.display_description,
                 icon=state_value.display_icon,
                 tag=state_value,
                 row_tooltip=row_tooltip)
Ejemplo n.º 28
0
def sim_picker_dialog_test(_connection=None):
    output = sims4.commands.CheatOutput(_connection)
    client = services.client_manager().get_first_client()

    def get_inputs_callback(dialog):
        if not dialog.accepted:
            output("Dialog was closed/cancelled")
            return
        output("Dialog was accepted")
        for sim_id in dialog.get_result_tags():
            output("id={}".format(sim_id))

    localized_title = lambda **_: LocalizationHelperTuning.get_raw_text(
        "Sim Picker Dialog Test")
    localized_text = lambda **_: LocalizationHelperTuning.get_raw_text(
        "Select up to five sims and press OK or close dialog....")
    max_selectable_immutable = sims4.collections.make_immutable_slots_class(
        set(['multi_select', 'number_selectable', 'max_type']))
    max_selectable = max_selectable_immutable({
        'multi_select': False,
        'number_selectable': 5,
        'max_type': 1
    })
    dialog = UiSimPicker.TunableFactory().default(
        client.active_sim,
        text=localized_text,
        title=localized_title,
        max_selectable=max_selectable,
        min_selectable=1,
        should_show_names=True,
        hide_row_description=False)
    for sim_info in services.sim_info_manager().get_all():
        # Set second arg below to True to have that sim preselected/highlighted....
        dialog.add_row(
            SimPickerRow(sim_info.sim_id, False, tag=sim_info.sim_id))

    dialog.add_listener(get_inputs_callback)
    dialog.show_dialog(icon_override=IconInfoData(obj_instance=(sim_info)))
Ejemplo n.º 29
0
 def picker_rows_gen(cls, inst, target, context, **kwargs):
     for item in cls._items_gen():
         display_name = LocalizationHelperTuning.get_raw_text(
             str(item.__name__)
         ) if item.display_name is None else item.display_name
         row_tooltip = None if item.display_tooltip is None else lambda *_, tooltip=item.display_tooltip: tooltip
         row = ObjectPickerRow(name=display_name,
                               icon=item.display_icon,
                               def_id=item.decoration_resource,
                               row_tooltip=row_tooltip,
                               row_description=item.display_description,
                               tag_list=item.picker_categories,
                               tag=item,
                               use_catalog_product_thumbnails=False)
         yield row
Ejemplo n.º 30
0
 def populate_protocol_buffer(self, lot_row_data):
     super().populate_protocol_buffer(lot_row_data.base_data, name_override=LocalizationHelperTuning.get_raw_text(self.name))
     logger.assert_raise(self.zone_id is not None, 'No zone_id passed to lot picker row', owner='nbaker')
     lot_row_data.lot_info_item.zone_id = self.zone_id
     if self.name is not None:
         lot_row_data.lot_info_item.name = self.name
     if self.world_id is not None:
         lot_row_data.lot_info_item.world_id = self.world_id
     if self.lot_template_id is not None:
         lot_row_data.lot_info_item.lot_template_id = self.lot_template_id
     if self.lot_description_id is not None:
         lot_row_data.lot_info_item.lot_description_id = self.lot_description_id
     if self.venue_type_name is not None:
         lot_row_data.lot_info_item.venue_type_name = self.venue_type_name
     if self.household_name is not None:
         lot_row_data.lot_info_item.household_name = self.household_name
Ejemplo n.º 31
0
 def _do_behavior(self):
     royalty_payment = self.royalty_payment
     recipient = self.interaction.get_participant(royalty_payment.royalty_recipient)
     if recipient is None:
         logger.error("Trying to set up a royalty payment but interaction, {}, doesn't have the participant type {}.", self.interaction, royalty_payment.royalty_recipient)
     royalty_tracker = recipient.sim_info.royalty_tracker
     if royalty_tracker is None:
         logger.error('Trying to set up a royalty payment but the sim has a None royalty tracker.')
     participant = self.interaction.get_participant(royalty_payment.royalty_subject)
     if participant is None:
         logger.error("Trying to set up a royalty payment but the royalty subject, {}, doesn't exist in this interaction.", royalty_payment.royalty_subject)
     if isinstance(participant, (str, LocalizedString)):
         display_name = LocalizationHelperTuning.get_raw_text(participant)
     else:
         display_name = LocalizationHelperTuning.get_object_name(participant)
     royalty_tracker.start_royalty(royalty_payment.royalty_type, royalty_payment.guid64, display_name, royalty_payment.payment_multipliers.get_multiplier(self.interaction.get_resolver()))
Ejemplo n.º 32
0
 def show_dialog(cls, first_time_buyer=False):
     business_managers = services.business_service(
     ).get_business_managers_for_household()
     if not business_managers:
         logger.error(
             'Trying to show the balance transfer dialog but failed to find any owned businesses for the active household.'
         )
         return False
     active_household = services.active_household()
     current_zone_id = services.current_zone_id()
     current_business_manager = business_managers.get(current_zone_id, None)
     balance_transfer_msg = Dialog_pb2.BalanceTransferDialog()
     balance_transfer_msg.transfer_amount = min(
         active_household.funds.money, current_business_manager.tuning_data.
         initial_funds_transfer_amount) if first_time_buyer else 0
     if first_time_buyer or current_business_manager is None:
         cls._add_household(balance_transfer_msg, active_household)
         cls._try_add_current_business_lot(balance_transfer_msg,
                                           business_managers,
                                           current_zone_id)
     else:
         cls._try_add_current_business_lot(balance_transfer_msg,
                                           business_managers,
                                           current_zone_id)
         cls._add_household(balance_transfer_msg, active_household)
     for (zone_id, business_manager) in business_managers.items():
         if zone_id == current_zone_id:
             continue
         zone_data = services.get_persistence_service().get_zone_proto_buff(
             zone_id)
         if zone_data is None:
             logger.error(
                 "Business tracker thinks a zone exists that doesn't. Zone id:{}",
                 zone_id)
         else:
             with ProtocolBufferRollback(
                     balance_transfer_msg.lot_data) as lot_data:
                 lot_data.lot_name = LocalizationHelperTuning.get_raw_text(
                     zone_data.name)
                 lot_data.zone_id = zone_id
                 lot_data.balance = business_manager.funds.money
     transfer_op = GenericProtocolBufferOp(
         DistributorOps_pb2.Operation.RETAIL_BALANCE_TRANSFER_DIALOG,
         balance_transfer_msg)
     Distributor.instance().add_op_with_no_owner(transfer_op)
Ejemplo n.º 33
0
 def _get_string_for_humans(self, sim, household, *args, **kwargs):
     humans = tuple(
         household.get_humans_gen()) if household is not None else ()
     if not (self.empty_household is not None and
             (household is None or not humans)):
         return self.empty_household(sim, *args, **kwargs)
     if household is None:
         logger.error(
             "LocalizedStringHouseholdNameSelector is being provided a None household, but 'empty_household' text is unset."
         )
         return LocalizationHelperTuning.get_raw_text('')
     if self.single_sim is not None and len(humans) == 1:
         return self.single_sim(humans[0], *args + (sim, ), **kwargs)
     if self.single_family is not None and all(
             sim_info.last_name == sim.last_name
             for sim_info in humans) and sim.last_name == household.name:
         return self.single_family(sim.last_name, *args + (sim, ), **kwargs)
     return self.fallback(household.name, *args + (sim, ), **kwargs)
Ejemplo n.º 34
0
 def _build_object_relationship_update_proto(self,
                                             actor_sim_info,
                                             member_obj_def_id,
                                             deltas=None,
                                             name_override=None):
     msg = commodity_protocol.RelationshipUpdate()
     actor_sim_id = actor_sim_info.sim_id
     msg.actor_sim_id = actor_sim_id
     if name_override is not None:
         loc_custom_name = LocalizationHelperTuning.get_raw_text(
             name_override)
         build_icon_info_msg(IconInfoData(), loc_custom_name,
                             msg.target_icon_override)
     if self._target_object_id == 0:
         target_object = None
         tag_set = services.relationship_service().get_mapped_tag_set_of_id(
             member_obj_def_id)
         definition_ids = services.relationship_service(
         ).get_ids_of_tag_set(tag_set)
         for definition_id in definition_ids:
             for obj in services.object_manager().objects:
                 if definition_id == obj.definition.id:
                     target_object = obj
                     break
         if target_object is None:
             logger.error(
                 'Failed to find an object with requested object tag set in the world,                             so the initial object type relationship creation for sim {} will not complete.',
                 actor_sim_info)
             return
         (msg.target_id.object_id,
          msg.target_id.manager_id) = target_object.icon_info
         msg.target_instance_id = target_object.id
         self._target_object_id = msg.target_id.object_id
         self._target_object_manager_id = msg.target_id.manager_id
         self._target_object_instance_id = msg.target_instance_id
     else:
         msg.target_id.object_id = self._target_object_id
         msg.target_id.manager_id = self._target_object_manager_id
         msg.target_instance_id = self._target_object_instance_id
     msg.last_update_time = self._last_update_time
     track_bits = self._build_relationship_track_proto(msg)
     self._build_relationship_bit_proto(actor_sim_id, track_bits, msg)
     return msg
Ejemplo n.º 35
0
 def get_state_strings(self):
     obj = self.owner
     int_token = 0
     for state_int_data in self.state_value_numbers:
         state_value = state_int_data.state_value
         while obj.has_state(state_value.state) and obj.get_state(state_value.state) is state_value:
             int_token = state_int_data.number
             break
     bullet_points = []
     for state_string_datas in self.state_value_strings:
         for state_string_data in state_string_datas:
             state_value = state_string_data.state_value
             while obj.has_state(state_value.state) and obj.get_state(state_value.state) is state_value:
                 bullet_point = state_string_data.text(int_token)
                 bullet_points.append(bullet_point)
                 break
     if bullet_points:
         if len(bullet_points) == 1:
             return LocalizationHelperTuning.get_raw_text(bullet_points[0])
         return LocalizationHelperTuning.get_bulleted_list(None, *bullet_points)
Ejemplo n.º 36
0
def ui_dialog_notification_test(*all_text, _connection=None):
    client = services.client_manager().get(_connection)
    all_text_str = ' '.join(all_text)
    if '/' in all_text:
        (title, text) = all_text_str.split('/')
        notification = UiDialogNotification.TunableFactory().default(client.active_sim, text=lambda **_: LocalizationHelperTuning.get_raw_text(text), title=lambda **_: LocalizationHelperTuning.get_raw_text(title))
    else:
        notification = UiDialogNotification.TunableFactory().default(client.active_sim, text=lambda **_: LocalizationHelperTuning.get_raw_text(all_text_str))
    notification.show_dialog(icon_override=(None, client.active_sim))