Rev 536 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 536 | Rev 550 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop |
2 | This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop |
3 | Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.net |
3 | Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.net |
4 | Copyright (C) 2018-2022 Daniel Marschall, ViaThinkSoft |
4 | Copyright (C) 2018-2023 Daniel Marschall, ViaThinkSoft |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify |
6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by |
7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. |
9 | (at your option) any later version. |
Line 121... | Line 121... | ||
121 | 121 | ||
122 | if (DescriptorAvailable(NULL)) { /* playing back. Do our thing. */ |
122 | if (DescriptorAvailable(NULL)) { /* playing back. Do our thing. */ |
123 | token = OpenReader(array); |
123 | token = OpenReader(array); |
124 | if (token) { |
124 | if (token) { |
125 | while (PIGetKey(token, &key, &type, &flags)) { |
125 | while (PIGetKey(token, &key, &type, &flags)) { |
126 | if (key == getAeteKey('R', gdata->standalone ? &gdata->parm : NULL)) { |
126 | if (key == getAeteKey('R', gdata->parm.standalone ? &gdata->parm : NULL)) { |
127 | if (expr[0]) free(expr[0]); |
127 | char *tmp = get_cstring(token); |
128 | expr[0] = get_cstring(token); |
128 | strcpy(gdata->parm.szFormula[0], tmp); |
- | 129 | free(tmp); |
|
129 | } |
130 | } |
130 | else if (key == getAeteKey('G', gdata->standalone ? &gdata->parm : NULL)) { |
131 | else if (key == getAeteKey('G', gdata->parm.standalone ? &gdata->parm : NULL)) { |
131 | if (expr[1]) free(expr[1]); |
132 | char* tmp = get_cstring(token); |
132 | expr[1] = get_cstring(token); |
133 | strcpy(gdata->parm.szFormula[1], tmp); |
- | 134 | free(tmp); |
|
133 | } |
135 | } |
134 | else if (key == getAeteKey('B', gdata->standalone ? &gdata->parm : NULL)) { |
136 | else if (key == getAeteKey('B', gdata->parm.standalone ? &gdata->parm : NULL)) { |
135 | if (expr[2]) free(expr[2]); |
137 | char* tmp = get_cstring(token); |
136 | expr[2] = get_cstring(token); |
138 | strcpy(gdata->parm.szFormula[2], tmp); |
- | 139 | free(tmp); |
|
137 | } |
140 | } |
138 | else if (key == getAeteKey('A', gdata->standalone ? &gdata->parm : NULL)) { |
141 | else if (key == getAeteKey('A', gdata->parm.standalone ? &gdata->parm : NULL)) { |
139 | if (expr[3]) free(expr[3]); |
142 | char* tmp = get_cstring(token); |
140 | expr[3] = get_cstring(token); |
143 | strcpy(gdata->parm.szFormula[3], tmp); |
- | 144 | free(tmp); |
|
141 | } |
145 | } |
142 | else { |
146 | else { |
143 | int i; |
147 | int i; |
144 | for (i = 0; i <= 7; ++i) { |
148 | for (i = 0; i <= 7; ++i) { |
145 | if (key == getAeteKey((char)('0'+i), gdata->standalone ? &gdata->parm : NULL)) { |
149 | if (key == getAeteKey((char)('0'+i), gdata->parm.standalone ? &gdata->parm : NULL)) { |
146 | PIGetInt(token, &v); |
150 | PIGetInt(token, &v); |
147 | if (v < 0) v = 0; |
151 | if (v < 0) v = 0; |
148 | else if (v > 255) v = 255; |
152 | else if (v > 255) v = 255; |
149 | slider[i] = (uint8_t)v; |
153 | gdata->parm.val[i] = (uint8_t)v; |
150 | } |
154 | } |
151 | } |
155 | } |
152 | } |
156 | } |
153 | } |
157 | } |
154 | 158 | ||
Line 167... | Line 171... | ||
167 | 171 | ||
168 | OSErr WriteScriptParamsOnRead(void) |
172 | OSErr WriteScriptParamsOnRead(void) |
169 | { |
173 | { |
170 | PIWriteDescriptor token; |
174 | PIWriteDescriptor token; |
171 | OSErr gotErr = noErr; |
175 | OSErr gotErr = noErr; |
172 | extern int ctls[], maps[], nplanes; |
176 | extern int nplanes; |
173 | int i, allctls; |
177 | int i, allctls; |
174 | 178 | ||
175 | if (DescriptorAvailable(NULL)) { /* recording. Do our thing. */ |
179 | if (DescriptorAvailable(NULL)) { /* recording. Do our thing. */ |
176 | // 1. Call openWriteDescriptorProc which will return a PIWriteDescriptor token, such as writeToken. |
180 | // 1. Call openWriteDescriptorProc which will return a PIWriteDescriptor token, such as writeToken. |
177 | token = OpenWriter(); |
181 | token = OpenWriter(); |
178 | if (token) { |
182 | if (token) { |
179 | // 2. Call various Put routines such as PutIntegerProc, PutFloatProc, etc., to add key/value pairs to writeToken. The keys and value types must correspond to those in your terminology resource. |
183 | // 2. Call various Put routines such as PutIntegerProc, PutFloatProc, etc., to add key/value pairs to writeToken. The keys and value types must correspond to those in your terminology resource. |
180 | 184 | ||
181 | // write keys here |
185 | // write keys here |
182 | if (!gdata->standalone) { |
186 | if (!gdata->parm.standalone) { |
183 | if (nplanes > 0) put_cstring(token, getAeteKey('R', gdata->standalone ? &gdata->parm : NULL), expr[0]); |
187 | if (nplanes > 0) put_cstring(token, getAeteKey('R', gdata->parm.standalone ? &gdata->parm : NULL), gdata->parm.szFormula[0]); |
184 | if (nplanes > 1) put_cstring(token, getAeteKey('G', gdata->standalone ? &gdata->parm : NULL), expr[1]); |
188 | if (nplanes > 1) put_cstring(token, getAeteKey('G', gdata->parm.standalone ? &gdata->parm : NULL), gdata->parm.szFormula[1]); |
185 | if (nplanes > 2) put_cstring(token, getAeteKey('B', gdata->standalone ? &gdata->parm : NULL), expr[2]); |
189 | if (nplanes > 2) put_cstring(token, getAeteKey('B', gdata->parm.standalone ? &gdata->parm : NULL), gdata->parm.szFormula[2]); |
186 | if (nplanes > 3) put_cstring(token, getAeteKey('A', gdata->standalone ? &gdata->parm : NULL), expr[3]); |
190 | if (nplanes > 3) put_cstring(token, getAeteKey('A', gdata->parm.standalone ? &gdata->parm : NULL), gdata->parm.szFormula[3]); |
187 | } |
191 | } |
188 | 192 | ||
189 | /* only write values for the sliders that are actually used! */ |
193 | /* only write values for the sliders that are actually used! */ |
190 | allctls = checksliders(4, ctls, maps); |
194 | allctls = checksliders(4); |
191 | for (i = 0; i <= 7; ++i) { |
195 | for (i = 0; i < 8; ++i) { |
192 | if (allctls || ctls[i]) { |
196 | if (allctls || gdata->parm.ctl_used[i]) { |
193 | PIPutInt(token, getAeteKey((char)('0'+i), gdata->standalone ? &gdata->parm : NULL), slider[i]); |
197 | PIPutInt(token, getAeteKey((char)('0'+i), gdata->parm.standalone ? &gdata->parm : NULL), gdata->parm.val[i]); |
194 | } |
198 | } |
195 | } |
199 | } |
196 | 200 | ||
197 | gotErr = CloseWriter(&token); /* closes and sets dialog optional */ |
201 | gotErr = CloseWriter(&token); /* closes and sets dialog optional */ |
198 | /* done. Now pass handle on to Photoshop */ |
202 | /* done. Now pass handle on to Photoshop */ |