ScummVM API documentation
map.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 NANCY_STATE_MAP_H
23 #define NANCY_STATE_MAP_H
24 
25 #include "common/singleton.h"
26 
27 #include "engines/nancy/sound.h"
28 #include "engines/nancy/video.h"
29 
30 #include "engines/nancy/state/state.h"
31 
32 #include "engines/nancy/ui/animatedbutton.h"
33 #include "engines/nancy/ui/ornaments.h"
34 
35 namespace Nancy {
36 
37 class NancyEngine;
38 
39 namespace UI {
40 class Button;
41 }
42 
43 namespace State {
44 
45 class Map : public State, public Common::Singleton<Map> {
46 public:
47  enum State { kInit, kLoad, kRun, kExit };
48  Map();
49  virtual ~Map() = default;
50 
51  void process() override;
52  void onStateEnter(const NancyState::NancyState prevState) override;
53  bool onStateExit(const NancyState::NancyState nextState) override;
54 
55  const SoundDescription &getSound();
56 
57 protected:
59  public:
60  MapViewport() : RenderObject(6) {}
61  virtual ~MapViewport() = default;
62 
63  void init() override;
64  void updateGraphics() override;
65 
66  void loadVideo(const Common::Path &filename, const Common::Path &palette = Common::Path());
67  void playVideo() { _decoder.start(); }
68  void unloadVideo() { _decoder.close(); }
69 
70  AVFDecoder _decoder;
71  private:
72  };
73 
74  virtual void init() = 0;
75  virtual void load();
76  virtual void run() = 0;
77  virtual void registerGraphics();
78 
79  void setLabel(int labelID);
80 
81  const MAP *_mapData;
82 
83  MapViewport _viewport;
84  RenderObject _label;
85  RenderObject _closedLabel;
86  RenderObject _background;
87 
88  State _state;
89  uint16 _mapID;
90  int16 _pickedLocationID;
91  Common::Array<bool> _activeLocations;
92  Common::Array<Common::Rect> _locationLabelDests;
93 };
94 
95 class TVDMap : public Map {
96  friend class MapGlobe;
97 
98 public:
99  TVDMap();
100  virtual ~TVDMap() = default;
101 
102 private:
103  class MapGlobe : public Nancy::UI::AnimatedButton {
104  public:
105  MapGlobe(uint zOrder, TVDMap *owner) : AnimatedButton(zOrder), _gargoyleEyes(zOrder), _owner(owner) {}
106  virtual ~MapGlobe() = default;
107 
108  void init() override;
109  void registerGraphics() override;
110  void onClick() override;
111  void onTrigger() override;
112 
113  private:
114  TVDMap *_owner;
115  RenderObject _gargoyleEyes;
116  };
117 
118  void init() override;
119  void load() override;
120  void run() override;
121  void registerGraphics() override;
122 
123  bool onStateExit(const NancyState::NancyState nextState) override;
124 
125  MapGlobe _globe;
126  UI::ViewportOrnaments _ornaments;
127 };
128 
129 class Nancy1Map : public Map {
130 public:
131  Nancy1Map();
132  virtual ~Nancy1Map();
133 
134 private:
135  void init() override;
136  void load() override;
137  void run() override;
138  void registerGraphics() override;
139 
140  bool onStateExit(const NancyState::NancyState next) override;
141 
142  UI::Button *_button;
143 };
144 
145 #define NancyMapState Nancy::State::Map::instance()
146 
147 } // End of namespace State
148 } // End of namespace Nancy
149 
150 namespace Common {
151 
152 template<>
153 Nancy::State::Map *Singleton<Nancy::State::Map>::makeInstance();
154 
155 } // End of namespace Common
156 
157 #endif // NANCY_STATE_MAP_H
Definition: map.h:129
Definition: animatedbutton.h:33
Definition: map.h:95
Definition: path.h:52
Definition: enginedata.h:176
Definition: soundequalizerpuzzle.h:27
Definition: map.h:45
Definition: renderobject.h:36
Definition: ornaments.h:30
Definition: map.h:58
Definition: button.h:33
Definition: algorithm.h:29
Definition: video.h:41
Definition: commontypes.h:254
Definition: input.h:69
Definition: actionmanager.h:32
Definition: singleton.h:42