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
@@ -5,7 +5,7 @@
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
#include "UIScene_CraftingMenu.h"
#ifdef __PSVITA__
#if defined(__PSVITA__) || defined(_WINDOWS64)
#define GAME_CRAFTING_TOUCHUPDATE_TIMER_ID 0
#define GAME_CRAFTING_TOUCHUPDATE_TIMER_TIME 100
#endif
@@ -13,6 +13,9 @@
UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
m_bIgnoreKeyPresses = false;
m_bMouseLDownPrev = false;
m_bCraftArmed = false;
m_iHoverHSlot = -1;
CraftingPanelScreenInput* initData = (CraftingPanelScreenInput*)_initData;
m_iContainerType=initData->iContainerType;
@@ -176,13 +179,13 @@ UIScene_CraftingMenu::UIScene_CraftingMenu(int iPad, void *_initData, UILayer *p
// 4J-PB - Must be after the CanBeMade list has been set up with CheckRecipesAvailable
UpdateTooltips();
#ifdef __PSVITA__
#if defined(__PSVITA__) || defined(_WINDOWS64)
ui.TouchBoxRebuild(this);
// initialise vita touch controls with ids
for(unsigned int i = 0; i < ETouchInput_Count; ++i)
{
m_TouchInput[i].init(i);
}
ui.TouchBoxRebuild(this);
#endif
}
@@ -225,9 +228,7 @@ EUIScene UIScene_CraftingMenu::getSceneType()
{
return eUIScene_Crafting2x2Menu;
}
}
wstring UIScene_CraftingMenu::getMoviePath()
} wstring UIScene_CraftingMenu::getMoviePath()
{
if(app.GetLocalPlayerCount() > 1)
{
@@ -254,7 +255,238 @@ wstring UIScene_CraftingMenu::getMoviePath()
}
}
#ifdef __PSVITA__
void UIScene_CraftingMenu::handleMouseHover(float x, float y, int iId)
{
#ifdef _WINDOWS64
if (iId == ETouchInput_CraftingHSlots)
{
UpdateHSlotHover(x, y);
}
#endif
}
#ifdef _WINDOWS64
bool UIScene_CraftingMenu::GetTabSegmentForPoint(float fx, float fy, int &iOut)
{
int iMaxGroup = (m_iContainerType == RECIPE_TYPE_3x3) ? m_iMaxGroup3x3 : m_iMaxGroup2x2;
if (iMaxGroup <= 0) return false;
m_controlMainPanel.UpdateControl();
m_tabRow.UpdateControl();
float fOx = (float)m_controlMainPanel.getXPos() + (float)m_tabRow.getXPos();
float fOy = (float)m_controlMainPanel.getYPos() + (float)m_tabRow.getYPos();
float fW = (float)m_tabRow.getWidth();
float fH = (float)m_tabRow.getHeight();
if (fW < 4.0f || fH < 4.0f) return false;
if (fx < fOx || fx >= fOx + fW * (float)iMaxGroup || fy < fOy || fy >= fOy + fH) return false;
int iSeg = (int)((fx - fOx) / fW);
if (iSeg < 0) iSeg = 0;
if (iSeg >= iMaxGroup) iSeg = iMaxGroup - 1;
iOut = iSeg;
return true;
}
void UIScene_CraftingMenu::SelectGroupTabUnderPoint(float fx, float fy)
{
int iSeg;
if (!GetTabSegmentForPoint(fx, fy, iSeg)) return;
if (iSeg == m_iGroupIndex)
{
ui.PlayUISFX(eSFX_Focus);
return;
}
showTabHighlight(m_iGroupIndex, false);
m_iGroupIndex = iSeg;
showTabHighlight(m_iGroupIndex, true);
m_iCurrentSlotHIndex = 0;
m_iCurrentSlotVIndex = 1;
CheckRecipesAvailable();
iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1;
iVSlotIndexA[1] = 0;
iVSlotIndexA[2] = 1;
ui.PlayUISFX(eSFX_Focus);
UpdateVerticalSlots();
UpdateHighlight();
setGroupText(GetGroupNameText(m_pGroupA[m_iGroupIndex]));
}
bool UIScene_CraftingMenu::GetHSlotIndexForPoint(float fx, float fy, int &iOut)
{
if (m_iCraftablesMaxHSlotC <= 0) return false;
m_controlMainPanel.UpdateControl();
m_slotListCraftingHSlots.UpdateControl();
float fRowX = (float)m_slotListCraftingHSlots.getXPos() + (float)m_controlMainPanel.getXPos();
float fRowY = (float)m_slotListCraftingHSlots.getYPos() + (float)m_controlMainPanel.getYPos();
S32 iSlotSize = m_slotListCraftingHSlots.GetSlotSize();
if (iSlotSize <= 0) iSlotSize = 50;
float fRowW = (float)(m_iCraftablesMaxHSlotC * iSlotSize);
float fRowH = (float)iSlotSize;
if (fRowW < 4.0f || fRowH < 4.0f) return false;
if (fx < fRowX || fx >= fRowX + fRowW || fy < fRowY || fy >= fRowY + fRowH) return false;
float fSlotW = fRowW / (float)m_iCraftablesMaxHSlotC;
int iSlot = (int)((fx - fRowX) / fSlotW);
if (iSlot < 0) iSlot = 0;
if (iSlot >= m_iCraftablesMaxHSlotC) iSlot = m_iCraftablesMaxHSlotC - 1;
if (CanBeMadeA[iSlot].iCount == 0) return false;
iOut = iSlot;
return true;
}
void UIScene_CraftingMenu::UpdateHSlotHover(float fx, float fy)
{
int iSlot;
if (GetHSlotIndexForPoint(fx, fy, iSlot))
{
if (iSlot != m_iHoverHSlot)
{
m_slotListCraftingHSlots.clearHighlight();
m_slotListCraftingHSlots.setHighlightSlot(iSlot);
m_iHoverHSlot = iSlot;
}
}
else if (m_iHoverHSlot != -1)
{
m_slotListCraftingHSlots.clearHighlight();
m_iHoverHSlot = -1;
}
}
void UIScene_CraftingMenu::SelectHSlotUnderPoint(float fx, float fy)
{
int iNewSlot;
if (!GetHSlotIndexForPoint(fx, fy, iNewSlot)) return;
if (iNewSlot == m_iCurrentSlotHIndex) return;
int iOldHSlot = m_iCurrentSlotHIndex;
m_iCurrentSlotHIndex = iNewSlot;
m_iCurrentSlotVIndex = 1;
iVSlotIndexA[0] = CanBeMadeA[m_iCurrentSlotHIndex].iCount - 1;
iVSlotIndexA[1] = 0;
iVSlotIndexA[2] = 1;
UpdateVerticalSlots();
UpdateHighlight();
if (CanBeMadeA[iOldHSlot].iCount > 0)
{
setShowCraftHSlot(iOldHSlot, true);
}
}
void UIScene_CraftingMenu::tick()
{
UIScene::tick();
if (InputManager.IsMouseCaptured()) return;
extern int g_iWindowClientW, g_iWindowClientH;
float fMovieW = getMovieWidth();
float fMovieH = getMovieHeight();
if (fMovieW < 1.0f) fMovieW = 1280.0f;
if (fMovieH < 1.0f) fMovieH = 720.0f;
float fScalex = fMovieW / (float)(g_iWindowClientW > 0 ? g_iWindowClientW : 1280);
float fScaley = fMovieH / (float)(g_iWindowClientH > 0 ? g_iWindowClientH : 720);
float fx = (float)InputManager.GetMouseX() * fScalex;
float fy = (float)InputManager.GetMouseY() * fScaley;
if (ui.IsControllerMode())
{
if (m_iHoverHSlot != -1)
{
m_slotListCraftingHSlots.clearHighlight();
m_iHoverHSlot = -1;
}
}
else
{
UpdateHSlotHover(fx, fy);
}
bool bLDown = InputManager.IsMouseLDown();
if (bLDown && !m_bMouseLDownPrev)
{
m_bCraftArmed = false;
int iTab;
if (GetTabSegmentForPoint(fx, fy, iTab))
{
SelectGroupTabUnderPoint(fx, fy);
}
else
{
int iSlot;
if (GetHSlotIndexForPoint(fx, fy, iSlot))
{
if (iSlot == m_iCurrentSlotHIndex)
m_bCraftArmed = true;
else
SelectHSlotUnderPoint(fx, fy);
}
}
}
else if (!bLDown && m_bMouseLDownPrev)
{
if (m_bCraftArmed)
{
m_bCraftArmed = false;
int iSlot;
if (GetHSlotIndexForPoint(fx, fy, iSlot) && iSlot == m_iCurrentSlotHIndex)
handleKeyDown(m_iPad, ACTION_MENU_A, false);
}
}
m_bMouseLDownPrev = bLDown;
}
#endif
void UIScene_CraftingMenu::CycleVerticalVariant(bool bForward)
{
int iCount = CanBeMadeA[m_iCurrentSlotHIndex].iCount;
if (iCount <= 1) return;
if (iCount > 2)
{
if (bForward)
{
if (m_iCurrentSlotVIndex != 2)
{
m_iCurrentSlotVIndex++;
}
else
{
iVSlotIndexA[0] = iVSlotIndexA[1];
iVSlotIndexA[1] = iVSlotIndexA[2];
iVSlotIndexA[2] = (iVSlotIndexA[2] == iCount - 1) ? 0 : iVSlotIndexA[2] + 1;
}
}
else
{
if (m_iCurrentSlotVIndex != 0)
{
m_iCurrentSlotVIndex--;
}
else
{
iVSlotIndexA[2] = iVSlotIndexA[1];
iVSlotIndexA[1] = iVSlotIndexA[0];
iVSlotIndexA[0] = (iVSlotIndexA[0] == 0) ? iCount - 1 : iVSlotIndexA[0] - 1;
}
}
}
else
{
m_iCurrentSlotVIndex = (bForward) ? ((m_iCurrentSlotVIndex != 1) ? 1 : 0) : ((m_iCurrentSlotVIndex != 0) ? 0 : 1);
}
ui.PlayUISFX(eSFX_Focus);
UpdateVerticalSlots();
UpdateHighlight();
}
#if defined(__PSVITA__) || defined(_WINDOWS64)
UIControl* UIScene_CraftingMenu::GetMainPanel()
{
return &m_controlMainPanel;
@@ -369,6 +601,7 @@ void UIScene_CraftingMenu::handleTouchInput(unsigned int iPad, S32 x, S32 y, int
void UIScene_CraftingMenu::handleTouchBoxRebuild()
{
addTimer(GAME_CRAFTING_TOUCHUPDATE_TIMER_ID,GAME_CRAFTING_TOUCHUPDATE_TIMER_TIME);
UIScene::handleTouchBoxRebuild();
}
void UIScene_CraftingMenu::handleTimerComplete(int id)
@@ -556,7 +789,10 @@ void UIScene_CraftingMenu::handleInput(int iPad, int key, bool repeat, bool pres
{
case ACTION_MENU_OTHER_STICK_UP:
case ACTION_MENU_OTHER_STICK_DOWN:
sendInputToMovie(key,repeat,pressed,released);
if (pressed)
{
CycleVerticalVariant(key == ACTION_MENU_OTHER_STICK_DOWN);
}
break;
default:
if(pressed)