#pragma once // using namespace std; #include "TutorialTask.h" #include "TutorialConstraint.h" #include "TutorialHint.h" #include "TutorialMessage.h" #include "TutorialEnum.h" #include // #define TUTORIAL_HINT_DELAY_TIME 14000 // How long we should wait from // displaying one hint to the next #define TUTORIAL_DISPLAY_MESSAGE_TIME 7000 // #define TUTORIAL_MINIMUM_DISPLAY_MESSAGE_TIME 2000 // #define TUTORIAL_REMINDER_TIME (TUTORIAL_DISPLAY_MESSAGE_TIME + 20000) // #define TUTORIAL_CONSTRAINT_DELAY_REMOVE_TICKS 15 // // // 0-24000 // #define TUTORIAL_FREEZE_TIME_VALUE 8000 class Level; class CXuiScene; class Tutorial { public: class PopupMessageDetails { public: int m_messageId; int m_promptId; int m_titleId; std::wstring m_messageString; std::wstring m_promptString; std::wstring m_titleString; int m_icon; int m_iAuxVal; bool m_allowFade; bool m_isReminder; bool m_replaceCurrent; bool m_forceDisplay; bool m_delay; PopupMessageDetails() { m_messageId = -1; m_promptId = -1; m_titleId = -1; m_messageString = L""; m_promptString = L""; m_titleString = L""; m_icon = TUTORIAL_NO_ICON; m_iAuxVal = 0; m_allowFade = true; m_isReminder = false; m_replaceCurrent = false; m_forceDisplay = false; m_delay = false; } bool isSameContent(PopupMessageDetails* other); }; private: static int m_iTutorialHintDelayTime; static int m_iTutorialDisplayMessageTime; static int m_iTutorialMinimumDisplayMessageTime; static int m_iTutorialExtraReminderTime; static int m_iTutorialReminderTime; static int m_iTutorialConstraintDelayRemoveTicks; static int m_iTutorialFreezeTimeValue; eTutorial_State m_CurrentState; bool m_hasStateChanged; bool m_bSceneIsSplitscreen; bool m_bHasTickedOnce; int m_firstTickTime; protected: std::unordered_map messages; std::vector m_globalConstraints; std::vector constraints[e_Tutorial_State_Max]; std::vector > constraintsToRemove[e_Tutorial_State_Max]; std::vector tasks; // We store a copy of the tasks for the main gameplay tutorial // so that we could display an overview menu std::vector activeTasks[e_Tutorial_State_Max]; std::vector hints[e_Tutorial_State_Max]; TutorialTask* currentTask[e_Tutorial_State_Max]; TutorialConstraint* currentFailedConstraint[e_Tutorial_State_Max]; bool m_freezeTime; bool m_timeFrozen; // D3DXVECTOR3 m_OriginalPosition; public: std::uint32_t lastMessageTime; std::uint32_t m_lastHintDisplayedTime; private: PopupMessageDetails* m_lastMessage; eTutorial_State m_lastMessageState; unsigned int m_iTaskReminders; bool m_allowShow; public: bool m_hintDisplayed; private: bool hasRequestedUI; bool uiTempDisabled; UIScene* m_UIScene; int m_iPad; public: bool m_allTutorialsComplete; bool m_fullTutorialComplete; bool m_isFullTutorial; public: Tutorial(int iPad, bool isFullTutorial = false); virtual ~Tutorial(); void tick(); int getPad() { return m_iPad; } virtual bool isStateCompleted(eTutorial_State state); virtual void setStateCompleted(eTutorial_State state); bool isHintCompleted(eTutorial_Hint hint); void setHintCompleted(eTutorial_Hint hint); void setHintCompleted(TutorialHint* hint); // completableId will be either a eTutorial_State value or eTutorial_Hint void setCompleted(int completableId); bool getCompleted(int completableId); void changeTutorialState(eTutorial_State newState, UIScene* scene = nullptr); bool isSelectedItemState(); bool setMessage(PopupMessageDetails* message); bool setMessage(TutorialHint* hint, PopupMessageDetails* message); bool setMessage(const std::wstring& message, int icon, int auxValue); void showTutorialPopup(bool show); void useItemOn(Level* level, std::shared_ptr item, int x, int y, int z, bool bTestUseOnly = false); void useItemOn(std::shared_ptr item, bool bTestUseOnly = false); void completeUsingItem(std::shared_ptr item); void startDestroyBlock(std::shared_ptr item, Tile* tile); void destroyBlock(Tile* tile); void attack(std::shared_ptr player, std::shared_ptr entity); void itemDamaged(std::shared_ptr item); void handleUIInput(int iAction); void createItemSelected(std::shared_ptr item, bool canMake); void onCrafted(std::shared_ptr item); void onTake(std::shared_ptr item, unsigned int invItemCountAnyAux, unsigned int invItemCountThisAux); void onSelectedItemChanged(std::shared_ptr item); void onLookAt(int id, int iData = 0); void onLookAtEntity(std::shared_ptr entity); void onRideEntity(std::shared_ptr entity); void onEffectChanged(MobEffect* effect, bool bRemoved = false); bool canMoveToPosition(double xo, double yo, double zo, double xt, double yt, double zt); bool isInputAllowed(int mapping); void AddGlobalConstraint(TutorialConstraint* c); void AddConstraint(TutorialConstraint* c); void RemoveConstraint(TutorialConstraint* c, bool delayedRemove = false); void addTask(eTutorial_State state, TutorialTask* t); void addHint(eTutorial_State state, TutorialHint* h); void addMessage(int messageId, bool limitRepeats = false, unsigned char numRepeats = TUTORIAL_MESSAGE_DEFAULT_SHOW); int GetTutorialDisplayMessageTime() { return m_iTutorialDisplayMessageTime; } // Only for the main gameplay tutorial std::vector* getTasks(); unsigned int getCurrentTaskIndex(); UIScene* getScene() { return m_UIScene; } eTutorial_State getCurrentState() { return m_CurrentState; } // These are required so that we have a consistent mapping of the completion // bits stored in the profile data static void staticCtor(); static std::vector s_completableTasks; static void debugResetPlayerSavedProgress(int iPad); };