Add scene chain Insta OF demo workflow
This commit is contained in:
+26
-5
@@ -214,7 +214,9 @@ def _cast_slots(character_cast: Any) -> list[dict[str, Any]]:
|
||||
return []
|
||||
|
||||
|
||||
def _slot_matches(slot: dict[str, Any], subject_label: str) -> bool:
|
||||
def _slot_matches(slot: dict[str, Any], subject_type: str, subject_label: str) -> bool:
|
||||
if subject_type != "all" and str(slot.get("subject_type") or "").strip().lower() != subject_type:
|
||||
return False
|
||||
if subject_label == "all":
|
||||
return True
|
||||
return str(slot.get("label") or "").strip().upper() == subject_label.upper()
|
||||
@@ -222,6 +224,7 @@ def _slot_matches(slot: dict[str, Any], subject_label: str) -> bool:
|
||||
|
||||
def _update_character_cast_wardrobe(
|
||||
character_cast: str | dict[str, Any] | list[Any] | None,
|
||||
subject_type: str,
|
||||
subject_label: str,
|
||||
softcore_outfit: str,
|
||||
hardcore_clothing: str,
|
||||
@@ -231,7 +234,7 @@ def _update_character_cast_wardrobe(
|
||||
return character_cast if isinstance(character_cast, str) else ""
|
||||
changed = False
|
||||
for slot in slots:
|
||||
if not _slot_matches(slot, subject_label):
|
||||
if not _slot_matches(slot, subject_type, subject_label):
|
||||
continue
|
||||
if softcore_outfit:
|
||||
slot["softcore_outfit"] = softcore_outfit
|
||||
@@ -555,6 +558,7 @@ class SxCPSceneWardrobe:
|
||||
"required": {
|
||||
"scene": (SXCP_SCENE,),
|
||||
"enabled": ("BOOLEAN", {"default": True}),
|
||||
"subject_type": (["all", "woman", "man"], {"default": "woman"}),
|
||||
"subject_label": (SUBJECT_LABEL_CHOICES, {"default": "all"}),
|
||||
"clothing_override": (["profile_default", "random", "full", "minimal"], {"default": "profile_default"}),
|
||||
"softcore_outfit": ("STRING", {"default": "", "multiline": True}),
|
||||
@@ -568,24 +572,41 @@ class SxCPSceneWardrobe:
|
||||
FUNCTION = "build"
|
||||
CATEGORY = "prompt_builder/v2_scene"
|
||||
|
||||
def build(self, scene, enabled, subject_label, clothing_override, softcore_outfit, hardcore_clothing, wardrobe_prompt):
|
||||
def build(
|
||||
self,
|
||||
scene,
|
||||
enabled,
|
||||
subject_type,
|
||||
subject_label,
|
||||
clothing_override,
|
||||
softcore_outfit,
|
||||
hardcore_clothing,
|
||||
wardrobe_prompt,
|
||||
):
|
||||
parsed = _parse_scene(scene)
|
||||
current_cast = _base_config(parsed, "character_cast")
|
||||
if enabled:
|
||||
updated_cast = _update_character_cast_wardrobe(current_cast, subject_label, softcore_outfit, hardcore_clothing)
|
||||
updated_cast = _update_character_cast_wardrobe(
|
||||
current_cast,
|
||||
subject_type,
|
||||
subject_label,
|
||||
softcore_outfit,
|
||||
hardcore_clothing,
|
||||
)
|
||||
if updated_cast:
|
||||
_set_config(parsed, "character_cast", updated_cast)
|
||||
else:
|
||||
updated_cast = current_cast
|
||||
layer = {
|
||||
"enabled": bool(enabled),
|
||||
"subject_type": subject_type,
|
||||
"subject_label": subject_label,
|
||||
"clothing_override": clothing_override,
|
||||
"softcore_outfit": softcore_outfit or "",
|
||||
"hardcore_clothing": hardcore_clothing or "",
|
||||
"prompt": wardrobe_prompt or "",
|
||||
}
|
||||
summary = "disabled" if not enabled else f"{subject_label}; {clothing_override}"
|
||||
summary = "disabled" if not enabled else f"{subject_type} {subject_label}; {clothing_override}"
|
||||
_set_layer(parsed, "wardrobe", layer, summary)
|
||||
return _dump(parsed), updated_cast or "", summary, _dump(parsed)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user