コード例 #1
0
	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["text_cancel"] = Language.MakeLocalizationStringCallable(self._GetCancelButtonText())
		dialogArguments["ui_responses"] = dialogResponses

		return dialogArguments
コード例 #2
0
ファイル: Distribution.py プロジェクト: NeonOcean/S4.Order
def _ShowPromotionNotification(promotion: _Promotion) -> None:
    notificationArguments = {
        "text":
        lambda *args, **kwargs: Language.CreateLocalizationString(promotion.
                                                                  Text)
    }

    if promotion.Link is not None:
        if promotion.LinkButton is not None:
            linkResponseText = lambda *args, **kwargs: Language.CreateLocalizationString(
                promotion.LinkButton)
        else:
            linkResponseText = PromotionDefaultButton.GetCallableLocalizationString(
            )

        linkResponseCommand = collections.make_immutable_slots_class(
            ("command", "arguments"))

        linkResponseArguments = [
            collections.make_immutable_slots_class(("arg_value", "arg_type"))
        ]

        linkResponseArguments[0] = linkResponseArguments[0]({
            "arg_value":
            codecs.encode(bytearray(promotion.Link, "utf-8"),
                          "hex").decode("utf-8"),
            "arg_type":
            ui_dialog.CommandArgType.ARG_TYPE_STRING
        })

        linkResponseCommand = linkResponseCommand({
            "command":
            This.Mod.Namespace.lower() + ".distribution.show_url",
            "arguments":
            linkResponseArguments
        })

        linkResponse = ui_dialog.UiDialogResponse(
            text=linkResponseText,
            ui_request=ui_dialog.UiDialogResponse.UiDialogUiRequest.
            SEND_COMMAND,
            response_command=linkResponseCommand)

        notificationArguments["ui_responses"] = (linkResponse, )

    if promotion.Title is not None:
        notificationArguments[
            "title"] = lambda *args, **kwargs: Language.CreateLocalizationString(
                promotion.Title)
    else:
        notificationArguments[
            "title"] = PromotionDefaultTitle.GetCallableLocalizationString()

    Notifications.ShowNotification(queue=True, **notificationArguments)
コード例 #3
0
ファイル: SettingsList.py プロジェクト: NeonOcean/S4.Order
	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
コード例 #4
0
ファイル: SettingsList.py プロジェクト: NeonOcean/S4.Order
		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)
コード例 #5
0
ファイル: List.py プロジェクト: NeonOcean/S4.Order
 def _GetDescriptionText(self,
                         listPath: str) -> localization.LocalizedString:
     listPathIdentifier = listPath.replace(self.ListPathSeparator,
                                           "_")  # type: str
     return Language.GetLocalizationStringByIdentifier(
         This.Mod.Namespace + ".Mod_Settings.List.Paths." +
         listPathIdentifier + ".Description")
コード例 #6
0
ファイル: Types.py プロジェクト: NeonOcean/S4.Order
    def GetValueText(cls, value: bool) -> localization.LocalizedString:
        if not isinstance(value, bool):
            raise Exceptions.IncorrectTypeException(value, "value", (bool, ))

        valueString = str(value)  # type: str
        return Language.GetLocalizationStringByIdentifier(
            This.Mod.Namespace + ".Settings.Types.Boolean.Yes_No." +
            valueString,
            fallbackText=valueString)
コード例 #7
0
ファイル: List.py プロジェクト: NeonOcean/S4.Order
 def _GetTitleListPathText(self,
                           listPath: str) -> localization.LocalizedString:
     listPathIdentifier = listPath.replace(self.ListPathSeparator,
                                           "_")  # type: str
     fallbackText = "List.Paths." + listPathIdentifier + ".Title"  # type: str
     return Language.GetLocalizationStringByIdentifier(
         This.Mod.Namespace + ".Mod_Settings.List.Paths." +
         listPathIdentifier + ".Title",
         fallbackText=fallbackText)
コード例 #8
0
ファイル: TextBuilder.py プロジェクト: NeonOcean/S4.Order
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
コード例 #9
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
コード例 #10
0
ファイル: SettingsList.py プロジェクト: NeonOcean/S4.Order
	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
コード例 #11
0
	def __init__ (self,
				  value: typing.Any,
				  identifier: str,
				  priority: typing.Union[float, int],
				  reasonText: typing.Optional[typing.Callable[[], localization.LocalizedString]] = None):

		self.Value = value  # type: typing.Any
		self.Identifier = identifier  # type: str
		self.Priority = priority  # type: typing.Union[float, int]

		if reasonText is not None:
			self.ReasonText = reasonText  # type: typing.Callable[[], localization.LocalizedString]
		else:
			self.ReasonText = lambda *args, **kwargs: Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Settings.Misc.Override.Unknown_Reason")  # type: typing.Callable[[], localization.LocalizedString]
コード例 #12
0
class ChoiceDialogButton(DialogButton):
	ChoiceButton = Language.String(This.Mod.Namespace + ".Setting_Dialogs.Choice_Button", fallbackText = "Choice_Button")  # type: Language.String

	def __init__ (self, selected: bool = False, *args, **kwargs):
		"""
		:param selected: Whether or not the button's text will have a selected look.
		:type selected: bool
		"""

		super().__init__(*args, **kwargs)

		self.Selected = selected  # type: bool

	def GenerateDialogResponse (self) -> ui_dialog.UiDialogResponse:
		if self.Selected:
			valueButtonStringTokens = ("> ", self.Text, " <")
		else:
			valueButtonStringTokens = ("", self.Text, "")

		if self.ChoiceButton.IdentifierIsRegistered():
			buttonTextString = self.ChoiceButton.GetCallableLocalizationString(*valueButtonStringTokens)
		else:
			buttonTextString = self.Text

		responseArguments = {
			"dialog_response_id": self.ResponseID,
			"sort_order": self.SortOrder,
			"text": buttonTextString
		}

		if self.SubText is not None:
			buttonSubTextString = lambda *args, **kwargs: self.SubText

			responseArguments["subtext"] = buttonSubTextString

		response = ui_dialog.UiDialogResponse(**responseArguments)

		return response
コード例 #13
0
ファイル: Dialogs.py プロジェクト: NeonOcean/S4.Order
 def _GetDescriptionSettingText(
     self, setting: UISettingsShared.SettingStandardWrapper
 ) -> localization.LocalizedString:
     return Language.GetLocalizationStringByIdentifier(
         This.Mod.Namespace + ".Mod_Settings.Values." + setting.Key +
         ".Description")
コード例 #14
0
	def _GetCancelButtonText (self) -> localization.LocalizedString:
		return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Setting_Dialogs.Cancel_Button", fallbackText = "Cancel_Button")
コード例 #15
0
	def _GetDescriptionPartsDocumentationText (self) -> localization.LocalizedString:
		return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Setting_Dialogs.Description_Parts.Documentation")
コード例 #16
0
	def _GetDescriptionPartsOverriddenValueText (self) -> localization.LocalizedString:
		return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Setting_Dialogs.Description_Parts.Overridden_Value")
コード例 #17
0
	def _GetDescriptionSettingText (self, setting: UISettingsShared.SettingWrapper) -> localization.LocalizedString:
		return Language.CreateLocalizationString("**")
コード例 #18
0
ファイル: Dependent.py プロジェクト: NeonOcean/S4.Order
from __future__ import annotations

import interactions
from NeonOcean.S4.Order import Language, Mods, This
from event_testing import results, test_base
from sims4.tuning import tunable

DisabledTooltip = Language.String(
    This.Mod.Namespace + ".Interactions.Support.Dependent.Disabled_Tooltip",
    fallbackText="Disabled_Tooltip")


class DependentTest(test_base.BaseTest):
    # noinspection SpellCheckingInspection
    def __call__(self, affordance):
        if affordance is None:
            return results.TestResult(False)

        if not issubclass(affordance, DependentExtension):
            return results.TestResult(True)

        if affordance.DependentOnMod:
            if affordance.DependentMod is not None:
                if not affordance.DependentMod.IsLoaded():
                    return results.TestResult(
                        False,
                        tooltip=DisabledTooltip.GetCallableLocalizationString(
                            affordance.DependentMod.Namespace))

        return results.TestResult(True)
コード例 #19
0
from __future__ import annotations

import abc
import traceback
import typing

import services
from NeonOcean.S4.Order import Debug, Language, This
from NeonOcean.S4.Order.Tools import Exceptions, TextBuilder
from NeonOcean.S4.Order.UI import SettingsShared as UISettingsShared
from sims4 import localization
from ui import ui_dialog, ui_dialog_picker

InvalidInputNotificationTitle = Language.String(This.Mod.Namespace + ".Setting_Dialogs.Invalid_Input_Notification.Title")  # type: Language.String
InvalidInputNotificationText = Language.String(This.Mod.Namespace + ".Setting_Dialogs.Invalid_Input_Notification.Text")  # type: Language.String

PresetConfirmDialogTitle = Language.String(This.Mod.Namespace + ".Setting_Dialogs.Preset_Confirm_Dialog.Title")  # type: Language.String
PresetConfirmDialogText = Language.String(This.Mod.Namespace + ".Setting_Dialogs.Preset_Confirm_Dialog.Text")  # type: Language.String
PresetConfirmDialogYesButton = Language.String(This.Mod.Namespace + ".Setting_Dialogs.Preset_Confirm_Dialog.Yes_Button", fallbackText = "Preset_Confirm_Dialog.Yes_Button")  # type: Language.String
PresetConfirmDialogNoButton = Language.String(This.Mod.Namespace + ".Setting_Dialogs.Preset_Confirm_Dialog.No_Button", fallbackText = "Preset_Confirm_Dialog.No_Button")  # type: Language.String

class DialogButton:
	def __init__ (self,
				  responseID: int,
				  sortOrder: int,
				  callback: typing.Callable[[ui_dialog.UiDialog], None],
				  text: localization.LocalizedString,
				  subText: localization.LocalizedString = None):
		"""
		:param responseID: The identifier used to determine which response the dialog was given.
		:type responseID: int
コード例 #20
0
ファイル: SettingsList.py プロジェクト: NeonOcean/S4.Order
	def _GetResetAllConfirmDialogNoButtonText (self) -> localization.LocalizedString:
		return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Setting_Lists.Reset_All.Confirm_Dialog.No_Button", fallbackText = "No_Button")
コード例 #21
0
	def GetNameText (cls) -> localization.LocalizedString:
		return Language.GetLocalizationStringByIdentifier(This.Mod.Namespace + ".Mod_Settings.Values." + cls.Key + ".Name", fallbackText = cls.Key)
コード例 #22
0
ファイル: Resetting.py プロジェクト: NeonOcean/S4.Order
from __future__ import annotations

import inspect
import sys
import types
import typing

from NeonOcean.S4.Order import Debug, Language, Mods, This
from NeonOcean.S4.Order.UI import Dialogs
from ui import ui_dialog

DialogTitle = Language.String(This.Mod.Namespace + ".Reset.Dialog.Title")  # type: Language.String
DialogText = Language.String(This.Mod.Namespace + ".Reset.Dialog.Text")  # type: Language.String
DialogEverythingButton = Language.String(This.Mod.Namespace + ".Reset.Dialog.Everything_Button", fallbackText = "Everything_Button")  # type: Language.String
DialogSettingsButton = Language.String(This.Mod.Namespace + ".Reset.Dialog.Settings_Button", fallbackText = "Settings_Button")  # type: Language.String
DialogCancelButton = Language.String(This.Mod.Namespace + ".Reset.Dialog.Cancel_Button", fallbackText = "Cancel_Button")  # type: Language.String

ConfirmDialogTitle = Language.String(This.Mod.Namespace + ".Reset.Confirm_Dialog.Title")  # type: Language.String
ConfirmDialogEverythingText = Language.String(This.Mod.Namespace + ".Reset.Confirm_Dialog.Everything_Text")  # type: Language.String
ConfirmDialogSettingsText = Language.String(This.Mod.Namespace + ".Reset.Confirm_Dialog.Settings_Text")  # type: Language.String
ConfirmDialogYesButton = Language.String(This.Mod.Namespace + ".Reset.Confirm_Dialog.Yes_Button", fallbackText = "Yes_Button")  # type: Language.String
ConfirmDialogNoButton = Language.String(This.Mod.Namespace + ".Reset.Confirm_Dialog.No_Button", fallbackText = "No_Button")  # type: Language.String

def ResetEverything (mod: Mods.Mod) -> bool:
	"""
	Resets everything that can be reset in the target mod.

	:return: Returns true if successful or false if not.
	:rtype: bool
	"""
コード例 #23
0
	def GetDefaultText (cls) -> localization.LocalizedString:
		return Language.CreateLocalizationString("**")
コード例 #24
0
ファイル: List.py プロジェクト: NeonOcean/S4.Order
 def _GetTitleText(self, listPath: str) -> localization.LocalizedString:
     return Language.GetLocalizationStringByIdentifier(
         This.Mod.Namespace + ".Mod_Settings.List.Title")
コード例 #25
0
ファイル: Distribution.py プロジェクト: NeonOcean/S4.Order
import json
import os
import random
import threading
import typing
from http import client
from urllib import request

import zone
from NeonOcean.S4.Order import Debug, Director, Information, Language, Mods, Paths, Settings, This, Websites
from NeonOcean.S4.Order.Tools import Exceptions, Parse, Timer, Version
from NeonOcean.S4.Order.UI import Notifications
from sims4 import collections
from ui import ui_dialog

UpdateNotificationTitle = Language.String(
    This.Mod.Namespace + ".Distribution.Update_Notification.Title")
UpdateNotificationReleaseText = Language.String(
    This.Mod.Namespace + ".Distribution.Update_Notification.Release_Text")
UpdateNotificationPreviewText = Language.String(
    This.Mod.Namespace + ".Distribution.Update_Notification.Preview_Text")
UpdateNotificationButton = Language.String(
    This.Mod.Namespace + ".Distribution.Update_Notification.Button")

PromotionDefaultTitle = Language.String(
    This.Mod.Namespace + ".Distribution.Promotions.Default.Title")
PromotionDefaultButton = Language.String(
    This.Mod.Namespace + ".Distribution.Promotions.Default.Button")

_distributionURL = "http://dist.mods.neonoceancreations.com"  # type: str

_updatesTicker = None  # type: typing.Optional[Timer.Timer]
コード例 #26
0
ファイル: Dialogs.py プロジェクト: NeonOcean/S4.Order
 def _GetValueText(self, value: bool) -> localization.LocalizedString:
     return Language.GetLocalizationStringByIdentifier(
         This.Mod.Namespace + ".Settings.Types.Boolean.Yes_No." +
         str(value),
         fallbackText=str(value))
コード例 #27
0
ファイル: TextBuilder.py プロジェクト: NeonOcean/S4.Order
def _GetFormattingText() -> localization.LocalizedString:
    return Language.GetLocalizationStringByIdentifier(
        This.Mod.Namespace + ".Text_Builder.Formatting",
        fallbackText="Missing Formatting String!")
コード例 #28
0
	def GetValueText (cls, value: typing.Any) -> localization.LocalizedString:
		return Language.CreateLocalizationString("**")
コード例 #29
0
from __future__ import annotations

import typing
import webbrowser

from NeonOcean.S4.Order import Debug, Language, Mods, This
from NeonOcean.S4.Order.Tools import Exceptions
from NeonOcean.S4.Order.UI import Dialogs
from sims4 import localization
from ui import ui_dialog

OpenBrowserDialogText = Language.String(
    This.Mod.Namespace +
    ".Generic_Dialogs.Open_Browser_Dialog.Text")  # type: Language.String
OpenBrowserDialogYesButton = Language.String(
    This.Mod.Namespace + ".Generic_Dialogs.Open_Browser_Dialog.Yes_Button",
    fallbackText="Yes_Button")  # type: Language.String
OpenBrowserDialogNoButton = Language.String(
    This.Mod.Namespace + ".Generic_Dialogs.Open_Browser_Dialog.No_Button",
    fallbackText="No_Button")  # type: Language.String

AboutModDialogTitle = Language.String(
    This.Mod.Namespace +
    ".Generic_Dialogs.About_Mod_Dialog.Title")  # type: Language.String
AboutModDialogText = Language.String(
    This.Mod.Namespace +
    ".Generic_Dialogs.About_Mod_Dialog.Text")  # type: Language.String
AboutModDialogOkButton = Language.String(
    This.Mod.Namespace + ".Generic_Dialogs.About_Mod_Dialog.Ok_Button",
    fallbackText="Ok_Button")  # type: Language.String
AboutModDialogUnknown = Language.String(
コード例 #30
0
import json
import os
import sys
import types
import typing
import time
import zipfile

import zone
from NeonOcean.S4.Order import Debug, Language, LoadingEvents, LoadingShared, Mods, Paths, This
from NeonOcean.S4.Order.Tools import Exceptions, Parse, Version
from NeonOcean.S4.Order.UI import Notifications
from sims4.importer import custom_import
from ui import ui_dialog_notification

LoadingFailureNotificationTitle = Language.String(This.Mod.Namespace + ".Mod_Loading.Failure_Notification.Title")  # type: Language.String
LoadingFailureNotificationText = Language.String(This.Mod.Namespace + ".Mod_Loading.Failure_Notification.Text")  # type: Language.String

InvalidSetupNotificationTitle = Language.String(This.Mod.Namespace + ".Mod_Loading.Invalid_Setup_Notification.Title")  # type: Language.String
InvalidSetupNotificationText = Language.String(This.Mod.Namespace + ".Mod_Loading.Invalid_Setup_Notification.Text")  # type: Language.String

CascadeFailureNotificationTitle = Language.String(This.Mod.Namespace + ".Mod_Loading.Cascade_Failure_Notification.Title")  # type: Language.String
CascadeFailureNotificationText = Language.String(This.Mod.Namespace + ".Mod_Loading.Cascade_Failure_Notification.Text")  # type: Language.String

NotLoadedFailureNotificationTitle = Language.String(This.Mod.Namespace + ".Mod_Loading.Not_Loaded_Notification.Title")  # type: Language.String
NotLoadedFailureNotificationText = Language.String(This.Mod.Namespace + ".Mod_Loading.Not_Loaded_Notification.Text")  # type: Language.String

_allLoaders = list()  # type: typing.List[_Loader]

_autoLoad = True  # type: bool