diff options
Diffstat (limited to 'Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp')
| -rw-r--r-- | Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp | 456 |
1 files changed, 240 insertions, 216 deletions
diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp index 29ddcf71..667431b2 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp @@ -21,6 +21,7 @@ IUIScene_AbstractContainerMenu::IUIScene_AbstractContainerMenu() m_pointerPos.x = 0.0f; m_pointerPos.y = 0.0f; + m_bPointerDrivenByMouse = false; } @@ -73,7 +74,7 @@ void IUIScene_AbstractContainerMenu::Initialize(int iPad, AbstractContainerMenu* m_iCurrSlotX = 0; m_iCurrSlotY = 0; #endif // TAP_DETECTION - // + // // for(int i=0;i<XUSER_MAX_COUNT;i++) // { // m_bFirstTouchStored[i]=false; @@ -101,10 +102,10 @@ int IUIScene_AbstractContainerMenu::GetSectionDimensions( ESceneSection eSection *piNumRows = 0; *piNumColumns = 0; } - return( ( *piNumRows ) * ( *piNumColumns ) ); + return( ( *piNumRows ) * ( *piNumColumns ) ); } -void IUIScene_AbstractContainerMenu::updateSlotPosition( ESceneSection eSection, ESceneSection newSection, ETapState eTapDirection, int *piTargetX, int *piTargetY, int xOffset ) +void IUIScene_AbstractContainerMenu::updateSlotPosition( ESceneSection eSection, ESceneSection newSection, ETapState eTapDirection, int *piTargetX, int *piTargetY, int xOffset, int yOffset ) { // Update the target slot based on the size of the current section int columns, rows; @@ -124,10 +125,19 @@ void IUIScene_AbstractContainerMenu::updateSlotPosition( ESceneSection eSection, { (*piTargetY) = 0; } - if( (*piTargetY) < 0 ) + int offsetY = (*piTargetY) - yOffset; + if( offsetY < 0 ) { (*piTargetY) = 0; } + else if(offsetY >= rows) + { + (*piTargetY) = rows - 1; + } + else + { + (*piTargetY) = offsetY; + } // Update X int offsetX = (*piTargetX) - xOffset; @@ -205,7 +215,7 @@ void IUIScene_AbstractContainerMenu::SetToolTip( EToolTipButton eButton, EToolTi void IUIScene_AbstractContainerMenu::UpdateTooltips() { // Table gives us text id for tooltip. - static const DWORD kaToolTipextIds[ eNumToolTips ] = + static const DWORD kaToolTipextIds[ eNumToolTips ] = { IDS_TOOLTIPS_PICKUPPLACE, //eToolTipPickupPlace_OLD IDS_TOOLTIPS_EXIT, // eToolTipExit @@ -307,7 +317,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() float fNewX=(((float)pTouchPadData->touch[0].x)-m_oldvTouchPos.x) * m_fTouchPadMulX; float fNewY=(((float)pTouchPadData->touch[0].y)-m_oldvTouchPos.y) * m_fTouchPadMulY; - // relative positions - needs a deadzone + // relative positions - needs a deadzone if(fNewX>m_fTouchPadDeadZoneX) { @@ -320,11 +330,11 @@ void IUIScene_AbstractContainerMenu::onMouseTick() if(fNewY>m_fTouchPadDeadZoneY) { - vPointerPos.y=m_oldvPointerPos.y+((fNewY-m_fTouchPadDeadZoneY)*((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InMenu)/100.0f)); + vPointerPos.y=m_oldvPointerPos.y+((fNewY-m_fTouchPadDeadZoneY)*((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InMenu)/100.0f)); } else if(fNewY<-m_fTouchPadDeadZoneY) { - vPointerPos.y=m_oldvPointerPos.y+((fNewY+m_fTouchPadDeadZoneY)*((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InMenu)/100.0f)); + vPointerPos.y=m_oldvPointerPos.y+((fNewY+m_fTouchPadDeadZoneY)*((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InMenu)/100.0f)); } // Clamp to pointer extents. @@ -334,130 +344,131 @@ void IUIScene_AbstractContainerMenu::onMouseTick() else if ( vPointerPos.y > m_fPointerMaxY ) vPointerPos.y = m_fPointerMaxY; bStickInput = true; - m_eCurrTapState=eTapStateNoInput; + m_eCurrTapState=eTapStateNoInput; } else { // reset the touch flag m_bFirstTouchStored[iPad]=false; - + #endif - // If there is any input on sticks, move the pointer. - if ( ( fabs( fInputX ) >= 0.01f ) || ( fabs( fInputY ) >= 0.01f ) ) - { - fInputDirX = ( fInputX > 0.0f ) ? 1.0f : ( fInputX < 0.0f )?-1.0f : 0.0f; - fInputDirY = ( fInputY > 0.0f ) ? 1.0f : ( fInputY < 0.0f )?-1.0f : 0.0f; + // If there is any input on sticks, move the pointer. + if ( ( fabs( fInputX ) >= 0.01f ) || ( fabs( fInputY ) >= 0.01f ) ) + { + m_bPointerDrivenByMouse = false; + fInputDirX = ( fInputX > 0.0f ) ? 1.0f : ( fInputX < 0.0f )?-1.0f : 0.0f; + fInputDirY = ( fInputY > 0.0f ) ? 1.0f : ( fInputY < 0.0f )?-1.0f : 0.0f; #ifdef TAP_DETECTION - // Check for potential tap input to jump slot. - ETapState eNewTapInput = GetTapInputType( fInputX, fInputY ); + // Check for potential tap input to jump slot. + ETapState eNewTapInput = GetTapInputType( fInputX, fInputY ); - switch( m_eCurrTapState ) + switch( m_eCurrTapState ) + { + case eTapStateNoInput: + m_eCurrTapState = eNewTapInput; + break; + + case eTapStateUp: + case eTapStateDown: + case eTapStateLeft: + case eTapStateRight: + if ( ( eNewTapInput != m_eCurrTapState ) && ( eNewTapInput != eTapStateNoInput ) ) { - case eTapStateNoInput: - m_eCurrTapState = eNewTapInput; - break; - - case eTapStateUp: - case eTapStateDown: - case eTapStateLeft: - case eTapStateRight: - if ( ( eNewTapInput != m_eCurrTapState ) && ( eNewTapInput != eTapStateNoInput ) ) - { - // Input is no longer suitable for tap. - m_eCurrTapState = eTapNone; - } - break; - - case eTapNone: - /// Nothing to do, input is not a tap. - break; + // Input is no longer suitable for tap. + m_eCurrTapState = eTapNone; } + break; + + case eTapNone: + /// Nothing to do, input is not a tap. + break; + } #endif // TAP_DETECTION - // Square it so we get more precision for small inputs. - fInputX = fInputX * fInputX * fInputDirX * POINTER_SPEED_FACTOR; - fInputY = fInputY * fInputY * fInputDirY * POINTER_SPEED_FACTOR; - //fInputX = fInputX * POINTER_SPEED_FACTOR; - //fInputY = fInputY * POINTER_SPEED_FACTOR; - float fInputScale = 1.0f; + // Square it so we get more precision for small inputs. + fInputX = fInputX * fInputX * fInputDirX * POINTER_SPEED_FACTOR; + fInputY = fInputY * fInputY * fInputDirY * POINTER_SPEED_FACTOR; + //fInputX = fInputX * POINTER_SPEED_FACTOR; + //fInputY = fInputY * POINTER_SPEED_FACTOR; + float fInputScale = 1.0f; - // Ramp up input from zero when new input is recieved over INPUT_TICKS_FOR_SCALING ticks. This is to try to improve tapping stick to move 1 box. - if ( m_iConsectiveInputTicks < MAX_INPUT_TICKS_FOR_SCALING ) - { - ++m_iConsectiveInputTicks; - fInputScale = ( (float)( m_iConsectiveInputTicks) / (float)(MAX_INPUT_TICKS_FOR_SCALING) ); - } + // Ramp up input from zero when new input is recieved over INPUT_TICKS_FOR_SCALING ticks. This is to try to improve tapping stick to move 1 box. + if ( m_iConsectiveInputTicks < MAX_INPUT_TICKS_FOR_SCALING ) + { + ++m_iConsectiveInputTicks; + fInputScale = ( (float)( m_iConsectiveInputTicks) / (float)(MAX_INPUT_TICKS_FOR_SCALING) ); + } #ifdef TAP_DETECTION - else if ( m_iConsectiveInputTicks < MAX_INPUT_TICKS_FOR_TAPPING ) - { - ++m_iConsectiveInputTicks; - } - else - { - m_eCurrTapState = eTapNone; - } + else if ( m_iConsectiveInputTicks < MAX_INPUT_TICKS_FOR_TAPPING ) + { + ++m_iConsectiveInputTicks; + } + else + { + m_eCurrTapState = eTapNone; + } #endif - // 4J Stu - The cursor moves too fast in SD mode - // The SD/splitscreen scenes are approximately 0.6 times the size of the fullscreen on - if(!RenderManager.IsHiDef() || app.GetLocalPlayerCount() > 1) fInputScale *= 0.6f; + // 4J Stu - The cursor moves too fast in SD mode + // The SD/splitscreen scenes are approximately 0.6 times the size of the fullscreen on + if(!RenderManager.IsHiDef() || app.GetLocalPlayerCount() > 1) fInputScale *= 0.6f; - fInputX *= fInputScale; - fInputY *= fInputScale; + fInputX *= fInputScale; + fInputY *= fInputScale; #ifdef USE_POINTER_ACCEL - m_fPointerAccelX += fInputX / 50.0f; - m_fPointerAccelY += fInputY / 50.0f; + m_fPointerAccelX += fInputX / 50.0f; + m_fPointerAccelY += fInputY / 50.0f; - if ( fabsf( fInputX ) > fabsf( m_fPointerVelX + m_fPointerAccelX ) ) - { - m_fPointerVelX += m_fPointerAccelX; - } - else - { - m_fPointerAccelX = fInputX - m_fPointerVelX; - m_fPointerVelX = fInputX; - } + if ( fabsf( fInputX ) > fabsf( m_fPointerVelX + m_fPointerAccelX ) ) + { + m_fPointerVelX += m_fPointerAccelX; + } + else + { + m_fPointerAccelX = fInputX - m_fPointerVelX; + m_fPointerVelX = fInputX; + } - if ( fabsf( fInputY ) > fabsf( m_fPointerVelY + m_fPointerAccelY ) ) - { - m_fPointerVelY += m_fPointerAccelY; - } - else - { - m_fPointerAccelY = fInputY - m_fPointerVelY; - m_fPointerVelY = fInputY; - } - //printf( "IN %.2f VEL %.2f ACC %.2f\n", fInputY, m_fPointerVelY, m_fPointerAccelY ); + if ( fabsf( fInputY ) > fabsf( m_fPointerVelY + m_fPointerAccelY ) ) + { + m_fPointerVelY += m_fPointerAccelY; + } + else + { + m_fPointerAccelY = fInputY - m_fPointerVelY; + m_fPointerVelY = fInputY; + } + //printf( "IN %.2f VEL %.2f ACC %.2f\n", fInputY, m_fPointerVelY, m_fPointerAccelY ); - vPointerPos.x += m_fPointerVelX; - vPointerPos.y -= m_fPointerVelY; + vPointerPos.x += m_fPointerVelX; + vPointerPos.y -= m_fPointerVelY; #else - // Add input to pointer position. - vPointerPos.x += fInputX; - vPointerPos.y -= fInputY; + // Add input to pointer position. + vPointerPos.x += fInputX; + vPointerPos.y -= fInputY; #endif - // Clamp to pointer extents. - if ( vPointerPos.x < m_fPointerMinX ) vPointerPos.x = m_fPointerMinX; - else if ( vPointerPos.x > m_fPointerMaxX ) vPointerPos.x = m_fPointerMaxX; - if ( vPointerPos.y < m_fPointerMinY ) vPointerPos.y = m_fPointerMinY; - else if ( vPointerPos.y > m_fPointerMaxY ) vPointerPos.y = m_fPointerMaxY; + // Clamp to pointer extents. + if ( vPointerPos.x < m_fPointerMinX ) vPointerPos.x = m_fPointerMinX; + else if ( vPointerPos.x > m_fPointerMaxX ) vPointerPos.x = m_fPointerMaxX; + if ( vPointerPos.y < m_fPointerMinY ) vPointerPos.y = m_fPointerMinY; + else if ( vPointerPos.y > m_fPointerMaxY ) vPointerPos.y = m_fPointerMaxY; - bStickInput = true; - } - else - { - m_iConsectiveInputTicks = 0; + bStickInput = true; + } + else + { + m_iConsectiveInputTicks = 0; #ifdef USE_POINTER_ACCEL - m_fPointerVelX = 0.0f; - m_fPointerVelY = 0.0f; - m_fPointerAccelX = 0.0f; - m_fPointerAccelY = 0.0f; + m_fPointerVelX = 0.0f; + m_fPointerVelY = 0.0f; + m_fPointerAccelX = 0.0f; + m_fPointerAccelY = 0.0f; #endif - } + } #ifdef __ORBIS__ } @@ -501,7 +512,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() ( vPointerPos.y >= sectionPos.y ) && ( vPointerPos.y <= itemMax.y ) ) { // Pointer is over this control! - eSectionUnderPointer = eSection; + eSectionUnderPointer = eSection; vSnapPos.x = itemPos.x + ( itemSize.x / 2.0f ); vSnapPos.y = itemPos.y + ( itemSize.y / 2.0f ); @@ -589,8 +600,11 @@ void IUIScene_AbstractContainerMenu::onMouseTick() } } + // 4J - TomK - set to section none if this is a non-visible section + if(!IsVisible(eSectionUnderPointer)) eSectionUnderPointer = eSectionNone; + // If we are not over any slot, set focus elsewhere. - if ( eSectionUnderPointer == eSectionNone ) + if ( eSectionUnderPointer == eSectionNone ) { setFocusToPointer( getPad() ); #ifdef TAP_DETECTION @@ -680,7 +694,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() // If there is no stick input, and we are over a slot, then snap pointer to slot centre. // 4J - TomK - only if this particular component allows so! - if(CanHaveFocus(eSectionUnderPointer)) + if(!m_bPointerDrivenByMouse && CanHaveFocus(eSectionUnderPointer)) { vPointerPos.x = vSnapPos.x; vPointerPos.y = vSnapPos.y; @@ -768,20 +782,26 @@ void IUIScene_AbstractContainerMenu::onMouseTick() if( bPointerIsOverSlot && bSlotHasItem ) { - vector<wstring> unformattedStrings; - wstring desc = GetItemDescription( slot, unformattedStrings ); - SetPointerText(desc, unformattedStrings, slot != m_lastPointerLabelSlot); + vector<HtmlString> *desc = GetItemDescription(slot); + SetPointerText(desc, slot != m_lastPointerLabelSlot); m_lastPointerLabelSlot = slot; + delete desc; + } + else if (eSectionUnderPointer != eSectionNone && !IsSectionSlotList(eSectionUnderPointer) ) + { + vector<HtmlString> *desc = GetSectionHoverText(eSectionUnderPointer); + SetPointerText(desc, false); + m_lastPointerLabelSlot = NULL; + delete desc; } else { - vector<wstring> unformattedStrings; - SetPointerText(L"", unformattedStrings, false); + SetPointerText(NULL, false); m_lastPointerLabelSlot = NULL; } - EToolTipItem buttonA, buttonX, buttonY, buttonRT; - buttonA = buttonX = buttonY = buttonRT = eToolTipNone; + EToolTipItem buttonA, buttonX, buttonY, buttonRT, buttonBack; + buttonA = buttonX = buttonY = buttonRT = buttonBack = eToolTipNone; if ( bPointerIsOverSlot ) { SetPointerOutsideMenu( false ); @@ -790,7 +810,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() if ( bSlotHasItem ) { // Item in hand and item in slot ... is item in slot the same as in out hand? If so, can we stack on to it? - if ( bCarriedIsSameAsSlot ) + if ( bCarriedIsSameAsSlot ) { // Can we stack more into this slot? if ( iSlotStackSizeRemaining == 0 ) @@ -865,13 +885,22 @@ void IUIScene_AbstractContainerMenu::onMouseTick() if ( iSlotCount == 1 ) { buttonA = eToolTipPickUpGeneric; - buttonRT = eToolTipWhatIsThis; } else { // Multiple items in slot. buttonA = eToolTipPickUpAll; buttonX = eToolTipPickUpHalf; + } + +#ifdef __PSVITA__ + if (!InputManager.IsVitaTV()) + { + buttonBack = eToolTipWhatIsThis; + } + else +#endif + { buttonRT = eToolTipWhatIsThis; } } @@ -919,7 +948,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() else { buttonY = eToolTipQuickMove; - } + } break; case ArmorRecipes::eArmorType_Leggings: if(isSlotEmpty(eSectionInventoryArmor,2)) @@ -1051,7 +1080,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() bool bValidIngredient=false; //bool bValidIngredientBottom=false; - if(Item::items[iId]->hasPotionBrewingFormula() || (iId == Item::netherStalkSeeds_Id)) + if(Item::items[iId]->hasPotionBrewingFormula() || (iId == Item::netherwart_seeds_Id)) { bValidIngredient=true; } @@ -1077,15 +1106,15 @@ void IUIScene_AbstractContainerMenu::onMouseTick() // ingredient slot empty buttonY = eToolTipQuickMoveIngredient; } - } + } else { // valid potion? Glass bottle with water in it is a 'potion' too. if(iId==Item::potion_Id) { // space available? - if(isSlotEmpty(eSectionBrewingBottle1,0) || - isSlotEmpty(eSectionBrewingBottle2,0) || + if(isSlotEmpty(eSectionBrewingBottle1,0) || + isSlotEmpty(eSectionBrewingBottle2,0) || isSlotEmpty(eSectionBrewingBottle3,0)) { buttonY = eToolTipQuickMoveIngredient; @@ -1112,8 +1141,8 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { // is there already something in the ingredient slot? if(isSlotEmpty(eSectionEnchantSlot,0)) - { - // tool slot empty + { + // tool slot empty switch(iId) { case Item::bow_Id: @@ -1124,10 +1153,10 @@ void IUIScene_AbstractContainerMenu::onMouseTick() buttonY=eToolTipQuickMoveWeapon; break; - case Item::helmet_cloth_Id: - case Item::chestplate_cloth_Id: - case Item::leggings_cloth_Id: - case Item::boots_cloth_Id: + case Item::helmet_leather_Id: + case Item::chestplate_leather_Id: + case Item::leggings_leather_Id: + case Item::boots_leather_Id: case Item::helmet_chain_Id: case Item::chestplate_chain_Id: @@ -1155,7 +1184,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick() buttonY = eToolTipQuickMove; break; default: - buttonY=eToolTipQuickMoveTool; + buttonY=eToolTipQuickMoveTool; break; } } @@ -1163,10 +1192,10 @@ void IUIScene_AbstractContainerMenu::onMouseTick() { buttonY = eToolTipQuickMove; } - } + } else { - buttonY=eToolTipQuickMove; + buttonY=eToolTipQuickMove; } } else @@ -1201,13 +1230,13 @@ void IUIScene_AbstractContainerMenu::onMouseTick() shared_ptr<ItemInstance> item = nullptr; if(bPointerIsOverSlot && bSlotHasItem) item = getSlotItem(eSectionUnderPointer, iNewSlotIndex); - overrideTooltips(eSectionUnderPointer, item, bIsItemCarried, bSlotHasItem, bCarriedIsSameAsSlot, iSlotStackSizeRemaining, buttonA, buttonX, buttonY, buttonRT); + overrideTooltips(eSectionUnderPointer, item, bIsItemCarried, bSlotHasItem, bCarriedIsSameAsSlot, iSlotStackSizeRemaining, buttonA, buttonX, buttonY, buttonRT, buttonBack); SetToolTip( eToolTipButtonA, buttonA ); SetToolTip( eToolTipButtonX, buttonX ); SetToolTip( eToolTipButtonY, buttonY ); SetToolTip( eToolTipButtonRT, buttonRT ); - + SetToolTip( eToolTipButtonBack, buttonBack ); // Offset back to image top left. vPointerPos.x -= m_fPointerImageOffsetX; @@ -1275,35 +1304,60 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b #endif int buttonNum=0; // 0 = LeftMouse, 1 = RightMouse - BOOL quickKeyHeld=FALSE; // Represents shift key on PC - - BOOL validKeyPress = FALSE; - //BOOL itemEditorKeyPress = FALSE; + BOOL quickKeyHeld=false; // Represents shift key on PC + BOOL quickKeyDown = false; // Represents shift key on PC + BOOL validKeyPress = false; + bool itemEditorKeyPress = false; // Ignore input from other players //if(pMinecraft->player->GetXboxPad()!=pInputData->UserIndex) return S_OK; - + switch(iAction) { #ifdef _DEBUG_MENUS_ENABLED -#if TO_BE_IMPLEMENTED - case VK_PAD_RTHUMB_PRESS: + case ACTION_MENU_OTHER_STICK_PRESS: itemEditorKeyPress = TRUE; break; -#endif -#endif +#endif case ACTION_MENU_A: #ifdef __ORBIS__ case ACTION_MENU_TOUCHPAD_PRESS: #endif - if(!bRepeat) + if (!bRepeat) { validKeyPress = TRUE; // Standard left click buttonNum = 0; - quickKeyHeld = FALSE; - ui.PlayUISFX(eSFX_Press); + if (KMInput.IsKeyDown(VK_SHIFT)) + { + { + validKeyPress = TRUE; + + // Shift and left click + buttonNum = 0; + quickKeyHeld = TRUE; + if (IsSectionSlotList(m_eCurrSection)) + { + int currentIndex = getCurrentIndex(m_eCurrSection) - getSectionStartOffset(m_eCurrSection); + + bool bSlotHasItem = !isSlotEmpty(m_eCurrSection, currentIndex); + if (bSlotHasItem) + ui.PlayUISFX(eSFX_Press); + } + } + } + else { + if (IsSectionSlotList(m_eCurrSection)) + { + int currentIndex = getCurrentIndex(m_eCurrSection) - getSectionStartOffset(m_eCurrSection); + + bool bSlotHasItem = !isSlotEmpty(m_eCurrSection, currentIndex); + if (bSlotHasItem) + ui.PlayUISFX(eSFX_Press); + } + // + } } break; case ACTION_MENU_X: @@ -1314,9 +1368,18 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b // Standard right click buttonNum = 1; quickKeyHeld = FALSE; - ui.PlayUISFX(eSFX_Press); + + if( IsSectionSlotList( m_eCurrSection ) ) + { + int currentIndex = getCurrentIndex( m_eCurrSection ) - getSectionStartOffset(m_eCurrSection); + + bool bSlotHasItem = !isSlotEmpty(m_eCurrSection, currentIndex); + if ( bSlotHasItem ) + ui.PlayUISFX(eSFX_Press); + } } break; + case ACTION_MENU_Y: if(!bRepeat) { @@ -1333,7 +1396,14 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b // Shift and left click buttonNum = 0; quickKeyHeld = TRUE; - ui.PlayUISFX(eSFX_Press); + if( IsSectionSlotList( m_eCurrSection ) ) + { + int currentIndex = getCurrentIndex( m_eCurrSection ) - getSectionStartOffset(m_eCurrSection); + + bool bSlotHasItem = !isSlotEmpty(m_eCurrSection, currentIndex); + if ( bSlotHasItem ) + ui.PlayUISFX(eSFX_Press); + } } } break; @@ -1358,7 +1428,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b } else { - ui.CloseUIScenes(iPad); + ui.CloseUIScenes(iPad); } bHandled = true; @@ -1395,13 +1465,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b bHandled = true; } break; -#ifdef __PSVITA__ - //CD - Vita uses select for What's this - key 40 - case MINECRAFT_ACTION_GAME_INFO: -#else case ACTION_MENU_PAGEDOWN: -#endif - { if( IsSectionSlotList( m_eCurrSection ) ) { @@ -1456,7 +1520,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b { handleOutsideClicked(iPad, buttonNum, quickKeyHeld); } - else // + else // { // over empty space or something else??? handleOtherClicked(iPad,m_eCurrSection,buttonNum,quickKeyHeld?true:false); @@ -1467,47 +1531,19 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b bHandled = true; } #ifdef _DEBUG_MENUS_ENABLED -#if TO_BE_IMPLEMENTED else if(itemEditorKeyPress == TRUE) { - HXUIOBJ hFocusObject = GetFocus(pInputData->UserIndex); - HXUIOBJ hFocusObjectParent; - XuiElementGetParent( hFocusObject, &hFocusObjectParent ); - - HXUICLASS hClassCXuiCtrlSlotList; - - // TODO Define values for these - hClassCXuiCtrlSlotList = XuiFindClass( L"CXuiCtrlSlotList" ); - - // If the press comes from a SlotList, cast it up then send a clicked call to it's menu - if( XuiIsInstanceOf( hFocusObjectParent, hClassCXuiCtrlSlotList ) ) - { - CXuiCtrlSlotList* slotList; - VOID *pObj; - XuiObjectFromHandle( hFocusObjectParent, &pObj ); - slotList = (CXuiCtrlSlotList *)pObj; - - int currentIndex = slotList->GetCurSel(); - - CXuiCtrlSlotItemListItem* pCXuiCtrlSlotItem; - slotList->GetCXuiCtrlSlotItem( currentIndex, &( pCXuiCtrlSlotItem ) ); - - //Minecraft *pMinecraft = Minecraft::GetInstance(); - - CScene_DebugItemEditor::ItemEditorInput *initData = new CScene_DebugItemEditor::ItemEditorInput(); - initData->iPad = m_iPad; - initData->slot = pCXuiCtrlSlotItem->getSlot( pCXuiCtrlSlotItem->m_hObj ); + if( IsSectionSlotList( m_eCurrSection ) ) + { + ItemEditorInput *initData = new ItemEditorInput(); + initData->iPad = getPad(); + initData->slot = getSlot( m_eCurrSection, getCurrentIndex(m_eCurrSection) ); initData->menu = m_menu; - // Add timer to poll controller stick input at 60Hz - HRESULT timerResult = KillTimer( POINTER_INPUT_TIMER_ID ); - assert( timerResult == S_OK ); - - app.NavigateToScene(m_iPad,eUIScene_DebugItemEditor,(void *)initData,false,TRUE); + ui.NavigateToScene(getPad(),eUIScene_DebugItemEditor,(void *)initData); } } #endif -#endif else { handleAdditionalKeyPress(iAction); @@ -1528,7 +1564,7 @@ void IUIScene_AbstractContainerMenu::handleOutsideClicked(int iPad, int buttonNu // Drop items. //pMinecraft->localgameModes[m_iPad]->handleInventoryMouseClick(menu->containerId, AbstractContainerMenu::CLICKED_OUTSIDE, buttonNum, quickKeyHeld?true:false, pMinecraft->localplayers[m_iPad] ); - slotClicked(AbstractContainerMenu::CLICKED_OUTSIDE, buttonNum, quickKeyHeld?true:false); + slotClicked(AbstractContainerMenu::SLOT_CLICKED_OUTSIDE, buttonNum, quickKeyHeld?true:false); } void IUIScene_AbstractContainerMenu::handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey) @@ -1573,8 +1609,7 @@ bool IUIScene_AbstractContainerMenu::IsSameItemAs(shared_ptr<ItemInstance> itemA { if(itemA == NULL || itemB == NULL) return false; - bool bStackedByData = itemA->isStackedByData(); - return ( ( itemA->id == itemB->id ) && ( (bStackedByData && itemA->getAuxValue() == itemB->getAuxValue()) || !bStackedByData ) ); + return (itemA->id == itemB->id && (!itemB->isStackedByData() || itemB->getAuxValue() == itemA->getAuxValue()) && ItemInstance::tagMatches(itemB, itemA) ); } int IUIScene_AbstractContainerMenu::GetEmptyStackSpace(Slot *slot) @@ -1598,38 +1633,27 @@ int IUIScene_AbstractContainerMenu::GetEmptyStackSpace(Slot *slot) return iResult; } -wstring IUIScene_AbstractContainerMenu::GetItemDescription(Slot *slot, vector<wstring> &unformattedStrings) +vector<HtmlString> *IUIScene_AbstractContainerMenu::GetItemDescription(Slot *slot) { - if(slot == NULL) return L""; + if(slot == NULL) return NULL; - wstring desc = L""; - vector<wstring> *strings = slot->getItem()->getHoverText(nullptr, false, unformattedStrings); - bool firstLine = true; - for(AUTO_VAR(it, strings->begin()); it != strings->end(); ++it) + vector<HtmlString> *lines = slot->getItem()->getHoverText(nullptr, false); + + // Add rarity to first line + if (lines->size() > 0) { - wstring thisString = *it; - if(!firstLine) + lines->at(0).color = slot->getItem()->getRarity()->color; + + if(slot->getItem()->hasCustomHoverName()) { - desc.append( L"<br />" ); + lines->at(0).color = eTextColor_RenamedItemTitle; } - else - { - firstLine = false; - wchar_t formatted[256]; - eMinecraftColour rarityColour = slot->getItem()->getRarity()->color; - int colour = app.GetHTMLColour(rarityColour); + } - if(slot->getItem()->hasCustomHoverName()) - { - colour = app.GetHTMLColour(eTextColor_RenamedItemTitle); - } + return lines; +} - swprintf(formatted, 256, L"<font color=\"#%08x\">%ls</font>",colour,thisString.c_str()); - thisString = formatted; - } - desc.append( thisString ); - } - strings->clear(); - delete strings; - return desc; +vector<HtmlString> *IUIScene_AbstractContainerMenu::GetSectionHoverText(ESceneSection eSection) +{ + return NULL; } |
