|
35 | 35 | #include "pngutils/pngutils.h" |
36 | 36 | #include "ship/ship.h" |
37 | 37 | #include "tgautils/tgautils.h" |
| 38 | +#include "cfile/cfilesystem.h" |
38 | 39 |
|
39 | 40 | #include <ctype.h> |
40 | 41 | #include <limits.h> |
|
47 | 48 | /** |
48 | 49 | * @todo upgrade this to an inline funciton, taking bitmap_entry and const char* as arguments |
49 | 50 | */ |
50 | | -#define EFF_FILENAME_CHECK { if ( be->type == BM_TYPE_EFF ) strcpy_s( filename, be->info.ani.eff.filename ); else strcpy_s( filename, be->filename ); } |
| 51 | +#define EFF_FILENAME_CHECK \ |
| 52 | +{ \ |
| 53 | + if ( be->type == BM_TYPE_EFF ) { \ |
| 54 | + strcpy_s( filename, be->info.ani.eff.filename ); \ |
| 55 | + if (be->info.ani.eff.in_subdir) { \ |
| 56 | + if (!set_temp_subdir_pathtype(bm_bitmaps[be->info.ani.first_frame].filename)) { \ |
| 57 | + mprintf(("BMPMAN: Failed to set temporary pathtype for %s: EFF_FILENAME_CHECK failed!\n", be->filename)); \ |
| 58 | + } \ |
| 59 | + } \ |
| 60 | + } \ |
| 61 | + else { \ |
| 62 | + strcpy_s( filename, be->filename ); \ |
| 63 | + } \ |
| 64 | +} |
51 | 65 | // -------------------------------------------------------------------------------------------------------------------- |
52 | 66 | // Monitor variables |
53 | 67 | MONITOR(NumBitmapPage) |
@@ -83,6 +97,8 @@ const int BM_ANI_NUM_TYPES = sizeof(bm_ani_type_list) / sizeof(bm_ani_type_list[ |
83 | 97 | void(*bm_set_components)(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a) = NULL; |
84 | 98 | void(*bm_set_components_32)(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a) = NULL; |
85 | 99 |
|
| 100 | +extern cf_pathtype Pathtypes[CF_MAX_PATH_TYPES]; |
| 101 | + |
86 | 102 | // -------------------------------------------------------------------------------------------------------------------- |
87 | 103 | // Declaration of protected variables (defined in cmdline.cpp). |
88 | 104 | extern int Cmdline_cache_bitmaps; |
@@ -1311,8 +1327,9 @@ int bm_load(const SCP_string& filename) { |
1311 | 1327 | return bm_load(filename.c_str()); |
1312 | 1328 | } |
1313 | 1329 |
|
1314 | | -bool bm_load_and_parse_eff(const char *filename, int dir_type, int *nframes, int *nfps, int *key, BM_TYPE *type) { |
| 1330 | +bool bm_load_and_parse_eff(const char *filename, int dir_type, int *nframes, int *nfps, int *key, BM_TYPE *type, bool *in_subdir) { |
1315 | 1331 | int frames = 0, fps = 30, keyframe = 0; |
| 1332 | + bool subdir = false; |
1316 | 1333 | char ext[8]; |
1317 | 1334 | BM_TYPE c_type = BM_TYPE_NONE; |
1318 | 1335 | char file_text[1024]; |
@@ -1350,6 +1367,11 @@ bool bm_load_and_parse_eff(const char *filename, int dir_type, int *nframes, int |
1350 | 1367 | return false; |
1351 | 1368 | } |
1352 | 1369 |
|
| 1370 | + if (optional_string( "$Subdir:" )) { |
| 1371 | + stuff_boolean(&subdir); |
| 1372 | + } |
| 1373 | + |
| 1374 | + |
1353 | 1375 | // done with EFF so unpause parsing so whatever can continue |
1354 | 1376 | unpause_parse(); |
1355 | 1377 |
|
@@ -1386,6 +1408,8 @@ bool bm_load_and_parse_eff(const char *filename, int dir_type, int *nframes, int |
1386 | 1408 | if (key) |
1387 | 1409 | *key = keyframe; |
1388 | 1410 |
|
| 1411 | + *in_subdir = subdir; |
| 1412 | + |
1389 | 1413 | return true; |
1390 | 1414 | } |
1391 | 1415 |
|
@@ -1501,6 +1525,7 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke |
1501 | 1525 | char filename[MAX_FILENAME_LEN]; |
1502 | 1526 | int reduced = 0; |
1503 | 1527 | int anim_fps = 0, anim_frames = 0, key = 0; |
| 1528 | + bool in_subdir = false; |
1504 | 1529 | float anim_total_time = 0.0f; |
1505 | 1530 | int anim_width = 0, anim_height = 0; |
1506 | 1531 | BM_TYPE type = BM_TYPE_NONE, eff_type = BM_TYPE_NONE, c_type = BM_TYPE_NONE; |
@@ -1597,7 +1622,7 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke |
1597 | 1622 |
|
1598 | 1623 | // it's an effect file, any readable image type with eff being txt |
1599 | 1624 | if (type == BM_TYPE_EFF) { |
1600 | | - if (!bm_load_and_parse_eff(filename, dir_type, &anim_frames, &anim_fps, &key, &eff_type)) { |
| 1625 | + if (!bm_load_and_parse_eff(filename, dir_type, &anim_frames, &anim_fps, &key, &eff_type, &in_subdir)) { |
1601 | 1626 | mprintf(("BMPMAN: Error reading EFF\n")); |
1602 | 1627 | if (img_cfp != nullptr) |
1603 | 1628 | cfclose(img_cfp); |
@@ -1695,6 +1720,10 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke |
1695 | 1720 | return -1; |
1696 | 1721 | } |
1697 | 1722 |
|
| 1723 | + if (in_subdir) { |
| 1724 | + set_temp_subdir_pathtype(filename); |
| 1725 | + } |
| 1726 | + |
1698 | 1727 | int first_handle = bm_get_next_handle(); |
1699 | 1728 |
|
1700 | 1729 | for (i = 0; i < anim_frames; i++) { |
@@ -1760,6 +1789,11 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke |
1760 | 1789 | bm_bitmaps[n + i].num_mipmaps = mm_lvl; |
1761 | 1790 | bm_bitmaps[n + i].mem_taken = (size_t)img_size; |
1762 | 1791 | bm_bitmaps[n + i].dir_type = dir_type; |
| 1792 | + bm_bitmaps[n + i].info.ani.eff.in_subdir = in_subdir; |
| 1793 | + if (in_subdir) |
| 1794 | + bm_bitmaps[n + i].dir_type = CF_TYPE_TEMP_SUBDIR_LOOKUP; |
| 1795 | + else |
| 1796 | + bm_bitmaps[n + i].dir_type = dir_type; |
1763 | 1797 |
|
1764 | 1798 | bm_bitmaps[n + i].load_count++; |
1765 | 1799 |
|
@@ -2594,6 +2628,10 @@ void bm_page_in_stop() { |
2594 | 2628 | if ((bm_bitmaps[i].type != BM_TYPE_NONE) && (bm_bitmaps[i].type != BM_TYPE_RENDER_TARGET_DYNAMIC) && (bm_bitmaps[i].type != BM_TYPE_RENDER_TARGET_STATIC)) { |
2595 | 2629 | if (bm_bitmaps[i].preloaded) { |
2596 | 2630 | if (bm_preloading) { |
| 2631 | + if (bm_bitmaps[i].type == BM_TYPE_EFF && bm_bitmaps[i].info.ani.eff.in_subdir) { |
| 2632 | + set_temp_subdir_pathtype(bm_bitmaps[i].filename); |
| 2633 | + } |
| 2634 | + |
2597 | 2635 | if (!gr_preload(bm_bitmaps[i].handle, (bm_bitmaps[i].preloaded == 2))) { |
2598 | 2636 | mprintf(("Out of VRAM. Done preloading.\n")); |
2599 | 2637 | bm_preloading = 0; |
|
0 commit comments