| 468 | vector<igraph *> usedigraphs; // char codes ('\1' + n) |
| 469 | |
| 470 | void addigraph(char *fname) |
| 471 | { |
| 472 | char *b, *s = newstring(fname), *mnem = strtok_r(s, "_", &b), *r; |
| 473 | if(mnem && *mnem && !igraphs.access(mnem)) |
| 474 | { // new mnem |
| 475 | defformatstring(filename)("%s%s.png", IGRAPHPATH, fname); |
| 476 | Texture *tex = textureload(filename); |
| 477 | if(tex != notexture && tex->xs && tex->ys) |
| 478 | { |
| 479 | igraph &ig = igraphs[newstring(mnem)]; |
| 480 | ig.fname = fname; |
| 481 | ig.tex = tex; |
| 482 | ig.used = !mnem[1] && *mnem >= '1' && *mnem <= '9' ? *mnem - '0' : 0; |
| 483 | if(ig.used && usedigraphs.inrange(ig.used)) usedigraphs[ig.used] = &ig; // hardcode "1".."9" |
| 484 | while((r = strtok_r(NULL, "_", &b))) ig.frames.add(max(5, (int)ATOI(r))); |
| 485 | if(ig.frames.empty()) ig.frames.add(igraphdefaultframetime); |
| 486 | while(ig.frames.length() < tex->xs / tex->ys) ig.frames.add(ig.frames.last()); |
| 487 | loopv(ig.frames) if(i) ig.frames[i] += ig.frames[i - 1]; |
| 488 | #ifdef _DEBUG |
| 489 | clientlogf(" loaded igraph \"%s\", short \"%s\", %dx%d, %d frame%s", fname, mnem, tex->xs, tex->ys, ig.frames.length(), ig.frames.length() > 1 ? "s" : ""); |
| 490 | #endif |
| 491 | } |
| 492 | } |
| 493 | igraphsi[fname] = 0; |
| 494 | delstring(s); |
| 495 | } |
| 496 | |
| 497 | void updateigraphs() // read all filenames and parse new ones (also preloads the textures) |
| 498 | { |
no test coverage detected