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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef ULTIMA_SHARED_GFX_DUNGEON_H 24 #define ULTIMA_SHARED_GFX_DUNGEON_H 25 26 #include "ultima/shared/gfx/visual_surface.h" 27 28 namespace Ultima { 29 namespace Shared { 30 31 typedef void(*DrawWidgetFn)(Graphics::ManagedSurface &s, uint widgetId, uint distance, byte color); 32 33 class Game; 34 35 /** 36 * Acts as a handy container for the drawing methods for rendering the dungeon view 37 */ 38 class DungeonSurface : public Gfx::VisualSurface { 39 private: 40 Point _penPos; 41 byte _edgeColor; 42 byte _highlightColor; 43 byte _widgetColor; 44 DrawWidgetFn _widgetFn; 45 public: 46 /** 47 * Constructor 48 */ 49 DungeonSurface(const Graphics::ManagedSurface &src, const Rect &bounds, Game *game, DrawWidgetFn widgetFn); 50 51 /** 52 * Draw a line 53 */ drawLine(int x0,int y0,int x1,int y1,uint32 color)54 void drawLine(int x0, int y0, int x1, int y1, uint32 color) { 55 Gfx::VisualSurface::drawLine(x0 - 8, y0 - 8, x1 - 8, y1 - 8, color); 56 _penPos = Point(x1, y1); 57 } 58 59 /** 60 * Draw a line from a prior line ending point to a new destination pos 61 */ drawLineTo(int x,int y,uint32 color)62 void drawLineTo(int x, int y, uint32 color) { 63 Gfx::VisualSurface::drawLine(_penPos.x - 8, _penPos.y - 8, x - 8, y - 8, color); 64 _penPos = Point(x, y); 65 } 66 67 /** 68 * Draw a horizontal line. 69 */ hLine(int x,int y,int x2,uint32 color)70 void hLine(int x, int y, int x2, uint32 color) { 71 Gfx::VisualSurface::hLine(x - 8, y - 8, x2 - 8, color); 72 _penPos = Point(x2, y); 73 } 74 75 /** 76 * Draw a vertical line. 77 */ vLine(int x,int y,int y2,uint32 color)78 void vLine(int x, int y, int y2, uint32 color) { 79 Gfx::VisualSurface::vLine(x - 8, y - 8, y2 - 8, color); 80 _penPos = Point(x, y2); 81 } 82 83 /** 84 * Draw a frame around a specified rect. 85 */ frameRect(const Common::Rect & r,uint32 color)86 void frameRect(const Common::Rect &r, uint32 color) { 87 Gfx::VisualSurface::frameRect(Rect(r.left - 8, r.top - 8, r.right - 8, r.bottom - 8), color); 88 } 89 90 91 /** 92 * Draws a wall 93 */ 94 void drawWall(uint distance); 95 96 /** 97 * Draws a doorway directly in front of the player 98 */ 99 void drawDoorway(uint distance); 100 101 /** 102 * Draws a vertical line forming the edge of cells to the left of the player 103 */ 104 void drawLeftEdge(uint distance); 105 106 /** 107 * Draws a vertical line forming the edge of cells to the right of the player 108 */ 109 void drawRightEdge(uint distance); 110 111 /** 112 * Draws a monster or item at a given distance from the player 113 */ 114 void drawWidget(uint widgetId, uint distance, byte color); 115 116 /** 117 * Draw a ladder down face on 118 */ 119 void drawLadderDownFaceOn(uint distance); 120 121 /** 122 * Draw a ladder down side on 123 */ 124 void drawLadderDownSideOn(uint distance); 125 126 /** 127 * Draw a ladder down face on 128 */ 129 void drawLadderUpFaceOn(uint distance); 130 131 /** 132 * Draw a ladder down side on 133 */ 134 void drawLadderUpSideOn(uint distance); 135 136 /** 137 * Draw beams 138 */ 139 void drawBeams(uint distance); 140 141 /** 142 * Draws a door on the left hand side 143 */ 144 void drawLeftDoor(uint distance); 145 146 /** 147 * Draws a wall on the left-hand side 148 */ 149 void drawLeftWall(uint distance); 150 151 /** 152 * Draws the partial wall visible at the back of a corridor leading to the left 153 */ 154 void drawLeftBlank(uint distance); 155 156 /** 157 * Draws a door on the right hand side 158 */ 159 void drawRightDoor(uint distance); 160 161 /** 162 * Draws a wall on the right-hand side 163 */ 164 void drawRightWall(uint distance); 165 166 /** 167 * Draws the partial wall visible at the back of a corridor leading to the right 168 */ 169 void drawRightBlank(uint distance); 170 }; 171 172 } // End of namespace Shared 173 } // End of namespace Ultima 174 175 #endif 176