|
from ..core import BOOLEAN, STRING, CATEGORY, any, logger
|
|
|
|
|
|
class CSwitchBooleanAny:
|
|
def __init__(self):
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"on_true": (any, {}),
|
|
"on_false": (any, {}),
|
|
"boolean": BOOLEAN,
|
|
}
|
|
}
|
|
|
|
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
|
|
RETURN_TYPES = (any,)
|
|
|
|
FUNCTION = "execute"
|
|
|
|
def execute(self, on_true, on_false, boolean=True):
|
|
logger.debug("Any switch: " + str(boolean))
|
|
|
|
if boolean:
|
|
return (on_true,)
|
|
else:
|
|
return (on_false,)
|
|
|
|
|
|
class CSwitchBooleanString:
|
|
def __init__(self):
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"on_true": STRING,
|
|
"on_false": STRING,
|
|
"boolean": BOOLEAN,
|
|
}
|
|
}
|
|
|
|
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
|
|
RETURN_TYPES = ("STRING",)
|
|
RETURN_NAMES = ("string",)
|
|
|
|
FUNCTION = "execute"
|
|
|
|
def execute(self, on_true, on_false, boolean=True):
|
|
logger.debug("String switch: " + str(boolean))
|
|
|
|
if boolean:
|
|
return (on_true,)
|
|
else:
|
|
return (on_false,)
|
|
|
|
|
|
class CSwitchBooleanConditioning:
|
|
def __init__(self):
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"on_true": ("CONDITIONING",),
|
|
"on_false": ("CONDITIONING",),
|
|
"boolean": BOOLEAN,
|
|
}
|
|
}
|
|
|
|
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
|
|
RETURN_TYPES = ("CONDITIONING",)
|
|
RETURN_NAMES = ("conditioning",)
|
|
|
|
FUNCTION = "execute"
|
|
|
|
def execute(self, on_true, on_false, boolean=True):
|
|
logger.debug("Conditioning switch: " + str(boolean))
|
|
|
|
if boolean:
|
|
return (on_true,)
|
|
else:
|
|
return (on_false,)
|
|
|
|
|
|
class CSwitchBooleanImage:
|
|
def __init__(self):
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"on_true": ("IMAGE",),
|
|
"on_false": ("IMAGE",),
|
|
"boolean": BOOLEAN,
|
|
}
|
|
}
|
|
|
|
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
|
|
RETURN_TYPES = ("IMAGE",)
|
|
RETURN_NAMES = ("image",)
|
|
|
|
FUNCTION = "execute"
|
|
|
|
def execute(self, on_true, on_false, boolean=True):
|
|
logger.debug("Image switch: " + str(boolean))
|
|
|
|
if boolean:
|
|
return (on_true,)
|
|
else:
|
|
return (on_false,)
|
|
|
|
class CSwitchBooleanLatent:
|
|
def __init__(self):
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"on_true": ("LATENT",),
|
|
"on_false": ("LATENT",),
|
|
"boolean": BOOLEAN,
|
|
}
|
|
}
|
|
|
|
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
|
|
RETURN_TYPES = ("LATENT",)
|
|
RETURN_NAMES = ("latent",)
|
|
|
|
FUNCTION = "execute"
|
|
|
|
def execute(self, on_true, on_false, boolean=True):
|
|
logger.debug("Latent switch: " + str(boolean))
|
|
|
|
if boolean:
|
|
return (on_true,)
|
|
else:
|
|
return (on_false,)
|
|
|
|
|
|
class CSwitchBooleanMask:
|
|
def __init__(self):
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"on_true": ("MASK",),
|
|
"on_false": ("MASK",),
|
|
"boolean": BOOLEAN,
|
|
}
|
|
}
|
|
|
|
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
|
|
RETURN_TYPES = ("MASK",)
|
|
RETURN_NAMES = ("mask",)
|
|
|
|
FUNCTION = "execute"
|
|
|
|
def execute(self, on_true, on_false, boolean=True):
|
|
logger.debug("Mask switch: " + str(boolean))
|
|
|
|
if boolean:
|
|
return (on_true,)
|
|
else:
|
|
return (on_false,)
|
|
|