ScummVM API documentation
imagemgr.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 ULTIMA4_GFX_IMAGEMGR_H
23 #define ULTIMA4_GFX_IMAGEMGR_H
24 
25 #include "ultima/ultima4/gfx/image.h"
26 #include "ultima/ultima4/core/observer.h"
27 #include "common/hashmap.h"
28 #include "common/hash-str.h"
29 
30 namespace Common {
31 class File;
32 }
33 
34 namespace Image {
35 class ImageDecoder;
36 }
37 
38 namespace Ultima {
39 namespace Ultima4 {
40 
41 class ConfigElement;
42 class Debug;
43 class ImageSet;
44 class Settings;
45 
46 /*
47  * The image manager is responsible for loading and keeping track of
48  * the various images.
49  */
50 
51 #define BKGD_SHAPES "tiles"
52 #define BKGD_CHARSET "charset"
53 #define BKGD_BORDERS "borders"
54 #define BKGD_INTRO "title"
55 #define BKGD_OPTIONS_TOP "options_top"
56 #define BKGD_OPTIONS_BTM "options_btm"
57 #define BKGD_TREE "tree"
58 #define BKGD_PORTAL "portal"
59 #define BKGD_OUTSIDE "outside"
60 #define BKGD_INSIDE "inside"
61 #define BKGD_WAGON "wagon"
62 #define BKGD_GYPSY "gypsy"
63 #define BKGD_ABACUS "abacus"
64 #define BKGD_HONCOM "honcom"
65 #define BKGD_VALJUS "valjus"
66 #define BKGD_SACHONOR "sachonor"
67 #define BKGD_SPIRHUM "spirhum"
68 #define BKGD_ANIMATE "beasties"
69 #define BKGD_KEY "key"
70 #define BKGD_HONESTY "honesty"
71 #define BKGD_COMPASSN "compassn"
72 #define BKGD_VALOR "valor"
73 #define BKGD_JUSTICE "justice"
74 #define BKGD_SACRIFIC "sacrific"
75 #define BKGD_HONOR "honor"
76 #define BKGD_SPIRIT "spirit"
77 #define BKGD_HUMILITY "humility"
78 #define BKGD_TRUTH "truth"
79 #define BKGD_LOVE "love"
80 #define BKGD_COURAGE "courage"
81 #define BKGD_STONCRCL "stoncrcl"
82 #define BKGD_RUNE_INF "rune0"
83 #define BKGD_SHRINE_HON "rune1"
84 #define BKGD_SHRINE_COM "rune2"
85 #define BKGD_SHRINE_VAL "rune3"
86 #define BKGD_SHRINE_JUS "rune4"
87 #define BKGD_SHRINE_SAC "rune5"
88 #define BKGD_SHRINE_HNR "rune6"
89 #define BKGD_SHRINE_SPI "rune7"
90 #define BKGD_SHRINE_HUM "rune8"
91 #define BKGD_GEMTILES "gemtiles"
92 
93 enum ImageFixup {
94  FIXUP_NONE,
95  FIXUP_INTRO,
96  FIXUP_ABYSS,
97  FIXUP_ABACUS,
98  FIXUP_DUNGNS,
99  FIXUP_BLACKTRANSPARENCYHACK,
100  FIXUP_FMTOWNSSCREEN
101 };
102 
106 class ImageInfo {
107 public:
108  ~ImageInfo();
109 
110  Common::String _name;
111  Common::String _filename;
112  int _width, _height, _depth;
113  int _prescale;
114  Common::String _filetype;
115  int _tiles;
116  bool _introOnly;
118  bool _xu4Graphic;
119  ImageFixup _fixup;
122 
123  bool hasBlackBackground();
124 };
125 
129 class ImageMgr : Observer<Settings *> {
130 public:
131  static ImageMgr *getInstance();
132  static void destroy();
133 
137  ImageInfo *get(const Common::String &name, bool returnUnscaled = false);
138 
142  SubImage *getSubImage(const Common::String &name);
143 
147  void freeIntroBackgrounds();
148  const Common::Array<Common::String> &getSetNames();
149  Common::File *getImageFile(ImageInfo *info);
150  bool imageExists(ImageInfo *info);
151 
152 private:
153  ImageMgr();
154  ~ImageMgr();
155  void init();
156 
157  ImageSet *loadImageSetFromConf(const ConfigElement &conf);
158  ImageInfo *loadImageInfoFromConf(const ConfigElement &conf);
159  SubImage *loadSubImageFromConf(const ImageInfo *info, const ConfigElement &conf);
160 
164  ImageSet *getSet(const Common::String &setname);
165 
169  ImageInfo *getInfo(const Common::String &name);
170 
174  ImageInfo *getInfoFromSet(const Common::String &name, ImageSet *set);
175 
176  Common::String guessFileType(const Common::String &filename);
177 
178  void fixupIntro(Image *im, int prescale);
179  void fixupAbyssVision(Image *im, int prescale);
180  void fixupAbacus(Image *im, int prescale);
181 
186  void fixupDungNS(Image *im, int prescale);
187 
192  void fixupFMTowns(Image *im, int prescale);
193 
197  void update(Settings *newSettings);
198 
202  ::Image::ImageDecoder *createDecoder(const Common::String &fileType, int width, int height, int bpp);
203 
204  static ImageMgr *_instance;
206  Common::Array<Common::String> _imageSetNames;
207  ImageSet *_baseSet;
208  ImageInfo _screenInfo;
209  uint *_abyssData;
210 };
211 
212 #define imageMgr (ImageMgr::getInstance())
213 
214 } // End of namespace Ultima4
215 } // End of namespace Ultima
216 
217 #endif
Definition: image_decoder.h:53
Definition: str.h:59
int _tiles
Definition: imagemgr.h:115
Definition: settings.h:147
ImageFixup _fixup
Definition: imagemgr.h:119
Definition: config.h:126
Definition: imagemgr.h:106
Definition: observer.h:37
Image * _image
Definition: imagemgr.h:120
Definition: imagemgr.h:129
int _transparentIndex
Definition: imagemgr.h:117
Definition: image.h:49
Definition: detection.h:27
Definition: hashmap.h:85
Definition: file.h:47
Definition: algorithm.h:29
Definition: movie_decoder.h:32
bool _introOnly
Definition: imagemgr.h:116
bool _xu4Graphic
Definition: imagemgr.h:118