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-06-15 22:42:08 +02:00
# include "eventman.h"
# include "dungeonman.h"
2016-06-23 17:32:55 +02:00
# include "movesens.h"
2016-06-23 23:54:37 +02:00
# include "objectman.h"
2016-06-24 01:43:43 +02:00
# include "inventory.h"
2016-06-25 17:03:02 +02:00
# include "menus.h"
2016-07-07 00:46:51 +02:00
# include "timeline.h"
# include "projexpl.h"
# include "text.h"
# include "group.h"
2016-08-09 08:33:31 +02:00
# include "dialog.h"
2016-08-16 19:15:35 +02:00
# include "sounds.h"
2016-08-22 19:27:10 +02:00
# include <mortevielle/saveload.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 } */
KeyboardInput ( k7_CommandToggleInventoryChampion_0 , Common : : KEYCODE_F1 , 0 ) , /* F1 (<CSI>1~) Atari ST: Code = 0x3B00 */
KeyboardInput ( k8_CommandToggleInventoryChampion_1 , Common : : KEYCODE_F2 , 0 ) , /* F2 (<CSI>2~) Atari ST: Code = 0x3C00 */
KeyboardInput ( k9_CommandToggleInventoryChampion_2 , Common : : KEYCODE_F3 , 0 ) , /* F3 (<CSI>3~) Atari ST: Code = 0x3D00 */
KeyboardInput ( k10_CommandToggleInventoryChampion_3 , Common : : KEYCODE_F4 , 0 ) , /* F4 (<CSI>4~) Atari ST: Code = 0x3E00 */
KeyboardInput ( k140_CommandSaveGame , Common : : KEYCODE_s , Common : : KBD_CTRL ) , /* CTRL-S Atari ST: Code = 0x0013 */
KeyboardInput ( k147_CommandFreezeGame , Common : : KEYCODE_ESCAPE , 0 ) , /* Esc (0x1B) Atari ST: Code = 0x001B */
KeyboardInput ( k0_CommandNone , Common : : KEYCODE_INVALID , 0 )
} ;
KeyboardInput secondaryKeyboardInputMovement [ 19 ] = { // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement
/* { Command, Code } */
KeyboardInput ( k1_CommandTurnLeft , Common : : KEYCODE_KP4 , 0 ) , /* Numeric pad 4 Atari ST: Code = 0x5200 */
KeyboardInput ( k3_CommandMoveForward , Common : : KEYCODE_KP5 , 0 ) , /* Numeric pad 5 Atari ST: Code = 0x4800 */
KeyboardInput ( k2_CommandTurnRight , Common : : KEYCODE_KP6 , 0 ) , /* Numeric pad 6 Atari ST: Code = 0x4700 */
KeyboardInput ( k6_CommandMoveLeft , Common : : KEYCODE_KP1 , 0 ) , /* Numeric pad 1 Atari ST: Code = 0x4B00 */
KeyboardInput ( k5_CommandMoveBackward , Common : : KEYCODE_KP2 , 0 ) , /* Numeric pad 2 Atari ST: Code = 0x5000 */
KeyboardInput ( k4_CommandMoveRight , Common : : KEYCODE_KP3 , 0 ) , /* Numeric pad 3 Atari ST: Code = 0x4D00. Remaining entries below not present */
KeyboardInput ( k3_CommandMoveForward , Common : : KEYCODE_w , 0 ) , /* Up Arrow (<CSI>A) */ /*Differs for testing convenience*/
KeyboardInput ( k3_CommandMoveForward , Common : : KEYCODE_w , Common : : KBD_SHIFT ) , /* Shift Up Arrow (<CSI>T) */ /*Differs for testing convenience*/
KeyboardInput ( k6_CommandMoveLeft , Common : : KEYCODE_a , 0 ) , /* Backward Arrow (<CSI>D) */ /*Differs for testing convenience*/
KeyboardInput ( k6_CommandMoveLeft , Common : : KEYCODE_a , Common : : KBD_SHIFT ) , /* Shift Forward Arrow (<CSI> A) */ /*Differs for testing convenience*/
KeyboardInput ( k4_CommandMoveRight , Common : : KEYCODE_d , 0 ) , /* Forward Arrow (<CSI>C) */ /*Differs for testing convenience*/
KeyboardInput ( k4_CommandMoveRight , Common : : KEYCODE_d , Common : : KBD_SHIFT ) , /* Shift Backward Arrow (<CSI> @) */ /*Differs for testing convenience*/
KeyboardInput ( k5_CommandMoveBackward , Common : : KEYCODE_s , 0 ) , /* Down arrow (<CSI>B) */ /*Differs for testing convenience*/
KeyboardInput ( k5_CommandMoveBackward , Common : : KEYCODE_s , Common : : KBD_SHIFT ) , /* Shift Down arrow (<CSI>S) */ /*Differs for testing convenience*/
KeyboardInput ( k1_CommandTurnLeft , Common : : KEYCODE_q , 0 ) , /* Del (0x7F) */ /*Differs for testing convenience*/
KeyboardInput ( k1_CommandTurnLeft , Common : : KEYCODE_q , Common : : KBD_SHIFT ) , /* Shift Del (0x7F) */ /*Differs for testing convenience*/
KeyboardInput ( k2_CommandTurnRight , Common : : KEYCODE_e , 0 ) , /* Help (<CSI>?~) */ /*Differs for testing convenience*/
KeyboardInput ( k2_CommandTurnRight , Common : : KEYCODE_e , Common : : KBD_SHIFT ) , /* Shift Help (<CSI>?~) */ /*Differs for testing convenience*/
KeyboardInput ( k0_CommandNone , Common : : KEYCODE_INVALID , 0 )
} ;
KeyboardInput primaryKeyboardInputPartySleeping [ 3 ] = { // @ G0460_as_Graphic561_PrimaryKeyboardInput_PartySleeping
/* { Command, Code } */
KeyboardInput ( k146_CommandWakeUp , Common : : KEYCODE_RETURN , 0 ) , /* Return */
KeyboardInput ( k147_CommandFreezeGame , Common : : KEYCODE_ESCAPE , 0 ) , /* Esc */
KeyboardInput ( k0_CommandNone , Common : : KEYCODE_INVALID , 0 )
} ;
KeyboardInput primaryKeyboardInputFrozenGame [ 2 ] = { // @ G0461_as_Graphic561_PrimaryKeyboardInput_FrozenGame
/* { Command, Code } */
KeyboardInput ( k148_CommandUnfreezeGame , Common : : KEYCODE_ESCAPE , 0 ) , /* Esc */
KeyboardInput ( k0_CommandNone , Common : : KEYCODE_INVALID , 0 )
} ;
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 } */
MouseInput ( k200_CommandEntranceEnterDungeon , 244 , 298 , 45 , 58 , k1_LeftMouseButton ) ,
// Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo
MouseInput ( k201_CommandEntranceResume , 244 , 298 , 76 , 93 , k1_LeftMouseButton ) ,
MouseInput ( k202_CommandEntranceDrawCredits , 248 , 293 , 187 , 199 , k1_LeftMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
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 } */
MouseInput ( k215_CommandRestartGame , 103 , 217 , 145 , 159 , k1_LeftMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
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 } */
MouseInput ( k12_CommandClickInChampion_0_StatusBox , 0 , 42 , 0 , 28 , k1_LeftMouseButton ) ,
MouseInput ( k13_CommandClickInChampion_1_StatusBox , 69 , 111 , 0 , 28 , k1_LeftMouseButton ) ,
MouseInput ( k14_CommandClickInChampion_2_StatusBox , 138 , 180 , 0 , 28 , k1_LeftMouseButton ) ,
MouseInput ( k15_CommandClickInChampion_3_StatusBox , 207 , 249 , 0 , 28 , k1_LeftMouseButton ) ,
MouseInput ( k125_CommandClickOnChamptionIcon_Top_Left , 274 , 299 , 0 , 13 , k1_LeftMouseButton ) ,
MouseInput ( k126_CommandClickOnChamptionIcon_Top_Right , 301 , 319 , 0 , 13 , k1_LeftMouseButton ) ,
MouseInput ( k127_CommandClickOnChamptionIcon_Lower_Right , 301 , 319 , 15 , 28 , k1_LeftMouseButton ) ,
MouseInput ( k128_CommandClickOnChamptionIcon_Lower_Left , 274 , 299 , 15 , 28 , k1_LeftMouseButton ) ,
MouseInput ( k7_CommandToggleInventoryChampion_0 , 43 , 66 , 0 , 28 , k1_LeftMouseButton ) , /* Atari ST: Only present in CSB 2.x and with Box.X1 = 44. swapped with 4 next entries */
MouseInput ( k8_CommandToggleInventoryChampion_1 , 112 , 135 , 0 , 28 , k1_LeftMouseButton ) , /* Atari ST: Only present in CSB 2.x and with Box.X1 = 113. swapped with 4 next entries */
MouseInput ( k9_CommandToggleInventoryChampion_2 , 181 , 204 , 0 , 28 , k1_LeftMouseButton ) , /* Atari ST: Only present in CSB 2.x and with Box.X1 = 182. swapped with 4 next entries */
MouseInput ( k10_CommandToggleInventoryChampion_3 , 250 , 273 , 0 , 28 , k1_LeftMouseButton ) , /* Atari ST: Only present in CSB 2.x and with Box.X1 = 251. swapped with 4 next entries */
MouseInput ( k7_CommandToggleInventoryChampion_0 , 0 , 66 , 0 , 28 , k2_RightMouseButton ) , /* Atari ST: swapped with 4 previous entries */
MouseInput ( k8_CommandToggleInventoryChampion_1 , 69 , 135 , 0 , 28 , k2_RightMouseButton ) , /* Atari ST: swapped with 4 previous entries */
MouseInput ( k9_CommandToggleInventoryChampion_2 , 138 , 204 , 0 , 28 , k2_RightMouseButton ) , /* Atari ST: swapped with 4 previous entries */
MouseInput ( k10_CommandToggleInventoryChampion_3 , 207 , 273 , 0 , 28 , k2_RightMouseButton ) , /* Atari ST: swapped with 4 previous entries */
MouseInput ( k100_CommandClickInSpellArea , 233 , 319 , 42 , 73 , k1_LeftMouseButton ) ,
MouseInput ( k111_CommandClickInActionArea , 233 , 319 , 77 , 121 , k1_LeftMouseButton ) ,
MouseInput ( k147_CommandFreezeGame , 0 , 1 , 198 , 199 , k1_LeftMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
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 } */
MouseInput ( k1_CommandTurnLeft , 234 , 261 , 125 , 145 , k1_LeftMouseButton ) ,
MouseInput ( k3_CommandMoveForward , 263 , 289 , 125 , 145 , k1_LeftMouseButton ) ,
MouseInput ( k2_CommandTurnRight , 291 , 318 , 125 , 145 , k1_LeftMouseButton ) ,
MouseInput ( k6_CommandMoveLeft , 234 , 261 , 147 , 167 , k1_LeftMouseButton ) ,
MouseInput ( k5_CommandMoveBackward , 263 , 289 , 147 , 167 , k1_LeftMouseButton ) ,
MouseInput ( k4_CommandMoveRight , 291 , 318 , 147 , 167 , k1_LeftMouseButton ) ,
MouseInput ( k80_CommandClickInDungeonView , 0 , 223 , 33 , 168 , k1_LeftMouseButton ) ,
MouseInput ( k83_CommandToggleInventoryLeader , 0 , 319 , 33 , 199 , k2_RightMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput secondaryMouseInputChampionInventory [ 38 ] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
MouseInput ( k11_CommandCloseInventory , 0 , 319 , 0 , 199 , k2_RightMouseButton ) ,
MouseInput ( k140_CommandSaveGame , 174 , 182 , 36 , 44 , k1_LeftMouseButton ) ,
MouseInput ( k145_CommandSleep , 188 , 204 , 36 , 44 , k1_LeftMouseButton ) ,
MouseInput ( k11_CommandCloseInventory , 210 , 218 , 36 , 44 , k1_LeftMouseButton ) ,
MouseInput ( k28_CommandClickOnSlotBoxInventoryReadyHand , 6 , 21 , 86 , 101 , k1_LeftMouseButton ) ,
MouseInput ( k29_CommandClickOnSlotBoxInventoryActionHand , 62 , 77 , 86 , 101 , k1_LeftMouseButton ) ,
MouseInput ( k30_CommandClickOnSlotBoxInventoryHead , 34 , 49 , 59 , 74 , k1_LeftMouseButton ) ,
MouseInput ( k31_CommandClickOnSlotBoxInventoryTorso , 34 , 49 , 79 , 94 , k1_LeftMouseButton ) ,
MouseInput ( k32_CommandClickOnSlotBoxInventoryLegs , 34 , 49 , 99 , 114 , k1_LeftMouseButton ) ,
MouseInput ( k33_CommandClickOnSlotBoxInventoryFeet , 34 , 49 , 119 , 134 , k1_LeftMouseButton ) ,
MouseInput ( k34_CommandClickOnSlotBoxInventoryPouch_2 , 6 , 21 , 123 , 138 , k1_LeftMouseButton ) ,
MouseInput ( k70_CommandClickOnMouth , 56 , 71 , 46 , 61 , k1_LeftMouseButton ) ,
MouseInput ( k71_CommandClickOnEye , 12 , 27 , 46 , 61 , k1_LeftMouseButton ) ,
MouseInput ( k35_CommandClickOnSlotBoxInventoryQuiverLine_2_1 , 79 , 94 , 106 , 121 , k1_LeftMouseButton ) ,
MouseInput ( k36_CommandClickOnSlotBoxInventoryQuiverLine_1_2 , 62 , 77 , 123 , 138 , k1_LeftMouseButton ) ,
MouseInput ( k37_CommandClickOnSlotBoxInventoryQuiverLine_2_2 , 79 , 94 , 123 , 138 , k1_LeftMouseButton ) ,
MouseInput ( k38_CommandClickOnSlotBoxInventoryNeck , 6 , 21 , 66 , 81 , k1_LeftMouseButton ) ,
MouseInput ( k39_CommandClickOnSlotBoxInventoryPouch_1 , 6 , 21 , 106 , 121 , k1_LeftMouseButton ) ,
MouseInput ( k40_CommandClickOnSlotBoxInventoryQuiverLine_1_1 , 62 , 77 , 106 , 121 , k1_LeftMouseButton ) ,
MouseInput ( k41_CommandClickOnSlotBoxInventoryBackpackLine_1_1 , 66 , 81 , 66 , 81 , k1_LeftMouseButton ) ,
MouseInput ( k42_CommandClickOnSlotBoxInventoryBackpackLine_2_2 , 83 , 98 , 49 , 64 , k1_LeftMouseButton ) ,
MouseInput ( k43_CommandClickOnSlotBoxInventoryBackpackLine_2_3 , 100 , 115 , 49 , 64 , k1_LeftMouseButton ) ,
MouseInput ( k44_CommandClickOnSlotBoxInventoryBackpackLine_2_4 , 117 , 132 , 49 , 64 , k1_LeftMouseButton ) ,
MouseInput ( k45_CommandClickOnSlotBoxInventoryBackpackLine_2_5 , 134 , 149 , 49 , 64 , k1_LeftMouseButton ) ,
MouseInput ( k46_CommandClickOnSlotBoxInventoryBackpackLine_2_6 , 151 , 166 , 49 , 64 , k1_LeftMouseButton ) ,
MouseInput ( k47_CommandClickOnSlotBoxInventoryBackpackLine_2_7 , 168 , 183 , 49 , 64 , k1_LeftMouseButton ) ,
MouseInput ( k48_CommandClickOnSlotBoxInventoryBackpackLine_2_8 , 185 , 200 , 49 , 64 , k1_LeftMouseButton ) ,
MouseInput ( k49_CommandClickOnSlotBoxInventoryBackpackLine_2_9 , 202 , 217 , 49 , 64 , k1_LeftMouseButton ) ,
MouseInput ( k50_CommandClickOnSlotBoxInventoryBackpackLine_1_2 , 83 , 98 , 66 , 81 , k1_LeftMouseButton ) ,
MouseInput ( k51_CommandClickOnSlotBoxInventoryBackpackLine_1_3 , 100 , 115 , 66 , 81 , k1_LeftMouseButton ) ,
MouseInput ( k52_CommandClickOnSlotBoxInventoryBackpackLine_1_4 , 117 , 132 , 66 , 81 , k1_LeftMouseButton ) ,
MouseInput ( k53_CommandClickOnSlotBoxInventoryBackpackLine_1_5 , 134 , 149 , 66 , 81 , k1_LeftMouseButton ) ,
MouseInput ( k54_CommandClickOnSlotBoxInventoryBackpackLine_1_6 , 151 , 166 , 66 , 81 , k1_LeftMouseButton ) ,
MouseInput ( k55_CommandClickOnSlotBoxInventoryBackpackLine_1_7 , 168 , 183 , 66 , 81 , k1_LeftMouseButton ) ,
MouseInput ( k56_CommandClickOnSlotBoxInventoryBackpackLine_1_8 , 185 , 200 , 66 , 81 , k1_LeftMouseButton ) ,
MouseInput ( k57_CommandClickOnSlotBoxInventoryBackpackLine_1_9 , 202 , 217 , 66 , 81 , k1_LeftMouseButton ) ,
MouseInput ( k81_CommandClickInPanel , 96 , 223 , 83 , 167 , k1_LeftMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput primaryMouseInputPartySleeping [ 3 ] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
MouseInput ( k146_CommandWakeUp , 0 , 223 , 33 , 168 , k1_LeftMouseButton ) ,
MouseInput ( k146_CommandWakeUp , 0 , 223 , 33 , 168 , k2_RightMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput primaryMouseInputFrozenGame [ 3 ] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
MouseInput ( k148_CommandUnfreezeGame , 0 , 319 , 0 , 199 , k1_LeftMouseButton ) ,
MouseInput ( k148_CommandUnfreezeGame , 0 , 319 , 0 , 199 , k2_RightMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput mouseInputActionAreaNames [ 5 ] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
MouseInput ( k112_CommandClickInActionAreaPass , 285 , 318 , 77 , 83 , k1_LeftMouseButton ) ,
MouseInput ( k113_CommandClickInActionAreaAction_0 , 234 , 318 , 86 , 96 , k1_LeftMouseButton ) ,
MouseInput ( k114_CommandClickInActionAreaAction_1 , 234 , 318 , 98 , 108 , k1_LeftMouseButton ) ,
MouseInput ( k115_CommandClickInActionAreaAction_2 , 234 , 318 , 110 , 120 , k1_LeftMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
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 } */
MouseInput ( k116_CommandClickInActionAreaChampion_0_Action , 233 , 252 , 86 , 120 , k1_LeftMouseButton ) ,
MouseInput ( k117_CommandClickInActionAreaChampion_1_Action , 255 , 274 , 86 , 120 , k1_LeftMouseButton ) ,
MouseInput ( k118_CommandClickInActionAreaChampion_2_Action , 277 , 296 , 86 , 120 , k1_LeftMouseButton ) ,
MouseInput ( k119_CommandClickInActionAreaChampion_3_Action , 299 , 318 , 86 , 120 , k1_LeftMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput mouseInputSpellArea [ 9 ] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
MouseInput ( k101_CommandClickInSpellAreaSymbol_1 , 235 , 247 , 51 , 61 , k1_LeftMouseButton ) ,
MouseInput ( k102_CommandClickInSpellAreaSymbol_2 , 249 , 261 , 51 , 61 , k1_LeftMouseButton ) ,
MouseInput ( k103_CommandClickInSpellAreaSymbol_3 , 263 , 275 , 51 , 61 , k1_LeftMouseButton ) ,
MouseInput ( k104_CommandClickInSpellAreaSymbol_4 , 277 , 289 , 51 , 61 , k1_LeftMouseButton ) ,
MouseInput ( k105_CommandClickInSpellAreaSymbol_5 , 291 , 303 , 51 , 61 , k1_LeftMouseButton ) ,
MouseInput ( k106_CommandClickInSpellAreaSymbol_6 , 305 , 317 , 51 , 61 , k1_LeftMouseButton ) ,
MouseInput ( k108_CommandClickInSpeallAreaCastSpell , 234 , 303 , 63 , 73 , k1_LeftMouseButton ) ,
MouseInput ( k107_CommandClickInSpellAreaRecantSymbol , 305 , 318 , 63 , 73 , k1_LeftMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput mouseInputChampionNamesHands [ 13 ] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
MouseInput ( k16_CommandSetLeaderChampion_0 , 0 , 42 , 0 , 6 , k1_LeftMouseButton ) ,
MouseInput ( k17_CommandSetLeaderChampion_1 , 69 , 111 , 0 , 6 , k1_LeftMouseButton ) ,
MouseInput ( k18_CommandSetLeaderChampion_2 , 138 , 180 , 0 , 6 , k1_LeftMouseButton ) ,
MouseInput ( k19_CommandSetLeaderChampion_3 , 207 , 249 , 0 , 6 , k1_LeftMouseButton ) ,
MouseInput ( k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand , 4 , 19 , 10 , 25 , k1_LeftMouseButton ) ,
MouseInput ( k21_CommandClickOnSlotBoxChampion_0_StatusBoxActionHand , 24 , 39 , 10 , 25 , k1_LeftMouseButton ) ,
MouseInput ( k22_CommandClickOnSlotBoxChampion_1_StatusBoxReadyHand , 73 , 88 , 10 , 25 , k1_LeftMouseButton ) ,
MouseInput ( k23_CommandClickOnSlotBoxChampion_1_StatusBoxActionHand , 93 , 108 , 10 , 25 , k1_LeftMouseButton ) ,
MouseInput ( k24_CommandClickOnSlotBoxChampion_2_StatusBoxReadyHand , 142 , 157 , 10 , 25 , k1_LeftMouseButton ) ,
MouseInput ( k25_CommandClickOnSlotBoxChampion_2_StatusBoxActionHand , 162 , 177 , 10 , 25 , k1_LeftMouseButton ) ,
MouseInput ( k26_CommandClickOnSlotBoxChampion_3_StatusBoxReadyHand , 211 , 226 , 10 , 25 , k1_LeftMouseButton ) ,
MouseInput ( k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand , 231 , 246 , 10 , 25 , k1_LeftMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput mouseInputPanelChest [ 9 ] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
MouseInput ( k58_CommandClickOnSlotBoxChest_1 , 117 , 132 , 92 , 107 , k1_LeftMouseButton ) ,
MouseInput ( k59_CommandClickOnSlotBoxChest_2 , 106 , 121 , 109 , 124 , k1_LeftMouseButton ) ,
MouseInput ( k60_CommandClickOnSlotBoxChest_3 , 111 , 126 , 126 , 141 , k1_LeftMouseButton ) ,
MouseInput ( k61_CommandClickOnSlotBoxChest_4 , 128 , 143 , 131 , 146 , k1_LeftMouseButton ) ,
MouseInput ( k62_CommandClickOnSlotBoxChest_5 , 145 , 160 , 134 , 149 , k1_LeftMouseButton ) ,
MouseInput ( k63_CommandClickOnSlotBoxChest_6 , 162 , 177 , 136 , 151 , k1_LeftMouseButton ) ,
MouseInput ( k64_CommandClickOnSlotBoxChest_7 , 179 , 194 , 137 , 152 , k1_LeftMouseButton ) ,
MouseInput ( k65_CommandClickOnSlotBoxChest_8 , 196 , 211 , 138 , 153 , k1_LeftMouseButton ) ,
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput mouseInputPanelResurrectReincarnateCancel [ 4 ] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4]
/* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */
MouseInput ( k160_CommandClickInPanelResurrect , 108 , 158 , 90 , 138 , k1_LeftMouseButton ) , /* Atari ST: Box = 104, 158, 86, 142 */
MouseInput ( k161_CommandClickInPanelReincarnate , 161 , 211 , 90 , 138 , k1_LeftMouseButton ) , /* Atari ST: Box = 163, 217, 86, 142 */
MouseInput ( k162_CommandClickInPanelCancel , 108 , 211 , 141 , 153 , k1_LeftMouseButton ) , /* Atari ST: Box = 104, 217, 146, 156 */
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
2016-08-21 00:58:11 +02:00
MouseInput primaryMouseInputViewportDialog1Choice [ 2 ] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2]
MouseInput ( k210_CommandClickOnDialogChoice_1 , 16 , 207 , 138 , 152 , k1_LeftMouseButton ) , /* Bottom button */
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput primaryMouseInputViewportDialog2Choices [ 3 ] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3]
MouseInput ( k210_CommandClickOnDialogChoice_1 , 16 , 207 , 101 , 115 , k1_LeftMouseButton ) , /* Top button */
MouseInput ( k211_CommandClickOnDialogChoice_2 , 16 , 207 , 138 , 152 , k1_LeftMouseButton ) , /* Bottom button */
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput primaryMouseInputViewportDialog3Choices [ 4 ] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4]
MouseInput ( k210_CommandClickOnDialogChoice_1 , 16 , 207 , 101 , 115 , k1_LeftMouseButton ) , /* Top button */
MouseInput ( k211_CommandClickOnDialogChoice_2 , 16 , 101 , 138 , 152 , k1_LeftMouseButton ) , /* Lower left button */
MouseInput ( k212_CommandClickOnDialogChoice_3 , 123 , 207 , 138 , 152 , k1_LeftMouseButton ) , /* Lower right button */
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput primaryMouseInputViewportDialog4Choices [ 5 ] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5]
MouseInput ( k210_CommandClickOnDialogChoice_1 , 16 , 101 , 101 , 115 , k1_LeftMouseButton ) , /* Top left button */
MouseInput ( k211_CommandClickOnDialogChoice_2 , 123 , 207 , 101 , 115 , k1_LeftMouseButton ) , /* Top right button */
MouseInput ( k212_CommandClickOnDialogChoice_3 , 16 , 101 , 138 , 152 , k1_LeftMouseButton ) , /* Lower left button */
MouseInput ( k213_CommandClickOnDialogChoice_4 , 123 , 207 , 138 , 152 , k1_LeftMouseButton ) , /* Lower right button */
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput primaryMouseInputScreenDialog1Choice [ 2 ] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2]
MouseInput ( k210_CommandClickOnDialogChoice_1 , 63 , 254 , 138 , 152 , k1_LeftMouseButton ) , /* Bottom button */
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput primaryMouseInputScreenDialog2Choices [ 3 ] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3]
MouseInput ( k210_CommandClickOnDialogChoice_1 , 63 , 254 , 101 , 115 , k1_LeftMouseButton ) , /* Top button */
MouseInput ( k211_CommandClickOnDialogChoice_2 , 63 , 254 , 138 , 152 , k1_LeftMouseButton ) , /* Bottom button */
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput primaryMouseInputScreenDialog3Choices [ 4 ] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4]
MouseInput ( k210_CommandClickOnDialogChoice_1 , 63 , 254 , 101 , 115 , k1_LeftMouseButton ) , /* Top button */
MouseInput ( k211_CommandClickOnDialogChoice_2 , 63 , 148 , 138 , 152 , k1_LeftMouseButton ) , /* Lower left button */
MouseInput ( k212_CommandClickOnDialogChoice_3 , 170 , 254 , 138 , 152 , k1_LeftMouseButton ) , /* Lower right button */
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
MouseInput primaryMouseInputScreenDialog4Choices [ 5 ] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5]
MouseInput ( k210_CommandClickOnDialogChoice_1 , 63 , 148 , 101 , 115 , k1_LeftMouseButton ) , /* Top left button */
MouseInput ( k211_CommandClickOnDialogChoice_2 , 170 , 254 , 101 , 115 , k1_LeftMouseButton ) , /* Top right button */
MouseInput ( k212_CommandClickOnDialogChoice_3 , 63 , 148 , 138 , 152 , k1_LeftMouseButton ) , /* Lower left button */
MouseInput ( k213_CommandClickOnDialogChoice_4 , 170 , 254 , 138 , 152 , k1_LeftMouseButton ) , /* Lower right button */
MouseInput ( k0_CommandNone , 0 , 0 , 0 , 0 , k0_NoneMouseButton )
} ;
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 + + )
_mouseInputChampionNamesHands [ 13 ] = 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 ;
_pendingClickButton = k0_NoneMouseButton ;
_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-08-25 08:12:23 +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-08-10 00:12:20 +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 ) ;
_vm - > _displayMan - > blitToBitmap ( _mousePointerTempBuffer , L0051_puc_Bitmap , boxMousePointerObjectShadow , 0 , 0 , 8 , 16 , kM1_ColorNoTransparency , 16 , 18 ) ;
_vm - > _displayMan - > blitToBitmapShrinkWithPalChange ( bitmap , _mousePointerTempBuffer , 16 , 16 , 16 , 16 , palChangesMousePointerIcon ) ;
_vm - > _displayMan - > blitToBitmap ( _mousePointerTempBuffer , L0051_puc_Bitmap , boxMousePointerObject , 0 , 0 , 8 , 16 , k0_ColorBlack , 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 ) ;
_useChampionIconOrdinalAsMousePointerBitmap = _vm - > indexToOrdinal ( kM1_ChampionNone ) ;
_mousePointerBitmapUpdated = true ;
2016-08-25 18:32:03 +02:00
bool useByteBoxCoordinatesBackup = _vm - > _displayMan - > _useByteBoxCoordinates ;
_vm - > _displayMan - > blitToScreen ( _mousePointerOriginalColorsChampionIcon , & _vm - > _championMan - > _boxChampionIcons [ championIconIndex < < 2 ] , 16 , k12_ColorDarkestGray , 18 ) ;
_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-08-25 08:12:23 +02:00
setMousePointerToNormal ( ( _vm - > _championMan - > _leaderIndex = = kM1_ChampionNone ) ? 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-08-25 08:12:23 +02:00
return ( button ! = k0_NoneMouseButton ) ? ( _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 ) {
_vm - > _system - > warpMouse ( pos . x , pos . y ) ;
}
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 ;
while ( _vm - > _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-07-11 10:52:38 +02:00
while ( input - > _commandToIssue ! = k0_CommandNone ) {
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-07-11 10:52:38 +02:00
while ( input - > _commandToIssue ! = k0_CommandNone ) {
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 : {
MouseButton button = ( event . type = = Common : : EVENT_LBUTTONDOWN ) ? k1_LeftMouseButton : k2_RightMouseButton ;
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 : {
MouseButton button = ( event . type = = Common : : EVENT_LBUTTONDOWN ) ? k1_LeftMouseButton : k2_RightMouseButton ;
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-07-02 02:58:44 +02:00
if ( commandType = = k0_CommandNone )
2016-08-25 08:12:23 +02:00
commandType = getCommandTypeFromMouseInput ( _secondaryMouseInput , mousePos , button ) ;
2016-06-16 23:48:18 +02:00
2016-07-02 02:58:44 +02:00
if ( commandType ! = k0_CommandNone )
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-07-02 02:58:44 +02:00
return k0_CommandNone ;
2016-06-16 23:48:18 +02:00
2016-08-10 07:39:43 +02:00
CommandType commandType = k0_CommandNone ;
2016-07-02 02:58:44 +02:00
while ( ( commandType = input - > _commandTypeToIssue ) ! = k0_CommandNone ) {
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-08-24 08:03:55 +02:00
if ( ( cmdType > = k3_CommandMoveForward ) & & ( cmdType < = k6_CommandMoveLeft ) & & ( _vm - > _disabledMovementTicks | | ( _vm - > _projectileDisableMovementTicks & & ( _vm - > _lastProjectileDisabledMovementDirection = = ( normalizeModulo4 ( _vm - > _dungeonMan - > _partyDir + cmdType - k3_CommandMoveForward ) ) ) ) ) ) { /* 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-07-12 11:30:25 +02:00
if ( ( cmdType = = k2_CommandTurnRight ) | | ( cmdType = = k1_CommandTurnLeft ) ) {
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-07-12 11:30:25 +02:00
if ( ( cmdType > = k3_CommandMoveForward ) & & ( cmdType < = k6_CommandMoveLeft ) ) {
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-07-12 11:30:25 +02:00
if ( ( cmdType > = k12_CommandClickInChampion_0_StatusBox ) & & ( cmdType < = k15_CommandClickInChampion_3_StatusBox ) ) {
2016-08-10 21:48:22 +02:00
int16 championIdx = cmdType - k12_CommandClickInChampion_0_StatusBox ;
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-07-12 11:30:25 +02:00
if ( ( cmdType > = k125_CommandClickOnChamptionIcon_Top_Left ) & & ( cmdType < = k128_CommandClickOnChamptionIcon_Lower_Left ) ) {
2016-08-25 08:12:23 +02:00
mouseProcessCommands125To128_clickOnChampionIcon ( cmdType - k125_CommandClickOnChamptionIcon_Top_Left ) ;
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-07-12 11:30:25 +02:00
if ( ( cmdType > = k28_CommandClickOnSlotBoxInventoryReadyHand ) & & ( cmdType < ( k65_CommandClickOnSlotBoxChest_8 + 1 ) ) ) {
2016-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _leaderIndex ! = kM1_ChampionNone )
_vm - > _championMan - > clickOnSlotBox ( cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand ) ;
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-07-12 11:30:25 +02:00
if ( ( cmdType > = k7_CommandToggleInventoryChampion_0 ) & & ( cmdType < = k11_CommandCloseInventory ) ) {
2016-08-22 19:27:10 +02:00
if ( cmdType = = k11_CommandCloseInventory ) {
delete _vm - > _saveThumbnail ;
_vm - > _saveThumbnail = nullptr ;
} else if ( ! _vm - > _saveThumbnail ) {
_vm - > _saveThumbnail = new Common : : MemoryWriteStreamDynamic ( ) ;
Graphics : : saveThumbnail ( * _vm - > _saveThumbnail ) ;
}
2016-08-10 21:48:22 +02:00
int16 championIndex = cmdType - k7_CommandToggleInventoryChampion_0 ;
2016-08-23 07:54:16 +02:00
if ( ( ( championIndex = = k4_ChampionCloseInventory ) | | ( 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-07-12 11:30:25 +02:00
if ( cmdType = = k83_CommandToggleInventoryLeader ) {
2016-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _leaderIndex ! = kM1_ChampionNone )
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-07-12 11:30:25 +02:00
if ( cmdType = = k100_CommandClickInSpellArea ) {
2016-08-23 07:54:16 +02:00
if ( ( ! _vm - > _championMan - > _candidateChampionOrdinal ) & & ( _vm - > _championMan - > _magicCasterChampionIndex ! = kM1_ChampionNone ) )
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-07-12 11:30:25 +02:00
if ( cmdType = = k111_CommandClickInActionArea ) {
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-07-12 11:30:25 +02:00
if ( cmdType = = k70_CommandClickOnMouth ) {
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-07-12 11:30:25 +02:00
if ( cmdType = = k71_CommandClickOnEye ) {
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-07-12 11:30:25 +02:00
if ( cmdType = = k80_CommandClickInDungeonView ) {
2016-08-25 08:12:23 +02:00
commandProcessType80ClickInDungeonView ( commandX , commandY ) ;
2016-07-12 11:30:25 +02:00
return ;
}
if ( cmdType = = k81_CommandClickInPanel ) {
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-07-12 11:30:25 +02:00
if ( cmdType = = k145_CommandSleep ) {
2016-08-23 07:54:16 +02:00
if ( ! _vm - > _championMan - > _candidateChampionOrdinal ) {
2016-08-25 21:25:18 +02:00
if ( _vm - > _inventoryMan - > _inventoryChampionOrdinal )
_vm - > _inventoryMan - > toggleInventory ( k4_ChampionCloseInventory ) ;
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-07-12 11:30:25 +02:00
if ( cmdType = = k146_CommandWakeUp ) {
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-07-12 11:30:25 +02:00
if ( cmdType = = k140_CommandSaveGame ) {
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-07-12 11:30:25 +02:00
if ( cmdType = = k147_CommandFreezeGame ) {
2016-08-23 23:36:18 +02:00
_vm - > _gameTimeTicking = false ;
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > drawDisabledMenu ( ) ;
2016-08-25 18:32:03 +02:00
_vm - > _displayMan - > fillBitmap ( _vm - > _displayMan - > _bitmapViewport , k0_ColorBlack , 112 , 136 ) ;
2016-08-15 20:25:40 +02:00
switch ( _vm - > getGameLanguage ( ) ) { // localized
default :
case Common : : EN_ANY :
2016-08-25 22:38:03 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 81 , 69 , k4_ColorCyan , k0_ColorBlack ,
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-08-25 22:38:03 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 66 , 69 , k4_ColorCyan , k0_ColorBlack ,
2016-08-15 20:25:40 +02:00
" SPIEL ANGEHALTEN " , k136_heightViewport ) ;
break ;
case Common : : FR_FRA :
2016-08-25 22:38:03 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 84 , 69 , k4_ColorCyan , k0_ColorBlack ,
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-07-12 11:30:25 +02:00
if ( cmdType = = k148_CommandUnfreezeGame ) {
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-07-12 11:30:25 +02:00
if ( cmdType = = k200_CommandEntranceEnterDungeon ) {
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-07-12 11:30:25 +02:00
if ( cmdType = = k201_CommandEntranceResume ) {
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-07-12 11:30:25 +02:00
if ( cmdType = = k202_CommandEntranceDrawCredits ) {
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-07-12 11:30:25 +02:00
if ( ( cmdType > = k210_CommandClickOnDialogChoice_1 ) & & ( cmdType < = k213_CommandClickOnDialogChoice_4 ) ) {
2016-08-23 23:36:18 +02:00
_vm - > _dialog - > _selectedDialogChoice = cmdType - ( k210_CommandClickOnDialogChoice_1 - 1 ) ;
2016-07-12 11:30:25 +02:00
return ;
}
2016-08-10 21:48:22 +02:00
if ( cmdType = = k215_CommandRestartGame )
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-08-10 21:48:22 +02:00
if ( cmdType = = k1_CommandTurnLeft )
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-08-21 01:16:00 +02:00
if ( Square ( partySquare ) . getType ( ) = = k3_StairsElemType ) {
2016-08-25 08:12:23 +02:00
commandTakeStairs ( getFlag ( partySquare , k0x0004_StairsUp ) ) ;
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-08-24 08:03:55 +02:00
_vm - > _championMan - > setPartyDirection ( normalizeModulo4 ( _vm - > _dungeonMan - > _partyDir + ( ( cmdType = = k2_CommandTurnRight ) ? 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 ;
for ( uint16 idx = k0_ChampionFirst ; idx < _vm - > _championMan - > _partyChampionCount ; idx + + ) {
_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 + + ;
}
uint16 movementArrowIdx = cmdType - k3_CommandMoveForward ;
Box * highlightBox = & boxMovementArrows [ movementArrowIdx ] ;
2016-08-25 08:12:23 +02:00
commandHighlightBoxEnable ( highlightBox - > _x1 , highlightBox - > _x2 , highlightBox - > _y1 , highlightBox - > _y2 ) ;
2016-08-24 08:03:55 +02:00
int16 partyMapX = _vm - > _dungeonMan - > _partyMapX ;
int16 partyMapY = _vm - > _dungeonMan - > _partyMapY ;
uint16 AL1115_ui_Square = _vm - > _dungeonMan - > getSquare ( partyMapX , partyMapY ) . toByte ( ) ;
2016-08-21 01:16:00 +02:00
bool isStairsSquare = ( Square ( AL1115_ui_Square ) . getType ( ) = = k3_StairsElemType ) ;
2016-08-10 22:41:12 +02:00
if ( isStairsSquare & & ( movementArrowIdx = = 2 ) ) { /* If moving backward while in stairs */
2016-08-25 08:12:23 +02:00
commandTakeStairs ( getFlag ( AL1115_ui_Square , k0x0004_StairsUp ) ) ;
2016-08-26 22:50:30 +02:00
return ;
}
2016-08-24 08:03:55 +02:00
_vm - > _dungeonMan - > mapCoordsAfterRelMovement ( _vm - > _dungeonMan - > _partyDir , movementArrowToStepForwardCount [ movementArrowIdx ] , movementArrowToSepRightCount [ movementArrowIdx ] , partyMapX , partyMapY ) ;
int16 partySquareType = Square ( AL1115_ui_Square = _vm - > _dungeonMan - > getSquare ( partyMapX , partyMapY ) . toByte ( ) ) . getType ( ) ;
2016-08-10 22:41:12 +02:00
if ( partySquareType = = k3_ElementTypeStairs ) {
2016-08-25 22:09:30 +02:00
_vm - > _moveSens - > getMoveResult ( Thing : : _party , _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY , kM1_MapXNotOnASquare , 0 ) ;
2016-08-24 08:03:55 +02:00
_vm - > _dungeonMan - > _partyMapX = partyMapX ;
_vm - > _dungeonMan - > _partyMapY = partyMapY ;
2016-08-25 08:12:23 +02:00
commandTakeStairs ( getFlag ( AL1115_ui_Square , k0x0004_StairsUp ) ) ;
2016-08-26 22:50:30 +02:00
return ;
}
2016-08-10 22:41:12 +02:00
bool isMovementBlocked = false ;
if ( partySquareType = = k0_ElementTypeWall )
isMovementBlocked = true ;
else if ( partySquareType = = k4_DoorElemType ) {
byte doorState = Square ( AL1115_ui_Square ) . getDoorState ( ) ;
isMovementBlocked = ( doorState ! = k0_doorState_OPEN ) & & ( doorState ! = k1_doorState_FOURTH ) & & ( doorState ! = k5_doorState_DESTROYED ) ;
} else if ( partySquareType = = k6_ElementTypeFakeWall )
isMovementBlocked = ( ! getFlag ( AL1115_ui_Square , k0x0004_FakeWallOpen ) & & ! getFlag ( AL1115_ui_Square , k0x0001_FakeWallImaginary ) ) ;
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-08-23 23:36:18 +02:00
int16 L1124_i_FirstDamagedChampionIndex = _vm - > _championMan - > getTargetChampionIndex ( partyMapX , partyMapY , normalizeModulo4 ( movementArrowIdx ) ) ;
2016-08-23 07:54:16 +02:00
int16 L1125_i_SecondDamagedChampionIndex = _vm - > _championMan - > getTargetChampionIndex ( partyMapX , partyMapY , returnNextVal ( movementArrowIdx ) ) ;
int16 damage = _vm - > _championMan - > addPendingDamageAndWounds_getDamage ( L1124_i_FirstDamagedChampionIndex , 1 , k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs , k2_attackType_SELF ) ;
2016-08-10 21:48:22 +02:00
if ( L1124_i_FirstDamagedChampionIndex ! = L1125_i_SecondDamagedChampionIndex )
2016-08-23 07:54:16 +02:00
damage | = _vm - > _championMan - > addPendingDamageAndWounds_getDamage ( L1125_i_SecondDamagedChampionIndex , 1 , k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs , k2_attackType_SELF ) ;
2016-08-10 21:48:22 +02:00
2016-08-10 22:41:12 +02:00
if ( damage )
2016-08-25 22:38:03 +02:00
_vm - > _sound - > requestPlay ( k18_soundPARTY_DAMAGED , partyMapX , partyMapY , k0_soundModePlayImmediately ) ;
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-08-25 22:09:30 +02:00
_vm - > _moveSens - > getMoveResult ( Thing : : _party , kM1_MapXNotOnASquare , 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 ;
for ( uint16 idx = k0_ChampionFirst ; 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-07-07 00:46:51 +02:00
# define k0_sideLeft 0 // @ C0_SIDE_LEFT
# define k1_sideRight 1 // @ C0_SIDE_LEFT
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-08-24 08:03:55 +02:00
if ( _vm - > _dungeonMan - > _squareAheadElement = = k17_ElementTypeDoorFront ) {
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-08-24 08:03:55 +02:00
if ( _vm - > _dungeonMan - > _squareAheadElement = = k17_ElementTypeDoorFront ) {
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-08-08 16:12:15 +02:00
void EventManager : : setMousePointerFromSpriteData ( byte * mouseSprite ) {
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-08-23 07:54:16 +02:00
if ( ( cm . _leaderIndex = = champIndex ) | | ( ( champIndex ! = kM1_ChampionNone ) & & ! cm . _champions [ champIndex ] . _currHealth ) )
2016-06-18 16:23:44 +02:00
return ;
2016-08-23 07:54:16 +02:00
if ( cm . _leaderIndex ! = kM1_ChampionNone ) {
leaderIndex = cm . _leaderIndex ;
cm . _champions [ leaderIndex ] . setAttributeFlag ( k0x0200_ChampionAttributeLoad , true ) ;
cm . _champions [ leaderIndex ] . setAttributeFlag ( k0x0080_ChampionAttributeNameTitle , true ) ;
2016-08-24 08:03:55 +02:00
cm . _champions [ leaderIndex ] . _load - = _vm - > _dungeonMan - > getObjectWeight ( cm . _leaderHandObject ) ;
2016-08-23 07:54:16 +02:00
cm . _leaderIndex = kM1_ChampionNone ;
cm . drawChampionState ( leaderIndex ) ;
2016-06-18 16:23:44 +02:00
}
2016-07-02 01:55:48 +02:00
if ( champIndex = = kM1_ChampionNone ) {
2016-08-23 07:54:16 +02:00
cm . _leaderIndex = kM1_ChampionNone ;
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-07-02 01:55:48 +02:00
champion - > setAttributeFlag ( k0x0400_ChampionAttributeIcon , true ) ;
champion - > setAttributeFlag ( k0x0080_ChampionAttributeNameTitle , 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-08-24 08:03:55 +02:00
uint16 mapX = _vm - > _dungeonMan - > _partyMapX + _vm - > _dirIntoStepCountEast [ _vm - > _dungeonMan - > _partyDir ] ;
uint16 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-08-25 22:09:30 +02:00
_vm - > _stopWaitingForPlayerInput = _vm - > _moveSens - > sensorIsTriggeredByClickOnWall ( mapX , mapY , 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-08-24 08:03:55 +02:00
if ( _vm - > _dungeonMan - > _squareAheadElement = = k17_ElementTypeDoorFront ) {
2016-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _leaderIndex = = kM1_ChampionNone )
2016-06-23 23:54:37 +02:00
return ;
2016-08-10 23:10:57 +02:00
2016-08-24 08:03:55 +02:00
int16 L1155_i_MapX = _vm - > _dungeonMan - > _partyMapX + _vm - > _dirIntoStepCountEast [ _vm - > _dungeonMan - > _partyDir ] ;
int16 L1156_i_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-08-24 08:03:55 +02:00
Junk * junkPtr = ( Junk * ) _vm - > _dungeonMan - > getSquareFirstThingData ( L1155_i_MapX , L1156_i_MapY ) ;
if ( ( ( ( Door * ) junkPtr ) - > hasButton ( ) ) & & _vm - > _dungeonMan - > _dungeonViewClickableBoxes [ k5_ViewCellDoorButtonOrWallOrn ] . isPointInside ( posX , posY - 33 ) ) {
2016-08-23 23:36:18 +02:00
_vm - > _stopWaitingForPlayerInput = true ;
2016-08-25 22:38:03 +02:00
_vm - > _sound - > requestPlay ( k01_soundSWITCH , _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY , k1_soundModePlayIfPrioritized ) ;
2016-08-25 22:09:30 +02:00
_vm - > _moveSens - > addEvent ( k10_TMEventTypeDoor , L1155_i_MapX , L1156_i_MapY , 0 , k2_SensorEffToggle , _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-08-10 23:10:57 +02:00
for ( uint16 currViewCell = k0_ViewCellFronLeft ; currViewCell < k5_ViewCellDoorButtonOrWallOrn + 1 ; currViewCell + + ) {
2016-08-24 08:03:55 +02:00
if ( _vm - > _dungeonMan - > _dungeonViewClickableBoxes [ currViewCell ] . isPointInside ( posX , posY - 33 ) ) {
2016-08-10 23:10:57 +02:00
if ( currViewCell = = k5_ViewCellDoorButtonOrWallOrn ) {
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 ) ;
if ( _vm - > _dungeonMan - > _squareAheadElement = = k0_ElementTypeWall ) {
2016-08-10 23:10:57 +02:00
for ( uint16 currViewCell = k0_ViewCellFronLeft ; currViewCell < k1_ViewCellFrontRight + 1 ; currViewCell + + ) {
2016-08-18 21:18:08 +02:00
if ( boxObjectPiles [ currViewCell ] . isPointInside ( posX , posY ) ) {
2016-08-25 08:12:23 +02:00
processType80_clickInDungeonViewDropLeaderHandObject ( currViewCell ) ;
2016-06-23 23:54:37 +02:00
return ;
}
}
2016-08-24 08:03:55 +02:00
if ( _vm - > _dungeonMan - > _dungeonViewClickableBoxes [ k5_ViewCellDoorButtonOrWallOrn ] . isPointInside ( posX , posY - 33 ) ) {
if ( _vm - > _dungeonMan - > _isFacingAlcove )
2016-08-25 08:12:23 +02:00
processType80_clickInDungeonViewDropLeaderHandObject ( k4_ViewCellAlcove ) ;
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-08-10 23:10:57 +02:00
if ( ( iconIdx > = k8_IconIndiceJunkWater ) & & ( iconIdx < = k9_IconIndiceJunkWaterSkin ) )
junkPtr - > setChargeCount ( 3 ) ; /* Full */
else if ( iconIdx = = k195_IconIndicePotionEmptyFlask )
( ( Potion * ) junkPtr ) - > setType ( k15_PotionTypeWaterFlask ) ;
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
for ( uint16 currViewCell = k0_ViewCellFronLeft ; currViewCell < k3_ViewCellBackLeft + 1 ; currViewCell + + ) {
2016-08-18 21:18:08 +02:00
if ( boxObjectPiles [ currViewCell ] . isPointInside ( posX , posY ) ) {
2016-08-25 08:12:23 +02:00
processType80_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-07-02 02:58:44 +02:00
if ( commandType = = k162_CommandClickInPanelCancel ) {
2016-08-25 21:25:18 +02:00
invMan . toggleInventory ( k4_ChampionCloseInventory ) ;
2016-08-23 23:36:18 +02:00
champMan . _candidateChampionOrdinal = _vm - > indexToOrdinal ( kM1_ChampionNone ) ;
2016-08-23 07:54:16 +02:00
if ( champMan . _partyChampionCount = = 1 ) {
2016-08-25 08:12:23 +02:00
commandSetLeader ( kM1_ChampionNone ) ;
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 ;
box . _y1 = 0 ;
2016-07-03 03:07:38 +02:00
box . _y2 = 28 ;
2016-07-02 12:57:31 +02:00
box . _x1 = championIndex * k69_ChampionStatusBoxSpacing ;
2016-07-03 03:07:38 +02:00
box . _x2 = box . _x1 + 66 ;
2016-08-25 18:32:03 +02:00
dispMan . _useByteBoxCoordinates = false ;
dispMan . fillScreenBox ( box , k0_ColorBlack ) ;
dispMan . fillScreenBox ( _vm - > _championMan - > _boxChampionIcons [ champMan . getChampionIconIndex ( champ - > _cell , dunMan . _partyDir ) * 2 ] , k0_ColorBlack ) ;
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-08-23 23:36:18 +02:00
champMan . _candidateChampionOrdinal = _vm - > indexToOrdinal ( kM1_ChampionNone ) ;
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-07-02 01:55:48 +02:00
for ( uint16 slotIndex = k0_ChampionSlotReadyHand ; slotIndex < k30_ChampionSlotChest_1 ; 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-08-26 22:43:17 +02:00
if ( thing . getType ( ) = = k3_SensorThingType ) {
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-07-02 02:58:44 +02:00
if ( commandType = = k161_CommandClickInPanelReincarnate ) {
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-07-02 01:55:48 +02:00
champ - > getStatistic ( ( ChampionStatisticType ) statIndex , k1_ChampionStatCurrent ) + + ; // returns reference
champ - > getStatistic ( ( ChampionStatisticType ) statIndex , k0_ChampionStatMaximum ) + + ; // 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-08-25 08:12:23 +02:00
commandSetLeader ( k0_ChampionFirst ) ;
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > setMagicCasterAndDrawSpellArea ( k0_ChampionFirst ) ;
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-08-25 22:38:03 +02:00
_vm - > _textMan - > printMessage ( champColor , ( commandType = = k160_CommandClickInPanelResurrect ) ? " RESURRECTED. " : " REINCARNATED. " ) ;
2016-08-15 20:25:40 +02:00
break ;
2016-08-16 09:28:57 +02:00
case Common : : DE_DEU :
2016-08-25 22:38:03 +02:00
_vm - > _textMan - > printMessage ( champColor , ( commandType = = k160_CommandClickInPanelResurrect ) ? " VOM TODE ERWECKT. " : " REINKARNIERT. " ) ;
2016-08-15 20:25:40 +02:00
break ;
case Common : : FR_FRA :
2016-08-25 22:38:03 +02:00
_vm - > _textMan - > printMessage ( champColor , ( commandType = = k160_CommandClickInPanelResurrect ) ? " RESSUSCITE. " : " REINCARNE. " ) ;
2016-08-15 20:25:40 +02:00
break ;
}
2016-06-24 01:43:43 +02:00
2016-08-25 21:25:18 +02:00
invMan . toggleInventory ( k4_ChampionCloseInventory ) ;
2016-08-25 21:59:02 +02:00
_vm - > _menuMan - > drawEnabledMenus ( ) ;
2016-08-25 08:12:23 +02:00
setMousePointerToNormal ( ( _vm - > _championMan - > _leaderIndex = = kM1_ChampionNone ) ? 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-07-02 12:57:31 +02:00
case k4_PanelContentChest :
2016-08-23 07:54:16 +02:00
if ( champMan . _leaderIndex = = kM1_ChampionNone ) // if no leader
2016-06-24 02:08:26 +02:00
return ;
2016-08-25 08:12:23 +02:00
commandType = getCommandTypeFromMouseInput ( _mouseInputPanelChest , Common : : Point ( x , y ) , k1_LeftMouseButton ) ;
2016-07-02 02:58:44 +02:00
if ( commandType ! = k0_CommandNone )
2016-08-23 07:54:16 +02:00
_vm - > _championMan - > clickOnSlotBox ( commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand ) ;
2016-06-24 02:08:26 +02:00
break ;
2016-07-02 12:57:31 +02:00
case k5_PanelContentResurrectReincarnate :
2016-08-23 07:54:16 +02:00
if ( ! champMan . _leaderEmptyHanded )
2016-06-24 02:08:26 +02:00
break ;
2016-08-25 08:12:23 +02:00
commandType = getCommandTypeFromMouseInput ( _mouseInputPanelResurrectReincarnateCancel , Common : : Point ( x , y ) , k1_LeftMouseButton ) ;
2016-07-02 02:58:44 +02:00
if ( commandType ! = k0_CommandNone )
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-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _leaderIndex = = kM1_ChampionNone )
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-07-07 00:46:51 +02:00
if ( viewCell > = k2_ViewCellBackRight ) {
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-08-25 21:17:48 +02:00
_vm - > _groupMan - > getCreatureOrdinalInCell ( ( Group * ) _vm - > _dungeonMan - > getThingData ( groupThing ) , 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-08-25 22:19:34 +02:00
if ( _vm - > _objectMan - > getIconIndex ( topPileThing ) ! = kM1_IconIndiceNone ) {
2016-08-25 22:09:30 +02:00
_vm - > _moveSens - > getMoveResult ( topPileThing , mapX , mapY , kM1_MapXNotOnASquare , 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-08-25 08:12:23 +02:00
void EventManager : : processType80_clickInDungeonViewDropLeaderHandObject ( uint16 viewCell ) {
2016-08-23 07:54:16 +02:00
if ( _vm - > _championMan - > _leaderIndex = = kM1_ChampionNone )
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-08-11 07:44:56 +02:00
bool droppingIntoAnAlcove = ( viewCell = = k4_ViewCellAlcove ) ;
if ( droppingIntoAnAlcove )
2016-07-07 00:46:51 +02:00
viewCell = k2_ViewCellBackRight ;
2016-08-11 07:44:56 +02:00
if ( viewCell > k1_ViewCellFrontRight )
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-08-24 08:03:55 +02:00
uint16 currCell = normalizeModulo4 ( _vm - > _dungeonMan - > _partyDir + viewCell ) ;
2016-08-23 07:54:16 +02:00
Thing removedThing = _vm - > _championMan - > getObjectRemovedFromLeaderHand ( ) ;
2016-08-25 22:09:30 +02:00
_vm - > _moveSens - > getMoveResult ( thingWithNewCell ( removedThing , currCell ) , kM1_MapXNotOnASquare , 0 , mapX , mapY ) ;
2016-08-25 22:19:34 +02:00
if ( droppingIntoAnAlcove & & _vm - > _dungeonMan - > _isFacingViAltar & & ( _vm - > _objectMan - > getIconIndex ( removedThing ) = = k147_IconIndiceJunkChampionBones ) ) {
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-08-24 08:03:55 +02:00
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 ( ) ;
newEvent . _B . _location . _mapX = mapX ;
newEvent . _B . _location . _mapY = mapY ;
newEvent . _C . A . _cell = currCell ;
newEvent . _C . A . _effect = k2_SensorEffToggle ;
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-08-25 18:32:03 +02:00
_vm - > _displayMan - > fillBitmap ( _vm - > _displayMan - > _bitmapViewport , k0_ColorBlack , 112 , 136 ) ;
2016-08-15 20:25:40 +02:00
switch ( _vm - > getGameLanguage ( ) ) { // localized
default :
case Common : : EN_ANY :
2016-08-25 22:38:03 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 93 , 69 , k4_ColorCyan , k0_ColorBlack , " 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-08-25 22:38:03 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 96 , 69 , k4_ColorCyan , k0_ColorBlack , " WECKEN " , k136_heightViewport ) ;
2016-08-15 20:25:40 +02:00
break ;
case Common : : FR_FRA :
2016-08-25 22:38:03 +02:00
_vm - > _textMan - > printTextToBitmap ( _vm - > _displayMan - > _bitmapViewport , k112_byteWidthViewport , 72 , 69 , k4_ColorCyan , k0_ColorBlack , " 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-07-29 22:27:43 +02:00
while ( _vm - > _system - > getEventManager ( ) - > pollEvent ( event ) & & ! _vm - > _engineShouldQuit ) {
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-08-25 22:09:30 +02:00
_vm - > _moveSens - > getMoveResult ( Thing : : _party , _vm - > _dungeonMan - > _partyMapX , _vm - > _dungeonMan - > _partyMapY , kM1_MapXNotOnASquare , 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-08-25 08:12:23 +02:00
uint16 commandType = getCommandTypeFromMouseInput ( _mouseInputChampionNamesHands , Common : : Point ( posX , posY ) , k1_LeftMouseButton ) ;
2016-08-11 23:21:52 +02:00
if ( ( commandType > = k16_CommandSetLeaderChampion_0 ) & & ( commandType < = k19_CommandSetLeaderChampion_3 ) )
2016-08-25 08:12:23 +02:00
commandSetLeader ( ( ChampionIndex ) ( commandType - k16_CommandSetLeaderChampion_0 ) ) ;
2016-08-11 23:21:52 +02:00
else if ( ( commandType > = k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand ) & & ( commandType < = k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand ) )
2016-08-23 07:54:16 +02:00
_vm - > _championMan - > clickOnSlotBox ( commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand ) ;
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-08-24 08:03:55 +02:00
if ( _vm - > _championMan - > getIndexInCell ( normalizeModulo4 ( champIconIndex + _vm - > _dungeonMan - > _partyDir ) ) = = kM1_ChampionNone ) {
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-08-25 18:32:03 +02:00
_vm - > _displayMan - > blitToBitmap ( _vm - > _displayMan - > _bitmapScreen , tmpBitmap , championIconShadowBox , curChampionIconBox - > _x1 , curChampionIconBox - > _y1 , k160_byteWidthScreen , k16_byteWidth , k0_ColorBlack , 200 , 18 ) ;
_vm - > _displayMan - > blitToBitmapShrinkWithPalChange ( tmpBitmap , _mousePointerOriginalColorsChampionIcon , 32 , 18 , 32 , 18 , mousePointerIconShadowBox ) ;
_vm - > _displayMan - > blitToBitmap ( _vm - > _displayMan - > _bitmapScreen , _mousePointerOriginalColorsChampionIcon , championIconBox , curChampionIconBox - > _x1 , curChampionIconBox - > _y1 , k160_byteWidthScreen , k16_byteWidth , k0_ColorBlack , 200 , 18 ) ;
_vm - > _displayMan - > fillScreenBox ( * curChampionIconBox , k0_ColorBlack ) ;
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 ) ;
_useChampionIconOrdinalAsMousePointerBitmap = _vm - > indexToOrdinal ( kM1_ChampionNone ) ;
2016-08-24 08:03:55 +02:00
int16 championCellIndex = _vm - > _championMan - > getIndexInCell ( normalizeModulo4 ( championIconIndex + _vm - > _dungeonMan - > _partyDir ) ) ;
2016-08-11 23:21:52 +02:00
if ( championIconIndex = = champIconIndex ) {
2016-08-23 07:54:16 +02:00
setFlag ( _vm - > _championMan - > _champions [ championCellIndex ] . _attributes , k0x0400_ChampionAttributeIcon ) ;
_vm - > _championMan - > drawChampionState ( ( ChampionIndex ) championCellIndex ) ;
2016-07-12 12:26:22 +02:00
} else {
2016-08-24 08:03:55 +02:00
int16 championIndex = _vm - > _championMan - > getIndexInCell ( normalizeModulo4 ( champIconIndex + _vm - > _dungeonMan - > _partyDir ) ) ;
2016-08-11 23:21:52 +02:00
if ( championIndex > = 0 ) {
2016-08-24 08:03:55 +02:00
_vm - > _championMan - > _champions [ championIndex ] . _cell = ( ViewCell ) normalizeModulo4 ( championIconIndex + _vm - > _dungeonMan - > _partyDir ) ;
2016-08-23 07:54:16 +02:00
setFlag ( _vm - > _championMan - > _champions [ championIndex ] . _attributes , k0x0400_ChampionAttributeIcon ) ;
_vm - > _championMan - > drawChampionState ( ( ChampionIndex ) championIndex ) ;
2016-08-11 23:21:52 +02:00
} else
2016-08-25 18:32:03 +02:00
_vm - > _displayMan - > fillScreenBox ( _vm - > _championMan - > _boxChampionIcons [ championIconIndex ] , k0_ColorBlack ) ;
2016-08-11 23:21:52 +02:00
2016-08-24 08:03:55 +02:00
_vm - > _championMan - > _champions [ championCellIndex ] . _cell = ( ViewCell ) normalizeModulo4 ( champIconIndex + _vm - > _dungeonMan - > _partyDir ) ;
2016-08-23 07:54:16 +02:00
setFlag ( _vm - > _championMan - > _champions [ championCellIndex ] . _attributes , k0x0400_ChampionAttributeIcon ) ;
_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-08-11 23:21:52 +02:00
int16 championIndex = kM1_ChampionNone ;
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 ) )
championIndex = 1 ;
else if ( ( posX > = 294 ) & & ( posX < = 305 ) )
championIndex = 2 ;
else if ( posX > = 308 )
championIndex = 3 ;
2016-07-12 14:38:52 +02:00
break ;
case 1 :
2016-08-11 23:21:52 +02:00
if ( ( posX > = 233 ) & & ( posX < = 244 ) )
championIndex = 0 ;
else if ( ( posX > = 294 ) & & ( posX < = 305 ) )
championIndex = 2 ;
else if ( posX > = 308 )
championIndex = 3 ;
2016-07-12 14:38:52 +02:00
break ;
case 2 :
2016-08-11 23:21:52 +02:00
if ( ( posX > = 233 ) & & ( posX < = 244 ) )
championIndex = 0 ;
else if ( ( posX > = 247 ) & & ( posX < = 258 ) )
championIndex = 1 ;
else if ( posX > = 308 )
championIndex = 3 ;
2016-07-12 14:38:52 +02:00
break ;
case 3 :
2016-08-11 23:21:52 +02:00
if ( ( posX > = 247 ) & & ( posX < = 258 ) )
championIndex = 1 ;
else if ( ( posX > = 261 ) & & ( posX < = 272 ) )
championIndex = 2 ;
else if ( posX < = 244 )
championIndex = 0 ;
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-08-23 07:54:16 +02:00
if ( ( championIndex ! = kM1_ChampionNone ) & & ( 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-08-25 08:12:23 +02:00
CommandType newCommand = getCommandTypeFromMouseInput ( _mouseInputSpellArea , Common : : Point ( posX , posY ) , k1_LeftMouseButton ) ;
2016-08-11 23:21:52 +02:00
if ( newCommand ! = k0_CommandNone )
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 */
Box ( 305 , 318 , 63 , 73 ) } ; /* Delete */
if ( cmdType = = k108_CommandClickInSpeallAreaCastSpell ) {
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
uint16 symbolIndex = cmdType - k101_CommandClickInSpellAreaSymbol_1 ;
Box * highlightBox = & spellSymbolsAndDelete [ symbolIndex ] ;
2016-08-25 08:12:23 +02:00
commandHighlightBoxEnable ( highlightBox - > _x1 , highlightBox - > _x2 , highlightBox - > _y1 , highlightBox - > _y2 ) ;
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-08-25 08:12:23 +02:00
uint16 mouseCommand = getCommandTypeFromMouseInput ( _mouseInputActionAreaNames , Common : : Point ( posX , posY ) , k1_LeftMouseButton ) ;
2016-08-11 23:21:52 +02:00
if ( mouseCommand ! = k0_CommandNone ) {
if ( mouseCommand = = k112_CommandClickInActionAreaPass ) {
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 ) ;
} else if ( ( mouseCommand - k112_CommandClickInActionAreaPass ) < = _vm - > _menuMan - > _actionCount ) {
2016-08-11 23:21:52 +02:00
if ( mouseCommand = = k113_CommandClickInActionAreaAction_0 )
2016-08-25 08:12:23 +02:00
commandHighlightBoxEnable ( 234 , 318 , 86 , 96 ) ;
2016-08-11 23:21:52 +02:00
else if ( mouseCommand = = k114_CommandClickInActionAreaAction_1 )
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-08-25 21:59:02 +02:00
_vm - > _stopWaitingForPlayerInput = _vm - > _menuMan - > didClickTriggerAction ( mouseCommand - k113_CommandClickInActionAreaAction_0 ) ;
2016-07-13 15:01:00 +02:00
}
}
2016-08-25 21:59:02 +02:00
} else if ( _vm - > _menuMan - > _actionAreaContainsIcons ) {
2016-08-25 08:12:23 +02:00
uint16 mouseCommand = getCommandTypeFromMouseInput ( _mouseInputActionAreaIcons , Common : : Point ( posX , posY ) , k1_LeftMouseButton ) ;
2016-08-11 23:21:52 +02:00
if ( mouseCommand ! = k0_CommandNone ) {
mouseCommand - = k116_CommandClickInActionAreaChampion_0_Action ;
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 ) {
if ( _vm - > _system - > getEventManager ( ) - > pollEvent ( event ) ) {
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 ) {
highlightScreenBox ( _highlightScreenBox . _x1 , _highlightScreenBox . _x2 , _highlightScreenBox . _y1 , _highlightScreenBox . _y2 ) ;
_highlightBoxEnabled = false ;
2016-08-19 19:00:58 +02:00
}
}
2016-06-27 23:00:33 +02:00
} // end of namespace DM