aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIController.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.Client/Common/UI/UIController.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
Modernize project codebase (#906)
* 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 * Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.Client/Common/UI/UIController.cpp')
-rw-r--r--Minecraft.Client/Common/UI/UIController.cpp377
1 files changed, 197 insertions, 180 deletions
diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp
index b0bd7dd3..e64808fc 100644
--- a/Minecraft.Client/Common/UI/UIController.cpp
+++ b/Minecraft.Client/Common/UI/UIController.cpp
@@ -64,14 +64,14 @@ DWORD UIController::m_dwTrialTimerLimitSecs=DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME;
static UIControl_Slider *FindSliderById(UIScene *pScene, int sliderId)
{
vector<UIControl *> *controls = pScene->GetControls();
- if (!controls) return NULL;
+ if (!controls) return nullptr;
for (size_t i = 0; i < controls->size(); ++i)
{
UIControl *ctrl = (*controls)[i];
if (ctrl && ctrl->getControlType() == UIControl::eSlider && ctrl->getId() == sliderId)
- return (UIControl_Slider *)ctrl;
+ return static_cast<UIControl_Slider *>(ctrl);
}
- return NULL;
+ return nullptr;
}
#endif
@@ -151,7 +151,7 @@ int64_t UIController::iggyAllocCount = 0;
static unordered_map<void *,size_t> allocations;
static void * RADLINK AllocateFunction ( void * alloc_callback_user_data , size_t size_requested , size_t * size_returned )
{
- UIController *controller = (UIController *)alloc_callback_user_data;
+ UIController *controller = static_cast<UIController *>(alloc_callback_user_data);
EnterCriticalSection(&controller->m_Allocatorlock);
#ifdef EXCLUDE_IGGY_ALLOCATIONS_FROM_HEAP_INSPECTOR
void *alloc = __real_malloc(size_requested);
@@ -168,7 +168,7 @@ static void * RADLINK AllocateFunction ( void * alloc_callback_user_data , size_
static void RADLINK DeallocateFunction ( void * alloc_callback_user_data , void * ptr )
{
- UIController *controller = (UIController *)alloc_callback_user_data;
+ UIController *controller = static_cast<UIController *>(alloc_callback_user_data);
EnterCriticalSection(&controller->m_Allocatorlock);
size_t size = allocations[ptr];
UIController::iggyAllocCount -= size;
@@ -184,15 +184,15 @@ static void RADLINK DeallocateFunction ( void * alloc_callback_user_data , void
UIController::UIController()
{
- m_uiDebugConsole = NULL;
- m_reloadSkinThread = NULL;
+ m_uiDebugConsole = nullptr;
+ m_reloadSkinThread = nullptr;
m_navigateToHomeOnReload = false;
m_bCleanupOnReload = false;
- m_mcTTFFont = NULL;
- m_moj7 = NULL;
- m_moj11 = NULL;
+ m_mcTTFFont = nullptr;
+ m_moj7 = nullptr;
+ m_moj11 = nullptr;
// 4J-JEV: It's important that these remain the same, unless updateCurrentLanguage is going to be called.
m_eCurrentFont = m_eTargetFont = eFont_NotLoaded;
@@ -273,7 +273,7 @@ void UIController::SetSysUIShowing(bool bVal)
void UIController::SetSystemUIShowing(LPVOID lpParam,bool bVal)
{
- UIController *pClass=(UIController *)lpParam;
+ UIController *pClass=static_cast<UIController *>(lpParam);
pClass->SetSysUIShowing(bVal);
}
@@ -313,13 +313,13 @@ void UIController::postInit()
for(unsigned int i = 0; i < eUIGroup_COUNT; ++i)
{
- m_groups[i] = new UIGroup((EUIGroup)i,i-1);
+ m_groups[i] = new UIGroup(static_cast<EUIGroup>(i),i-1);
}
#ifdef ENABLE_IGGY_EXPLORER
iggy_explorer = IggyExpCreate("127.0.0.1", 9190, malloc(IGGYEXP_MIN_STORAGE), IGGYEXP_MIN_STORAGE);
- if ( iggy_explorer == NULL )
+ if ( iggy_explorer == nullptr )
{
// not normally an error, just an error for this demo!
app.DebugPrintf( "Couldn't connect to Iggy Explorer, did you run it first?" );
@@ -332,7 +332,7 @@ void UIController::postInit()
#ifdef ENABLE_IGGY_PERFMON
m_iggyPerfmonEnabled = false;
- iggy_perfmon = IggyPerfmonCreate(perf_malloc, perf_free, NULL);
+ iggy_perfmon = IggyPerfmonCreate(perf_malloc, perf_free, nullptr);
IggyInstallPerfmon(iggy_perfmon);
#endif
@@ -373,7 +373,7 @@ UITTFFont *UIController::createFont(EFont fontLanguage)
#endif
// 4J-JEV, Cyrillic characters have been added to this font now, (4/July/14)
// XC_LANGUAGE_RUSSIAN and XC_LANGUAGE_GREEK:
- default: return NULL;
+ default: return nullptr;
}
}
@@ -400,17 +400,17 @@ void UIController::SetupFont()
if (m_eCurrentFont != eFont_NotLoaded) app.DebugPrintf("[UIController] Font switch required for language transition to %i.\n", nextLanguage);
else app.DebugPrintf("[UIController] Initialising font for language %i.\n", nextLanguage);
- if (m_mcTTFFont != NULL)
+ if (m_mcTTFFont != nullptr)
{
delete m_mcTTFFont;
- m_mcTTFFont = NULL;
+ m_mcTTFFont = nullptr;
}
if(m_eTargetFont == eFont_Bitmap)
{
// these may have been set up by a previous language being chosen
- if (m_moj7 == NULL) m_moj7 = new UIBitmapFont(SFontData::Mojangles_7);
- if (m_moj11 == NULL) m_moj11 = new UIBitmapFont(SFontData::Mojangles_11);
+ if (m_moj7 == nullptr) m_moj7 = new UIBitmapFont(SFontData::Mojangles_7);
+ if (m_moj11 == nullptr) m_moj11 = new UIBitmapFont(SFontData::Mojangles_11);
// 4J-JEV: Ensure we redirect to them correctly, even if the objects were previously initialised.
m_moj7->registerFont();
@@ -618,7 +618,7 @@ IggyLibrary UIController::loadSkin(const wstring &skinPath, const wstring &skinN
if(!skinPath.empty() && app.hasArchiveFile(skinPath))
{
byteArray baFile = app.getArchiveFile(skinPath);
- lib = IggyLibraryCreateFromMemoryUTF16( (IggyUTF16 *)skinName.c_str() , (void *)baFile.data, baFile.length, NULL );
+ lib = IggyLibraryCreateFromMemoryUTF16( (IggyUTF16 *)skinName.c_str() , (void *)baFile.data, baFile.length, nullptr );
delete[] baFile.data;
#ifdef _DEBUG
@@ -626,12 +626,12 @@ IggyLibrary UIController::loadSkin(const wstring &skinPath, const wstring &skinN
rrbool res;
int iteration = 0;
int64_t totalStatic = 0;
- while(res = IggyDebugGetMemoryUseInfo ( NULL ,
- lib ,
- "" ,
- 0 ,
- iteration ,
- &memoryInfo ))
+ while(res = IggyDebugGetMemoryUseInfo (nullptr,
+ lib ,
+ "" ,
+ 0 ,
+ iteration ,
+ &memoryInfo ))
{
totalStatic += memoryInfo.static_allocation_bytes;
app.DebugPrintf(app.USER_SR, "%ls - %.*s, static: %dB, dynamic: %dB\n", skinPath.c_str(), memoryInfo.subcategory_stringlen, memoryInfo.subcategory, memoryInfo.static_allocation_bytes, memoryInfo.dynamic_allocation_bytes);
@@ -695,7 +695,7 @@ void UIController::StartReloadSkinThread()
int UIController::reloadSkinThreadProc(void* lpParam)
{
EnterCriticalSection(&ms_reloadSkinCS); // MGH - added to prevent crash loading Iggy movies while the skins were being reloaded
- UIController *controller = (UIController *)lpParam;
+ UIController *controller = static_cast<UIController *>(lpParam);
// Load new skin
controller->loadSkins();
@@ -730,7 +730,7 @@ bool UIController::IsExpectingOrReloadingSkin()
void UIController::CleanUpSkinReload()
{
delete m_reloadSkinThread;
- m_reloadSkinThread = NULL;
+ m_reloadSkinThread = nullptr;
if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin())
{
@@ -790,18 +790,19 @@ void UIController::tickInput()
#endif
{
#ifdef _WINDOWS64
- m_mouseClickConsumedByScene = false;
- if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
- {
- UIScene *pScene = NULL;
- // Search by layer priority across all groups (layer-first).
- // Tooltip layer is skipped because it holds non-interactive
- // overlays (button hints, timer) that should never capture mouse.
- // Old group-first order found those tooltips on eUIGroup_Fullscreen
- // before reaching in-game menus on eUIGroup_Player1.
- static const EUILayer mouseLayers[] = {
+ m_mouseClickConsumedByScene = false;
+ if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
+ {
+ UIScene *pScene = nullptr;
+
+ // Search by layer priority across all groups (layer-first).
+ // Tooltip layer is skipped because it holds non-interactive
+ // overlays (button hints, timer) that should never capture mouse.
+ // Old group-first order found those tooltips on eUIGroup_Fullscreen
+ // before reaching in-game menus on eUIGroup_Player1.
+ static const EUILayer mouseLayers[] = {
#ifndef _CONTENT_PACKAGE
- eUILayer_Debug,
+ eUILayer_Debug,
#endif
eUILayer_Error,
eUILayer_Alert,
@@ -811,7 +812,7 @@ void UIController::tickInput()
};
// Only check the fullscreen group and the primary (KBM) player's group.
// Other splitscreen players use controllers — mouse must not affect them.
- const int mouseGroups[] = { (int)eUIGroup_Fullscreen, ProfileManager.GetPrimaryPad() + 1 };
+ const int mouseGroups[] = { static_cast<int>(eUIGroup_Fullscreen), ProfileManager.GetPrimaryPad() + 1 };
for (int l = 0; l < _countof(mouseLayers) && !pScene; ++l)
{
for (int g = 0; g < _countof(mouseGroups) && !pScene; ++g)
@@ -820,9 +821,25 @@ void UIController::tickInput()
}
}
if (pScene && pScene->getMovie())
- {
- int rawMouseX = g_KBMInput.GetMouseX();
- int rawMouseY = g_KBMInput.GetMouseY();
+ {
+ int rawMouseX = g_KBMInput.GetMouseX();
+ int rawMouseY = g_KBMInput.GetMouseY();
+ F32 mouseX = static_cast<F32>(rawMouseX);
+ F32 mouseY = static_cast<F32>(rawMouseY);
+
+ extern HWND g_hWnd;
+ if (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)
+ {
+ mouseX = mouseX * (m_fScreenWidth / static_cast<F32>(winW));
+ mouseY = mouseY * (m_fScreenHeight / static_cast<F32>(winH));
+ }
+ }
// Only update hover focus when the mouse has actually moved,
// so that mouse-wheel scrolling can change list selection
@@ -837,8 +854,8 @@ void UIController::tickInput()
// 1. Map window pixels -> UIController screen space
// 2. Subtract the viewport tile origin
// 3. Scale from display dimensions to SWF authoring dimensions
- F32 sceneMouseX = (F32)rawMouseX;
- F32 sceneMouseY = (F32)rawMouseY;
+ F32 sceneMouseX = static_cast<F32>(rawMouseX);
+ F32 sceneMouseY = static_cast<F32>(rawMouseY);
{
extern HWND g_hWnd;
RECT rc;
@@ -849,8 +866,8 @@ void UIController::tickInput()
if (winW > 0 && winH > 0)
{
// Step 1: window pixels -> screen space
- F32 screenX = sceneMouseX * (getScreenWidth() / (F32)winW);
- F32 screenY = sceneMouseY * (getScreenHeight() / (F32)winH);
+ F32 screenX = sceneMouseX * (getScreenWidth() / static_cast<F32>(winW));
+ F32 screenY = sceneMouseY * (getScreenHeight() / static_cast<F32>(winH));
// Step 2 & 3: account for split-screen viewport
C4JRender::eViewportType vp = pScene->GetParentLayer()->getViewport();
@@ -862,15 +879,15 @@ void UIController::tickInput()
// All viewports use Fit16x9 for menu scenes
S32 fitW, fitH, fitOffsetX, fitOffsetY;
Fit16x9(vpW, vpH, fitW, fitH, fitOffsetX, fitOffsetY);
- S32 originX = (S32)vpOriginX + fitOffsetX;
- S32 originY = (S32)vpOriginY + fitOffsetY;
+ S32 originX = static_cast<S32>(vpOriginX) + fitOffsetX;
+ S32 originY = static_cast<S32>(vpOriginY) + fitOffsetY;
displayW = fitW;
displayH = fitH;
if (displayW > 0 && displayH > 0)
{
- sceneMouseX = (screenX - originX) * ((F32)pScene->getRenderWidth() / (F32)displayW);
- sceneMouseY = (screenY - originY) * ((F32)pScene->getRenderHeight() / (F32)displayH);
+ sceneMouseX = (screenX - originX) * (static_cast<F32>(pScene->getRenderWidth()) / static_cast<F32>(displayW));
+ sceneMouseY = (screenY - originY) * (static_cast<F32>(pScene->getRenderHeight()) / static_cast<F32>(displayH));
}
}
}
@@ -923,7 +940,7 @@ void UIController::tickInput()
// TexturePackList origin is where the slot area starts,
// not the top-left of the whole control — use GetRealHeight.
if (type == UIControl::eTexturePackList)
- ch = ((UIControl_TexturePackList *)ctrl)->GetRealHeight();
+ ch = static_cast<UIControl_TexturePackList*>(ctrl)->GetRealHeight();
if (cw <= 0 || ch <= 0)
continue;
@@ -934,8 +951,8 @@ void UIController::tickInput()
{
// ButtonList manages focus internally via Flash —
// pass mouse coords so it can highlight the right item.
- ((UIControl_ButtonList *)ctrl)->SetTouchFocus(
- (S32)sceneMouseX, (S32)sceneMouseY, false);
+ static_cast<UIControl_ButtonList*>(ctrl)->SetTouchFocus(
+ static_cast<S32>(sceneMouseX), static_cast<S32>(sceneMouseY), false);
hitControlId = -1;
hitArea = INT_MAX;
hitCtrl = NULL;
@@ -944,10 +961,10 @@ void UIController::tickInput()
if (type == UIControl::eTexturePackList)
{
// TexturePackList expects coords relative to its origin.
- UIControl_TexturePackList *pList = (UIControl_TexturePackList *)ctrl;
+ UIControl_TexturePackList *pList = static_cast<UIControl_TexturePackList*>(ctrl);
pScene->SetFocusToElement(ctrl->getId());
pList->SetTouchFocus(
- (S32)(sceneMouseX - cx), (S32)(sceneMouseY - cy), false);
+ static_cast<S32>(sceneMouseX - cx), static_cast<S32>(sceneMouseY - cy), false);
m_bMouseHoverHorizontalList = true;
hitControlId = -1;
hitArea = INT_MAX;
@@ -983,7 +1000,7 @@ void UIController::tickInput()
// happens after both tickInput and scene tick, so no flicker.
if (hitCtrl && hitCtrl->getControlType() == UIControl::eTextInput)
{
- ((UIControl_TextInput *)hitCtrl)->setCaretVisible(false);
+ static_cast<UIControl_TextInput*>(hitCtrl)->setCaretVisible(false);
}
}
}
@@ -1049,7 +1066,7 @@ void UIController::tickInput()
if (pMainPanel && ctrl->getParentPanel() != pMainPanel)
continue;
- UIControl_Slider *pSlider = (UIControl_Slider *)ctrl;
+ UIControl_Slider *pSlider = static_cast<UIControl_Slider *>(ctrl);
pSlider->UpdateControl();
S32 cx = pSlider->getXPos() + panelOffsetX;
S32 cy = pSlider->getYPos() + panelOffsetY;
@@ -1078,7 +1095,7 @@ void UIController::tickInput()
S32 sliderWidth = pSlider->GetRealWidth();
if (sliderWidth > 0)
{
- float fNewSliderPos = (sceneMouseX - (float)sliderX) / (float)sliderWidth;
+ float fNewSliderPos = (sceneMouseX - static_cast<float>(sliderX)) / static_cast<float>(sliderWidth);
if (fNewSliderPos < 0.0f) fNewSliderPos = 0.0f;
if (fNewSliderPos > 1.0f) fNewSliderPos = 1.0f;
pSlider->SetSliderTouchPos(fNewSliderPos);
@@ -1165,7 +1182,7 @@ void UIController::handleInput()
if(ProfileManager.GetLockedProfile() >= 0 && !InputManager.IsPadLocked( ProfileManager.GetLockedProfile() ) && firstUnfocussedUnhandledPad >= 0)
{
- ProfileManager.RequestSignInUI(false, false, false, false, true, NULL, NULL, firstUnfocussedUnhandledPad );
+ ProfileManager.RequestSignInUI(false, false, false, false, true, nullptr, nullptr, firstUnfocussedUnhandledPad );
}
}
#endif
@@ -1192,8 +1209,8 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
if((m_bTouchscreenPressed==false) && pTouchData->reportNum==1)
{
// no active touch? clear active and highlighted touch UI elements
- m_ActiveUIElement = NULL;
- m_HighlightedUIElement = NULL;
+ m_ActiveUIElement = nullptr;
+ m_HighlightedUIElement = nullptr;
// fullscreen first
UIScene *pScene=m_groups[(int)eUIGroup_Fullscreen]->getCurrentScene();
@@ -1493,7 +1510,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
IggyMemoryUseInfo memoryInfo;
rrbool res;
int iteration = 0;
- while(res = IggyDebugGetMemoryUseInfo ( NULL ,
+ while(res = IggyDebugGetMemoryUseInfo ( nullptr ,
m_iggyLibraries[i] ,
"" ,
0 ,
@@ -1524,7 +1541,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
bool handled = false;
// Send the key to the fullscreen group first
- m_groups[(int)eUIGroup_Fullscreen]->handleInput(iPad, key, repeat, pressed, released, handled);
+ m_groups[static_cast<int>(eUIGroup_Fullscreen)]->handleInput(iPad, key, repeat, pressed, released, handled);
if(!handled)
{
// If it's not been handled yet, then pass the event onto the players specific group
@@ -1535,9 +1552,9 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
rrbool RADLINK UIController::ExternalFunctionCallback( void * user_callback_data , Iggy * player , IggyExternalFunctionCallUTF16 * call)
{
- UIScene *scene = (UIScene *)IggyPlayerGetUserdata(player);
+ UIScene *scene = static_cast<UIScene *>(IggyPlayerGetUserdata(player));
- if(scene != NULL)
+ if(scene != nullptr)
{
scene->externalCallback(call);
}
@@ -1610,8 +1627,8 @@ void UIController::getRenderDimensions(C4JRender::eViewportType viewport, S32 &w
else
{
// Split-screen: use raw viewport dims — the SWF tiling code handles non-16:9
- width = (S32)viewW;
- height = (S32)viewH;
+ width = static_cast<S32>(viewW);
+ height = static_cast<S32>(viewH);
}
}
@@ -1628,14 +1645,14 @@ void UIController::setupRenderPosition(C4JRender::eViewportType viewport)
{
S32 fitW, fitH, fitOffsetX, fitOffsetY;
Fit16x9(vpW, vpH, fitW, fitH, fitOffsetX, fitOffsetY);
- xPos = (S32)vpOriginX + fitOffsetX;
- yPos = (S32)vpOriginY + fitOffsetY;
+ xPos = static_cast<S32>(vpOriginX) + fitOffsetX;
+ yPos = static_cast<S32>(vpOriginY) + fitOffsetY;
}
else
{
// Split-screen: position at viewport origin, no 16:9 fitting
- xPos = (S32)vpOriginX;
- yPos = (S32)vpOriginY;
+ xPos = static_cast<S32>(vpOriginX);
+ yPos = static_cast<S32>(vpOriginY);
}
m_tileOriginX = xPos;
@@ -1699,8 +1716,8 @@ void UIController::setupCustomDrawMatrices(UIScene *scene, CustomDrawData *custo
Minecraft *pMinecraft=Minecraft::GetInstance();
// Clear just the region required for this control.
- float sceneWidth = (float)scene->getRenderWidth();
- float sceneHeight = (float)scene->getRenderHeight();
+ float sceneWidth = static_cast<float>(scene->getRenderWidth());
+ float sceneHeight = static_cast<float>(scene->getRenderHeight());
LONG left, right, top, bottom;
#ifdef __PS3__
@@ -1728,10 +1745,10 @@ void UIController::setupCustomDrawMatrices(UIScene *scene, CustomDrawData *custo
if(!m_bScreenWidthSetup)
{
Minecraft *pMinecraft=Minecraft::GetInstance();
- if(pMinecraft != NULL)
+ if(pMinecraft != nullptr)
{
- m_fScreenWidth=(float)pMinecraft->width_phys;
- m_fScreenHeight=(float)pMinecraft->height_phys;
+ m_fScreenWidth=static_cast<float>(pMinecraft->width_phys);
+ m_fScreenHeight=static_cast<float>(pMinecraft->height_phys);
m_bScreenWidthSetup = true;
}
}
@@ -1775,9 +1792,9 @@ void UIController::endCustomDrawGameStateAndMatrices()
void RADLINK UIController::CustomDrawCallback(void *user_callback_data, Iggy *player, IggyCustomDrawCallbackRegion *region)
{
- UIScene *scene = (UIScene *)IggyPlayerGetUserdata(player);
+ UIScene *scene = static_cast<UIScene *>(IggyPlayerGetUserdata(player));
- if(scene != NULL)
+ if(scene != nullptr)
{
scene->customDraw(region);
}
@@ -1789,7 +1806,7 @@ void RADLINK UIController::CustomDrawCallback(void *user_callback_data, Iggy *pl
//width - Input value: optional number of pixels wide specified from AS3, or -1 if not defined. Output value: the number of pixels wide to pretend to Iggy that the bitmap is. SWF and AS3 scales bitmaps based on their pixel dimensions, so you can use this to substitute a texture that is higher or lower resolution that ActionScript thinks it is.
//height - Input value: optional number of pixels high specified from AS3, or -1 if not defined. Output value: the number of pixels high to pretend to Iggy that the bitmap is. SWF and AS3 scales bitmaps based on their pixel dimensions, so you can use this to substitute a texture that is higher or lower resolution that ActionScript thinks it is.
//destroy_callback_data - Optional additional output value you can set; the value will be passed along to the corresponding Iggy_TextureSubstitutionDestroyCallback (e.g. you can store the pointer to your own internal structure here).
-//return - A platform-independent wrapped texture handle provided by GDraw, or NULL (NULL with throw an ActionScript 3 ArgumentError that the Flash developer can catch) Use by calling IggySetTextureSubstitutionCallbacks.
+//return - A platform-independent wrapped texture handle provided by GDraw, or nullptr (nullptr with throw an ActionScript 3 ArgumentError that the Flash developer can catch) Use by calling IggySetTextureSubstitutionCallbacks.
//
//Discussion
//
@@ -1804,7 +1821,7 @@ GDrawTexture * RADLINK UIController::TextureSubstitutionCreateCallback ( void *
app.DebugPrintf("Found substitution texture %ls, with %d bytes\n", texture_name,it->second.length);
BufferedImage image(it->second.data, it->second.length);
- if( image.getData() != NULL )
+ if( image.getData() != nullptr )
{
image.preMultiplyAlpha();
Textures *t = Minecraft::GetInstance()->textures;
@@ -1822,18 +1839,18 @@ GDrawTexture * RADLINK UIController::TextureSubstitutionCreateCallback ( void *
#endif
*destroy_callback_data = (void *)id;
- app.DebugPrintf("Found substitution texture %ls (%d) - %dx%d\n", (wchar_t *)texture_name, id, image.getWidth(), image.getHeight());
+ app.DebugPrintf("Found substitution texture %ls (%d) - %dx%d\n", static_cast<wchar_t *>(texture_name), id, image.getWidth(), image.getHeight());
return ui.getSubstitutionTexture(id);
}
else
{
- return NULL;
+ return nullptr;
}
}
else
{
- app.DebugPrintf("Could not find substitution texture %ls\n", (wchar_t *)texture_name);
- return NULL;
+ app.DebugPrintf("Could not find substitution texture %ls\n", static_cast<wchar_t *>(texture_name));
+ return nullptr;
}
}
@@ -1843,7 +1860,7 @@ void RADLINK UIController::TextureSubstitutionDestroyCallback ( void * user_call
{
// Orbis complains about casting a pointer to an int
LONGLONG llVal=(LONGLONG)destroy_callback_data;
- int id=(int)llVal;
+ int id=static_cast<int>(llVal);
app.DebugPrintf("Destroying iggy texture %d\n", id);
ui.destroySubstitutionTexture(user_callback_data, handle);
@@ -1948,7 +1965,7 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI
if( ( iPad != 255 ) && ( iPad >= 0 ) )
{
menuDisplayedPad = iPad;
- group = (EUIGroup)(iPad+1);
+ group = static_cast<EUIGroup>(iPad + 1);
}
else group = eUIGroup_Fullscreen;
}
@@ -1963,7 +1980,7 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI
EnterCriticalSection(&m_navigationLock);
SetMenuDisplayed(menuDisplayedPad,true);
- bool success = m_groups[(int)group]->NavigateToScene(iPad, scene, initData, layer);
+ bool success = m_groups[static_cast<int>(group)]->NavigateToScene(iPad, scene, initData, layer);
if(success && group == eUIGroup_Fullscreen) setFullscreenMenuDisplayed(true);
LeaveCriticalSection(&m_navigationLock);
@@ -1978,18 +1995,18 @@ bool UIController::NavigateBack(int iPad, bool forceUsePad, EUIScene eScene, EUI
bool navComplete = false;
if( app.GetGameStarted() )
{
- bool navComplete = m_groups[(int)eUIGroup_Fullscreen]->NavigateBack(iPad, eScene, eLayer);
+ bool navComplete = m_groups[static_cast<int>(eUIGroup_Fullscreen)]->NavigateBack(iPad, eScene, eLayer);
if(!navComplete && ( iPad != 255 ) && ( iPad >= 0 ) )
{
- EUIGroup group = (EUIGroup)(iPad+1);
- navComplete = m_groups[(int)group]->NavigateBack(iPad, eScene, eLayer);
- if(!m_groups[(int)group]->GetMenuDisplayed())SetMenuDisplayed(iPad,false);
+ EUIGroup group = static_cast<EUIGroup>(iPad + 1);
+ navComplete = m_groups[static_cast<int>(group)]->NavigateBack(iPad, eScene, eLayer);
+ if(!m_groups[static_cast<int>(group)]->GetMenuDisplayed())SetMenuDisplayed(iPad,false);
}
// 4J-PB - autosave in fullscreen doesn't clear the menuDisplayed flag
else
{
- if(!m_groups[(int)eUIGroup_Fullscreen]->GetMenuDisplayed())
+ if(!m_groups[static_cast<int>(eUIGroup_Fullscreen)]->GetMenuDisplayed())
{
setFullscreenMenuDisplayed(false);
for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
@@ -2001,8 +2018,8 @@ bool UIController::NavigateBack(int iPad, bool forceUsePad, EUIScene eScene, EUI
}
else
{
- navComplete = m_groups[(int)eUIGroup_Fullscreen]->NavigateBack(iPad, eScene, eLayer);
- if(!m_groups[(int)eUIGroup_Fullscreen]->GetMenuDisplayed()) SetMenuDisplayed(XUSER_INDEX_ANY,false);
+ navComplete = m_groups[static_cast<int>(eUIGroup_Fullscreen)]->NavigateBack(iPad, eScene, eLayer);
+ if(!m_groups[static_cast<int>(eUIGroup_Fullscreen)]->GetMenuDisplayed()) SetMenuDisplayed(XUSER_INDEX_ANY,false);
}
return navComplete;
}
@@ -2023,11 +2040,11 @@ void UIController::NavigateToHomeMenu()
TexturePack *pTexPack=Minecraft::GetInstance()->skins->getSelected();
- DLCTexturePack *pDLCTexPack=NULL;
+ DLCTexturePack *pDLCTexPack=nullptr;
if(pTexPack->hasAudio())
{
// get the dlc texture pack, and store it
- pDLCTexPack=(DLCTexturePack *)pTexPack;
+ pDLCTexPack=static_cast<DLCTexturePack *>(pTexPack);
}
// change to the default texture pack
@@ -2044,11 +2061,11 @@ void UIController::NavigateToHomeMenu()
eStream_CD_1);
pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 1, 1);
- // if(pDLCTexPack->m_pStreamedWaveBank!=NULL)
+ // if(pDLCTexPack->m_pStreamedWaveBank!=nullptr)
// {
// pDLCTexPack->m_pStreamedWaveBank->Destroy();
// }
- // if(pDLCTexPack->m_pSoundBank!=NULL)
+ // if(pDLCTexPack->m_pSoundBank!=nullptr)
// {
// pDLCTexPack->m_pSoundBank->Destroy();
// }
@@ -2082,7 +2099,7 @@ UIScene *UIController::GetTopScene(int iPad, EUILayer layer, EUIGroup group)
// If the game isn't running treat as user 0, otherwise map index directly from pad
if( ( iPad != 255 ) && ( iPad >= 0 ) )
{
- group = (EUIGroup)(iPad+1);
+ group = static_cast<EUIGroup>(iPad + 1);
}
else group = eUIGroup_Fullscreen;
}
@@ -2092,7 +2109,7 @@ UIScene *UIController::GetTopScene(int iPad, EUILayer layer, EUIGroup group)
group = eUIGroup_Fullscreen;
}
}
- return m_groups[(int)group]->GetTopScene(layer);
+ return m_groups[static_cast<int>(group)]->GetTopScene(layer);
}
size_t UIController::RegisterForCallbackId(UIScene *scene)
@@ -2119,7 +2136,7 @@ void UIController::UnregisterCallbackId(size_t id)
UIScene *UIController::GetSceneFromCallbackId(size_t id)
{
- UIScene *scene = NULL;
+ UIScene *scene = nullptr;
auto it = m_registeredCallbackScenes.find(id);
if(it != m_registeredCallbackScenes.end() )
{
@@ -2140,7 +2157,7 @@ void UIController::LeaveCallbackIdCriticalSection()
void UIController::CloseAllPlayersScenes()
{
- m_groups[(int)eUIGroup_Fullscreen]->getTooltips()->SetTooltips(-1);
+ m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getTooltips()->SetTooltips(-1);
for(unsigned int i = 0; i < eUIGroup_COUNT; ++i)
{
//m_bCloseAllScenes[i] = true;
@@ -2163,7 +2180,7 @@ void UIController::CloseUIScenes(int iPad, bool forceIPad)
if( app.GetGameStarted() || forceIPad )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
@@ -2171,22 +2188,22 @@ void UIController::CloseUIScenes(int iPad, bool forceIPad)
group = eUIGroup_Fullscreen;
}
- m_groups[(int)group]->closeAllScenes();
- m_groups[(int)group]->getTooltips()->SetTooltips(-1);
+ m_groups[static_cast<int>(group)]->closeAllScenes();
+ m_groups[static_cast<int>(group)]->getTooltips()->SetTooltips(-1);
// This should cause the popup to dissappear
TutorialPopupInfo popupInfo;
- if(m_groups[(int)group]->getTutorialPopup()) m_groups[(int)group]->getTutorialPopup()->SetTutorialDescription(&popupInfo);
+ if(m_groups[static_cast<int>(group)]->getTutorialPopup()) m_groups[static_cast<int>(group)]->getTutorialPopup()->SetTutorialDescription(&popupInfo);
if(group==eUIGroup_Fullscreen) setFullscreenMenuDisplayed(false);
- SetMenuDisplayed((group == eUIGroup_Fullscreen ? XUSER_INDEX_ANY : iPad), m_groups[(int)group]->GetMenuDisplayed());
+ SetMenuDisplayed((group == eUIGroup_Fullscreen ? XUSER_INDEX_ANY : iPad), m_groups[static_cast<int>(group)]->GetMenuDisplayed());
}
void UIController::setFullscreenMenuDisplayed(bool displayed)
{
// Show/hide the tooltips for the fullscreen group
- m_groups[(int)eUIGroup_Fullscreen]->showComponent(ProfileManager.GetPrimaryPad(),eUIComponent_Tooltips,eUILayer_Tooltips,displayed);
+ m_groups[static_cast<int>(eUIGroup_Fullscreen)]->showComponent(ProfileManager.GetPrimaryPad(),eUIComponent_Tooltips,eUILayer_Tooltips,displayed);
// Show/hide tooltips for the other layers
for(unsigned int i = (eUIGroup_Fullscreen+1); i < eUIGroup_COUNT; ++i)
@@ -2201,14 +2218,14 @@ bool UIController::IsPauseMenuDisplayed(int iPad)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- return m_groups[(int)group]->IsPauseMenuDisplayed();
+ return m_groups[static_cast<int>(group)]->IsPauseMenuDisplayed();
}
bool UIController::IsContainerMenuDisplayed(int iPad)
@@ -2217,14 +2234,14 @@ bool UIController::IsContainerMenuDisplayed(int iPad)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- return m_groups[(int)group]->IsContainerMenuDisplayed();
+ return m_groups[static_cast<int>(group)]->IsContainerMenuDisplayed();
}
bool UIController::IsIgnorePlayerJoinMenuDisplayed(int iPad)
@@ -2233,14 +2250,14 @@ bool UIController::IsIgnorePlayerJoinMenuDisplayed(int iPad)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- return m_groups[(int)group]->IsIgnorePlayerJoinMenuDisplayed();
+ return m_groups[static_cast<int>(group)]->IsIgnorePlayerJoinMenuDisplayed();
}
bool UIController::IsIgnoreAutosaveMenuDisplayed(int iPad)
@@ -2249,14 +2266,14 @@ bool UIController::IsIgnoreAutosaveMenuDisplayed(int iPad)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- return m_groups[(int)eUIGroup_Fullscreen]->IsIgnoreAutosaveMenuDisplayed() || (group != eUIGroup_Fullscreen && m_groups[(int)group]->IsIgnoreAutosaveMenuDisplayed());
+ return m_groups[static_cast<int>(eUIGroup_Fullscreen)]->IsIgnoreAutosaveMenuDisplayed() || (group != eUIGroup_Fullscreen && m_groups[static_cast<int>(group)]->IsIgnoreAutosaveMenuDisplayed());
}
void UIController::SetIgnoreAutosaveMenuDisplayed(int iPad, bool displayed)
@@ -2270,14 +2287,14 @@ bool UIController::IsSceneInStack(int iPad, EUIScene eScene)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- return m_groups[(int)group]->IsSceneInStack(eScene);
+ return m_groups[static_cast<int>(group)]->IsSceneInStack(eScene);
}
bool UIController::GetMenuDisplayed(int iPad)
@@ -2358,14 +2375,14 @@ void UIController::SetTooltipText( unsigned int iPad, unsigned int tooltip, int
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->SetTooltipText(tooltip, iTextID);
+ if(m_groups[static_cast<int>(group)]->getTooltips()) m_groups[static_cast<int>(group)]->getTooltips()->SetTooltipText(tooltip, iTextID);
}
void UIController::SetEnableTooltips( unsigned int iPad, BOOL bVal )
@@ -2374,14 +2391,14 @@ void UIController::SetEnableTooltips( unsigned int iPad, BOOL bVal )
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->SetEnableTooltips(bVal);
+ if(m_groups[static_cast<int>(group)]->getTooltips()) m_groups[static_cast<int>(group)]->getTooltips()->SetEnableTooltips(bVal);
}
void UIController::ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show )
@@ -2390,14 +2407,14 @@ void UIController::ShowTooltip( unsigned int iPad, unsigned int tooltip, bool sh
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->ShowTooltip(tooltip,show);
+ if(m_groups[static_cast<int>(group)]->getTooltips()) m_groups[static_cast<int>(group)]->getTooltips()->ShowTooltip(tooltip,show);
}
void UIController::SetTooltips( unsigned int iPad, int iA, int iB, int iX, int iY, int iLT, int iRT, int iLB, int iRB, int iLS, int iRS, int iBack, bool forceUpdate)
@@ -2419,14 +2436,14 @@ void UIController::SetTooltips( unsigned int iPad, int iA, int iB, int iX, int i
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->SetTooltips(iA, iB, iX, iY, iLT, iRT, iLB, iRB, iLS, iRS, iBack, forceUpdate);
+ if(m_groups[static_cast<int>(group)]->getTooltips()) m_groups[static_cast<int>(group)]->getTooltips()->SetTooltips(iA, iB, iX, iY, iLT, iRT, iLB, iRB, iLS, iRS, iBack, forceUpdate);
}
void UIController::EnableTooltip( unsigned int iPad, unsigned int tooltip, bool enable )
@@ -2435,14 +2452,14 @@ void UIController::EnableTooltip( unsigned int iPad, unsigned int tooltip, bool
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->EnableTooltip(tooltip,enable);
+ if(m_groups[static_cast<int>(group)]->getTooltips()) m_groups[static_cast<int>(group)]->getTooltips()->EnableTooltip(tooltip,enable);
}
void UIController::RefreshTooltips(unsigned int iPad)
@@ -2461,7 +2478,7 @@ void UIController::AnimateKeyPress(int iPad, int iAction, bool bRepeat, bool bPr
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
@@ -2469,7 +2486,7 @@ void UIController::AnimateKeyPress(int iPad, int iAction, bool bRepeat, bool bPr
group = eUIGroup_Fullscreen;
}
bool handled = false;
- if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->handleInput(iPad, iAction, bRepeat, bPressed, bReleased, handled);
+ if(m_groups[static_cast<int>(group)]->getTooltips()) m_groups[static_cast<int>(group)]->getTooltips()->handleInput(iPad, iAction, bRepeat, bPressed, bReleased, handled);
}
void UIController::OverrideSFX(int iPad, int iAction,bool bVal)
@@ -2479,7 +2496,7 @@ void UIController::OverrideSFX(int iPad, int iAction,bool bVal)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
@@ -2487,7 +2504,7 @@ void UIController::OverrideSFX(int iPad, int iAction,bool bVal)
group = eUIGroup_Fullscreen;
}
bool handled = false;
- if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->overrideSFX(iPad, iAction,bVal);
+ if(m_groups[static_cast<int>(group)]->getTooltips()) m_groups[static_cast<int>(group)]->getTooltips()->overrideSFX(iPad, iAction,bVal);
}
void UIController::PlayUISFX(ESoundEffect eSound)
@@ -2515,13 +2532,13 @@ void UIController::DisplayGamertag(unsigned int iPad, bool show)
{
show = false;
}
- EUIGroup group = (EUIGroup)(iPad+1);
- if(m_groups[(int)group]->getHUD()) m_groups[(int)group]->getHUD()->ShowDisplayName(show);
+ EUIGroup group = static_cast<EUIGroup>(iPad + 1);
+ if(m_groups[static_cast<int>(group)]->getHUD()) m_groups[static_cast<int>(group)]->getHUD()->ShowDisplayName(show);
// Update TutorialPopup in Splitscreen if no container is displayed (to make sure the Popup does not overlap with the Gamertag!)
- if(app.GetLocalPlayerCount() > 1 && m_groups[(int)group]->getTutorialPopup() && !m_groups[(int)group]->IsContainerMenuDisplayed())
+ if(app.GetLocalPlayerCount() > 1 && m_groups[static_cast<int>(group)]->getTutorialPopup() && !m_groups[static_cast<int>(group)]->IsContainerMenuDisplayed())
{
- m_groups[(int)group]->getTutorialPopup()->UpdateTutorialPopup();
+ m_groups[static_cast<int>(group)]->getTutorialPopup()->UpdateTutorialPopup();
}
}
@@ -2532,7 +2549,7 @@ void UIController::SetSelectedItem(unsigned int iPad, const wstring &name)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
@@ -2540,7 +2557,7 @@ void UIController::SetSelectedItem(unsigned int iPad, const wstring &name)
group = eUIGroup_Fullscreen;
}
bool handled = false;
- if(m_groups[(int)group]->getHUD()) m_groups[(int)group]->getHUD()->SetSelectedLabel(name);
+ if(m_groups[static_cast<int>(group)]->getHUD()) m_groups[static_cast<int>(group)]->getHUD()->SetSelectedLabel(name);
}
void UIController::UpdateSelectedItemPos(unsigned int iPad)
@@ -2593,10 +2610,10 @@ void UIController::HandleInventoryUpdated(int iPad)
EUIGroup group = eUIGroup_Fullscreen;
if( app.GetGameStarted() && ( iPad != 255 ) && ( iPad >= 0 ) )
{
- group = (EUIGroup)(iPad+1);
+ group = static_cast<EUIGroup>(iPad + 1);
}
- m_groups[group]->HandleMessage(eUIMessage_InventoryUpdated, NULL);
+ m_groups[group]->HandleMessage(eUIMessage_InventoryUpdated, nullptr);
}
void UIController::HandleGameTick()
@@ -2615,14 +2632,14 @@ void UIController::SetTutorial(int iPad, Tutorial *tutorial)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- if(m_groups[(int)group]->getTutorialPopup()) m_groups[(int)group]->getTutorialPopup()->SetTutorial(tutorial);
+ if(m_groups[static_cast<int>(group)]->getTutorialPopup()) m_groups[static_cast<int>(group)]->getTutorialPopup()->SetTutorial(tutorial);
}
void UIController::SetTutorialDescription(int iPad, TutorialPopupInfo *info)
@@ -2631,7 +2648,7 @@ void UIController::SetTutorialDescription(int iPad, TutorialPopupInfo *info)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
@@ -2639,11 +2656,11 @@ void UIController::SetTutorialDescription(int iPad, TutorialPopupInfo *info)
group = eUIGroup_Fullscreen;
}
- if(m_groups[(int)group]->getTutorialPopup())
+ if(m_groups[static_cast<int>(group)]->getTutorialPopup())
{
// tutorial popup needs to know if a container menu is being displayed
- m_groups[(int)group]->getTutorialPopup()->SetContainerMenuVisible(m_groups[(int)group]->IsContainerMenuDisplayed());
- m_groups[(int)group]->getTutorialPopup()->SetTutorialDescription(info);
+ m_groups[static_cast<int>(group)]->getTutorialPopup()->SetContainerMenuVisible(m_groups[static_cast<int>(group)]->IsContainerMenuDisplayed());
+ m_groups[static_cast<int>(group)]->getTutorialPopup()->SetTutorialDescription(info);
}
}
@@ -2651,9 +2668,9 @@ void UIController::SetTutorialDescription(int iPad, TutorialPopupInfo *info)
void UIController::RemoveInteractSceneReference(int iPad, UIScene *scene)
{
EUIGroup group;
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
- if(m_groups[(int)group]->getTutorialPopup()) m_groups[(int)group]->getTutorialPopup()->RemoveInteractSceneReference(scene);
+ if(m_groups[static_cast<int>(group)]->getTutorialPopup()) m_groups[static_cast<int>(group)]->getTutorialPopup()->RemoveInteractSceneReference(scene);
}
#endif
@@ -2663,14 +2680,14 @@ void UIController::SetTutorialVisible(int iPad, bool visible)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
{
group = eUIGroup_Fullscreen;
}
- if(m_groups[(int)group]->getTutorialPopup()) m_groups[(int)group]->getTutorialPopup()->SetVisible(visible);
+ if(m_groups[static_cast<int>(group)]->getTutorialPopup()) m_groups[static_cast<int>(group)]->getTutorialPopup()->SetVisible(visible);
}
bool UIController::IsTutorialVisible(int iPad)
@@ -2679,7 +2696,7 @@ bool UIController::IsTutorialVisible(int iPad)
if( app.GetGameStarted() )
{
// If the game isn't running treat as user 0, otherwise map index directly from pad
- if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = (EUIGroup)(iPad+1);
+ if( ( iPad != 255 ) && ( iPad >= 0 ) ) group = static_cast<EUIGroup>(iPad + 1);
else group = eUIGroup_Fullscreen;
}
else
@@ -2687,7 +2704,7 @@ bool UIController::IsTutorialVisible(int iPad)
group = eUIGroup_Fullscreen;
}
bool visible = false;
- if(m_groups[(int)group]->getTutorialPopup()) visible = m_groups[(int)group]->getTutorialPopup()->IsVisible();
+ if(m_groups[static_cast<int>(group)]->getTutorialPopup()) visible = m_groups[static_cast<int>(group)]->getTutorialPopup()->IsVisible();
return visible;
}
@@ -2697,7 +2714,7 @@ void UIController::UpdatePlayerBasePositions()
for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx)
{
- if(pMinecraft->localplayers[idx] != NULL)
+ if(pMinecraft->localplayers[idx] != nullptr)
{
if(pMinecraft->localplayers[idx]->m_iScreenSection==C4JRender::VIEWPORT_TYPE_FULLSCREEN)
{
@@ -2707,7 +2724,7 @@ void UIController::UpdatePlayerBasePositions()
{
DisplayGamertag(idx,true);
}
- m_groups[idx+1]->SetViewportType((C4JRender::eViewportType)pMinecraft->localplayers[idx]->m_iScreenSection);
+ m_groups[idx+1]->SetViewportType(static_cast<C4JRender::eViewportType>(pMinecraft->localplayers[idx]->m_iScreenSection));
}
else
{
@@ -2740,7 +2757,7 @@ void UIController::ShowOtherPlayersBaseScene(unsigned int iPad, bool show)
void UIController::ShowTrialTimer(bool show)
{
- if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showTrialTimer(show);
+ if(m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()->showTrialTimer(show);
}
void UIController::SetTrialTimerLimitSecs(unsigned int uiSeconds)
@@ -2752,7 +2769,7 @@ void UIController::UpdateTrialTimer(unsigned int iPad)
{
WCHAR wcTime[20];
- DWORD dwTimeTicks=(DWORD)app.getTrialTimer();
+ DWORD dwTimeTicks=static_cast<DWORD>(app.getTrialTimer());
if(dwTimeTicks>m_dwTrialTimerLimitSecs)
{
@@ -2771,11 +2788,11 @@ void UIController::UpdateTrialTimer(unsigned int iPad)
int iMins=dwTimeTicks/60;
int iSeconds=dwTimeTicks%60;
swprintf( wcTime, 20, L"%d:%02d",iMins,iSeconds);
- if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->setTrialTimer(wcTime);
+ if(m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()->setTrialTimer(wcTime);
}
else
{
- if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->setTrialTimer(L"");
+ if(m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()->setTrialTimer(L"");
}
// are we out of time?
@@ -2785,7 +2802,7 @@ void UIController::UpdateTrialTimer(unsigned int iPad)
// bring up the pause menu to stop the trial over message box being called again?
if(!ui.GetMenuDisplayed( iPad ) )
{
- ui.NavigateToScene(iPad, eUIScene_PauseMenu, NULL, eUILayer_Scene);
+ ui.NavigateToScene(iPad, eUIScene_PauseMenu, nullptr, eUILayer_Scene);
app.SetAction(iPad,eAppAction_TrialOver);
}
@@ -2794,7 +2811,7 @@ void UIController::UpdateTrialTimer(unsigned int iPad)
void UIController::ReduceTrialTimerValue()
{
- DWORD dwTimeTicks=(int)app.getTrialTimer();
+ DWORD dwTimeTicks=static_cast<int>(app.getTrialTimer());
if(dwTimeTicks>m_dwTrialTimerLimitSecs)
{
@@ -2806,7 +2823,7 @@ void UIController::ReduceTrialTimerValue()
void UIController::ShowAutosaveCountdownTimer(bool show)
{
- if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showTrialTimer(show);
+ if(m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()->showTrialTimer(show);
}
void UIController::UpdateAutosaveCountdownTimer(unsigned int uiSeconds)
@@ -2814,7 +2831,7 @@ void UIController::UpdateAutosaveCountdownTimer(unsigned int uiSeconds)
#if !(defined(_XBOX_ONE) || defined(__ORBIS__))
WCHAR wcAutosaveCountdown[100];
swprintf( wcAutosaveCountdown, 100, app.GetString(IDS_AUTOSAVE_COUNTDOWN),uiSeconds);
- if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->setTrialTimer(wcAutosaveCountdown);
+ if(m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()->setTrialTimer(wcAutosaveCountdown);
#endif
}
@@ -2831,12 +2848,12 @@ void UIController::ShowSavingMessage(unsigned int iPad, C4JStorage::ESavingMessa
show = true;
break;
}
- if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showSaveIcon(show);
+ if(m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()->showSaveIcon(show);
}
void UIController::ShowPlayerDisplayname(bool show)
{
- if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showPlayerDisplayName(show);
+ if(m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()->showPlayerDisplayName(show);
}
void UIController::SetWinUserIndex(unsigned int iPad)
@@ -2855,12 +2872,12 @@ void UIController::ShowUIDebugConsole(bool show)
if(show)
{
- m_uiDebugConsole = (UIComponent_DebugUIConsole *)m_groups[eUIGroup_Fullscreen]->addComponent(0, eUIComponent_DebugUIConsole, eUILayer_Debug);
+ m_uiDebugConsole = static_cast<UIComponent_DebugUIConsole *>(m_groups[eUIGroup_Fullscreen]->addComponent(0, eUIComponent_DebugUIConsole, eUILayer_Debug));
}
else
{
m_groups[eUIGroup_Fullscreen]->removeComponent(eUIComponent_DebugUIConsole, eUILayer_Debug);
- m_uiDebugConsole = NULL;
+ m_uiDebugConsole = nullptr;
}
#endif
}
@@ -2871,12 +2888,12 @@ void UIController::ShowUIDebugMarketingGuide(bool show)
if(show)
{
- m_uiDebugMarketingGuide = (UIComponent_DebugUIMarketingGuide *)m_groups[eUIGroup_Fullscreen]->addComponent(0, eUIComponent_DebugUIMarketingGuide, eUILayer_Debug);
+ m_uiDebugMarketingGuide = static_cast<UIComponent_DebugUIMarketingGuide *>(m_groups[eUIGroup_Fullscreen]->addComponent(0, eUIComponent_DebugUIMarketingGuide, eUILayer_Debug));
}
else
{
m_groups[eUIGroup_Fullscreen]->removeComponent(eUIComponent_DebugUIMarketingGuide, eUILayer_Debug);
- m_uiDebugMarketingGuide = NULL;
+ m_uiDebugMarketingGuide = nullptr;
}
#endif
}
@@ -2894,13 +2911,13 @@ bool UIController::PressStartPlaying(unsigned int iPad)
void UIController::ShowPressStart(unsigned int iPad)
{
m_iPressStartQuadrantsMask|=1<<iPad;
- if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showPressStart(iPad, true);
+ if(m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()->showPressStart(iPad, true);
}
void UIController::HidePressStart()
{
ClearPressStart();
- if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->showPressStart(0, false);
+ if(m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()) m_groups[static_cast<int>(eUIGroup_Fullscreen)]->getPressStartToPlay()->showPressStart(0, false);
}
void UIController::ClearPressStart()
@@ -2963,7 +2980,7 @@ C4JStorage::EMessageResult UIController::RequestMessageBox(UINT uiTitle, UINT ui
}
}
-C4JStorage::EMessageResult UIController::RequestUGCMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = NULL*/, LPVOID lpParam/* = NULL*/)
+C4JStorage::EMessageResult UIController::RequestUGCMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = nullptr*/, LPVOID lpParam/* = nullptr*/)
{
// Default title / messages
if (title == -1)
@@ -2995,7 +3012,7 @@ C4JStorage::EMessageResult UIController::RequestUGCMessageBox(UINT title/* = -1
#endif
}
-C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = NULL*/, LPVOID lpParam/* = NULL*/)
+C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = nullptr*/, LPVOID lpParam/* = nullptr*/)
{
// Default title / messages
if (title == -1)
@@ -3033,7 +3050,7 @@ C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(UINT
void UIController::setFontCachingCalculationBuffer(int length)
{
/* 4J-JEV: As described in an email from Sean.
- If your `optional_temp_buffer` is NULL, Iggy will allocate the temp
+ If your `optional_temp_buffer` is nullptr, Iggy will allocate the temp
buffer on the stack during Iggy draw calls. The size of the buffer it
will allocate is 16 bytes times `max_chars` in 32-bit, and 24 bytes
times `max_chars` in 64-bit. If the stack of the thread making the
@@ -3046,10 +3063,10 @@ void UIController::setFontCachingCalculationBuffer(int length)
static const int CHAR_SIZE = 16;
#endif
- if (m_tempBuffer != NULL) delete [] m_tempBuffer;
+ if (m_tempBuffer != nullptr) delete [] m_tempBuffer;
if (length<0)
{
- if (m_defaultBuffer == NULL) m_defaultBuffer = new char[CHAR_SIZE*5000];
+ if (m_defaultBuffer == nullptr) m_defaultBuffer = new char[CHAR_SIZE*5000];
IggySetFontCachingCalculationBuffer(5000, m_defaultBuffer, CHAR_SIZE*5000);
}
else
@@ -3059,16 +3076,16 @@ void UIController::setFontCachingCalculationBuffer(int length)
}
}
-// Returns the first scene of given type if it exists, NULL otherwise
+// Returns the first scene of given type if it exists, nullptr otherwise
UIScene *UIController::FindScene(EUIScene sceneType)
{
- UIScene *pScene = NULL;
+ UIScene *pScene = nullptr;
for (int i = 0; i < eUIGroup_COUNT; i++)
{
pScene = m_groups[i]->FindScene(sceneType);
#ifdef __PS3__
- if (pScene != NULL) return pScene;
+ if (pScene != nullptr) return pScene;
#else
if (pScene != nullptr) return pScene;
#endif
@@ -3234,7 +3251,7 @@ bool UIController::TouchBoxHit(UIScene *pUIScene,S32 x, S32 y)
}
//app.DebugPrintf("MISS at x = %i y = %i\n", (int)x, (int)y);
- m_HighlightedUIElement = NULL;
+ m_HighlightedUIElement = nullptr;
return false;
}