aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIScene.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-07 21:56:03 -0500
committerGitHub <noreply@github.com>2026-03-08 09:56:03 +0700
commita9be52c41a02d207233199e98898fe7483d7e817 (patch)
tree71dfaec3a86b05e9ca409b97d8eb9d7f993bfdd0 /Minecraft.Client/Common/UI/UIScene.cpp
parent1be5faaea781402e7de06b263eeca4c688b7712c (diff)
Project modernization (#630)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides
Diffstat (limited to 'Minecraft.Client/Common/UI/UIScene.cpp')
-rw-r--r--Minecraft.Client/Common/UI/UIScene.cpp87
1 files changed, 44 insertions, 43 deletions
diff --git a/Minecraft.Client/Common/UI/UIScene.cpp b/Minecraft.Client/Common/UI/UIScene.cpp
index 3f204414..a714d32e 100644
--- a/Minecraft.Client/Common/UI/UIScene.cpp
+++ b/Minecraft.Client/Common/UI/UIScene.cpp
@@ -11,8 +11,8 @@ UIScene::UIScene(int iPad, UILayer *parentLayer)
{
m_parentLayer = parentLayer;
m_iPad = iPad;
- swf = NULL;
- m_pItemRenderer = NULL;
+ swf = nullptr;
+ m_pItemRenderer = nullptr;
bHasFocus = false;
m_hasTickedOnce = false;
@@ -26,7 +26,7 @@ UIScene::UIScene(int iPad, UILayer *parentLayer)
m_lastOpacity = 1.0f;
m_bUpdateOpacity = false;
- m_backScene = NULL;
+ m_backScene = nullptr;
m_cacheSlotRenders = false;
m_needsCacheRendered = true;
@@ -49,14 +49,14 @@ UIScene::~UIScene()
ui.UnregisterCallbackId(m_callbackUniqueId);
}
- if(m_pItemRenderer != NULL) delete m_pItemRenderer;
+ if(m_pItemRenderer != nullptr) delete m_pItemRenderer;
}
void UIScene::destroyMovie()
{
/* Destroy the Iggy player. */
IggyPlayerDestroy( swf );
- swf = NULL;
+ swf = nullptr;
// Clear out the controls collection (doesn't delete the controls, and they get re-setup later)
m_controls.clear();
@@ -115,7 +115,7 @@ bool UIScene::needsReloaded()
bool UIScene::hasMovie()
{
- return swf != NULL;
+ return swf != nullptr;
}
F64 UIScene::getSafeZoneHalfHeight()
@@ -330,7 +330,7 @@ void UIScene::loadMovie()
byteArray baFile = ui.getMovieData(moviePath.c_str());
int64_t beforeLoad = ui.iggyAllocCount;
- swf = IggyPlayerCreateFromMemory ( baFile.data , baFile.length, NULL);
+ swf = IggyPlayerCreateFromMemory ( baFile.data , baFile.length, nullptr);
int64_t afterLoad = ui.iggyAllocCount;
IggyPlayerInitializeAndTickRS ( swf );
int64_t afterTick = ui.iggyAllocCount;
@@ -365,7 +365,7 @@ void UIScene::loadMovie()
int64_t totalStatic = 0;
int64_t totalDynamic = 0;
while(res = IggyDebugGetMemoryUseInfo ( swf ,
- NULL ,
+ nullptr ,
0 ,
0 ,
iteration ,
@@ -389,21 +389,22 @@ void UIScene::loadMovie()
void UIScene::getDebugMemoryUseRecursive(const wstring &moviePath, IggyMemoryUseInfo &memoryInfo)
{
- rrbool res;
- IggyMemoryUseInfo internalMemoryInfo;
- int internalIteration = 0;
- while(res = IggyDebugGetMemoryUseInfo ( swf ,
- NULL ,
- memoryInfo.subcategory ,
- memoryInfo.subcategory_stringlen ,
- internalIteration ,
- &internalMemoryInfo ))
- {
- app.DebugPrintf(app.USER_SR, "%ls - %.*s static: %d ( %d ) dynamic: %d ( %d )\n", moviePath.c_str(), internalMemoryInfo.subcategory_stringlen, internalMemoryInfo.subcategory,
- internalMemoryInfo.static_allocation_bytes, internalMemoryInfo.static_allocation_count, internalMemoryInfo.dynamic_allocation_bytes, internalMemoryInfo.dynamic_allocation_count);
- ++internalIteration;
- if(internalMemoryInfo.subcategory_stringlen > memoryInfo.subcategory_stringlen) getDebugMemoryUseRecursive(moviePath, internalMemoryInfo);
- }
+ rrbool res;
+ IggyMemoryUseInfo internalMemoryInfo;
+ int internalIteration = 0;
+ while (res = IggyDebugGetMemoryUseInfo(swf,
+ 0,
+ memoryInfo.subcategory,
+ memoryInfo.subcategory_stringlen,
+ internalIteration,
+ &internalMemoryInfo))
+ {
+ app.DebugPrintf(app.USER_SR, "%ls - %.*s static: %d ( %d ) dynamic: %d ( %d )\n", moviePath.c_str(), internalMemoryInfo.subcategory_stringlen, internalMemoryInfo.subcategory,
+ internalMemoryInfo.static_allocation_bytes, internalMemoryInfo.static_allocation_count, internalMemoryInfo.dynamic_allocation_bytes, internalMemoryInfo.dynamic_allocation_count);
+ ++internalIteration;
+ if (internalMemoryInfo.subcategory_stringlen > memoryInfo.subcategory_stringlen)
+ getDebugMemoryUseRecursive(moviePath, internalMemoryInfo);
+ }
}
void UIScene::PrintTotalMemoryUsage(int64_t &totalStatic, int64_t &totalDynamic)
@@ -416,7 +417,7 @@ void UIScene::PrintTotalMemoryUsage(int64_t &totalStatic, int64_t &totalDynamic)
int64_t sceneStatic = 0;
int64_t sceneDynamic = 0;
while(res = IggyDebugGetMemoryUseInfo ( swf ,
- NULL ,
+ 0 ,
"" ,
0 ,
iteration ,
@@ -464,7 +465,7 @@ void UIScene::tick()
UIControl* UIScene::GetMainPanel()
{
- return NULL;
+ return nullptr;
}
#ifdef _WINDOWS64
@@ -666,19 +667,19 @@ void UIScene::removeControl( UIControl_Base *control, bool centreScene)
void UIScene::slideLeft()
{
IggyDataValue result;
- IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSlideLeft , 0 , NULL );
+ IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSlideLeft , 0 , nullptr );
}
void UIScene::slideRight()
{
IggyDataValue result;
- IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSlideRight , 0 , NULL );
+ IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSlideRight , 0 , nullptr );
}
void UIScene::doHorizontalResizeCheck()
{
IggyDataValue result;
- IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcHorizontalResizeCheck , 0 , NULL );
+ IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcHorizontalResizeCheck , 0 , nullptr );
}
void UIScene::render(S32 width, S32 height, C4JRender::eViewportType viewport)
@@ -721,7 +722,7 @@ void UIScene::customDraw(IggyCustomDrawCallbackRegion *region)
void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion *region, int iPad, shared_ptr<ItemInstance> item, float fAlpha, bool isFoil, bool bDecorations)
{
- if (item!= NULL)
+ if (item!= nullptr)
{
if(m_cacheSlotRenders)
{
@@ -849,7 +850,7 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, shared_pt
if (pop > 0)
{
glPushMatrix();
- float squeeze = 1 + pop / (float) Inventory::POP_TIME_DURATION;
+ float squeeze = 1 + pop / static_cast<float>(Inventory::POP_TIME_DURATION);
float sx = x;
float sy = y;
float sxoffs = 8 * scaleX;
@@ -860,7 +861,7 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, shared_pt
}
PIXBeginNamedEvent(0,"Render and decorate");
- if(m_pItemRenderer == NULL) m_pItemRenderer = new ItemRenderer();
+ if(m_pItemRenderer == nullptr) m_pItemRenderer = new ItemRenderer();
RenderManager.StateSetBlendEnable(true);
RenderManager.StateSetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
RenderManager.StateSetBlendFactor(0xffffffff);
@@ -878,15 +879,15 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, shared_pt
{
glPushMatrix();
glScalef(scaleX, scaleY, 1.0f);
- int iX= (int)(0.5f+((float)x)/scaleX);
- int iY= (int)(0.5f+((float)y)/scaleY);
+ int iX= static_cast<int>(0.5f + ((float)x) / scaleX);
+ int iY= static_cast<int>(0.5f + ((float)y) / scaleY);
m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, item, iX, iY, fAlpha);
glPopMatrix();
}
else
{
- m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, item, (int)x, (int)y, fAlpha);
+ m_pItemRenderer->renderGuiItemDecorations(pMinecraft->font, pMinecraft->textures, item, static_cast<int>(x), static_cast<int>(y), fAlpha);
}
}
@@ -897,9 +898,9 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, shared_pt
// 4J Stu - Not threadsafe
//void UIScene::navigateForward(int iPad, EUIScene scene, void *initData)
//{
-// if(m_parentLayer == NULL)
+// if(m_parentLayer == nullptr)
// {
-// app.DebugPrintf("A scene is trying to navigate forwards, but it's parent layer is NULL!\n");
+// app.DebugPrintf("A scene is trying to navigate forwards, but it's parent layer is nullptr!\n");
//#ifndef _CONTENT_PACKAGE
// __debugbreak();
//#endif
@@ -917,9 +918,9 @@ void UIScene::navigateBack()
ui.NavigateBack(m_iPad);
- if(m_parentLayer == NULL)
+ if(m_parentLayer == nullptr)
{
-// app.DebugPrintf("A scene is trying to navigate back, but it's parent layer is NULL!\n");
+// app.DebugPrintf("A scene is trying to navigate back, but it's parent layer is nullptr!\n");
#ifndef _CONTENT_PACKAGE
// __debugbreak();
#endif
@@ -1042,7 +1043,7 @@ void UIScene::sendInputToMovie(int key, bool repeat, bool pressed, bool released
IggyEvent keyEvent;
// 4J Stu - Keyloc is always standard as we don't care about shift/alt
- IggyMakeEventKey( &keyEvent, pressed?IGGY_KEYEVENT_Down:IGGY_KEYEVENT_Up, (IggyKeycode)iggyKeyCode, IGGY_KEYLOC_Standard );
+ IggyMakeEventKey( &keyEvent, pressed?IGGY_KEYEVENT_Down:IGGY_KEYEVENT_Up, static_cast<IggyKeycode>(iggyKeyCode), IGGY_KEYLOC_Standard );
IggyEventResult result;
IggyPlayerDispatchEventRS ( swf , &keyEvent , &result );
@@ -1331,8 +1332,8 @@ bool UIScene::hasRegisteredSubstitutionTexture(const wstring &textureName)
void UIScene::_handleFocusChange(F64 controlId, F64 childId)
{
- m_iFocusControl = (int)controlId;
- m_iFocusChild = (int)childId;
+ m_iFocusControl = static_cast<int>(controlId);
+ m_iFocusChild = static_cast<int>(childId);
handleFocusChange(controlId, childId);
ui.PlayUISFX(eSFX_Focus);
@@ -1340,8 +1341,8 @@ void UIScene::_handleFocusChange(F64 controlId, F64 childId)
void UIScene::_handleInitFocus(F64 controlId, F64 childId)
{
- m_iFocusControl = (int)controlId;
- m_iFocusChild = (int)childId;
+ m_iFocusControl = static_cast<int>(controlId);
+ m_iFocusChild = static_cast<int>(childId);
//handleInitFocus(controlId, childId);
handleFocusChange(controlId, childId);