Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | pmbaty | 1 | /* |
| 2 | * Portions of this file are copyright Rebirth contributors and licensed as |
||
| 3 | * described in COPYING.txt. |
||
| 4 | * Portions of this file are copyright Parallax Software and licensed |
||
| 5 | * according to the Parallax license below. |
||
| 6 | * See COPYING.txt for license details. |
||
| 7 | |||
| 8 | THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
||
| 9 | SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
||
| 10 | END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
||
| 11 | ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
||
| 12 | IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
||
| 13 | SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
||
| 14 | FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
||
| 15 | CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
||
| 16 | AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
||
| 17 | COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
||
| 18 | */ |
||
| 19 | |||
| 20 | /* |
||
| 21 | * |
||
| 22 | * Functions for loading palettes |
||
| 23 | * |
||
| 24 | */ |
||
| 25 | |||
| 26 | #include <string.h> |
||
| 27 | #include <stdlib.h> |
||
| 28 | |||
| 29 | #include "maths.h" |
||
| 30 | #include "vecmat.h" |
||
| 31 | #include "gr.h" |
||
| 32 | #include "3d.h" |
||
| 33 | #include "palette.h" |
||
| 34 | #include "rle.h" |
||
| 35 | #include "inferno.h" |
||
| 36 | #include "game.h" |
||
| 37 | #include "gamepal.h" |
||
| 38 | #include "mission.h" |
||
| 39 | #include "newmenu.h" |
||
| 40 | #include "texmerge.h" |
||
| 41 | #include "piggy.h" |
||
| 42 | #include "strutil.h" |
||
| 43 | #include "gauges.h" |
||
| 44 | |||
| 45 | namespace dsx { |
||
| 46 | |||
| 47 | char last_palette_loaded[FILENAME_LEN]=""; |
||
| 48 | char last_palette_loaded_pig[FILENAME_LEN]=""; |
||
| 49 | |||
| 50 | //load a palette by name. returns 1 if new palette loaded, else 0 |
||
| 51 | //if used_for_level is set, load pig, etc. |
||
| 52 | //if no_change_screen is set, the current screen does not get remapped, |
||
| 53 | //and the hardware palette does not get changed |
||
| 54 | int load_palette(const char *name,int used_for_level,int no_change_screen) |
||
| 55 | { |
||
| 56 | char pigname[FILENAME_LEN]; |
||
| 57 | palette_array_t old_pal; |
||
| 58 | |||
| 59 | //special hack to tell that palette system about a pig that's been loaded elsewhere |
||
| 60 | if (used_for_level == -2) { |
||
| 61 | strncpy(last_palette_loaded_pig, name, sizeof(last_palette_loaded_pig) - 1); |
||
| 62 | return 1; |
||
| 63 | } |
||
| 64 | |||
| 65 | if (name==NULL) |
||
| 66 | name = last_palette_loaded_pig; |
||
| 67 | |||
| 68 | if (used_for_level && d_stricmp(last_palette_loaded_pig,name) != 0) { |
||
| 69 | |||
| 70 | struct splitpath_t path; |
||
| 71 | d_splitpath(name,&path); |
||
| 72 | snprintf(pigname, sizeof(pigname), "%.*s.pig", DXX_ptrdiff_cast_int(path.base_end - path.base_start), path.base_start); |
||
| 73 | //if not editor, load pig first so small install message can come |
||
| 74 | //up in old palette. If editor version, we must load the pig after |
||
| 75 | //the palette is loaded so we can remap new textures. |
||
| 76 | #if !DXX_USE_EDITOR |
||
| 77 | piggy_new_pigfile(pigname); |
||
| 78 | #endif |
||
| 79 | } |
||
| 80 | |||
| 81 | if (d_stricmp(last_palette_loaded,name) != 0) { |
||
| 82 | |||
| 83 | old_pal = gr_palette; |
||
| 84 | |||
| 85 | strncpy(last_palette_loaded,name,sizeof(last_palette_loaded)); |
||
| 86 | |||
| 87 | gr_use_palette_table(name); |
||
| 88 | |||
| 89 | if (Game_wind && !no_change_screen) |
||
| 90 | gr_remap_bitmap_good(grd_curscreen->sc_canvas.cv_bitmap, old_pal, -1, -1); |
||
| 91 | |||
| 92 | if (!no_change_screen) |
||
| 93 | gr_palette_load(gr_palette); |
||
| 94 | |||
| 95 | newmenu_free_background(); // palette changed! free menu! |
||
| 96 | gr_remap_color_fonts(); |
||
| 97 | |||
| 98 | Color_0_31_0 = -1; //for gauges |
||
| 99 | } |
||
| 100 | |||
| 101 | |||
| 102 | if (used_for_level && d_stricmp(last_palette_loaded_pig,name) != 0) { |
||
| 103 | |||
| 104 | strncpy(last_palette_loaded_pig,name,sizeof(last_palette_loaded_pig)); |
||
| 105 | |||
| 106 | #if DXX_USE_EDITOR |
||
| 107 | piggy_new_pigfile(pigname); |
||
| 108 | #endif |
||
| 109 | |||
| 110 | texmerge_flush(); |
||
| 111 | rle_cache_flush(); |
||
| 112 | } |
||
| 113 | |||
| 114 | return 1; |
||
| 115 | } |
||
| 116 | |||
| 117 | } |