Rev 206 | Rev 211 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 206 | Rev 210 | ||
---|---|---|---|
Line 63... | Line 63... | ||
63 | /* FIXME: not sure if we are supposed to dispose of handle */ |
63 | /* FIXME: not sure if we are supposed to dispose of handle */ |
64 | } |
64 | } |
65 | return str; |
65 | return str; |
66 | } |
66 | } |
67 | 67 | ||
- | 68 | // If parm is NULL, then it is standalone, otherwise it is the main plugin |
|
- | 69 | OSType getAeteKey(char c, PARM_T* parm) { |
|
- | 70 | // To make our plugin compatible with AppleScript, each key must |
|
- | 71 | // be unique, since the namespace is global! |
|
- | 72 | // Furthermore, the "uniqueID/scope" hstm-field in the PIPL must be empty. |
|
- | 73 | ||
- | 74 | if (parm != NULL) { |
|
- | 75 | unsigned long hash; |
|
- | 76 | char *data; |
|
- | 77 | // char* debug = malloc(2000); |
|
- | 78 | // sprintf(debug, "getAeteKey %c with title %s/%s in STANDALONE PLUGIN", c, INPLACEP2CSTR(parm->title), INPLACEP2CSTR(parm->category)); |
|
- | 79 | // simplealert(debug); |
|
- | 80 | ||
- | 81 | data = (char*)malloc(0x300); |
|
68 | /* return true if dialog should be shown */ |
82 | if (!data) return 'xxxx'; |
- | 83 | sprintf(data, "%s %s %c", |
|
- | 84 | INPLACEP2CSTR(parm->category), |
|
- | 85 | INPLACEP2CSTR(parm->title), |
|
- | 86 | c); |
|
- | 87 | hash = printablehash(djb2(data)); |
|
- | 88 | free(data); |
|
- | 89 | return hash; |
|
- | 90 | } else { |
|
- | 91 | // char* debug = malloc(2000); |
|
- | 92 | // sprintf(debug, "getAeteKey %c in MAIN PLUGIN", c); |
|
- | 93 | // simplealert(debug); |
|
- | 94 | ||
- | 95 | // Attention: AETE keys (xpr#, cTl#) must be equal in scripting.r, scripting.rc and scripting.c(getAeteKey)! |
|
- | 96 | if (c == 'R') return 'xprR'; |
|
- | 97 | if (c == 'G') return 'xprG'; |
|
- | 98 | if (c == 'B') return 'xprB'; |
|
- | 99 | if (c == 'A') return 'xprA'; |
|
- | 100 | return 'cTl0' + (c - '0'); |
|
- | 101 | } |
|
- | 102 | } |
|
69 | 103 | ||
- | 104 | /* return true if dialog should be shown */ |
|
70 | enum ScriptingShowDialog ReadScriptParamsOnRead(void) |
105 | enum ScriptingShowDialog ReadScriptParamsOnRead(void) |
71 | { |
106 | { |
72 | PIReadDescriptor token; |
107 | PIReadDescriptor token; |
73 | DescriptorKeyID key; |
108 | DescriptorKeyID key; |
74 | DescriptorTypeID type; |
109 | DescriptorTypeID type; |
Line 79... | Line 114... | ||
79 | 114 | ||
80 | if (DescriptorAvailable(NULL)){ /* playing back. Do our thing. */ |
115 | if (DescriptorAvailable(NULL)){ /* playing back. Do our thing. */ |
81 | token = OpenReader(array); |
116 | token = OpenReader(array); |
82 | if (token){ |
117 | if (token) { |
83 | while (PIGetKey(token, &key, &type, &flags)){ |
118 | while (PIGetKey(token, &key, &type, &flags)) { |
84 | switch (key){ |
119 | if (key == getAeteKey('R', gdata->standalone ? &gdata->parm : NULL)) { |
85 | case PARAM_R_KEY: expr[0] = get_cstring(token); break; |
120 | expr[0] = get_cstring(token); |
- | 121 | } else if (key == getAeteKey('G', gdata->standalone ? &gdata->parm : NULL)) { |
|
86 | case PARAM_G_KEY: expr[1] = get_cstring(token); break; |
122 | expr[1] = get_cstring(token); |
- | 123 | } else if (key == getAeteKey('B', gdata->standalone ? &gdata->parm : NULL)) { |
|
87 | case PARAM_B_KEY: expr[2] = get_cstring(token); break; |
124 | expr[2] = get_cstring(token); |
- | 125 | } else if (key == getAeteKey('A', gdata->standalone ? &gdata->parm : NULL)) { |
|
88 | case PARAM_A_KEY: expr[3] = get_cstring(token); break; |
126 | expr[3] = get_cstring(token); |
89 | default: |
127 | } else { |
- | 128 | int i; |
|
90 | if(key >= PARAM_CTL0_KEY && key <= PARAM_CTL7_KEY){ |
129 | for (i=0; i<=7; ++i) { |
- | 130 | if (key == getAeteKey('0'+i, gdata->standalone ? &gdata->parm : NULL)) { |
|
91 | PIGetInt(token,&v); |
131 | PIGetInt(token, &v); |
- | 132 | slider[i] = v; |
|
92 | slider[key - PARAM_CTL0_KEY] = v; |
133 | } |
93 | } |
134 | } |
94 | break; |
- | |
95 | } |
135 | } |
96 | } |
136 | } |
97 | 137 | ||
98 | /*stickyError =*/ CloseReader(&token); // closes & disposes. |
138 | /*stickyError =*/ CloseReader(&token); // closes & disposes. |
99 | 139 | ||
Line 117... | Line 157... | ||
117 | if (DescriptorAvailable(NULL)){ /* recording. Do our thing. */ |
157 | if (DescriptorAvailable(NULL)){ /* recording. Do our thing. */ |
118 | token = OpenWriter(); |
158 | token = OpenWriter(); |
119 | if (token){ |
159 | if (token){ |
120 | // write keys here |
160 | // write keys here |
121 | if(!gdata->standalone){ |
161 | if(!gdata->standalone){ |
122 | if (nplanes > 0) put_cstring(token, PARAM_R_KEY, expr[0]); |
162 | if (nplanes > 0) put_cstring(token, getAeteKey('R', gdata->standalone ? &gdata->parm : NULL), expr[0]); |
123 | if (nplanes > 1) put_cstring(token, PARAM_G_KEY, expr[1]); |
163 | if (nplanes > 1) put_cstring(token, getAeteKey('G', gdata->standalone ? &gdata->parm : NULL), expr[1]); |
124 | if (nplanes > 2) put_cstring(token, PARAM_B_KEY, expr[2]); |
164 | if (nplanes > 2) put_cstring(token, getAeteKey('B', gdata->standalone ? &gdata->parm : NULL), expr[2]); |
125 | if (nplanes > 3) put_cstring(token, PARAM_A_KEY, expr[3]); |
165 | if (nplanes > 3) put_cstring(token, getAeteKey('A', gdata->standalone ? &gdata->parm : NULL), expr[3]); |
126 | } |
166 | } |
127 | 167 | ||
128 | /* only write values for the sliders that are actually used! */ |
168 | /* only write values for the sliders that are actually used! */ |
129 | allctls = checksliders(4,ctls,maps); |
169 | allctls = checksliders(4,ctls,maps); |
130 | for(i = 0; i < 8; ++i) |
170 | for (i=0; i<=7; ++i) { |
131 | if(allctls || ctls[i]) |
171 | if (allctls || ctls[i]) { |
132 | PIPutInt(token, PARAM_CTL0_KEY+i, slider[i]); |
172 | PIPutInt(token, getAeteKey('0'+i, gdata->standalone ? &gdata->parm : NULL), slider[i]); |
- | 173 | } |
|
- | 174 | } |
|
133 | 175 | ||
134 | gotErr = CloseWriter(&token); /* closes and sets dialog optional */ |
176 | gotErr = CloseWriter(&token); /* closes and sets dialog optional */ |
135 | /* done. Now pass handle on to Photoshop */ |
177 | /* done. Now pass handle on to Photoshop */ |
136 | } |
178 | } |
137 | } |
179 | } |