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