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.')
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.')
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.')
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.')
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 icon(self) -> Any: if super().icon is not None: return super().icon if self.value is True: return CommonIconUtils.load_checked_square_icon() return CommonIconUtils.load_unchecked_square_icon()
def _settings_human(self, on_close: Callable[[], Any] = None) -> None: def _on_close() -> None: if on_close is not None: on_close() def _reopen(): self._settings_human(on_close=on_close) option_dialog = CommonChooseObjectOptionDialog( CommonStringId.CUSTOM_GENDER_SETTINGS, CGSStringId.CGS_CUSTOM_GENDER_SETTINGS_DESCRIPTION, mod_identity=self.mod_identity, on_close=_on_close) option_dialog.add_option( CommonDialogActionOption( CommonDialogOptionContext( CGSStringId.GLOBAL_SETTINGS_NAME, CGSStringId.GLOBAL_SETTINGS_DESCRIPTION), on_chosen=CGSGlobalSettingsDialog(self._sim_info, on_close=_reopen).open)) def _set_to_vanilla_gender_chosen(): if CommonGenderUtils.is_male(self._sim_info): CommonSimGenderOptionUtils.update_gender_options_to_vanilla_male( self._sim_info) else: CommonSimGenderOptionUtils.update_gender_options_to_vanilla_female( self._sim_info) _reopen() option_dialog.add_option( CommonDialogActionOption(CommonDialogOptionContext( CGSStringId.CGS_SET_TO_VANILLA_GENDER_OPTIONS_NAME, CGSStringId.CGS_SET_TO_VANILLA_GENDER_OPTIONS_DESCRIPTION, icon=CommonIconUtils.load_arrow_right_icon()), on_chosen=_set_to_vanilla_gender_chosen)) def _on_gender_chosen(): CommonGenderUtils.swap_gender(self._sim_info, update_gender_options=False) _reopen() current_gender_string = CGSStringId.MALE if CommonGenderUtils.is_female(self._sim_info): current_gender_string = CGSStringId.FEMALE option_dialog.add_option( CommonDialogActionOption(CommonDialogOptionContext( CGSStringId.CGS_SWAP_GENDER_NAME, CGSStringId.CGS_SWAP_GENDER_DESCRIPTION, title_tokens=(current_gender_string, ), icon=CommonIconUtils.load_arrow_right_icon()), on_chosen=_on_gender_chosen)) def _on_physical_frame_chosen(): value = not CommonSimGenderOptionUtils.has_masculine_frame( self._sim_info) CommonSimGenderOptionUtils.update_body_frame(self._sim_info, value) _reopen() current_body_frame = CommonStringId.FEMININE if CommonSimGenderOptionUtils.has_masculine_frame(self._sim_info): current_body_frame = CommonStringId.MASCULINE option_dialog.add_option( CommonDialogActionOption(CommonDialogOptionContext( CommonStringId.PHYSICAL_FRAME, CGSStringId.CGS_CURRENT, description_tokens=(current_body_frame, ), icon=CommonIconUtils.load_arrow_right_icon()), on_chosen=_on_physical_frame_chosen)) current_clothing = CommonStringId.FEMININE if CommonSimGenderOptionUtils.prefers_menswear(self._sim_info): current_clothing = CommonStringId.MASCULINE def _on_clothing_preference_chosen(): value = not CommonSimGenderOptionUtils.prefers_menswear( self._sim_info) CommonSimGenderOptionUtils.update_clothing_preference( self._sim_info, value) _reopen() option_dialog.add_option( CommonDialogActionOption(CommonDialogOptionContext( CommonStringId.CLOTHING_PREFERENCE, CGSStringId.CGS_CURRENT, description_tokens=(current_clothing, ), icon=CommonIconUtils.load_arrow_right_icon()), on_chosen=_on_clothing_preference_chosen)) def _on_toggle_breasts_chosen(option_identifier: str, has_breasts: bool): self.log.format(option_identifier=option_identifier, has_breasts=has_breasts) def _on_acknowledged(_): _reopen() CommonSimGenderOptionUtils.update_has_breasts( self._sim_info, has_breasts) CommonOkDialog( CGSStringId.CGS_SETTING_SAVE_RELOAD_ALERT_NAME, CGSStringId.CGS_SETTING_SAVE_RELOAD_ALERT_DESCRIPTION).show( on_acknowledged=_on_acknowledged) has_vanilla_breasts = False if CommonGenderUtils.is_female(self._sim_info): has_vanilla_breasts = not CommonTraitUtils.has_trait( self._sim_info, CommonTraitId.BREASTS_FORCE_OFF) option_dialog.add_option( CommonDialogToggleOption( 'ToggleBreasts', CommonTraitUtils.has_trait(self._sim_info, CommonTraitId.BREASTS_FORCE_ON) or has_vanilla_breasts, CommonDialogOptionContext( CGSStringId.CGS_TOGGLE_BREASTS_NAME, CGSStringId.CGS_TOGGLE_BREASTS_DESCRIPTION), on_chosen=_on_toggle_breasts_chosen)) option_dialog.add_option( CommonDialogActionOption(CommonDialogOptionContext( CGSStringId.CGS_PREGNANCY_OPTIONS_NAME, CGSStringId.CGS_PREGNANCY_OPTIONS_DESCRIPTION, icon=CommonIconUtils.load_arrow_navigate_into_icon()), on_chosen=lambda *_, **__: self. _pregnancy_options(on_close=_reopen))) title = CGSStringId.CGS_TOGGLE_CAN_USE_TOILET_STANDING_NAME if CommonSimGenderOptionUtils.uses_toilet_standing(self._sim_info): title = CommonLocalizationUtils.create_localized_string( title, text_color=CommonLocalizedStringColor.GREEN) icon = CommonIconUtils.load_checked_square_icon() else: icon = CommonIconUtils.load_unchecked_square_icon() text = CGSStringId.CGS_TOGGLE_CAN_USE_TOILET_STANDING_DESCRIPTION def _on_toilet_usage_chosen(): value = not CommonSimGenderOptionUtils.uses_toilet_standing( self._sim_info) CommonSimGenderOptionUtils.update_toilet_usage( self._sim_info, value) _reopen() option_dialog.add_option( CommonDialogActionOption(CommonDialogOptionContext(title, text, icon=icon), on_chosen=_on_toilet_usage_chosen)) option_dialog.show(sim_info=self._sim_info)