added some kbm stuff

This commit is contained in:
2026-09-13 19:41:44 -07:00
parent 82e802873f
commit 5023e0a8d6
217 changed files with 3744 additions and 235 deletions
@@ -1,6 +1,9 @@
#include "stdafx.h"
#include "IUIScene_AbstractContainerMenu.h"
#include "UIScene.h"
#include "UIControl.h"
#include "UIControl_SlotList.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
@@ -89,6 +92,21 @@ void IUIScene_AbstractContainerMenu::Initialize(int iPad, AbstractContainerMenu*
PlatformInitialize(iPad,startIndex);
}
void IUIScene_AbstractContainerMenu::FixSlotGridSize(ESceneSection eSection, UIControl_SlotList &list, UIVec2D &sectionSize)
{
if (sectionSize.x <= 0.0f || sectionSize.y <= 0.0f)
{
S32 iSlot = list.GetSlotSize();
int iCols = 0, iRows = 0;
GetSectionDimensions(eSection, &iCols, &iRows);
if (iSlot > 0 && iCols > 0 && iRows > 0)
{
sectionSize.x = (float)(iSlot * iCols);
sectionSize.y = (float)(iSlot * iRows);
}
}
}
int IUIScene_AbstractContainerMenu::GetSectionDimensions( ESceneSection eSection, int* piNumColumns, int* piNumRows )
{
if(IsSectionSlotList(eSection))
@@ -257,7 +275,7 @@ void IUIScene_AbstractContainerMenu::UpdateTooltips()
}
}
void IUIScene_AbstractContainerMenu::onMouseTick()
void IUIScene_AbstractContainerMenu::onMouseTick(UIScene *pScene)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
if( pMinecraft->localgameModes[getPad()] != NULL)
@@ -289,9 +307,22 @@ void IUIScene_AbstractContainerMenu::onMouseTick()
int iPad = getPad();
bool bStickInput = false;
bool bUsingMouse = false;
float fInputX = InputManager.GetJoypadStick_LX( iPad, false )*((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InMenu)/100.0f); // apply the sensitivity
float fInputY = InputManager.GetJoypadStick_LY( iPad, false )*((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InMenu)/100.0f); // apply the sensitivity
#ifdef _WINDOWS64
if (!InputManager.IsMouseCaptured() && !ui.IsControllerMode())
{
ui.GetMovieMousePos(pScene, vPointerPos.x, vPointerPos.y);
fInputX = 0.0f;
fInputY = 0.0f;
bUsingMouse = true;
m_eCurrTapState = eTapStateNoInput;
m_iConsectiveInputTicks = 0;
}
#endif
#ifdef __ORBIS__
// should have sensitivity for the touchpad
//(float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_TouchPadInMenu)/100.0f
@@ -482,6 +513,22 @@ void IUIScene_AbstractContainerMenu::onMouseTick()
// Centre position of item under pointer, use this to snap pointer to item.
D3DXVECTOR3 vSnapPos;
UIVec2D vMainPanelOffset;
vMainPanelOffset.x = 0.0f;
vMainPanelOffset.y = 0.0f;
if (pScene)
{
UIControl *pMainPanel = pScene->GetMainPanel();
if (pMainPanel)
{
pMainPanel->UpdateControl();
vMainPanelOffset.x = (float)pMainPanel->getXPos();
vMainPanelOffset.y = (float)pMainPanel->getYPos();
}
}
RefreshSlotControls();
for ( int iSection = m_eFirstSection; iSection < m_eMaxSection; ++iSection )
{
// Do not check any further if we have already found the item under the pointer.
@@ -496,6 +543,8 @@ void IUIScene_AbstractContainerMenu::onMouseTick()
// Get position of this section.
UIVec2D sectionPos;
GetPositionOfSection( eSection, &( sectionPos ) );
sectionPos.x += vMainPanelOffset.x;
sectionPos.y += vMainPanelOffset.y;
if(!IsSectionSlotList(eSection))
{
@@ -671,6 +720,8 @@ void IUIScene_AbstractContainerMenu::onMouseTick()
// Desired slot after tap input is valid, so make the jump to this slot.
UIVec2D sectionPos;
GetPositionOfSection( eSectionUnderPointer, &( sectionPos ) );
sectionPos.x += vMainPanelOffset.x;
sectionPos.y += vMainPanelOffset.y;
iNewSlotIndex = ( iDesiredSlotY * iNumColumns ) + iDesiredSlotX;
@@ -692,7 +743,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(CanHaveFocus(eSectionUnderPointer) && !bUsingMouse)
{
vPointerPos.x = vSnapPos.x;
vPointerPos.y = vSnapPos.y;
@@ -1320,8 +1371,15 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b
buttonNum = 0;
quickKeyHeld = FALSE;
ui.PlayUISFX(eSFX_Press);
#ifdef _WINDOWS64
{ FILE *cf = fopen("inv_debug.log", "a"); if (cf) { fprintf(cf, "CLICK ptr=(%.1f,%.1f) sec=%d sx=%d sy=%d\n", m_pointerPos.x, m_pointerPos.y, (int)m_eCurrSection, m_iCurrSlotX, m_iCurrSlotY);
if (m_eCurrSection != eSectionNone) { UIVec2D dsp, dip, disz; int dc=0, dr=0; GetPositionOfSection(m_eCurrSection, &dsp); GetItemScreenData(m_eCurrSection, 0, &dip, &disz); GetSectionDimensions(m_eCurrSection, &dc, &dr);
extern int g_iWindowClientW, g_iWindowClientH; int rawx = InputManager.GetMouseX(), rawy = InputManager.GetMouseY();
fprintf(cf, " secrect=(%.1f,%.1f) item0=(%.1f,%.1f %.1fx%.1f) cols=%d rows=%d raw=(%d,%d) client=(%d,%d) screen=(%.1f,%.1f)\n", dsp.x, dsp.y, dip.x, dip.y, disz.x, disz.y, dc, dr, rawx, rawy, g_iWindowClientW, g_iWindowClientH, ui.getScreenWidth(), ui.getScreenHeight()); }
fclose(cf); } }
#endif
}
break;
break;
case ACTION_MENU_X:
if(!bRepeat)
{
@@ -1452,12 +1510,12 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b
}
else
{
if( IsSectionSlotList( m_eCurrSection ) )
{
handleSlotListClicked(m_eCurrSection,buttonNum,quickKeyHeld);
}
else
{
if( IsSectionSlotList( m_eCurrSection ) )
{
handleSlotListClicked(m_eCurrSection,buttonNum,quickKeyHeld);
}
else
{
// TODO Clicked something else, like for example the craft result. Do something here
// 4J WESTY : For pointer system we can legally drop items outside of the window panel here, or may press button while