Menu settings updates

This commit is contained in:
Kijai 2024-04-08 13:22:10 +03:00
parent 0d46ee8866
commit 10d4debafc
3 changed files with 34 additions and 10 deletions

View File

@ -82,8 +82,8 @@ app.registerExtension({
};
app.ui.settings.addSetting({
id: "KJNodes.SetGetMenu",
name: "🔗💥⛓️ Make Set/Get -nodes defaults (turn off and reload to disable)",
id: "🦛 KJNodes.SetGetMenu",
name: "🦛 KJNodes: Make Set/Get -nodes defaults (turn off and reload to disable)",
defaultValue: false,
type: "boolean",
options: (value) => [
@ -103,7 +103,7 @@ app.registerExtension({
});
app.ui.settings.addSetting({
id: "KJNodes.DisableMiddleClickDefault",
name: "Middle click default node adding",
name: "🦛 KJNodes: Middle click default node adding",
defaultValue: false,
type: "boolean",
options: (value) => [
@ -116,15 +116,33 @@ app.registerExtension({
});
app.ui.settings.addSetting({
id: "KJNodes.nodeAutoColor",
name: "Automatically set node colors",
name: "🦛 KJNodes: Automatically set node colors",
defaultValue: true,
type: "boolean",
options: (value) => [
{ value: true, text: "On", selected: value === true },
{ value: false, text: "Off", selected: value === false },
],
// onChange: (value) => {
// },
});
app.ui.settings.addSetting({
id: "KJNodes.helpPopup",
name: "🦛 KJNodes: Help popups",
defaultValue: true,
type: "boolean",
options: (value) => [
{ value: true, text: "On", selected: value === true },
{ value: false, text: "Off", selected: value === false },
],
});
app.ui.settings.addSetting({
id: "KJNodes.disablePrefix",
name: "🦛 KJNodes: Disable automatic Set_ and Get_ prefix",
defaultValue: false,
type: "boolean",
options: (value) => [
{ value: true, text: "On", selected: value === true },
{ value: false, text: "Off", selected: value === false },
],
});
}
});

View File

@ -27,7 +27,7 @@ export const loadScript = (
scriptEle.addEventListener('error', (ev) => {
reject({
status: false,
message: `Failed to load the script {FILE_URL}`,
message: `Failed to load the script ${FILE_URL}`,
})
})
@ -48,6 +48,11 @@ loadScript('/kjweb_async/purify.min.js').catch((e) => {
app.registerExtension({
name: "KJNodes.HelpPopup",
async beforeRegisterNodeDef(nodeType, nodeData) {
if (app.ui.settings.getSettingValue("KJNodes.helpPopup") === false) {
return;
}
const categories = ["KJNodes", "SUPIR", "VoiceCraft", "Marigold"];
try {
categories.forEach(category => {

View File

@ -26,6 +26,7 @@ function setColorAndBgColor(type) {
}
}
let isAlertShown = false;
let disablePrefix = app.ui.settings.getSettingValue("KJNodes.disablePrefix")
function showAlertWithThrottle(message, delay) {
if (!isAlertShown) {
@ -57,7 +58,7 @@ app.registerExtension({
(s, t, u, v, x) => {
node.validateName(node.graph);
if(this.widgets[0].value !== ''){
this.title = "Set_" + this.widgets[0].value;
this.title = (!disablePrefix ? "Set_" : "") + this.widgets[0].value;
}
this.update();
this.properties.previousName = this.widgets[0].value;
@ -96,7 +97,7 @@ app.registerExtension({
const type = fromNode.outputs[link_info.origin_slot].type;
if (this.title === "Set"){
this.title = "Set_" + type;
this.title = (!disablePrefix ? "Set_" : "") + type;
}
if (this.widgets[0].value === '*'){
this.widgets[0].value = type
@ -278,7 +279,7 @@ app.registerExtension({
let linkType = (setter.inputs[0].type);
this.setType(linkType);
this.title = "Get_" + setter.widgets[0].value;
this.title = (!disablePrefix ? "Get_" : "") + setter.widgets[0].value;
if (app.ui.settings.getSettingValue("KJNodes.nodeAutoColor")){
setColorAndBgColor.call(this, linkType);