ScummVM API documentation
ImageManager.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 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 //=============================================================================
32 // Author: Arvind
33 // Purpose: Contains the image manager class - used to manage in-game assets
34 //=============================================================================
35 #ifndef CRAB_IMAGEMANAGER_H
36 #define CRAB_IMAGEMANAGER_H
37 
38 #include "crab/image/Image.h"
39 #include "crab/TMX/TMXTileSet.h"
40 
41 #include "common/hashmap.h"
42 
43 namespace Crab {
44 
45 // We use this object as the key for all image assets
46 typedef uint ImageKey;
47 
48 // Since we use uint as a key for images, our loadImgKey function is loadNum
49 #define loadImgKey loadNum
50 
51 namespace pyrodactyl {
52 namespace image {
53 // We store images here
54 typedef Common::HashMap<ImageKey, Image> TextureMap;
55 
56 // Two image maps are used in the game - current (changes with level) and common
57 enum MapID {
58  MAP_CURRENT,
59  MAP_COMMON,
60  MAP_TOTAL
61 };
62 
63 class ImageManager {
64  // Assets are stored in images
65  // Common is stuff used everywhere - this is only loaded once
66  TextureMap _map[MAP_TOTAL];
67 
68  // The default image for all invalid image names
69  Image _invalidImg;
70 
71 public:
72  // The tile sets used in the level
73  TMX::TileSetGroup _tileset;
74 
75  // This image is used to notify player about changes to quests and inventory
76  ImageKey _notify;
77 
78  ImageManager() {
79  _notify = 0;
80  }
81 
82  ~ImageManager() {}
83 
84  void quit();
85 
86  bool init();
87  // image related stuff
88 
89  // Load all images specified in an xml file in a map
90  void loadMap(const Common::Path &filename, const MapID &mapid = MAP_CURRENT);
91 
92  void getTexture(const ImageKey &id, Image &data);
93  Image &getTexture(const ImageKey &id);
94  bool validTexture(const ImageKey &id);
95 
96  void draw(const int &x, const int &y, const ImageKey &id,
97  Common::Rect *clip = nullptr, const TextureFlipType &flip = FLIP_NONE);
98  void draw(const int &x, const int &y, const ImageKey &id,
99  Rect *clip, const TextureFlipType &flip = FLIP_NONE);
100 
101  void dimScreen();
102  void blackScreen();
103 
104  // Draw the notification icon
105  void notifyDraw(const int &x, const int &y) {
106  auto *k = &getTexture(_notify);
107  draw(x - k->w() / 2, y - k->h() / 2, _notify);
108  }
109 };
110 
111 } // End of namespace image
112 } // End of namespace pyrodactyl
113 
114 } // End of namespace Crab
115 
116 #endif // CRAB_IMAGEMANAGER_H
Definition: Rectangle.h:42
Definition: rect.h:144
Definition: path.h:52
Definition: ImageManager.h:63
Definition: moveeffect.h:37
Definition: movie_decoder.h:32
Definition: TMXTileSet.h:86