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 "IUIController.h"
4#include "UIEnums.h"
5#include "UIGroup.h"
6
7class UIAbstractBitmapFont;
8class UIBitmapFont;
9class UITTFFont;
10class UIComponent_DebugUIConsole;
11class UIComponent_DebugUIMarketingGuide;
12class UIControl;
13
14// Base class for all shared functions between UIControllers
15class UIController : public IUIController
16{
17public:
18 static __int64 iggyAllocCount;
19
20 // MGH - added to prevent crash loading Iggy movies while the skins were being reloaded
21 static CRITICAL_SECTION ms_reloadSkinCS;
22 static bool ms_bReloadSkinCSInitialised;
23
24protected:
25 UIComponent_DebugUIConsole *m_uiDebugConsole;
26 UIComponent_DebugUIMarketingGuide *m_uiDebugMarketingGuide;
27
28private:
29 CRITICAL_SECTION m_navigationLock;
30
31 static const int UI_REPEAT_KEY_DELAY_MS = 300; // How long from press until the first repeat
32 static const int UI_REPEAT_KEY_REPEAT_RATE_MS = 100; // How long in between repeats
33 DWORD m_actionRepeatTimer[XUSER_MAX_COUNT][ACTION_MAX_MENU+1];
34
35 float m_fScreenWidth;
36 float m_fScreenHeight;
37 bool m_bScreenWidthSetup;
38
39 S32 m_tileOriginX, m_tileOriginY;
40
41 enum EFont
42 {
43 eFont_NotLoaded = 0,
44
45 eFont_Bitmap,
46 eFont_Japanese,
47 eFont_SimpChinese,
48 eFont_TradChinese,
49 eFont_Korean,
50
51 };
52
53 // 4J-JEV: It's important that currentFont == targetFont, unless updateCurrentLanguage is going to be called.
54 EFont m_eCurrentFont, m_eTargetFont;
55
56 // 4J-JEV: Behaves like navigateToHome when not ingame. When in-game, it closes all player scenes instead.
57 bool m_bCleanupOnReload;
58
59 EFont getFontForLanguage(int language);
60 UITTFFont *createFont(EFont fontLanguage);
61
62 UIAbstractBitmapFont *m_mcBitmapFont;
63 UITTFFont *m_mcTTFFont;
64 UIBitmapFont *m_moj7, *m_moj11;
65
66public:
67 void setCleanupOnReload();
68 void updateCurrentFont();
69
70
71private:
72 // 4J-PB - ui element type for PSVita touch control
73#ifdef __PSVITA__
74
75 typedef struct
76 {
77 UIControl *pControl;
78 S32 x1,y1,x2,y2;
79 }
80 UIELEMENT;
81 // E3 - Fine for now, but we need to make this better!
82 vector<UIELEMENT *> m_TouchBoxes[eUIGroup_COUNT][eUILayer_COUNT][eUIScene_COUNT];
83 bool m_bTouchscreenPressed;
84#endif
85 // 4J Stu - These should be in the order that they reference each other (i.e. they can only reference one with a lower value in the enum)
86 enum ELibraries
87 {
88 eLibrary_Platform,
89 eLibrary_GraphicsDefault,
90 eLibrary_GraphicsHUD,
91 eLibrary_GraphicsInGame,
92 eLibrary_GraphicsTooltips,
93 eLibrary_GraphicsLabels,
94 eLibrary_Labels,
95 eLibrary_InGame,
96 eLibrary_HUD,
97 eLibrary_Tooltips,
98 eLibrary_Default,
99
100#if ( defined(_WINDOWS64) )
101 // 4J Stu - Load the 720/480 skins so that we have something to fallback on during development
102#ifndef _FINAL_BUILD
103 eLibraryFallback_Platform,
104 eLibraryFallback_GraphicsDefault,
105 eLibraryFallback_GraphicsHUD,
106 eLibraryFallback_GraphicsInGame,
107 eLibraryFallback_GraphicsTooltips,
108 eLibraryFallback_GraphicsLabels,
109 eLibraryFallback_Labels,
110 eLibraryFallback_InGame,
111 eLibraryFallback_HUD,
112 eLibraryFallback_Tooltips,
113 eLibraryFallback_Default,
114#endif
115#endif
116
117 eLibrary_Count,
118 };
119
120 IggyLibrary m_iggyLibraries[eLibrary_Count];
121
122protected:
123 GDrawFunctions *gdraw_funcs;
124
125private:
126 HIGGYEXP iggy_explorer;
127 HIGGYPERFMON iggy_perfmon;
128 bool m_iggyPerfmonEnabled;
129
130 bool m_bMenuDisplayed[XUSER_MAX_COUNT]; // track each players menu displayed
131 bool m_bMenuToBeClosed[XUSER_MAX_COUNT]; // actioned at the end of the game loop
132 int m_iCountDown[XUSER_MAX_COUNT]; // ticks to block input
133
134 bool m_bCloseAllScenes[eUIGroup_COUNT];
135
136 int m_iPressStartQuadrantsMask;
137
138 C4JRender::eViewportType m_currentRenderViewport;
139 bool m_bCustomRenderPosition;
140
141 static DWORD m_dwTrialTimerLimitSecs;
142
143 unordered_map<wstring, byteArray> m_substitutionTextures;
144
145 typedef struct _CachedMovieData
146 {
147 byteArray m_ba;
148 __int64 m_expiry;
149 } CachedMovieData;
150 unordered_map<wstring, CachedMovieData> m_cachedMovieData;
151
152 typedef struct _QueuedMessageBoxData
153 {
154 MessageBoxInfo info;
155 int iPad;
156 EUILayer layer;
157 } QueuedMessageBoxData;
158 vector<QueuedMessageBoxData *> m_queuedMessageBoxData;
159
160 unsigned int m_winUserIndex;
161 //bool m_bSysUIShowing;
162 bool m_bSystemUIShowing;
163 C4JThread *m_reloadSkinThread;
164 bool m_navigateToHomeOnReload;
165 int m_accumulatedTicks;
166 __uint64 m_lastUiSfx; // Tracks time (ms) of last UI sound effect
167
168 D3D11_RECT m_customRenderingClearRect;
169
170 unordered_map<size_t, UIScene *> m_registeredCallbackScenes; // A collection of scenes and unique id's that are used in async callbacks so we can safely handle when they get destroyed
171 CRITICAL_SECTION m_registeredCallbackScenesCS;;
172
173public:
174 UIController();
175#ifdef __PSVITA__
176 void TouchBoxAdd(UIControl *pControl,UIScene *pUIScene);
177 bool TouchBoxHit(UIScene *pUIScene,S32 x, S32 y);
178 void TouchBoxesClear(UIScene *pUIScene);
179 void TouchBoxRebuild(UIScene *pUIScene);
180
181 void HandleTouchInput(unsigned int iPad, unsigned int key, bool bPressed, bool bRepeat, bool bReleased);
182 void SendTouchInput(unsigned int iPad, unsigned int key, bool bPressed, bool bRepeat, bool bReleased);
183
184 private:
185 void TouchBoxAdd(UIControl *pControl,EUIGroup eUIGroup,EUILayer eUILayer,EUIScene eUIscene, UIControl *pMainPanelControl);
186 UIELEMENT *m_ActiveUIElement;
187 UIELEMENT *m_HighlightedUIElement;
188#endif
189
190protected:
191 UIGroup *m_groups[eUIGroup_COUNT];
192
193public:
194 void showComponent(int iPad, EUIScene scene, EUILayer layer, EUIGroup group, bool show)
195 {
196 m_groups[group]->showComponent(iPad, scene, layer, show);
197 }
198
199 void removeComponent(EUIScene scene, EUILayer layer, EUIGroup group)
200 {
201 m_groups[group]->removeComponent(scene, layer);
202 }
203
204protected:
205 // Should be called from the platforms init function
206 void preInit(S32 width, S32 height);
207 void postInit();
208
209
210public:
211 CRITICAL_SECTION m_Allocatorlock;
212 void SetupFont();
213 bool PendingFontChange();
214 bool UsingBitmapFont();
215
216public:
217 // TICKING
218 virtual void tick();
219
220private:
221 void loadSkins();
222 IggyLibrary loadSkin(const wstring &skinPath, const wstring &skinName);
223
224public:
225 void ReloadSkin();
226 virtual void StartReloadSkinThread();
227 virtual bool IsReloadingSkin();
228 virtual bool IsExpectingOrReloadingSkin();
229 virtual void CleanUpSkinReload();
230
231private:
232 static int reloadSkinThreadProc(void* lpParam);
233
234public:
235 byteArray getMovieData(const wstring &filename);
236
237 // INPUT
238private:
239 void tickInput();
240 void handleInput();
241 void handleKeyPress(unsigned int iPad, unsigned int key);
242
243protected:
244 static rrbool RADLINK ExternalFunctionCallback( void * user_callback_data , Iggy * player , IggyExternalFunctionCallUTF16 * call );
245
246public:
247 // RENDERING
248 float getScreenWidth() { return m_fScreenWidth; }
249 float getScreenHeight() { return m_fScreenHeight; }
250
251 virtual void render() = 0;
252 void getRenderDimensions(C4JRender::eViewportType viewport, S32 &width, S32 &height);
253 void setupRenderPosition(C4JRender::eViewportType viewport);
254 void setupRenderPosition(S32 xOrigin, S32 yOrigin);
255
256 void SetSysUIShowing(bool bVal);
257 static void SetSystemUIShowing(LPVOID lpParam,bool bVal);
258
259protected:
260 virtual void setTileOrigin(S32 xPos, S32 yPos) = 0;
261
262public:
263
264 virtual CustomDrawData *setupCustomDraw(UIScene *scene, IggyCustomDrawCallbackRegion *region) = 0;
265 virtual CustomDrawData *calculateCustomDraw(IggyCustomDrawCallbackRegion *region) = 0;
266 virtual void endCustomDraw(IggyCustomDrawCallbackRegion *region) = 0;
267protected:
268 // Should be called from the platforms render function
269 void renderScenes();
270
271public:
272 virtual void beginIggyCustomDraw4J(IggyCustomDrawCallbackRegion *region, CustomDrawData *customDrawRegion) = 0;
273 void setupCustomDrawGameState();
274 void endCustomDrawGameState();
275 void setupCustomDrawMatrices(UIScene *scene, CustomDrawData *customDrawRegion);
276 void setupCustomDrawGameStateAndMatrices(UIScene *scene, CustomDrawData *customDrawRegion);
277 void endCustomDrawMatrices();
278 void endCustomDrawGameStateAndMatrices();
279
280protected:
281
282 static void RADLINK CustomDrawCallback(void *user_callback_data, Iggy *player, IggyCustomDrawCallbackRegion *Region);
283 static GDrawTexture * RADLINK TextureSubstitutionCreateCallback( void * user_callback_data , IggyUTF16 * texture_name , S32 * width , S32 * height , void **destroy_callback_data );
284 static void RADLINK TextureSubstitutionDestroyCallback( void * user_callback_data , void * destroy_callback_data , GDrawTexture * handle );
285
286 virtual GDrawTexture *getSubstitutionTexture(int textureId) { return NULL; }
287 virtual void destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle) {}
288
289public:
290 void registerSubstitutionTexture(const wstring &textureName, PBYTE pbData, DWORD dwLength);
291 void unregisterSubstitutionTexture(const wstring &textureName, bool deleteData);
292
293public:
294 // NAVIGATION
295 bool NavigateToScene(int iPad, EUIScene scene, void *initData = NULL, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD);
296 bool NavigateBack(int iPad, bool forceUsePad = false, EUIScene eScene = eUIScene_COUNT, EUILayer eLayer = eUILayer_COUNT);
297 void NavigateToHomeMenu();
298 UIScene *GetTopScene(int iPad, EUILayer layer = eUILayer_Scene, EUIGroup group = eUIGroup_PAD);
299
300 size_t RegisterForCallbackId(UIScene *scene);
301 void UnregisterCallbackId(size_t id);
302 UIScene *GetSceneFromCallbackId(size_t id);
303 void EnterCallbackIdCriticalSection();
304 void LeaveCallbackIdCriticalSection();
305
306private:
307 void setFullscreenMenuDisplayed(bool displayed);
308
309public:
310 void CloseAllPlayersScenes();
311 void CloseUIScenes(int iPad, bool forceIPad = false);
312
313 virtual bool IsPauseMenuDisplayed(int iPad);
314 virtual bool IsContainerMenuDisplayed(int iPad);
315 virtual bool IsIgnorePlayerJoinMenuDisplayed(int iPad);
316 virtual bool IsIgnoreAutosaveMenuDisplayed(int iPad);
317 virtual void SetIgnoreAutosaveMenuDisplayed(int iPad, bool displayed);
318 virtual bool IsSceneInStack(int iPad, EUIScene eScene);
319 bool GetMenuDisplayed(int iPad);
320 void SetMenuDisplayed(int iPad,bool bVal);
321 virtual void CheckMenuDisplayed();
322 void AnimateKeyPress(int iPad, int iAction, bool bRepeat, bool bPressed, bool bReleased);
323 void OverrideSFX(int iPad, int iAction,bool bVal);
324
325 // TOOLTIPS
326 virtual void SetTooltipText( unsigned int iPad, unsigned int tooltip, int iTextID );
327 virtual void SetEnableTooltips( unsigned int iPad, BOOL bVal );
328 virtual void ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show );
329 virtual void SetTooltips( unsigned int iPad, int iA, int iB=-1, int iX=-1, int iY=-1 , int iLT=-1, int iRT=-1, int iLB=-1, int iRB=-1, int iLS=-1, int iRS=-1, int iBack=-1, bool forceUpdate = false);
330 virtual void EnableTooltip( unsigned int iPad, unsigned int tooltip, bool enable );
331 virtual void RefreshTooltips(unsigned int iPad);
332
333 virtual void PlayUISFX(ESoundEffect eSound);
334
335 virtual void DisplayGamertag(unsigned int iPad, bool show);
336 virtual void SetSelectedItem(unsigned int iPad, const wstring &name);
337 virtual void UpdateSelectedItemPos(unsigned int iPad);
338
339 virtual void HandleDLCMountingComplete();
340 virtual void HandleDLCInstalled(int iPad);
341#ifdef _XBOX_ONE
342 virtual void HandleDLCLicenseChange();
343#endif
344 virtual void HandleTMSDLCFileRetrieved(int iPad);
345 virtual void HandleTMSBanFileRetrieved(int iPad);
346 virtual void HandleInventoryUpdated(int iPad);
347 virtual void HandleGameTick();
348
349 virtual void SetTutorial(int iPad, Tutorial *tutorial);
350 virtual void SetTutorialDescription(int iPad, TutorialPopupInfo *info);
351 virtual void RemoveInteractSceneReference(int iPad, UIScene *scene);
352 virtual void SetTutorialVisible(int iPad, bool visible);
353 virtual bool IsTutorialVisible(int iPad);
354
355 virtual void UpdatePlayerBasePositions();
356 virtual void SetEmptyQuadrantLogo(int iSection);
357 virtual void HideAllGameUIElements();
358 virtual void ShowOtherPlayersBaseScene(unsigned int iPad, bool show);
359
360 virtual void ShowTrialTimer(bool show);
361 virtual void SetTrialTimerLimitSecs(unsigned int uiSeconds);
362 virtual void UpdateTrialTimer(unsigned int iPad);
363 virtual void ReduceTrialTimerValue();
364
365 virtual void ShowAutosaveCountdownTimer(bool show);
366 virtual void UpdateAutosaveCountdownTimer(unsigned int uiSeconds);
367 virtual void ShowSavingMessage(unsigned int iPad, C4JStorage::ESavingMessage eVal);
368
369 virtual void ShowPlayerDisplayname(bool show);
370 virtual bool PressStartPlaying(unsigned int iPad);
371 virtual void ShowPressStart(unsigned int iPad);
372 virtual void HidePressStart();
373 void ClearPressStart();
374
375 virtual C4JStorage::EMessageResult RequestAlertMessage(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=NULL,LPVOID lpParam=NULL, WCHAR *pwchFormatString=NULL);
376 virtual C4JStorage::EMessageResult RequestErrorMessage(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=NULL,LPVOID lpParam=NULL, WCHAR *pwchFormatString=NULL);
377private:
378 virtual C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad,int( *Func)(LPVOID,int,const C4JStorage::EMessageResult),LPVOID lpParam, WCHAR *pwchFormatString,DWORD dwFocusButton, bool bIsError);
379
380public:
381 C4JStorage::EMessageResult RequestUGCMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = NULL, LPVOID lpParam = NULL);
382 C4JStorage::EMessageResult RequestContentRestrictedMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = NULL, LPVOID lpParam = NULL);
383
384 virtual void SetWinUserIndex(unsigned int iPad);
385 unsigned int GetWinUserIndex();
386
387 virtual void ShowUIDebugConsole(bool show);
388 virtual void ShowUIDebugMarketingGuide(bool show);
389 void logDebugString(const string &text);
390 UIScene* FindScene(EUIScene sceneType);
391
392public:
393 char *m_defaultBuffer, *m_tempBuffer;
394 void setFontCachingCalculationBuffer(int length);
395
396
397};