Mercurial > mm7
diff Keyboard.cpp @ 2331:9551756f46c4
Moving functions out of mm7_6.cpp into appropriate classes as static methods or free functions
author | Grumpy7 |
---|---|
date | Wed, 02 Apr 2014 01:21:05 +0200 |
parents | aff7a7b072b7 |
children | ddb803517a48 |
line wrap: on
line diff
--- a/Keyboard.cpp Tue Apr 01 23:44:27 2014 +0200 +++ b/Keyboard.cpp Wed Apr 02 01:21:05 2014 +0200 @@ -8,6 +8,11 @@ #include "Vis.h" #include "MM7.h" #include "Actor.h" +#include "Party.h" +#include "Timer.h" +#include "TurnEngine.h" +#include "Weather.h" +#include "CastSpellInfo.h" #include "DecorationList.h" #include "Indoor.h" #include "viewport.h" @@ -478,3 +483,382 @@ break; }*/ } + + +//----- (0042FC4E) -------------------------------------------------------- +void Keyboard::ProcessInputActions() +{ + char v4; // al@9 + //char v8; // bl@100 + unsigned __int16 v9; // ax@102 + int spell_price; // eax@103 + char v14; // al@159 + unsigned int v15; // eax@168 + PartyAction partyAction; // [sp-14h] [bp-1Ch]@20 + InputAction inputAction; // [sp+0h] [bp-8h]@7 + //int v24; // [sp+4h] [bp-4h]@87 + + pGame->pKeyboardInstance->EnterCriticalSection(); + Keyboard* pKeyboard = pGame->pKeyboardInstance; + if (!bAlwaysRun) + { + if (pKeyboard->IsShiftHeld()) + pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; + else + pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; + } + else + { + if (pKeyboard->IsShiftHeld()) + pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; + else + pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; + } + + //pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; + + + // WUT? double event trigger + /*for ( uint i = 0; i < 30; ++i ) + { + if ( pKeyActionMap->pToggleTypes[i] ) + v14 = pGame->pKeyboardInstance->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[i]); + else + v14 = pGame->pKeyboardInstance->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[i]); + if ( v14 ) + { + if (pCurrentScreen == SCREEN_GAME) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); + continue; + } + if ( pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) + { + v15 = pMessageQueue_50CBD0->uNumMessages; + if ( pMessageQueue_50CBD0->uNumMessages ) + { + v15 = 0; + if ( pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 ) + { + v15 = 1; + pMessageQueue_50CBD0->uNumMessages = 0; + pMessageQueue_50CBD0->pMessages[v15].eType = UIMSG_Escape; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + continue; + } + pMessageQueue_50CBD0->uNumMessages = 0; + } + //pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + } + } + }*/ + if ( !pEventTimer->bPaused ) + { + for ( uint i = 0; i < 30; ++i ) + { + inputAction = (InputAction)i; + if ( pKeyActionMap->pToggleTypes[inputAction] ) + v4 = pKeyboard->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[inputAction]); + else + v4 = pKeyboard->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[inputAction]); + if ( v4 ) + { + switch ( inputAction ) + { + case INPUT_MoveForward: + if (pCurrentScreen != SCREEN_GAME) + break; + if (!pParty->bTurnBasedModeOn) + { + if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) + partyAction = PARTY_RunForward; + else + partyAction = PARTY_WalkForward; + pPartyActionQueue->Add(partyAction); + break; + } + if (pTurnEngine->turn_stage != TE_WAIT && pTurnEngine->turn_stage != TE_ATTACK && pTurnEngine->uActionPointsLeft > 0 ) + { + pTurnEngine->uActionPointsLeft -= 26; + if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) + partyAction = PARTY_RunForward; + else + partyAction = PARTY_WalkForward; + pPartyActionQueue->Add(partyAction); + break; + } + break; + case INPUT_MoveBackwards: + if (pCurrentScreen != SCREEN_GAME) + break; + if (!pParty->bTurnBasedModeOn) + { + if ( pParty->uFlags2 & 2 ) + partyAction = PARTY_RunBackward; + else + partyAction = PARTY_WalkBackward; + pPartyActionQueue->Add(partyAction); + break; + } + if ( pTurnEngine->turn_stage != TE_WAIT && pTurnEngine->turn_stage != TE_ATTACK && pTurnEngine->uActionPointsLeft > 0 ) + { + pTurnEngine->uActionPointsLeft -= 26; + if ( pParty->uFlags2 & 2 ) + partyAction = PARTY_RunBackward; + else + partyAction = PARTY_WalkBackward; + pPartyActionQueue->Add(partyAction); + break; + } + break; + case INPUT_StrafeLeft: + if (pCurrentScreen != SCREEN_GAME) + break; + if (!pParty->bTurnBasedModeOn) + { + partyAction = PARTY_StrafeLeft; + pPartyActionQueue->Add(partyAction); + break; + } + if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->uActionPointsLeft <= 0 ) + break; + pTurnEngine->uActionPointsLeft -= 26; + partyAction = PARTY_StrafeLeft; + pPartyActionQueue->Add(partyAction); + break; + case INPUT_StrafeRight: + if (pCurrentScreen != SCREEN_GAME) + break; + if (!pParty->bTurnBasedModeOn) + { + partyAction = PARTY_StrafeRight; + pPartyActionQueue->Add(partyAction); + break; + } + if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->uActionPointsLeft <= 0 ) + break; + pTurnEngine->uActionPointsLeft -= 26; + partyAction = PARTY_StrafeRight; + pPartyActionQueue->Add(partyAction); + break; + case INPUT_TurnLeft: + if (pCurrentScreen != SCREEN_GAME) + break; + if ( GetAsyncKeyState(VK_CONTROL) ) // strafing + { + if (pParty->bTurnBasedModeOn) + { + if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->uActionPointsLeft <= 0 ) + break; + pTurnEngine->uActionPointsLeft -= 26; + } + partyAction = PARTY_StrafeLeft; + } + else + { + if ( pParty->uFlags2 & 2 ) + partyAction = PARTY_FastTurnLeft; + else + partyAction = PARTY_TurnLeft; + } + pPartyActionQueue->Add(partyAction); + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) + pWeather->OnPlayerTurn(10); + break; + case INPUT_TurnRight: + if (pCurrentScreen != SCREEN_GAME) + break; + if ( GetAsyncKeyState(17) ) // strafing + { + if (pParty->bTurnBasedModeOn) + { + if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->uActionPointsLeft <= 0 ) + break; + pTurnEngine->uActionPointsLeft -= 26; + } + partyAction = PARTY_StrafeRight; + } + else + { + if ( pParty->uFlags2 & 2 ) + partyAction = PARTY_FastTurnRight; + else + partyAction = PARTY_TurnRight; + } + pPartyActionQueue->Add(partyAction); + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) + pWeather->OnPlayerTurn(-10); + break; + case INPUT_Jump: + if (pCurrentScreen != SCREEN_GAME || pParty->bTurnBasedModeOn) + break; + partyAction = (PartyAction)12; + pPartyActionQueue->Add(partyAction); + break; + case INPUT_Yell: + if (!pCurrentScreen && uActiveCharacter) + { + pParty->Yell(); + pPlayers[uActiveCharacter]->PlaySound(SPEECH_Yell, 0); + } + break; + case INPUT_Pass: + if ( pCurrentScreen ) + break; + if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == TE_MOVEMENT) + { + pTurnEngine->field_18 |= TE_FLAG_8; + break; + } + if ( uActiveCharacter ) + { + if ( !pPlayers[uActiveCharacter]->uTimeToRecovery ) + { + if ( !pParty->bTurnBasedModeOn ) + pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)pPlayers[uActiveCharacter]->GetAttackRecoveryTime(false) * 2.133333333333333)); + CastSpellInfoHelpers::_427D48(); + pTurnEngine->ApplyPlayerAction(); + } + } + break; + case INPUT_Combat://if press ENTER + if (pCurrentScreen == SCREEN_GAME) + { + if (pParty->bTurnBasedModeOn) + { + if (pTurnEngine->turn_stage == TE_MOVEMENT || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) + { + pParty->bTurnBasedModeOn = 0; + pTurnEngine->End(true); + } + } + else + { + pTurnEngine->Start(); + pParty->bTurnBasedModeOn = true; + } + } + break; + case INPUT_CastReady: + if (pCurrentScreen != SCREEN_GAME) + break; + if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == TE_MOVEMENT) + { + pTurnEngine->field_18 |= TE_FLAG_8; + break; + } + if ( !uActiveCharacter ) + break; + v9 = pPlayers[uActiveCharacter]->pActiveSkills[(unsigned __int8)pPlayers[uActiveCharacter]->uQuickSpell / 11 + 12]; + if ( !pPlayers[uActiveCharacter]->uQuickSpell || bUnderwater + || (( !(HIBYTE(v9) & 1)) ? + ((v9 & 0x80) == 0 ? + ((v9 & 0x40) == 0 ? spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uNormalLevelMana : spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uExpertLevelMana) : + spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uMasterLevelMana) : + spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uMagisterLevelMana, + spell_price > pPlayers[uActiveCharacter]->sMana) ) + { + pPartyActionQueue = pPartyActionQueue; + pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); + break; + } + else + pMessageQueue_50C9E8->AddMessage(UIMSG_CastQuickSpell, 0, 0); + break; + case INPUT_Attack: + if (pCurrentScreen != SCREEN_GAME) + break; + if (pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT) + { + pTurnEngine->field_18 |= TE_FLAG_8; + break; + } + pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); + break; + case INPUT_EventTrigger: + if (pCurrentScreen == SCREEN_GAME) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); + break; + } + if ( pCurrentScreen == SCREEN_NPC_DIALOGUE ) + { + if ( pMessageQueue_50CBD0->uNumMessages ) + { + pMessageQueue_50CBD0->uNumMessages = 0; + if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) + { + pMessageQueue_50CBD0->uNumMessages = 1; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 = 0; + ++pMessageQueue_50CBD0->uNumMessages; + break; + } + break; + } + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + } + break; + case INPUT_CharCycle: + if ( pCurrentScreen == SCREEN_SPELL_BOOK ) + break; + + pMessageQueue_50C9E8->AddMessage(UIMSG_CycleCharacters, 0, 0); + break; + case INPUT_LookUp: + if ( pEventTimer->bPaused ) + break; + partyAction = (PartyAction)7; + pPartyActionQueue->Add(partyAction); + break; + case INPUT_CenterView: + if ( pEventTimer->bPaused ) + break; + partyAction = (PartyAction)9; + pPartyActionQueue->Add(partyAction); + break; + case INPUT_LookDown: + if ( pEventTimer->bPaused ) + break; + partyAction = (PartyAction)8; + pPartyActionQueue->Add(partyAction); + break; + case INPUT_FlyUp: + if ( pCurrentScreen || pEventTimer->bPaused ) + break; + partyAction = (PartyAction)13; + pPartyActionQueue->Add(partyAction); + break; + case INPUT_Land: + if ( pCurrentScreen || pEventTimer->bPaused ) + break; + partyAction = (PartyAction)15; + pPartyActionQueue->Add(partyAction); + break; + case INPUT_FlyDown: + if ( !pCurrentScreen + && !pEventTimer->bPaused ) + { + partyAction = (PartyAction)14; + pPartyActionQueue->Add(partyAction); + } + break; + case INPUT_ZoomIn: + pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomOutBtn, 0, 0); + break; + case INPUT_ZoomOut: + pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomInBtn, 0, 0); + break; + case INPUT_AlwaysRun: + bAlwaysRun = bAlwaysRun == 0; + break; + default: + break; + } + } + } + } +}