#pragma once #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 #include #include "ParagraphBoxAnimationState.h" #include "VisualNovelParagraphBox.generated.h" // --------------------------------------------------------------------------------------------- // /// Event type used to signal when the visual novel box has finished an animation /// @remarks /// Parameter indicates whether the paragraph has finished its 'appear' animation /// or whether it has finished its 'disappear' animation DECLARE_DYNAMIC_DELEGATE_OneParam( FAnimationNotificationDelegate, EParagraphBoxAnimationState, animationState ); /// Event type used to signal when the player confirmed a visual novel box /// @remarks /// Parameter contains the index of a the choice made by the player or /// -1 if the displayed paragraph didn't provide any choices DECLARE_DYNAMIC_DELEGATE_OneParam(FConfirmParagraphDelegate, int32, choiceIndex); // --------------------------------------------------------------------------------------------- // // This class does not need to be modified. UINTERFACE(MinimalAPI, BlueprintType) class UVisualNovelParagraphBox : public UInterface { GENERATED_BODY() }; // --------------------------------------------------------------------------------------------- // /// Implemented by visual novel UI showing paragraphs and multiple-choice questions class NUCLEX_API IVisualNovelParagraphBox { GENERATED_BODY() /// Typedef for the UInterface, used by my custom cast method public: typedef UVisualNovelParagraphBox UInterfaceType; /// Retrieves the current animation state of the paragraph box /// @returns The paragraph box' current animation state public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="Visual Novel") EParagraphBoxAnimationState GetAnimationState(); /// Adds a subscriber that will be called back when the animation state changes /// @param callback Callback that will be invoked when the animation state changes public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="Visual Novel") void AddAnimationSubscriber(const FAnimationNotificationDelegate &callback); /// Removes a subscriber from callback list for when the animation state changes /// @param callback Callback that will be removed from the callback list public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="Visual Novel") void RemoveAnimationSubscriber(const FAnimationNotificationDelegate &callback); /// Adds a subscriber that will be called back when player confirms the paragraph /// @param callback Callback that will be invoked when the paragraph is confirmed public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="Visual Novel") void AddConfirmSubscriber(const FConfirmParagraphDelegate &callback); /// Removes a subscriber from callback list for when the paragraph is confirmed /// @param callback Callback that will be removed from the callback list public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="Visual Novel") void RemoveConfirmSubscriber(const FConfirmParagraphDelegate &callback); /// Displays the visual novel box with the specified paragraph /// @param speaker Speaker if the text is something being said by a character /// Can be an empty string if this is pure narration /// @param text Dialogue or narration that will be displayed as the paragraph /// @remarks If there is no animation, the callback should be invoked synchronously public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="Visual Novel") void ShowParagraph( const FString &speaker, const FString &text ); /// Displays the visual novel box and asks the player to make a choice /// @param speaker Speaker if the text is something being said by a character /// Can be an empty string if this is pure narration /// @param text Dialogue or narration that will be displayed as the paragraph /// @param firstChoiceText Text in the first choice available to the player /// @param secondChoiceText Text in the second choice available to the player /// @param thirdChoiceText Text in the third choice available to the player /// @remarks If there is no animation, the callback should be invoked synchronously public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="Visual Novel") void ShowChoices( const FString &speaker, const FString &text, const TArray &choices ); /// Closes the visual novel box /// @remarks If there is no animation, the callback should be invoked synchronously public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="Visual Novel") void Hide(); }; // --------------------------------------------------------------------------------------------- //