Premade Dialogs

Premade Choose Sim Option Dialog

class CommonPremadeChooseSimOptionDialog(title_identifier, description_identifier, title_tokens=(), description_tokens=(), on_close=CommonFunctionUtils.noop, mod_identity=None, include_sim_callback=None, instanced_sims_only=True, on_sim_chosen=CommonFunctionUtils.noop)

Bases: sims4communitylib.dialogs.option_dialogs.common_choose_sim_option_dialog.CommonChooseSimOptionDialog

A premade dialog that will display a list of Sims based on a filter and will prompt the player to choose a single Sim.

Note

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

Example usage:
def _on_chosen(_sim_info: SimInfo):
    pass

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

# Create the dialog that will only show adult Sims in the current area.
option_dialog = CommonPremadeChooseSimOptionDialog(
    CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
    CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
    title_tokens=title_tokens,
    description_tokens=description_tokens,
    mod_identity=ModInfo.get_identity(),
    include_sim_callback=CommonAgeUtils.is_adult,
    instanced_sims_only=True,
    on_sim_chosen=_on_chosen
)

option_dialog.show(
    sim_info=CommonSimUtils.get_active_sim_info(),
    column_count=4
)
Parameters:
  • title_identifier (Union[int, str, LocalizedString, CommonStringId]) – A decimal identifier of the title text.
  • description_identifier (Union[int, str, LocalizedString, CommonStringId]) – A decimal identifier of the description text.
  • title_tokens (Iterator[Any], optional) – An iterable of Tokens to format into the title.
  • description_tokens (Iterator[Any], optional) – An iterable of Tokens to format into the description.
  • on_close (Callable[.., Any], optional) – A callback invoked upon the dialog closing.
  • mod_identity (CommonModIdentity, optional) – The identity of the mod creating the dialog. See CommonModIdentity for more information.
  • include_sim_callback (Callable[[SimInfo], bool], optional) – If the result of this callback is True, the sim will be included in the results. If set to None, All sims will be included.
  • instanced_sims_only (bool, optional) – If True, only Sims that are currently spawned will be shown. If False, all Sims will be shown. Default is True.
  • on_sim_chosen (Callable[[SimInfo], Any], optional) – Called upon a Sim being chosen. Default is noop().
log_identifier

A string identifier for the log used by instances of the class.

Note

This is the text that will appear when logging messages.

Returns:The identifier of the log
Return type:str

Premade Choose Sims Option Dialog

class CommonPremadeChooseSimsOptionDialog(title_identifier, description_identifier, title_tokens=(), description_tokens=(), on_close=CommonFunctionUtils.noop, mod_identity=None, include_sim_callback=None, instanced_sims_only=True)

Bases: sims4communitylib.dialogs.option_dialogs.common_choose_sims_option_dialog.CommonChooseSimsOptionDialog

A premade dialog that will display a list of Sims based on a filter and will prompt the player to choose one or more Sims.

Note

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

Example usage:
def _on_submit(_chosen_sim_info_list: Tuple[SimInfo]):
    pass

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

# Create the dialog that will only show adult (include_sim_callback=CommonAgeUtils.is_adult) Sims in the current area (instanced_sims_only=True).
option_dialog = CommonPremadeChooseSimsOptionDialog(
    CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
    CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN,
    title_tokens=title_tokens,
    description_tokens=description_tokens,
    mod_identity=ModInfo.get_identity(),
    include_sim_callback=CommonAgeUtils.is_adult,
    instanced_sims_only=True
)

option_dialog.show(
    sim_info=CommonSimUtils.get_active_sim_info(),
    column_count=4,
    max_selectable=5,
    on_submit=_on_submit
)
Parameters:
  • title_identifier (Union[int, str, LocalizedString, CommonStringId]) – A decimal identifier of the title text.
  • description_identifier (Union[int, str, LocalizedString, CommonStringId]) – A decimal identifier of the description text.
  • title_tokens (Iterator[Any], optional) – An iterable of Tokens to format into the title.
  • description_tokens (Iterator[Any], optional) – An iterable of Tokens to format into the description.
  • on_close (Callable[.., Any], optional) – A callback invoked upon the dialog closing.
  • mod_identity (CommonModIdentity, optional) – The identity of the mod creating the dialog. See CommonModIdentity for more information.
  • include_sim_callback (Callable[[SimInfo], bool], optional) – If the result of this callback is True, the sim will be included in the results. If set to None, All sims will be included.
  • instanced_sims_only (bool, optional) – If True, only Sims that are currently spawned will be shown. If False, all Sims will be shown. Default is True.
log_identifier

A string identifier for the log used by instances of the class.

Note

This is the text that will appear when logging messages.

Returns:The identifier of the log
Return type:str