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