Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def ShowInvalidInputNotification(inputString: str, modName: str) -> None:
    if services.current_zone() is None:
        Debug.Log("Tried to show setting dialog before a zone was loaded.\n" +
                  str.join("", traceback.format_stack()),
                  This.Mod.Namespace,
                  Debug.LogLevels.Warning,
                  group=This.Mod.Namespace,
                  owner=__name__)
        return

    notificationArguments = {
        "title":
        InvalidInputNotificationTitle.GetCallableLocalizationString(modName),
        "text":
        InvalidInputNotificationText.GetCallableLocalizationString(
            inputString),
        "expand_behavior":
        ui_dialog_notification.UiDialogNotification.
        UiDialogNotificationExpandBehavior.FORCE_EXPAND,
        "urgency":
        ui_dialog_notification.UiDialogNotification.
        UiDialogNotificationUrgency.URGENT
    }

    Notifications.ShowNotification(queue=False, **notificationArguments)
Ejemplo n.º 3
0
def ShowMissedPillNotification(targetSimInfo: sim_info.SimInfo,
                               missedPills: int) -> None:
    """
	Show a notification indicating that the target sim forgot to take this many pills.
	"""

    if not isinstance(targetSimInfo, sim_info.SimInfo):
        raise Exceptions.IncorrectTypeException(targetSimInfo, "targetSimInfo",
                                                (sim_info.SimInfo, ))

    if not isinstance(missedPills, int):
        raise Exceptions.IncorrectTypeException(missedPills, "missedPills",
                                                (int, ))

    notificationArguments = {
        "owner":
        targetSimInfo,
        "title":
        MissedPillNotificationTitle.GetCallableLocalizationString(),
        "text":
        MissedPillNotificationText.GetCallableLocalizationString(
            targetSimInfo, missedPills),
        "icon":
        lambda *args, **kwargs: shared_messages.IconInfoData(obj_instance=
                                                             targetSimInfo),
        "urgency":
        ui_dialog_notification.UiDialogNotification.
        UiDialogNotificationUrgency.URGENT,
    }

    Notifications.ShowNotification(queue=False, **notificationArguments)
Ejemplo n.º 4
0
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__)
Ejemplo n.º 5
0
def _ShowSavingFirstTimeNotification() -> None:
    notificationArguments = {
        "title":
        SavingFirstTimeNotificationTitle.GetCallableLocalizationString(),
        "text":
        SavingFirstTimeNotificationText.GetCallableLocalizationString(),
    }  # type: typing.Dict[str, typing.Any]

    Notifications.ShowNotification(queue=True, **notificationArguments)
Ejemplo n.º 6
0
def _ShowCommitFailureDialog () -> None:
	notificationArguments = {
		"title": FailureNotificationsTitle.GetCallableLocalizationString(),
		"text": FailureNotificationsCommitText.GetCallableLocalizationString(),
		"expand_behavior": ui_dialog_notification.UiDialogNotification.UiDialogNotificationExpandBehavior.FORCE_EXPAND,
		"urgency": ui_dialog_notification.UiDialogNotification.UiDialogNotificationUrgency.URGENT
	}  # type: typing.Dict[str, typing.Any]

	Notifications.ShowNotification(queue = True, **notificationArguments)
Ejemplo n.º 7
0
def _ShowMismatchGameTickWarningDialog (savingIdentifiers: typing.List[str]) -> None:
	identifiersText = "\n".join(savingIdentifiers)

	notificationArguments = {
		"title": WarningNotificationsTitle.GetCallableLocalizationString(),
		"text": WarningNotificationsMismatchGameTickText.GetCallableLocalizationString(identifiersText),
		"expand_behavior": ui_dialog_notification.UiDialogNotification.UiDialogNotificationExpandBehavior.FORCE_EXPAND,
		"urgency": ui_dialog_notification.UiDialogNotification.UiDialogNotificationUrgency.URGENT
	}  # type: typing.Dict[str, typing.Any]

	Notifications.ShowNotification(queue = True, **notificationArguments)
Ejemplo n.º 8
0
def ShowFertilityNotificationsEnabledNotification (targetSimInfo: sim_info.SimInfo) -> None:
	if not isinstance(targetSimInfo, sim_info.SimInfo):
		raise Exceptions.IncorrectTypeException(targetSimInfo, "targetSimInfo", (sim_info.SimInfo,))

	notificationArguments = {
		"owner": targetSimInfo,
		"title": FertilityNotificationsEnabledNotificationTitle.GetCallableLocalizationString(),
		"text": FertilityNotificationsEnabledNotificationText.GetCallableLocalizationString(),
		"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)
Ejemplo n.º 9
0
def _ShowUnsupportedLanguageNotification() -> None:
    notificationArguments = {
        "title":
        UnsupportedLanguageNotificationTitle.GetCallableLocalizationString(),
        "text":
        UnsupportedLanguageNotificationText.GetCallableLocalizationString(),
        "expand_behavior":
        ui_dialog_notification.UiDialogNotification.
        UiDialogNotificationExpandBehavior.FORCE_EXPAND,
        "urgency":
        ui_dialog_notification.UiDialogNotification.
        UiDialogNotificationUrgency.URGENT
    }  # type: typing.Dict[str, ...]

    Notifications.ShowNotification(queue=True, **notificationArguments)
Ejemplo n.º 10
0
def _ShowInvalidLanguageNotification() -> None:
    notificationArguments = {
        "title":
        InvalidLanguageNotificationTitle.GetCallableLocalizationString(),
        "text":
        InvalidLanguageNotificationText.GetCallableLocalizationString(),
        "expand_behavior":
        ui_dialog_notification.UiDialogNotification.
        UiDialogNotificationExpandBehavior.FORCE_EXPAND,
        "urgency":
        ui_dialog_notification.UiDialogNotification.
        UiDialogNotificationUrgency.URGENT
    }

    Notifications.ShowNotification(**notificationArguments)
Ejemplo n.º 11
0
def _ShowGameSTBLPackageReadErrorNotification() -> None:
    notificationArguments = {
        "title":
        GameSTBLPackageReadErrorNotificationTitle.
        GetCallableLocalizationString(),
        "text":
        GameSTBLPackageMissingNotificationText.GetCallableLocalizationString(),
        "expand_behavior":
        ui_dialog_notification.UiDialogNotification.
        UiDialogNotificationExpandBehavior.FORCE_EXPAND,
        "urgency":
        ui_dialog_notification.UiDialogNotification.
        UiDialogNotificationUrgency.URGENT
    }  # type: typing.Dict[str, ...]

    Notifications.ShowNotification(queue=True, **notificationArguments)
Ejemplo n.º 12
0
def ShowPositiveTestResultNotification(
        targetSimInfo: sim_info.SimInfo) -> None:
    if not isinstance(targetSimInfo, sim_info.SimInfo):
        raise Exceptions.IncorrectTypeException(targetSimInfo, "targetSimInfo",
                                                (sim_info.SimInfo, ))

    notificationArguments = {
        "title":
        PositiveTestResultNotificationTitle.GetCallableLocalizationString(),
        "text":
        PositiveTestResultNotificationText.GetCallableLocalizationString(
            targetSimInfo),
        "icon":
        lambda *args, **kwargs: shared_messages.IconInfoData(obj_instance=
                                                             targetSimInfo)
    }

    Notifications.ShowNotification(queue=False, **notificationArguments)
Ejemplo n.º 13
0
	def _ShowWriteFailureDialog (self, exception: Exception) -> None:
		Notifications.ShowNotification(queue = True,
									   title = self.WriteFailureNotificationTitle.GetCallableLocalizationString(),
									   text = self.WriteFailureNotificationText.GetCallableLocalizationString(FormatException(exception)),
									   expand_behavior = ui_dialog_notification.UiDialogNotification.UiDialogNotificationExpandBehavior.FORCE_EXPAND,
									   urgency = ui_dialog_notification.UiDialogNotification.UiDialogNotificationUrgency.URGENT)