#pragma region CPL License /* Nuclex Unreal Module Copyright (C) 2014-2021 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library 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 IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #include "ShowParagraphAction.h" // --------------------------------------------------------------------------------------------- // FShowParagraphAction::FShowParagraphAction( const FLatentActionInfo &latentInfo, const TSharedPtr ¶graphBoxState, EDialogueChoice *selectedChoice ) : callbackTarget(latentInfo.CallbackTarget), executionFunction(latentInfo.ExecutionFunction), outputLink(latentInfo.Linkage), paragraphBoxState(paragraphBoxState), selectedChoice(selectedChoice) {} // --------------------------------------------------------------------------------------------- // void FShowParagraphAction::UpdateOperation(FLatentResponse &response) { if(this->paragraphBoxState.IsValid()) { if(!this->paragraphBoxState->Detached) { // Check if the player has confirmed the paragraph box. If the story controller // has been asked to also close the paragraph box, wait until its animation state // indicates that is has fully closed before completing bool isFinished = this->paragraphBoxState->Confirmed; if(isFinished && (!this->paragraphBoxState->KeepOpen)) { isFinished = ( this->paragraphBoxState->AnimationState == EParagraphBoxAnimationState::Hidden ); } // If this is a multiple-choice paragraph, select the Blueprint node's contiuation pin // via the choice made by the player if(isFinished) { if(this->selectedChoice != nullptr) { switch(this->paragraphBoxState->SelectedChoiceIndex) { case 0: { *this->selectedChoice = EDialogueChoice::Choice1; break; } case 1: { *this->selectedChoice = EDialogueChoice::Choice2; break; } case 2: { *this->selectedChoice = EDialogueChoice::Choice3; break; } case 3: { *this->selectedChoice = EDialogueChoice::Choice4; break; } case 4: { *this->selectedChoice = EDialogueChoice::Choice5; break; } default: { *this->selectedChoice = EDialogueChoice::Cancelled; break; } } } this->paragraphBoxState->IsLatentActionRunning = false; } response.FinishAndTriggerIf( isFinished, this->executionFunction, this->outputLink, this->callbackTarget ); // Make sure the default handler (which terminates the latent action without executing // any continuation pin) does not run. return; } // See below, but we also indicate that the latent action terminated if // the paragraph box state was still valid this->paragraphBoxState->IsLatentActionRunning = false; } // Paragraph box was detached or went bust (GC), so we quit, too response.DoneIf(true); } // --------------------------------------------------------------------------------------------- //