Add files via upload
This commit is contained in:
Binary file not shown.
+32
-48
@@ -1,19 +1,13 @@
|
||||
import os
|
||||
|
||||
NODE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
LISTS_DIR = os.path.join(NODE_DIR, "lists")
|
||||
|
||||
class ComfyUIDynamicDropdownsPro:
|
||||
class DynamicDropdownDemoNode:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
# Default fallback options if text files aren't parsed yet
|
||||
styles = ["Amateur Candid", "Studio Cinematic", "Vintage Film"]
|
||||
lighting = ["Soft Natural", "Harsh Neon", "Golden Hour"]
|
||||
|
||||
return {
|
||||
"required": {
|
||||
"demo_style": (styles,),
|
||||
"demo_lighting": (lighting,),
|
||||
"style": (["Studio Cinematic", "Anime Flat", "Editorial", "Raw Documentary", "Soft Portrait"],),
|
||||
"lighting": (["Soft Natural", "Harsh Neon", "Golden Hour", "Blue Hour", "Studio Key"],),
|
||||
"post_process": (["Orange Down", "Teal & Orange", "Matte Black", "Film Grain", "Clean"],),
|
||||
"camera": (["Studio Cinematic, Tyren Style", "35mm f/1.4", "Anamorphic", "Wide Angle", "Macro"],),
|
||||
"composition": (["Studio Cinematic", "Rule of Thirds", "Centered", "Dutch Angle", "Overhead"],),
|
||||
},
|
||||
"optional": {
|
||||
"input_string": ("STRING", {"forceInput": True}),
|
||||
@@ -23,49 +17,39 @@ class ComfyUIDynamicDropdownsPro:
|
||||
|
||||
RETURN_TYPES = ("STRING", "CONDITIONING")
|
||||
RETURN_NAMES = ("PROMPT_STRING", "CONDITIONING")
|
||||
FUNCTION = "process_prompt"
|
||||
CATEGORY = "Custom Selection"
|
||||
FUNCTION = "execute"
|
||||
CATEGORY = "🎭 Dynamic Dropdowns"
|
||||
|
||||
def process_prompt(self, demo_style, demo_lighting, input_string="", clip=None, **kwargs):
|
||||
clean_choices = []
|
||||
def execute(self, clip=None, input_string="", **kwargs):
|
||||
selections = []
|
||||
|
||||
# 1. Inject the daisy-chained input string first if present
|
||||
if input_string and str(input_string).strip():
|
||||
clean_choices.append(str(input_string).strip())
|
||||
# Pull standard selections from the demo dropdowns block sequence
|
||||
for key in ["style", "lighting", "post_process", "camera", "composition"]:
|
||||
if key in kwargs:
|
||||
val = str(kwargs[key]).strip()
|
||||
if val and val != "None":
|
||||
selections.append(val)
|
||||
|
||||
# Inject upstream daisy-chained string blocks if present
|
||||
if input_string and input_string.strip():
|
||||
selections.insert(0, input_string.strip())
|
||||
|
||||
# 2. Add the base required dropdown values
|
||||
if demo_style and demo_style != "Select...":
|
||||
clean_choices.append(str(demo_style).strip())
|
||||
if demo_lighting and demo_lighting != "Select...":
|
||||
clean_choices.append(str(demo_lighting).strip())
|
||||
|
||||
# 3. Dynamically append any extra custom slots generated by the frontend JS buttons
|
||||
for key in sorted(kwargs.keys()):
|
||||
value = kwargs[key]
|
||||
if value and str(value).strip() and value != "Select...":
|
||||
clean_choices.append(str(value).strip())
|
||||
|
||||
# 4. Concatenate everything with clean single commas
|
||||
final_prompt = ", ".join([c for c in clean_choices if c])
|
||||
|
||||
# 5. Handle the optional CLIP conditioning safely without crashing if unlinked
|
||||
final_string = ", ".join(selections)
|
||||
final_string = final_string.replace('"', '').replace('\\\\', '').replace(', ,', ',')
|
||||
|
||||
# Process Conditioning Block engine stack mapping
|
||||
conditioning = []
|
||||
if clip is not None:
|
||||
tokens = clip.tokenize(final_prompt)
|
||||
tokens = clip.tokenize(final_string)
|
||||
cond, pooled = clip.encode_from_tokens(tokens, return_pooled=True)
|
||||
conditioning_output = [[cond, {"pooled_output": pooled}]]
|
||||
else:
|
||||
conditioning_output = None
|
||||
|
||||
return (final_prompt, conditioning_output)
|
||||
|
||||
# --- REGISTRATION CONFIGURATION ---
|
||||
|
||||
# Crucial link that tells ComfyUI to look inside the /js folder for UI overrides
|
||||
WEB_DIRECTORY = "./js"
|
||||
conditioning = [[cond, {"pooled_output": pooled}]]
|
||||
|
||||
return (final_string, conditioning)
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"ComfyUI_Dynamic_Dropdowns_Demo": ComfyUIDynamicDropdownsPro
|
||||
"DynamicDropdownDemoNode": DynamicDropdownDemoNode
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"ComfyUI_Dynamic_Dropdowns_Demo": "🎭 Dynamic Dropdowns (Pro Mode)"
|
||||
"DynamicDropdownDemoNode": "🎭 Dynamic Dropdowns (Demo Mode)"
|
||||
}
|
||||
Reference in New Issue
Block a user