ScummVM API documentation
map_window.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 NUVIE_CORE_MAP_WINDOW_H
23#define NUVIE_CORE_MAP_WINDOW_H
24
25#include "ultima/nuvie/core/nuvie_defs.h"
26#include "ultima/nuvie/core/obj_manager.h"
27#include "ultima/nuvie/gui/widgets/gui_widget.h"
28#include "ultima/nuvie/core/map.h"
29
30namespace Ultima {
31namespace Nuvie {
32
33class Configuration;
34class TileManager;
35class ActorManager;
36class Actor;
37class AnimManager;
38class Map;
39class MapCoord;
40class Screen;
41class CallBack;
42class Game;
43
44#define MAPWINDOW_THUMBNAIL_SIZE 52
45#define MAPWINDOW_THUMBNAIL_SCALE 3
46
47#define MAP_OVERLAY_DEFAULT 0 /* just below border */
48#define MAP_OVERLAY_ONTOP 1 /* cover border */
49
50#define MAPWINDOW_ROOFTILES_IMG_W 5
51#define MAPWINDOW_ROOFTILES_IMG_H 204
52
53typedef struct {
54 Tile *t;
55 uint16 x, y;
56} TileInfo;
57
58typedef struct {
59 Tile *eye_tile;
60 uint16 prev_x, prev_y;
61 uint16 moves_left;
62 CallBack *caller;
63} WizardEye;
64
65enum RoofDisplayType {ROOF_DISPLAY_OFF, ROOF_DISPLAY_NORMAL, ROOF_DISPLAY_FORCE_ON };
66enum InterfaceType { INTERFACE_NORMAL, INTERFACE_FULLSCREEN, INTERFACE_IGNORE_BLOCK };
67enum X_RayType { X_RAY_CHEAT_OFF = -1, X_RAY_OFF = 0, X_RAY_ON = 1, X_RAY_CHEAT_ON = 2};
68enum CanDropOrMoveMsg { MSG_NOT_POSSIBLE, MSG_SUCCESS, MSG_BLOCKED, MSG_OUT_OF_RANGE, MSG_NO_TILE};
69
70class MapWindow: public GUI_Widget {
71 friend class AnimManager;
72 friend class ConverseGumpWOU;
73 Game *game;
74 const Configuration *config;
75 int game_type;
76 bool enable_doubleclick;
77 bool walk_with_left_button;
78 uint8 walk_button_mask;
79 X_RayType x_ray_view;
80 InterfaceType interface;
81
82 bool custom_actor_tiles;
83
84 Map *map;
85
86 uint16 *tmp_map_buf; // tempory buffer for flood fill, hide rooms.
87 uint16 tmp_map_width, tmp_map_height;
88 Graphics::ManagedSurface *overlay; // used for visual effects
89 uint8 overlay_level; // where the overlay surface is placed
90 int min_brightness;
91
92 TileManager *tile_manager;
93 ObjManager *obj_manager;
94 ActorManager *actor_manager;
95 AnimManager *anim_manager;
96
97 sint16 cur_x, cur_y;
98 uint16 cursor_x, cursor_y, map_center_xoff;
99 sint16 mousecenter_x, mousecenter_y; // location mousecursor rotates around, relative to cur_x&cur_y
100 uint16 last_boundary_fill_x, last_boundary_fill_y; // start of boundary-fill in previous blacking update
101 Tile *cursor_tile;
102 Tile *use_tile;
103
104 bool show_cursor;
105 bool show_use_cursor;
106 bool show_grid;
107
108 unsigned char *thumbnail;
109 bool new_thumbnail;
110
111 uint16 win_width, win_height, border_width;
112 uint8 cur_level;
113 uint16 map_width;
114
115 uint8 cur_x_add, cur_y_add; // pixel offset from cur_x,cur_y (set by shiftMapRelative)
116 sint32 vel_x, vel_y; // velocity of automatic map movement (pixels per second)
117
118 Common::Rect clip_rect;
119 Graphics::ManagedSurface _mapWinSubSurf; // sub surface of the screen clipped to MapWindow's clip_rect
120
121 Obj *selected_obj;
122 Actor *look_actor;
123 Obj *look_obj;
124 bool hackmove;
125 bool walking;
126 bool look_on_left_click;
127 bool looking; // used to stop look_on_left_click from triggering during mouseup from left button walking, failed drag, or input mode
128
129 bool window_updated;
130 bool freeze_blacking_location;
131 bool enable_blacking;
132
133 bool roof_mode;
134 RoofDisplayType roof_display;
135
136 Graphics::ManagedSurface *roof_tiles;
137
138 WizardEye wizard_eye_info;
139
140 bool draw_brit_lens_anim;
141 bool draw_garg_lens_anim;
142// Common::Array<TileInfo> m_ViewableObjTiles; // shouldn't need this for in_town checks
143 Common::Array<TileInfo> m_ViewableMapTiles;
144
145 bool lighting_update_required;
146
147 bool game_started;
148
149public:
150
151 MapWindow(const Configuration *cfg, Map *m);
152 ~MapWindow() override;
153
154 bool init(TileManager *tm, ObjManager *om, ActorManager *am);
155
156 sint16 get_cur_x() const {
157 return cur_x;
158 }
159 sint16 get_cur_y() const {
160 return cur_y;
161 }
162 bool set_windowSize(uint16 width, uint16 height);
163 void set_show_cursor(bool state);
164 void set_show_use_cursor(bool state);
165 void set_show_grid(bool state);
166 bool is_grid_showing() {
167 return show_grid;
168 }
169 void set_velocity(sint16 vx, sint16 vy) {
170 vel_x = vx;
171 vel_y = vy;
172 }
173 void set_overlay(Graphics::ManagedSurface *surfpt);
174 void set_overlay_level(int level = MAP_OVERLAY_DEFAULT) {
175 overlay_level = level;
176 }
177 void set_x_ray_view(X_RayType state, bool cheat_off = false);
178 X_RayType get_x_ray_view() {
179 return x_ray_view;
180 }
181 void set_freeze_blacking_location(bool state);
182 void set_enable_blacking(bool state);
183 void set_roof_mode(bool roofs);
184 void set_roof_display_mode(enum RoofDisplayType mode) {
185 roof_display = mode;
186 }
187 void set_walking(bool state);
188 void set_walk_button_mask();
189 bool will_walk_with_left_button() {
190 return walk_with_left_button;
191 }
192 void set_walk_with_left_button(bool val) {
193 walk_with_left_button = val;
194 set_walk_button_mask();
195 }
196 void set_looking(bool state) {
197 looking = state;
198 }
199 int get_min_brightness() {
200 return min_brightness;
201 }
202 void set_min_brightness(int brightness) {
203 min_brightness = brightness;
204 }
205
206 void moveLevel(uint8 new_level);
207 void moveMap(sint16 new_x, sint16 new_y, sint8 new_level, uint8 new_x_add = 0, uint8 new_y_add = 0);
208 void moveMapRelative(sint16 rel_x, sint16 rel_y);
209 void shiftMapRelative(sint16 rel_x, sint16 rel_y);
210 void set_mousecenter(sint16 new_x, sint16 new_y) {
211 mousecenter_x = new_x;
212 mousecenter_y = new_y;
213 }
214 void reset_mousecenter() {
215 mousecenter_x = win_width / 2;
216 mousecenter_y = win_height / 2;
217 }
218 uint16 get_win_area() {
219 return win_width * win_height;
220 }
221 void centerMapOnActor(Actor *actor);
222 void centerMap(uint16 x, uint16 y, uint8 z);
223 void centerCursor();
224
225 void moveCursor(sint16 new_x, sint16 new_y);
226 void moveCursorRelative(sint16 rel_x, sint16 rel_y);
227
228 bool is_doubleclick_enabled() {
229 return enable_doubleclick;
230 }
231 void set_enable_doubleclick(bool val) {
232 enable_doubleclick = val;
233 }
234 void set_look_on_left_click(bool val) {
235 look_on_left_click = val;
236 }
237 void set_use_left_clicks();
238 bool will_look_on_left_click() {
239 return look_on_left_click;
240 }
241 bool is_on_screen(uint16 x, uint16 y, uint8 z);
242 bool tile_is_black(uint16 x, uint16 y, const Obj *obj = nullptr) const; // subtracts cur_x and cur_y
243 const char *look(uint16 x, uint16 y, bool show_prefix = true);
244 const char *lookAtCursor(bool show_prefix = true) {
245 return (look(cursor_x, cursor_y, show_prefix));
246 }
247 Obj *get_objAtCursor(bool for_use = false);
248 Obj *get_objAtCoord(MapCoord coord, bool top_obj, bool include_ignored_objects, bool for_use = false);
249 Actor *get_actorAtCursor();
250 MapCoord get_cursorCoord();
251 Obj *get_objAtMousePos(int x, int y);
252 Actor *get_actorAtMousePos(int x, int y);
253 void teleport_to_cursor();
254 void select_target(int x, int y);
255 void mouseToWorldCoords(int mx, int my, int &wx, int &wy);
256 void get_movement_direction(uint16 mx, uint16 my, sint16 &rel_x, sint16 &rel_y, uint8 *mptr = nullptr);
257
258 TileManager *get_tile_manager() {
259 return tile_manager;
260 }
261 AnimManager *get_anim_manager() {
262 return anim_manager;
263 }
264 const Common::Rect *get_clip_rect() const {
265 return &clip_rect;
266 }
267 Graphics::ManagedSurface *get_overlay();
268
269 void get_level(uint8 *level) const;
270 void get_pos(uint16 *x, uint16 *y, uint8 *px = nullptr, uint8 *py = nullptr) const;
271 void get_velocity(sint16 *vx, sint16 *vy) const {
272 *vx = vel_x;
273 *vy = vel_y;
274 }
275 void get_windowSize(uint16 *width, uint16 *height) const;
276
277 bool in_window(uint16 x, uint16 y, uint8 z) const;
278 bool in_dungeon_level() const;
279 bool in_town() const;
280// can put object at world location x,y?
281 CanDropOrMoveMsg can_drop_or_move_obj(uint16 x, uint16 y, Actor *actor, Obj *obj);
282 void display_can_drop_or_move_msg(CanDropOrMoveMsg msg, Common::String msg_text = "");
283 bool can_get_obj(const Actor *actor, Obj *obj);
284 bool blocked_by_wall(const Actor *actor, const Obj *obj);
285 MapCoord original_obj_loc;
286
287 void updateBlacking();
288 void updateAmbience();
289 void update();
290 void Display(bool full_redraw) override;
291
292 GUI_status MouseDown(int x, int y, Events::MouseButton button) override;
293 GUI_status MouseUp(int x, int y, Events::MouseButton button) override;
294 GUI_status MouseMotion(int x, int y, uint8 state) override;
295 GUI_status MouseDouble(int x, int y, Events::MouseButton button) override;
296 GUI_status MouseClick(int x, int y, Events::MouseButton button) override;
297 GUI_status Idle(void) override;
298 GUI_status MouseLeave(uint8 state) override;
299 GUI_status MouseDelayed(int x, int y, Events::MouseButton button) override;
300 GUI_status MouseHeld(int x, int y, Events::MouseButton button) override;
301 GUI_status KeyDown(const Common::KeyState &key) override;
302 GUI_status MouseWheel(sint32 x, sint32 y) override;
303
304 void drag_drop_success(int x, int y, int message, void *data) override;
305 void drag_drop_failed(int x, int y, int message, void *data) override;
306
307 bool drag_accept_drop(int x, int y, int message, void *data) override;
308 void drag_perform_drop(int x, int y, int message, void *data) override;
309 bool move_on_drop(Obj *obj);
310 void set_interface();
311 InterfaceType get_interface();
312 bool is_interface_fullscreen_in_combat();
313
314 void drag_draw(int x, int y, int message, void *data) override;
315
316 void update_mouse_cursor(uint32 mx, uint32 my);
317
318 unsigned char *make_thumbnail();
319 void free_thumbnail();
320 Graphics::ManagedSurface *get_sdl_surface();
321 Graphics::ManagedSurface *get_sdl_surface(uint16 x, uint16 y, uint16 w, uint16 h);
322 Graphics::ManagedSurface *get_roof_tiles() {
323 return roof_tiles;
324 }
325
326 Common::Array<const Obj *> m_ViewableObjects; //^^ dodgy public buffer
327
328 void wizard_eye_start(const MapCoord &location, uint16 duration, CallBack *caller);
329
330 bool using_map_tile_lighting;
331
332protected:
333 void create_thumbnail();
334
335 void drawActors();
336 void drawAnims(bool top_anims);
337 void drawObjs();
338 void drawObjSuperBlock(bool draw_lowertiles, bool toptile);
339 inline void drawObj(const Obj *obj, bool draw_lowertiles, bool toptile);
340 inline void drawTile(const Tile *tile, uint16 x, uint16 y, bool toptile, bool use_tile_data = false);
341 inline void drawNewTile(const Tile *tile, uint16 x, uint16 y, bool toptile);
342 void drawBorder();
343 inline void drawTopTile(const Tile *tile, uint16 x, uint16 y, bool toptile);
344 inline void drawActor(const Actor *actor);
345 void drawRoofs();
346 void drawGrid();
347 void drawRain();
348 inline void drawLensAnim();
349
350 void updateLighting();
351 void generateTmpMap();
352 void boundaryFill(const byte *map_ptr, uint16 pitch, uint16 x, uint16 y);
353 bool floorTilesVisible();
354 bool boundaryLookThroughWindow(uint16 tile_num, uint16 x, uint16 y);
355
356 void reshapeBoundary();
357 inline bool tmpBufTileIsBlack(uint16 x, uint16 y) const;
358 bool tmpBufTileIsBoundary(uint16 x, uint16 y);
359 bool tmpBufTileIsWall(uint16 x, uint16 y, NuvieDir direction);
360
361 void wizard_eye_stop();
362 void wizard_eye_update();
363 bool is_wizard_eye_mode() {
364 if (wizard_eye_info.moves_left != 0) return true;
365 else return false;
366 }
367
368 void loadRoofTiles();
369
370private:
371 void createLightOverlay();
372
373 void AddMapTileToVisibleList(uint16 tile_num, uint16 x, uint16 y);
374 bool can_display_obj(uint16 x, uint16 y, Obj *obj);
375};
376
377} // End of namespace Nuvie
378} // End of namespace Ultima
379
380#endif
Definition: array.h:52
Definition: str.h:59
Definition: managed_surface.h:51
Definition: actor.h:174
Definition: actor_manager.h:42
Definition: anim_manager.h:49
Definition: call_back.h:50
Definition: configuration.h:60
Definition: converse_gump_wou.h:38
Definition: gui_widget.h:38
Definition: game.h:72
Definition: map.h:84
Definition: map.h:147
Definition: map_window.h:70
Definition: obj.h:84
Definition: obj_manager.h:74
Definition: tile_manager.h:145
Definition: keyboard.h:294
Definition: rect.h:536
Definition: atari-screen.h:58
Definition: tile_manager.h:113
Definition: map_window.h:53
Definition: map_window.h:58