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 ZVISION_CURSOR_MANAGER_H 24 #define ZVISION_CURSOR_MANAGER_H 25 26 #include "zvision/graphics/cursors/cursor.h" 27 28 #include "common/str.h" 29 30 namespace Graphics { 31 struct PixelFormat; 32 } 33 34 namespace ZVision { 35 36 class ZVision; 37 38 /** 39 * Mostly usable cursors 40 */ 41 enum CursorIndex { 42 CursorIndex_Active = 0, 43 CursorIndex_DownArr = 3, 44 CursorIndex_HandPu = 6, 45 CursorIndex_Idle = 11, 46 CursorIndex_Left = 12, 47 CursorIndex_Right = 13, 48 CursorIndex_UpArr = 17, 49 CursorIndex_ItemIdle = 18, 50 CursorIndex_ItemAct = 19 51 }; 52 53 /** 54 * Class to manage cursor changes. The actual changes have to be done 55 * through CursorMan. Otherwise the cursor will disappear after GMM 56 * or debug console. 57 * TODO: Figure out a way to get rid of the extraneous data copying due to having to use CursorMan 58 */ 59 class CursorManager { 60 public: 61 CursorManager(ZVision *engine, const Graphics::PixelFormat pixelFormat); 62 63 private: 64 static const int NUM_CURSORS = 18; 65 66 // 18 default cursors in up/down states, +2 for items idle/act cursors 67 ZorkCursor _cursors[NUM_CURSORS + 2][2]; 68 69 ZVision *_engine; 70 const Graphics::PixelFormat _pixelFormat; 71 bool _cursorIsPushed; 72 int _item; 73 int _lastitem; 74 int _currentCursor; 75 76 static const char *_cursorNames[]; 77 static const char *_zgiCursorFileNames[]; 78 static const char *_zNemCursorFileNames[]; 79 80 public: 81 /** Creates the idle cursor and shows it */ 82 void initialize(); 83 84 /** 85 * Change cursor to specified cursor ID. If item setted to not 0 and cursor id idle/acrive/handpu change cursor to item. 86 * 87 * @param id Wanted cursor id. 88 */ 89 90 void changeCursor(int id); 91 92 /** 93 * Return founded id for string contains cursor name 94 * 95 * @param name Cursor name 96 * @return Id of cursor or idle cursor id if not found 97 */ 98 99 int getCursorId(const Common::String &name); 100 101 /** 102 * Load cursor for item by id, and try to change cursor to item cursor if it's not 0 103 * 104 * @param id Item id or 0 for no item cursor 105 */ 106 107 void setItemID(int id); 108 109 /** 110 * Change the cursor to a certain push state. If the cursor is already in the specified push state, nothing will happen. 111 * 112 * @param pushed Should the cursor be pushed (true) or not pushed (false) (Another way to say it: down or up) 113 */ 114 void cursorDown(bool pushed); 115 116 /** 117 * Show or hide mouse cursor. 118 * 119 * @param vis Should the cursor be showed (true) or hide (false) 120 */ 121 void showMouse(bool vis); 122 123 private: 124 /** 125 * Calls CursorMan.replaceCursor() using the data in cursor 126 * 127 * @param cursor The cursor to show 128 */ 129 void changeCursor(const ZorkCursor &cursor); 130 }; 131 132 } // End of namespace ZVision 133 134 #endif 135