diff --git a/sdppp_python/comfy/nodes.py b/sdppp_python/comfy/nodes.py index 5727a6b..06df5d2 100644 --- a/sdppp_python/comfy/nodes.py +++ b/sdppp_python/comfy/nodes.py @@ -192,12 +192,8 @@ def define_comfyui_nodes(sdpppServer): @classmethod def IS_CHANGED(self, **kwargs): sdppp_arg = kwargs['sdppp'] - try: - if kwargs['document_name']['identify'] == '### Active Document ###' or kwargs['document_name']['identify'] == '### 当前文档 ###': - return sdppp_is_changed(sdpppServer, sdppp_arg, 'selectionStateID') - finally: - return sdppp_is_changed(sdpppServer, sdppp_arg, '') - + return sdppp_is_changed(sdpppServer, sdppp_arg, '') + @classmethod def INPUT_TYPES(cls): return { @@ -237,11 +233,7 @@ def define_comfyui_nodes(sdpppServer): sdppp_arg = kwargs['sdppp'] document_arg = kwargs['document'] - try: - if kwargs['layer_or_group'] == '### Selected Layer ###' or kwargs['layer_or_group'] == '### 所选图层 ###': - return sdppp_is_changed(sdpppServer, sdppp_arg, document_arg, 'selectionStateID') - finally: - return sdppp_is_changed(sdpppServer, sdppp_arg, document_arg) + return sdppp_is_changed(sdpppServer, sdppp_arg, document_arg) @classmethod def INPUT_TYPES(cls): diff --git a/typescripts/modules/comfy/src/litegraph/fe-widgets.mts b/typescripts/modules/comfy/src/litegraph/fe-widgets.mts index 265fdaf..c342985 100644 --- a/typescripts/modules/comfy/src/litegraph/fe-widgets.mts +++ b/typescripts/modules/comfy/src/litegraph/fe-widgets.mts @@ -63,9 +63,16 @@ export class DocumentWidget extends SDPPPComboWidget { instance_id: i18n('document {0} not found', documentWidget.value), identify: '' }); + let identify = data.identify; + if (SpeicialIDManager.is_SPECIAL_DOCUMENT_CURRENT(identify)) { + const ret = await ComfySocket.instance.getSpecialIdentifierValue(data.instance_id, { + identifier: identify + }) + identify = ret.value; + } return JSON.stringify({ instance_id: data.instance_id, - identify: data.identify + identify: identify }); } node.size = [size[0], Math.max(size[1], node.size[1])]; @@ -133,11 +140,29 @@ export class LayerWidget extends SDPPPComboWidget { value = SpeicialIDManager.fixI18n(value); } }) + layerWidget.serializeValue = async () => { + const documentWidget = this.documentWidgetByLinked; + if (!documentWidget) return layerWidget.value; + + const document = parseDocumentOption(documentWidget.widget.value); + if (!document) return layerWidget.value + + let identify = layerWidget.value; + if (SpeicialIDManager.is_SPECIAL_LAYER_SELECTED_LAYER(identify)) { + const ret = await ComfySocket.instance.getSpecialIdentifierValue(document.instance_id, { + identifier: identify + }) + identify = ret.value; + } + return identify; + } } static create(node: any, name: I18nKey, options: LayerWidgetWithDocumentSelectionCtorOptions) { const size = node.size.slice(0); const layerWidget = node.addWidget('combo', name, options.extraOptions[0] || '', () => { }, { forceInput: true, values: options.extraOptions }) - + // layerWidget.serializeValue = async () => { + // this.documentWidgetByLinked + // } node.size = [size[0], Math.max(size[1], node.size[1])]; return new LayerWidgetWithDocumentSelection(node, layerWidget, { @@ -203,6 +228,22 @@ export class LayerWidgetWithDocumentSelection extends LayerWidget { const documentWidget = this.documentWidgetInNode || this.documentWidgetByLinked; documentWidget?.selectConcreteDocument(); }) + layerWidget.serializeValue = async () => { + const documentWidget = this.documentWidgetInNode || this.documentWidgetByLinked; + if (!documentWidget) return layerWidget.value; + + const document = parseDocumentOption(documentWidget.widget.value); + if (!document) return layerWidget.value + + let identify = layerWidget.value; + if (SpeicialIDManager.is_SPECIAL_LAYER_SELECTED_LAYER(identify)) { + const ret = await ComfySocket.instance.getSpecialIdentifierValue(document.instance_id, { + identifier: identify + }) + identify = ret.value; + } + return identify; + } this.documentWidgetInNode?.onChange(this.update) } public override update() { diff --git a/typescripts/modules/photoshop-internal b/typescripts/modules/photoshop-internal index 1725546..ace712e 160000 --- a/typescripts/modules/photoshop-internal +++ b/typescripts/modules/photoshop-internal @@ -1 +1 @@ -Subproject commit 17255469f345fa60de425cf70c7906acfdcd0d31 +Subproject commit ace712eb985a34d37cc846630e2308303c7d1acc diff --git a/typescripts/src/socket/PhotoshopCalleeInterface.mts b/typescripts/src/socket/PhotoshopCalleeInterface.mts index 86bf0cb..3a663f9 100644 --- a/typescripts/src/socket/PhotoshopCalleeInterface.mts +++ b/typescripts/src/socket/PhotoshopCalleeInterface.mts @@ -152,6 +152,17 @@ export interface RunPhotoshopActionActions { } } +// =========== getSpecialIdentifierValue Interfaces =========== +export interface getSpecialIdentifierValueActions { + params: { + identifier: string + width?: number, + height?: number + }, + result: { + value: string + } +} // Main interface that aggregates all action types export interface PhotoshopCalleeActions { psd: PSDActions; @@ -165,6 +176,7 @@ export interface PhotoshopCalleeActions { getLinkedLayers: LayerReducerActions; getLayersInGroup: LayerReducerActions; runPhotoshopAction: RunPhotoshopActionActions; + getSpecialIdentifierValue: getSpecialIdentifierValueActions; } // // PhotoshopCaller actions interface (referenced in PhotoshopCallee) diff --git a/typescripts/src/socket/PhotoshopCaller.mts b/typescripts/src/socket/PhotoshopCaller.mts index 8f0684d..ce841ad 100644 --- a/typescripts/src/socket/PhotoshopCaller.mts +++ b/typescripts/src/socket/PhotoshopCaller.mts @@ -86,6 +86,18 @@ export function PhotoshopCallerSocket(SocketClass: SocketConstructor) { }); }); } + + public async getSpecialIdentifierValue(sid: string, payload: PhotoshopCalleeActions['getSpecialIdentifierValue']['params']) { + return new Promise((resolve, reject) => { + this.socket.emit('B_photoshop', { + action: 'getSpecialIdentifierValue', + sid: sid, + params: payload + }, (data: any) => { + data && data.error ? reject(new Error(data.error)) : resolve(data); + }); + }); + } } } diff --git a/typescripts/src/socket/PhotoshopCallerInterface.mts b/typescripts/src/socket/PhotoshopCallerInterface.mts index 340dd6a..a931bd1 100644 --- a/typescripts/src/socket/PhotoshopCallerInterface.mts +++ b/typescripts/src/socket/PhotoshopCallerInterface.mts @@ -5,6 +5,7 @@ export interface PhotoshopCaller { exportPSDDataURLToPhotoshop(sid: string, document_identify: string, dataURL: string, fromSSID: string): Promise; getImage(sid: string, payload: PhotoshopCalleeActions['getImage']['params']): Promise; sendImage(sid: string, payload: PhotoshopCalleeActions['sendImages']['params']): Promise; + getSpecialIdentifierValue(sid: string, payload: PhotoshopCalleeActions['getSpecialIdentifierValue']['params']): Promise; } export interface PhotoshopCallerActions { @@ -24,5 +25,6 @@ export interface PhotoshopCallerActions { type: string; subfolder: string; } - } + }, + } \ No newline at end of file