Overview
Comment: | Complete implementing level strings in the level editor (I think) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
51681082e0966a768a6991ed6d7e0624 |
User & Date: | user on 2021-03-28 20:25:38 |
Other Links: | manifest | tags |
Context
2021-03-28
| ||
20:45 | Improve the README file check-in: bbc05f163c user: user tags: trunk | |
20:25 | Complete implementing level strings in the level editor (I think) check-in: 51681082e0 user: user tags: trunk | |
06:01 | Start to implement editing level strings (not finished yet) check-in: 59dfac25ca user: user tags: trunk | |
Changes
Modified edit.c from [b7508d9e96] to [621212b430].
︙ | ︙ | |||
561 562 563 564 565 566 567 568 569 570 571 572 573 574 | goto redraw; case SDL_QUIT: exit(0); break; } } } static Value ask_value(const char*s) { int i; s=screen_prompt(s); if(!s || !*s) return UVALUE(0,4); if(*s=='-' || *s=='+' || (*s>='0' && *s<='9')) { if(*s=='0' && s[1]=='x') return NVALUE(strtol(s+2,0,16)&0xFFFF); | > > | 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | goto redraw; case SDL_QUIT: exit(0); break; } } } static int string_list(void); static Value ask_value(const char*s) { int i; s=screen_prompt(s); if(!s || !*s) return UVALUE(0,4); if(*s=='-' || *s=='+' || (*s>='0' && *s<='9')) { if(*s=='0' && s[1]=='x') return NVALUE(strtol(s+2,0,16)&0xFFFF); |
︙ | ︙ | |||
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | draw_text(200,i,buf,0xF0,0xF9); break; } } draw_text(0,64,"Str:",0xF0,0xF7); snprintf(buf,255,"%d",nlevelstrings); draw_text(64,64,buf,0xF0,0xF7); SDL_UnlockSurface(screen); SDL_Flip(screen); while(SDL_WaitEvent(&ev)) switch(ev.type) { case SDL_KEYDOWN: switch(ev.key.keysym.sym) { case SDLK_RETURN: case SDLK_KP_ENTER: case SDLK_ESCAPE: return; case SDLK_1: v=ask_value("Misc1:"); if(v.t<4) m->misc1=v; break; case SDLK_2: v=ask_value("Misc2:"); if(v.t<4) m->misc2=v; break; case SDLK_3: v=ask_value("Misc3:"); if(v.t<4) m->misc3=v; break; case SDLK_KP1: m->dir=5; break; case SDLK_KP2: m->dir=6; break; case SDLK_KP3: m->dir=7; break; case SDLK_KP4: m->dir=4; break; case SDLK_KP6: m->dir=0; break; case SDLK_KP7: m->dir=3; break; case SDLK_KP8: m->dir=2; break; | > > > > > | 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | draw_text(200,i,buf,0xF0,0xF9); break; } } draw_text(0,64,"Str:",0xF0,0xF7); snprintf(buf,255,"%d",nlevelstrings); draw_text(64,64,buf,0xF0,0xF7); draw_text(0,80,"<1-3> Misc <4-6> Misc=String <NumPad> Dir",0xF0,0xF3); draw_text(0,88,"<F1> Help <F2> EditorHelp <RET> Exit",0xF0,0xF3); SDL_UnlockSurface(screen); SDL_Flip(screen); while(SDL_WaitEvent(&ev)) switch(ev.type) { case SDL_KEYDOWN: switch(ev.key.keysym.sym) { case SDLK_RETURN: case SDLK_KP_ENTER: case SDLK_ESCAPE: return; case SDLK_1: v=ask_value("Misc1:"); if(v.t<4) m->misc1=v; break; case SDLK_2: v=ask_value("Misc2:"); if(v.t<4) m->misc2=v; break; case SDLK_3: v=ask_value("Misc3:"); if(v.t<4) m->misc3=v; break; case SDLK_4: case SDLK_q: j=string_list(); if(j!=-1) m->misc1=UVALUE(j,TY_LEVELSTRING); break; case SDLK_5: case SDLK_w: j=string_list(); if(j!=-1) m->misc2=UVALUE(j,TY_LEVELSTRING); break; case SDLK_6: case SDLK_e: j=string_list(); if(j!=-1) m->misc3=UVALUE(j,TY_LEVELSTRING); break; case SDLK_KP1: m->dir=5; break; case SDLK_KP2: m->dir=6; break; case SDLK_KP3: m->dir=7; break; case SDLK_KP4: m->dir=4; break; case SDLK_KP6: m->dir=0; break; case SDLK_KP7: m->dir=3; break; case SDLK_KP8: m->dir=2; break; |
︙ | ︙ | |||
1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 | memmove(cp+1,cp,(s+sz+1)-cp); if(!o) memmove(cp+1,cp,(s+sz+1)-cp); *cp=31; cp[1]=i; c++; goto redraw; } static int string_list(void) { char buf[18]; SDL_Event ev; SDL_Rect r; int n=0; int scroll=0; int i,j; redraw: r.x=r.y=0; r.w=screen->w; r.h=screen->h; SDL_FillRect(screen,&r,0xF0); r.h=8; SDL_FillRect(screen,&r,0xF1); r.y=8; r.h=screen->h-8; scrollbar(&scroll,screen->h/8-1,nlevelstrings,0,&r); SDL_LockSurface(screen); | > > > > > > > > > > > > > > > > > > > > > > | | 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 | memmove(cp+1,cp,(s+sz+1)-cp); if(!o) memmove(cp+1,cp,(s+sz+1)-cp); *cp=31; cp[1]=i; c++; goto redraw; } static inline void replace_level_string_uses(int x) { Uint32 n; Object*o; for(n=0;n<nobjects;n++) if(o=objects[n]) { if(o->misc1.t==TY_LEVELSTRING && o->misc1.u>=x) --o->misc1.u; if(o->misc2.t==TY_LEVELSTRING && o->misc2.u>=x) --o->misc2.u; if(o->misc3.t==TY_LEVELSTRING && o->misc3.u>=x) --o->misc3.u; } } static inline int count_level_string_uses(int x) { int c=0; Uint32 n; Object*o; for(n=0;n<nobjects;n++) if(o=objects[n]) { if(o->misc1.t==TY_LEVELSTRING && o->misc1.u==x) c++; if(o->misc2.t==TY_LEVELSTRING && o->misc2.u==x) c++; if(o->misc3.t==TY_LEVELSTRING && o->misc3.u==x) c++; } return c; } static int string_list(void) { char buf[18]; SDL_Event ev; SDL_Rect r; int n=0; int scroll=0; int i,j; redraw: r.x=r.y=0; r.w=screen->w; r.h=screen->h; SDL_FillRect(screen,&r,0xF0); r.h=8; SDL_FillRect(screen,&r,0xF1); r.y=8; r.h=screen->h-8; scrollbar(&scroll,screen->h/8-1,nlevelstrings,0,&r); SDL_LockSurface(screen); draw_text(0,0,"Level Strings: <INS> Add <DEL> Delete <SP> Edit <RET> Pick <F1> Preview <F2> Uses <ESC> Cancel",0xF1,0xFF); for(i=0;i<screen->h/8-1;i++) { j=i+scroll; if(j>=nlevelstrings) break; snprintf(buf,8,"%c%5d%c",n==j?'<':' ',j,n==j?'>':' '); draw_text(16,(i+1)<<3,buf,0xF0,0xFB); draw_text(80,(i+1)<<3,levelstrings[j],0xF0,0xF7); } |
︙ | ︙ | |||
1324 1325 1326 1327 1328 1329 1330 | } break; case SDLK_DELETE: if(n>=nlevelstrings) break; if(n==nlevelstrings-1) { free(levelstrings[--nlevelstrings]); } else { | < > > > > > > > > > > | 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 | } break; case SDLK_DELETE: if(n>=nlevelstrings) break; if(n==nlevelstrings-1) { free(levelstrings[--nlevelstrings]); } else { replace_level_string_uses(n+1); free(levelstrings[n]); --nlevelstrings; for(i=n;i<nlevelstrings;i++) levelstrings[i]=levelstrings[i+1]; } break; case SDLK_F1: if(nlevelstrings) modal_draw_popup(levelstrings[n]); set_cursor(XC_draft_small); break; case SDLK_F2: if(nlevelstrings) { snprintf(buf,17,"%d uses",count_level_string_uses(n)); modal_draw_popup(buf); } break; case SDLK_UP: case SDLK_KP_MINUS: n--; break; case SDLK_DOWN: case SDLK_KP_PLUS: n++; break; } if(n<=0) n=0; else if(n>=nlevelstrings) n=nlevelstrings-1; goto redraw; case SDL_VIDEOEXPOSE: goto redraw; |
︙ | ︙ |