Exemplo n.º 1
0
    def ShowDialog(
        cls,
        returnCallback: typing.Optional[typing.Callable[[],
                                                        None]] = None) -> None:
        """
		Show the dialog to change this setting.
		:param returnCallback: The return callback will be triggered after the setting dialog is closed.
		:type returnCallback: typing.Callable[[], None]
		"""

        if not isinstance(returnCallback,
                          typing.Callable) and returnCallback is not None:
            raise Exceptions.IncorrectTypeException(returnCallback,
                                                    "returnCallback",
                                                    ("Callable", None))

        if not cls.CanShowDialog():
            return

        if cls.Dialog is None:
            return

        settingWrapper = UISettingsShared.SettingStandardWrapper(
            cls)  # type: UISettingsShared.SettingStandardWrapper
        settingDialog = cls.Dialog()  # type: UISettings.SettingDialogBase
        settingDialog.ShowDialog(settingWrapper, returnCallback=returnCallback)
Exemplo n.º 2
0
    def ShowDialog(cls,
                   simID: str,
                   returnCallback: typing.Callable[[], None] = None) -> None:
        """
		Show the dialog to change this setting.
		:param simID: The ID of the sim who's setting value the dialog would be changing.
		:type simID: str
		:param returnCallback: The return callback will be triggered after the setting dialog is closed.
		:type returnCallback: typing.Callable[[], None]
		"""

        if not isinstance(simID, str):
            raise Exceptions.IncorrectTypeException(simID, "simID", (str, ))

        if not isinstance(returnCallback,
                          typing.Callable) and returnCallback is not None:
            raise Exceptions.IncorrectTypeException(returnCallback,
                                                    "returnCallback",
                                                    ("Callable", None))

        if not hasattr(cls, "Dialog"):
            return

        if cls.Dialog is None:
            return

        settingWrapper = UISettingsShared.SettingBranchWrapper(
            cls, simID)  # type: UISettingsShared.SettingBranchWrapper
        settingDialog = cls.Dialog()  # type: UISettings.SettingDialogBase
        settingDialog.ShowDialog(settingWrapper, returnCallback=returnCallback)
Exemplo n.º 3
0
def GetListDialogSettings () -> typing.List[UISettingsShared.SettingStandardWrapper]:
	return [UISettingsShared.SettingStandardWrapper(setting) for setting in Settings.GetAllSettings()]
Exemplo n.º 4
0
def GetListDialogSettingsSystem () -> UISettingsShared.SettingsSystemStandardWrapper:
	return UISettingsShared.SettingsSystemStandardWrapper(SettingsBase, GetListDialogSettings(), SettingsBase.Save, SettingsBase.Update)
Exemplo n.º 5
0
def GetListDialogSettings(
        branch: str) -> typing.List[UISettingsShared.SettingBranchWrapper]:
    return [
        UISettingsShared.SettingBranchWrapper(setting, branch)
        for setting in SimSettings.GetAllSettings()
    ]
Exemplo n.º 6
0
def GetListDialogSettingsSystem(
        branch: str) -> UISettingsShared.SettingsSystemBranchWrapper:
    return UISettingsShared.SettingsSystemBranchWrapper(
        SettingsBase, GetListDialogSettings(branch),
        lambda *args, **kwargs: None, SettingsBase.Update)