2016-08-26 22:36:31 +02:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers , whose names
* are too numerous to list here . Please refer to the COPYRIGHT
* file distributed with this source distribution .
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
*/
/*
* Based on the Reverse Engineering work of Christophe Fontanel ,
* maintainer of the Dungeon Master Encyclopaedia ( http : //dmweb.free.fr/)
*/
2016-06-15 10:41:33 +02:00
# include "common/system.h"
2016-06-15 18:22:32 +02:00
# include "graphics/cursorman.h"
2016-09-03 10:38:43 +02:00
# include "graphics/thumbnail.h"
2016-06-15 22:42:08 +02:00
2016-09-03 10:38:43 +02:00
# include "dm/eventman.h"
# include "dm/dungeonman.h"
# include "dm/movesens.h"
# include "dm/objectman.h"
# include "dm/inventory.h"
# include "dm/menus.h"
# include "dm/timeline.h"
# include "dm/projexpl.h"
# include "dm/text.h"
# include "dm/group.h"
# include "dm/dialog.h"
# include "dm/sounds.h"
2016-06-15 10:41:33 +02:00
2016-06-16 23:48:18 +02:00
namespace DM {
2016-07-11 10:52:38 +02:00
2016-08-20 11:00:24 +02:00
void EventManager : : initArrays ( ) {
KeyboardInput primaryKeyboardInputInterface [ 7 ] = { // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface
/* { Command, Code } */
2016-09-13 22:58:54 +02:00
KeyboardInput ( kDMCommandToggleInventoryChampion0 , Common : : KEYCODE_F1 , 0 ) , /* F1 (<CSI>1~) Atari ST: Code = 0x3B00 */
KeyboardInput ( kDMCommandToggleInventoryChampion1 , Common : : KEYCODE_F2 , 0 ) , /* F2 (<CSI>2~) Atari ST: Code = 0x3C00 */
KeyboardInput ( kDMCommandToggleInventoryChampion2 , Common : : KEYCODE_F3 , 0 ) , /* F3 (<CSI>3~) Atari ST: Code = 0x3D00 */
KeyboardInput ( kDMCommandToggleInventoryChampion3 , Common : : KEYCODE_F4 , 0 ) , /* F4 (<CSI>4~) Atari ST: Code = 0x3E00 */
KeyboardInput ( kDMCommandSaveGame , Common : : KEYCODE_s , Common : : KBD_CTRL ) , /* CTRL-S Atari ST: Code = 0x0013 */
KeyboardInput ( kDMCommandFreezeGame , Common : : KEYCODE_ESCAPE , 0 ) , /* Esc (0x1B) Atari ST: Code = 0x001B */
KeyboardInput ( kDMCommandNone , Common : : KEYCODE_INVALID , 0 )
2016-08-20 11:00:24 +02:00
} ;
KeyboardInput secondaryKeyboardInputMovement [ 19 ] = { // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement
/* { Command, Code } */
2016-09-13 22:58:54 +02:00
KeyboardInput ( kDMCommandTurnLeft , Common : : KEYCODE_KP4 , 0 ) , /* Numeric pad 4 Atari ST: Code = 0x5200 */
KeyboardInput ( kDMCommandMoveForward , Common : : KEYCODE_KP5 , 0 ) , /* Numeric pad 5 Atari ST: Code = 0x4800 */
KeyboardInput ( kDMCommandTurnRight , Common : : KEYCODE_KP6 , 0 ) , /* Numeric pad 6 Atari ST: Code = 0x4700 */
KeyboardInput ( kDMCommandMoveLeft , Common : : KEYCODE_KP1 , 0 ) , /* Numeric pad 1 Atari ST: Code = 0x4B00 */
KeyboardInput ( kDMCommandMoveBackward , Common : : KEYCODE_KP2 , 0 ) , /* Numeric pad 2 Atari ST: Code = 0x5000 */
KeyboardInput ( kDMCommandMoveRight , Common : : KEYCODE_KP3 , 0 ) , /* Numeric pad 3 Atari ST: Code = 0x4D00. Remaining entries below not present */
KeyboardInput ( kDMCommandMoveForward , Common : : KEYCODE_w , 0 ) , /* Up Arrow (<CSI>A) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandMoveForward , Common : : KEYCODE_w , Common : : KBD_SHIFT ) , /* Shift Up Arrow (<CSI>T) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandMoveLeft , Common : : KEYCODE_a , 0 ) , /* Backward Arrow (<CSI>D) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandMoveLeft , Common : : KEYCODE_a , Common : : KBD_SHIFT ) , /* Shift Forward Arrow (<CSI> A) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandMoveRight , Common : : KEYCODE_d , 0 ) , /* Forward Arrow (<CSI>C) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandMoveRight , Common : : KEYCODE_d , Common : : KBD_SHIFT ) , /* Shift Backward Arrow (<CSI> @) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandMoveBackward , Common : : KEYCODE_s , 0 ) , /* Down arrow (<CSI>B) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandMoveBackward , Common : : KEYCODE_s , Common : : KBD_SHIFT ) , /* Shift Down arrow (<CSI>S) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandTurnLeft , Common : : KEYCODE_q , 0 ) , /* Del (0x7F) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandTurnLeft , Common : : KEYCODE_q , Common : : KBD_SHIFT ) , /* Shift Del (0x7F) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandTurnRight , Common : : KEYCODE_e , 0 ) , /* Help (<CSI>?~) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandTurnRight , Common : : KEYCODE_e , Common : : KBD_SHIFT ) , /* Shift Help (<CSI>?~) */ /*Differs for testing convenience*/
KeyboardInput ( kDMCommandNone , Common : : KEYCODE_INVALID , 0 )
2016-08-20 11:00:24 +02:00
} ;
KeyboardInput primaryKeyboardInputPartySleeping [ 3 ] = { // @ G0460_as_Graphic561_PrimaryKeyboardInput_PartySleeping
/* { Command, Code } */
2016-09-13 22:58:54 +02:00
KeyboardInput ( kDMCommandWakeUp , Common : : KEYCODE_RETURN , 0 ) , /* Return */
KeyboardInput ( kDMCommandFreezeGame , Common : : KEYCODE_ESCAPE , 0 ) , /* Esc */
KeyboardInput ( kDMCommandNone , Common : : KEYCODE_INVALID , 0 )
2016-08-20 11:00:24 +02:00
} ;
KeyboardInput primaryKeyboardInputFrozenGame [ 2 ] = { // @ G0461_as_Graphic561_PrimaryKeyboardInput_FrozenGame
/* { Command, Code } */
2016-09-13 22:58:54 +02:00
KeyboardInput ( kDMCommandUnfreezeGame , Common : : KEYCODE_ESCAPE , 0 ) , /* Esc */
KeyboardInput ( kDMCommandNone , Common : : KEYCODE_INVALID , 0 )
2016-08-20 11:00:24 +02:00
} ;
2016-08-20 18:34:52 +02:00
MouseInput primaryMouseInputEntrance [ 4 ] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4]
2016-08-20 14:22:47 +02:00
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandEntranceEnterDungeon , 244 , 298 , 45 , 58 , kDMMouseButtonLeft ) ,
2016-08-20 14:22:47 +02:00
// Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandEntranceResume , 244 , 298 , 76 , 93 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandEntranceDrawCredits , 248 , 293 , 187 , 199 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 14:22:47 +02:00
} ;
2016-08-20 18:34:52 +02:00
MouseInput primaryMouseInputRestartGame [ 2 ] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2]
2016-08-20 14:22:47 +02:00
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandRestartGame , 103 , 217 , 145 , 159 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 14:22:47 +02:00
} ;
2016-08-20 18:34:52 +02:00
MouseInput primaryMouseInputInterface [ 20 ] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20]
2016-08-20 14:22:47 +02:00
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickInChampion0StatusBox , 0 , 42 , 0 , 28 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInChampion1StatusBox , 69 , 111 , 0 , 28 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInChampion2StatusBox , 138 , 180 , 0 , 28 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInChampion3StatusBox , 207 , 249 , 0 , 28 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnChamptionIconTopLeft , 274 , 299 , 0 , 13 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnChamptionIconTopRight , 301 , 319 , 0 , 13 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnChamptionIconLowerRight , 301 , 319 , 15 , 28 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnChamptionIconLowerLeft , 274 , 299 , 15 , 28 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandToggleInventoryChampion0 , 43 , 66 , 0 , 28 , kDMMouseButtonLeft ) , /* Atari ST: Only present in CSB 2.x and with Box.X1 = 44. swapped with 4 next entries */
MouseInput ( kDMCommandToggleInventoryChampion1 , 112 , 135 , 0 , 28 , kDMMouseButtonLeft ) , /* Atari ST: Only present in CSB 2.x and with Box.X1 = 113. swapped with 4 next entries */
MouseInput ( kDMCommandToggleInventoryChampion2 , 181 , 204 , 0 , 28 , kDMMouseButtonLeft ) , /* Atari ST: Only present in CSB 2.x and with Box.X1 = 182. swapped with 4 next entries */
MouseInput ( kDMCommandToggleInventoryChampion3 , 250 , 273 , 0 , 28 , kDMMouseButtonLeft ) , /* Atari ST: Only present in CSB 2.x and with Box.X1 = 251. swapped with 4 next entries */
MouseInput ( kDMCommandToggleInventoryChampion0 , 0 , 66 , 0 , 28 , kDMMouseButtonRight ) , /* Atari ST: swapped with 4 previous entries */
MouseInput ( kDMCommandToggleInventoryChampion1 , 69 , 135 , 0 , 28 , kDMMouseButtonRight ) , /* Atari ST: swapped with 4 previous entries */
MouseInput ( kDMCommandToggleInventoryChampion2 , 138 , 204 , 0 , 28 , kDMMouseButtonRight ) , /* Atari ST: swapped with 4 previous entries */
MouseInput ( kDMCommandToggleInventoryChampion3 , 207 , 273 , 0 , 28 , kDMMouseButtonRight ) , /* Atari ST: swapped with 4 previous entries */
MouseInput ( kDMCommandClickInSpellArea , 233 , 319 , 42 , 73 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInActionArea , 233 , 319 , 77 , 121 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandFreezeGame , 0 , 1 , 198 , 199 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 14:22:47 +02:00
} ;
2016-08-20 18:34:52 +02:00
MouseInput secondaryMouseInputMovement [ 9 ] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandTurnLeft , 234 , 261 , 125 , 145 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandMoveForward , 263 , 289 , 125 , 145 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandTurnRight , 291 , 318 , 125 , 145 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandMoveLeft , 234 , 261 , 147 , 167 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandMoveBackward , 263 , 289 , 147 , 167 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandMoveRight , 291 , 318 , 147 , 167 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInDungeonView , 0 , 223 , 33 , 168 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandToggleInventoryLeader , 0 , 319 , 33 , 199 , kDMMouseButtonRight ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 18:34:52 +02:00
} ;
MouseInput secondaryMouseInputChampionInventory [ 38 ] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandCloseInventory , 0 , 319 , 0 , 199 , kDMMouseButtonRight ) ,
MouseInput ( kDMCommandSaveGame , 174 , 182 , 36 , 44 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandSleep , 188 , 204 , 36 , 44 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandCloseInventory , 210 , 218 , 36 , 44 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryReadyHand , 6 , 21 , 86 , 101 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryActionHand , 62 , 77 , 86 , 101 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryHead , 34 , 49 , 59 , 74 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryTorso , 34 , 49 , 79 , 94 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryLegs , 34 , 49 , 99 , 114 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryFeet , 34 , 49 , 119 , 134 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryPouch2 , 6 , 21 , 123 , 138 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnMouth , 56 , 71 , 46 , 61 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnEye , 12 , 27 , 46 , 61 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryQuiverLine2_1 , 79 , 94 , 106 , 121 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryQuiverLine1_2 , 62 , 77 , 123 , 138 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryQuiverLine2_2 , 79 , 94 , 123 , 138 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryNeck , 6 , 21 , 66 , 81 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryPouch1 , 6 , 21 , 106 , 121 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryQuiverLine1_1 , 62 , 77 , 106 , 121 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine1_1 , 66 , 81 , 66 , 81 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine2_2 , 83 , 98 , 49 , 64 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine2_3 , 100 , 115 , 49 , 64 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine2_4 , 117 , 132 , 49 , 64 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine2_5 , 134 , 149 , 49 , 64 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine2_6 , 151 , 166 , 49 , 64 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine2_7 , 168 , 183 , 49 , 64 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine2_8 , 185 , 200 , 49 , 64 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine2_9 , 202 , 217 , 49 , 64 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine1_2 , 83 , 98 , 66 , 81 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine1_3 , 100 , 115 , 66 , 81 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine1_4 , 117 , 132 , 66 , 81 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine1_5 , 134 , 149 , 66 , 81 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine1_6 , 151 , 166 , 66 , 81 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine1_7 , 168 , 183 , 66 , 81 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine1_8 , 185 , 200 , 66 , 81 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxInventoryBackpackLine1_9 , 202 , 217 , 66 , 81 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInPanel , 96 , 223 , 83 , 167 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 18:34:52 +02:00
} ;
MouseInput primaryMouseInputPartySleeping [ 3 ] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandWakeUp , 0 , 223 , 33 , 168 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandWakeUp , 0 , 223 , 33 , 168 , kDMMouseButtonRight ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 18:34:52 +02:00
} ;
MouseInput primaryMouseInputFrozenGame [ 3 ] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandUnfreezeGame , 0 , 319 , 0 , 199 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandUnfreezeGame , 0 , 319 , 0 , 199 , kDMMouseButtonRight ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 18:34:52 +02:00
} ;
MouseInput mouseInputActionAreaNames [ 5 ] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickInActionAreaPass , 285 , 318 , 77 , 83 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInActionAreaAction0 , 234 , 318 , 86 , 96 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInActionAreaAction1 , 234 , 318 , 98 , 108 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInActionAreaAction2 , 234 , 318 , 110 , 120 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 18:34:52 +02:00
} ;
2016-08-20 18:47:24 +02:00
MouseInput mouseInputActionAreaIcons [ 5 ] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickInActionAreaChampion0Action , 233 , 252 , 86 , 120 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInActionAreaChampion1Action , 255 , 274 , 86 , 120 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInActionAreaChampion2Action , 277 , 296 , 86 , 120 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInActionAreaChampion3Action , 299 , 318 , 86 , 120 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 18:47:24 +02:00
} ;
MouseInput mouseInputSpellArea [ 9 ] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickInSpellAreaSymbol1 , 235 , 247 , 51 , 61 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInSpellAreaSymbol2 , 249 , 261 , 51 , 61 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInSpellAreaSymbol3 , 263 , 275 , 51 , 61 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInSpellAreaSymbol4 , 277 , 289 , 51 , 61 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInSpellAreaSymbol5 , 291 , 303 , 51 , 61 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInSpellAreaSymbol6 , 305 , 317 , 51 , 61 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInSpeallAreaCastSpell , 234 , 303 , 63 , 73 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickInSpellAreaRecantSymbol , 305 , 318 , 63 , 73 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 18:47:24 +02:00
} ;
MouseInput mouseInputChampionNamesHands [ 13 ] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandSetLeaderChampion0 , 0 , 42 , 0 , 6 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandSetLeaderChampion1 , 69 , 111 , 0 , 6 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandSetLeaderChampion2 , 138 , 180 , 0 , 6 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandSetLeaderChampion3 , 207 , 249 , 0 , 6 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChampion0StatusBoxReadyHand , 4 , 19 , 10 , 25 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChampion0StatusBoxActionHand , 24 , 39 , 10 , 25 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChampion1StatusBoxReadyHand , 73 , 88 , 10 , 25 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChampion1StatusBoxActionHand , 93 , 108 , 10 , 25 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChampion2StatusBoxReadyHand , 142 , 157 , 10 , 25 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChampion2StatusBoxActionHand , 162 , 177 , 10 , 25 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChampion3StatusBoxReadyHand , 211 , 226 , 10 , 25 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChampion3StatusBoxActionHand , 231 , 246 , 10 , 25 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 18:47:24 +02:00
} ;
MouseInput mouseInputPanelChest [ 9 ] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickOnSlotBoxChest1 , 117 , 132 , 92 , 107 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChest2 , 106 , 121 , 109 , 124 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChest3 , 111 , 126 , 126 , 141 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChest4 , 128 , 143 , 131 , 146 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChest5 , 145 , 160 , 134 , 149 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChest6 , 162 , 177 , 136 , 151 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChest7 , 179 , 194 , 137 , 152 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandClickOnSlotBoxChest8 , 196 , 211 , 138 , 153 , kDMMouseButtonLeft ) ,
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 18:47:24 +02:00
} ;
MouseInput mouseInputPanelResurrectReincarnateCancel [ 4 ] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickInPanelResurrect , 108 , 158 , 90 , 138 , kDMMouseButtonLeft ) , /* Atari ST: Box = 104, 158, 86, 142 */
MouseInput ( kDMCommandClickInPanelReincarnate , 161 , 211 , 90 , 138 , kDMMouseButtonLeft ) , /* Atari ST: Box = 163, 217, 86, 142 */
MouseInput ( kDMCommandClickInPanelCancel , 108 , 211 , 141 , 153 , kDMMouseButtonLeft ) , /* Atari ST: Box = 104, 217, 146, 156 */
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-20 18:47:24 +02:00
} ;
2016-08-21 00:58:11 +02:00
MouseInput primaryMouseInputViewportDialog1Choice [ 2 ] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickOnDialogChoice1 , 16 , 207 , 138 , 152 , kDMMouseButtonLeft ) , /* Bottom button */
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-21 00:58:11 +02:00
} ;
MouseInput primaryMouseInputViewportDialog2Choices [ 3 ] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickOnDialogChoice1 , 16 , 207 , 101 , 115 , kDMMouseButtonLeft ) , /* Top button */
MouseInput ( kDMCommandClickOnDialogChoice2 , 16 , 207 , 138 , 152 , kDMMouseButtonLeft ) , /* Bottom button */
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-21 00:58:11 +02:00
} ;
MouseInput primaryMouseInputViewportDialog3Choices [ 4 ] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickOnDialogChoice1 , 16 , 207 , 101 , 115 , kDMMouseButtonLeft ) , /* Top button */
MouseInput ( kDMCommandClickOnDialogChoice2 , 16 , 101 , 138 , 152 , kDMMouseButtonLeft ) , /* Lower left button */
MouseInput ( kDMCommandClickOnDialogChoice3 , 123 , 207 , 138 , 152 , kDMMouseButtonLeft ) , /* Lower right button */
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-21 00:58:11 +02:00
} ;
MouseInput primaryMouseInputViewportDialog4Choices [ 5 ] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickOnDialogChoice1 , 16 , 101 , 101 , 115 , kDMMouseButtonLeft ) , /* Top left button */
MouseInput ( kDMCommandClickOnDialogChoice2 , 123 , 207 , 101 , 115 , kDMMouseButtonLeft ) , /* Top right button */
MouseInput ( kDMCommandClickOnDialogChoice3 , 16 , 101 , 138 , 152 , kDMMouseButtonLeft ) , /* Lower left button */
MouseInput ( kDMCommandClickOnDialogChoice4 , 123 , 207 , 138 , 152 , kDMMouseButtonLeft ) , /* Lower right button */
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-21 00:58:11 +02:00
} ;
MouseInput primaryMouseInputScreenDialog1Choice [ 2 ] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickOnDialogChoice1 , 63 , 254 , 138 , 152 , kDMMouseButtonLeft ) , /* Bottom button */
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-21 00:58:11 +02:00
} ;
MouseInput primaryMouseInputScreenDialog2Choices [ 3 ] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickOnDialogChoice1 , 63 , 254 , 101 , 115 , kDMMouseButtonLeft ) , /* Top button */
MouseInput ( kDMCommandClickOnDialogChoice2 , 63 , 254 , 138 , 152 , kDMMouseButtonLeft ) , /* Bottom button */
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-21 00:58:11 +02:00
} ;
MouseInput primaryMouseInputScreenDialog3Choices [ 4 ] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickOnDialogChoice1 , 63 , 254 , 101 , 115 , kDMMouseButtonLeft ) , /* Top button */
MouseInput ( kDMCommandClickOnDialogChoice2 , 63 , 148 , 138 , 152 , kDMMouseButtonLeft ) , /* Lower left button */
MouseInput ( kDMCommandClickOnDialogChoice3 , 170 , 254 , 138 , 152 , kDMMouseButtonLeft ) , /* Lower right button */
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-21 00:58:11 +02:00
} ;
MouseInput primaryMouseInputScreenDialog4Choices [ 5 ] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
2016-09-13 22:58:54 +02:00
MouseInput ( kDMCommandClickOnDialogChoice1 , 63 , 148 , 101 , 115 , kDMMouseButtonLeft ) , /* Top left button */
MouseInput ( kDMCommandClickOnDialogChoice2 , 170 , 254 , 101 , 115 , kDMMouseButtonLeft ) , /* Top right button */
MouseInput ( kDMCommandClickOnDialogChoice3 , 63 , 148 , 138 , 152 , kDMMouseButtonLeft ) , /* Lower left button */
MouseInput ( kDMCommandClickOnDialogChoice4 , 170 , 254 , 138 , 152 , kDMMouseButtonLeft ) , /* Lower right button */
MouseInput ( kDMCommandNone , 0 , 0 , 0 , 0 , kDMMouseButtonNone )
2016-08-21 00:58:11 +02:00
} ;
2016-08-20 18:47:24 +02:00
2016-08-20 18:34:52 +02:00
MouseInput * primaryMouseInputDialogSets [ 2 ] [ 4 ] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets
{
2016-08-21 00:58:11 +02:00
_primaryMouseInputViewportDialog1Choice ,
_primaryMouseInputViewportDialog2Choices ,
_primaryMouseInputViewportDialog3Choices ,
_primaryMouseInputViewportDialog4Choices
2016-08-20 18:34:52 +02:00
} ,
{
2016-08-21 00:58:11 +02:00
_primaryMouseInputScreenDialog1Choice ,
_primaryMouseInputScreenDialog2Choices ,
_primaryMouseInputScreenDialog3Choices ,
_primaryMouseInputScreenDialog4Choices
2016-08-20 18:34:52 +02:00
}
} ;
for ( int i = 0 ; i < 2 ; i + + ) {
_primaryKeyboardInputFrozenGame [ i ] = primaryKeyboardInputFrozenGame [ i ] ;
_primaryMouseInputRestartGame [ i ] = primaryMouseInputRestartGame [ i ] ;
2016-08-21 00:58:11 +02:00
_primaryMouseInputViewportDialog1Choice [ i ] = primaryMouseInputViewportDialog1Choice [ i ] ;
_primaryMouseInputScreenDialog1Choice [ i ] = primaryMouseInputScreenDialog1Choice [ i ] ;
2016-08-20 18:34:52 +02:00
for ( int j = 0 ; j < 4 ; j + + )
_primaryMouseInputDialogSets [ i ] [ j ] = primaryMouseInputDialogSets [ i ] [ j ] ;
}
for ( int i = 0 ; i < 3 ; i + + ) {
_primaryKeyboardInputPartySleeping [ i ] = primaryKeyboardInputPartySleeping [ i ] ;
_primaryMouseInputPartySleeping [ i ] = primaryMouseInputPartySleeping [ i ] ;
_primaryMouseInputFrozenGame [ i ] = primaryMouseInputFrozenGame [ i ] ;
2016-08-21 00:58:11 +02:00
_primaryMouseInputViewportDialog2Choices [ i ] = primaryMouseInputViewportDialog2Choices [ i ] ;
_primaryMouseInputScreenDialog2Choices [ i ] = primaryMouseInputScreenDialog2Choices [ i ] ;
2016-08-20 18:34:52 +02:00
}
2016-08-20 18:47:24 +02:00
for ( int i = 0 ; i < 4 ; i + + ) {
2016-08-20 18:34:52 +02:00
_primaryMouseInputEntrance [ i ] = primaryMouseInputEntrance [ i ] ;
2016-08-20 18:47:24 +02:00
_mouseInputPanelResurrectReincarnateCancel [ i ] = mouseInputPanelResurrectReincarnateCancel [ i ] ;
2016-08-21 00:58:11 +02:00
_primaryMouseInputViewportDialog3Choices [ i ] = primaryMouseInputViewportDialog3Choices [ i ] ;
_primaryMouseInputScreenDialog3Choices [ i ] = primaryMouseInputScreenDialog3Choices [ i ] ;
2016-08-20 18:47:24 +02:00
}
2016-08-20 18:34:52 +02:00
2016-08-20 18:47:24 +02:00
for ( int i = 0 ; i < 5 ; i + + ) {
2016-08-20 18:34:52 +02:00
_mouseInputActionAreaNames [ i ] = mouseInputActionAreaNames [ i ] ;
2016-08-20 18:47:24 +02:00
_mouseInputActionAreaIcons [ i ] = mouseInputActionAreaIcons [ i ] ;
2016-08-21 00:58:11 +02:00
_primaryMouseInputViewportDialog4Choices [ i ] = primaryMouseInputViewportDialog4Choices [ i ] ;
_primaryMouseInputScreenDialog4Choices [ i ] = primaryMouseInputScreenDialog4Choices [ i ] ;
2016-08-20 18:47:24 +02:00
}
2016-08-20 11:00:24 +02:00
for ( int i = 0 ; i < 7 ; i + + )
2016-08-20 14:22:47 +02:00
_primaryKeyboardInputInterface [ i ] = primaryKeyboardInputInterface [ i ] ;
2016-06-16 15:16:45 +02:00
2016-08-20 18:47:24 +02:00
for ( int i = 0 ; i < 9 ; i + + ) {
2016-08-20 18:34:52 +02:00
_secondaryMouseInputMovement [ i ] = secondaryMouseInputMovement [ i ] ;
2016-08-20 18:47:24 +02:00
_mouseInputSpellArea [ i ] = mouseInputSpellArea [ i ] ;
_mouseInputPanelChest [ i ] = mouseInputPanelChest [ i ] ;
}
for ( int i = 0 ; i < 13 ; i + + )
2016-09-05 23:11:25 +02:00
_mouseInputChampionNamesHands [ i ] = mouseInputChampionNamesHands [ i ] ;
2016-08-20 18:34:52 +02:00
2016-08-20 11:00:24 +02:00
for ( int i = 0 ; i < 19 ; i + + )
2016-08-20 14:22:47 +02:00
_secondaryKeyboardInputMovement [ i ] = secondaryKeyboardInputMovement [ i ] ;
2016-08-20 11:00:24 +02:00
2016-08-20 18:34:52 +02:00
for ( int i = 0 ; i < 20 ; i + + )
_primaryMouseInputInterface [ i ] = primaryMouseInputInterface [ i ] ;
2016-08-20 11:00:24 +02:00
2016-08-20 18:34:52 +02:00
for ( int i = 0 ; i < 38 ; i + + )
_secondaryMouseInputChampionInventory [ i ] = secondaryMouseInputChampionInventory [ i ] ;
2016-08-20 11:00:24 +02:00
}
2016-06-15 18:22:32 +02:00
EventManager : : EventManager ( DMEngine * vm ) : _vm ( vm ) {
2016-08-26 22:50:01 +02:00
_mousePos = Common : : Point ( 0 , 0 ) ;
2016-06-16 23:48:18 +02:00
_dummyMapIndex = 0 ;
2016-08-25 08:12:23 +02:00
_pendingClickPresent = false ;
_pendingClickPos = Common : : Point ( 0 , 0 ) ;
_mousePointerOriginalColorsObject = nullptr ;
_mousePointerOriginalColorsChampionIcon = nullptr ;
_mousePointerTempBuffer = nullptr ;
_isCommandQueueLocked = true ;
_mousePointerType = 0 ;
_previousMousePointerType = 0 ;
_primaryMouseInput = nullptr ;
_secondaryMouseInput = nullptr ;
_mousePointerBitmapUpdated = true ;
_refreshMousePointerInMainLoop = false ;
_highlightBoxEnabled = false ;
_useChampionIconOrdinalAsMousePointerBitmap = 0 ;
2016-09-13 22:58:54 +02:00
_pendingClickButton = kDMMouseButtonNone ;
2016-08-25 08:12:23 +02:00
_useObjectAsMousePointerBitmap = false ;
_useHandAsMousePointerBitmap = false ;
_preventBuildPointerScreenArea = false ;
_primaryKeyboardInput = nullptr ;
_secondaryKeyboardInput = nullptr ;
_ignoreMouseMovements = false ;
2016-08-27 11:07:49 +02:00
warning ( " _g587_hideMousePointerRequestCount should start with value 1 " ) ;
2016-08-25 08:12:23 +02:00
_hideMousePointerRequestCount = 0 ;
_mouseButtonStatus = 0 ;
2016-08-19 19:00:58 +02:00
_highlightScreenBox . setToZero ( ) ;
2016-08-20 11:00:24 +02:00
initArrays ( ) ;
2016-06-15 18:22:32 +02:00
}
2016-07-07 00:46:51 +02:00
EventManager : : ~ EventManager ( ) {
2016-08-25 08:12:23 +02:00
delete [ ] _mousePointerOriginalColorsObject ;
delete [ ] _mousePointerTempBuffer ;
delete [ ] _mousePointerOriginalColorsChampionIcon ;
2016-07-07 00:46:51 +02:00
}
2016-06-15 18:22:32 +02:00
2016-07-07 00:46:51 +02:00
void EventManager : : initMouse ( ) {
2016-08-15 07:58:04 +02:00
static uint16 gK150_PalMousePointer [ 16 ] = { 0x000 , 0x666 , 0x888 , 0x620 , 0x0CC , 0x840 , 0x080 , 0x0C0 , 0xF00 , 0xFA0 , 0xC86 , 0xFF0 , 0x000 , 0xAAA , 0x00F , 0xFFF } ; // @ K0150_aui_Palette_MousePointer
2016-08-25 08:12:23 +02:00
if ( ! _mousePointerOriginalColorsObject )
_mousePointerOriginalColorsObject = new byte [ 32 * 18 ] ;
if ( ! _mousePointerTempBuffer )
_mousePointerTempBuffer = new byte [ 32 * 18 ] ;
if ( ! _mousePointerOriginalColorsChampionIcon )
_mousePointerOriginalColorsChampionIcon = new byte [ 32 * 18 ] ;
2016-06-15 10:41:33 +02:00
2016-08-25 08:12:23 +02:00
_mousePointerType = k0_pointerArrow ;
_previousMousePointerType = k1_pointerHand ;
2016-06-15 10:41:33 +02:00
2016-08-14 21:24:36 +02:00
byte mousePalette [ 16 * 3 ] ;
for ( int i = 0 ; i < 16 ; + + i ) {
mousePalette [ i * 3 ] = ( gK150_PalMousePointer [ i ] > > 8 ) * ( 256 / 16 ) ;
mousePalette [ i * 3 + 1 ] = ( gK150_PalMousePointer [ i ] > > 4 ) * ( 256 / 16 ) ;
mousePalette [ i * 3 + 2 ] = gK150_PalMousePointer [ i ] * ( 256 / 16 ) ;
}
CursorMan . pushCursorPalette ( mousePalette , 0 , 16 ) ;
2016-06-15 10:41:33 +02:00
_mousePos = Common : : Point ( 0 , 0 ) ;
2016-08-25 08:12:23 +02:00
buildpointerScreenArea ( _mousePos . x , _mousePos . y ) ;
2016-06-15 18:22:32 +02:00
CursorMan . showMouse ( false ) ;
2016-06-16 23:48:18 +02:00
setMousePos ( Common : : Point ( 320 / 2 , 200 / 2 ) ) ;
2016-06-15 10:41:33 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : setMousePointerToNormal ( int16 mousePointer ) {
_preventBuildPointerScreenArea = true ;
_useObjectAsMousePointerBitmap = false ;
_useHandAsMousePointerBitmap = ( mousePointer = = k1_pointerHand ) ;
_mousePointerBitmapUpdated = true ;
_preventBuildPointerScreenArea = false ;
buildpointerScreenArea ( _mousePos . x , _mousePos . y ) ;
2016-07-07 00:46:51 +02:00
}
2016-09-03 14:20:13 +02:00
void EventManager : : setPointerToObject ( byte * bitmap ) {
2016-08-10 00:12:20 +02:00
static byte palChangesMousepointerOjbectIconShadow [ 16 ] = { 120 , 120 , 120 , 120 , 120 , 120 , 120 , 120 ,
2016-07-07 00:46:51 +02:00
120 , 120 , 120 , 120 , 0 , 120 , 120 , 120 } ; // @ K0027_auc_PaletteChanges_MousePointerObjectIconShadow
2016-08-10 00:12:20 +02:00
static byte palChangesMousePointerIcon [ 16 ] = { 120 , 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 ,
2016-07-07 00:46:51 +02:00
100 , 110 , 0 , 130 , 140 , 150 } ; // @ G0044_auc_Graphic562_PaletteChanges_MousePointerIcon
2016-09-10 21:50:57 +02:00
static Box boxMousePointerObjectShadow ( 2 , 17 , 2 , 17 ) ; // @ G0619_s_Box_MousePointer_ObjectShadow
static Box boxMousePointerObject ( 0 , 15 , 0 , 15 ) ; // @ G0620_s_Box_MousePointer_Object
2016-07-07 00:46:51 +02:00
2016-08-25 08:12:23 +02:00
_preventBuildPointerScreenArea = true ;
_useObjectAsMousePointerBitmap = true ;
_useHandAsMousePointerBitmap = false ;
_mousePointerBitmapUpdated = true ;
2016-08-25 18:32:03 +02:00
_vm - > _displayMan - > _useByteBoxCoordinates = true ;
2016-08-25 08:12:23 +02:00
byte * L0051_puc_Bitmap = _mousePointerOriginalColorsObject ;
2016-07-07 00:46:51 +02:00
memset ( L0051_puc_Bitmap , 0 , 32 * 18 ) ;
2016-08-26 22:50:13 +02:00
2016-08-25 18:32:03 +02:00
_vm - > _displayMan - > blitToBitmapShrinkWithPalChange ( bitmap , _mousePointerTempBuffer , 16 , 16 , 16 , 16 , palChangesMousepointerOjbectIconShadow ) ;
2016-09-16 07:46:10 +02:00
_vm - > _displayMan - > blitToBitmap ( _mousePointerTempBuffer , L0051_puc_Bitmap , boxMousePointerObjectShadow , 0 , 0 , 8 , 16 , kDMColorNoTransparency , 16 , 18 ) ;
2016-08-25 18:32:03 +02:00
_vm - > _displayMan - > blitToBitmapShrinkWithPalChange ( bitmap , _mousePointerTempBuffer , 16 , 16 , 16 , 16 , palChangesMousePointerIcon ) ;
2016-09-16 07:46:10 +02:00
_vm - > _displayMan - > blitToBitmap ( _mousePointerTempBuffer , L0051_puc_Bitmap , boxMousePointerObject , 0 , 0 , 8 , 16 , kDMColorBlack , 16 , 18 ) ;
2016-08-10 00:12:20 +02:00
2016-08-25 08:12:23 +02:00
_preventBuildPointerScreenArea = false ;
buildpointerScreenArea ( _mousePos . x , _mousePos . y ) ;
2016-07-07 00:46:51 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : mouseDropChampionIcon ( ) {
_preventBuildPointerScreenArea = true ;
uint16 championIconIndex = _vm - > ordinalToIndex ( _useChampionIconOrdinalAsMousePointerBitmap ) ;
2016-09-09 07:12:36 +02:00
_useChampionIconOrdinalAsMousePointerBitmap = _vm - > indexToOrdinal ( kDMChampionNone ) ;
2016-08-25 08:12:23 +02:00
_mousePointerBitmapUpdated = true ;
2016-08-25 18:32:03 +02:00
bool useByteBoxCoordinatesBackup = _vm - > _displayMan - > _useByteBoxCoordinates ;
2016-09-16 07:46:10 +02:00
_vm - > _displayMan - > blitToScreen ( _mousePointerOriginalColorsChampionIcon , & _vm - > _championMan - > _boxChampionIcons [ championIconIndex < < 2 ] , 16 , kDMColorDarkestGray , 18 ) ;
2016-08-25 18:32:03 +02:00
_vm - > _displayMan - > _useByteBoxCoordinates = useByteBoxCoordinatesBackup ;
2016-08-25 08:12:23 +02:00
_preventBuildPointerScreenArea = false ;
2016-07-07 00:46:51 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : buildpointerScreenArea ( int16 mousePosX , int16 mousePosY ) {
2016-08-18 21:18:08 +02:00
static unsigned char bitmapArrowPointer [ 288 ] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer
0x00 , 0x00 , 0x00 , 0x00 , 0x40 , 0x00 , 0x00 , 0x00 , 0x60 , 0x00 , 0x00 , 0x00 , 0x70 , 0x00 , 0x00 , 0x00 ,
0x78 , 0x00 , 0x00 , 0x00 , 0x7C , 0x00 , 0x00 , 0x00 , 0x7E , 0x00 , 0x00 , 0x00 , 0x7F , 0x00 , 0x00 , 0x00 ,
0x7F , 0x80 , 0x00 , 0x00 , 0x7C , 0x00 , 0x00 , 0x00 , 0x6C , 0x00 , 0x00 , 0x00 , 0x46 , 0x00 , 0x00 , 0x00 ,
0x06 , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x40 , 0x00 , 0x00 , 0x00 ,
0x60 , 0x00 , 0x00 , 0x00 , 0x70 , 0x00 , 0x00 , 0x00 , 0x78 , 0x00 , 0x00 , 0x00 , 0x7C , 0x00 , 0x00 , 0x00 ,
0x7E , 0x00 , 0x00 , 0x00 , 0x7F , 0x00 , 0x00 , 0x00 , 0x7F , 0x80 , 0x00 , 0x00 , 0x7C , 0x00 , 0x00 , 0x00 ,
0x6C , 0x00 , 0x00 , 0x00 , 0x46 , 0x00 , 0x00 , 0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 ,
0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0xC0 , 0x00 , 0x00 , 0x00 , 0xA0 , 0x00 , 0x00 , 0x00 , 0x90 , 0x00 , 0x00 , 0x00 , 0x88 , 0x00 , 0x00 , 0x00 ,
0x84 , 0x00 , 0x00 , 0x00 , 0x82 , 0x00 , 0x00 , 0x00 , 0x81 , 0x00 , 0x00 , 0x00 , 0x80 , 0x80 , 0x00 , 0x00 ,
0x80 , 0x40 , 0x00 , 0x00 , 0x83 , 0xC0 , 0x00 , 0x00 , 0x92 , 0x00 , 0x00 , 0x00 , 0xA9 , 0x00 , 0x00 , 0x00 ,
0xC9 , 0x00 , 0x00 , 0x00 , 0x04 , 0x80 , 0x00 , 0x00 , 0x04 , 0x80 , 0x00 , 0x00 , 0x03 , 0x80 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xC0 , 0x00 , 0x00 , 0x00 , 0xE0 , 0x00 , 0x00 , 0x00 ,
0xF0 , 0x00 , 0x00 , 0x00 , 0xF8 , 0x00 , 0x00 , 0x00 , 0xFC , 0x00 , 0x00 , 0x00 , 0xFE , 0x00 , 0x00 , 0x00 ,
0xFF , 0x00 , 0x00 , 0x00 , 0xFF , 0x80 , 0x00 , 0x00 , 0xFF , 0xC0 , 0x00 , 0x00 , 0xFF , 0xC0 , 0x00 , 0x00 ,
0xFE , 0x00 , 0x00 , 0x00 , 0xEF , 0x00 , 0x00 , 0x00 , 0xCF , 0x00 , 0x00 , 0x00 , 0x07 , 0x80 , 0x00 , 0x00 ,
0x07 , 0x80 , 0x00 , 0x00 , 0x03 , 0x80 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
} ;
static unsigned char bitmapHanPointer [ 288 ] = { // @ G0043_auc_Graphic562_Bitmap_HandPointer
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xC0 , 0x00 , 0x00 , 0x00 , 0x6A , 0x00 , 0x00 , 0x00 ,
0x35 , 0x40 , 0x00 , 0x00 , 0x1A , 0xA0 , 0x00 , 0x00 , 0x0D , 0x50 , 0x00 , 0x00 , 0x0E , 0xA8 , 0x00 , 0x00 ,
0x07 , 0xF8 , 0x00 , 0x00 , 0xC7 , 0xFC , 0x00 , 0x00 , 0x67 , 0xFC , 0x00 , 0x00 , 0x77 , 0xFC , 0x00 , 0x00 ,
0x3F , 0xFC , 0x00 , 0x00 , 0x3F , 0xFC , 0x00 , 0x00 , 0x1F , 0xFE , 0x00 , 0x00 , 0x07 , 0xFF , 0x00 , 0x00 ,
0x01 , 0xFF , 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x20 , 0x00 , 0x00 , 0x00 , 0x95 , 0x00 , 0x00 , 0x00 , 0x4A , 0xA0 , 0x00 , 0x00 , 0x25 , 0x50 , 0x00 , 0x00 ,
0x12 , 0xA8 , 0x00 , 0x00 , 0x11 , 0x54 , 0x00 , 0x00 , 0xC8 , 0x04 , 0x00 , 0x00 , 0x28 , 0x02 , 0x00 , 0x00 ,
0x98 , 0x02 , 0x00 , 0x00 , 0x88 , 0x02 , 0x00 , 0x00 , 0x40 , 0x02 , 0x00 , 0x00 , 0x40 , 0x02 , 0x00 , 0x00 ,
0x20 , 0x01 , 0x00 , 0x00 , 0x18 , 0x00 , 0x00 , 0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xE0 , 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 ,
0x7F , 0xE0 , 0x00 , 0x00 , 0x3F , 0xF0 , 0x00 , 0x00 , 0x1F , 0xF8 , 0x00 , 0x00 , 0x1F , 0xFC , 0x00 , 0x00 ,
0xCF , 0xFC , 0x00 , 0x00 , 0xEF , 0xFE , 0x00 , 0x00 , 0xFF , 0xFE , 0x00 , 0x00 , 0xFF , 0xFE , 0x00 , 0x00 ,
0x7F , 0xFE , 0x00 , 0x00 , 0x7F , 0xFE , 0x00 , 0x00 , 0x3F , 0xFF , 0x00 , 0x00 , 0x1F , 0xFF , 0x00 , 0x00 ,
0x07 , 0xFF , 0x00 , 0x00 , 0x01 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
} ;
2016-08-25 08:12:23 +02:00
_preventBuildPointerScreenArea = true ;
if ( _useChampionIconOrdinalAsMousePointerBitmap ) {
2016-07-07 00:46:51 +02:00
if ( ( mousePosY > 28 ) | | ( mousePosX < 274 ) ) {
2016-08-25 08:12:23 +02:00
_mousePointerType = k4_pointerTypeAutoselect ;
mouseDropChampionIcon ( ) ;
2016-08-10 07:39:43 +02:00
} else
2016-08-25 08:12:23 +02:00
_mousePointerType = k2_pointerTypeChampionIcon ;
2016-08-10 07:39:43 +02:00
} else if ( mousePosY > = 169 )
2016-08-25 08:12:23 +02:00
_mousePointerType = k0_pointerTypeArrow ;
2016-08-10 07:39:43 +02:00
else if ( mousePosX > = 274 )
2016-08-25 08:12:23 +02:00
_mousePointerType = k0_pointerTypeArrow ;
2016-08-10 07:39:43 +02:00
else if ( mousePosY < = 28 ) {
uint16 championIdx = mousePosX / 69 ;
uint16 xOverChampionStatusBox = mousePosX % 69 ;
2016-08-23 07:54:16 +02:00
if ( championIdx > = _vm - > _championMan - > _partyChampionCount )
2016-08-25 08:12:23 +02:00
_mousePointerType = k4_pointerTypeAutoselect ;
2016-08-10 07:39:43 +02:00
else if ( xOverChampionStatusBox > 42 )
2016-08-25 08:12:23 +02:00
_mousePointerType = k4_pointerTypeAutoselect ;
2016-08-10 07:39:43 +02:00
else {
championIdx + + ;
2016-08-25 21:25:18 +02:00
if ( championIdx = = _vm - > _inventoryMan - > _inventoryChampionOrdinal )
2016-08-25 08:12:23 +02:00
_mousePointerType = k0_pointerTypeArrow ;
2016-08-10 07:39:43 +02:00
else if ( mousePosY < = 6 )
2016-08-25 08:12:23 +02:00
_mousePointerType = k0_pointerTypeArrow ;
2016-08-10 07:39:43 +02:00
else
2016-08-25 08:12:23 +02:00
_mousePointerType = k4_pointerTypeAutoselect ;
2016-07-07 00:46:51 +02:00
}
2016-08-10 07:39:43 +02:00
} else if ( mousePosX > = 224 )
2016-08-25 08:12:23 +02:00
_mousePointerType = k0_pointerTypeArrow ;
2016-08-10 07:39:43 +02:00
else
2016-08-25 08:12:23 +02:00
_mousePointerType = k4_pointerTypeAutoselect ;
2016-08-10 07:39:43 +02:00
2016-08-25 08:12:23 +02:00
if ( _mousePointerType = = k4_pointerTypeAutoselect )
_mousePointerType = ( _useObjectAsMousePointerBitmap ) ? k1_pointerTypeObjectIcon : ( _useHandAsMousePointerBitmap ) ? k3_pointerTypeHand : k0_pointerTypeArrow ;
2016-08-10 07:39:43 +02:00
2016-08-25 08:12:23 +02:00
if ( _mousePointerBitmapUpdated | | ( _mousePointerType ! = _previousMousePointerType ) ) {
_mousePointerBitmapUpdated = false ;
switch ( _mousePointerType ) {
2016-07-07 00:46:51 +02:00
case k0_pointerTypeArrow :
2016-08-18 21:18:08 +02:00
setMousePointerFromSpriteData ( bitmapArrowPointer ) ;
2016-07-07 00:46:51 +02:00
break ;
case k1_pointerTypeObjectIcon :
2016-08-25 08:12:23 +02:00
CursorMan . replaceCursor ( _mousePointerOriginalColorsObject , 32 , 18 , 0 , 0 , 0 ) ;
2016-07-07 00:46:51 +02:00
break ;
case k2_pointerTypeChampionIcon :
2016-08-25 08:12:23 +02:00
CursorMan . replaceCursor ( _mousePointerOriginalColorsChampionIcon , 32 , 18 , 0 , 0 , 0 ) ;
2016-07-07 00:46:51 +02:00
break ;
case k3_pointerTypeHand :
2016-08-18 21:18:08 +02:00
setMousePointerFromSpriteData ( bitmapHanPointer ) ;
2016-07-07 00:46:51 +02:00
break ;
}
}
2016-08-25 08:12:23 +02:00
_previousMousePointerType = _mousePointerType ;
_preventBuildPointerScreenArea = false ;
2016-07-07 00:46:51 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : setMousePointer ( ) {
2016-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _leaderEmptyHanded )
2016-09-09 07:12:36 +02:00
setMousePointerToNormal ( ( _vm - > _championMan - > _leaderIndex = = kDMChampionNone ) ? k0_pointerArrow : k1_pointerHand ) ;
2016-08-10 07:39:43 +02:00
else
2016-08-25 22:19:34 +02:00
setPointerToObject ( _vm - > _objectMan - > _objectIconForMousePointer ) ;
2016-07-07 00:46:51 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : showMouse ( ) {
if ( _hideMousePointerRequestCount + + = = 0 )
2016-08-10 07:39:43 +02:00
CursorMan . showMouse ( true ) ;
2016-07-07 00:46:51 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : hideMouse ( ) {
if ( _hideMousePointerRequestCount - - = = 1 )
2016-08-10 07:39:43 +02:00
CursorMan . showMouse ( false ) ;
2016-06-15 10:41:33 +02:00
}
2016-07-28 19:27:58 +02:00
bool EventManager : : isMouseButtonDown ( MouseButton button ) {
2016-09-13 22:58:54 +02:00
return ( button ! = kDMMouseButtonNone ) ? ( _mouseButtonStatus & button ) : ( _mouseButtonStatus = = 0 ) ;
2016-07-28 19:27:58 +02:00
}
2016-07-07 00:46:51 +02:00
2016-06-15 10:41:33 +02:00
void EventManager : : setMousePos ( Common : : Point pos ) {
2016-09-03 15:52:59 +02:00
g_system - > warpMouse ( pos . x , pos . y ) ;
2016-06-15 10:41:33 +02:00
}
2016-07-28 17:53:42 +02:00
Common : : EventType EventManager : : processInput ( Common : : Event * grabKey , Common : : Event * grabMouseClick ) {
2016-06-15 10:41:33 +02:00
Common : : Event event ;
2016-09-03 15:52:59 +02:00
while ( g_system - > getEventManager ( ) - > pollEvent ( event ) ) {
2016-06-16 23:48:18 +02:00
switch ( event . type ) {
2016-07-11 10:52:38 +02:00
case Common : : EVENT_KEYDOWN : {
2016-06-16 23:48:18 +02:00
if ( event . synthetic )
break ;
2016-08-10 07:39:43 +02:00
2016-08-10 11:10:56 +02:00
if ( event . kbd . keycode = = Common : : KEYCODE_d & & event . kbd . hasFlags ( Common : : KBD_CTRL ) ) {
_vm - > _console - > attach ( ) ;
2016-08-10 14:44:42 +02:00
return Common : : EVENT_INVALID ;
2016-08-10 11:10:56 +02:00
}
2016-07-28 17:53:42 +02:00
if ( grabKey ) {
* grabKey = event ;
return event . type ;
}
2016-08-10 07:39:43 +02:00
2016-08-25 08:12:23 +02:00
if ( _primaryKeyboardInput ) {
KeyboardInput * input = _primaryKeyboardInput ;
2016-09-13 22:58:54 +02:00
while ( input - > _commandToIssue ! = kDMCommandNone ) {
2016-07-11 10:52:38 +02:00
if ( ( input - > _key = = event . kbd . keycode ) & & ( input - > _modifiers = = ( event . kbd . flags & input - > _modifiers ) ) ) {
2016-08-25 08:12:23 +02:00
processPendingClick ( ) ; // possible fix to BUG0_73
2016-07-11 10:52:38 +02:00
_commandQueue . push ( Command ( Common : : Point ( - 1 , - 1 ) , input - > _commandToIssue ) ) ;
break ;
}
input + + ;
}
}
2016-08-26 22:50:30 +02:00
2016-08-25 08:12:23 +02:00
if ( _secondaryKeyboardInput ) {
KeyboardInput * input = _secondaryKeyboardInput ;
2016-09-13 22:58:54 +02:00
while ( input - > _commandToIssue ! = kDMCommandNone ) {
2016-07-11 10:52:38 +02:00
if ( ( input - > _key = = event . kbd . keycode ) & & ( input - > _modifiers = = ( event . kbd . flags & input - > _modifiers ) ) ) {
2016-08-25 08:12:23 +02:00
processPendingClick ( ) ; // possible fix to BUG0_73
2016-07-11 10:52:38 +02:00
_commandQueue . push ( Command ( Common : : Point ( - 1 , - 1 ) , input - > _commandToIssue ) ) ;
break ;
}
input + + ;
}
}
2016-07-28 17:53:42 +02:00
break ;
2016-08-26 22:50:30 +02:00
}
2016-06-16 23:48:18 +02:00
case Common : : EVENT_MOUSEMOVE :
2016-08-25 08:12:23 +02:00
if ( ! _ignoreMouseMovements )
2016-07-13 19:51:14 +02:00
_mousePos = event . mouse ;
2016-06-16 23:48:18 +02:00
break ;
2016-06-17 14:29:05 +02:00
case Common : : EVENT_LBUTTONDOWN :
2016-07-28 19:27:58 +02:00
case Common : : EVENT_RBUTTONDOWN : {
2016-09-13 22:58:54 +02:00
MouseButton button = ( event . type = = Common : : EVENT_LBUTTONDOWN ) ? kDMMouseButtonLeft : kDMMouseButtonRight ;
2016-08-25 08:12:23 +02:00
_mouseButtonStatus | = button ;
2016-07-28 17:53:42 +02:00
if ( grabMouseClick ) {
* grabMouseClick = event ;
return event . type ;
}
2016-08-25 08:12:23 +02:00
_pendingClickPresent = true ;
_pendingClickPos = _mousePos ;
_pendingClickButton = button ;
2016-07-28 19:27:58 +02:00
break ;
}
case Common : : EVENT_LBUTTONUP :
case Common : : EVENT_RBUTTONUP : {
2016-09-13 22:58:54 +02:00
MouseButton button = ( event . type = = Common : : EVENT_LBUTTONDOWN ) ? kDMMouseButtonLeft : kDMMouseButtonRight ;
2016-08-25 08:12:23 +02:00
_mouseButtonStatus & = ~ button ;
resetPressingEyeOrMouth ( ) ;
2016-06-16 23:48:18 +02:00
break ;
2016-07-28 19:27:58 +02:00
}
2016-07-29 22:27:43 +02:00
case Common : : EVENT_QUIT :
_vm - > _engineShouldQuit = true ;
break ;
2016-06-23 23:22:50 +02:00
default :
break ;
2016-06-15 10:41:33 +02:00
}
}
2016-08-25 08:12:23 +02:00
if ( _ignoreMouseMovements )
2016-07-29 15:13:38 +02:00
setMousePos ( _mousePos ) ;
2016-07-28 17:53:42 +02:00
return Common : : EVENT_INVALID ;
2016-06-15 10:41:33 +02:00
}
2016-06-16 23:48:18 +02:00
2016-07-28 17:53:42 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : processPendingClick ( ) {
if ( _pendingClickPresent ) {
_pendingClickPresent = false ;
processClick ( _pendingClickPos , _pendingClickButton ) ;
2016-06-16 23:48:18 +02:00
}
}
2016-08-25 08:12:23 +02:00
void EventManager : : processClick ( Common : : Point mousePos , MouseButton button ) {
2016-06-16 23:48:18 +02:00
CommandType commandType ;
2016-08-25 08:12:23 +02:00
commandType = getCommandTypeFromMouseInput ( _primaryMouseInput , mousePos , button ) ;
2016-09-13 22:58:54 +02:00
if ( commandType = = kDMCommandNone )
2016-08-25 08:12:23 +02:00
commandType = getCommandTypeFromMouseInput ( _secondaryMouseInput , mousePos , button ) ;
2016-06-16 23:48:18 +02:00
2016-09-13 22:58:54 +02:00
if ( commandType ! = kDMCommandNone )
2016-06-16 23:48:18 +02:00
_commandQueue . push ( Command ( mousePos , commandType ) ) ;
2016-08-25 08:12:23 +02:00
_isCommandQueueLocked = false ;
2016-06-16 23:48:18 +02:00
}
2016-08-25 08:12:23 +02:00
CommandType EventManager : : getCommandTypeFromMouseInput ( MouseInput * input , Common : : Point mousePos , MouseButton button ) {
2016-06-16 23:48:18 +02:00
if ( ! input )
2016-09-13 22:58:54 +02:00
return kDMCommandNone ;
2016-06-16 23:48:18 +02:00
2016-09-13 22:58:54 +02:00
CommandType commandType = kDMCommandNone ;
while ( ( commandType = input - > _commandTypeToIssue ) ! = kDMCommandNone ) {
2016-06-18 18:02:48 +02:00
if ( input - > _hitbox . isPointInside ( mousePos ) & & input - > _button = = button )
2016-06-16 23:48:18 +02:00
break ;
input + + ;
}
return commandType ;
}
2016-08-25 08:12:23 +02:00
void EventManager : : processCommandQueue ( ) {
2016-08-10 21:48:22 +02:00
static KeyboardInput * primaryKeyboardInputBackup ;
static KeyboardInput * secondaryKeyboardInputBackup ;
static MouseInput * primaryMouseInputBackup ;
static MouseInput * secondaryMouseInputBackup ;
2016-07-12 11:30:25 +02:00
2016-08-25 08:12:23 +02:00
_isCommandQueueLocked = true ;
2016-07-12 11:30:25 +02:00
if ( _commandQueue . empty ( ) ) { /* If the command queue is empty */
2016-08-25 08:12:23 +02:00
_isCommandQueueLocked = false ;
processPendingClick ( ) ;
2016-06-17 14:29:05 +02:00
return ;
}
Command cmd = _commandQueue . pop ( ) ;
2016-08-10 21:48:22 +02:00
CommandType cmdType = cmd . _type ;
2016-09-13 22:58:54 +02:00
if ( ( cmdType > = kDMCommandMoveForward ) & & ( cmdType < = kDMCommandMoveLeft ) & & ( _vm - > _disabledMovementTicks | | ( _vm - > _projectileDisableMovementTicks & & ( _vm - > _lastProjectileDisabledMovementDirection = = ( _vm - > normalizeModulo4 ( _vm - > _dungeonMan - > _partyDir + cmdType - kDMCommandMoveForward ) ) ) ) ) ) { /* If movement is disabled */
2016-08-25 08:12:23 +02:00
_isCommandQueueLocked = false ;
processPendingClick ( ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
int16 commandX = cmd . _pos . x ;
int16 commandY = cmd . _pos . y ;
2016-08-25 08:12:23 +02:00
_isCommandQueueLocked = false ;
processPendingClick ( ) ;
2016-09-13 22:58:54 +02:00
if ( ( cmdType = = kDMCommandTurnRight ) | | ( cmdType = = kDMCommandTurnLeft ) ) {
2016-08-25 08:12:23 +02:00
commandTurnParty ( cmdType ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( ( cmdType > = kDMCommandMoveForward ) & & ( cmdType < = kDMCommandMoveLeft ) ) {
2016-08-25 08:12:23 +02:00
commandMoveParty ( cmdType ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( ( cmdType > = kDMCommandClickInChampion0StatusBox ) & & ( cmdType < = kDMCommandClickInChampion3StatusBox ) ) {
int16 championIdx = cmdType - kDMCommandClickInChampion0StatusBox ;
2016-08-23 07:54:16 +02:00
if ( ( championIdx < _vm - > _championMan - > _partyChampionCount ) & & ! _vm - > _championMan - > _candidateChampionOrdinal )
2016-08-25 08:12:23 +02:00
commandProcessTypes12to27_clickInChampionStatusBox ( championIdx , commandX , commandY ) ;
2016-08-10 21:48:22 +02:00
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( ( cmdType > = kDMCommandClickOnChamptionIconTopLeft ) & & ( cmdType < = kDMCommandClickOnChamptionIconLowerLeft ) ) {
mouseProcessCommands125To128_clickOnChampionIcon ( cmdType - kDMCommandClickOnChamptionIconTopLeft ) ;
2016-08-10 21:48:22 +02:00
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( ( cmdType > = kDMCommandClickOnSlotBoxInventoryReadyHand ) & & ( cmdType < ( kDMCommandClickOnSlotBoxChest8 + 1 ) ) ) {
2016-09-09 07:12:36 +02:00
if ( _vm - > _championMan - > _leaderIndex ! = kDMChampionNone )
2016-09-13 22:58:54 +02:00
_vm - > _championMan - > clickOnSlotBox ( cmdType - kDMCommandClickOnSlotBoxChampion0StatusBoxReadyHand ) ;
2016-08-10 21:48:22 +02:00
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( ( cmdType > = kDMCommandToggleInventoryChampion0 ) & & ( cmdType < = kDMCommandCloseInventory ) ) {
if ( cmdType = = kDMCommandCloseInventory ) {
2016-08-22 19:27:10 +02:00
delete _vm - > _saveThumbnail ;
_vm - > _saveThumbnail = nullptr ;
} else if ( ! _vm - > _saveThumbnail ) {
_vm - > _saveThumbnail = new Common : : MemoryWriteStreamDynamic ( ) ;
Graphics : : saveThumbnail ( * _vm - > _saveThumbnail ) ;
}
2016-09-13 22:58:54 +02:00
int16 championIndex = cmdType - kDMCommandToggleInventoryChampion0 ;
2016-09-09 07:12:36 +02:00
if ( ( ( championIndex = = kDMChampionCloseInventory ) | | ( championIndex < _vm - > _championMan - > _partyChampionCount ) ) & & ! _vm - > _championMan - > _candidateChampionOrdinal )
2016-08-25 21:25:18 +02:00
_vm - > _inventoryMan - > toggleInventory ( ( ChampionIndex ) championIndex ) ;
2016-08-10 21:48:22 +02:00
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandToggleInventoryLeader ) {
2016-09-09 07:12:36 +02:00
if ( _vm - > _championMan - > _leaderIndex ! = kDMChampionNone )
2016-08-25 21:25:18 +02:00
_vm - > _inventoryMan - > toggleInventory ( _vm - > _championMan - > _leaderIndex ) ;
2016-08-10 21:48:22 +02:00
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandClickInSpellArea ) {
2016-09-09 07:12:36 +02:00
if ( ( ! _vm - > _championMan - > _candidateChampionOrdinal ) & & ( _vm - > _championMan - > _magicCasterChampionIndex ! = kDMChampionNone ) )
2016-08-25 08:12:23 +02:00
commandProcessType100_clickInSpellArea ( commandX , commandY ) ;
2016-08-10 21:48:22 +02:00
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandClickInActionArea ) {
2016-08-23 07:54:16 +02:00
if ( ! _vm - > _championMan - > _candidateChampionOrdinal )
2016-08-25 08:12:23 +02:00
commandProcessType111To115_ClickInActionArea ( commandX , commandY ) ;
2016-08-10 21:48:22 +02:00
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandClickOnMouth ) {
2016-08-25 21:25:18 +02:00
_vm - > _inventoryMan - > clickOnMouth ( ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandClickOnEye ) {
2016-08-25 21:25:18 +02:00
_vm - > _inventoryMan - > clickOnEye ( ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandClickInDungeonView ) {
2016-08-25 08:12:23 +02:00
commandProcessType80ClickInDungeonView ( commandX , commandY ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandClickInPanel ) {
2016-08-25 08:12:23 +02:00
commandProcess81ClickInPanel ( commandX , commandY ) ;
2016-06-17 14:29:05 +02:00
return ;
}
2016-08-23 23:36:18 +02:00
if ( _vm - > _pressingEye | | _vm - > _pressingMouth )
2016-06-17 14:29:05 +02:00
return ;
2016-06-23 17:32:55 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandSleep ) {
2016-08-23 07:54:16 +02:00
if ( ! _vm - > _championMan - > _candidateChampionOrdinal ) {
2016-08-25 21:25:18 +02:00
if ( _vm - > _inventoryMan - > _inventoryChampionOrdinal )
2016-09-09 07:12:36 +02:00
_vm - > _inventoryMan - > toggleInventory ( kDMChampionCloseInventory ) ;
2016-08-10 21:48:22 +02:00
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > drawDisabledMenu ( ) ;
2016-08-23 07:54:16 +02:00
_vm - > _championMan - > _partyIsSleeping = true ;
2016-08-25 08:12:23 +02:00
drawSleepScreen ( ) ;
2016-08-25 18:32:03 +02:00
_vm - > _displayMan - > drawViewport ( k2_viewportAsBeforeSleepOrFreezeGame ) ;
2016-08-23 23:36:18 +02:00
_vm - > _waitForInputMaxVerticalBlankCount = 0 ;
2016-08-25 08:12:23 +02:00
_primaryMouseInput = _primaryMouseInputPartySleeping ;
_secondaryMouseInput = 0 ;
_primaryKeyboardInput = _primaryKeyboardInputPartySleeping ;
_secondaryKeyboardInput = nullptr ;
discardAllInput ( ) ;
2016-07-12 11:30:25 +02:00
}
return ;
2016-06-17 14:29:05 +02:00
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandWakeUp ) {
2016-08-23 07:54:16 +02:00
_vm - > _championMan - > wakeUp ( ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandSaveGame ) {
2016-08-23 07:54:16 +02:00
if ( ( _vm - > _championMan - > _partyChampionCount > 0 ) & & ! _vm - > _championMan - > _candidateChampionOrdinal )
2016-08-23 23:36:18 +02:00
_vm - > saveGame ( ) ;
2016-08-10 21:48:22 +02:00
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandFreezeGame ) {
2016-08-23 23:36:18 +02:00
_vm - > _gameTimeTicking = false ;
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > drawDisabledMenu ( ) ;
2016-09-16 07:46:10 +02:00
_vm - > _displayMan - > fillBitmap ( _vm - > _displayMan - > _bitmapViewport , kDMColorBlack , 112 , 136 ) ;
2016-08-15 20:25:40 +02:00
switch ( _vm - > getGameLanguage ( ) ) { // localized
default :
case Common : : EN_ANY :
2016-09-16 07:46:10 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 81 , 69 , kDMColorCyan , kDMColorBlack ,
2016-08-15 20:25:40 +02:00
" GAME FROZEN " , k136_heightViewport ) ;
break ;
2016-08-16 09:28:57 +02:00
case Common : : DE_DEU :
2016-09-16 07:46:10 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 66 , 69 , kDMColorCyan , kDMColorBlack ,
2016-08-15 20:25:40 +02:00
" SPIEL ANGEHALTEN " , k136_heightViewport ) ;
break ;
case Common : : FR_FRA :
2016-09-16 07:46:10 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 84 , 69 , kDMColorCyan , kDMColorBlack ,
2016-08-15 20:25:40 +02:00
" JEU BLOQUE " , k136_heightViewport ) ;
break ;
}
2016-08-25 18:32:03 +02:00
_vm - > _displayMan - > drawViewport ( k2_viewportAsBeforeSleepOrFreezeGame ) ;
2016-08-25 08:12:23 +02:00
primaryMouseInputBackup = _primaryMouseInput ;
secondaryMouseInputBackup = _secondaryMouseInput ;
primaryKeyboardInputBackup = _primaryKeyboardInput ;
secondaryKeyboardInputBackup = _secondaryKeyboardInput ;
_primaryMouseInput = _primaryMouseInputFrozenGame ;
_secondaryMouseInput = 0 ;
_primaryKeyboardInput = _primaryKeyboardInputFrozenGame ;
_secondaryKeyboardInput = nullptr ;
discardAllInput ( ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandUnfreezeGame ) {
2016-08-23 23:36:18 +02:00
_vm - > _gameTimeTicking = true ;
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > drawEnabledMenus ( ) ;
2016-08-25 08:12:23 +02:00
_primaryMouseInput = primaryMouseInputBackup ;
_secondaryMouseInput = secondaryMouseInputBackup ;
_primaryKeyboardInput = primaryKeyboardInputBackup ;
_secondaryKeyboardInput = secondaryKeyboardInputBackup ;
discardAllInput ( ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandEntranceEnterDungeon ) {
2016-08-23 23:36:18 +02:00
_vm - > _newGameFl = k1_modeLoadDungeon ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandEntranceResume ) {
2016-08-23 23:36:18 +02:00
_vm - > _newGameFl = k0_modeLoadSavedGame ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandEntranceDrawCredits ) {
2016-08-23 23:36:18 +02:00
_vm - > entranceDrawCredits ( ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( ( cmdType > = kDMCommandClickOnDialogChoice1 ) & & ( cmdType < = kDMCommandClickOnDialogChoice4 ) ) {
_vm - > _dialog - > _selectedDialogChoice = cmdType - ( kDMCommandClickOnDialogChoice1 - 1 ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandRestartGame )
2016-08-23 23:36:18 +02:00
_vm - > _restartGameRequest = true ;
2016-06-17 14:29:05 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : commandTurnParty ( CommandType cmdType ) {
2016-08-23 23:36:18 +02:00
_vm - > _stopWaitingForPlayerInput = true ;
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandTurnLeft )
2016-08-25 08:12:23 +02:00
commandHighlightBoxEnable ( 234 , 261 , 125 , 145 ) ;
2016-08-10 21:48:22 +02:00
else
2016-08-25 08:12:23 +02:00
commandHighlightBoxEnable ( 291 , 318 , 125 , 145 ) ;
2016-08-10 21:48:22 +02:00
2016-08-24 08:03:55 +02:00
uint16 partySquare = _vm - > _dungeonMan - > getSquare ( _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY ) . toByte ( ) ;
2016-09-13 07:46:38 +02:00
if ( Square ( partySquare ) . getType ( ) = = kDMElementTypeStairs ) {
commandTakeStairs ( getFlag ( partySquare , kDMSquareMaskStairsUp ) ) ;
2016-07-11 13:12:40 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
2016-08-25 22:09:30 +02:00
_vm - > _moveSens - > processThingAdditionOrRemoval ( _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY , Thing : : _party , true , false ) ;
2016-09-13 22:58:54 +02:00
_vm - > _championMan - > setPartyDirection ( _vm - > normalizeModulo4 ( _vm - > _dungeonMan - > _partyDir + ( ( cmdType = = kDMCommandTurnRight ) ? 1 : 3 ) ) ) ;
2016-08-25 22:09:30 +02:00
_vm - > _moveSens - > processThingAdditionOrRemoval ( _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY , Thing : : _party , true , true ) ;
2016-06-17 14:29:05 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : commandMoveParty ( CommandType cmdType ) {
2016-08-10 21:48:22 +02:00
static Box boxMovementArrows [ 4 ] = { // @ G0463_as_Graphic561_Box_MovementArrows
2016-08-26 22:50:30 +02:00
/* { X1, X2, Y1, Y2 } */
Box ( 263 , 289 , 125 , 145 ) , /* Forward */
Box ( 291 , 318 , 147 , 167 ) , /* Right */
Box ( 263 , 289 , 147 , 167 ) , /* Backward */
2016-08-10 21:48:22 +02:00
Box ( 234 , 261 , 147 , 167 ) /* Left */
} ;
2016-08-26 22:50:30 +02:00
2016-08-10 21:48:22 +02:00
static int16 movementArrowToStepForwardCount [ 4 ] = { // @ G0465_ai_Graphic561_MovementArrowToStepForwardCount
2016-08-26 22:50:30 +02:00
1 , /* Forward */
0 , /* Right */
- 1 , /* Backward */
2016-08-10 21:48:22 +02:00
0 /* Left */
} ;
static int16 movementArrowToSepRightCount [ 4 ] = { // @ G0466_ai_Graphic561_MovementArrowToStepRightCount
2016-08-26 22:50:30 +02:00
0 , /* Forward */
1 , /* Right */
0 , /* Backward */
2016-08-10 21:48:22 +02:00
- 1 /* Left */
} ;
2016-08-26 22:50:30 +02:00
2016-08-23 23:36:18 +02:00
_vm - > _stopWaitingForPlayerInput = true ;
2016-08-23 07:54:16 +02:00
Champion * championsPtr = _vm - > _championMan - > _champions ;
2016-09-09 07:12:36 +02:00
for ( uint16 idx = kDMChampionFirst ; idx < _vm - > _championMan - > _partyChampionCount ; idx + + ) {
2016-08-23 07:54:16 +02:00
_vm - > _championMan - > decrementStamina ( idx , ( ( championsPtr - > _load * 3 ) / _vm - > _championMan - > getMaximumLoad ( championsPtr ) ) + 1 ) ; /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */
2016-08-10 22:41:12 +02:00
championsPtr + + ;
}
2016-09-13 22:58:54 +02:00
uint16 movementArrowIdx = cmdType - kDMCommandMoveForward ;
2016-08-10 22:41:12 +02:00
Box * highlightBox = & boxMovementArrows [ movementArrowIdx ] ;
2016-09-16 21:17:02 +02:00
commandHighlightBoxEnable ( highlightBox - > _rect . left , highlightBox - > _rect . right , highlightBox - > _rect . top , highlightBox - > _rect . bottom ) ;
2016-08-24 08:03:55 +02:00
int16 partyMapX = _vm - > _dungeonMan - > _partyMapX ;
int16 partyMapY = _vm - > _dungeonMan - > _partyMapY ;
2016-09-11 10:53:54 +02:00
Square curSquare = _vm - > _dungeonMan - > getSquare ( partyMapX , partyMapY ) ;
2016-09-13 07:46:38 +02:00
bool isStairsSquare = ( curSquare . getType ( ) = = kDMElementTypeStairs ) ;
2016-08-10 22:41:12 +02:00
if ( isStairsSquare & & ( movementArrowIdx = = 2 ) ) { /* If moving backward while in stairs */
2016-09-13 07:46:38 +02:00
commandTakeStairs ( getFlag ( curSquare . toByte ( ) , kDMSquareMaskStairsUp ) ) ;
2016-08-26 22:50:30 +02:00
return ;
}
2016-09-11 10:45:20 +02:00
2016-08-24 08:03:55 +02:00
_vm - > _dungeonMan - > mapCoordsAfterRelMovement ( _vm - > _dungeonMan - > _partyDir , movementArrowToStepForwardCount [ movementArrowIdx ] , movementArrowToSepRightCount [ movementArrowIdx ] , partyMapX , partyMapY ) ;
2016-09-11 10:53:54 +02:00
curSquare = _vm - > _dungeonMan - > getSquare ( partyMapX , partyMapY ) ;
2016-09-11 10:59:18 +02:00
bool isMovementBlocked = false ;
2016-09-13 07:46:38 +02:00
ElementType partySquareType = curSquare . getType ( ) ;
2016-09-11 10:59:18 +02:00
switch ( partySquareType ) {
2016-09-11 21:22:22 +02:00
case kDMElementTypeWall :
2016-09-11 10:59:18 +02:00
isMovementBlocked = true ;
break ;
2016-09-11 21:22:22 +02:00
case kDMElementTypeStairs : {
_vm - > _moveSens - > getMoveResult ( Thing : : _party , _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY , kDMMapXNotOnASquare , 0 ) ;
2016-08-24 08:03:55 +02:00
_vm - > _dungeonMan - > _partyMapX = partyMapX ;
_vm - > _dungeonMan - > _partyMapY = partyMapY ;
2016-09-11 10:53:54 +02:00
byte stairState = curSquare . toByte ( ) ;
2016-09-13 07:46:38 +02:00
commandTakeStairs ( getFlag ( stairState , kDMSquareMaskStairsUp ) ) ;
2016-08-26 22:50:30 +02:00
return ;
2016-09-11 10:59:18 +02:00
}
2016-09-13 07:46:38 +02:00
case kDMElementTypeDoor : {
2016-09-11 10:53:54 +02:00
byte doorState = curSquare . getDoorState ( ) ;
2016-09-14 21:27:09 +02:00
isMovementBlocked = ( doorState ! = kDMDoorStateOpen ) & & ( doorState ! = kDMDoorStateOneFourth ) & & ( doorState ! = kDMDoorStateDestroyed ) ;
2016-09-11 10:59:18 +02:00
}
break ;
2016-09-11 21:22:22 +02:00
case kDMElementTypeFakeWall : {
2016-09-11 10:53:54 +02:00
byte wallState = curSquare . toByte ( ) ;
2016-09-13 07:46:38 +02:00
isMovementBlocked = ( ! getFlag ( wallState , kDMSquareMaskFakeWallOpen ) & & ! getFlag ( wallState , kDMSquareMaskFakeWallImaginary ) ) ;
2016-09-11 10:59:18 +02:00
}
break ;
default :
break ;
2016-09-11 10:53:54 +02:00
}
2016-08-10 22:41:12 +02:00
2016-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _partyChampionCount ) {
2016-08-10 22:41:12 +02:00
if ( isMovementBlocked ) {
2016-08-24 08:03:55 +02:00
movementArrowIdx + = ( _vm - > _dungeonMan - > _partyDir + 2 ) ;
2016-09-11 10:45:20 +02:00
int16 firstDamagedChampionIndex = _vm - > _championMan - > getTargetChampionIndex ( partyMapX , partyMapY , _vm - > normalizeModulo4 ( movementArrowIdx ) ) ;
int16 secondDamagedChampionIndex = _vm - > _championMan - > getTargetChampionIndex ( partyMapX , partyMapY , _vm - > turnDirRight ( movementArrowIdx ) ) ;
int16 damage = _vm - > _championMan - > addPendingDamageAndWounds_getDamage ( firstDamagedChampionIndex , 1 , kDMWoundTorso | kDMWoundLegs , kDMAttackTypeSelf ) ;
if ( firstDamagedChampionIndex ! = secondDamagedChampionIndex )
damage | = _vm - > _championMan - > addPendingDamageAndWounds_getDamage ( secondDamagedChampionIndex , 1 , kDMWoundTorso | kDMWoundLegs , kDMAttackTypeSelf ) ;
2016-08-10 21:48:22 +02:00
2016-08-10 22:41:12 +02:00
if ( damage )
2016-09-12 22:36:17 +02:00
_vm - > _sound - > requestPlay ( k18_soundPARTY_DAMAGED , partyMapX , partyMapY , kDMSoundModePlayImmediately ) ;
2016-08-21 01:16:00 +02:00
} else {
2016-08-25 21:17:48 +02:00
isMovementBlocked = ( _vm - > _groupMan - > groupGetThing ( partyMapX , partyMapY ) ! = Thing : : _endOfList ) ;
2016-08-21 01:16:00 +02:00
if ( isMovementBlocked )
2016-08-25 21:17:48 +02:00
_vm - > _groupMan - > processEvents29to41 ( partyMapX , partyMapY , kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent , 0 ) ;
2016-08-21 01:16:00 +02:00
}
2016-08-26 22:50:30 +02:00
}
2016-08-10 22:41:12 +02:00
2016-08-10 13:42:46 +02:00
// DEBUG CODE: check for Console flag
2016-08-10 22:41:12 +02:00
if ( isMovementBlocked & & ! _vm - > _console - > _debugNoclip ) {
2016-08-25 08:12:23 +02:00
discardAllInput ( ) ;
2016-08-23 23:36:18 +02:00
_vm - > _stopWaitingForPlayerInput = false ;
2016-08-26 22:50:30 +02:00
return ;
}
2016-08-10 22:41:12 +02:00
if ( isStairsSquare )
2016-09-11 21:22:22 +02:00
_vm - > _moveSens - > getMoveResult ( Thing : : _party , kDMMapXNotOnASquare , 0 , partyMapX , partyMapY ) ;
2016-08-10 22:41:12 +02:00
else
2016-08-25 22:09:30 +02:00
_vm - > _moveSens - > getMoveResult ( Thing : : _party , _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY , partyMapX , partyMapY ) ;
2016-08-10 22:41:12 +02:00
uint16 disabledMovtTicks = 1 ;
2016-08-23 07:54:16 +02:00
championsPtr = _vm - > _championMan - > _champions ;
2016-09-09 07:12:36 +02:00
for ( uint16 idx = kDMChampionFirst ; idx < _vm - > _championMan - > _partyChampionCount ; idx + + ) {
2016-08-10 22:41:12 +02:00
if ( championsPtr - > _currHealth )
2016-08-23 07:54:16 +02:00
disabledMovtTicks = MAX ( ( int32 ) disabledMovtTicks , ( int32 ) _vm - > _championMan - > getMovementTicks ( championsPtr ) ) ;
2016-08-10 22:41:12 +02:00
championsPtr + + ;
2016-08-26 22:50:30 +02:00
}
2016-08-23 23:36:18 +02:00
_vm - > _disabledMovementTicks = disabledMovtTicks ;
_vm - > _projectileDisableMovementTicks = 0 ;
2016-06-17 14:29:05 +02:00
}
2016-08-25 08:12:23 +02:00
bool EventManager : : isLeaderHandObjThrown ( int16 posX , int16 posY ) {
2016-09-10 21:50:57 +02:00
# define k0_sideLeft 0 // @ C0_SIDE_LEFT
# define k1_sideRight 1 // @ C0_SIDE_LEFT
2016-07-07 00:46:51 +02:00
2016-08-10 23:10:57 +02:00
if ( ( posY < 47 ) | | ( posY > 102 ) )
2016-07-07 00:46:51 +02:00
return false ;
2016-08-10 23:10:57 +02:00
bool objectThrownFl ;
2016-07-07 00:46:51 +02:00
if ( posX < = 111 ) {
2016-09-11 21:22:22 +02:00
if ( _vm - > _dungeonMan - > _squareAheadElement = = kDMElementTypeDoorFront ) {
2016-08-10 23:10:57 +02:00
if ( posX < 64 )
2016-07-07 00:46:51 +02:00
return false ;
2016-08-10 23:10:57 +02:00
} else if ( posX < 32 )
return false ;
// Strangerke: Only present in CSB2.1... But it fixes a bug so we keep it
2016-08-23 07:54:16 +02:00
objectThrownFl = _vm - > _championMan - > isLeaderHandObjectThrown ( k0_sideLeft ) ;
2016-07-07 00:46:51 +02:00
} else {
2016-09-11 21:22:22 +02:00
if ( _vm - > _dungeonMan - > _squareAheadElement = = kDMElementTypeDoorFront ) {
2016-08-10 23:10:57 +02:00
if ( posX > 163 )
2016-07-07 00:46:51 +02:00
return false ;
2016-08-10 23:10:57 +02:00
} else if ( posX > 191 )
return false ;
2016-08-23 07:54:16 +02:00
objectThrownFl = _vm - > _championMan - > isLeaderHandObjectThrown ( k1_sideRight ) ;
2016-07-07 00:46:51 +02:00
}
2016-08-10 23:10:57 +02:00
if ( objectThrownFl )
2016-08-23 23:36:18 +02:00
_vm - > _stopWaitingForPlayerInput = true ;
2016-08-10 23:10:57 +02:00
return objectThrownFl ;
2016-07-07 00:46:51 +02:00
}
2016-09-03 14:20:13 +02:00
void EventManager : : setMousePointerFromSpriteData ( byte * mouseSprite ) {
2016-08-08 16:12:15 +02:00
byte bitmap [ 16 * 18 ] ;
2016-08-14 21:24:36 +02:00
memset ( bitmap , 0 , sizeof ( bitmap ) ) ;
for ( int16 imgPart = 1 ; imgPart < 3 ; + + imgPart ) {
for ( byte * line = mouseSprite + 72 * imgPart , * pixel = bitmap ;
line < mouseSprite + 72 * ( imgPart + 1 ) ;
line + = 4 ) {
2016-08-08 16:12:15 +02:00
uint16 words [ 2 ] ;
words [ 0 ] = READ_BE_UINT16 ( line ) ;
words [ 1 ] = READ_BE_UINT16 ( line + 2 ) ;
2016-08-14 21:24:36 +02:00
for ( int16 i = 15 ; i > = 0 ; - - i , + + pixel ) {
uint16 val = ( ( ( words [ 0 ] > > i ) & 1 ) | ( ( ( words [ 1 ] > > i ) & 1 ) < < 1 ) ) < < ( imgPart & 0x2 ) ;
if ( val )
* pixel = val + 8 ;
}
2016-08-08 16:12:15 +02:00
}
}
2016-07-07 00:46:51 +02:00
2016-08-08 16:41:07 +02:00
CursorMan . replaceCursor ( bitmap , 16 , 18 , 0 , 0 , 0 ) ;
2016-08-08 16:12:15 +02:00
}
2016-07-07 00:46:51 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : commandSetLeader ( ChampionIndex champIndex ) {
2016-06-18 16:23:44 +02:00
ChampionMan & cm = * _vm - > _championMan ;
ChampionIndex leaderIndex ;
2016-09-09 07:12:36 +02:00
if ( ( cm . _leaderIndex = = champIndex ) | | ( ( champIndex ! = kDMChampionNone ) & & ! cm . _champions [ champIndex ] . _currHealth ) )
2016-06-18 16:23:44 +02:00
return ;
2016-09-09 07:12:36 +02:00
if ( cm . _leaderIndex ! = kDMChampionNone ) {
2016-08-23 07:54:16 +02:00
leaderIndex = cm . _leaderIndex ;
2016-09-09 07:32:32 +02:00
cm . _champions [ leaderIndex ] . setAttributeFlag ( kDMAttributeLoad , true ) ;
cm . _champions [ leaderIndex ] . setAttributeFlag ( kDMAttributeNameTitle , true ) ;
2016-08-24 08:03:55 +02:00
cm . _champions [ leaderIndex ] . _load - = _vm - > _dungeonMan - > getObjectWeight ( cm . _leaderHandObject ) ;
2016-09-09 07:12:36 +02:00
cm . _leaderIndex = kDMChampionNone ;
2016-08-23 07:54:16 +02:00
cm . drawChampionState ( leaderIndex ) ;
2016-06-18 16:23:44 +02:00
}
2016-09-09 07:12:36 +02:00
if ( champIndex = = kDMChampionNone ) {
cm . _leaderIndex = kDMChampionNone ;
2016-06-18 16:23:44 +02:00
return ;
}
2016-08-23 07:54:16 +02:00
cm . _leaderIndex = champIndex ;
Champion * champion = & cm . _champions [ cm . _leaderIndex ] ;
2016-08-24 08:03:55 +02:00
champion - > _dir = _vm - > _dungeonMan - > _partyDir ;
cm . _champions [ champIndex ] . _load + = _vm - > _dungeonMan - > getObjectWeight ( cm . _leaderHandObject ) ;
2016-08-23 23:36:18 +02:00
if ( _vm - > indexToOrdinal ( champIndex ) ! = cm . _candidateChampionOrdinal ) {
2016-09-09 07:32:32 +02:00
champion - > setAttributeFlag ( kDMAttributeIcon , true ) ;
champion - > setAttributeFlag ( kDMAttributeNameTitle , true ) ;
2016-08-23 07:54:16 +02:00
cm . drawChampionState ( champIndex ) ;
2016-06-18 16:23:44 +02:00
}
}
2016-06-17 14:29:05 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : commandProcessType80ClickInDungeonViewTouchFrontWall ( ) {
2016-09-13 22:07:02 +02:00
int16 mapX = _vm - > _dungeonMan - > _partyMapX + _vm - > _dirIntoStepCountEast [ _vm - > _dungeonMan - > _partyDir ] ;
int16 mapY = _vm - > _dungeonMan - > _partyMapY + _vm - > _dirIntoStepCountNorth [ _vm - > _dungeonMan - > _partyDir ] ;
2016-08-26 22:50:13 +02:00
2016-08-24 08:03:55 +02:00
if ( ( mapX > = 0 ) & & ( mapX < _vm - > _dungeonMan - > _currMapWidth )
& & ( mapY > = 0 ) & & ( mapY < _vm - > _dungeonMan - > _currMapHeight ) )
2016-09-11 09:46:35 +02:00
_vm - > _stopWaitingForPlayerInput = _vm - > _moveSens - > sensorIsTriggeredByClickOnWall ( mapX , mapY , _vm - > returnOppositeDir ( _vm - > _dungeonMan - > _partyDir ) ) ;
2016-06-23 17:32:55 +02:00
}
2016-06-23 23:54:37 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : commandProcessType80ClickInDungeonView ( int16 posX , int16 posY ) {
2016-08-18 21:18:08 +02:00
Box boxObjectPiles [ 4 ] = { // @ G0462_as_Graphic561_Box_ObjectPiles
/* { X1, X2, Y1, Y2 } */
Box ( 24 , 111 , 148 , 168 ) , /* Front left */
Box ( 112 , 199 , 148 , 168 ) , /* Front right */
Box ( 112 , 183 , 122 , 147 ) , /* Back right */
Box ( 40 , 111 , 122 , 147 ) /* Back left */
} ;
2016-09-11 21:22:22 +02:00
if ( _vm - > _dungeonMan - > _squareAheadElement = = kDMElementTypeDoorFront ) {
2016-09-09 07:12:36 +02:00
if ( _vm - > _championMan - > _leaderIndex = = kDMChampionNone )
2016-06-23 23:54:37 +02:00
return ;
2016-08-10 23:10:57 +02:00
2016-09-12 21:56:49 +02:00
int16 mapX = _vm - > _dungeonMan - > _partyMapX + _vm - > _dirIntoStepCountEast [ _vm - > _dungeonMan - > _partyDir ] ;
int16 mapY = _vm - > _dungeonMan - > _partyMapY + _vm - > _dirIntoStepCountNorth [ _vm - > _dungeonMan - > _partyDir ] ;
2016-08-10 23:10:57 +02:00
2016-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _leaderEmptyHanded ) {
2016-09-12 21:56:49 +02:00
Junk * junkPtr = ( Junk * ) _vm - > _dungeonMan - > getSquareFirstThingData ( mapX , mapY ) ;
2016-09-16 07:46:10 +02:00
if ( ( ( ( Door * ) junkPtr ) - > hasButton ( ) ) & & _vm - > _dungeonMan - > _dungeonViewClickableBoxes [ kDMViewCellDoorButtonOrWallOrn ] . isPointInside ( posX , posY - 33 ) ) {
2016-08-23 23:36:18 +02:00
_vm - > _stopWaitingForPlayerInput = true ;
2016-09-12 22:36:17 +02:00
_vm - > _sound - > requestPlay ( k01_soundSWITCH , _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY , kDMSoundModePlayIfPrioritized ) ;
2016-09-12 21:56:49 +02:00
_vm - > _moveSens - > addEvent ( k10_TMEventTypeDoor , mapX , mapY , kDMCellNorthWest , kDMSensorEffectToggle , _vm - > _gameTime + 1 ) ;
2016-07-07 00:46:51 +02:00
return ;
}
2016-08-25 08:12:23 +02:00
} else if ( isLeaderHandObjThrown ( posX , posY ) )
2016-08-10 23:10:57 +02:00
return ;
2016-06-23 23:54:37 +02:00
}
2016-08-10 23:10:57 +02:00
2016-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _leaderEmptyHanded ) {
2016-09-16 07:46:10 +02:00
for ( uint16 currViewCell = kDMViewCellFronLeft ; currViewCell < kDMViewCellDoorButtonOrWallOrn + 1 ; currViewCell + + ) {
2016-08-24 08:03:55 +02:00
if ( _vm - > _dungeonMan - > _dungeonViewClickableBoxes [ currViewCell ] . isPointInside ( posX , posY - 33 ) ) {
2016-09-16 07:46:10 +02:00
if ( currViewCell = = kDMViewCellDoorButtonOrWallOrn ) {
2016-08-24 08:03:55 +02:00
if ( ! _vm - > _dungeonMan - > _isFacingAlcove )
2016-08-25 08:12:23 +02:00
commandProcessType80ClickInDungeonViewTouchFrontWall ( ) ;
2016-08-10 23:10:57 +02:00
} else
2016-08-25 08:12:23 +02:00
processType80_clickInDungeonView_grabLeaderHandObject ( currViewCell ) ;
2016-08-10 23:10:57 +02:00
2016-06-23 23:54:37 +02:00
return ;
}
}
} else {
2016-08-23 07:54:16 +02:00
Thing thingHandObject = _vm - > _championMan - > _leaderHandObject ;
2016-08-24 08:03:55 +02:00
Junk * junkPtr = ( Junk * ) _vm - > _dungeonMan - > getThingData ( thingHandObject ) ;
2016-09-11 21:22:22 +02:00
if ( _vm - > _dungeonMan - > _squareAheadElement = = kDMElementTypeWall ) {
2016-09-16 07:46:10 +02:00
for ( uint16 currViewCell = kDMViewCellFronLeft ; currViewCell < kDMViewCellFrontRight + 1 ; currViewCell + + ) {
2016-08-18 21:18:08 +02:00
if ( boxObjectPiles [ currViewCell ] . isPointInside ( posX , posY ) ) {
2016-09-16 07:46:10 +02:00
clickInDungeonViewDropLeaderHandObject ( currViewCell ) ;
2016-06-23 23:54:37 +02:00
return ;
}
}
2016-09-16 07:46:10 +02:00
if ( _vm - > _dungeonMan - > _dungeonViewClickableBoxes [ kDMViewCellDoorButtonOrWallOrn ] . isPointInside ( posX , posY - 33 ) ) {
2016-08-24 08:03:55 +02:00
if ( _vm - > _dungeonMan - > _isFacingAlcove )
2016-09-16 07:46:10 +02:00
clickInDungeonViewDropLeaderHandObject ( kDMViewCellAlcove ) ;
2016-08-10 23:10:57 +02:00
else {
2016-08-24 08:03:55 +02:00
if ( _vm - > _dungeonMan - > _isFacingFountain ) {
2016-08-25 22:19:34 +02:00
uint16 iconIdx = _vm - > _objectMan - > getIconIndex ( thingHandObject ) ;
2016-08-24 08:03:55 +02:00
uint16 weight = _vm - > _dungeonMan - > getObjectWeight ( thingHandObject ) ;
2016-09-09 01:09:25 +02:00
if ( ( iconIdx > = kDMIconIndiceJunkWater ) & & ( iconIdx < = kDMIconIndiceJunkWaterSkin ) )
2016-08-10 23:10:57 +02:00
junkPtr - > setChargeCount ( 3 ) ; /* Full */
2016-09-09 01:09:25 +02:00
else if ( iconIdx = = kDMIconIndicePotionEmptyFlask )
2016-09-12 22:20:31 +02:00
( ( Potion * ) junkPtr ) - > setType ( kDMPotionTypeWaterFlask ) ;
2016-08-10 23:10:57 +02:00
else {
2016-08-25 08:12:23 +02:00
commandProcessType80ClickInDungeonViewTouchFrontWall ( ) ;
2016-08-10 23:10:57 +02:00
return ;
2016-06-23 23:54:37 +02:00
}
2016-08-23 07:54:16 +02:00
_vm - > _championMan - > drawChangedObjectIcons ( ) ;
2016-08-24 08:03:55 +02:00
_vm - > _championMan - > _champions [ _vm - > _championMan - > _leaderIndex ] . _load + = _vm - > _dungeonMan - > getObjectWeight ( thingHandObject ) - weight ;
2016-06-23 23:54:37 +02:00
}
2016-08-25 08:12:23 +02:00
commandProcessType80ClickInDungeonViewTouchFrontWall ( ) ;
2016-06-23 23:54:37 +02:00
}
}
} else {
2016-08-25 08:12:23 +02:00
if ( isLeaderHandObjThrown ( posX , posY ) )
2016-07-07 00:46:51 +02:00
return ;
2016-08-10 23:10:57 +02:00
2016-09-16 07:46:10 +02:00
for ( uint16 currViewCell = kDMViewCellFronLeft ; currViewCell < kDMViewCellBackLeft + 1 ; currViewCell + + ) {
2016-08-18 21:18:08 +02:00
if ( boxObjectPiles [ currViewCell ] . isPointInside ( posX , posY ) ) {
2016-09-16 07:46:10 +02:00
clickInDungeonViewDropLeaderHandObject ( currViewCell ) ;
2016-06-23 23:54:37 +02:00
return ;
}
}
}
}
}
2016-08-25 08:12:23 +02:00
void EventManager : : commandProcessCommands160To162ClickInResurrectReincarnatePanel ( CommandType commandType ) {
2016-06-24 01:43:43 +02:00
ChampionMan & champMan = * _vm - > _championMan ;
InventoryMan & invMan = * _vm - > _inventoryMan ;
DisplayMan & dispMan = * _vm - > _displayMan ;
DungeonMan & dunMan = * _vm - > _dungeonMan ;
2016-08-23 07:54:16 +02:00
uint16 championIndex = champMan . _partyChampionCount - 1 ;
Champion * champ = & champMan . _champions [ championIndex ] ;
2016-09-13 22:58:54 +02:00
if ( commandType = = kDMCommandClickInPanelCancel ) {
2016-09-09 07:12:36 +02:00
invMan . toggleInventory ( kDMChampionCloseInventory ) ;
champMan . _candidateChampionOrdinal = _vm - > indexToOrdinal ( kDMChampionNone ) ;
2016-08-23 07:54:16 +02:00
if ( champMan . _partyChampionCount = = 1 ) {
2016-09-09 07:12:36 +02:00
commandSetLeader ( kDMChampionNone ) ;
2016-06-24 01:43:43 +02:00
}
2016-08-23 07:54:16 +02:00
champMan . _partyChampionCount - - ;
2016-06-24 01:43:43 +02:00
Box box ;
2016-09-16 21:17:02 +02:00
box . _rect . top = 0 ;
box . _rect . bottom = 28 ;
2016-09-18 11:46:53 +02:00
box . _rect . left = championIndex * kDMChampionStatusBoxSpacing ;
2016-09-16 21:17:02 +02:00
box . _rect . right = box . _rect . left + 66 ;
2016-08-25 18:32:03 +02:00
dispMan . _useByteBoxCoordinates = false ;
2016-09-16 07:46:10 +02:00
dispMan . fillScreenBox ( box , kDMColorBlack ) ;
dispMan . fillScreenBox ( _vm - > _championMan - > _boxChampionIcons [ champMan . getChampionIconIndex ( champ - > _cell , dunMan . _partyDir ) * 2 ] , kDMColorBlack ) ;
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > drawEnabledMenus ( ) ;
2016-08-25 08:12:23 +02:00
showMouse ( ) ;
2016-06-24 01:43:43 +02:00
return ;
}
2016-09-09 07:12:36 +02:00
champMan . _candidateChampionOrdinal = _vm - > indexToOrdinal ( kDMChampionNone ) ;
2016-08-24 08:03:55 +02:00
int16 mapX = dunMan . _partyMapX + _vm - > _dirIntoStepCountEast [ dunMan . _partyDir ] ;
int16 mapY = dunMan . _partyMapY + _vm - > _dirIntoStepCountNorth [ dunMan . _partyDir ] ;
2016-06-24 01:43:43 +02:00
2016-09-10 11:47:36 +02:00
for ( uint16 slotIndex = kDMSlotReadyHand ; slotIndex < kDMSlotChest1 ; slotIndex + + ) {
2016-06-24 01:43:43 +02:00
Thing thing = champ - > getSlot ( ( ChampionSlot ) slotIndex ) ;
2016-06-30 13:29:42 +02:00
if ( thing ! = Thing : : _none ) {
2016-08-24 08:03:55 +02:00
_vm - > _dungeonMan - > unlinkThingFromList ( thing , Thing ( 0 ) , mapX , mapY ) ;
2016-06-24 01:43:43 +02:00
}
}
2016-08-24 08:03:55 +02:00
Thing thing = dunMan . getSquareFirstThing ( mapX , mapY ) ;
2016-06-24 01:43:43 +02:00
for ( ; ; ) { // infinite
2016-09-11 00:33:54 +02:00
if ( thing . getType ( ) = = kDMThingTypeSensor ) {
2016-08-24 08:03:55 +02:00
( ( Sensor * ) dunMan . getThingData ( thing ) ) - > setTypeDisabled ( ) ;
2016-06-24 01:43:43 +02:00
break ;
}
2016-08-24 08:03:55 +02:00
thing = dunMan . getNextThing ( thing ) ;
2016-06-24 01:43:43 +02:00
}
2016-09-13 22:58:54 +02:00
if ( commandType = = kDMCommandClickInPanelReincarnate ) {
2016-08-23 07:54:16 +02:00
champMan . renameChampion ( champ ) ;
2016-07-29 22:27:43 +02:00
if ( _vm - > _engineShouldQuit )
return ;
2016-06-24 01:43:43 +02:00
champ - > resetSkillsToZero ( ) ;
for ( uint16 i = 0 ; i < 12 ; i + + ) {
2016-07-26 13:13:38 +02:00
uint16 statIndex = _vm - > getRandomNumber ( 7 ) ;
2016-09-09 07:32:32 +02:00
champ - > getStatistic ( ( ChampionStatType ) statIndex , kDMStatCurrent ) + + ; // returns reference
champ - > getStatistic ( ( ChampionStatType ) statIndex , kDMStatMaximum ) + + ; // returns reference
2016-06-24 01:43:43 +02:00
}
}
2016-08-23 07:54:16 +02:00
if ( champMan . _partyChampionCount = = 1 ) {
2016-08-25 22:19:34 +02:00
_vm - > _projexpl - > _lastPartyMovementTime = _vm - > _gameTime ;
2016-09-09 07:12:36 +02:00
commandSetLeader ( kDMChampionFirst ) ;
_vm - > _menuMan - > setMagicCasterAndDrawSpellArea ( kDMChampionFirst ) ;
2016-08-11 07:44:56 +02:00
} else
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > drawSpellAreaControls ( champMan . _magicCasterChampionIndex ) ;
2016-06-24 01:43:43 +02:00
2016-08-25 22:38:03 +02:00
_vm - > _textMan - > printLineFeed ( ) ;
2016-08-18 21:18:08 +02:00
Color champColor = _vm - > _championMan - > _championColor [ championIndex ] ;
2016-08-25 22:38:03 +02:00
_vm - > _textMan - > printMessage ( champColor , champ - > _name ) ;
2016-08-15 20:25:40 +02:00
switch ( _vm - > getGameLanguage ( ) ) { // localized
default :
case Common : : EN_ANY :
2016-09-13 22:58:54 +02:00
_vm - > _textMan - > printMessage ( champColor , ( commandType = = kDMCommandClickInPanelResurrect ) ? " RESURRECTED. " : " REINCARNATED. " ) ;
2016-08-15 20:25:40 +02:00
break ;
2016-08-16 09:28:57 +02:00
case Common : : DE_DEU :
2016-09-13 22:58:54 +02:00
_vm - > _textMan - > printMessage ( champColor , ( commandType = = kDMCommandClickInPanelResurrect ) ? " VOM TODE ERWECKT. " : " REINKARNIERT. " ) ;
2016-08-15 20:25:40 +02:00
break ;
case Common : : FR_FRA :
2016-09-13 22:58:54 +02:00
_vm - > _textMan - > printMessage ( champColor , ( commandType = = kDMCommandClickInPanelResurrect ) ? " RESSUSCITE. " : " REINCARNE. " ) ;
2016-08-15 20:25:40 +02:00
break ;
}
2016-06-24 01:43:43 +02:00
2016-09-09 07:12:36 +02:00
invMan . toggleInventory ( kDMChampionCloseInventory ) ;
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > drawEnabledMenus ( ) ;
2016-09-09 07:12:36 +02:00
setMousePointerToNormal ( ( _vm - > _championMan - > _leaderIndex = = kDMChampionNone ) ? k0_pointerArrow : k1_pointerHand ) ;
2016-06-24 01:43:43 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : commandProcess81ClickInPanel ( int16 x , int16 y ) {
2016-06-24 02:08:26 +02:00
ChampionMan & champMan = * _vm - > _championMan ;
InventoryMan & invMan = * _vm - > _inventoryMan ;
CommandType commandType ;
2016-08-25 21:25:18 +02:00
switch ( invMan . _panelContent ) {
2016-09-18 11:46:53 +02:00
case kDMPanelContentChest :
2016-09-09 07:12:36 +02:00
if ( champMan . _leaderIndex = = kDMChampionNone ) // if no leader
2016-06-24 02:08:26 +02:00
return ;
2016-09-13 22:58:54 +02:00
commandType = getCommandTypeFromMouseInput ( _mouseInputPanelChest , Common : : Point ( x , y ) , kDMMouseButtonLeft ) ;
if ( commandType ! = kDMCommandNone )
_vm - > _championMan - > clickOnSlotBox ( commandType - kDMCommandClickOnSlotBoxChampion0StatusBoxReadyHand ) ;
2016-06-24 02:08:26 +02:00
break ;
2016-09-18 11:46:53 +02:00
case kDMPanelContentResurrectReincarnate :
2016-08-23 07:54:16 +02:00
if ( ! champMan . _leaderEmptyHanded )
2016-06-24 02:08:26 +02:00
break ;
2016-09-13 22:58:54 +02:00
commandType = getCommandTypeFromMouseInput ( _mouseInputPanelResurrectReincarnateCancel , Common : : Point ( x , y ) , kDMMouseButtonLeft ) ;
if ( commandType ! = kDMCommandNone )
2016-08-25 08:12:23 +02:00
commandProcessCommands160To162ClickInResurrectReincarnatePanel ( commandType ) ;
2016-06-24 02:08:26 +02:00
break ;
2016-06-27 22:41:18 +02:00
default :
break ;
2016-06-24 02:08:26 +02:00
}
}
2016-08-25 08:12:23 +02:00
void EventManager : : processType80_clickInDungeonView_grabLeaderHandObject ( uint16 viewCell ) {
2016-09-09 07:12:36 +02:00
if ( _vm - > _championMan - > _leaderIndex = = kDMChampionNone )
2016-07-07 00:46:51 +02:00
return ;
2016-08-11 07:44:56 +02:00
2016-08-24 08:03:55 +02:00
int16 mapX = _vm - > _dungeonMan - > _partyMapX ;
int16 mapY = _vm - > _dungeonMan - > _partyMapY ;
2016-09-16 07:46:10 +02:00
if ( viewCell > = kDMViewCellBackRight ) {
2016-08-24 08:03:55 +02:00
mapX + = _vm - > _dirIntoStepCountEast [ _vm - > _dungeonMan - > _partyDir ] , mapY + = _vm - > _dirIntoStepCountNorth [ _vm - > _dungeonMan - > _partyDir ] ;
2016-08-25 21:17:48 +02:00
Thing groupThing = _vm - > _groupMan - > groupGetThing ( mapX , mapY ) ;
2016-08-11 07:44:56 +02:00
if ( ( groupThing ! = Thing : : _endOfList ) & &
2016-08-25 22:09:30 +02:00
! _vm - > _moveSens - > isLevitating ( groupThing ) & &
2016-09-11 09:46:35 +02:00
_vm - > _groupMan - > getCreatureOrdinalInCell ( ( Group * ) _vm - > _dungeonMan - > getThingData ( groupThing ) , _vm - > normalizeModulo4 ( viewCell + _vm - > _dungeonMan - > _partyDir ) ) ) {
2016-07-07 00:46:51 +02:00
return ; /* It is not possible to grab an object on floor if there is a non levitating creature on its cell */
}
}
2016-08-11 07:44:56 +02:00
2016-08-24 08:03:55 +02:00
Thing topPileThing = _vm - > _dungeonMan - > _pileTopObject [ viewCell ] ;
2016-09-09 01:09:25 +02:00
if ( _vm - > _objectMan - > getIconIndex ( topPileThing ) ! = kDMIconIndiceNone ) {
2016-09-11 21:22:22 +02:00
_vm - > _moveSens - > getMoveResult ( topPileThing , mapX , mapY , kDMMapXNotOnASquare , 0 ) ;
2016-08-23 07:54:16 +02:00
_vm - > _championMan - > putObjectInLeaderHand ( topPileThing , true ) ;
2016-07-07 00:46:51 +02:00
}
2016-08-11 07:44:56 +02:00
2016-08-23 23:36:18 +02:00
_vm - > _stopWaitingForPlayerInput = true ;
2016-07-07 00:46:51 +02:00
}
2016-09-16 07:46:10 +02:00
void EventManager : : clickInDungeonViewDropLeaderHandObject ( uint16 viewCell ) {
2016-09-09 07:12:36 +02:00
if ( _vm - > _championMan - > _leaderIndex = = kDMChampionNone )
2016-07-07 00:46:51 +02:00
return ;
2016-08-11 07:44:56 +02:00
2016-08-24 08:03:55 +02:00
int16 mapX = _vm - > _dungeonMan - > _partyMapX ;
int16 mapY = _vm - > _dungeonMan - > _partyMapY ;
2016-09-16 07:46:10 +02:00
bool droppingIntoAnAlcove = ( viewCell = = kDMViewCellAlcove ) ;
2016-08-11 07:44:56 +02:00
if ( droppingIntoAnAlcove )
2016-09-16 07:46:10 +02:00
viewCell = kDMViewCellBackRight ;
2016-08-11 07:44:56 +02:00
2016-09-16 07:46:10 +02:00
if ( viewCell > kDMViewCellFrontRight )
2016-08-24 08:03:55 +02:00
mapX + = _vm - > _dirIntoStepCountEast [ _vm - > _dungeonMan - > _partyDir ] , mapY + = _vm - > _dirIntoStepCountNorth [ _vm - > _dungeonMan - > _partyDir ] ;
2016-08-11 07:44:56 +02:00
2016-09-11 09:46:35 +02:00
uint16 currCell = _vm - > normalizeModulo4 ( _vm - > _dungeonMan - > _partyDir + viewCell ) ;
2016-08-23 07:54:16 +02:00
Thing removedThing = _vm - > _championMan - > getObjectRemovedFromLeaderHand ( ) ;
2016-09-11 21:22:22 +02:00
_vm - > _moveSens - > getMoveResult ( _vm - > thingWithNewCell ( removedThing , currCell ) , kDMMapXNotOnASquare , 0 , mapX , mapY ) ;
2016-09-09 01:09:25 +02:00
if ( droppingIntoAnAlcove & & _vm - > _dungeonMan - > _isFacingViAltar & & ( _vm - > _objectMan - > getIconIndex ( removedThing ) = = kDMIconIndiceJunkChampionBones ) ) {
2016-08-24 08:03:55 +02:00
Junk * removedJunk = ( Junk * ) _vm - > _dungeonMan - > getThingData ( removedThing ) ;
2016-08-11 07:44:56 +02:00
TimelineEvent newEvent ;
2016-09-11 09:46:35 +02:00
_vm - > setMapAndTime ( newEvent . _mapTime , _vm - > _dungeonMan - > _partyMapIndex , _vm - > _gameTime + 1 ) ;
2016-08-11 07:44:56 +02:00
newEvent . _type = k13_TMEventTypeViAltarRebirth ;
newEvent . _priority = removedJunk - > getChargeCount ( ) ;
2016-09-10 21:50:57 +02:00
newEvent . _Bu . _location . _mapX = mapX ;
newEvent . _Bu . _location . _mapY = mapY ;
2016-09-10 21:54:22 +02:00
newEvent . _Cu . A . _cell = currCell ;
2016-09-12 00:03:48 +02:00
newEvent . _Cu . A . _effect = kDMSensorEffectToggle ;
2016-08-25 22:38:03 +02:00
_vm - > _timeline - > addEventGetEventIndex ( & newEvent ) ;
2016-07-07 00:46:51 +02:00
}
2016-08-23 23:36:18 +02:00
_vm - > _stopWaitingForPlayerInput = true ;
2016-07-07 00:46:51 +02:00
}
2016-08-25 08:12:23 +02:00
bool EventManager : : hasPendingClick ( Common : : Point & point , MouseButton button ) {
if ( _pendingClickButton & & button = = _pendingClickButton )
point = _pendingClickPos ;
2016-06-27 22:41:18 +02:00
2016-08-25 08:12:23 +02:00
return _pendingClickPresent ;
2016-06-27 22:41:18 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : drawSleepScreen ( ) {
2016-09-16 07:46:10 +02:00
_vm - > _displayMan - > fillBitmap ( _vm - > _displayMan - > _bitmapViewport , kDMColorBlack , 112 , 136 ) ;
2016-08-15 20:25:40 +02:00
switch ( _vm - > getGameLanguage ( ) ) { // localized
default :
case Common : : EN_ANY :
2016-09-16 07:46:10 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 93 , 69 , kDMColorCyan , kDMColorBlack , " WAKE UP " , k136_heightViewport ) ;
2016-08-15 20:25:40 +02:00
break ;
2016-08-16 09:28:57 +02:00
case Common : : DE_DEU :
2016-09-16 07:46:10 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 96 , 69 , kDMColorCyan , kDMColorBlack , " WECKEN " , k136_heightViewport ) ;
2016-08-15 20:25:40 +02:00
break ;
case Common : : FR_FRA :
2016-09-16 07:46:10 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 72 , 69 , kDMColorCyan , kDMColorBlack , " REVEILLEZ-VOUS " , k136_heightViewport ) ;
2016-08-15 20:25:40 +02:00
break ;
}
2016-07-07 00:46:51 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : discardAllInput ( ) {
2016-07-07 00:46:51 +02:00
Common : : Event event ;
2016-09-03 15:52:59 +02:00
while ( g_system - > getEventManager ( ) - > pollEvent ( event ) & & ! _vm - > _engineShouldQuit ) {
2016-07-29 22:27:43 +02:00
if ( event . type = = Common : : EVENT_QUIT )
_vm - > _engineShouldQuit = true ;
}
2016-07-07 00:46:51 +02:00
_commandQueue . clear ( ) ;
}
2016-08-25 08:12:23 +02:00
void EventManager : : commandTakeStairs ( bool stairsGoDown ) {
2016-09-11 21:22:22 +02:00
_vm - > _moveSens - > getMoveResult ( Thing : : _party , _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY , kDMMapXNotOnASquare , 0 ) ;
2016-08-24 08:03:55 +02:00
_vm - > _newPartyMapIndex = _vm - > _dungeonMan - > getLocationAfterLevelChange ( _vm - > _dungeonMan - > _partyMapIndex , stairsGoDown ? - 1 : 1 , & _vm - > _dungeonMan - > _partyMapX , & _vm - > _dungeonMan - > _partyMapY ) ;
_vm - > _dungeonMan - > setCurrentMap ( _vm - > _newPartyMapIndex ) ;
_vm - > _championMan - > setPartyDirection ( _vm - > _dungeonMan - > getStairsExitDirection ( _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY ) ) ;
_vm - > _dungeonMan - > setCurrentMap ( _vm - > _dungeonMan - > _partyMapIndex ) ;
2016-08-26 22:50:30 +02:00
}
2016-07-12 12:05:20 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : commandProcessTypes12to27_clickInChampionStatusBox ( uint16 champIndex , int16 posX , int16 posY ) {
2016-08-25 21:25:18 +02:00
if ( _vm - > indexToOrdinal ( champIndex ) = = _vm - > _inventoryMan - > _inventoryChampionOrdinal ) {
2016-08-25 08:12:23 +02:00
commandSetLeader ( ( ChampionIndex ) champIndex ) ;
2016-07-12 12:05:20 +02:00
} else {
2016-09-13 22:58:54 +02:00
uint16 commandType = getCommandTypeFromMouseInput ( _mouseInputChampionNamesHands , Common : : Point ( posX , posY ) , kDMMouseButtonLeft ) ;
if ( ( commandType > = kDMCommandSetLeaderChampion0 ) & & ( commandType < = kDMCommandSetLeaderChampion3 ) )
commandSetLeader ( ( ChampionIndex ) ( commandType - kDMCommandSetLeaderChampion0 ) ) ;
else if ( ( commandType > = kDMCommandClickOnSlotBoxChampion0StatusBoxReadyHand ) & & ( commandType < = kDMCommandClickOnSlotBoxChampion3StatusBoxActionHand ) )
_vm - > _championMan - > clickOnSlotBox ( commandType - kDMCommandClickOnSlotBoxChampion0StatusBoxReadyHand ) ;
2016-07-12 12:05:20 +02:00
}
}
2016-07-12 12:26:22 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : mouseProcessCommands125To128_clickOnChampionIcon ( uint16 champIconIndex ) {
2016-08-11 23:21:52 +02:00
static Box championIconShadowBox = Box ( 2 , 20 , 2 , 15 ) ;
static Box championIconBox = Box ( 0 , 18 , 0 , 13 ) ;
static byte mousePointerIconShadowBox [ 16 ] = { 0 , 120 , 120 , 120 , 120 , 120 , 120 , 120 , 120 , 120 , 120 , 120 , 0 , 120 , 120 , 120 } ;
2016-07-12 12:26:22 +02:00
2016-08-25 08:12:23 +02:00
_preventBuildPointerScreenArea = true ;
if ( ! _useChampionIconOrdinalAsMousePointerBitmap ) {
2016-09-11 09:46:35 +02:00
if ( _vm - > _championMan - > getIndexInCell ( _vm - > normalizeModulo4 ( champIconIndex + _vm - > _dungeonMan - > _partyDir ) ) = = kDMChampionNone ) {
2016-08-25 08:12:23 +02:00
_preventBuildPointerScreenArea = false ;
2016-07-12 12:26:22 +02:00
return ;
}
2016-08-25 08:12:23 +02:00
_mousePointerBitmapUpdated = true ;
_useChampionIconOrdinalAsMousePointerBitmap = true ;
2016-08-25 18:32:03 +02:00
_vm - > _displayMan - > _useByteBoxCoordinates = false ;
2016-08-25 08:12:23 +02:00
byte * tmpBitmap = _mousePointerTempBuffer ;
2016-08-11 23:21:52 +02:00
memset ( tmpBitmap , 0 , 32 * 18 ) ;
2016-08-18 21:18:08 +02:00
Box * curChampionIconBox = & _vm - > _championMan - > _boxChampionIcons [ champIconIndex ] ;
2016-08-11 23:21:52 +02:00
2016-09-16 21:17:02 +02:00
_vm - > _displayMan - > blitToBitmap ( _vm - > _displayMan - > _bitmapScreen , tmpBitmap , championIconShadowBox , curChampionIconBox - > _rect . left , curChampionIconBox - > _rect . top , k160_byteWidthScreen , k16_byteWidth , kDMColorBlack , 200 , 18 ) ;
2016-08-25 18:32:03 +02:00
_vm - > _displayMan - > blitToBitmapShrinkWithPalChange ( tmpBitmap , _mousePointerOriginalColorsChampionIcon , 32 , 18 , 32 , 18 , mousePointerIconShadowBox ) ;
2016-09-16 21:17:02 +02:00
_vm - > _displayMan - > blitToBitmap ( _vm - > _displayMan - > _bitmapScreen , _mousePointerOriginalColorsChampionIcon , championIconBox , curChampionIconBox - > _rect . left , curChampionIconBox - > _rect . top , k160_byteWidthScreen , k16_byteWidth , kDMColorBlack , 200 , 18 ) ;
2016-09-16 07:46:10 +02:00
_vm - > _displayMan - > fillScreenBox ( * curChampionIconBox , kDMColorBlack ) ;
2016-08-25 08:12:23 +02:00
_useChampionIconOrdinalAsMousePointerBitmap = _vm - > indexToOrdinal ( champIconIndex ) ;
2016-07-12 12:26:22 +02:00
} else {
2016-08-25 08:12:23 +02:00
_mousePointerBitmapUpdated = true ;
uint16 championIconIndex = _vm - > ordinalToIndex ( _useChampionIconOrdinalAsMousePointerBitmap ) ;
2016-09-09 07:12:36 +02:00
_useChampionIconOrdinalAsMousePointerBitmap = _vm - > indexToOrdinal ( kDMChampionNone ) ;
2016-09-11 09:46:35 +02:00
int16 championCellIndex = _vm - > _championMan - > getIndexInCell ( _vm - > normalizeModulo4 ( championIconIndex + _vm - > _dungeonMan - > _partyDir ) ) ;
2016-08-11 23:21:52 +02:00
if ( championIconIndex = = champIconIndex ) {
2016-09-09 07:32:32 +02:00
setFlag ( _vm - > _championMan - > _champions [ championCellIndex ] . _attributes , kDMAttributeIcon ) ;
2016-08-23 07:54:16 +02:00
_vm - > _championMan - > drawChampionState ( ( ChampionIndex ) championCellIndex ) ;
2016-07-12 12:26:22 +02:00
} else {
2016-09-11 09:46:35 +02:00
int16 championIndex = _vm - > _championMan - > getIndexInCell ( _vm - > normalizeModulo4 ( champIconIndex + _vm - > _dungeonMan - > _partyDir ) ) ;
2016-08-11 23:21:52 +02:00
if ( championIndex > = 0 ) {
2016-09-11 09:46:35 +02:00
_vm - > _championMan - > _champions [ championIndex ] . _cell = ( ViewCell ) _vm - > normalizeModulo4 ( championIconIndex + _vm - > _dungeonMan - > _partyDir ) ;
2016-09-09 07:32:32 +02:00
setFlag ( _vm - > _championMan - > _champions [ championIndex ] . _attributes , kDMAttributeIcon ) ;
2016-08-23 07:54:16 +02:00
_vm - > _championMan - > drawChampionState ( ( ChampionIndex ) championIndex ) ;
2016-08-11 23:21:52 +02:00
} else
2016-09-16 07:46:10 +02:00
_vm - > _displayMan - > fillScreenBox ( _vm - > _championMan - > _boxChampionIcons [ championIconIndex ] , kDMColorBlack ) ;
2016-08-11 23:21:52 +02:00
2016-09-11 09:46:35 +02:00
_vm - > _championMan - > _champions [ championCellIndex ] . _cell = ( ViewCell ) _vm - > normalizeModulo4 ( champIconIndex + _vm - > _dungeonMan - > _partyDir ) ;
2016-09-09 07:32:32 +02:00
setFlag ( _vm - > _championMan - > _champions [ championCellIndex ] . _attributes , kDMAttributeIcon ) ;
2016-08-23 07:54:16 +02:00
_vm - > _championMan - > drawChampionState ( ( ChampionIndex ) championCellIndex ) ;
2016-07-12 12:26:22 +02:00
}
}
2016-08-25 08:12:23 +02:00
_preventBuildPointerScreenArea = false ;
buildpointerScreenArea ( _mousePos . x , _mousePos . y ) ;
2016-07-12 12:26:22 +02:00
}
2016-07-12 14:38:52 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : commandProcessType100_clickInSpellArea ( uint16 posX , uint16 posY ) {
2016-09-09 07:12:36 +02:00
ChampionIndex championIndex = kDMChampionNone ;
2016-07-12 14:38:52 +02:00
if ( posY < = 48 ) {
2016-08-23 07:54:16 +02:00
switch ( _vm - > _championMan - > _magicCasterChampionIndex ) {
2016-07-12 14:38:52 +02:00
case 0 :
2016-08-11 23:21:52 +02:00
if ( ( posX > = 280 ) & & ( posX < = 291 ) )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionSecond ;
2016-08-11 23:21:52 +02:00
else if ( ( posX > = 294 ) & & ( posX < = 305 ) )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionThird ;
2016-08-11 23:21:52 +02:00
else if ( posX > = 308 )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionFourth ;
2016-08-11 23:21:52 +02:00
2016-07-12 14:38:52 +02:00
break ;
case 1 :
2016-08-11 23:21:52 +02:00
if ( ( posX > = 233 ) & & ( posX < = 244 ) )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionFirst ;
2016-08-11 23:21:52 +02:00
else if ( ( posX > = 294 ) & & ( posX < = 305 ) )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionThird ;
2016-08-11 23:21:52 +02:00
else if ( posX > = 308 )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionFourth ;
2016-08-11 23:21:52 +02:00
2016-07-12 14:38:52 +02:00
break ;
case 2 :
2016-08-11 23:21:52 +02:00
if ( ( posX > = 233 ) & & ( posX < = 244 ) )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionFirst ;
2016-08-11 23:21:52 +02:00
else if ( ( posX > = 247 ) & & ( posX < = 258 ) )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionSecond ;
2016-08-11 23:21:52 +02:00
else if ( posX > = 308 )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionFourth ;
2016-08-11 23:21:52 +02:00
2016-07-12 14:38:52 +02:00
break ;
case 3 :
2016-08-11 23:21:52 +02:00
if ( ( posX > = 247 ) & & ( posX < = 258 ) )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionSecond ;
2016-08-11 23:21:52 +02:00
else if ( ( posX > = 261 ) & & ( posX < = 272 ) )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionThird ;
2016-08-11 23:21:52 +02:00
else if ( posX < = 244 )
2016-09-09 07:12:36 +02:00
championIndex = kDMChampionFirst ;
2016-08-21 01:16:00 +02:00
break ;
default :
2016-08-11 23:21:52 +02:00
break ;
2016-07-12 14:38:52 +02:00
}
2016-08-11 23:21:52 +02:00
2016-09-09 07:12:36 +02:00
if ( ( championIndex ! = kDMChampionNone ) & & ( championIndex < _vm - > _championMan - > _partyChampionCount ) )
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > setMagicCasterAndDrawSpellArea ( championIndex ) ;
2016-08-11 23:21:52 +02:00
2016-07-12 14:38:52 +02:00
return ;
}
2016-08-11 23:21:52 +02:00
2016-09-13 22:58:54 +02:00
CommandType newCommand = getCommandTypeFromMouseInput ( _mouseInputSpellArea , Common : : Point ( posX , posY ) , kDMMouseButtonLeft ) ;
if ( newCommand ! = kDMCommandNone )
2016-08-25 08:12:23 +02:00
commandProcessTypes101To108_clickInSpellSymbolsArea ( newCommand ) ;
2016-07-12 14:38:52 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : commandProcessTypes101To108_clickInSpellSymbolsArea ( CommandType cmdType ) {
2016-08-11 23:21:52 +02:00
static Box spellSymbolsAndDelete [ 7 ] = {
2016-07-12 14:38:52 +02:00
/* { X1, X2, Y1, Y2 } */
Box ( 235 , 247 , 51 , 61 ) , /* Symbol 1 */
Box ( 249 , 261 , 51 , 61 ) , /* Symbol 2 */
Box ( 263 , 275 , 51 , 61 ) , /* Symbol 3 */
Box ( 277 , 289 , 51 , 61 ) , /* Symbol 4 */
Box ( 291 , 303 , 51 , 61 ) , /* Symbol 5 */
Box ( 305 , 317 , 51 , 61 ) , /* Symbol 6 */
2016-08-28 00:33:32 +02:00
Box ( 305 , 318 , 63 , 73 ) /* Delete */
} ;
2016-07-12 14:38:52 +02:00
2016-09-13 22:58:54 +02:00
if ( cmdType = = kDMCommandClickInSpeallAreaCastSpell ) {
2016-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _champions [ _vm - > _championMan - > _magicCasterChampionIndex ] . _symbols [ 0 ] = = ' \0 ' )
2016-07-12 14:38:52 +02:00
return ;
2016-08-11 23:21:52 +02:00
2016-08-25 08:12:23 +02:00
commandHighlightBoxEnable ( 234 , 303 , 63 , 73 ) ;
2016-08-25 21:59:02 +02:00
_vm - > _stopWaitingForPlayerInput = _vm - > _menuMan - > getClickOnSpellCastResult ( ) ;
2016-07-12 14:38:52 +02:00
return ;
}
2016-08-11 23:21:52 +02:00
2016-09-13 22:58:54 +02:00
uint16 symbolIndex = cmdType - kDMCommandClickInSpellAreaSymbol1 ;
2016-08-11 23:21:52 +02:00
Box * highlightBox = & spellSymbolsAndDelete [ symbolIndex ] ;
2016-09-16 21:17:02 +02:00
commandHighlightBoxEnable ( highlightBox - > _rect . left , highlightBox - > _rect . right , highlightBox - > _rect . top , highlightBox - > _rect . bottom ) ;
2016-08-23 23:36:18 +02:00
_vm - > delay ( 1 ) ;
2016-08-25 08:12:23 +02:00
highlightBoxDisable ( ) ;
2016-08-11 23:21:52 +02:00
if ( symbolIndex < 6 )
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > addChampionSymbol ( symbolIndex ) ;
2016-08-11 23:21:52 +02:00
else
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > deleteChampionSymbol ( ) ;
2016-07-12 14:38:52 +02:00
}
2016-07-13 15:01:00 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : commandProcessType111To115_ClickInActionArea ( int16 posX , int16 posY ) {
2016-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _actingChampionOrdinal ) {
2016-09-13 22:58:54 +02:00
uint16 mouseCommand = getCommandTypeFromMouseInput ( _mouseInputActionAreaNames , Common : : Point ( posX , posY ) , kDMMouseButtonLeft ) ;
if ( mouseCommand ! = kDMCommandNone ) {
if ( mouseCommand = = kDMCommandClickInActionAreaPass ) {
2016-08-25 08:12:23 +02:00
commandHighlightBoxEnable ( 285 , 319 , 77 , 83 ) ;
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > didClickTriggerAction ( - 1 ) ;
2016-09-13 22:58:54 +02:00
} else if ( ( mouseCommand - kDMCommandClickInActionAreaPass ) < = _vm - > _menuMan - > _actionCount ) {
if ( mouseCommand = = kDMCommandClickInActionAreaAction0 )
2016-08-25 08:12:23 +02:00
commandHighlightBoxEnable ( 234 , 318 , 86 , 96 ) ;
2016-09-13 22:58:54 +02:00
else if ( mouseCommand = = kDMCommandClickInActionAreaAction1 )
2016-08-25 08:12:23 +02:00
commandHighlightBoxEnable ( 234 , 318 , 98 , 108 ) ;
2016-08-11 23:21:52 +02:00
else
2016-08-25 08:12:23 +02:00
commandHighlightBoxEnable ( 234 , 318 , 110 , 120 ) ;
2016-08-11 23:21:52 +02:00
2016-09-13 22:58:54 +02:00
_vm - > _stopWaitingForPlayerInput = _vm - > _menuMan - > didClickTriggerAction ( mouseCommand - kDMCommandClickInActionAreaAction0 ) ;
2016-07-13 15:01:00 +02:00
}
}
2016-08-25 21:59:02 +02:00
} else if ( _vm - > _menuMan - > _actionAreaContainsIcons ) {
2016-09-13 22:58:54 +02:00
uint16 mouseCommand = getCommandTypeFromMouseInput ( _mouseInputActionAreaIcons , Common : : Point ( posX , posY ) , kDMMouseButtonLeft ) ;
if ( mouseCommand ! = kDMCommandNone ) {
mouseCommand - = kDMCommandClickInActionAreaChampion0Action ;
2016-08-23 07:54:16 +02:00
if ( mouseCommand < _vm - > _championMan - > _partyChampionCount )
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > processCommands116To119_setActingChampion ( mouseCommand ) ;
2016-07-13 15:01:00 +02:00
}
}
}
2016-07-29 15:13:38 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : resetPressingEyeOrMouth ( ) {
2016-08-23 23:36:18 +02:00
if ( _vm - > _pressingEye ) {
2016-08-25 08:12:23 +02:00
_ignoreMouseMovements = false ;
2016-08-23 23:36:18 +02:00
_vm - > _stopPressingEye = true ;
2016-07-29 15:13:38 +02:00
}
2016-08-23 23:36:18 +02:00
if ( _vm - > _pressingMouth ) {
2016-08-25 08:12:23 +02:00
_ignoreMouseMovements = false ;
2016-08-23 23:36:18 +02:00
_vm - > _stopPressingMouth = true ;
2016-07-29 15:13:38 +02:00
}
}
2016-07-29 22:27:43 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : waitForMouseOrKeyActivity ( ) {
discardAllInput ( ) ;
2016-07-29 22:27:43 +02:00
Common : : Event event ;
while ( true ) {
2016-09-03 15:52:59 +02:00
if ( g_system - > getEventManager ( ) - > pollEvent ( event ) ) {
2016-07-29 22:27:43 +02:00
switch ( event . type ) {
case Common : : EVENT_QUIT :
_vm - > _engineShouldQuit = true ;
case Common : : EVENT_KEYDOWN : // Intentional fall through
case Common : : EVENT_LBUTTONDOWN :
case Common : : EVENT_RBUTTONDOWN :
return ;
2016-08-21 01:16:00 +02:00
default :
break ;
2016-07-29 22:27:43 +02:00
}
}
2016-08-23 23:36:18 +02:00
_vm - > delay ( 1 ) ;
2016-07-29 22:27:43 +02:00
_vm - > _displayMan - > updateScreen ( ) ;
}
}
2016-08-19 19:00:58 +02:00
2016-08-25 08:12:23 +02:00
void EventManager : : commandHighlightBoxEnable ( int16 x1 , int16 x2 , int16 y1 , int16 y2 ) {
2016-08-19 19:00:58 +02:00
_highlightScreenBox = Box ( x1 , x2 , y1 , y2 ) ;
2016-08-25 08:12:23 +02:00
highlightScreenBox ( x1 , x2 , y1 , y2 ) ;
_highlightBoxEnabled = true ;
2016-08-19 19:00:58 +02:00
}
2016-08-25 08:12:23 +02:00
void EventManager : : highlightBoxDisable ( ) {
if ( _highlightBoxEnabled = = true ) {
2016-09-16 21:17:02 +02:00
highlightScreenBox ( _highlightScreenBox . _rect . left , _highlightScreenBox . _rect . right , _highlightScreenBox . _rect . top , _highlightScreenBox . _rect . bottom ) ;
2016-08-25 08:12:23 +02:00
_highlightBoxEnabled = false ;
2016-08-19 19:00:58 +02:00
}
}
2016-06-27 23:00:33 +02:00
} // end of namespace DM