the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 268 lines 9.0 kB view raw
1#pragma once 2 3// 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. 4// Would probably be required if we decide to slow down the pointer movement. 5// 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 6// code as it worked well for that situation. This #define should still stop the same things happening when using the 7// stick though when not defined 8#define TAP_DETECTION 9 10// Uncomment to enable acceleration on pointer input. 11//#define USE_POINTER_ACCEL 12 13#define POINTER_INPUT_TIMER_ID (0) // Arbitrary timer ID. 14#define POINTER_SPEED_FACTOR (13.0f) // Speed of pointer. 15//#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 16 17#define MAX_INPUT_TICKS_FOR_SCALING (7) 18#define MAX_INPUT_TICKS_FOR_TAPPING (15) 19 20class AbstractContainerMenu; 21class Slot; 22 23class IUIScene_AbstractContainerMenu 24{ 25protected: 26 // Sections of this scene containing items selectable by the pointer. 27 // 4J Stu - Always make the Using section the first one 28 enum ESceneSection 29 { 30 eSectionNone = -1, 31 eSectionContainerUsing = 0, 32 eSectionContainerInventory, 33 eSectionContainerChest, 34 eSectionContainerMax, 35 36 eSectionFurnaceUsing, 37 eSectionFurnaceInventory, 38 eSectionFurnaceIngredient, 39 eSectionFurnaceFuel, 40 eSectionFurnaceResult, 41 eSectionFurnaceMax, 42 43 eSectionInventoryUsing, 44 eSectionInventoryInventory, 45 eSectionInventoryArmor, 46 eSectionInventoryMax, 47 48 eSectionTrapUsing, 49 eSectionTrapInventory, 50 eSectionTrapTrap, 51 eSectionTrapMax, 52 53 eSectionInventoryCreativeUsing, 54 eSectionInventoryCreativeSelector, 55 eSectionInventoryCreativeTab_0, 56 eSectionInventoryCreativeTab_1, 57 eSectionInventoryCreativeTab_2, 58 eSectionInventoryCreativeTab_3, 59 eSectionInventoryCreativeTab_4, 60 eSectionInventoryCreativeTab_5, 61 eSectionInventoryCreativeTab_6, 62 eSectionInventoryCreativeTab_7, 63 eSectionInventoryCreativeSlider, 64 eSectionInventoryCreativeMax, 65 66 eSectionEnchantUsing, 67 eSectionEnchantInventory, 68 eSectionEnchantSlot, 69 eSectionEnchantButton1, 70 eSectionEnchantButton2, 71 eSectionEnchantButton3, 72 eSectionEnchantMax, 73 74 eSectionBrewingUsing, 75 eSectionBrewingInventory, 76 eSectionBrewingBottle1, 77 eSectionBrewingBottle2, 78 eSectionBrewingBottle3, 79 eSectionBrewingIngredient, 80 eSectionBrewingMax, 81 82 eSectionAnvilUsing, 83 eSectionAnvilInventory, 84 eSectionAnvilItem1, 85 eSectionAnvilItem2, 86 eSectionAnvilResult, 87 eSectionAnvilName, 88 eSectionAnvilMax, 89 90 eSectionBeaconUsing, 91 eSectionBeaconInventory, 92 eSectionBeaconItem, 93 eSectionBeaconPrimaryTierOneOne, 94 eSectionBeaconPrimaryTierOneTwo, 95 eSectionBeaconPrimaryTierTwoOne, 96 eSectionBeaconPrimaryTierTwoTwo, 97 eSectionBeaconPrimaryTierThree, 98 eSectionBeaconSecondaryOne, 99 eSectionBeaconSecondaryTwo, 100 eSectionBeaconConfirm, 101 eSectionBeaconMax, 102 103 eSectionHopperUsing, 104 eSectionHopperInventory, 105 eSectionHopperContents, 106 eSectionHopperMax, 107 108 eSectionHorseUsing, 109 eSectionHorseInventory, 110 eSectionHorseChest, 111 eSectionHorseArmor, 112 eSectionHorseSaddle, 113 eSectionHorseMax, 114 115 eSectionFireworksUsing, 116 eSectionFireworksInventory, 117 eSectionFireworksResult, 118 eSectionFireworksIngredients, 119 eSectionFireworksMax, 120 }; 121 122 AbstractContainerMenu* m_menu; 123 bool m_autoDeleteMenu; 124 125 eTutorial_State m_previousTutorialState; 126 127 UIVec2D m_pointerPos; 128 bool m_bPointerDrivenByMouse; 129 130 // Offset from pointer image top left to centre (we use the centre as the actual pointer). 131 float m_fPointerImageOffsetX; 132 float m_fPointerImageOffsetY; 133 134 // Min and max extents for the pointer. 135 float m_fPointerMinX; 136 float m_fPointerMaxX; 137 float m_fPointerMinY; 138 float m_fPointerMaxY; 139 140 // Min and max extents of the panel. 141 float m_fPanelMinX; 142 float m_fPanelMaxX; 143 float m_fPanelMinY; 144 float m_fPanelMaxY; 145 146 int m_iConsectiveInputTicks; 147 148 // Used for detecting quick "taps" in a direction, should jump cursor to next slot. 149 enum ETapState 150 { 151 eTapStateNoInput = 0, 152 eTapStateUp, 153 eTapStateDown, 154 eTapStateLeft, 155 eTapStateRight, 156 eTapStateJump, 157 eTapNone 158 }; 159 160 ETapState m_eCurrTapState; 161 ESceneSection m_eCurrSection; 162 int m_iCurrSlotX; 163 int m_iCurrSlotY; 164 165#ifdef __ORBIS__ 166 bool m_bFirstTouchStored[XUSER_MAX_COUNT]; // monitor the first position of a touch, so we can use relative distances of movement 167 UIVec2D m_oldvPointerPos; 168 UIVec2D m_oldvTouchPos; 169 // store the multipliers to map the UI window to the touchpad window 170 float m_fTouchPadMulX; 171 float m_fTouchPadMulY; 172 float m_fTouchPadDeadZoneX; // usese the multipliers 173 float m_fTouchPadDeadZoneY; 174 175 176#endif 177 178 // ENum indexes of the first section for this scene, and 1+the last section 179 ESceneSection m_eFirstSection, m_eMaxSection; 180 181 // 4J - WESTY - Added for pointer prototype. 182 // Current tooltip settings. 183 EToolTipItem m_aeToolTipSettings[ eToolTipNumButtons ]; 184 185 // 4J - WESTY - Added for pointer prototype. 186 // Indicates if pointer is outside UI window (used to drop items). 187 bool m_bPointerOutsideMenu; 188 Slot *m_lastPointerLabelSlot; 189 190 bool m_bSplitscreen; 191 bool m_bNavigateBack; // should we exit the xuiscenes or just navigate back on exit? 192 193 virtual bool IsSectionSlotList( ESceneSection eSection ) { return eSection != eSectionNone; } 194 virtual bool CanHaveFocus( ESceneSection eSection ) { return true; } 195 virtual bool IsVisible( ESceneSection eSection ) { return true; } 196 int GetSectionDimensions( ESceneSection eSection, int* piNumColumns, int* piNumRows ); 197 virtual int getSectionColumns(ESceneSection eSection) = 0; 198 virtual int getSectionRows(ESceneSection eSection) = 0; 199 virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY ) = 0; 200 virtual void GetPositionOfSection( ESceneSection eSection, UIVec2D* pPosition ) = 0; 201 virtual void GetItemScreenData( ESceneSection eSection, int iItemIndex, UIVec2D* pPosition, UIVec2D* pSize ) = 0; 202 void updateSlotPosition( ESceneSection eSection, ESceneSection newSection, ETapState eTapDirection, int *piTargetX, int *piTargetY, int xOffset = 0, int yOffset = 0 ); 203 204 #ifdef TAP_DETECTION 205 ETapState GetTapInputType( float fInputX, float fInputY ); 206 #endif 207 208 // Current tooltip settings. 209 void SetToolTip( EToolTipButton eButton, EToolTipItem eItem ); 210 void UpdateTooltips(); 211 212 // 4J - WESTY - Added for pointer prototype. 213 void SetPointerOutsideMenu( bool bOutside ) { m_bPointerOutsideMenu = bOutside; } 214 215 void Initialize(int m_iPad, AbstractContainerMenu* menu, bool autoDeleteMenu, int startIndex,ESceneSection firstSection,ESceneSection maxSection, bool bNavigateBack=FALSE); 216 virtual void PlatformInitialize(int iPad, int startIndex) = 0; 217 virtual void InitDataAssociations(int iPad, AbstractContainerMenu *menu, int startIndex = 0) = 0; 218 219 void onMouseTick(); 220 bool handleKeyDown(int iPad, int iAction, bool bRepeat); 221 virtual bool handleValidKeyPress(int iUserIndex, int buttonNum, BOOL quickKeyHeld); 222 virtual void handleOutsideClicked(int iPad, int buttonNum, BOOL quickKeyHeld); 223 virtual void handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey); 224 virtual void handleAdditionalKeyPress(int iAction); 225 virtual void handleSlotListClicked(ESceneSection eSection, int buttonNum, BOOL quickKeyHeld); 226 virtual void handleSectionClick(ESceneSection eSection) = 0; 227 void slotClicked(int slotId, int buttonNum, bool quickKey); 228 int getCurrentIndex(ESceneSection eSection); 229 virtual int getSectionStartOffset(ESceneSection eSection) = 0; 230 virtual bool doesSectionTreeHaveFocus(ESceneSection eSection) = 0; 231 virtual void setSectionFocus(ESceneSection eSection, int iPad) = 0; 232 virtual void setSectionSelectedSlot(ESceneSection eSection, int x, int y) = 0; 233 virtual void setFocusToPointer(int iPad) = 0; 234 virtual void SetPointerText(vector<HtmlString> *description, bool newSlot) = 0; 235 virtual vector<HtmlString> *GetSectionHoverText(ESceneSection eSection); 236 virtual shared_ptr<ItemInstance> getSlotItem(ESceneSection eSection, int iSlot) = 0; 237 virtual Slot *getSlot(ESceneSection eSection, int iSlot) = 0; 238 virtual bool isSlotEmpty(ESceneSection eSection, int iSlot) = 0; 239 virtual void adjustPointerForSafeZone() = 0; 240 241 virtual bool overrideTooltips( 242 ESceneSection sectionUnderPointer, 243 shared_ptr<ItemInstance> itemUnderPointer, 244 bool bIsItemCarried, 245 bool bSlotHasItem, 246 bool bCarriedIsSameAsSlot, 247 int iSlotStackSizeRemaining, 248 EToolTipItem &buttonA, 249 EToolTipItem &buttonX, 250 EToolTipItem &buttonY, 251 EToolTipItem &buttonRT, 252 EToolTipItem &buttonBack 253 ) { return false; } 254 255private: 256 bool IsSameItemAs(shared_ptr<ItemInstance> itemA, shared_ptr<ItemInstance> itemB); 257 int GetEmptyStackSpace(Slot *slot); 258 259 vector<HtmlString> *GetItemDescription(Slot *slot); 260 261protected: 262 263 IUIScene_AbstractContainerMenu(); 264 virtual ~IUIScene_AbstractContainerMenu(); 265 266public: 267 virtual int getPad() = 0; 268};