Rev 537 | Rev 541 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 537 | Rev 539 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ |
19 | */ |
20 | 20 | ||
21 | #include "ff.h" |
21 | #include "ff.h" |
22 | 22 | ||
- | 23 | #include "version.h" |
|
- | 24 | #include "time.h" |
|
23 | #include "file_compat.h" |
25 | #include "file_compat.h" |
24 | #include "sprintf_tiny.h" |
26 | #include "sprintf_tiny.h" |
25 | 27 | ||
26 | #define CHOPLINES 63 |
28 | #define CHOPLINES 63 |
27 | 29 | ||
Line 200... | Line 202... | ||
200 | 202 | ||
201 | return e; |
203 | return e; |
202 | } |
204 | } |
203 | 205 | ||
204 | OSErr saveparams_guf(Handle h, Boolean useparm) { |
206 | OSErr saveparams_guf(Handle h, Boolean useparm) { |
- | 207 | extern int ctls[], maps[]; |
|
- | 208 | ||
- | 209 | char* p, * start; |
|
- | 210 | int i; |
|
- | 211 | OSErr e; |
|
- | 212 | size_t est; |
|
- | 213 | ||
- | 214 | if (!h) return nilHandleErr; |
|
- | 215 | ||
- | 216 | est = strlen(expr[0]) + strlen(expr[1]) + strlen(expr[2]) + strlen(expr[3]); |
|
- | 217 | // do not be tempted to combine into one expression: 'est' is referenced below |
|
- | 218 | est += 16000; |
|
- | 219 | ||
- | 220 | // TODO: Encode the file in UTF-8! (German Umlauts, etc.) |
|
- | 221 | ||
- | 222 | PIUNLOCKHANDLE(h); // should not be necessary |
|
- | 223 | if (!(e = PISETHANDLESIZE(h, (int32)(est))) && (p = start = PILOCKHANDLE(h, false))) { |
|
- | 224 | char strBuildDate[11/*strlen("0000-00-00") + 1*/]; |
|
- | 225 | time_t iBuildDate = time(0); |
|
- | 226 | strftime(strBuildDate, 100, "%Y-%m-%d", localtime(&iBuildDate)); |
|
- | 227 | ||
- | 228 | checksliders(4, ctls, maps); |
|
- | 229 | ||
- | 230 | // Metadata |
|
- | 231 | p += sprintf(p, "# Created with Filter Foundry %s\r\n", VERSION_STR); |
|
- | 232 | p += sprintf(p, "\r\n"); |
|
- | 233 | p += sprintf(p, "[GUF]\r\n"); |
|
- | 234 | p += sprintf(p, "Protocol=1\r\n"); |
|
- | 235 | p += sprintf(p, "\r\n"); |
|
- | 236 | p += sprintf(p, "[Info]\r\n"); |
|
- | 237 | p += sprintf(p, "Category=<Image>/Filter Factory/%s\r\n", useparm ? gdata->parm.szCategory : "..."); |
|
- | 238 | p += sprintf(p, "Title=%s\r\n", useparm ? gdata->parm.szTitle : "..."); |
|
- | 239 | p += sprintf(p, "Copyright=%s\r\n", useparm ? gdata->parm.szCopyright : "..."); |
|
- | 240 | p += sprintf(p, "Author=%s\r\n", useparm ? gdata->parm.szAuthor : "..."); |
|
- | 241 | p += sprintf(p, "\r\n"); |
|
- | 242 | p += sprintf(p, "[Version]\r\n"); |
|
- | 243 | p += sprintf(p, "Major=1\r\n"); |
|
- | 244 | p += sprintf(p, "Minor=0\r\n"); |
|
- | 245 | p += sprintf(p, "Micro=0\r\n"); |
|
- | 246 | p += sprintf(p, "\r\n"); |
|
- | 247 | p += sprintf(p, "[Filter Factory]\r\n"); |
|
- | 248 | p += sprintf(p, "8bf=%s\r\n", useparm ? "Untitled.8bf" : "Untitled.8bf"); // TODO: get .guf filename and change .guf to .8bf |
|
- | 249 | p += sprintf(p, "\r\n"); |
|
- | 250 | p += sprintf(p, "[Gimp]\r\n"); |
|
- | 251 | p += sprintf(p, "Registered=false\r\n"); |
|
- | 252 | p += sprintf(p, "Description=%s\r\n", useparm ? gdata->parm.szTitle : "..."); |
|
- | 253 | p += sprintf(p, "EdgeMode=2\r\n"); |
|
- | 254 | p += sprintf(p, "Date=%s\r\n", strBuildDate); |
|
- | 255 | p += sprintf(p, "\r\n"); |
|
- | 256 | ||
205 | // TODO: implement |
257 | if (useparm) { |
- | 258 | for (i = 0; i < 8; i++) { |
|
- | 259 | p += sprintf(p, "[Control %d]\r\n", i); |
|
- | 260 | p += sprintf(p, "Enabled=%s\r\n", gdata->parm.ctl_used[i] ? "true" : "false"); |
|
- | 261 | p += sprintf(p, "Label=%s\r\n", gdata->parm.szCtl[i]); |
|
- | 262 | p += sprintf(p, "Preset=%d\r\n", gdata->parm.val[i]); |
|
- | 263 | p += sprintf(p, "Step=1\r\n"); |
|
- | 264 | p += sprintf(p, "\r\n"); |
|
- | 265 | } |
|
- | 266 | for (i = 0; i < 4; i++) { |
|
- | 267 | p += sprintf(p, "[Map %d]\r\n", i); |
|
- | 268 | p += sprintf(p, "Enabled=%s\r\n", gdata->parm.map_used[i] ? "true" : "false"); |
|
- | 269 | p += sprintf(p, "Label=%s\r\n", gdata->parm.szMap[i]); |
|
- | 270 | p += sprintf(p, "\r\n"); |
|
- | 271 | } |
|
- | 272 | } |
|
- | 273 | else { |
|
- | 274 | for (i = 0; i < 8; i++) { |
|
- | 275 | p += sprintf(p, "[Control %d]\r\n", i); |
|
- | 276 | p += sprintf(p, "Enabled=%s\r\n", ctls[i] ? "true" : "false"); |
|
- | 277 | p += sprintf(p, "Label=%s\r\n", "..."); |
|
- | 278 | p += sprintf(p, "Preset=%d\r\n", slider[i]); |
|
- | 279 | p += sprintf(p, "Step=1\r\n"); |
|
- | 280 | p += sprintf(p, "\r\n"); |
|
- | 281 | } |
|
- | 282 | for (i = 0; i < 4; i++) { |
|
- | 283 | p += sprintf(p, "[Map %d]\r\n", i); |
|
- | 284 | p += sprintf(p, "Enabled=%s\r\n", maps[i] ? "true" : "false"); |
|
- | 285 | p += sprintf(p, "Label=%s\r\n", "..."); |
|
- | 286 | p += sprintf(p, "\r\n"); |
|
- | 287 | } |
|
- | 288 | } |
|
- | 289 | ||
- | 290 | p += sprintf(p, "[Code]\r\n"); |
|
- | 291 | p += sprintf(p, "R=%s\r\n", useparm ? gdata->parm.szFormula[0] : expr[0]); |
|
- | 292 | p += sprintf(p, "G=%s\r\n", useparm ? gdata->parm.szFormula[1] : expr[1]); |
|
- | 293 | p += sprintf(p, "B=%s\r\n", useparm ? gdata->parm.szFormula[2] : expr[2]); |
|
- | 294 | p += sprintf(p, "A=%s\r\n", useparm ? gdata->parm.szFormula[3] : expr[3]); |
|
- | 295 | ||
- | 296 | PIUNLOCKHANDLE(h); |
|
- | 297 | e = PISETHANDLESIZE(h, (int32)(p - start)); // could ignore this error, maybe |
|
- | 298 | } |
|
- | 299 | ||
206 | return NULL; |
300 | return e; |
207 | } |
301 | } |
208 | 302 | ||
209 | OSErr savehandleintofile(Handle h,FILEREF r){ |
303 | OSErr savehandleintofile(Handle h,FILEREF r){ |
210 | Ptr p; |
304 | Ptr p; |
211 | FILECOUNT n; |
305 | FILECOUNT n; |