ScummVM API documentation
palette_manager.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA8_GFX_PALETTEMANAGER_H
23 #define ULTIMA8_GFX_PALETTEMANAGER_H
24 
25 #include "ultima/shared/std/containers.h"
26 #include "graphics/pixelformat.h"
27 #include "ultima/ultima8/gfx/pal_transforms.h"
28 
29 namespace Ultima {
30 namespace Ultima8 {
31 
32 class Palette;
33 
35 public:
36  explicit PaletteManager(const Graphics::PixelFormat &format);
37  ~PaletteManager();
38 
39  static PaletteManager *get_instance() {
40  return _paletteManager;
41  }
42 
43  enum PalIndex {
44  Pal_Game = 0,
45  Pal_Movie = 1,
46  Pal_Diff = 2, // Crusaders only - difficulty screen??
47  Pal_Misc = 3, // Crusaders only - game menu
48  Pal_Misc2 = 4, // Crusaders only - ??
49  Pal_Star = 5, // Crusaders only - ??
50  Pal_Cred = 6, // Crusader: No regret only (but mentioned in the no remorse exe!)
51  Pal_JPFontStart = 16
52  };
53 
54  void load(PalIndex index, Common::ReadStream &rs, Common::ReadStream &xformrs);
55  void load(PalIndex index, Common::ReadStream &rs);
56  Palette *getPalette(PalIndex index);
57  uint getNumPalettes() const { return _palettes.size(); }
58 
59  void duplicate(PalIndex src, PalIndex dest);
60 
63  void updatedPalette(PalIndex index, int maxindex = 0);
64 
66  void transformPalette(PalIndex index, const int16 matrix[12]);
67 
69  void untransformPalette(PalIndex index);
70 
72  bool getTransformMatrix(int16 matrix[12], PalIndex index);
73 
74  // Get a TransformMatrix from a PalTransforms value (-4.11 fixed)
75  static void getTransformMatrix(int16 matrix[12],
76  PalTransforms trans);
77 
78  // Create a custom Transform Matrix from RGBA col32. (-4.11 fixed)
79  // Alpha will set how much of original palette to keep. 0 = keep none
80  static void getTransformMatrix(int16 matrix[12], uint32 col32);
81 
83  void PixelFormatChanged(const Graphics::PixelFormat &format);
84 
86  void reset();
87 
89  void resetTransforms();
90  bool loadTransforms(Common::ReadStream &rs);
91  void saveTransforms(Common::WriteStream &ws);
92 
93 private:
94  Std::vector<Palette *> _palettes;
95  Graphics::PixelFormat _format;
96 
97  static PaletteManager *_paletteManager;
98 };
99 
100 } // End of namespace Ultima8
101 } // End of namespace Ultima
102 
103 #endif
void transformPalette(PalIndex index, const int16 matrix[12])
Apply a transform matrix to a palette (-4.11 fixed)
void updatedPalette(PalIndex index, int maxindex=0)
Definition: stream.h:77
Definition: pixelformat.h:138
void untransformPalette(PalIndex index)
reset the transformation matrix of a palette
bool getTransformMatrix(int16 matrix[12], PalIndex index)
Get the current TransformMatrix for the given index.
Definition: detection.h:27
void resetTransforms()
Reset all the transforms back to default.
void PixelFormatChanged(const Graphics::PixelFormat &format)
Change the pixel format used by the PaletteManager.
void reset()
Reset the Palette Manager.
Definition: palette_manager.h:34
Definition: stream.h:385
Definition: containers.h:38
Definition: palette.h:36
Definition: atari-screen.h:42