| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef TEXPAGE_H |
| 20 | #define TEXPAGE_H |
| 21 | |
| 22 | #include "manage.h" |
| 23 | #include "cfile.h" |
| 24 | #include "pstypes.h" |
| 25 | #include "procedurals.h" |
| 26 | |
| 27 | struct mngs_texture_page { |
| 28 | char bitmap_name[PAGENAME_LEN]; // filename for the bitmap associated with this texture |
| 29 | char destroy_name[PAGENAME_LEN]; // filename for the destroyed bitmap |
| 30 | char sound_name[PAGENAME_LEN]; // filename for the destroyed bitmap |
| 31 | texture tex_struct; |
| 32 | |
| 33 | int num_proc_elements; |
| 34 | |
| 35 | uint8_t proc_heat, proc_light, proc_thickness, osc_value; |
| 36 | |
| 37 | float proc_evaluation_time, osc_time; |
| 38 | |
| 39 | uint8_t proc_type[MAX_PROC_ELEMENTS]; |
| 40 | |
| 41 | uint8_t proc_frequency[MAX_PROC_ELEMENTS]; |
| 42 | uint8_t proc_speed[MAX_PROC_ELEMENTS]; |
| 43 | |
| 44 | uint8_t proc_size[MAX_PROC_ELEMENTS]; |
| 45 | |
| 46 | uint8_t proc_x1[MAX_PROC_ELEMENTS]; |
| 47 | uint8_t proc_y1[MAX_PROC_ELEMENTS]; |
| 48 | uint8_t proc_x2[MAX_PROC_ELEMENTS]; |
| 49 | uint8_t proc_y2[MAX_PROC_ELEMENTS]; |
| 50 | |
| 51 | uint16_t proc_palette[256]; |
| 52 | }; |
| 53 | |
| 54 | // Texture page functions |
| 55 | //--------------------------------------------------------------- |
| 56 | |
| 57 | // Reads a texture page from an open file. Returns 0 on error. |
| 58 | |
| 59 | int mng_ReadTexturePage(CFILE *infile, mngs_texture_page *texpage); |
| 60 | |
| 61 | // Given an open file pointer and a texture handle, writes that texture page out |
| 62 | void mng_WriteTexturePage(CFILE *outfile, mngs_texture_page *texpage); |
| 63 | |
| 64 | // Reads a texture page from an open file. Returns 0 on error. |
| 65 | |
| 66 | int mng_ReadNewTexturePage(CFILE *infile, mngs_texture_page *texpage); |
| 67 | |
| 68 | // Given an open file pointer and a texture handle, writes that texture page out |
| 69 | void mng_WriteNewTexturePage(CFILE *outfile, mngs_texture_page *texpage); |
| 70 | |
| 71 | // Given a texture page, allocs a texture and loads that textures associated bitmap |
| 72 | // returns texture handle on success, -1 if fail |
| 73 | int mng_SetAndLoadTexture(mngs_texture_page *texpage); |
| 74 | |
| 75 | // Reads in a texture page from the local table file, superseding any texture |
| 76 | // already in RAM with that same name |
| 77 | void mng_LoadLocalTexturePage(CFILE *); |
| 78 | |
| 79 | // Reads in a page off the net |
| 80 | void mng_LoadNetTexturePage(CFILE *, bool overlay = false); |
| 81 | |
| 82 | // Reads in the texpage named "name" into texpage struct |
| 83 | // Returns 0 on error, else 1 if all is good |
| 84 | int mng_FindSpecificTexPage(char *name, mngs_texture_page *texpage, int offset = 0); |
| 85 | |
| 86 | // Given a texpage and a texture handle, attempts to make texture n correspond to |
| 87 | // to the texpage. |
| 88 | int mng_AssignTexPageToTexture(mngs_texture_page *texpage, int n, CFILE *infile = NULL); |
| 89 | |
| 90 | // Copies values from a texture_page into a texture |
| 91 | void mng_AssignTextureToTexPage(int n, mngs_texture_page *texpage); |
| 92 | |
| 93 | // First searches through the texture index to see if the texture is already |
| 94 | // loaded. If not, searches in the table file and loads it. |
| 95 | // Returns index of texture found, -1 if not |
| 96 | int mng_GetGuaranteedTexturePage(char *name, CFILE *infile = NULL); |
| 97 | |
| 98 | // Given some texture names, finds them in the table file and deletes them |
| 99 | // If local is 1, deletes from the local table file |
| 100 | int mng_DeleteTexPageSeries(char *names[], int num_textures, int local); |
| 101 | |
| 102 | #endif |