コード例 #1
0
 def display(text,
             title,
             sims_ids,
             selected_sims_ids=(),
             min_selectable=1,
             max_selectable=1,
             should_show_names=True,
             hide_row_description=False,
             sim=None,
             callback=None):
     text = TurboL18NUtil.get_localized_string(text)
     title = TurboL18NUtil.get_localized_string(title)
     sim_picker_dialog = UiSimPicker.TunableFactory().default(
         sim or TurboUIUtil._get_client_sim(),
         text=lambda *args, **kwargs: text,
         title=lambda *args, **kwargs: title,
         min_selectable=min_selectable,
         max_selectable=max_selectable,
         should_show_names=should_show_names,
         hide_row_description=hide_row_description)
     for sim_id in sims_ids:
         sim_picker_dialog.add_row(
             SimPickerRow(sim_id,
                          select_default=sim_id in selected_sims_ids,
                          tag=sim_id))
     if callback is not None:
         sim_picker_dialog.add_listener(callback)
     sim_picker_dialog.show_dialog()
コード例 #2
0
 def picker_rows_gen(cls, inst, target, context, **kwargs):
     inst_or_cls = inst if inst is not None else cls
     adoption_service = services.get_adoption_service()
     with adoption_service.real_sim_info_cache():
         for entry in inst_or_cls.picker_entries:
             for sim_info in adoption_service.get_sim_infos(entry.count, entry.creation_data.age, entry.creation_data.gender, entry.creation_data.species):
                 aging_data = AgingTuning.get_aging_data(sim_info.species)
                 age_transition_data = aging_data.get_age_transition_data(sim_info.age)
                 row_description = age_transition_data.age_trait.display_name(sim_info)
                 yield SimPickerRow(sim_id=sim_info.sim_id, tag=sim_info.sim_id, row_description=row_description)
コード例 #3
0
 def on_choice_selected(self, interaction, picked_items, **kwargs):
     dialog = self.picker_dialog(interaction.sim,
                                 title=lambda *_, **__: interaction.
                                 get_name(apply_name_modifiers=False),
                                 resolver=interaction.get_resolver())
     for filter_result in self._get_filter_results():
         dialog.add_row(
             SimPickerRow(filter_result.sim_info.sim_id,
                          tag=filter_result.sim_info))
     dialog.add_listener(
         self._get_on_sim_choice_selected(interaction, picked_items))
     dialog.show_dialog()
コード例 #4
0
def _common_testing_show_choose_sims_dialog(_connection: int = None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test choose sims dialog.')

    def _on_chosen(choice: Union[Tuple[SimInfo], None],
                   outcome: CommonChoiceOutcome):
        output('Chose {} with result: {}.'.format(
            CommonSimNameUtils.get_full_names(choice), pformat(outcome)))

    try:
        # LocalizedStrings within other LocalizedStrings
        title_tokens = (CommonLocalizationUtils.create_localized_string(
            CommonStringId.TESTING_SOME_TEXT_FOR_TESTING,
            text_color=CommonLocalizedStringColor.GREEN), )
        description_tokens = (CommonLocalizationUtils.create_localized_string(
            CommonStringId.TESTING_TEST_TEXT_WITH_SIM_FIRST_AND_LAST_NAME,
            tokens=(CommonSimUtils.get_active_sim_info(), ),
            text_color=CommonLocalizedStringColor.BLUE), )
        from sims4communitylib.utils.common_icon_utils import CommonIconUtils
        current_count = 0
        count = 25
        options = []
        for sim_info in CommonSimUtils.get_sim_info_for_all_sims_generator():
            if current_count >= count:
                break
            sim_id = CommonSimUtils.get_sim_id(sim_info)
            is_enabled = random.choice((True, False))
            options.append(
                SimPickerRow(sim_id,
                             select_default=False,
                             tag=sim_info,
                             is_enable=is_enabled))
            current_count += 1

        dialog = CommonChooseSimsDialog(
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            tuple(options),
            title_tokens=title_tokens,
            description_tokens=description_tokens)
        dialog.show(on_chosen=_on_chosen,
                    column_count=5,
                    min_selectable=2,
                    max_selectable=6)
    except Exception as ex:
        CommonExceptionHandler.log_exception(ModInfo.get_identity().name,
                                             'Failed to show dialog',
                                             exception=ex)
        output(
            'Failed to show dialog, please locate your exception log file and upload it to the appropriate thread.'
        )
    output('Done showing.')
コード例 #5
0
    def as_row(self, option_id: int) -> SimPickerRow:
        """as_row(option_id)

        Convert the option into a picker row.

        :param option_id: The index of the option.
        :type option_id: int
        :return: The option as a Picker Row
        :rtype: SimPickerRow
        """
        return SimPickerRow(self.sim_id,
                            select_default=self.context.is_selected,
                            is_enable=self.context.is_enabled,
                            tag=self)
コード例 #6
0
 def _handle_dialog(self, dialog):
     if not dialog.accepted and dialog.response != NPCHostedSituationDialog.BRING_OTHER_SIMS_RESPONSE_ID:
         with telemetry_helper.begin_hook(telemetry_writer, TELEMETRY_HOOK_SITUATION_REJECTED, sim_info=self._receiver_sim_info) as hook:
             hook.write_guid(TELEMETRY_SITUATION_TYPE_ID, self._situation_to_run.guid64)
         services.drama_scheduler_service().complete_node(self.uid)
         return
     if dialog.response == NPCHostedSituationDialog.BRING_OTHER_SIMS_RESPONSE_ID:
         bring_other_sims_data = self._chosen_dialog.bring_other_sims
         picker_dialog = bring_other_sims_data.picker_dialog(self._receiver_sim_info, resolver=self._get_resolver())
         blacklist = {sim_info.id for sim_info in self._sender_sim_info.household.sim_info_gen()}
         blacklist.add(self._receiver_sim_info.id)
         results = services.sim_filter_service().submit_filter(bring_other_sims_data.travel_with_filter, callback=None, requesting_sim_info=self._receiver_sim_info, blacklist_sim_ids=blacklist, allow_yielding=False, gsi_source_fn=self.get_sim_filter_gsi_name)
         for result in results:
             picker_dialog.add_row(SimPickerRow(result.sim_info.sim_id, tag=result.sim_info))
         picker_dialog.show_dialog(on_response=self._handle_picker_dialog)
         return
     self._create_situation()
     services.drama_scheduler_service().complete_node(self.uid)
コード例 #7
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)))
コード例 #8
0
 def create_row(cls, inst, tag):
     return SimPickerRow(sim_id=tag, tag=tag)