aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
diff options
context:
space:
mode:
authorqwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com>2026-03-16 21:44:26 -0500
committerGitHub <noreply@github.com>2026-03-16 21:44:26 -0500
commitce739f6045ec72127491286ea3f3f21e537c1b55 (patch)
treef33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
parent255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff)
parent5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff)
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp')
-rw-r--r--Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp61
1 files changed, 46 insertions, 15 deletions
diff --git a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
index 6b196c1b..0c3b6096 100644
--- a/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
+++ b/Minecraft.Client/Common/UI/UIScene_AbstractContainerMenu.cpp
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "UI.h"
#include "UIScene_AbstractContainerMenu.h"
+#include "UISplitScreenHelpers.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
@@ -49,15 +50,15 @@ void UIScene_AbstractContainerMenu::handleDestroy()
#endif
Minecraft *pMinecraft = Minecraft::GetInstance();
- if( pMinecraft->localgameModes[m_iPad] != NULL )
+ if( pMinecraft->localgameModes[m_iPad] != nullptr )
{
- TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad];
- if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState);
+ TutorialMode *gameMode = static_cast<TutorialMode *>(pMinecraft->localgameModes[m_iPad]);
+ if(gameMode != nullptr) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState);
}
// 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss.
// We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying)
- if(pMinecraft->localplayers[m_iPad] != NULL && pMinecraft->localplayers[m_iPad]->containerMenu->containerId == m_menu->containerId)
+ if(pMinecraft->localplayers[m_iPad] != nullptr && pMinecraft->localplayers[m_iPad]->containerMenu->containerId == m_menu->containerId)
{
pMinecraft->localplayers[m_iPad]->closeContainer();
}
@@ -149,8 +150,8 @@ void UIScene_AbstractContainerMenu::PlatformInitialize(int iPad, int startIndex)
m_fPointerMaxX = m_fPanelMaxX + fPointerWidth;
m_fPointerMaxY = m_fPanelMaxY + (fPointerHeight/2);
-// m_hPointerText=NULL;
-// m_hPointerTextBkg=NULL;
+// m_hPointerText=nullptr;
+// m_hPointerTextBkg=nullptr;
// Put the pointer over first item in use row to start with.
UIVec2D itemPos;
@@ -187,14 +188,19 @@ void UIScene_AbstractContainerMenu::PlatformInitialize(int iPad, int startIndex)
IggyEvent mouseEvent;
S32 width, height;
m_parentLayer->getRenderDimensions(width, height);
- S32 x = m_pointerPos.x*((float)width/m_movieWidth);
- S32 y = m_pointerPos.y*((float)height/m_movieHeight);
+
+ C4JRender::eViewportType vp = m_parentLayer->getViewport();
+ if(vp != C4JRender::VIEWPORT_TYPE_FULLSCREEN)
+ Fit16x9(width, height);
+
+ S32 x = m_pointerPos.x*(static_cast<float>(width)/m_movieWidth);
+ S32 y = m_pointerPos.y*(static_cast<float>(height)/m_movieHeight);
IggyMakeEventMouseMove( &mouseEvent, x, y);
IggyEventResult result;
IggyPlayerDispatchEventRS ( getMovie() , &mouseEvent , &result );
-#ifdef USE_POINTER_ACCEL
+#ifdef USE_POINTER_ACCEL
m_fPointerVelX = 0.0f;
m_fPointerVelY = 0.0f;
m_fPointerAccelX = 0.0f;
@@ -212,8 +218,12 @@ void UIScene_AbstractContainerMenu::tick()
S32 width, height;
m_parentLayer->getRenderDimensions(width, height);
- S32 x = (S32)(m_pointerPos.x * ((float)width / m_movieWidth));
- S32 y = (S32)(m_pointerPos.y * ((float)height / m_movieHeight));
+ C4JRender::eViewportType vp = m_parentLayer->getViewport();
+ if(vp != C4JRender::VIEWPORT_TYPE_FULLSCREEN)
+ Fit16x9(width, height);
+
+ S32 x = static_cast<S32>(m_pointerPos.x * (static_cast<float>(width) / m_movieWidth));
+ S32 y = static_cast<S32>(m_pointerPos.y * (static_cast<float>(height) / m_movieHeight));
IggyMakeEventMouseMove( &mouseEvent, x, y);
@@ -251,10 +261,31 @@ void UIScene_AbstractContainerMenu::render(S32 width, S32 height, C4JRender::eVi
m_needsCacheRendered = false;
}
+void UIScene_AbstractContainerMenu::getMouseToSWFScale(float &scaleX, float &scaleY)
+{
+ extern HWND g_hWnd;
+ RECT rc;
+ GetClientRect(g_hWnd, &rc);
+ int winW = rc.right - rc.left;
+ int winH = rc.bottom - rc.top;
+ if(winW <= 0 || winH <= 0) { scaleX = 1.0f; scaleY = 1.0f; return; }
+
+ S32 renderW, renderH;
+ C4JRender::eViewportType vp = GetParentLayer()->getViewport();
+ ui.getRenderDimensions(vp, renderW, renderH);
+ if(vp != C4JRender::VIEWPORT_TYPE_FULLSCREEN)
+ Fit16x9(renderW, renderH);
+
+ float screenW = (float)ui.getScreenWidth();
+ float screenH = (float)ui.getScreenHeight();
+ scaleX = static_cast<float>(m_movieWidth) * screenW / (static_cast<float>(renderW) * static_cast<float>(winW));
+ scaleY = static_cast<float>(m_movieHeight) * screenH / (static_cast<float>(renderH) * static_cast<float>(winH));
+}
+
void UIScene_AbstractContainerMenu::customDraw(IggyCustomDrawCallbackRegion *region)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
- if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return;
+ if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return;
shared_ptr<ItemInstance> item = nullptr;
int slotId = -1;
@@ -265,7 +296,7 @@ void UIScene_AbstractContainerMenu::customDraw(IggyCustomDrawCallbackRegion *reg
}
else
{
- swscanf((wchar_t*)region->name,L"slot_%d",&slotId);
+ swscanf(static_cast<wchar_t *>(region->name),L"slot_%d",&slotId);
if (slotId == -1)
{
app.DebugPrintf("This is not the control we are looking for\n");
@@ -278,7 +309,7 @@ void UIScene_AbstractContainerMenu::customDraw(IggyCustomDrawCallbackRegion *reg
}
}
- if(item != NULL) customDrawSlotControl(region,m_iPad,item,m_menu->isValidIngredient(item, slotId)?1.0f:0.5f,item->isFoil(),true);
+ if(item != nullptr) customDrawSlotControl(region,m_iPad,item,m_menu->isValidIngredient(item, slotId)?1.0f:0.5f,item->isFoil(),true);
}
void UIScene_AbstractContainerMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
@@ -337,7 +368,7 @@ Slot *UIScene_AbstractContainerMenu::getSlot(ESceneSection eSection, int iSlot)
{
Slot *slot = m_menu->getSlot( getSectionStartOffset(eSection) + iSlot );
if(slot) return slot;
- else return NULL;
+ else return nullptr;
}
bool UIScene_AbstractContainerMenu::isSlotEmpty(ESceneSection eSection, int iSlot)