palette.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2000-2001  The Exult Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef PALETTE_H
00020 #define PALETTE_H
00021 
00022 class Image_window8;
00023 
00024 /*
00025  *  Palette #'s in 'palettes.flx':
00026  */
00027 const int PALETTE_DAY = 0;
00028 const int PALETTE_DUSK = 1;
00029 const int PALETTE_DAWN = 1;   // Think this is it.
00030 const int PALETTE_NIGHT = 2;
00031 const int PALETTE_INVISIBLE = 3;  // When Avatar is invisible.
00032           // 4 looks just like #1.
00033 const int PALETTE_HAZE = 5;
00034           // 6 looks a little brighter than #2.
00035           // 7 is somewhat warmer.  Torch?
00036 const int PALETTE_RED = 8;    // Used when hit in combat.
00037           // 9 has lots of black.
00038 const int PALETTE_LIGHTNING = 10;
00039 
00040 
00041 
00042 class Palette
00043   {
00044     Image_window8 *win;
00045     unsigned char pal1[768];
00046     unsigned char pal2[768];
00047     int brightness;
00048     int max_val;
00049     int palette;    // Palette #.
00050     bool faded_out;   // true if faded palette to black.
00051     bool fades_enabled;
00052 
00053 public:
00054     Palette();
00055     ~Palette();
00056           // Fade palette in/out.
00057     void fade(int cycles, int inout, int pal_num = -1);
00058     bool is_faded_out()
00059       { return faded_out; }
00060     void flash_red(); // Flash red for a moment.
00061           // Set desired palette.
00062     void set(int pal_num, int new_brightness = -1, 
00063               bool repaint=true);
00064     int get_brightness()  // Percentage:  100 = normal.
00065       { return brightness; }
00066           //   the user.
00067     void set_fades_enabled(bool f) { fades_enabled = f; }
00068     bool get_fades_enabled() const { return fades_enabled; }
00069 
00070     void apply(bool repaint=true);
00071     void load(const char *fname, int index,
00072         const char *xfname = 0, int xindex = -1);
00073     void set_brightness(int bright);
00074     void set_max_val(int max);
00075     int get_max_val();
00076     void fade_in(int cycles);
00077     void fade_out(int cycles);
00078     int find_color(int r, int g, int b);
00079     void create_trans_table(unsigned char br, unsigned bg,
00080       unsigned bb, int alpha, unsigned char *table);
00081     void show();
00082 
00083     void set_color(int nr, int r, int g, int b);
00084     unsigned char get_red(int nr) { return pal1[3*nr]; }
00085     unsigned char get_green(int nr) { return pal1[3*nr + 1]; }
00086     unsigned char get_blue(int nr) { return pal1[3*nr + 2]; }
00087     void set_palette (unsigned char palnew[768]);
00088   };
00089   
00090 
00091 #endif

Generated on Mon Jul 9 14:42:49 2007 for ExultEngine by  doxygen 1.5.1