V2.0.0 - Title manager - titles #3 - OK!
This commit is contained in:
+3
-3
@@ -792,7 +792,7 @@ class PrimereModelControl:
|
||||
}
|
||||
|
||||
def get_primeremodelcontrol(self, **kwargs):
|
||||
model_concept = kwargs.pop('model_concept', 'SD1')
|
||||
model_concept = kwargs.pop('model_concept', None)
|
||||
model_name = kwargs.pop('model_name', None)
|
||||
concepts = kwargs.pop('concepts', 'Auto')
|
||||
models = kwargs.pop('models', 'Auto')
|
||||
@@ -800,7 +800,7 @@ class PrimereModelControl:
|
||||
scheduler_name = kwargs.pop('scheduler_name', comfy.samplers.KSampler.SCHEDULERS[0])
|
||||
steps = kwargs.pop('steps', 12)
|
||||
cfg = kwargs.pop('cfg', 7.0)
|
||||
active_concept = model_concept if concepts == "Auto" else concepts
|
||||
active_concept = model_concept if concepts == "Auto" and model_name is not None else concepts
|
||||
saved = {}
|
||||
if concepts == "Auto" and models == "Auto":
|
||||
raw_model = model_name
|
||||
@@ -827,7 +827,7 @@ class PrimereModelControl:
|
||||
else:
|
||||
active_display = active_concept
|
||||
|
||||
if kwargs.get('override_steps') == True:
|
||||
if kwargs.get('override_steps') == True and model_name is not None:
|
||||
found = re.findall(r"(?i)(\d+)step", model_name.lower())
|
||||
if found:
|
||||
steps = int(found[0])
|
||||
|
||||
@@ -182,7 +182,7 @@ app.registerExtension({
|
||||
setup() {
|
||||
app.api.addEventListener("primere.concept_setting", (event) => {
|
||||
const detail = event.detail;
|
||||
if (detail?.status === "missing" && detail.concept != null) {
|
||||
if (detail?.status === "missing" && detail.concept != null && detail.concept != 'Auto') {
|
||||
showToast("error", `No saved settings for model type "${detail.concept}". Current node values will be used.`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -299,6 +299,27 @@ function attachTitleHoverHandlers(node) {
|
||||
node.__primereTitleHoverBound = true;
|
||||
}
|
||||
|
||||
function attachTitleSerializationGuard(node) {
|
||||
if (!node || node.__primereTitleSerializeGuardBound) return;
|
||||
const prevOnSerialize = node.onSerialize;
|
||||
node.onSerialize = function (o) {
|
||||
if (typeof prevOnSerialize === "function") {
|
||||
prevOnSerialize.call(this, o);
|
||||
}
|
||||
if (!o || !Array.isArray(o.widgets_values) || !Array.isArray(this.widgets)) return;
|
||||
const titleIndexes = new Set();
|
||||
for (let i = 0; i < this.widgets.length; i++) {
|
||||
if (this.widgets[i]?.__primereTitleWidget) {
|
||||
titleIndexes.add(i);
|
||||
}
|
||||
}
|
||||
if (titleIndexes.size > 0) {
|
||||
o.widgets_values = o.widgets_values.filter((_, idx) => !titleIndexes.has(idx));
|
||||
}
|
||||
};
|
||||
node.__primereTitleSerializeGuardBound = true;
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: "Primere.TitleManager",
|
||||
|
||||
@@ -309,6 +330,7 @@ app.registerExtension({
|
||||
getNodeTitleConfig(nodeData.name).then((sections) => {
|
||||
insertTitleWidgets(node, sections);
|
||||
attachTitleHoverHandlers(node);
|
||||
attachTitleSerializationGuard(node);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -321,9 +343,16 @@ app.registerExtension({
|
||||
|
||||
const onConfigure = nodeType.prototype.onConfigure;
|
||||
nodeType.prototype.onConfigure = function (config) {
|
||||
if (config && Array.isArray(config.widgets_values)) {
|
||||
config.widgets_values = config.widgets_values.filter((v) => {
|
||||
if (typeof v !== "string") return true;
|
||||
return !/^─+\s.*\s─+$/.test(v.trim());
|
||||
});
|
||||
}
|
||||
onConfigure ? onConfigure.apply(this, [config]) : undefined;
|
||||
const node = this;
|
||||
setTimeout(() => applyTitleManager(node), 0);
|
||||
};
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user