Subversion Repositories filter_foundry

Rev

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

Rev 536 Rev 537
Line 698... Line 698...
698
        }
698
        }
699
        free(inputworkinitial);
699
        free(inputworkinitial);
700
        return true;
700
        return true;
701
}
701
}
702
 
702
 
703
Boolean readfile_picotxt(StandardFileReply* sfr, TCHAR** reason) {
703
Boolean readfile_picotxt_or_ffdecomp(StandardFileReply* sfr, TCHAR** reason) {
704
        extern int ctls[], maps[];
704
        extern int ctls[], maps[];
705
 
705
 
706
        Handle h;
706
        Handle h;
707
        Boolean res = false;
707
        Boolean res = false;
708
        FILEREF refnum;
708
        FILEREF refnum;
Line 739... Line 739...
739
                                for (i = 0; i < 4; i++) {
739
                                for (i = 0; i < 4; i++) {
740
                                        if (expr[i]) free(expr[i]);
740
                                        if (expr[i]) free(expr[i]);
741
                                        expr[i] = my_strdup(gdata->parm.szFormula[i]);
741
                                        expr[i] = my_strdup(gdata->parm.szFormula[i]);
742
                                }
742
                                }
743
 
743
 
744
                                // Slider names
-
 
745
                                for (i = 0; i < 8; i++) {
744
                                for (i = 0; i < 8; i++) {
-
 
745
                                        int v;
746
                                        char keyname[7];
746
                                        char keyname[7+1], tmp[5];
-
 
747
 
-
 
748
                                        // Slider names
747
                                        sprintf(keyname, "ctl[%d]", i);
749
                                        sprintf(keyname, "ctl[%d]", i);
748
                                        _picoReadProperty(q, count, keyname, gdata->parm.szCtl[i], sizeof(gdata->parm.szCtl[i]), false);
750
                                        _picoReadProperty(q, count, keyname, gdata->parm.szCtl[i], sizeof(gdata->parm.szCtl[i]), false);
749
                                }
-
 
750
 
751
 
751
                                // Slider values
752
                                        // Slider values
752
                                for (i = 0; i < 8; i++) {
-
 
753
                                        char keyname[7], tmp[5];
-
 
754
                                        int v;
-
 
755
                                        sprintf(keyname, "val[%d]", i);
753
                                        sprintf(keyname, "val[%d]", i);
756
                                        if (!_picoReadProperty(q, count, keyname, tmp, sizeof(tmp), false)) {
754
                                        if (!_picoReadProperty(q, count, keyname, tmp, sizeof(tmp), false)) {
757
                                                sprintf(keyname, "def[%d]", i);
755
                                                sprintf(keyname, "def[%d]", i);
758
                                                if (!_picoReadProperty(q, count, keyname, tmp, sizeof(tmp), false)) {
756
                                                if (!_picoReadProperty(q, count, keyname, tmp, sizeof(tmp), false)) {
759
                                                        strcpy(tmp,"0");
757
                                                        strcpy(tmp,"0");
Line 765... Line 763...
765
                                        gdata->parm.val[i] = slider[i] = (uint8_t)v;
763
                                        gdata->parm.val[i] = slider[i] = (uint8_t)v;
766
                                }
764
                                }
767
 
765
 
768
                                // Map names
766
                                // Map names
769
                                for (i = 0; i < 4; i++) {
767
                                for (i = 0; i < 4; i++) {
770
                                        char keyname[7];
768
                                        char keyname[7+1];
771
                                        sprintf(keyname, "map[%d]", i);
769
                                        sprintf(keyname, "map[%d]", i);
772
                                        _picoReadProperty(q, count, keyname, gdata->parm.szMap[i], sizeof(gdata->parm.szMap[i]), false);
770
                                        _picoReadProperty(q, count, keyname, gdata->parm.szMap[i], sizeof(gdata->parm.szMap[i]), false);
773
                                }
771
                                }
774
 
772
 
775
                                //These will be set when the expressions are evaluated anyway. So this part is optional:
773
                                //These will be set when the expressions are evaluated anyway. So this part is optional:
776
                                checksliders(4, ctls, maps);
774
                                checksliders(4, ctls, maps);
777
                                for (i = 0; i < 8; i++) gdata->parm.ctl_used[i] = ctls[i];
775
                                for (i = 0; i < 8; i++) gdata->parm.ctl_used[i] = ctls[i];
-
 
776
                                for (i = 0; i < 4; i++) gdata->parm.map_used[i] = maps[i];
-
 
777
 
-
 
778
                                res = true;
-
 
779
                        }
-
 
780
 
-
 
781
                        PIUNLOCKHANDLE(h);
-
 
782
                        PIDISPOSEHANDLE(h);
-
 
783
                }
-
 
784
                FSClose(refnum);
-
 
785
        }
-
 
786
 
-
 
787
        return res;
-
 
788
}
-
 
789
 
-
 
790
Boolean _gufReadProperty(char* inputFile, size_t maxInput, const char* section, const char* property, char* outputFile, size_t maxOutput) {
-
 
791
        // TODO: Implement
-
 
792
        return false;
-
 
793
}
-
 
794
 
-
 
795
Boolean readfile_guf(StandardFileReply* sfr, TCHAR** reason) {
-
 
796
        extern int ctls[], maps[];
-
 
797
 
-
 
798
        Handle h;
-
 
799
        Boolean res = false;
-
 
800
        FILEREF refnum;
-
 
801
 
-
 
802
        if (!fileHasExtension(sfr, TEXT(".guf"))) return false;
-
 
803
 
-
 
804
        if (FSpOpenDF(&sfr->sfFile, fsRdPerm, &refnum) == noErr) {
-
 
805
                if ((h = readfileintohandle(refnum))) {
-
 
806
                        FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h);
-
 
807
                        char* q = PILOCKHANDLE(h, false);
-
 
808
 
-
 
809
                        char out[256];
-
 
810
                        if (_gufReadProperty(q, count, "GUF", "Protocol", out, sizeof(out))) {
-
 
811
                                if (!strcmp(out, "1")) {
-
 
812
                                        if (reason) *reason = FF_GetMsg_Cpy(MSG_INCOMPATIBLE_GUF_FILE_ID);
-
 
813
                                        return false;
-
 
814
                                }
-
 
815
                        }
-
 
816
                        else {
-
 
817
                                if (reason) *reason = FF_GetMsg_Cpy(MSG_INCOMPATIBLE_GUF_FILE_ID);
-
 
818
                                return false;
-
 
819
                        }
-
 
820
                        if (_gufReadProperty(q, count, "Info", "Title", out, sizeof(out))) {
-
 
821
                                int i;
-
 
822
 
-
 
823
                                // Plugin infos
-
 
824
                                _gufReadProperty(q, count, "Info", "Title", gdata->parm.szTitle, sizeof(gdata->parm.szTitle));
-
 
825
                                _gufReadProperty(q, count, "Info", "Category", gdata->parm.szCategory, sizeof(gdata->parm.szCategory)); // TODO: only last part of "/"
-
 
826
                                _gufReadProperty(q, count, "Info", "Author", gdata->parm.szAuthor, sizeof(gdata->parm.szAuthor));
-
 
827
                                _gufReadProperty(q, count, "Info", "Copyright", gdata->parm.szCopyright, sizeof(gdata->parm.szCopyright));
-
 
828
                                //_gufReadProperty(q, count, "Filter Factory", "8bf", gdata->parm.xxx, sizeof(gdata->parm.xxx));
-
 
829
 
-
 
830
                                // Expressions
-
 
831
                                if (!_gufReadProperty(q, count, "Code", "R", gdata->parm.szFormula[0], sizeof(gdata->parm.szFormula[0])))
-
 
832
                                        strcpy(gdata->parm.szFormula[0], "r");
-
 
833
                                if (!_gufReadProperty(q, count, "Code", "G", gdata->parm.szFormula[1], sizeof(gdata->parm.szFormula[1])))
-
 
834
                                        strcpy(gdata->parm.szFormula[1], "g");
-
 
835
                                if (!_gufReadProperty(q, count, "Code", "B", gdata->parm.szFormula[2], sizeof(gdata->parm.szFormula[2])))
-
 
836
                                        strcpy(gdata->parm.szFormula[2], "b");
-
 
837
                                if (!_gufReadProperty(q, count, "Code", "A", gdata->parm.szFormula[3], sizeof(gdata->parm.szFormula[3])))
-
 
838
                                        strcpy(gdata->parm.szFormula[3], "a");
-
 
839
                                for (i = 0; i < 4; i++) {
-
 
840
                                        if (expr[i]) free(expr[i]);
-
 
841
                                        expr[i] = my_strdup(gdata->parm.szFormula[i]);
-
 
842
                                }
-
 
843
 
-
 
844
                                for (i = 0; i < 8; i++) {
-
 
845
                                        int v;
-
 
846
                                        char keyname[10 + 1], tmp[5];
-
 
847
                                        sprintf(keyname, "Control %d", i);
-
 
848
 
-
 
849
                                        // Slider names
-
 
850
                                        _gufReadProperty(q, count, keyname, "Label", gdata->parm.szCtl[i], sizeof(gdata->parm.szCtl[i]));
-
 
851
 
-
 
852
                                        // Slider values
-
 
853
                                        if (!_gufReadProperty(q, count, keyname, "Preset", tmp, sizeof(tmp))) {
-
 
854
                                                strcpy(tmp, "0");
-
 
855
                                        }
-
 
856
                                        v = atoi(tmp);
-
 
857
                                        if (v < 0) v = 0;
-
 
858
                                        else if (v > 255) v = 255;
-
 
859
                                        gdata->parm.val[i] = slider[i] = (uint8_t)v;
-
 
860
                                }
-
 
861
 
-
 
862
                                // Map names
-
 
863
                                for (i = 0; i < 4; i++) {
-
 
864
                                        char keyname[6 + 1];
-
 
865
                                        sprintf(keyname, "Map %d", i);
-
 
866
                                        _gufReadProperty(q, count, keyname, "Label", gdata->parm.szMap[i], sizeof(gdata->parm.szMap[i]));
-
 
867
                                }
-
 
868
 
-
 
869
                                //These will be set when the expressions are evaluated anyway. So this part is optional:
-
 
870
                                checksliders(4, ctls, maps);
-
 
871
                                for (i = 0; i < 8; i++) gdata->parm.ctl_used[i] = ctls[i];
778
                                for (i = 0; i < 4; i++) gdata->parm.map_used[i] = maps[i];
872
                                for (i = 0; i < 4; i++) gdata->parm.map_used[i] = maps[i];
779
 
873
 
780
                                res = true;
874
                                res = true;
781
                        }
875
                        }
782
 
876