Exemplo n.º 1
0
	def _GetDescriptionValuesParts (self, setting: UISettingsShared.SettingWrapper) -> typing.List[typing.Union[localization.LocalizedString, str, int, float]]:
		valuesParts = list()  # type: typing.List[typing.Union[localization.LocalizedString, str, int, float]]

		defaultPart = self._GetDescriptionPartsDefaultText()  # type: localization.LocalizedString
		Language.AddTokens(defaultPart, self._GetDescriptionDefaultText(setting))
		valuesParts.append(defaultPart)

		if setting.IsOverridden():
			overriddenPart = self._GetDescriptionPartsOverriddenValueText()  # type: localization.LocalizedString
			overriddenPartTokens = (
				self._GetDescriptionOverrideValueText(setting),
				self._GetDescriptionOverrideReasonText(setting)
			)  # type: tuple

			Language.AddTokens(overriddenPart, *overriddenPartTokens)

			valuesParts.append("\n")
			valuesParts.append(overriddenPart)

		return valuesParts
Exemplo n.º 2
0
	def _GetRowSettingDescriptionParts (self, setting: UISettingsShared.SettingWrapper) -> typing.List[typing.Union[localization.LocalizedString, str, int, float]]:
		descriptionParts = list()  # type: typing.List[typing.Union[localization.LocalizedString, str, int, float]]

		settingValue = setting.Get()  # type: typing.Any
		settingValueText = setting.GetValueText(settingValue)  # type: localization.LocalizedString

		valueText = self._GetRowPartsSettingValueText()  # type: localization.LocalizedString
		Language.AddTokens(valueText, settingValueText)
		descriptionParts.append(valueText)

		if setting.IsOverridden():
			descriptionParts.append("\n")

			actualValue = setting.Get(ignoreOverride = True)  # type: typing.Any
			actualValueText = setting.GetValueText(actualValue)  # type: localization.LocalizedString

			overriddenText = self._GetRowPartsSettingOverriddenText()
			Language.AddTokens(overriddenText, actualValueText)
			descriptionParts.append(overriddenText)

		return descriptionParts
Exemplo n.º 3
0
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
Exemplo n.º 4
0
	def _GetTitleText (self, listPath: str) -> localization.LocalizedString:
		titleText = self._GetTitleTemplateText()  # type: localization.LocalizedString
		titleTextStandard = self._GetTitleStandardText()  # type: localization.LocalizedString
		titleTextListPath = self._GetTitleListPathText(listPath)  # type: localization.LocalizedString
		Language.AddTokens(titleText, titleTextStandard, titleTextListPath)
		return titleText