the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at master 277 lines 8.0 kB view raw
1#pragma once 2// 4J-PB - remove the inherits via dominance warnings 3#pragma warning( disable : 4250 ) 4using namespace std; 5// A scene map directly to an Iggy movie (or more accurately a collection of different sized movies) 6 7#include "UIEnums.h" 8#include "UIControl_Base.h" 9 10class ItemRenderer; 11class UILayer; 12 13// 4J Stu - Setup some defines for quickly mapping elements in the scene 14 15#define UI_BEGIN_MAP_ELEMENTS_AND_NAMES(parentClass) \ 16 virtual bool mapElementsAndNames() \ 17 { \ 18 parentClass::mapElementsAndNames(); \ 19 IggyValuePath *currentRoot = IggyPlayerRootPath ( getMovie() ); 20 21#define UI_END_MAP_ELEMENTS_AND_NAMES() \ 22 return true; \ 23 } 24 25#define UI_MAP_ELEMENT( var, name) \ 26 { var.setupControl(this, currentRoot , name ); m_controls.push_back(&var); } 27 28#define UI_BEGIN_MAP_CHILD_ELEMENTS( parent ) \ 29 { \ 30 IggyValuePath *lastRoot = currentRoot; \ 31 currentRoot = parent.getIggyValuePath(); 32 33#define UI_END_MAP_CHILD_ELEMENTS() \ 34 currentRoot = lastRoot; \ 35 } 36 37#define UI_MAP_NAME( var, name ) \ 38 { var = registerFastName(name); } 39 40class UIScene 41{ 42 friend class UILayer; 43public: 44 IggyValuePath *m_rootPath; 45 46private: 47 Iggy *swf; 48 IggyName m_funcRemoveObject, m_funcSlideLeft, m_funcSlideRight, m_funcSetSafeZone, m_funcSetFocus, m_funcHorizontalResizeCheck; 49 IggyName m_funcSetAlpha; 50 51 ItemRenderer *m_pItemRenderer; 52 unordered_map<wstring, IggyName> m_fastNames; 53 unordered_map<wstring, bool> m_registeredTextures; 54 55 typedef struct _TimerInfo 56 { 57 int duration; 58 int targetTime; 59 bool running; 60 } TimerInfo; 61 unordered_map<int,TimerInfo> m_timers; 62 63 int m_iFocusControl, m_iFocusChild; 64 float m_lastOpacity; 65 bool m_bUpdateOpacity; 66 bool m_bVisible; 67 bool m_bCanHandleInput; 68 UIScene *m_backScene; 69 70 size_t m_callbackUniqueId; 71 72public: 73 enum ESceneResolution 74 { 75 eSceneResolution_1080, 76 eSceneResolution_720, 77 eSceneResolution_480, 78 eSceneResolution_Vita, 79 }; 80 81protected: 82 ESceneResolution m_loadedResolution; 83 84 bool m_bIsReloading; 85 bool m_bFocussedOnce; 86 87 int m_movieWidth, m_movieHeight; 88 int m_renderWidth, m_renderHeight; 89 vector<UIControl *> m_controls; 90 91protected: 92 UILayer *m_parentLayer; 93 bool bHasFocus; 94 int m_iPad; 95 bool m_hasTickedOnce; 96 97public: 98 virtual Iggy *getMovie() { return swf; } 99 100 void destroyMovie(); 101 virtual void reloadMovie(bool force = false); 102 virtual bool needsReloaded(); 103 virtual bool hasMovie(); 104 virtual void updateSafeZone(); 105 106 int getRenderWidth() { return m_renderWidth; } 107 int getRenderHeight() { return m_renderHeight; } 108 109#ifdef __PSVITA__ 110 UILayer *GetParentLayer() {return m_parentLayer;} 111 EUIGroup GetParentLayerGroup() {return m_parentLayer->m_parentGroup->GetGroup();} 112 vector<UIControl *> *GetControls() {return &m_controls;} 113#endif 114 115protected: 116 virtual F64 getSafeZoneHalfHeight(); 117 virtual F64 getSafeZoneHalfWidth(); 118 void setSafeZone(S32 top, S32 bottom, S32 left, S32 right); 119 void doHorizontalResizeCheck(); 120 virtual wstring getMoviePath() = 0; 121 122 virtual bool mapElementsAndNames(); 123 void initialiseMovie(); 124 void loadMovie(); 125 126private: 127 void getDebugMemoryUseRecursive(const wstring &moviePath, IggyMemoryUseInfo &memoryInfo); 128 129public: 130 void PrintTotalMemoryUsage(__int64 &totalStatic, __int64 &totalDynamic); 131 132public: 133 UIScene(int iPad, UILayer *parentLayer); 134 virtual ~UIScene(); 135 136 virtual EUIScene getSceneType() = 0; 137 ESceneResolution getSceneResolution() { return m_loadedResolution; } 138 139 virtual void tick(); 140 141 IggyName registerFastName(const wstring &name); 142#ifdef __PSVITA__ 143 void SetFocusToElement(int iID); 144 void UpdateSceneControls(); 145#endif 146protected: 147 void addTimer(int id, int ms); 148 void killTimer(int id); 149 void tickTimers(); 150 TimerInfo* getTimer(int id) { return &m_timers[id]; } 151 virtual void handleTimerComplete(int id) {} 152 153public: 154 // FOCUS 155 // Returns true if this scene handles input 156 virtual bool stealsFocus() { return true; } 157 158 // Returns true if this scene has focus for the pad passed in 159 virtual bool hasFocus(int iPad) { return bHasFocus && iPad == m_iPad; } 160 161 void gainFocus(); 162 void loseFocus(); 163 164 virtual void updateTooltips(); 165 virtual void updateComponents() {} 166 virtual void handleGainFocus(bool navBack); 167 virtual void handleLoseFocus() {} 168 169 // Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden 170 virtual bool hidesLowerScenes() { return m_hasTickedOnce; } 171 172 // Returns true if this scene should block input to lower scenes (works like hidesLowerScenes but doesn't interfere with rendering) 173 virtual bool blocksInput() { return false; } 174 175 // returns main panel if controls are not living in the root 176 virtual UIControl* GetMainPanel(); 177 178 void removeControl( UIControl_Base *control, bool centreScene); 179 void slideLeft(); 180 void slideRight(); 181 182 // RENDERING 183 virtual void render(S32 width, S32 height, C4JRender::eViewportType viewpBort); 184 185 virtual void customDraw(IggyCustomDrawCallbackRegion *region); 186 187 void setOpacity(float percent); 188 void setVisible(bool visible); 189 bool isVisible() { return m_bVisible; } 190 191protected: 192 //void customDrawSlotControl(IggyCustomDrawCallbackRegion *region, int iPad, int iID, int iCount, int iAuxVal, float fAlpha, bool isFoil, bool bDecorations); 193 void customDrawSlotControl(IggyCustomDrawCallbackRegion *region, int iPad, shared_ptr<ItemInstance> item, float fAlpha, bool isFoil, bool bDecorations); 194 195 bool m_cacheSlotRenders; 196 bool m_needsCacheRendered; 197 int m_expectedCachedSlotCount; 198private: 199 typedef struct _CachedSlotDrawData 200 { 201 CustomDrawData *customDrawRegion; 202 shared_ptr<ItemInstance> item; 203 float fAlpha; 204 bool isFoil; 205 bool bDecorations; 206 } CachedSlotDrawData; 207 vector<CachedSlotDrawData *> m_cachedSlotDraw; 208 209 void _customDrawSlotControl(CustomDrawData *region, int iPad, shared_ptr<ItemInstance> item, float fAlpha, bool isFoil, bool bDecorations, bool usingCommandBuffer); 210 211public: 212 // INPUT 213 bool canHandleInput() { return m_bCanHandleInput; } 214 virtual bool allowRepeat(int key); 215 virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) {} 216 void externalCallback(IggyExternalFunctionCallUTF16 * call); 217 218 virtual void handleDestroy() {} 219protected: 220 void sendInputToMovie(int key, bool repeat, bool pressed, bool released); 221 virtual void handlePreReload() {} 222 virtual void handleReload() {} 223 virtual void handlePress(F64 controlId, F64 childId) {} 224 virtual void handleFocusChange(F64 controlId, F64 childId) {} 225 virtual void handleInitFocus(F64 controlId, F64 childId) {} 226 virtual void handleCheckboxToggled(F64 controlId, bool selected) {} 227 virtual void handleSliderMove(F64 sliderId, F64 currentValue) {} 228 virtual void handleAnimationEnd() {} 229 virtual void handleSelectionChanged(F64 selectedId) {} 230 virtual void handleRequestMoreData(F64 startIndex, bool up) {} 231 virtual void handleTouchBoxRebuild() {} 232private: 233 void _handleFocusChange(F64 controlId, F64 childId); 234 void _handleInitFocus(F64 controlId, F64 childId); 235 236 int convertGameActionToIggyKeycode(int action); 237 238public: 239 bool controlHasFocus(int iControlId); 240 bool controlHasFocus(UIControl_Base *control); 241 int getControlFocus(); 242 int getControlChildFocus(); 243 244 // NAVIGATION 245protected: 246 //void navigateForward(int iPad, EUIScene scene, void *initData = NULL); 247 void navigateBack(); 248 249public: 250 void setBackScene(UIScene *scene); 251 UIScene *getBackScene(); 252 virtual void HandleDLCMountingComplete() {} 253 virtual void HandleDLCInstalled() {} 254#ifdef _XBOX_ONE 255 virtual void HandleDLCLicenseChange() {} 256#endif 257 258 virtual void HandleMessage(EUIMessage message, void *data); 259 260 void registerSubstitutionTexture(const wstring &textureName, PBYTE pbData, DWORD dwLength, bool deleteData = false); 261 bool hasRegisteredSubstitutionTexture(const wstring &textureName); 262 263 virtual void handleUnlockFullVersion() {} 264 265 virtual void handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, bool bPressed, bool bRepeat, bool bReleased) {} 266 267 268protected: 269 270#ifdef _DURANGO 271 virtual long long getDefaultGtcButtons() { return _360_GTC_BACK; } 272#endif 273 274 size_t GetCallbackUniqueId(); 275 276 virtual bool isReadyToDelete(); 277};