CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

PALETTEC.H (4086B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /* $Header: /CounterStrike/PALETTE.H 2     9/23/97 11:00p Steve_t $ */
     17 /***********************************************************************************************
     18  ***              C O N F I D E N T I A L  ---  W E S T W O O D  S T U D I O S               ***
     19  ***********************************************************************************************
     20  *                                                                                             *
     21  *                 Project Name : Command & Conquer                                            *
     22  *                                                                                             *
     23  *                    File Name : PALETTE.H                                                    *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 12/02/95                                                     *
     28  *                                                                                             *
     29  *                  Last Update : December 2, 1995 [JLB]                                       *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 
     36 #ifndef PALETTE_Hx
     37 #define PALETTE_Hx
     38 
     39 #include	"rgb.h"
     40 
     41 /*
     42 **	The palette class is used to manipulate a palette as a whole. All 256 colors are
     43 **	represented by the palette class object.
     44 */
     45 class PaletteClass
     46 {
     47 	public:
     48 		enum {
     49 			COLOR_COUNT=256			// Number of color indices on the palette.
     50 		};
     51 
     52 		PaletteClass(void) {};
     53 		PaletteClass(RGBClass const & rgb);
     54 
     55 		RGBClass & operator[] (unsigned index) {return(Palette[index % COLOR_COUNT]);};
     56 		const RGBClass & operator[] (unsigned index) const {return(Palette[index % COLOR_COUNT]);};
     57 		int operator == (PaletteClass const & palette) const;
     58 		int operator != (PaletteClass const & palette) const {return(!(operator ==(palette)));};
     59 		PaletteClass & operator = (PaletteClass const & palette);
     60 		
     61 		// Removed these and replaced with function for clarity. ST - 5/9/2019
     62 		//operator const unsigned char * (void) const {return((const unsigned char *)&Palette[0]);};
     63 		//operator unsigned char * (void) {return((unsigned char *)&Palette[0]);};
     64 		const void *Get_Data(void) const { return &Palette[0]; }
     65 		void *Get_Data(void) { return &Palette[0]; }
     66 
     67 		void Adjust(int ratio);
     68 		void Adjust(int ratio, PaletteClass const & palette);
     69 		void Partial_Adjust(int ratio, char *lut);
     70 		void Partial_Adjust(int ratio, PaletteClass const & palette, char *lut);
     71 		void Set(int time = 0, void (*callback)(void) = 0) const;
     72 		int Closest_Color(RGBClass const & rgb) const;
     73 
     74 		static PaletteClass const & CurrentPalette;
     75 
     76 	protected:
     77 		RGBClass Palette[COLOR_COUNT];
     78 };
     79 
     80 
     81 #endif