Overview
Comment: | Data structures for dependent images in picture editor |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
120405b3b435ba0197815e0dcbf13040 |
User & Date: | user on 2021-04-12 23:18:04 |
Other Links: | manifest | tags |
Context
2021-04-13
| ||
23:36 | Start to implement the dependent picture editor; currently, colour filters and shift filters cannot be edited yet. check-in: a5c2814f64 user: user tags: trunk | |
2021-04-12
| ||
23:18 | Data structures for dependent images in picture editor check-in: 120405b3b4 user: user tags: trunk | |
03:43 | Start to implement dependent pictures in the picture editor. (Currently, it just does nothing.) check-in: ffd9bad655 user: user tags: trunk | |
Changes
Modified picedit.c from [9f00b04720] to [e04720f3bd].
︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | #include "cursorshapes.h" typedef struct { Uint8 size,meth; Uint8 data[0]; // the first row is all 0, since the compression algorithm requires this } Picture; typedef struct { Uint8 colors[64]; Uint8 ncolors; } ColorFilter; typedef struct { char name[64]; } OverlayFilter; typedef struct { Uint8 shift[32]; Uint8 size[32]; Uint8 nshift; } ShiftFilter; typedef struct { Uint8 code; // 0-7 = flip/rotations // 8-10 = change colours (8 is *->* *->* *->*; 9 is \->*->*->*->/; 10 is *<->* *<->* *<->*) // 11 = overlay // 12-15 = shift (up, down, right, left) union { ColorFilter color; OverlayFilter overlay; ShiftFilter shift; }; } Filter; typedef struct { char basename[64]; Filter filters[64]; Uint8 nfilters; } DependentPicture; static Uint8 cur_type; static void fn_valid_name(sqlite3_context*cxt,int argc,sqlite3_value**argv) { const char*s=sqlite3_value_text(*argv); if(!s || !*s || s[strspn(s,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-0123456789")]) { sqlite3_result_error(cxt,"Invalid name",-1); return; |
︙ | |||
254 255 256 257 258 259 260 | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | - + | } static void compress_picture(FILE*out,Picture*pic) { int bm=15; int bs=pic->size*pic->size; FILE*fp=fmemopen(0,bs,"w"); int i,j; |
︙ | |||
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 | 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - | } break; case SDL_VIDEOEXPOSE: goto redraw; } } } static void load_dependent_picture(const Uint8*data,int size,DependentPicture*dp) { FILE*fp; int i,j,k; memset(dp,0,sizeof(DependentPicture)); if(!size) { const char*s=screen_prompt("Name of base picture:"); if(s) strncpy(dp->basename,s,63); return; } fp=fmemopen((Uint8*)data,size,"r"); if(!fp) fatal("Error with fmemopen\n"); i=0; for(;;) { j=fgetc(fp); if(j<32) { if(j>0) ungetc(j,fp); break; } if(i<63) dp->basename[i++]=j; } while(dp->nfilters<64) { if((j=fgetc(fp))<0) break; switch(dp->filters[i=dp->nfilters++].code=j) { case 8 ... 10: j=dp->filters[i].color.ncolors=fgetc(fp); if(j<0 || j>64) j=64; fread(dp->filters[i].color.colors,1,j,fp); break; case 11: k=0; for(;;) { j=fgetc(fp); if(j<32) { if(j>0) ungetc(j,fp); break; } if(k<63) dp->filters[i].overlay.name[k++]=j; } break; case 12 ... 15: for(k=0;k<64;k++) { dp->filters[i].shift.shift[k]=(j=fgetc(fp))&127; dp->filters[i].shift.size[k]=fgetc(fp); if(j&128) break; } dp->filters[i].shift.nshift=k; break; } } fclose(fp); } static void save_dependent_picture(FILE*fp,DependentPicture*dp) { int i,j; fwrite(dp->basename,1,strlen(dp->basename)+(dp->filters[0].code<32?0:1),fp); for(i=0;i<dp->nfilters;i++) { fputc(dp->filters[i].code,fp); switch(dp->filters[i].code) { case 8 ... 10: fputc(dp->filters[i].color.ncolors,fp); fwrite(dp->filters[i].color.colors,1,dp->filters[i].color.ncolors,fp); break; case 11: fwrite(dp->filters[i].overlay.name,1,strlen(dp->filters[i].overlay.name)+(i<dp->nfilters-1&&dp->filters[i+1].code<32?0:1),fp); break; case 12 ... 15: if(!dp->filters[i].shift.nshift) fwrite("\x80",1,2,fp); for(j=0;j<dp->filters[i].shift.nshift;j++) { fputc(dp->filters[i].shift.shift[j]|(j==dp->filters[i].shift.nshift-1?128:0),fp); fputc(dp->filters[i].shift.size[j],fp); } break; } } } static void edit_dependent_picture(DependentPicture*dp,const char*name) { } static void edit_picture(sqlite3_int64 id) { sqlite3_stmt*st; Picture*pict[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; DependentPicture*dpict; char*name; const unsigned char*data; Uint8*buf=0; size_t size=0; FILE*fp; int i,n; |
︙ | |||
1067 1068 1069 1070 1071 1072 1073 | 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 | - + - - - | else screen_message("Too many pictures"); goto redraw; case SDLK_F2: max-=delete_picture(); goto redraw; case SDLK_F3: *ids=ask_picture_id("Edit:"); |
︙ |
Modified puzzleset.doc from [a3525461a6] to [27aef9bea9].
︙ | |||
26 27 28 29 30 31 32 33 34 35 36 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | + + + + - - - | This file contains pictures and sounds associated with the puzzle set. Nothing in this file affects the behaviour of the game, so you can safely replace it with a different set of pictures/sounds if wanted. The IMG lumps are the pictures. Each one may store multiple versions of a picture; the loader will select one based on the user's criteria. The DEP lumps are dependent pictures; each one references one or more IMG lumps, and specifies how to modify them to produce the new picture (e.g. by rotating, mirroring, changing colours, etc). The WAV lumps are sound effects. Each is a RIFF WAVE file; it must be of a type which can be loaded by SDL. (This is currently not used.) |
︙ |