def _common_testing_show_multi_pane_choose_option_dialog(
        _connection: int = None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test multi pane choose option dialog.')

    def _on_option_chosen_in_dialog_one(option_identifier: str, choice: str):
        output('Chose option in dialog one {} with value: {}.'.format(
            pformat(option_identifier), pformat(choice)))

    def _on_option_chosen_in_dialog_two(option_identifier: str, choice: str):
        output('Chose option in dialog two {} with value: {}.'.format(
            pformat(option_identifier), pformat(choice)))

    def _on_submit(chosen_options: Dict[int, Any]):
        output('Chosen options from all dialogs {}.'.format(
            pformat(chosen_options)))

    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), )

        sub_dialog_one = CommonChooseObjectOptionDialog(
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            title_tokens=title_tokens,
            description_tokens=description_tokens,
            per_page=2)

        sub_dialog_one.add_option(
            CommonDialogObjectOption(
                'Option 1',
                'Value 1',
                CommonDialogOptionContext(
                    CommonStringId.TESTING_SOME_TEXT_FOR_TESTING,
                    CommonStringId.TESTING_TEST_BUTTON_ONE,
                    icon=CommonIconUtils.load_checked_square_icon()),
                on_chosen=_on_option_chosen_in_dialog_one))

        sub_dialog_one.add_option(
            CommonDialogObjectOption(
                'Option 2',
                'Value 2',
                CommonDialogOptionContext(
                    CommonStringId.TESTING_SOME_TEXT_FOR_TESTING,
                    CommonStringId.TESTING_TEST_BUTTON_TWO,
                    icon=CommonIconUtils.load_arrow_navigate_into_icon()),
                on_chosen=_on_option_chosen_in_dialog_one))

        sub_dialog_one.add_option(
            CommonDialogObjectOption(
                'Option 3',
                'Value 3',
                CommonDialogOptionContext(
                    CommonLocalizationUtils.create_localized_string('Value 3'),
                    CommonStringId.TESTING_TEST_BUTTON_TWO,
                    icon=CommonIconUtils.load_arrow_navigate_into_icon()),
                on_chosen=_on_option_chosen_in_dialog_one))

        sub_dialog_two = CommonChooseObjectOptionDialog(
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            title_tokens=title_tokens,
            description_tokens=description_tokens,
            per_page=2)

        sub_dialog_two.add_option(
            CommonDialogObjectOption(
                'Option 4',
                'Value 4',
                CommonDialogOptionContext(
                    CommonStringId.TESTING_SOME_TEXT_FOR_TESTING,
                    CommonStringId.TESTING_TEST_BUTTON_ONE,
                    icon=CommonIconUtils.load_checked_square_icon()),
                on_chosen=_on_option_chosen_in_dialog_two))

        sub_dialog_two.add_option(
            CommonDialogObjectOption(
                'Option 5',
                'Value 5',
                CommonDialogOptionContext(
                    CommonStringId.TESTING_SOME_TEXT_FOR_TESTING,
                    CommonStringId.TESTING_TEST_BUTTON_TWO,
                    icon=CommonIconUtils.load_arrow_navigate_into_icon()),
                on_chosen=_on_option_chosen_in_dialog_two))

        sub_dialog_two.add_option(
            CommonDialogObjectOption(
                'Option 6',
                'Value 6',
                CommonDialogOptionContext(
                    CommonLocalizationUtils.create_localized_string('Value 3'),
                    CommonStringId.TESTING_TEST_BUTTON_TWO,
                    icon=CommonIconUtils.load_arrow_navigate_into_icon()),
                on_chosen=_on_option_chosen_in_dialog_two))

        option_dialog = CommonMultiPaneChooseOptionDialog(
            ModInfo.get_identity(),
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            title_tokens=title_tokens,
            description_tokens=description_tokens)

        option_dialog.add_sub_dialog(sub_dialog_one)
        option_dialog.add_sub_dialog(sub_dialog_two)

        option_dialog.show(on_submit=_on_submit,
                           sim_info=CommonSimUtils.get_active_sim_info())
    except Exception as ex:
        CommonExceptionHandler.log_exception(ModInfo.get_identity(),
                                             'Failed to show dialog',
                                             exception=ex)
        output('Failed to show dialog, please locate your exception log file.')
    output('Done showing.')
Exemple #2
0
def _common_testing_show_ok_dialog(_connection: int=None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test ok dialog.')

    def _on_acknowledged(_dialog: UiDialogOk):
        if _dialog.accepted:
            output('Ok option chosen.')
        else:
            output('Dialog closed.')

    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),)
        dialog = CommonOkDialog(
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            title_tokens=title_tokens,
            description_tokens=description_tokens,
            ok_text_identifier=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_TEST_BUTTON_ONE, text_color=CommonLocalizedStringColor.RED)
        )
        dialog.show(on_acknowledged=_on_acknowledged)
    except Exception as ex:
        CommonExceptionHandler.log_exception(ModInfo.get_identity(), 'Failed to show dialog', exception=ex)
        output('Failed to show ok dialog, please locate your exception log file.')
    output('Done showing.')
Exemple #3
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.')
Exemple #4
0
def _common_testing_show_choose_objects_option_dialog(_connection: int = None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test choose objects option dialog.')

    def _on_option_chosen(option_identifier: str, choice: str):
        output('Chose option {} with value: {}.'.format(
            pformat(option_identifier), pformat(choice)))

    def _on_submit(choices: Tuple[str]):
        output('Chose options {}.'.format(pformat(choices)))

    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), )
        option_dialog = CommonChooseObjectsOptionDialog(
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            title_tokens=title_tokens,
            description_tokens=description_tokens,
            per_page=2)

        from sims4communitylib.utils.common_icon_utils import CommonIconUtils

        option_dialog.add_option(
            CommonDialogObjectOption(
                'Option 1',
                'Value 1',
                CommonDialogOptionContext(
                    CommonStringId.TESTING_SOME_TEXT_FOR_TESTING,
                    CommonStringId.TESTING_TEST_BUTTON_ONE,
                    icon=CommonIconUtils.load_checked_square_icon()),
                on_chosen=_on_option_chosen))

        option_dialog.add_option(
            CommonDialogObjectOption(
                'Option 2',
                'Value 2',
                CommonDialogOptionContext(
                    CommonStringId.TESTING_SOME_TEXT_FOR_TESTING,
                    CommonStringId.TESTING_TEST_BUTTON_TWO,
                    icon=CommonIconUtils.load_arrow_navigate_into_icon()),
                on_chosen=_on_option_chosen))

        option_dialog.add_option(
            CommonDialogObjectOption(
                'Option 3',
                'Value 3',
                CommonDialogOptionContext(
                    CommonLocalizationUtils.create_localized_string('Value 3'),
                    CommonStringId.TESTING_TEST_BUTTON_TWO,
                    icon=CommonIconUtils.load_arrow_navigate_into_icon()),
                on_chosen=_on_option_chosen))

        option_dialog.show(on_submit=_on_submit,
                           sim_info=CommonSimUtils.get_active_sim_info(),
                           min_selectable=1,
                           max_selectable=2)
    except Exception as ex:
        CommonExceptionHandler.log_exception(ModInfo.get_identity(),
                                             'Failed to show dialog',
                                             exception=ex)
        output('Failed to show dialog, please locate your exception log file.')
    output('Done showing.')
Exemple #5
0
def _common_testing_show_input_float_dialog(_connection: int=None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test input float dialog.')

    def _on_chosen(choice: float, outcome: CommonChoiceOutcome):
        output('Chose {} with result: {}.'.format(pformat(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
        dialog = CommonInputFloatDialog(
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            2.0,
            title_tokens=title_tokens,
            description_tokens=description_tokens
        )
        dialog.show(on_submit=_on_chosen)
    except Exception as ex:
        CommonExceptionHandler.log_exception(ModInfo.get_identity(), 'Failed to show dialog', exception=ex)
        output('Failed to show dialog, please locate your exception log file.')
    output('Done showing.')
def _common_testing_show_choose_objects_dialog(_connection: int = None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test choose objects dialog.')

    def _on_chosen(choices: Tuple[str], outcome: CommonChoiceOutcome):
        output('Chose {} with result: {}.'.format(pformat(choices),
                                                  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
        options = [
            ObjectPickerRow(
                option_id=1,
                name=CommonLocalizationUtils.create_localized_string(
                    CommonStringId.TESTING_SOME_TEXT_FOR_TESTING),
                row_description=CommonLocalizationUtils.
                create_localized_string(
                    CommonStringId.TESTING_TEST_BUTTON_ONE),
                row_tooltip=None,
                icon=CommonIconUtils.load_checked_square_icon(),
                tag='Value 1'),
            ObjectPickerRow(
                option_id=2,
                name=CommonLocalizationUtils.create_localized_string(
                    CommonStringId.TESTING_SOME_TEXT_FOR_TESTING),
                row_description=CommonLocalizationUtils.
                create_localized_string(
                    CommonStringId.TESTING_TEST_BUTTON_TWO),
                row_tooltip=None,
                icon=CommonIconUtils.load_arrow_navigate_into_icon(),
                tag='Value 2'),
            ObjectPickerRow(
                option_id=3,
                name=CommonLocalizationUtils.create_localized_string(
                    'Value 3'),
                row_description=CommonLocalizationUtils.
                create_localized_string(
                    CommonStringId.TESTING_TEST_BUTTON_TWO),
                row_tooltip=None,
                icon=CommonIconUtils.load_arrow_navigate_into_icon(),
                tag='Value 3')
        ]
        dialog = CommonChooseObjectsDialog(
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            tuple(options),
            title_tokens=title_tokens,
            description_tokens=description_tokens,
            per_page=2)
        dialog.show(on_chosen=_on_chosen, min_selectable=1, max_selectable=2)
    except Exception as ex:
        CommonExceptionHandler.log_exception(ModInfo.get_identity(),
                                             'Failed to show dialog',
                                             exception=ex)
        output('Failed to show dialog, please locate your exception log file.')
    output('Done showing.')
Exemple #7
0
def _common_testing_show_purchase_objects_dialog(_connection: int = None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test purchase object dialog.')

    def _on_chosen(choices: str, outcome: CommonChoiceOutcome):
        output('Chose {} with result: {}.'.format(pformat(choices),
                                                  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), )
        show_discount = True
        from sims4communitylib.utils.common_icon_utils import CommonIconUtils
        active_sim_info = CommonSimUtils.get_active_sim_info()
        obj_id = 20359
        obj_definition = CommonObjectUtils.get_object_definition(obj_id)
        tags = obj_definition.build_buy_tags
        options = [
            PurchasePickerRow(def_id=obj_definition.id,
                              is_enable=True,
                              num_owned=CommonSimInventoryUtils.
                              get_count_of_object_in_inventory(
                                  active_sim_info, obj_id),
                              num_available=2000,
                              tags=obj_definition.build_buy_tags,
                              objects=tuple(),
                              row_tooltip=None,
                              show_discount=show_discount,
                              icon_override=None,
                              row_description=None),
        ]
        categories = list()
        for tag in tags:
            tag_name = CommonGameTag.value_to_name.get(tag, None)
            if tag_name is None:
                continue
            categories.append(
                CommonDialogObjectOptionCategory(tag,
                                                 obj_definition.icon,
                                                 category_name=tag_name))
        dialog = CommonPurchaseObjectsDialog(
            ModInfo.get_identity(),
            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.log.enable()
        dialog.show(on_chosen=_on_chosen, categories=categories)
    except Exception as ex:
        CommonExceptionHandler.log_exception(ModInfo.get_identity(),
                                             'Failed to show dialog',
                                             exception=ex)
        output('Failed to show dialog, please locate your exception log file.')
    output('Done showing.')
Exemple #8
0
    def _setup_dialog(
        self,
        option_dialog: CommonChooseButtonOptionDialog,
        on_close: Callable[[], None],
        on_previous: Callable[[], None],
        reopen: Callable[[], None],
        target_sim_info: SimInfo=None,
        **__
    ) -> bool:
        def _operation_run(operation: S4CMSingleSimOperation):
            def _on_operation_complete(_: bool) -> None:
                reopen()

            if target_sim_info is not None:
                operation.run_with_sims(self._sim_info, target_sim_info, on_completed=_on_operation_complete)
            else:
                operation.run(self._sim_info, on_completed=_on_operation_complete)

        if target_sim_info is None:
            active_sim_info = CommonSimUtils.get_active_sim_info()
            if active_sim_info is not None and self._sim_info is not active_sim_info:
                option_dialog.add_option(
                    CommonDialogButtonOption(
                        'WithSelf',
                        None,
                        CommonDialogResponseOptionContext(
                            S4CMSimControlMenuStringId.SET_RELATIONSHIPS_WITH_SIM,
                            text_tokens=(active_sim_info, )
                        ),
                        on_chosen=lambda *_, **__: None if self.open(target_sim_info=active_sim_info) else None
                    )
                )

        if (target_sim_info is None and S4CMSetFriendshipLevelOp().can_run_with_sim(self._sim_info)) or S4CMSetFriendshipLevelOp().can_run_with_sims(self._sim_info, target_sim_info):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'FriendshipLevel',
                    None,
                    CommonDialogResponseOptionContext(
                        S4CMSimControlMenuStringId.SET_FRIENDSHIP_LEVEL
                    ),
                    on_chosen=lambda *_, **__: _operation_run(S4CMSetFriendshipLevelOp())
                )
            )

        if (target_sim_info is None and S4CMSetRomanceLevelOp().can_run_with_sim(self._sim_info)) or S4CMSetRomanceLevelOp().can_run_with_sims(self._sim_info, target_sim_info):
            if S4CMSettingUtils.is_allowed_romantic_relationship(self._sim_info):
                option_dialog.add_option(
                    CommonDialogButtonOption(
                        'RomanceLevel',
                        None,
                        CommonDialogResponseOptionContext(
                            S4CMSimControlMenuStringId.SET_ROMANCE_LEVEL
                        ),
                        on_chosen=lambda *_, **__: _operation_run(S4CMSetRomanceLevelOp())
                    )
                )

        if (target_sim_info is None and S4CMAddHasMetSimsOp().can_run_with_sim(self._sim_info)) or S4CMAddHasMetSimsOp().can_run_with_sims(self._sim_info, target_sim_info):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'AddHasMet',
                    None,
                    CommonDialogResponseOptionContext(
                        S4CMSimControlMenuStringId.ADD_HAS_MET,
                    ),
                    on_chosen=lambda *_, **__: _operation_run(S4CMAddHasMetSimsOp())
                )
            )

        if (target_sim_info is None and S4CMRemoveHasMetSimsOp().can_run_with_sim(self._sim_info)) or S4CMRemoveHasMetSimsOp().can_run_with_sims(self._sim_info, target_sim_info):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'RemoveHasMet',
                    None,
                    CommonDialogResponseOptionContext(
                        S4CMSimControlMenuStringId.REMOVE_HAS_MET,
                    ),
                    on_chosen=lambda *_, **__: _operation_run(S4CMRemoveHasMetSimsOp())
                )
            )

        if (target_sim_info is None and S4CMSetFamilyRelationsBitOp().can_run_with_sim(self._sim_info)) or S4CMSetFamilyRelationsBitOp().can_run_with_sims(self._sim_info, target_sim_info):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'FamilyRelations',
                    None,
                    CommonDialogResponseOptionContext(
                        S4CMSimControlMenuStringId.SET_FAMILY_RELATIONS
                    ),
                    on_chosen=lambda *_, **__: _operation_run(S4CMSetFamilyRelationsBitOp())
                )
            )

        if (target_sim_info is None and S4CMForgetSimsOp().can_run_with_sim(self._sim_info)) or S4CMForgetSimsOp().can_run_with_sims(self._sim_info, target_sim_info):
            option_dialog.add_option(
                CommonDialogButtonOption(
                    'ForgetSims',
                    None,
                    CommonDialogResponseOptionContext(
                        S4CMSimControlMenuStringId.FORGET_SIMS,
                    ),
                    on_chosen=lambda *_, **__: _operation_run(S4CMForgetSimsOp())
                )
            )
        return True
def _common_testing_show_multi_pane_choose_dialog(_connection: int=None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test multi-pane choose dialog.')

    def _on_submit(choices_made: Dict[int, Any], outcome: CommonChoiceOutcome) -> None:
        output('On Submit choices_made: {} and outcome: {}'.format(pformat(choices_made), pformat(outcome)))

    def _on_sub_dialog_one_chosen(choice: Any, outcome: CommonChoiceOutcome) -> None:
        output('Sub Dialog one choice made: {} outcome: {}'.format(pformat(choice), pformat(outcome)))

    def _on_sub_dialog_two_chosen(choice: Any, outcome: CommonChoiceOutcome) -> None:
        output('Sub Dialog two choice made: {} outcome: {}'.format(pformat(choice), pformat(outcome)))

    sim_info = CommonSimUtils.get_active_sim_info()

    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
        # Create the dialog.
        dialog = CommonMultiPaneChooseDialog(
            ModInfo.get_identity(),
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            title_tokens=title_tokens,
            description_tokens=description_tokens
        )

        sub_dialog_one_options = [
            ObjectPickerRow(
                option_id=1,
                name=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_SOME_TEXT_FOR_TESTING),
                row_description=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_TEST_BUTTON_ONE),
                row_tooltip=None,
                icon=CommonIconUtils.load_checked_square_icon(),
                tag='Value 1'
            ),
            ObjectPickerRow(
                option_id=2,
                name=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_SOME_TEXT_FOR_TESTING),
                row_description=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_TEST_BUTTON_TWO),
                row_tooltip=None,
                icon=CommonIconUtils.load_arrow_navigate_into_icon(),
                tag='Value 2'
            ),
            ObjectPickerRow(
                option_id=3,
                name=CommonLocalizationUtils.create_localized_string('Value 3'),
                row_description=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_TEST_BUTTON_TWO),
                row_tooltip=None,
                icon=CommonIconUtils.load_arrow_navigate_into_icon(),
                tag='Value 3'
            )
        ]

        # Add sub dialog one.
        sub_dialog_one = CommonChooseObjectDialog(
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            tuple(sub_dialog_one_options),
            title_tokens=title_tokens,
            description_tokens=description_tokens
        )
        dialog.add_sub_dialog(sub_dialog_one, on_chosen=_on_sub_dialog_one_chosen, sim_info=sim_info)

        # Add sub dialog two.
        sub_dialog_two_options = [
            ObjectPickerRow(
                option_id=4,
                name=CommonLocalizationUtils.create_localized_string('Value 4'),
                row_description=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_TEST_BUTTON_ONE),
                row_tooltip=None,
                icon=CommonIconUtils.load_checked_square_icon(),
                tag='Value 4'
            ),
            ObjectPickerRow(
                option_id=5,
                name=CommonLocalizationUtils.create_localized_string('Value 5'),
                row_description=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_TEST_BUTTON_TWO),
                row_tooltip=None,
                icon=CommonIconUtils.load_arrow_navigate_into_icon(),
                tag='Value 5'
            ),
            ObjectPickerRow(
                option_id=6,
                name=CommonLocalizationUtils.create_localized_string('Value 6'),
                row_description=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_TEST_BUTTON_TWO),
                row_tooltip=None,
                icon=CommonIconUtils.load_arrow_navigate_into_icon(),
                tag='Value 6'
            )
        ]

        sub_dialog_two = CommonChooseObjectDialog(
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            tuple(sub_dialog_two_options),
            title_tokens=title_tokens,
            description_tokens=description_tokens
        )

        dialog.add_sub_dialog(sub_dialog_two, on_chosen=_on_sub_dialog_two_chosen, include_pagination=True)

        # Show the dialog.
        dialog.show(on_submit=_on_submit)
    except Exception as ex:
        CommonExceptionHandler.log_exception(ModInfo.get_identity(), 'Failed to show dialog', exception=ex)
        output('Failed to show dialog, please locate your exception log file.')
    output('Done showing.')
def _common_testing_show_choose_button_option_dialog(_connection: int = None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test choose button option dialog.')

    def _on_option_chosen(option_identifier: str, choice: str):
        output('Chose option {} with value: {}.'.format(
            pformat(option_identifier), pformat(choice)))

    def _on_previous_chosen() -> None:
        output('Chose previous option.')

    def _on_close() -> None:
        output('Closed dialog.')

    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), )
        option_dialog = CommonChooseButtonOptionDialog(
            ModInfo.get_identity(),
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
            title_tokens=title_tokens,
            description_tokens=description_tokens,
            on_previous=_on_previous_chosen,
            on_close=_on_close,
            per_page=2)

        option_dialog.add_option(
            CommonDialogButtonOption(
                'Option 1',
                'Value 1',
                CommonDialogResponseOptionContext(
                    CommonStringId.TESTING_SOME_TEXT_FOR_TESTING,
                    subtext_identifier=CommonStringId.TESTING_TEST_BUTTON_ONE),
                on_chosen=_on_option_chosen))

        option_dialog.add_option(
            CommonDialogButtonOption(
                'Option 2',
                'Value 2',
                CommonDialogResponseOptionContext(
                    CommonStringId.TESTING_SOME_TEXT_FOR_TESTING,
                    subtext_identifier=CommonStringId.TESTING_TEST_BUTTON_TWO,
                ),
                on_chosen=_on_option_chosen))

        option_dialog.add_option(
            CommonDialogButtonOption(
                'Option 3',
                'Value 3',
                CommonDialogResponseOptionContext(
                    CommonLocalizationUtils.create_localized_string('Value 3'),
                    subtext_identifier=CommonStringId.TESTING_TEST_BUTTON_TWO),
                on_chosen=_on_option_chosen))

        option_dialog.show(sim_info=CommonSimUtils.get_active_sim_info())
    except Exception as ex:
        CommonExceptionHandler.log_exception(ModInfo.get_identity(),
                                             'Failed to show dialog',
                                             exception=ex)
        output('Failed to show dialog, please locate your exception log file.')
    output('Done showing.')
Exemple #11
0
def _common_testing_show_choose_item_dialog(_connection: int=None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test choose item dialog.')

    def _item_chosen(chosen_item: str, result: CommonChooseItemResult):
        output('Item chosen {} with result: {}.'.format(pformat(chosen_item), pformat(result)))

    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
        options = [ObjectPickerRow(option_id=1, name=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_SOME_TEXT_FOR_TESTING),
                                   row_description=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_TEST_BUTTON_ONE),
                                   row_tooltip=None,
                                   icon=CommonIconUtils.load_checked_square_icon(),
                                   tag='Value 1'),
                   ObjectPickerRow(option_id=2, name=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_SOME_TEXT_FOR_TESTING),
                                   row_description=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_TEST_BUTTON_TWO),
                                   row_tooltip=None,
                                   icon=CommonIconUtils.load_arrow_navigate_into_icon(),
                                   tag='Value 2')]
        dialog = CommonChooseItemDialog(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_item_chosen=_item_chosen)
    except Exception as ex:
        log.format_error_with_message('Failed to show dialog', exception=ex)
        output('Failed to show dialog, please locate your exception log file.')
    output('Done showing.')
Exemple #12
0
def _common_testing_show_ok_cancel_dialog(_connection: int=None):
    output = sims4.commands.CheatOutput(_connection)
    output('Showing test ok cancel dialog.')

    def _ok_chosen(_: UiDialogOkCancel):
        output('Ok option chosen.')

    def _cancel_chosen(_: UiDialogOkCancel):
        output('Cancel option chosen.')

    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),)
        dialog = CommonOkCancelDialog(CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
                                      CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
                                      title_tokens=title_tokens,
                                      description_tokens=description_tokens,
                                      ok_text_identifier=CommonLocalizationUtils.create_localized_string(CommonStringId.TESTING_TEST_BUTTON_ONE, text_color=CommonLocalizedStringColor.RED),
                                      cancel_text_identifier=CommonStringId.TESTING_TEST_BUTTON_TWO)
        dialog.show(on_ok_selected=_ok_chosen, on_cancel_selected=_cancel_chosen)
    except Exception as ex:
        log.format_error_with_message('Failed to show ok cancel dialog', exception=ex)
        output('Failed to show ok cancel dialog, please locate your exception log file.')
    output('Done showing.')
Exemple #13
0
 def _create_dialog(self) -> Union[UiDialogOkCancel, None]:
     return UiDialogOkCancel.TunableFactory().default(CommonSimUtils.get_active_sim_info(),
                                                      text=lambda *_, **__: self.description,
                                                      title=lambda *_, **__: self.title,
                                                      text_ok=lambda *_, **__: self.ok_text,
                                                      text_cancel=lambda *_, **__: self.cancel_text)