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 
58  void duplicate(PalIndex src, PalIndex dest);
59 
62  void updatedPalette(PalIndex index, int maxindex = 0);
63 
65  void transformPalette(PalIndex index, const int16 matrix[12]);
66 
68  void untransformPalette(PalIndex index);
69 
71  bool getTransformMatrix(int16 matrix[12], PalIndex index);
72 
73  // Get a TransformMatrix from a PalTransforms value (-4.11 fixed)
74  static void getTransformMatrix(int16 matrix[12],
75  PalTransforms trans);
76 
77  // Create a custom Transform Matrix from RGBA col32. (-4.11 fixed)
78  // Alpha will set how much of original palette to keep. 0 = keep none
79  static void getTransformMatrix(int16 matrix[12], uint32 col32);
80 
82  void PixelFormatChanged(const Graphics::PixelFormat &format);
83 
85  void reset();
86 
88  void resetTransforms();
89  bool loadTransforms(Common::ReadStream &rs);
90  void saveTransforms(Common::WriteStream &ws);
91 
92  void createNativePalette(Palette *palette, int maxindex, const Graphics::PixelFormat &format);
93 
94 private:
95  Std::vector<Palette *> _palettes;
96  Graphics::PixelFormat _format;
97 
98  static PaletteManager *_paletteManager;
99 };
100 
101 } // End of namespace Ultima8
102 } // End of namespace Ultima
103 
104 #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:35
Definition: atari-screen.h:44