Premade Dialogs¶
Premade Choose Sim Demographic Types Dialog¶
- class CommonChooseSimDemographicTypesDialog(on_close, available_values=None, exclude_values=None)¶
Bases:
_HasS4CLLogOpen a dialog that prompts the player to choose from Sim Demographic Types.
- Parameters:
on_close (Callable[[], None]) – A callback invoked upon the dialog closing.
available_values (Iterator[CommonSimDemographicType], optional) – The available values shown in the dialog. Default is all Values.
exclude_values (Iterator[CommonSimDemographicType], optional) – The demographics to not display in the dialog. Default is all Values will be available.
- create_dialog_option(option_id, title, description, current_values, on_chosen)¶
Create a dialog option.
- property log_identifier¶
A string identifier for the log used by instances of the class.
Note
This is the message identifier that will appear when logging messages.
- Returns:
The identifier of the log
- Return type:
str
- open(title, description, current_selections, on_submit, include_all_choice=True, include_none_choice=True, reopen_on_submit=True)¶
Open the dialog.
- Parameters:
title (Union[int, CommonStringId, LocalizedString]) – The title to show at the top of the dialog.
description (Union[int, CommonStringId, LocalizedString]) – The description to show at the top of the dialog.
current_selections (Tuple[CommonSimDemographicType]) – The currently selected options in the dialog.
on_submit (Callable[[Tuple[CommonSimDemographicType]], None]) – A callback invoked upon submitting the dialog.
include_all_choice (bool, optional) – If True, the “All Sims” choice will be shown to players. If False, the “All Sims” choice will not be shown. Default is True.
include_none_choice (bool, optional) – If True, the “No Sims” choice will be shown to players. If False, the “No Sims” choice will not be shown. Default is True.
reopen_on_submit (bool, optional) – If True, the dialog will reopen on submit. If False, the dialog will not reopen on submit. Default is True.
- Return type:
None
Premade Choose Sim Option Dialog¶
- class CommonPremadeChooseSimOptionDialog(title_identifier, description_identifier, title_tokens=(), description_tokens=(), on_close=<function CommonFunctionUtils.noop>, mod_identity=None, include_sim_callback=None, instanced_sims_only=True, on_sim_chosen=<function CommonFunctionUtils.noop>)¶
Bases:
CommonChooseSimOptionDialogA 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_dialogin 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 iterator of Tokens to format into the title.
description_tokens (Iterator[Any], optional) – An iterator of Tokens to format into the description.
on_close (Callable[[], None], optional) – A callback invoked upon the dialog closing.
mod_identity (CommonModIdentity, optional) – The identity of the mod creating the dialog. See
CommonModIdentityfor 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().
- property log_identifier¶
A string identifier for the log used by instances of the class.
Note
This is the message identifier 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=<function CommonFunctionUtils.noop>, mod_identity=None, include_sim_callback=None, instanced_sims_only=True)¶
Bases:
CommonChooseSimsOptionDialogA 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_dialogin 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 iterator of Tokens to format into the title.
description_tokens (Iterator[Any], optional) – An iterator of Tokens to format into the description.
on_close (Callable[[], None], optional) – A callback invoked upon the dialog closing.
mod_identity (CommonModIdentity, optional) – The identity of the mod creating the dialog. See
CommonModIdentityfor 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.
- property log_identifier¶
A string identifier for the log used by instances of the class.
Note
This is the message identifier that will appear when logging messages.
- Returns:
The identifier of the log
- Return type:
str