Subversion Repositories filter_foundry

Rev

Rev 433 | Rev 445 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 433 Rev 444
Line 223... Line 223...
223
        for(i = 0; i < nplanes; i++)
223
        for(i = 0; i < nplanes; i++)
224
                if(!tree[i]){
224
                if(!tree[i]){
225
                        /* uh oh, couldn't parse one of the saved expressions...this is fatal */
225
                        /* uh oh, couldn't parse one of the saved expressions...this is fatal */
226
                        DISABLEDLGITEM(dp,IDOK);
226
                        DISABLEDLGITEM(dp,IDOK);
227
                        if(gdata->standalone){
227
                        if(gdata->standalone){
228
                                alertuser(_strdup("Can't run this filter (there is a problem with the saved expressions)."),_strdup(""));
228
                                alertuser((TCHAR*)TEXT("Can't run this filter (there is a problem with the saved expressions)."), (TCHAR*)TEXT(""));
229
                        }else{
229
                        }else{
230
                                DISABLEDLGITEM(dp,SAVEITEM);
230
                                DISABLEDLGITEM(dp,SAVEITEM);
231
                                DISABLEDLGITEM(dp,MAKEITEM);
231
                                DISABLEDLGITEM(dp,MAKEITEM);
232
                        }
232
                        }
233
                        return;
233
                        return;
Line 257... Line 257...
257
                "DA", "LabA"
257
                "DA", "LabA"
258
        };
258
        };
259
 
259
 
260
        /* hide unused expression items */
260
        /* hide unused expression items */
261
        if(gdata->standalone){
261
        if(gdata->standalone){
262
                SetDlgItemText(dp,PARAMAUTHORITEM,gdata->parm.szAuthor);
262
                SetDlgItemTextA(dp,PARAMAUTHORITEM,gdata->parm.szAuthor);
263
                SetDlgItemText(dp,PARAMCOPYITEM,gdata->parm.szCopyright);
263
                SetDlgItemTextA(dp,PARAMCOPYITEM,gdata->parm.szCopyright);
264
 
264
 
265
                // update labels for map() or ctl() sliders
265
                // update labels for map() or ctl() sliders
266
                for(i = 0; i < 8; ++i){
266
                for(i = 0; i < 8; ++i){
267
                        if(gdata->parm.map_used[i/2]){
267
                        if(gdata->parm.map_used[i/2]){
268
                                if((i&1) == 0){
268
                                if((i&1) == 0){
269
                                        // even (0, 2, 4, 6)
269
                                        // even (0, 2, 4, 6)
270
                                        strcpy(s,gdata->parm.szMap[i/2]);
270
                                        strcpy(s,gdata->parm.szMap[i/2]);
271
                                        SetDlgItemText(dp, FIRSTMAPLABELITEM+(i/2),s);
271
                                        SetDlgItemTextA(dp, FIRSTMAPLABELITEM+(i/2),s);
272
                                        HideDialogItem(dp, FIRSTCTLLABELITEM + i);
272
                                        HideDialogItem(dp, FIRSTCTLLABELITEM + i);
273
                                        HideDialogItem(dp, FIRSTCTLLABELITEM + i + 1);
273
                                        HideDialogItem(dp, FIRSTCTLLABELITEM + i + 1);
274
                                }
274
                                }
275
                        } else if(gdata->parm.ctl_used[i]){
275
                        } else if(gdata->parm.ctl_used[i]){
276
                                strcpy(s,gdata->parm.szCtl[i]);
276
                                strcpy(s,gdata->parm.szCtl[i]);
277
                                SetDlgItemText(dp, FIRSTCTLLABELITEM+i,s);
277
                                SetDlgItemTextA(dp, FIRSTCTLLABELITEM+i,s);
278
                                HideDialogItem(dp, FIRSTMAPLABELITEM + i/2);
278
                                HideDialogItem(dp, FIRSTMAPLABELITEM + i/2);
279
                        }else{
279
                        }else{
280
                                HideDialogItem(dp, FIRSTCTLITEM+i);
280
                                HideDialogItem(dp, FIRSTCTLITEM+i);
281
                                HideDialogItem(dp, FIRSTCTLTEXTITEM+i);
281
                                HideDialogItem(dp, FIRSTCTLTEXTITEM+i);
282
                                HideDialogItem(dp, FIRSTCTLLABELITEM + i);
282
                                HideDialogItem(dp, FIRSTCTLLABELITEM + i);
Line 291... Line 291...
291
                        HideDialogItem(dp,FIRSTICONITEM+i);
291
                        HideDialogItem(dp,FIRSTICONITEM+i);
292
                        HideDialogItem(dp,FIRSTEXPRITEM+i);
292
                        HideDialogItem(dp,FIRSTEXPRITEM+i);
293
                        HideDialogItem(dp,FIRSTLABELITEM+i);
293
                        HideDialogItem(dp,FIRSTLABELITEM+i);
294
                }else{
294
                }else{
295
                        s[0] = channelsuffixes[gpb->imageMode][i];
295
                        s[0] = channelsuffixes[gpb->imageMode][i];
296
                        SetDlgItemText(dp,FIRSTLABELITEM+i,s);
296
                        SetDlgItemTextA(dp,FIRSTLABELITEM+i,s);
297
                }
297
                }
298
        }
298
        }
299
 
299
 
300
        if(setup_preview(gpb,nplanes)){
300
        if(setup_preview(gpb,nplanes)){
301
                // On very large images, processing a fully zoomed out preview (the initial default)
301
                // On very large images, processing a fully zoomed out preview (the initial default)
Line 355... Line 355...
355
                return false; // end dialog
355
                return false; // end dialog
356
        case OPENITEM:
356
        case OPENITEM:
357
                if(!gdata->standalone && choosefiletypes(
357
                if(!gdata->standalone && choosefiletypes(
358
                        #ifdef MAC_ENV
358
                        #ifdef MAC_ENV
359
                        (StringPtr)_strdup("\pChoose filter settings"), // "\p" means "Pascal string"
359
                        (StringPtr)_strdup("\pChoose filter settings"), // "\p" means "Pascal string"
360
                        #else
-
 
361
                        (StringPtr)_strdup("\026Choose filter settings"),
-
 
362
                        #endif
-
 
363
                        &sfr,&reply,types,2,
360
                        & sfr, & reply, types, 2,
364
                        "All supported files (*.afs, *.8bf, *.pff, *.prm, *.bin, *.rsrc, *.txt, *.ffx)\0*.afs;*.8bf;*.pff;*.prm;*.bin;*.rsrc;*.txt;*.ffx\0Filter Factory Settings (*.afs, *.txt)\0*.afs;*.txt\0PluginCommander or FFDecomp TXT file (*.txt)\0*.txt\0Filter Factory for Windows, Standalone Filter (*.8bf)\0*.8bf\0Premiere TF/FF Settings (*.pff)\0*.pff\0Premiere TT/FF for Windows, Standalone Filter (*.prm)\0*.prm\0FilterFactory for MacOS, Standalone Filter (*.bin, *.rsrc)\0*.bin\0\"Filters Unlimited\" filter (*.ffx)\0*.ffx\0All files (*.*)\0*.*\0\0"
361
                        "All supported files (*.afs, *.8bf, *.pff, *.prm, *.bin, *.rsrc, *.txt, *.ffx)\0*.afs;*.8bf;*.pff;*.prm;*.bin;*.rsrc;*.txt;*.ffx\0Filter Factory Settings (*.afs, *.txt)\0*.afs;*.txt\0PluginCommander or FFDecomp TXT file (*.txt)\0*.txt\0Filter Factory for Windows, Standalone Filter (*.8bf)\0*.8bf\0Premiere TF/FF Settings (*.pff)\0*.pff\0Premiere TT/FF for Windows, Standalone Filter (*.prm)\0*.prm\0FilterFactory for MacOS, Standalone Filter (*.bin, *.rsrc)\0*.bin\0\"Filters Unlimited\" filter (*.ffx)\0*.ffx\0All files (*.*)\0*.*\0\0"
-
 
362
                        #else
-
 
363
                        TEXT("Choose filter settings"),
-
 
364
                        & sfr, & reply, types, 2,
365
                        #ifdef _WIN32
365
                        TEXT("All supported files (*.afs, *.8bf, *.pff, *.prm, *.bin, *.rsrc, *.txt, *.ffx)\0*.afs;*.8bf;*.pff;*.prm;*.bin;*.rsrc;*.txt;*.ffx\0Filter Factory Settings (*.afs, *.txt)\0*.afs;*.txt\0PluginCommander or FFDecomp TXT file (*.txt)\0*.txt\0Filter Factory for Windows, Standalone Filter (*.8bf)\0*.8bf\0Premiere TF/FF Settings (*.pff)\0*.pff\0Premiere TT/FF for Windows, Standalone Filter (*.prm)\0*.prm\0FilterFactory for MacOS, Standalone Filter (*.bin, *.rsrc)\0*.bin\0\"Filters Unlimited\" filter (*.ffx)\0*.ffx\0All files (*.*)\0*.*\0\0")
366
                        ,gdata->hWndMainDlg
366
                        ,gdata->hWndMainDlg
367
                        #endif /* _WIN32 */
367
                        #endif
368
                )){
368
                )){
369
                        // Backup everything, otherwise we might lose parameter data if the loading fails
369
                        // Backup everything, otherwise we might lose parameter data if the loading fails
370
                        bakState = saveInternalState();
370
                        bakState = saveInternalState();
371
 
371
 
372
                        if (loadfile(&sfr,&reason)) {
372
                        if (loadfile(&sfr,&reason)) {
373
                                updatedialog(dp);
373
                                updatedialog(dp);
374
                                maindlgupdate(dp);
374
                                maindlgupdate(dp);
375
                        }
375
                        }
376
                        else {
376
                        else {
-
 
377
                                #ifdef UNICODE
-
 
378
                                TCHAR reasonW[0x300];
-
 
379
                                mbstowcs(reasonW, reason, 0x300);
-
 
380
                                alertuser((TCHAR*)TEXT("Could not load settings."), reasonW);
-
 
381
                                #else
377
                                alertuser(_strdup("Cannot load settings."), reason);
382
                                alertuser((TCHAR*)TEXT("Could not load settings."), reason);
-
 
383
                                #endif
378
 
384
 
379
                                // Restore
385
                                // Restore
380
                                restoreInternalState(bakState);
386
                                restoreInternalState(bakState);
381
                        }
387
                        }
382
                }
388
                }
383
                break;
389
                break;
384
        case SAVEITEM:
390
        case SAVEITEM:
385
                if(!gdata->standalone && putfile(
391
                if(!gdata->standalone && putfile(
386
                        #ifdef MAC_ENV
392
                        #ifdef MAC_ENV
387
                        (StringPtr)_strdup("\pSave filter settings"), // "\p" means "Pascal string"
393
                        (StringPtr)_strdup("\pSave filter settings"), // "\p" means "Pascal string"
388
                        #else
-
 
389
                        (StringPtr)_strdup("\024Save filter settings"),
-
 
390
                        #endif
-
 
391
                        (StringPtr)_strdup("\0"),
394
                        (StringPtr)_strdup("\0"),
392
                        TEXT_FILETYPE,SIG_SIMPLETEXT,&reply,&sfr,
395
                        TEXT_FILETYPE, SIG_SIMPLETEXT, & reply, & sfr,
-
 
396
                        "afs",
393
                        "afs","All supported files (.afs, *.pff, .txt)\0*.afs;*.pff;*.txt\0Filter Factory Settings (*.afs)\0*.afs\0Premiere TF/FF Settings (*.pff)\0*.pff\0PluginCommander TXT file (*.txt)\0*.txt\0All files (*.*)\0*.*\0\0",1
397
                        "All supported files (.afs, *.pff, .txt)\0*.afs;*.pff;*.txt\0Filter Factory Settings (*.afs)\0*.afs\0Premiere TF/FF Settings (*.pff)\0*.pff\0PluginCommander TXT file (*.txt)\0*.txt\0All files (*.*)\0*.*\0\0", 1
-
 
398
                        #else
-
 
399
                        TEXT("Save filter settings"),
-
 
400
                        TEXT("\0"),
-
 
401
                        TEXT_FILETYPE, SIG_SIMPLETEXT, & reply, & sfr,
394
                        #ifdef _WIN32
402
                        TEXT("afs"),
-
 
403
                        TEXT("All supported files (.afs, *.pff, .txt)\0*.afs;*.pff;*.txt\0Filter Factory Settings (*.afs)\0*.afs\0Premiere TF/FF Settings (*.pff)\0*.pff\0PluginCommander TXT file (*.txt)\0*.txt\0All files (*.*)\0*.*\0\0"), 1
395
                        ,gdata->hWndMainDlg
404
                        ,gdata->hWndMainDlg
396
                        #endif /* _WIN32 */
405
                        #endif
397
                )){
406
                )){
398
                        if(savefile_afs_pff_picotxt(&sfr)) {
407
                        if(savefile_afs_pff_picotxt(&sfr)) {
399
                                completesave(&reply);
408
                                completesave(&reply);
400
 
409
 
401
                                if (fileHasExtension(&sfr, ".txt")) {
410
                                if (fileHasExtension(&sfr, TEXT(".txt"))) {
402
                                        char filename[MAX_PATH];
-
 
403
 
-
 
404
                                        showmessage(_strdup("The file was successfully saved in the \"PluginCommander\" TXT format. The file will now be opened in a text editor, so that you can fill in the missing data: Category, Title, Copyright, Author, Filename, Slider/Map names."));
411
                                        showmessage((TCHAR*)TEXT("The file was successfully saved in the \"PluginCommander\" TXT format. The file will now be opened in a text editor, so that you can fill in the missing data: Category, Title, Copyright, Author, Filename, Slider/Map names."));
405
 
412
 
406
                                        #ifdef MAC_ENV
413
                                        #ifdef MAC_ENV
407
                                        // TODO: Open text file instead
414
                                        // TODO: Open text file instead
408
                                        showmessage(_strdup("Please edit the file manually to enter the title, category, authorname, copyright, slidernames etc."));
415
                                        showmessage((TCHAR*)TEXT("Please edit the file manually to enter the title, category, authorname, copyright, slidernames etc."));
409
                                        #else
416
                                        #else
410
                                        myp2cstrcpy(filename, sfr.sfFile.name);
-
 
411
                                        hShellRes = ShellExecuteA(
417
                                        hShellRes = ShellExecute(
412
                                                gdata->hWndMainDlg,
418
                                                gdata->hWndMainDlg,
413
                                                "open",
419
                                                TEXT("open"),
414
                                                filename,
420
                                                &sfr.sfFile.szName[0],
415
                                                NULL,
421
                                                NULL,
416
                                                NULL,
422
                                                NULL,
417
                                                SW_SHOWNORMAL
423
                                                SW_SHOWNORMAL
418
                                        );
424
                                        );
419
                                        if (hShellRes <= (HINSTANCE)32) {
425
                                        if (hShellRes <= (HINSTANCE)32) {
420
                                                // MSDN states: "If the function succeeds, it returns a value greater than 32."
426
                                                // MSDN states: "If the function succeeds, it returns a value greater than 32."
421
 
427
 
422
                                                char s[100];
428
                                                TCHAR s[0x300];
423
                                                strcpy(s, "ShellExecuteA failed: ");
429
                                                xstrcpy(s, (TCHAR*)TEXT("ShellExecuteA failed: "));
424
                                                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL);
430
                                                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + xstrlen(s), 0x300 - xstrlen(s), NULL);
425
                                                dbg(s);
431
                                                dbg(&s[0]);
426
 
432
 
427
                                                showmessage(_strdup("Please edit the file manually to enter the title, category, author, copyright, filename, slidernames etc."));
433
                                                showmessage((TCHAR*)TEXT("Please edit the file manually to enter the title, category, author, copyright, filename, slidernames etc."));
428
                                        }
434
                                        }
429
                                        #endif
435
                                        #endif
430
                                }
436
                                }
431
 
437
 
432
                        }
438
                        }
Line 439... Line 445...
439
 
445
 
440
                break;
446
                break;
441
        case HELPITEM:
447
        case HELPITEM:
442
                #ifdef MAC_ENV
448
                #ifdef MAC_ENV
443
                // TODO: Open web-browser instead
449
                // TODO: Open web-browser instead
444
                showmessage(_strdup("You can find the documentation here: https://github.com/danielmarschall/filter_foundry/tree/master/doc"));
450
                showmessage((TCHAR*)TEXT("You can find the documentation here: https://github.com/danielmarschall/filter_foundry/tree/master/doc"));
445
                #else
451
                #else
446
                hShellRes = ShellExecuteA(
452
                hShellRes = ShellExecute(
447
                        gdata->hWndMainDlg,
453
                        gdata->hWndMainDlg,
448
                        "open",
454
                        TEXT("open"),
449
                        "https://github.com/danielmarschall/filter_foundry/blob/master/doc/The%20Filter%20Foundry.pdf",
455
                        TEXT("https://github.com/danielmarschall/filter_foundry/blob/master/doc/The%20Filter%20Foundry.pdf"),
450
                        NULL,
456
                        NULL,
451
                        NULL,
457
                        NULL,
452
                        SW_SHOWNORMAL
458
                        SW_SHOWNORMAL
453
                );
459
                );
454
                if (hShellRes == (HINSTANCE)ERROR_FILE_NOT_FOUND) {
460
                if (hShellRes == (HINSTANCE)ERROR_FILE_NOT_FOUND) {
Line 456... Line 462...
456
                        // So we ignore it for now...
462
                        // So we ignore it for now...
457
                }
463
                }
458
                else if (hShellRes <= (HINSTANCE)32) {
464
                else if (hShellRes <= (HINSTANCE)32) {
459
                        // MSDN states: "If the function succeeds, it returns a value greater than 32."
465
                        // MSDN states: "If the function succeeds, it returns a value greater than 32."
460
 
466
 
461
                        char s[100];
467
                        TCHAR s[0x300];
462
                        strcpy(s, "ShellExecuteA failed: ");
468
                        xstrcpy(s, (TCHAR*)TEXT("ShellExecute failed: "));
463
                        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL);
469
                        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + xstrlen(s), 0x300 - xstrlen(s), NULL);
464
                        dbg(s);
470
                        dbg(&s[0]);
465
 
471
 
466
                        showmessage(_strdup("You can find the documentation here: https://github.com/danielmarschall/filter_foundry/tree/master/doc"));
472
                        showmessage((TCHAR*)TEXT("You can find the documentation here: https://github.com/danielmarschall/filter_foundry/tree/master/doc"));
467
                }
473
                }
468
                #endif
474
                #endif
469
                break;
475
                break;
470
        case ZOOMINITEM:
476
        case ZOOMINITEM:
471
                zoomfactor = zoomfactor > 2. ? zoomfactor/2. : 1.;
477
                zoomfactor = zoomfactor > 2. ? zoomfactor/2. : 1.;
Line 512... Line 518...
512
        case FIRSTICONITEM:
518
        case FIRSTICONITEM:
513
        case FIRSTICONITEM+1:
519
        case FIRSTICONITEM+1:
514
        case FIRSTICONITEM+2:
520
        case FIRSTICONITEM+2:
515
        case FIRSTICONITEM+3:
521
        case FIRSTICONITEM+3:
516
                item -= FIRSTICONITEM;
522
                item -= FIRSTICONITEM;
-
 
523
                {
-
 
524
                        #ifdef UNICODE
-
 
525
                        TCHAR errW[0x300];
-
 
526
                        mbstowcs(errW, err[item], 0x300);
-
 
527
                        alertuser(errW, (TCHAR*)TEXT(""));
-
 
528
                        #else
517
                alertuser(err[item],_strdup(""));
529
                        alertuser(err[item], (TCHAR*)TEXT(""));
-
 
530
                        #endif
-
 
531
                }
518
                SELECTCTLTEXT(dp,FIRSTEXPRITEM+item,errstart[item],errpos[item]);
532
                SELECTCTLTEXT(dp,FIRSTEXPRITEM+item,errstart[item],errpos[item]);
519
                break;
533
                break;
520
        case FIRSTEXPRITEM:
534
        case FIRSTEXPRITEM:
521
        case FIRSTEXPRITEM+1:
535
        case FIRSTEXPRITEM+1:
522
        case FIRSTEXPRITEM+2:
536
        case FIRSTEXPRITEM+2:
Line 529... Line 543...
529
        }
543
        }
530
 
544
 
531
        return true; // keep going
545
        return true; // keep going
532
}
546
}
533
 
547
 
534
Boolean alertuser(char *err,char *more){
548
Boolean alertuser(TCHAR *err,TCHAR *more){
535
        char *s = (char*)malloc(strlen(err)+strlen(more)+2),*q;
549
        TCHAR *s = (TCHAR*)malloc((xstrlen(err)+xstrlen(more)+2)*sizeof(TCHAR)), *q;
536
        Boolean res;
550
        Boolean res;
537
 
551
 
538
        q = cat(s,err);
552
        q = xstrcat(s,err);
539
        *q++ = LF;
553
        *q++ = LF;
540
        q = cat(q,more);
554
        q = xstrcat(q,more);
541
        *q = 0;
555
        *q = 0;
542
        res = simplealert(s);
556
        res = simplealert(s);
543
        free(s);
557
        free(s);
544
        return res;
558
        return res;
545
}
559
}