Custom Notifications

Basic Notification

class CommonBasicNotification(title_identifier, description_identifier, title_tokens=(), description_tokens=(), urgency=UiDialogNotification.UiDialogNotificationUrgency.DEFAULT, information_level=UiDialogNotification.UiDialogNotificationLevel.SIM, expand_behavior=UiDialogNotification.UiDialogNotificationExpandBehavior.USER_SETTING, visual_type=UiDialogNotification.UiDialogNotificationVisualType.INFORMATION, ui_responses=())

Bases: object

A basic notification.

Note

Notifications are the messages that appear at the top right in-game.

Note

To see an example dialog, run the command s4clib_testing.show_basic_notification in the in-game console.

Example usage:
# Will display a test dialog.
def _common_testing_show_basic_notification():
    # LocalizedStrings within other LocalizedStrings
    title_tokens = (
        CommonLocalizationUtils.create_localized_string(
            CommonStringId.TESTING_SOME_TEXT_FOR_TESTING,
            text_color=CommonLocalizedStringColor.BLUE
        ),
    )
    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 = CommonBasicNotification(
        CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
        CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
        title_tokens=title_tokens,
        description_tokens=description_tokens,
        urgency=UiDialogNotification.UiDialogNotificationUrgency.URGENT
    )
    dialog.show()
Parameters:
  • title_identifier (Union[int, str, LocalizedString, CommonStringId]) – The title to display in the dialog.
  • description_identifier (Union[int, str, LocalizedString, CommonStringId]) – The description to display in the dialog.
  • title_tokens (Iterator[Any], optional) – Tokens to format into the title.
  • description_tokens (Iterator[Any], optional) – Tokens to format into the description.
  • urgency (UiDialogNotification.UiDialogNotificationUrgency, optional) – The urgency to which the notification will appear. (URGENT makes it orange) Default is Default (Blue).
  • information_level (UiDialogNotification.UiDialogNotificationLevel, optional) – The information level of the notification. Default is Sim.
  • expand_behavior (UiDialogNotification.UiDialogNotificationExpandBehavior, optional) – Specify how the notification will expand. Default is User Setting.
  • visual_type (UiDialogNotification.UiDialogNotificationVisualType, optional) – How the notification should appear. Default is Information
  • ui_responses (Tuple[UiDialogResponse], optional) – A collection of UI Responses that may be performed within the notification.
show(icon=None, secondary_icon=None)

Show the notification to the player.

Parameters:
  • icon (IconInfoData, optional) – The first icon that will display in the notification.
  • secondary_icon (IconInfoData, optional) – The second icon that will display in the notification.