def _CreateArguments(self, setting: UISettingsShared.SettingWrapper, currentValue: typing.Any, showDialogArguments: typing.Dict[str, typing.Any], *args, **kwargs) -> typing.Dict[str, typing.Any]: dialogArguments = dict() dialogOwner = showDialogArguments.get("owner") dialogButtons = kwargs[ "dialogButtons"] # type: typing.List[DialogButton] dialogResponses = list( ) # type: typing.List[ui_dialog.UiDialogResponse] for dialogButton in dialogButtons: # type: DialogButton dialogResponses.append(dialogButton.GenerateDialogResponse()) textString = self._GetDescriptionText( setting) # type: localization.LocalizedString dialogArguments["owner"] = dialogOwner dialogArguments["title"] = Language.MakeLocalizationStringCallable( self._GetTitleText(setting)) dialogArguments["text"] = Language.MakeLocalizationStringCallable( textString) dialogArguments["text_ok"] = Language.MakeLocalizationStringCallable( self._GetAcceptButtonText()) dialogArguments["ui_responses"] = dialogResponses return dialogArguments
def ResetAllButtonCallback( listDialogReference: ui_dialog.UiDialog) -> None: def ResetAllConfirmDialogCallback( confirmDialogReference: ui_dialog.UiDialog) -> None: if confirmDialogReference.response == ui_dialog.ButtonType.DIALOG_RESPONSE_OK: self.SettingsSystem.ResetAll() self.ShowDialog(listPath, returnCallback=returnCallback, **showDialogArguments) confirmDialogArguments = { "title": Language.MakeLocalizationStringCallable( self._GetResetAllConfirmDialogTitleText()), "text": Language.MakeLocalizationStringCallable( self._GetResetAllConfirmDialogDescriptionText()), "text_ok": Language.MakeLocalizationStringCallable( self._GetResetAllConfirmDialogYesButtonText()), "text_cancel": Language.MakeLocalizationStringCallable( self._GetResetAllConfirmDialogNoButtonText()) } Dialogs.ShowOkCancelDialog(callback=ResetAllConfirmDialogCallback, queue=False, **confirmDialogArguments)
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 _ShowDeleteSetConfirmDialog( self, editingSetTitle: str, setting: UISettingsShared.SettingWrapper, currentValue: typing.Any, showDialogArguments: typing.Dict[str, typing.Any], returnCallback: typing.Callable[[], None] = None, *args, **kwargs) -> None: editingPronounSetIdentifier = showDialogArguments[ "editingPronounSetIdentifier"] # type: str def deleteSetConfirmDialog( shownDeleteSetConfirmDialog: ui_dialog_generic. UiDialogTextInputOkCancel ) -> None: if shownDeleteSetConfirmDialog.accepted: currentValue.pop(editingPronounSetIdentifier, None) setting.Set(currentValue) if returnCallback is not None: returnCallback() else: self._ShowDialogInternal( setting, currentValue, showDialogArguments=showDialogArguments, returnCallback=returnCallback, *args, **kwargs) dialogArguments = { "title": Language.MakeLocalizationStringCallable( self._GetDeleteSetConfirmDialogTitle()), "text": Language.MakeLocalizationStringCallable( self._GetDeleteSetConfirmDialogText(editingSetTitle)), "text_ok": Language.MakeLocalizationStringCallable( self._GetDeleteSetConfirmDialogOkButton()), "text_cancel": Language.MakeLocalizationStringCallable( self._GetDeleteSetConfirmDialogCancelButton()), } UIDialogs.ShowOkCancelDialog(callback=deleteSetConfirmDialog, queue=False, **dialogArguments)
def _CreateArguments(self, listPath: str, showDialogArguments: typing.Dict[str, typing.Any], *args, **kwargs) -> typing.Dict[str, typing.Any]: dialogArguments = dict() dialogOwner = showDialogArguments.get("owner") dialogArguments["owner"] = dialogOwner dialogArguments["title"] = Language.MakeLocalizationStringCallable( self._GetTitleText(listPath)) dialogArguments["text"] = Language.MakeLocalizationStringCallable( self._GetDescriptionText(listPath)) return dialogArguments
def ShowStatusNotification (targetSimInfo: sim_info.SimInfo) -> None: # TODO create quick glance notification, only show the times? if not isinstance(targetSimInfo, sim_info.SimInfo): raise Exceptions.IncorrectTypeException(targetSimInfo, "targetSimInfo", (sim_info.SimInfo,)) targetDotInformation = Dot.GetDotInformation(targetSimInfo) # type: typing.Optional[Dot.DotInformation] if targetDotInformation is None: Debug.Log("Attempted to show a dot app status notification on a sim missing a dot information object.\nSim ID: %s" % targetSimInfo.id, This.Mod.Namespace, Debug.LogLevels.Warning, group = This.Mod.Namespace, owner = __name__) return if not targetDotInformation.Enabled: Debug.Log("Attempted to show a dot app status notification on a sim its not enabled for.\nSim ID: %s" % targetSimInfo.id, This.Mod.Namespace, Debug.LogLevels.Warning, group = This.Mod.Namespace, owner = __name__) return dotCycle = targetDotInformation.GetCurrentCycle() # type: typing.Optional[Dot.DotCycle] if dotCycle is None: ShowErrorNotification(targetSimInfo) return text = Language.MakeLocalizationStringCallable(_BuildStatusText(targetSimInfo, dotCycle)) notificationArguments = { "owner": targetSimInfo, "title": StatusNotificationTitle.GetCallableLocalizationString(), "text": text, "icon": lambda *args, **kwargs: shared_messages.IconInfoData(icon_resource = resources.ResourceKeyWrapper(CycleUIResources.DotAppIconKey)), "secondary_icon": lambda *args, **kwargs: shared_messages.IconInfoData(obj_instance = targetSimInfo), } Notifications.ShowNotification(queue = False, **notificationArguments)
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 _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 _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)