the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2using namespace std;
3#include "TutorialTask.h"
4#include "TutorialConstraint.h"
5#include "TutorialHint.h"
6#include "TutorialMessage.h"
7#include "TutorialEnum.h"
8
9// #define TUTORIAL_HINT_DELAY_TIME 14000 // How long we should wait from displaying one hint to the next
10// #define TUTORIAL_DISPLAY_MESSAGE_TIME 7000
11// #define TUTORIAL_MINIMUM_DISPLAY_MESSAGE_TIME 2000
12// #define TUTORIAL_REMINDER_TIME (TUTORIAL_DISPLAY_MESSAGE_TIME + 20000)
13// #define TUTORIAL_CONSTRAINT_DELAY_REMOVE_TICKS 15
14//
15// // 0-24000
16// #define TUTORIAL_FREEZE_TIME_VALUE 8000
17
18class Level;
19class CXuiScene;
20
21class Tutorial
22{
23public:
24 class PopupMessageDetails
25 {
26 public:
27 int m_messageId;
28 int m_promptId;
29 int m_titleId;
30 wstring m_messageString;
31 wstring m_promptString;
32 wstring m_titleString;
33 int m_icon;
34 int m_iAuxVal;
35 bool m_allowFade;
36 bool m_isReminder;
37 bool m_replaceCurrent;
38 bool m_forceDisplay;
39 bool m_delay;
40
41 PopupMessageDetails()
42 {
43 m_messageId = -1;
44 m_promptId = -1;
45 m_titleId = -1;
46 m_messageString = L"";
47 m_promptString = L"";
48 m_titleString = L"";
49 m_icon = TUTORIAL_NO_ICON;
50 m_iAuxVal = 0;
51 m_allowFade = true;
52 m_isReminder = false;
53 m_replaceCurrent = false;
54 m_forceDisplay = false;
55 m_delay = false;
56 }
57
58 bool isSameContent(PopupMessageDetails *other);
59
60 };
61
62private:
63 static int m_iTutorialHintDelayTime;
64 static int m_iTutorialDisplayMessageTime;
65 static int m_iTutorialMinimumDisplayMessageTime;
66 static int m_iTutorialExtraReminderTime;
67 static int m_iTutorialReminderTime;
68 static int m_iTutorialConstraintDelayRemoveTicks;
69 static int m_iTutorialFreezeTimeValue;
70 eTutorial_State m_CurrentState;
71 bool m_hasStateChanged;
72#ifdef _XBOX
73 HXUIOBJ m_hTutorialScene; // to store the popup scene (splitscreen or normal)
74#endif
75 bool m_bSceneIsSplitscreen;
76
77 bool m_bHasTickedOnce;
78 int m_firstTickTime;
79
80protected:
81 unordered_map<int, TutorialMessage *> messages;
82 vector<TutorialConstraint *> m_globalConstraints;
83 vector<TutorialConstraint *> constraints[e_Tutorial_State_Max];
84 vector< pair<TutorialConstraint *, unsigned char> > constraintsToRemove[e_Tutorial_State_Max];
85 vector<TutorialTask *> tasks; // We store a copy of the tasks for the main gameplay tutorial so that we could display an overview menu
86 vector<TutorialTask *> activeTasks[e_Tutorial_State_Max];
87 vector<TutorialHint *> hints[e_Tutorial_State_Max];
88 TutorialTask *currentTask[e_Tutorial_State_Max];
89 TutorialConstraint *currentFailedConstraint[e_Tutorial_State_Max];
90
91 bool m_freezeTime;
92 bool m_timeFrozen;
93 //D3DXVECTOR3 m_OriginalPosition;
94
95public:
96 DWORD lastMessageTime;
97 DWORD m_lastHintDisplayedTime;
98private:
99 PopupMessageDetails *m_lastMessage;
100
101 eTutorial_State m_lastMessageState;
102 unsigned int m_iTaskReminders;
103
104 bool m_allowShow;
105
106public:
107 bool m_hintDisplayed;
108
109private:
110 bool hasRequestedUI;
111 bool uiTempDisabled;
112
113#ifdef _XBOX
114 CXuiScene *m_UIScene;
115#else
116 UIScene *m_UIScene;
117#endif
118
119 int m_iPad;
120public:
121 bool m_allTutorialsComplete;
122 bool m_fullTutorialComplete;
123 bool m_isFullTutorial;
124public:
125 Tutorial(int iPad, bool isFullTutorial = false);
126 ~Tutorial();
127 void tick();
128
129 int getPad() { return m_iPad; }
130
131 virtual bool isStateCompleted( eTutorial_State state );
132 virtual void setStateCompleted( eTutorial_State state );
133 bool isHintCompleted( eTutorial_Hint hint );
134 void setHintCompleted( eTutorial_Hint hint );
135 void setHintCompleted( TutorialHint *hint );
136
137 // completableId will be either a eTutorial_State value or eTutorial_Hint
138 void setCompleted( int completableId );
139 bool getCompleted( int completableId );
140
141#ifdef _XBOX
142 void changeTutorialState(eTutorial_State newState, CXuiScene *scene = NULL);
143#else
144 void changeTutorialState(eTutorial_State newState, UIScene *scene = NULL);
145#endif
146 bool isSelectedItemState();
147
148 bool setMessage(PopupMessageDetails *message);
149 bool setMessage(TutorialHint *hint, PopupMessageDetails *message);
150 bool setMessage(const wstring &message, int icon, int auxValue);
151
152 void showTutorialPopup(bool show);
153
154 void useItemOn(Level *level, shared_ptr<ItemInstance> item, int x, int y, int z,bool bTestUseOnly=false);
155 void useItemOn(shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
156 void completeUsingItem(shared_ptr<ItemInstance> item);
157 void startDestroyBlock(shared_ptr<ItemInstance> item, Tile *tile);
158 void destroyBlock(Tile *tile);
159 void attack(shared_ptr<Player> player, shared_ptr<Entity> entity);
160 void itemDamaged(shared_ptr<ItemInstance> item);
161
162 void handleUIInput(int iAction);
163 void createItemSelected(shared_ptr<ItemInstance> item, bool canMake);
164 void onCrafted(shared_ptr<ItemInstance> item);
165 void onTake(shared_ptr<ItemInstance> item, unsigned int invItemCountAnyAux, unsigned int invItemCountThisAux);
166 void onSelectedItemChanged(shared_ptr<ItemInstance> item);
167 void onLookAt(int id, int iData=0);
168 void onLookAtEntity(shared_ptr<Entity> entity);
169 void onRideEntity(shared_ptr<Entity> entity);
170 void onEffectChanged(MobEffect *effect, bool bRemoved=false);
171
172 bool canMoveToPosition(double xo, double yo, double zo, double xt, double yt, double zt);
173 bool isInputAllowed(int mapping);
174
175 void AddGlobalConstraint(TutorialConstraint *c);
176 void AddConstraint(TutorialConstraint *c);
177 void RemoveConstraint(TutorialConstraint *c, bool delayedRemove = false);
178 void addTask(eTutorial_State state, TutorialTask *t);
179 void addHint(eTutorial_State state, TutorialHint *h);
180 void addMessage(int messageId, bool limitRepeats = false, unsigned char numRepeats = TUTORIAL_MESSAGE_DEFAULT_SHOW);
181
182 int GetTutorialDisplayMessageTime() {return m_iTutorialDisplayMessageTime;}
183
184 // Only for the main gameplay tutorial
185 vector<TutorialTask *> *getTasks();
186 unsigned int getCurrentTaskIndex();
187
188#ifdef _XBOX
189 CXuiScene *getScene() { return m_UIScene; }
190#else
191 UIScene *getScene() { return m_UIScene; }
192#endif
193 eTutorial_State getCurrentState() { return m_CurrentState; }
194
195 // These are required so that we have a consistent mapping of the completion bits stored in the profile data
196 static void staticCtor();
197 static vector<int> s_completableTasks;
198
199 static void debugResetPlayerSavedProgress(int iPad);
200};