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
|
#pragma once
#ifdef _WINDOWS64
struct SavedInventoryCursorPos
{
float x;
float y;
bool hasSavedPos;
};
extern SavedInventoryCursorPos g_savedInventoryCursorPos;
#endif
// Uncomment to enable tap input detection to jump 1 slot. Doesn't work particularly well yet, and I feel the system does not need it.
// Would probably be required if we decide to slow down the pointer movement.
// 4J Stu - There was a request to be able to navigate the scenes with the dpad, so I have used much of the TAP_DETECTION
// code as it worked well for that situation. This #define should still stop the same things happening when using the
// stick though when not defined
#define TAP_DETECTION
// Uncomment to enable acceleration on pointer input.
//#define USE_POINTER_ACCEL
#define POINTER_INPUT_TIMER_ID (0) // Arbitrary timer ID.
#define POINTER_SPEED_FACTOR (13.0f) // Speed of pointer.
//#define POINTER_PANEL_OVER_REACH (42.0f) // Amount beyond edge of panel which pointer can go over to drop items. - comes from the pointer size in the scene
#define MAX_INPUT_TICKS_FOR_SCALING (7)
#define MAX_INPUT_TICKS_FOR_TAPPING (15)
class AbstractContainerMenu;
class Slot;
class IUIScene_AbstractContainerMenu
{
protected:
// Sections of this scene containing items selectable by the pointer.
// 4J Stu - Always make the Using section the first one
enum ESceneSection
{
eSectionNone = -1,
eSectionContainerUsing = 0,
eSectionContainerInventory,
eSectionContainerChest,
eSectionContainerMax,
eSectionFurnaceUsing,
eSectionFurnaceInventory,
eSectionFurnaceIngredient,
eSectionFurnaceFuel,
eSectionFurnaceResult,
eSectionFurnaceMax,
eSectionInventoryUsing,
eSectionInventoryInventory,
eSectionInventoryArmor,
eSectionInventoryMax,
eSectionTrapUsing,
eSectionTrapInventory,
eSectionTrapTrap,
eSectionTrapMax,
eSectionInventoryCreativeUsing,
eSectionInventoryCreativeSelector,
eSectionInventoryCreativeTab_0,
eSectionInventoryCreativeTab_1,
eSectionInventoryCreativeTab_2,
eSectionInventoryCreativeTab_3,
eSectionInventoryCreativeTab_4,
eSectionInventoryCreativeTab_5,
eSectionInventoryCreativeTab_6,
eSectionInventoryCreativeTab_7,
eSectionInventoryCreativeSlider,
eSectionInventoryCreativeMax,
eSectionEnchantUsing,
eSectionEnchantInventory,
eSectionEnchantSlot,
eSectionEnchantButton1,
eSectionEnchantButton2,
eSectionEnchantButton3,
eSectionEnchantMax,
eSectionBrewingUsing,
eSectionBrewingInventory,
eSectionBrewingBottle1,
eSectionBrewingBottle2,
eSectionBrewingBottle3,
eSectionBrewingIngredient,
eSectionBrewingMax,
eSectionAnvilUsing,
eSectionAnvilInventory,
eSectionAnvilItem1,
eSectionAnvilItem2,
eSectionAnvilResult,
eSectionAnvilName,
eSectionAnvilMax,
eSectionBeaconUsing,
eSectionBeaconInventory,
eSectionBeaconItem,
eSectionBeaconPrimaryTierOneOne,
eSectionBeaconPrimaryTierOneTwo,
eSectionBeaconPrimaryTierTwoOne,
eSectionBeaconPrimaryTierTwoTwo,
eSectionBeaconPrimaryTierThree,
eSectionBeaconSecondaryOne,
eSectionBeaconSecondaryTwo,
eSectionBeaconConfirm,
eSectionBeaconMax,
eSectionHopperUsing,
eSectionHopperInventory,
eSectionHopperContents,
eSectionHopperMax,
eSectionHorseUsing,
eSectionHorseInventory,
eSectionHorseChest,
eSectionHorseArmor,
eSectionHorseSaddle,
eSectionHorseMax,
eSectionFireworksUsing,
eSectionFireworksInventory,
eSectionFireworksResult,
eSectionFireworksIngredients,
eSectionFireworksMax,
};
AbstractContainerMenu* m_menu;
bool m_autoDeleteMenu;
eTutorial_State m_previousTutorialState;
UIVec2D m_pointerPos;
bool m_bPointerDrivenByMouse;
// Offset from pointer image top left to centre (we use the centre as the actual pointer).
float m_fPointerImageOffsetX;
float m_fPointerImageOffsetY;
// Min and max extents for the pointer.
float m_fPointerMinX;
float m_fPointerMaxX;
float m_fPointerMinY;
float m_fPointerMaxY;
// Min and max extents of the panel.
float m_fPanelMinX;
float m_fPanelMaxX;
float m_fPanelMinY;
float m_fPanelMaxY;
int m_iConsectiveInputTicks;
// Used for detecting quick "taps" in a direction, should jump cursor to next slot.
enum ETapState
{
eTapStateNoInput = 0,
eTapStateUp,
eTapStateDown,
eTapStateLeft,
eTapStateRight,
eTapStateJump,
eTapNone
};
ETapState m_eCurrTapState;
ESceneSection m_eCurrSection;
int m_iCurrSlotX;
int m_iCurrSlotY;
#ifdef __ORBIS__
bool m_bFirstTouchStored[XUSER_MAX_COUNT]; // monitor the first position of a touch, so we can use relative distances of movement
UIVec2D m_oldvPointerPos;
UIVec2D m_oldvTouchPos;
// store the multipliers to map the UI window to the touchpad window
float m_fTouchPadMulX;
float m_fTouchPadMulY;
float m_fTouchPadDeadZoneX; // usese the multipliers
float m_fTouchPadDeadZoneY;
#endif
// ENum indexes of the first section for this scene, and 1+the last section
ESceneSection m_eFirstSection, m_eMaxSection;
// 4J - WESTY - Added for pointer prototype.
// Current tooltip settings.
EToolTipItem m_aeToolTipSettings[ eToolTipNumButtons ];
// 4J - WESTY - Added for pointer prototype.
// Indicates if pointer is outside UI window (used to drop items).
bool m_bPointerOutsideMenu;
Slot *m_lastPointerLabelSlot;
bool m_bSplitscreen;
bool m_bNavigateBack; // should we exit the xuiscenes or just navigate back on exit?
virtual bool IsSectionSlotList( ESceneSection eSection ) { return eSection != eSectionNone; }
virtual bool CanHaveFocus( ESceneSection eSection ) { return true; }
virtual bool IsVisible( ESceneSection eSection ) { return true; }
int GetSectionDimensions( ESceneSection eSection, int* piNumColumns, int* piNumRows );
virtual int getSectionColumns(ESceneSection eSection) = 0;
virtual int getSectionRows(ESceneSection eSection) = 0;
virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY ) = 0;
virtual void GetPositionOfSection( ESceneSection eSection, UIVec2D* pPosition ) = 0;
virtual void GetItemScreenData( ESceneSection eSection, int iItemIndex, UIVec2D* pPosition, UIVec2D* pSize ) = 0;
void updateSlotPosition( ESceneSection eSection, ESceneSection newSection, ETapState eTapDirection, int *piTargetX, int *piTargetY, int xOffset = 0, int yOffset = 0 );
#ifdef TAP_DETECTION
ETapState GetTapInputType( float fInputX, float fInputY );
#endif
// Current tooltip settings.
void SetToolTip( EToolTipButton eButton, EToolTipItem eItem );
void UpdateTooltips();
// 4J - WESTY - Added for pointer prototype.
void SetPointerOutsideMenu( bool bOutside ) { m_bPointerOutsideMenu = bOutside; }
void Initialize(int m_iPad, AbstractContainerMenu* menu, bool autoDeleteMenu, int startIndex,ESceneSection firstSection,ESceneSection maxSection, bool bNavigateBack=FALSE);
virtual void PlatformInitialize(int iPad, int startIndex) = 0;
virtual void InitDataAssociations(int iPad, AbstractContainerMenu *menu, int startIndex = 0) = 0;
void onMouseTick();
bool handleKeyDown(int iPad, int iAction, bool bRepeat);
virtual bool handleValidKeyPress(int iUserIndex, int buttonNum, BOOL quickKeyHeld);
virtual void handleOutsideClicked(int iPad, int buttonNum, BOOL quickKeyHeld);
virtual void handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey);
virtual void handleAdditionalKeyPress(int iAction);
virtual void handleSlotListClicked(ESceneSection eSection, int buttonNum, BOOL quickKeyHeld);
virtual void handleSectionClick(ESceneSection eSection) = 0;
void slotClicked(int slotId, int buttonNum, bool quickKey);
int getCurrentIndex(ESceneSection eSection);
virtual int getSectionStartOffset(ESceneSection eSection) = 0;
virtual bool doesSectionTreeHaveFocus(ESceneSection eSection) = 0;
virtual void setSectionFocus(ESceneSection eSection, int iPad) = 0;
virtual void setSectionSelectedSlot(ESceneSection eSection, int x, int y) = 0;
virtual void setFocusToPointer(int iPad) = 0;
virtual void SetPointerText(vector<HtmlString> *description, bool newSlot) = 0;
virtual vector<HtmlString> *GetSectionHoverText(ESceneSection eSection);
virtual shared_ptr<ItemInstance> getSlotItem(ESceneSection eSection, int iSlot) = 0;
virtual Slot *getSlot(ESceneSection eSection, int iSlot) = 0;
virtual bool isSlotEmpty(ESceneSection eSection, int iSlot) = 0;
virtual void adjustPointerForSafeZone() = 0;
virtual bool overrideTooltips(
ESceneSection sectionUnderPointer,
shared_ptr<ItemInstance> itemUnderPointer,
bool bIsItemCarried,
bool bSlotHasItem,
bool bCarriedIsSameAsSlot,
int iSlotStackSizeRemaining,
EToolTipItem &buttonA,
EToolTipItem &buttonX,
EToolTipItem &buttonY,
EToolTipItem &buttonRT,
EToolTipItem &buttonBack
) { return false; }
private:
bool IsSameItemAs(shared_ptr<ItemInstance> itemA, shared_ptr<ItemInstance> itemB);
int GetEmptyStackSpace(Slot *slot);
vector<HtmlString> *GetItemDescription(Slot *slot);
protected:
IUIScene_AbstractContainerMenu();
virtual ~IUIScene_AbstractContainerMenu();
public:
virtual int getPad() = 0;
virtual int getMovieWidth() = 0;
virtual int getMovieHeight() = 0;
virtual void getMouseToSWFScale(float &scaleX, float &scaleY) = 0;
};
|