- rename Smart Category Config → Smart Profile Switch 🧩 (code, JS, locales, demo workflow)
- add banner.svg and embed it at the top of README
- replace fragile OpenFileDialog folder-browse hack with native IFileDialog/FOS_PICKFOLDERS picker — fixes wrong-folder bug on single-click select
- flip Smart Resize's upscale_if_smaller default to true — node now resizes to target by default, as the name implies
- add width/height source tooltip to Smart Resolution Multiplier's image input
- fix stale widgets_values in smart_batch_resize_demo.json (10 fields → 13 after prefix/counter fields were added)
- full README rewrite: correct inputs/defaults/outputs for all 5 nodes, new Smart Profile Switch section, Example workflows section, expanded "Why these nodes?"
- add new example workflow (seedvr2_smartresize_demo.json), updated screenshots
- add assets/*.ai to .gitignore
- bump version to 1.0.2
66 lines
2.2 KiB
Python
66 lines
2.2 KiB
Python
class SmartProfileSwitch:
|
||
"""
|
||
CraftKit — Smart Profile Switch 🧩
|
||
Maps an active index (1–4) to a label, width, and height.
|
||
Designed to pair with Smart Prompt Controller's active_list output.
|
||
"""
|
||
|
||
_DEFAULTS = [
|
||
("Headshots", 1024, 1024),
|
||
("Halfbody", 832, 1216),
|
||
("Fullbody", 768, 1344),
|
||
("Tall", 640, 1536),
|
||
]
|
||
|
||
@classmethod
|
||
def INPUT_TYPES(cls):
|
||
required = {
|
||
"index": ("INT", {
|
||
"default": 1,
|
||
"min": 1,
|
||
"max": 4,
|
||
"step": 1,
|
||
"display": "number",
|
||
"tooltip": "Active profile (1–4). Connect to active_list from Smart Prompt Controller.",
|
||
}),
|
||
}
|
||
for i, (label, w, h) in enumerate(cls._DEFAULTS, 1):
|
||
required[f"label_{i}"] = ("STRING", {
|
||
"default": label,
|
||
"tooltip": f"Label for profile {i}, used as filename suffix.",
|
||
})
|
||
required[f"width_{i}"] = ("INT", {"default": w, "min": 64, "max": 8192, "step": 8})
|
||
required[f"height_{i}"] = ("INT", {"default": h, "min": 64, "max": 8192, "step": 8})
|
||
return {"required": required}
|
||
|
||
RETURN_TYPES = ("STRING", "INT", "INT")
|
||
RETURN_NAMES = ("label", "width", "height")
|
||
FUNCTION = "route"
|
||
CATEGORY = "CraftKit"
|
||
OUTPUT_NODE = True
|
||
|
||
def route(self, index,
|
||
label_1, width_1, height_1,
|
||
label_2, width_2, height_2,
|
||
label_3, width_3, height_3,
|
||
label_4, width_4, height_4):
|
||
slots = [
|
||
(label_1, width_1, height_1),
|
||
(label_2, width_2, height_2),
|
||
(label_3, width_3, height_3),
|
||
(label_4, width_4, height_4),
|
||
]
|
||
idx = max(1, min(4, index)) - 1
|
||
label, width, height = slots[idx]
|
||
status = f"Slot {idx + 1}: {label} | {width} × {height}"
|
||
return {"ui": {"text": [status]}, "result": (label, width, height)}
|
||
|
||
|
||
NODE_CLASS_MAPPINGS = {
|
||
"SmartProfileSwitch": SmartProfileSwitch,
|
||
}
|
||
|
||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||
"SmartProfileSwitch": "Smart Profile Switch \U0001f9e9",
|
||
}
|