def ShowReproductiveInfoNotifications(targetSimInfo: sim_info.SimInfo) -> None: if not isinstance(targetSimInfo, sim_info.SimInfo): raise Exceptions.IncorrectTypeException(targetSimInfo, "targetSimInfo", (sim_info.SimInfo, )) targetSimSystem = Reproduction.GetSimSystem( targetSimInfo ) # type: typing.Optional[ReproductionShared.ReproductiveSystem] if targetSimSystem is None: return notificationText = targetSimSystem.GetDebugNotificationString() notificationArguments = { "title": Language.MakeLocalizationStringCallable( Language.CreateLocalizationString("")), "text": Language.MakeLocalizationStringCallable( Language.CreateLocalizationString(notificationText)), } Notifications.ShowNotification(queue=False, **notificationArguments) Debug.Log( "Collected and reported debug info from a sim's reproductive system by request.\n\n%s" % notificationText, This.Mod.Namespace, Debug.LogLevels.Info, group=This.Mod.Namespace, owner=__name__)
def GetValueText( cls, value: typing.Union[float, int]) -> localization.LocalizedString: cls._TypeCheckValue(value) valueString = str(value) # type: str return Language.CreateLocalizationString(valueString)
def GetValueText(cls, value: str) -> localization.LocalizedString: if value == "": return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Settings.Types.Pronoun_Fallback.Default", fallbackText = "Pronoun_Fallback.Default") elif value == "0": return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Settings.Types.Pronoun_Fallback.Female", fallbackText = "Pronoun_Fallback.Female") elif value == "1": return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Settings.Types.Pronoun_Fallback.Male", fallbackText = "Pronoun_Fallback.Male") return Language.CreateLocalizationString("")
def GetValueText(cls, value: str) -> localization.LocalizedString: if value == "": return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Settings.Types.Pronoun_Set_Selection.Default", fallbackText = "Pronoun_Set_Selection.Default") elif value == "0": return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Settings.Types.Pronoun_Set_Selection.Female", fallbackText = "Pronoun_Set_Selection.Female") elif value == "1": return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Settings.Types.Pronoun_Set_Selection.Male", fallbackText = "Pronoun_Set_Selection.Male") currentLanguageHandler = LanguageHandlers.GetCurrentLanguageHandler() # type: typing.Optional[LanguageHandlers.LanguageHandlerBase] allPronounSets = PronounSets.GetAllPronounSets(currentLanguageHandler) # type: dict selectedPronounSet = allPronounSets.get(value, None) # type: dict if selectedPronounSet is None: return Language.CreateLocalizationString("") selectedPronounSetTitle = selectedPronounSet.get("Title", None) # type: str if selectedPronounSetTitle is None: return Language.CreateLocalizationString("") return Language.CreateLocalizationString(selectedPronounSetTitle)
def _CreateArguments(self, setting: UISettingsShared.SettingWrapper, currentValue: typing.Any, showDialogArguments: typing.Dict[str, typing.Any], *args, **kwargs) -> typing.Dict[str, typing.Any]: dialogArguments = super()._CreateArguments( setting, currentValue, showDialogArguments, *args, **kwargs) # type: typing.Dict[str, typing.Any] textInputKey = "Input" # type: str textInputLockedArguments = { "sort_order": 0, } textInput = ui_text_input.UiTextInput.TunableFactory( locked_args=textInputLockedArguments ).default # type: ui_text_input.UiTextInput if "currentInput" in kwargs: textInputInitialValue = Language.MakeLocalizationStringCallable( Language.CreateLocalizationString(kwargs["currentInput"])) else: textInputInitialValue = Language.MakeLocalizationStringCallable( Language.CreateLocalizationString( self._ValueToString(currentValue))) textInput.initial_value = textInputInitialValue textInput.restricted_characters = self._GetInputRestriction(setting) textInputs = collections.make_immutable_slots_class([textInputKey]) textInputs = textInputs({textInputKey: textInput}) dialogArguments["text_inputs"] = textInputs return dialogArguments
def BuildText( parts: typing.List[typing.Union[localization.LocalizedString, str, int, float]] ) -> localization.LocalizedString: """ Create new The Sims 4 localized strings by combining any localized string, string, int, or float together. :param parts: Parts to combined together to create the new localized string. :type parts: typing.List[typing.Union[localization.LocalizedString, str, int, float]] """ if not isinstance(parts, list): raise Exceptions.IncorrectTypeException(parts, "parts", (list, )) for partIndex in range(len(parts)): # type: int part = parts[ partIndex] # type: typing.Union[localization.LocalizedString, str, int, float] if not isinstance(part, (localization.LocalizedString, str, int, float)): raise Exceptions.IncorrectTypeException( part, "parts[%s]" % partIndex, (localization.LocalizedString, str, int, float)) if isinstance(part, (int, float)): parts[partIndex] = str(part) if len(parts) == 0: return Language.CreateLocalizationString("") lastString = None # type: typing.Optional[localization.LocalizedString] for part in reversed( parts ): # type: typing.Union[localization.LocalizedString, str, int, float] partString = _GetFormattingText() # type: localization.LocalizedString partStringTokens = (part, ) if lastString is not None: partStringTokens += (lastString, ) Language.AddTokens(partString, *partStringTokens) lastString = partString return lastString
def GetValueText (cls, value: typing.Any) -> localization.LocalizedString: return Language.CreateLocalizationString("**")
def GetDefaultText (cls) -> localization.LocalizedString: return Language.CreateLocalizationString("**")
def _GetDescriptionSettingText( self, setting: UISettingsShared.SettingWrapper ) -> localization.LocalizedString: return Language.CreateLocalizationString("**")
def ShowSelectSaveDialog () -> None: gameSaveSlotID = str(services.get_persistence_service().get_save_slot_proto_buff().slot_id) # type: str gameSaveGUID = str(services.get_persistence_service().get_save_slot_proto_guid()) # type: str dialogArguments = { "owner": services.get_active_sim().sim_info, "title": SelectSaveDialogTitle, "text": SelectSaveDialogText.GetCallableLocalizationString(*(gameSaveSlotID, gameSaveGUID)) } dialogRows = list() options = { } # type: typing.Dict[int, str] loadedSaveDirectoryPath = Save.GetLoadedDirectoryPath() # type: typing.Optional[str] loadedSaveDirectoryPathObject = pathlib.Path(Save.GetLoadedDirectoryPath()) if loadedSaveDirectoryPath is not None else None # type: typing.Optional[pathlib.Path] for saveDirectoryName in os.listdir(Paths.SavesPath): # type: str saveDirectoryPath = os.path.join(Paths.SavesPath, saveDirectoryName) # type: str if os.path.isdir(saveDirectoryPath): saveDirectoryPathObject = pathlib.Path(saveDirectoryPath) # type: pathlib.Path currentOptionID = 50000 + len(options) options[currentOptionID] = saveDirectoryPath saveDirectoryMetaData = Save.GetSaveMetaData(saveDirectoryPath) # type: typing.Optional[Save.ModSaveMetaData] rowDescriptionTokens = (SelectSaveDialogDescriptionMatchUnknown.GetLocalizationString(),) if saveDirectoryMetaData is not None: saveDirectoryMatchType = saveDirectoryMetaData.MatchesGameSave() # type: Save.ModSaveMatchTypes if saveDirectoryMatchType in Save.ModSaveMatchTypes.Match: rowDescriptionTokens = (SelectSaveDialogDescriptionMatchMatches.GetLocalizationString(),) elif saveDirectoryMatchType in Save.ModSaveMatchTypes.MismatchedGUID: rowDescriptionTokens = (SelectSaveDialogDescriptionMatchMismatchGUID.GetLocalizationString(),) elif saveDirectoryMatchType in Save.ModSaveMatchTypes.MismatchedGameTick: rowDescriptionTokens = (SelectSaveDialogDescriptionMatchMismatchGameTick.GetLocalizationString(),) if loadedSaveDirectoryPathObject is not None: if loadedSaveDirectoryPathObject == saveDirectoryPathObject: rowDescription = SelectSaveDialogDescriptionCurrentlyLoaded.GetLocalizationString(*rowDescriptionTokens) else: rowDescription = SelectSaveDialogDescriptionNormal.GetLocalizationString(*rowDescriptionTokens) else: rowDescription = SelectSaveDialogDescriptionNormal.GetLocalizationString(*rowDescriptionTokens) if saveDirectoryMetaData is None: rowNameTokens = (saveDirectoryName,) else: rowNameTokens = (saveDirectoryName + " (" + saveDirectoryMetaData.Name + ")",) dialogRows.append(ui_dialog_picker.ObjectPickerRow( option_id = currentOptionID, name = Language.CreateLocalizationString(*rowNameTokens), row_description = rowDescription)) def DialogCallback (dialogReference: ui_dialog_picker.UiObjectPicker) -> None: try: if dialogReference.response == ui_dialog.ButtonType.DIALOG_RESPONSE_CANCEL: return resultRows = dialogReference.picked_results # type: typing.Tuple[int] if len(resultRows) == 0: return selectedSaveDirectory = options.get(resultRows[0]) # type: typing.Optional[str] if selectedSaveDirectory is None: return Save.Load(services.get_persistence_service().get_save_slot_proto_buff().slot_id, selectedSaveDirectory, changingSave = True) except Exception as e: Debug.Log("Failed to run the callback for the select save dialog.", This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, exception = e) Dialogs.ShowObjectPickerDialog(DialogCallback, dialogRows, **dialogArguments)
def _GetRowListPathDescriptionText( self, listPath: str) -> localization.LocalizedString: return Language.CreateLocalizationString("")
def _GetTitleListPathText(self, listPath: str) -> localization.LocalizedString: return Language.CreateLocalizationString( listPath.rsplit(self.ListPathSeparator, 1)[-1])
def GetValueText (cls, value: dict) -> localization.LocalizedString: if not isinstance(value, dict): raise Exceptions.IncorrectTypeException(value, "value", (dict,)) return Language.CreateLocalizationString("")
def _CreateRows(self, setting: UISettingsShared.SettingWrapper, currentValue: typing.Any, showDialogArguments: typing.Dict[str, typing.Any], returnCallback: typing.Callable[[], None] = None, *args, **kwargs) -> typing.List[UISettings.DialogRow]: rows = super()._CreateRows( setting, currentValue, showDialogArguments, returnCallback=returnCallback, *args, **kwargs) # type: typing.List[UISettings.DialogRow] currentLanguageHandler = LanguageHandlers.GetCurrentLanguageHandler( ) # type: LanguageHandlers.LanguageHandlerBase editingPronounSetIdentifier = showDialogArguments[ "editingPronounSetIdentifier"] # type: str editingPronounSetContainer = currentValue.get( editingPronounSetIdentifier, None) if editingPronounSetContainer is None: editingPronounSet = dict() editingPronounSetContainer = { "Title": "New Pronoun Set", "Set": editingPronounSet } currentValue[ editingPronounSetIdentifier] = editingPronounSetContainer else: editingPronounSet = editingPronounSetContainer.get("Set", None) if editingPronounSet is None: editingPronounSet = dict() editingPronounSetContainer["Set"] = editingPronounSet editingPronounSetTitle = editingPronounSetContainer[ "Title"] # type: str def createDeleteSetCallback() -> typing.Callable: # noinspection PyUnusedLocal def deleteSetCallback(dialog: ui_dialog.UiDialog) -> None: try: self._ShowDeleteSetConfirmDialog( editingPronounSetTitle, setting, currentValue, showDialogArguments, returnCallback=returnCallback, *args, **kwargs) except: Debug.Log("Failed to run the delete set row callback.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__) return deleteSetCallback def createEditTitleCallback() -> typing.Callable: # noinspection PyUnusedLocal def editTitleCallback(dialog: ui_dialog.UiDialog) -> None: try: self._ShowEditTitleDialog( editingPronounSetContainer, setting, currentValue, showDialogArguments=showDialogArguments, returnCallback=returnCallback) except: Debug.Log("Failed to run the edit title row callback.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__) return editTitleCallback # noinspection PyUnusedLocal def createEditPairCallback( editingPairIdentifier: str) -> typing.Callable: # noinspection PyUnusedLocal def editPairCallback(dialog: ui_dialog.UiDialog) -> None: try: editingPairValue = editingPronounSet.get( editingPairIdentifier, "") if not isinstance(editingPairValue, str): editingPairValue = "" self._ShowEditPairDialog( editingPronounSet, editingPairIdentifier, editingPairValue, setting, currentValue, showDialogArguments=showDialogArguments, returnCallback=returnCallback) except: Debug.Log("Failed to run the edit pair row callback.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__) return editPairCallback deleteSetRow = UISettings.DialogRow( 4, createDeleteSetCallback(), self._GetDeleteSetRowText(), description=self._GetDeleteSetRowDescription(), icon=self._GetDeleteSetRowIcon()) rows.append(deleteSetRow) editTitleRow = UISettings.DialogRow( 5, createEditTitleCallback(), self._GetEditTitleDialogTitle(), description=Language.CreateLocalizationString( editingPronounSetTitle), icon=self._GetEditTitleRowIcon(), ) rows.append(editTitleRow) currentGenderTagPairOptionID = 100 # type: int for editablePairIdentifier in currentLanguageHandler.GetCustomPronounSetEditableGenderTagPairs( ): # type: str editablePairParts = editablePairIdentifier.split( "|") # type: typing.List[str] if len(editablePairParts) != 2: continue editablePairRowText = editablePairParts[0].capitalize( ) + " / " + editablePairParts[1].capitalize() # type: str editablePairValue = editingPronounSet.get(editablePairIdentifier, "") if isinstance(editablePairValue, str): editablePairRowDescription = Language.CreateLocalizationString( editablePairValue.capitalize() ) # type: localization.LocalizedString else: editablePairRowDescription = self._GetEditablePairSpecialAlternativeText( ) # type: localization.LocalizedString editablePairRow = UISettings.DialogRow( currentGenderTagPairOptionID, createEditPairCallback(editablePairIdentifier), Language.CreateLocalizationString(editablePairRowText), description=editablePairRowDescription, icon=self._GetEditablePairRowIcon(), ) currentGenderTagPairOptionID += 1 rows.append(editablePairRow) return rows
def _CreateRows(self, setting: UISettingsShared.SettingWrapper, currentValue: typing.Any, showDialogArguments: typing.Dict[str, typing.Any], returnCallback: typing.Callable[[], None] = None, *args, **kwargs) -> typing.List[UISettings.DialogRow]: rows = super()._CreateRows( setting, currentValue, showDialogArguments, returnCallback=returnCallback, *args, **kwargs) # type: typing.List[UISettings.DialogRow] currentLanguageHandler = LanguageHandlers.GetCurrentLanguageHandler( ) # type: LanguageHandlers.LanguageHandlerBase def generateNewValidSetID() -> str: newSetID = uuid.uuid4() # type: uuid.UUID newSetIDString = str(newSetID) # type: str if not newSetIDString in currentValue: return newSetIDString else: return generateNewValidSetID() def createNewSetCallback() -> typing.Callable: # noinspection PyUnusedLocal def selectionCallback(dialog: ui_dialog.UiDialog) -> None: newSetIDString = generateNewValidSetID() newPronounSetSet = currentLanguageHandler.GetCustomPronounSetStandardValues( ) # type: typing.Dict[str, str] currentValue[newSetIDString] = { "Title": "New Pronoun Set", "Set": newPronounSetSet } setting.Set(currentValue) self._ShowDialogInternal(setting, currentValue, showDialogArguments, returnCallback=returnCallback) return selectionCallback def editSetCallback( editingPronounSetIdentifier: str) -> typing.Callable: # noinspection PyUnusedLocal def editPronounSetCallback() -> None: self.ShowDialog(setting, returnCallback=returnCallback, **showDialogArguments) # noinspection PyUnusedLocal def selectionCallback(dialog: ui_dialog.UiDialog) -> None: if hasattr(setting.Setting, "EditPronounSetDialog"): setting.Setting.EditPronounSetDialog().ShowDialog( setting, editPronounSetCallback, editingPronounSetIdentifier=editingPronounSetIdentifier ) else: Debug.Log( "Cannot edit pronoun set as the custom pronoun set setting has no EditPronounSetDialog attribute.", This.Mod.Namespace, Debug.LogLevels.Warning, group=This.Mod.Namespace, owner=__name__) self._ShowDialogInternal(setting, currentValue, showDialogArguments, returnCallback=returnCallback) return selectionCallback newSetRow = UISettings.DialogRow( 10, createNewSetCallback(), self._GetNewSetRowText(), description=self._GetNewSetRowDescription(), icon=self._GetNewSetRowIcon(), ) rows.append(newSetRow) currentAdditionalSetOptionID = 100 # type: int for pronounSetIdentifier, pronounSet in PronounSets.GetCustomPronounSets( ).items(): pronounSetTitle = pronounSet.get( "Title", None) # type: typing.Optional[str] if pronounSetTitle is None: continue pronounSetRow = UISettings.DialogRow( currentAdditionalSetOptionID, editSetCallback(pronounSetIdentifier), Language.CreateLocalizationString(pronounSetTitle), description=self._GetCustomSetRowDescription(), icon=self._GetCustomSetRowIcon(), ) currentAdditionalSetOptionID += 1 rows.append(pronounSetRow) return rows
def _ShowEditPairDialog(self, editingPronounSet: dict, editingPairIdentifier: str, editingPairCurrentValue: str, setting: UISettingsShared.SettingWrapper, currentValue: typing.Any, showDialogArguments: typing.Dict[str, typing.Any], returnCallback: typing.Callable[[], None] = None, *args, **kwargs) -> None: def editPairDialogCallback( shownEditPairDialog: ui_dialog_generic.UiDialogTextInputOkCancel ) -> None: try: if shownEditPairDialog.accepted: editingPairNextValue = shownEditPairDialog.text_input_responses.get( textInputKey, editingPairCurrentValue) # type: str editingPairNextValue = editingPairNextValue.lower() editingPronounSet[ editingPairIdentifier] = editingPairNextValue # noinspection PyUnusedLocal def askToApplyAndFixCallback(appliedFix: bool) -> None: self._ShowDialogInternal( setting, currentValue, showDialogArguments=showDialogArguments, returnCallback=returnCallback, *args, **kwargs) currentLanguageHandler = LanguageHandlers.GetCurrentLanguageHandler( ) # type: LanguageHandlers.LanguageHandlerBase currentLanguageHandler.AskToApplyAndFixCustomPronounSetPair( editingPronounSet, editingPairIdentifier, editingPairNextValue, askToApplyAndFixCallback) else: self._ShowDialogInternal( setting, currentValue, showDialogArguments=showDialogArguments, returnCallback=returnCallback, *args, **kwargs) except: Debug.Log("Failed to run an edit pair dialog callback.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__) editingPairParts = editingPairIdentifier.split( "|") # type: typing.List[str] if len(editingPairParts) != 2: femaleLanguage = maleLanguage = "" # type: str else: femaleLanguage = editingPairParts[0].capitalize() # type: str maleLanguage = editingPairParts[1].capitalize() # type: str textInputKey = "Input" # type: str textInputLockedArguments = { "sort_order": 0, } textInput = ui_text_input.UiTextInput.TunableFactory( locked_args=textInputLockedArguments ).default # type: ui_text_input.UiTextInput textInputInitialValue = Language.MakeLocalizationStringCallable( Language.CreateLocalizationString( editingPairCurrentValue.capitalize())) textInput.initial_value = textInputInitialValue textInputs = collections.make_immutable_slots_class([textInputKey]) textInputs = textInputs({textInputKey: textInput}) dialogArguments = { "title": Language.MakeLocalizationStringCallable( self._GetEditPairDialogTitle()), "text": Language.MakeLocalizationStringCallable( self._GetEditPairDialogText(femaleLanguage, maleLanguage)), "text_ok": Language.MakeLocalizationStringCallable( self._GetEditPairDialogOkButton()), "text_cancel": Language.MakeLocalizationStringCallable( self._GetEditPairDialogCancelButton()), "text_inputs": textInputs } UIDialogs.ShowOkCancelInputDialog(callback=editPairDialogCallback, queue=False, **dialogArguments)
def _ShowEditTitleDialog(self, editingPronounSetContainer: dict, setting: UISettingsShared.SettingWrapper, currentValue: typing.Any, showDialogArguments: typing.Dict[str, typing.Any], returnCallback: typing.Callable[[], None] = None, *args, **kwargs) -> None: def editPairDialogCallback( shownEditPairDialog: ui_dialog_generic.UiDialogTextInputOkCancel ) -> None: if shownEditPairDialog.accepted: editingSetNextTitle = shownEditPairDialog.text_input_responses.get( textInputKey, editingSetCurrentTitle) # type: str editingPronounSetContainer["Title"] = editingSetNextTitle self._ShowDialogInternal(setting, currentValue, showDialogArguments=showDialogArguments, returnCallback=returnCallback, *args, **kwargs) editingSetCurrentTitle = editingPronounSetContainer.get( "Title", "New Pronoun Set") # type: str textInputKey = "Input" # type: str textInputLockedArguments = { "sort_order": 0, } textInput = ui_text_input.UiTextInput.TunableFactory( locked_args=textInputLockedArguments ).default # type: ui_text_input.UiTextInput textInputInitialValue = Language.MakeLocalizationStringCallable( Language.CreateLocalizationString(editingSetCurrentTitle)) textInput.initial_value = textInputInitialValue textInputs = collections.make_immutable_slots_class([textInputKey]) textInputs = textInputs({textInputKey: textInput}) dialogArguments = { "title": Language.MakeLocalizationStringCallable( self._GetEditTitleDialogTitle()), "text": Language.MakeLocalizationStringCallable( self._GetEditTitleDialogText()), "text_ok": Language.MakeLocalizationStringCallable( self._GetEditTitleDialogOkButton()), "text_cancel": Language.MakeLocalizationStringCallable( self._GetEditTitleDialogCancelButton()), "text_inputs": textInputs } UIDialogs.ShowOkCancelInputDialog(callback=editPairDialogCallback, queue=False, **dialogArguments)
def _ShowSetPregnancyProgressDialog( targetSimHandler: argument_helpers.RequiredTargetParam, _connection=None) -> None: try: if game_services.service_manager is None: return targetSimInfo = targetSimHandler.get_target( services.sim_info_manager()) if not isinstance(targetSimInfo, sim_info.SimInfo): raise ValueError( "Failed to get the target sim, %s is not a valid sim id." % targetSimHandler.target_id) targetSimSystem = Reproduction.GetSimSystem( targetSimInfo ) # type: typing.Optional[ReproductionShared.ReproductiveSystem] if targetSimSystem is None: return targetSimPregnancyTracker = targetSimSystem.GetTracker( FemalesShared.PregnancyTrackerIdentifier ) # type: typing.Optional[PregnancyTracker.PregnancyTracker] currentProgress = round( targetSimPregnancyTracker.GetPregnancyProgress(), 3) # type: float def dialogCallback( dialogReference: ui_dialog_generic.UiDialogTextInputOkCancel): if dialogReference.response == ui_dialog.ButtonType.DIALOG_RESPONSE_OK: nextProgressString = dialogReference.text_input_responses[ "Input"] # type: str try: nextProgress = float(nextProgressString) # type: float except: return if currentProgress != nextProgress: targetSimPregnancyTracker.SetPregnancyProgress( nextProgress) textInputKey = "Input" # type: str textInputLockedArguments = { "sort_order": 0, } textInput = ui_text_input.UiTextInput.TunableFactory( locked_args=textInputLockedArguments ).default # type: ui_text_input.UiTextInput textInputInitialValue = Language.MakeLocalizationStringCallable( Language.CreateLocalizationString(str(currentProgress))) textInput.initial_value = textInputInitialValue textInputs = collections.make_immutable_slots_class([textInputKey]) textInputs = textInputs({textInputKey: textInput}) dialogArguments = { "title": SetPregnancyProgressDialogTitle.GetCallableLocalizationString(), "text": SetPregnancyProgressDialogText.GetCallableLocalizationString(), "text_ok": SetPregnancyProgressDialogOkButton.GetCallableLocalizationString(), "text_cancel": SetPregnancyProgressDialogCancelButton. GetCallableLocalizationString(), "text_inputs": textInputs } Dialogs.ShowOkCancelInputDialog(callback=dialogCallback, queue=False, **dialogArguments) except Exception as e: Debug.Log( "Failed to show the set pregnancy progress dialog for a sim.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__, exception=e) raise e
def _CreateRows(self, setting: UISettingsShared.SettingWrapper, currentValue: typing.Any, showDialogArguments: typing.Dict[str, typing.Any], returnCallback: typing.Callable[[], None] = None, *args, **kwargs) -> typing.List[UISettings.DialogRow]: rows = super()._CreateRows( setting, currentValue, showDialogArguments, returnCallback=returnCallback, *args, **kwargs) # type: typing.List[UISettings.DialogRow] currentLanguageHandler = LanguageHandlers.GetCurrentLanguageHandler( ) # type: typing.Optional[typing.Type[LanguageHandlers.LanguageHandlerBase]] def createSelectionCallback(rowValue: str) -> typing.Callable: # noinspection PyUnusedLocal def selectionCallback(dialog: ui_dialog.UiDialog) -> None: self._ShowDialogInternal(setting, rowValue, showDialogArguments, returnCallback=returnCallback) return selectionCallback defaultSelectionValue = "" # type: str defaultRowSelected = True if currentValue == defaultSelectionValue else False # type: bool defaultRow = UISettings.DialogRow( 10, createSelectionCallback(defaultSelectionValue), self._GetDefaultRowText(), description=self._GetSelectedRowDescription() if defaultRowSelected else self._GetNotSelectedRowDescription(), icon=self._GetSelectedRowIcon() if defaultRowSelected else self._GetNotSelectedRowIcon(), ) femaleSelectionValue = "0" # type: str femaleRowSelected = True if currentValue == femaleSelectionValue else False # type: bool femaleRow = UISettings.DialogRow( 11, createSelectionCallback(femaleSelectionValue), self._GetFemaleRowText(), description=self._GetSelectedRowDescription() if femaleRowSelected else self._GetNotSelectedRowDescription(), icon=self._GetSelectedRowIcon() if femaleRowSelected else self._GetNotSelectedRowIcon(), ) maleSelectionValue = "1" # type: str maleRowSelected = True if currentValue == maleSelectionValue else False # type: bool maleRow = UISettings.DialogRow( 12, createSelectionCallback(maleSelectionValue), self._GetMaleRowText(), description=self._GetSelectedRowDescription() if maleRowSelected else self._GetNotSelectedRowDescription(), icon=self._GetSelectedRowIcon() if maleRowSelected else self._GetNotSelectedRowIcon(), ) rows.append(defaultRow) rows.append(femaleRow) rows.append(maleRow) currentAdditionalSetOptionID = 100 # type: int for pronounSetIdentifier, pronounSet in PronounSets.GetAllPronounSets( currentLanguageHandler).items(): pronounSetTitle = pronounSet.get( "Title", None) # type: typing.Optional[str] if pronounSetTitle is None: continue pronounSetSelected = True if currentValue == pronounSetIdentifier else False # type: bool pronounSetRow = UISettings.DialogRow( currentAdditionalSetOptionID, createSelectionCallback(pronounSetIdentifier), Language.CreateLocalizationString(pronounSetTitle), description=self._GetSelectedRowDescription() if pronounSetSelected else self._GetNotSelectedRowDescription(), icon=self._GetSelectedRowIcon() if pronounSetSelected else self._GetNotSelectedRowIcon(), ) currentAdditionalSetOptionID += 1 rows.append(pronounSetRow) return rows