Overview
Comment: | Implement editing multidependent pictures; also improve comconfig.doc (independently) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3083ae9c8d8f4d15f8e56d57765464f6 |
User & Date: | user on 2022-07-21 21:15:32 |
Other Links: | manifest | tags |
Context
2022-07-21
| ||
23:39 | Finish the implementation of multidependent pictures. check-in: 59c1955556 user: user tags: trunk | |
21:15 | Implement editing multidependent pictures; also improve comconfig.doc (independently) check-in: 3083ae9c8d user: user tags: trunk | |
2022-07-20
| ||
05:10 | Start to implement multidependent picture lumps (currently only adding/deleting them in the picture editor and listing them; you cannot edit nor use them yet). check-in: ed54db3698 user: user tags: trunk | |
Changes
Modified comconfig.doc from [44f21afded] to [e827074f10].
︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | + + + + + + + + + + + + + + + + | in future when they are implemented. CONFIG_ERROR_CHECKING Define error checking level, where 9 is maximum. Lower numbers might improve speed but may make the program crash in some cases and may also cause security vulnerabilities. CONFIG_LAUNCHER_PATH If defined, then it is the full path to a file to execute if Free Hero Mesh has been invoked with no command-line arguments, or if it is given the flag to run the launcher program instead. CONFIG_MULTIUSER_SCORES (Meant for storing scores on a multiuser system, somehow) CONFIG_OMIT_EDITOR If defined, omit the level editor and picture editor. CONFIG_OMIT_MUSIC If defined, omit background music playback capabilities. (Even if this is not defined, it can still be disabled at runtime. CONFIG_OMIT_SOUND If defined, omit all sound capabilities (including music). (Even if it is not defined, it can still be disabled at runtime.) CONFIG_PRIVATE_USERCACHE If defined as a octal number, set the default file permissions of the user cache database when creating it. (The user can still change them afterward by using chmod.) CONFIG_RANDOM_SOURCE Device to read random numbers from instead of using the random number |
︙ | |||
72 73 74 75 76 77 78 | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | - + + - + + | If defined, use BSD functions (such as funopen) instead of GNU functions (such as fopencookie), by adding emulations into the program. (It is still necessary to use a C compiler with GNU extensions though, even if the GNU library is not available.) CONFIG_USING_SDL12_COMPAT Define this if the program is to be compiled for use with the |
Modified fileformat.doc from [5da3136896] to [a630f0a978].
︙ | |||
225 226 227 228 229 230 231 232 233 234 235 236 237 238 | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + | * 85 to 169 = Heterogeneous run (1 to 85 pixels). Follow by that many bytes being the pixel values (palette index). * 170 to 254 = Copy-above run (1 to 85 pixels). Copies the specified number of pixels from the previous scanline. (If this crosses multiple scanlines, it continues copying it.) === xclass/*.MUL === This lump is a "multidependent" lump. The lump name is ignored except for the MUL suffix, but it is displayed in the picture editor. The first four bytes are the number of bases and the number of filters in each of the three filter lists. All of these bytes have the number in the low 6-bits, and bit7 is set if it is nullable; bit6 is unused and it must be clear. After that is the list of bases, each being a null-terminated string, which must be the name of a .IMG lump without the .IMG suffix. After the list of bases is the information for each filter chain; first all chains in the first list, and then the second, and then the third; null chains are not listed. These records have the format: * A small-endian 16-bit number, where bit10-bit0 is the length of this filter chain in bytes, bit13-bit11 is the length of the name in bytes (not counting the ._- prefix), and bit15-bit14 is the prefix character (0 if none, 1 if a hyphen, 2 if a underscore, or 3 if a dot). * The name, not counting the prefix, with no terminator. After that will be the list of filters in each chain, in the same format as for DEP lumps but without the base name. === xclass/*.WAV === A user-defined sound effect. The part of the lump name before the dot is the name used to refer to it in a class definition file; the exclamation mark is not included in the lump name. |
︙ |
Modified picedit.c from [86ecd14102] to [2327f052d7].
︙ | |||
48 49 50 51 52 53 54 | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | + - + + + + + + + + + + + + + + + + + + + + + + + | ColorFilter color; OverlayFilter overlay; ShiftFilter shift; }; } Filter; typedef struct { union { |
︙ | |||
283 284 285 286 287 288 289 | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | - + | static sqlite3_int64 ask_picture_id(const char*t) { sqlite3_stmt*st; const char*r=screen_prompt(t); int i; sqlite3_int64 id=0; if(!r || !*r) return 0; |
︙ | |||
1107 1108 1109 1110 1111 1112 1113 | 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | - + - + + - + | break; case SDL_VIDEOEXPOSE: goto redraw; } } } |
︙ | |||
1159 1160 1161 1162 1163 1164 1165 | 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 | - + - + | dp->filters[i].shift.nshift=k+1; break; } } fclose(fp); } |
︙ | |||
1367 1368 1369 1370 1371 1372 1373 | 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 | + - - + + - - - - + + + + + + + + | SDL_Rect r; SDL_Event ev; set_cursor(XC_arrow); redraw: r.x=r.y=0; r.w=screen->w; r.h=screen->h; SDL_LockSurface(screen); SDL_FillRect(screen,&r,0xF0); if(name) { |
︙ | |||
1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 | 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 | + | case SDLK_ESCAPE: return; case SDLK_UP: case SDLK_KP8: case SDLK_a: case SDLK_k: if(c>=0) --c; break; case SDLK_DOWN: case SDLK_KP2: case SDLK_z: case SDLK_j: ++c; break; case SDLK_INSERT: case SDLK_KP0: if(add_filter(dp,txt,c)) // maybe fallthrough case SDLK_SPACE: if(c==-1) { if(!name) break; s=screen_prompt("Name of base picture:"); if(s && *s) strncpy(dp->basename,s,63); } else if(c<dp->nfilters) { switch(dp->filters[c].code) { case 8 ... 10: edit_color_filter(&dp->filters[c].color); break; |
︙ | |||
1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 | 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } goto redraw; case SDL_VIDEOEXPOSE: goto redraw; } } } static void load_multidependent(const Uint8*data,int size,MultiDependent*mp) { Uint32 at=4; int i,j,k; memset(mp,0,sizeof(MultiDependent)); if(size<4) return; memcpy(mp->nitems,data,4); for(i=0;i<(mp->nbases&63);i++) { for(k=0;k<63 && at<size && data[at];k++) mp->bases[i].basename[k]=data[at++]; at++; } for(j=0;j<3;j++) for(i=0;i<(mp->nchains[j]&63) && at<size-2;i++) { k=data[at++]; k|=data[at++]<<8; mp->chains[j*63+i].size=k&0x07FF; mp->chains[j*63+i].name[0]="\x00-_."[k>>14]; k>>=11; if(at+(k&7)>size) break; memcpy(mp->chains[j*63+i].name+(k&~7?1:0),data+at,k&7); at+=k&7; } for(j=0;j<3;j++) for(i=0;i<(mp->nchains[j]&63) && at+mp->chains[j*63+i].size<=size;i++) { load_dependent_picture(data+at,mp->chains[j*63+i].size,mp->chains+j*63+i,1); at+=mp->chains[j*63+i].size; } } static void save_multidependent(FILE*fp,MultiDependent*mp) { Uint8*buf=0; size_t size=0; FILE*f=open_memstream((char**)&buf,&size); Uint32 at; int i,j,k,c; if(!f) fatal("Cannot open memory stream\n"); fwrite(mp->nitems,1,4,fp); for(i=0;i<(mp->nbases&63);i++) fwrite(mp->bases[i].basename,1,strlen(mp->bases[i].basename)+1,fp); for(j=0;j<3;j++) for(i=0;i<(mp->nchains[j]&63);i++) { at=ftell(f); save_dependent_picture(f,mp->chains+j*63+i,1); //TODO: This should check if it is too long, but unfortunately it does not do that. k=(ftell(f)-at)&0x07FF; c=mp->chains[j*63+i].name[0]; if(c=='-') k|=0x4000; if(c=='_') k|=0x8000; if(c=='.') k|=0xC000; k|=strlen(mp->chains[j*63+i].name+(k>>14?1:0))<<11; fputc(k,fp); fputc(k>>8,fp); if((k>>11)&7) fwrite(mp->chains[j*63+i].name+(k>>14?1:0),1,(k>>11)&7,fp); } fputc(0,f); fclose(f); if(!buf || !size) fatal("Allocation failed\n"); if(size) fwrite(buf,1,size-1,fp); free(buf); } static void edit_multidependent(MultiDependent*mp,const char*name) { const char*s; char row=0; char col=0; int i,j; SDL_Rect r; SDL_Event ev; set_cursor(XC_arrow); redraw: r.x=r.y=0; r.w=screen->w; r.h=screen->h; SDL_LockSurface(screen); SDL_FillRect(screen,&r,0xF0); draw_text(0,0,"Multidependent:",0xF0,0xF7); draw_text(136,0,name,0xF0,0xF5); draw_text(0,8,"<ESC> Exit <\x18/\x19/\x1A/\x1B> Cursor <SP> Edit <TAB> Name <BKSP> Toggle Null <INS> Add <DEL> Delete",0xF0,0xFB); draw_text(4,20,"BASE ",col==0?0xF2:0xF0,0xFE); if(mp->nbases&0x80) draw_text(4,28,"<Null>",0xF0,0xF7); draw_text(4+8*64,20,"I ",col==1?0xF2:0xF0,0xFE); if(mp->nchains[0]&0x80) draw_text(4+8*64,28,"<Null>",0xF0,0xF7); draw_text(4+8*74,20,"II ",col==2?0xF2:0xF0,0xFE); if(mp->nchains[1]&0x80) draw_text(4+8*74,28,"<Null>",0xF0,0xF7); draw_text(4+8*84,20,"III ",col==3?0xF2:0xF0,0xFE); if(mp->nchains[2]&0x80) draw_text(4+8*84,28,"<Null>",0xF0,0xF7); if(row>=(mp->nitems[col]&63)) row=(mp->nitems[col]&63?:1)-1; for(i=0;i<(mp->nbases&63);i++) draw_text(4,8*i+36,mp->bases[i].basename,(col==0 && row==i)?0xF1:0xF0,0xF7); for(j=0;j<3;j++) for(i=0;i<(mp->nchains[j]&63);i++) draw_text(4+8*(10*j+64),8*i+36,mp->chains[j*63+i].name,(col==j+1 && row==i)?0xF1:0xF0,0xF7); SDL_UnlockSurface(screen); SDL_Flip(screen); while(SDL_WaitEvent(&ev)) { switch(ev.type) { case SDL_QUIT: exit(0); break; case SDL_KEYDOWN: switch(ev.key.keysym.sym) { case SDLK_ESCAPE: case SDLK_q: return; case SDLK_BACKSPACE: case SDLK_t: mp->nitems[col]^=0x80; break; case SDLK_LEFT: case SDLK_KP4: case SDLK_h: if(col) --col; break; case SDLK_RIGHT: case SDLK_KP6: case SDLK_l: if(col<3) ++col; break; case SDLK_UP: case SDLK_KP8: case SDLK_k: if(row) --row; break; case SDLK_DOWN: case SDLK_KP2: case SDLK_j: ++row; break; case SDLK_HOME: case SDLK_KP7: row=0; break; case SDLK_END: case SDLK_KP1: row=64; break; case SDLK_INSERT: case SDLK_KP0: case SDLK_a: if((mp->nitems[col]&63)==63) break; row=mp->nitems[col]&63; s=screen_prompt(col?"Add filter chain:":"Add base item:"); if(!s || !*s) break; if(col) { strncpy(mp->chains[(col-1)*63+row].name,s,8); if(*s!='.' && *s!='_' && *s!='-') mp->chains[(col-1)*63+row].name[8]=0; mp->chains[(col-1)*63+row].nfilters=0; ++mp->nitems[col]; goto edit; } else { strncpy(mp->bases[row].basename,s,63); ++mp->nbases; } break; case SDLK_SPACE: case SDLK_e: edit: if(!mp->nitems[col]) break; if(!col) goto rename; edit_dependent_picture(mp->chains+(col-1)*63+row,0); break; case SDLK_DELETE: case SDLK_KP_PERIOD: case SDLK_d: if(!mp->nitems[col]) break; --mp->nitems[col]; if(col) { for(i=row;i<mp->nitems[col];i++) mp->chains[(col-1)*63+i]=mp->chains[(col-1)*63+i+1]; } else { for(i=row;i<mp->nbases;i++) mp->bases[i]=mp->bases[i+1]; } break; case SDLK_TAB: case SDLK_n: rename: if(!mp->nitems[col]) break; s=screen_prompt("Rename:"); if(!s || !*s) break; if(col) { strncpy(mp->chains[(col-1)*63+row].name,s,8); if(*s!='.' && *s!='_' && *s!='-') mp->chains[(col-1)*63+row].name[8]=0; mp->chains[(col-1)*63+row].nfilters=0; } else { strncpy(mp->bases[row].basename,s,63); } break; } goto redraw; case SDL_VIDEOEXPOSE: goto redraw; } } } 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; MultiDependent*mpict; char*name; const unsigned char*data; Uint8*buf=0; size_t size=0; FILE*fp; int i,n; if(i=sqlite3_prepare_v2(userdb,"SELECT SUBSTR(`NAME`,1,LENGTH(`NAME`)-4),`DATA`,`TYPE` FROM `PICEDIT` WHERE `ID`=?1;",-1,&st,0)) { |
︙ | |||
1516 1517 1518 1519 1520 1521 1522 | 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 | - + - + + + + + + + + + + + + | if(!buf || !size) fatal("Allocation failed\n"); *buf|=pict[0]->meth<<4; for(i=1;i<n;i++) buf[n+1+((i-1)>>1)]|=pict[i]->meth<<(i&1?0:4); for(i=0;i<16;i++) free(pict[i]); } else if(i==2) { dpict=malloc(sizeof(DependentPicture)); if(!dpict) fatal("Allocation failed\n"); |
︙ |
Modified picedit.doc from [5b2aad712f] to [6c48fbb9a5].
︙ | |||
12 13 14 15 16 17 18 | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | - + + | used; which one is used depends on the .altImage and .imageSize settings, which can be defined by the end user. === Main menu === The main menu displays the list of the names of all pictures. This list is |
︙ | |||
37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | + + + + | create it with variants of all of those sizes. You can also specify the same numbers multiple times if you want multiple variants of that size. The F7 key copies a picture. The F12 key allows entering a SQL statement. If there are any result rows, only the first row and first column are displayed. Any of the prompts for picture names can start the picture name with a plus sign in order to affect a multidependent picture; see the below section about multidependent pictures for details. === Drawing === The following keyboard commands are available: Esc |
︙ | |||
212 213 214 215 216 217 218 | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | * Base: This one must come first, and is the independent picture which will be used as the base; all other filters are applied to alter it. * Flip/rotation: Flip/rotate the picture. "Identity" also belongs to this category, but has no effect. |