bool Dialog::HandleKeypress() { if(KeyboardHelper::UpPressed() && canNavigateBack) { if (filePath.length() > 0 && gVoiceVolume > 0) { stopDialog(); } Finish(); OnDirectlyNavigated(DirectNavigationDirectionBack); return true; } if(KeyboardHelper::DownPressed() && canNavigateForward) { if (filePath.length() > 0 && gVoiceVolume > 0) { stopDialog(); } Finish(); OnDirectlyNavigated(DirectNavigationDirectionForward); return true; } return false; }
void Dialog::OnEvidenceSelectorEvidencePresented(EvidenceSelector *pSender, const string &evidenceId) { if (pSender == pEvidenceSelector) { stopDialog(); evidencePresented = true; Finish(); OnEvidencePresented(evidenceId); } }
void Dialog::Finish(bool shouldPlaySfx) { pState->SetIsFinishingDialog(true); shouldPlaySfx = shouldPlaySfx && !pState->GetIsFastForwarding(); if (!dialogEventIteratorSet && !dialogEventList.empty()) { dialogEventIterator = dialogEventList.begin(); pCurrentDialogEvent = *dialogEventIterator; ++dialogEventIterator; dialogEventIteratorSet = true; } curTextPosition = GetText().length(); if (pCurrentDialogEvent != NULL) { while (curTextPosition >= pCurrentDialogEvent->GetPosition()) { if (pCurrentDialogEvent->GetShouldBeRaisedWhenFinishing() && (!pCurrentDialogEvent->PlaysSfx() || shouldPlaySfx)) { pCurrentDialogEvent->RaiseEvent(); } if (dialogEventIterator != dialogEventList.end()) { pCurrentDialogEvent = *dialogEventIterator; ++dialogEventIterator; } else { pCurrentDialogEvent = NULL; } if (pCurrentDialogEvent == NULL) { break; } } } stopDialog(); millisecondsUntilPauseCompletes = 0; millisecondsUntilAudioPauseCompletes = 0; lastPausePosition = -1; endRequested = true; }
void Dialog::Reset() { curTextPosition = 0; millisecondsUntilPauseCompletes = 0; millisecondsUntilAudioPauseCompletes = 0; dialogEventIterator = dialogEventList.end(); pCurrentDialogEvent = NULL; dialogEventIteratorSet = false; timeSinceLetterBlipPlayed = numeric_limits<double>::max(); textColorStack.clear(); textColorStack.push_back(TextColorNormal); lastTextColorChangeIndex = 0; pPressForInfoTab->Reset(); pPresentEvidenceTab->Reset(); pCurrentPartner = NULL; pUsePartnerTab->Reset(); pEndInterrogationTab->Reset(); pConversationDownArrow->Reset(); pInterrogationUpArrow->Reset(); pInterrogationDownArrow->Reset(); pEvidenceSelector->Reset(); EventProviders::GetEvidenceSelectorEventProvider()->ClearListener(this); evidencePresented = false; lastPausePosition = -1; textSkipped = false; if (pState != NULL) { pState->SetIsLeftCharacterTalking(false); pState->SetIsRightCharacterTalking(false); } pState = NULL; if (filePath.length() > 0 && gVoiceVolume > 0) { stopDialog(); } }
bool Dialog::HandleClick() { // If this dialog is automatic or static, then we'll ignore every click. if (GetIsAutomatic() || isStatic) { return false; } if (isInterrogation && !pEvidenceSelector->GetIsShowing() && !pState->WasInterjectionOngoing()) { if (!isPassive) { pPressForInfoTab->Update(); pPresentEvidenceTab->Update(); if (Case::GetInstance()->GetPartnerManager()->GetCurrentPartnerId().length() > 0 && pCurrentPartner->GetConversationAbilityName().length() > 0) { pUsePartnerTab->Update(); } } if (!isConfrontation || Confrontation::GetEnabledConfrontationTopicCount() > 1) { pEndInterrogationTab->Update(); } pInterrogationUpArrow->UpdateState(); pInterrogationDownArrow->UpdateState(); } else if (pEvidenceSelector->GetIsShowing()) { pEvidenceSelector->UpdateState(); return true; } else if (presentEvidenceAutomatically && !pEvidenceSelector->GetIsShowing() && GetIsReadyToProgress()) { // If the evidence selector is being shown automatically, is not presently showing, // and if the dialog is ready to progress, then the user must've canceled. // We'll ignore clicks in this case, since we're about to exit. return true; } if (!GetIsReadyToProgress()) { //SetTextSkipped(true); Finish(); return true; } else if ( pPressForInfoTab->GetIsClicked() || pPresentEvidenceTab->GetIsClicked() || pUsePartnerTab->GetIsClicked() || pEndInterrogationTab->GetIsClicked() || pInterrogationUpArrow->GetIsClicked() || pInterrogationDownArrow->GetIsClicked()) { if (pPressForInfoTab->GetIsClicked()) { if (filePath.length() > 0 && gVoiceVolume > 0) { stopDialog(); } Finish(); OnPressForInfoClicked(); pPressForInfoTab->SetIsClicked(false); } else if (pPresentEvidenceTab->GetIsClicked()) { pEvidenceSelector->Begin(); pEvidenceSelector->Show(); Confrontation *pConfrontation = pState->GetCurrentConfrontation(); if (pConfrontation != NULL) { pConfrontation->HideHealthIcons(); } pPresentEvidenceTab->SetIsClicked(false); } else if (pUsePartnerTab->GetIsClicked()) { if (filePath.length() > 0 && gVoiceVolume > 0) { stopDialog(); } Finish(); OnUsePartnerClicked(); pUsePartnerTab->SetIsClicked(false); } else if (pEndInterrogationTab->GetIsClicked()) { if (filePath.length() > 0 && gVoiceVolume > 0) { stopDialog(); } Finish(); OnEndRequested(); pEndInterrogationTab->SetIsClicked(false); } else if (pInterrogationUpArrow->GetIsClicked()) { if (filePath.length() > 0 && gVoiceVolume > 0) { stopDialog(); } Finish(); OnDirectlyNavigated(DirectNavigationDirectionBack); pInterrogationUpArrow->SetIsClicked(false); } else if (pInterrogationDownArrow->GetIsClicked()) { if (filePath.length() > 0 && gVoiceVolume > 0) { stopDialog(); } Finish(); OnDirectlyNavigated(DirectNavigationDirectionForward); pInterrogationDownArrow->SetIsClicked(false); } return true; } return false; }
void Encounter::Update(int delta) { bool formattingAnimationInProgress = false; if (pDialogBackgroundInEase->GetIsStarted() && !pDialogBackgroundInEase->GetIsFinished()) { pDialogBackgroundInEase->Update(delta); dialogBackgroundYPosition = (int)pDialogBackgroundInEase->GetCurrentValue(); formattingAnimationInProgress = true; } else if (pDialogBackgroundOutEase->GetIsStarted() && !pDialogBackgroundOutEase->GetIsFinished()) { pDialogBackgroundOutEase->Update(delta); dialogBackgroundYPosition = (int)pDialogBackgroundOutEase->GetCurrentValue(); formattingAnimationInProgress = true; } else if (pDialogBackgroundOutEase->GetIsFinished()) { // If the dialog background out animation has finished, // then this encounter as a whole is finished too. SetIsFinished(true); dialogBackgroundYPosition = (int)pDialogBackgroundOutEase->GetCurrentValue(); formattingAnimationInProgress = true; } else { dialogBackgroundYPosition = 0; } if (pBackgroundOpacityInEase->GetIsStarted() && !pBackgroundOpacityInEase->GetIsFinished()) { pBackgroundOpacityInEase->Update(delta); backgroundOpacityAlphaValue = (int)pBackgroundOpacityInEase->GetCurrentValue(); } else if (pBackgroundOpacityOutEase->GetIsStarted()) { pBackgroundOpacityOutEase->Update(delta); backgroundOpacityAlphaValue = (int)pBackgroundOpacityOutEase->GetCurrentValue(); } else { backgroundOpacityAlphaValue = 255; } pLeftCharacterInEase->Update(delta); pLeftCharacterOutEase->Update(delta); pRightCharacterInEase->Update(delta); pRightCharacterOutEase->Update(delta); // If a formatting animation is in progress, we want to ignore any mouse clicks. if (formattingAnimationInProgress) { MouseHelper::HandleClick(); } if (pEvidenceSelector->GetIsShowing()) { pEvidenceSelector->Update(delta); if (!pEvidenceSelector->GetIsShowing()) { if (pLastButtonArrayBeforeConversation->GetCount() > 0) { pNextButtonArray = pLastButtonArrayBeforeConversation; } else { pNextButtonArray = pMainMenuButtonArray; } pExitTab->SetIsHidden(false); pPresentEvidenceTab->SetIsHidden(false); SwapButtonArrays(); } } else if (pCurrentConversation != NULL && pDialogBackgroundInEase->GetIsFinished()) { if (state.GetCurrentAnimation() != NULL) { state.GetCurrentAnimation()->Update(delta); } if (state.GetLeftCharacterXOffsetEasingFunction() != NULL) { state.GetLeftCharacterXOffsetEasingFunction()->Update(delta); } if (state.GetRightCharacterXOffsetEasingFunction() != NULL) { state.GetRightCharacterXOffsetEasingFunction()->Update(delta); } EasingFunction *pWindowMotionXEase = state.GetWindowMotionXEasingFunction(); EasingFunction *pWindowMotionYEase = state.GetWindowMotionYEasingFunction(); if (pWindowMotionXEase != NULL && !pWindowMotionXEase->GetIsFinished()) { pWindowMotionXEase->Update(delta); } if (pWindowMotionYEase != NULL && !pWindowMotionYEase->GetIsFinished()) { pWindowMotionYEase->Update(delta); } pCurrentConversation->Update(delta); if (pCurrentConversation->GetIsFinished() && !formattingAnimationInProgress) { stopDialog(); bool shouldRunPresentWrongEvidenceConversation = pCurrentConversation->GetState()->GetPresentWrongEvidenceRequested(); bool exitRequested = state.GetExitRequested(); if (exitRequested) { SetTransitionRequest(state.GetTransitionRequest()); } pCurrentConversation->ResetState(); if (pCurrentConversation != GetOneShotConversation() && !exitRequested) { Conversation *pPresentWrongConversation = shouldRunPresentWrongEvidenceConversation ? (Case::GetInstance()->GetEvidenceManager()->IsEvidenceWithIdProfile(lastPresentedEvidenceId) ? pPresentWrongProfileConversation : pPresentWrongEvidenceConversation) : NULL; if (shouldRunPresentWrongEvidenceConversation && pPresentWrongConversation != NULL) { pCurrentConversation = pPresentWrongConversation; pCurrentConversation->Begin(&state); } else { Case::GetInstance()->GetAudioManager()->RestoreMusicVolumeForDialog(); Case::GetInstance()->GetAudioManager()->RestoreAmbianceVolumeForDialog(); pCurrentConversation = NULL; RefreshButtonArrayContents(); if (pLastButtonArrayBeforeConversation != NULL && pLastButtonArrayBeforeConversation->GetCount() > 0) { pNextButtonArray = pLastButtonArrayBeforeConversation; } else { pNextButtonArray = pMainMenuButtonArray; } pExitTab->SetIsHidden(false); pPresentEvidenceTab->SetIsHidden(false); SwapButtonArrays(); } } else { Case::GetInstance()->GetAudioManager()->RestoreMusicVolumeForDialog(); Case::GetInstance()->GetAudioManager()->RestoreAmbianceVolumeForDialog(); Close(); } } } else if (pCurrentConversation == NULL) { if (pCurrentButtonArray != NULL) { if (shouldCloseButtonArray) { pCurrentButtonArray->Close(); shouldCloseButtonArray = false; pExitTab->SetIsHidden(true); pPresentEvidenceTab->SetIsHidden(true); } pCurrentButtonArray->Update(delta); if (pCurrentButtonArray->GetIsClosed()) { if (pNextConversation != NULL) { BeginNextConversation(); } else { SwapButtonArrays(); // If the current button array is NULL, // that means we should show the // evidence selector. if (pCurrentButtonArray == NULL) { pEvidenceSelector->Begin(); pEvidenceSelector->Show(); } } } if (pCurrentButtonArray == pMainMenuButtonArray && !pEvidenceSelector->GetIsShowing()) { pExitTab->Update(); pExitTab->UpdatePosition(delta); if (pExitTab->GetIsClicked()) { Close(); } pPresentEvidenceTab->Update(); pPresentEvidenceTab->UpdatePosition(delta); if (pPresentEvidenceTab->GetIsClicked()) { PrepNextButtonArray(NULL, -1); } } } } Case::GetInstance()->GetDialogCharacterManager()->UpdateForState(&state, delta); if (state.GetCurrentSpeakerName().length() > 0) { pCharacterNameTab->SetText(state.GetCurrentSpeakerName()); pCharacterNameTab->SetIsHidden(false); } else { pCharacterNameTab->SetIsHidden(true); } pCharacterNameTab->UpdatePosition(delta); }