diff options
| author | qwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com> | 2026-03-16 21:44:26 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-16 21:44:26 -0500 |
| commit | ce739f6045ec72127491286ea3f3f21e537c1b55 (patch) | |
| tree | f33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.Client/Common/UI/UIController.cpp | |
| parent | 255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff) | |
| parent | 5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff) | |
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.Client/Common/UI/UIController.cpp')
| -rw-r--r-- | Minecraft.Client/Common/UI/UIController.cpp | 849 |
1 files changed, 519 insertions, 330 deletions
diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 5375b784..b12ea5e7 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -3,6 +3,7 @@ #include "UI.h" #include "UIScene.h" #include "UIControl_Slider.h" +#include "UIControl_TexturePackList.h" #include "..\..\..\Minecraft.World\StringHelpers.h" #include "..\..\LocalPlayer.h" #include "..\..\DLCTexturePack.h" @@ -12,6 +13,7 @@ #include "..\..\EnderDragonRenderer.h" #include "..\..\MultiPlayerLocalPlayer.h" #include "UIFontData.h" +#include "UISplitScreenHelpers.h" #ifdef _WINDOWS64 #include "..\..\Windows64\KeyboardMouseInput.h" #endif @@ -56,18 +58,20 @@ bool UIController::ms_bReloadSkinCSInitialised = false; DWORD UIController::m_dwTrialTimerLimitSecs=DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; +// GetViewportRect and Fit16x9 are now in UISplitScreenHelpers.h + #ifdef _WINDOWS64 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 @@ -143,11 +147,11 @@ extern "C" void *__real_malloc(size_t t); extern "C" void __real_free(void *t); #endif -__int64 UIController::iggyAllocCount = 0; +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); @@ -164,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; @@ -180,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; @@ -237,6 +241,8 @@ UIController::UIController() m_winUserIndex = 0; m_mouseDraggingSliderScene = eUIScene_COUNT; m_mouseDraggingSliderId = -1; + m_mouseClickConsumedByScene = false; + m_bMouseHoverHorizontalList = false; m_lastHoverMouseX = -1; m_lastHoverMouseY = -1; m_accumulatedTicks = 0; @@ -267,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); } @@ -307,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?" ); @@ -326,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 @@ -367,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; } } @@ -394,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(); @@ -499,7 +505,7 @@ void UIController::tick() } // Clear out the cached movie file data - __int64 currentTime = System::currentTimeMillis(); + int64_t currentTime = System::currentTimeMillis(); for (auto it = m_cachedMovieData.begin(); it != m_cachedMovieData.end();) { if(it->second.m_expiry < currentTime) @@ -516,52 +522,23 @@ void UIController::tick() void UIController::loadSkins() { - wstring platformSkinPath = L""; - #ifdef __PS3__ - platformSkinPath = L"skinPS3.swf"; -#elif defined __PSVITA__ - platformSkinPath = L"skinVita.swf"; -#elif defined _WINDOWS64 - if(m_fScreenHeight>720.0f) - { - platformSkinPath = L"skinHDWin.swf"; - } - else - { - platformSkinPath = L"skinWin.swf"; - } -#elif defined _DURANGO - if(m_fScreenHeight>720.0f) - { - platformSkinPath = L"skinHDDurango.swf"; - } - else - { - platformSkinPath = L"skinDurango.swf"; - } -#elif defined __ORBIS__ - if(m_fScreenHeight>720.0f) - { - platformSkinPath = L"skinHDOrbis.swf"; - } - else - { - platformSkinPath = L"skinOrbis.swf"; - } + m_iggyLibraries[eLibrary_Platform] = loadSkin(L"skinPS3.swf", L"platformskin.swf"); -#endif - // Every platform has one of these, so nothing shared - if(m_fScreenHeight>720.0f) - { - m_iggyLibraries[eLibrary_Platform] = loadSkin(platformSkinPath, L"platformskinHD.swf"); - } - else - { - m_iggyLibraries[eLibrary_Platform] = loadSkin(platformSkinPath, L"platformskin.swf"); - } + m_iggyLibraries[eLibrary_GraphicsDefault] = loadSkin(L"skinGraphics.swf", L"skinGraphics.swf"); + m_iggyLibraries[eLibrary_GraphicsHUD] = loadSkin(L"skinGraphicsHud.swf", L"skinGraphicsHud.swf"); + m_iggyLibraries[eLibrary_GraphicsInGame] = loadSkin(L"skinGraphicsInGame.swf", L"skinGraphicsInGame.swf"); + m_iggyLibraries[eLibrary_GraphicsTooltips] = loadSkin(L"skinGraphicsTooltips.swf", L"skinGraphicsTooltips.swf"); + m_iggyLibraries[eLibrary_GraphicsLabels] = loadSkin(L"skinGraphicsLabels.swf", L"skinGraphicsLabels.swf"); + m_iggyLibraries[eLibrary_Labels] = loadSkin(L"skinLabels.swf", L"skinLabels.swf"); + m_iggyLibraries[eLibrary_InGame] = loadSkin(L"skinInGame.swf", L"skinInGame.swf"); + m_iggyLibraries[eLibrary_HUD] = loadSkin(L"skinHud.swf", L"skinHud.swf"); + m_iggyLibraries[eLibrary_Tooltips] = loadSkin(L"skinTooltips.swf", L"skinTooltips.swf"); + m_iggyLibraries[eLibrary_Default] = loadSkin(L"skin.swf", L"skin.swf"); + +#elif defined __PSVITA__ + m_iggyLibraries[eLibrary_Platform] = loadSkin(L"skinVita.swf", L"platformskin.swf"); -#if defined(__PS3__) || defined(__PSVITA__) m_iggyLibraries[eLibrary_GraphicsDefault] = loadSkin(L"skinGraphics.swf", L"skinGraphics.swf"); m_iggyLibraries[eLibrary_GraphicsHUD] = loadSkin(L"skinGraphicsHud.swf", L"skinGraphicsHud.swf"); m_iggyLibraries[eLibrary_GraphicsInGame] = loadSkin(L"skinGraphicsInGame.swf", L"skinGraphicsInGame.swf"); @@ -572,13 +549,14 @@ void UIController::loadSkins() m_iggyLibraries[eLibrary_HUD] = loadSkin(L"skinHud.swf", L"skinHud.swf"); m_iggyLibraries[eLibrary_Tooltips] = loadSkin(L"skinTooltips.swf", L"skinTooltips.swf"); m_iggyLibraries[eLibrary_Default] = loadSkin(L"skin.swf", L"skin.swf"); -#endif -#if ( defined(_WINDOWS64) || defined(_DURANGO) || defined(__ORBIS__) ) +#elif defined _WINDOWS64 + // HD platform skin — required by skinHD*.swf (1080p scene SWFs) + m_iggyLibraries[eLibrary_Platform] = loadSkin(L"skinHDWin.swf", L"platformskinHD.swf"); + // Non-HD platform skin — required by skin*.swf (720p/480p scene SWFs) + m_iggyLibraries[eLibraryFallback_Platform] = loadSkin(L"skinWin.swf", L"platformskin.swf"); -#if defined(_WINDOWS64) - // 4J Stu - Load the 720/480 skins so that we have something to fallback on during development -#ifndef _FINAL_BUILD + // Non-HD skin set (720p/480p scenes import these) m_iggyLibraries[eLibraryFallback_GraphicsDefault] = loadSkin(L"skinGraphics.swf", L"skinGraphics.swf"); m_iggyLibraries[eLibraryFallback_GraphicsHUD] = loadSkin(L"skinGraphicsHud.swf", L"skinGraphicsHud.swf"); m_iggyLibraries[eLibraryFallback_GraphicsInGame] = loadSkin(L"skinGraphicsInGame.swf", L"skinGraphicsInGame.swf"); @@ -589,9 +567,8 @@ void UIController::loadSkins() m_iggyLibraries[eLibraryFallback_HUD] = loadSkin(L"skinHud.swf", L"skinHud.swf"); m_iggyLibraries[eLibraryFallback_Tooltips] = loadSkin(L"skinTooltips.swf", L"skinTooltips.swf"); m_iggyLibraries[eLibraryFallback_Default] = loadSkin(L"skin.swf", L"skin.swf"); -#endif -#endif + // HD skin set (1080p scenes import these) m_iggyLibraries[eLibrary_GraphicsDefault] = loadSkin(L"skinHDGraphics.swf", L"skinHDGraphics.swf"); m_iggyLibraries[eLibrary_GraphicsHUD] = loadSkin(L"skinHDGraphicsHud.swf", L"skinHDGraphicsHud.swf"); m_iggyLibraries[eLibrary_GraphicsInGame] = loadSkin(L"skinHDGraphicsInGame.swf", L"skinHDGraphicsInGame.swf"); @@ -602,7 +579,35 @@ void UIController::loadSkins() m_iggyLibraries[eLibrary_HUD] = loadSkin(L"skinHDHud.swf", L"skinHDHud.swf"); m_iggyLibraries[eLibrary_Tooltips] = loadSkin(L"skinHDTooltips.swf", L"skinHDTooltips.swf"); m_iggyLibraries[eLibrary_Default] = loadSkin(L"skinHD.swf", L"skinHD.swf"); -#endif // HD platforms + +#elif defined _DURANGO + m_iggyLibraries[eLibrary_Platform] = loadSkin(L"skinHDDurango.swf", L"platformskinHD.swf"); + + m_iggyLibraries[eLibrary_GraphicsDefault] = loadSkin(L"skinHDGraphics.swf", L"skinHDGraphics.swf"); + m_iggyLibraries[eLibrary_GraphicsHUD] = loadSkin(L"skinHDGraphicsHud.swf", L"skinHDGraphicsHud.swf"); + m_iggyLibraries[eLibrary_GraphicsInGame] = loadSkin(L"skinHDGraphicsInGame.swf", L"skinHDGraphicsInGame.swf"); + m_iggyLibraries[eLibrary_GraphicsTooltips] = loadSkin(L"skinHDGraphicsTooltips.swf", L"skinHDGraphicsTooltips.swf"); + m_iggyLibraries[eLibrary_GraphicsLabels] = loadSkin(L"skinHDGraphicsLabels.swf", L"skinHDGraphicsLabels.swf"); + m_iggyLibraries[eLibrary_Labels] = loadSkin(L"skinHDLabels.swf", L"skinHDLabels.swf"); + m_iggyLibraries[eLibrary_InGame] = loadSkin(L"skinHDInGame.swf", L"skinHDInGame.swf"); + m_iggyLibraries[eLibrary_HUD] = loadSkin(L"skinHDHud.swf", L"skinHDHud.swf"); + m_iggyLibraries[eLibrary_Tooltips] = loadSkin(L"skinHDTooltips.swf", L"skinHDTooltips.swf"); + m_iggyLibraries[eLibrary_Default] = loadSkin(L"skinHD.swf", L"skinHD.swf"); + +#elif defined __ORBIS__ + m_iggyLibraries[eLibrary_Platform] = loadSkin(L"skinHDOrbis.swf", L"platformskinHD.swf"); + + m_iggyLibraries[eLibrary_GraphicsDefault] = loadSkin(L"skinHDGraphics.swf", L"skinHDGraphics.swf"); + m_iggyLibraries[eLibrary_GraphicsHUD] = loadSkin(L"skinHDGraphicsHud.swf", L"skinHDGraphicsHud.swf"); + m_iggyLibraries[eLibrary_GraphicsInGame] = loadSkin(L"skinHDGraphicsInGame.swf", L"skinHDGraphicsInGame.swf"); + m_iggyLibraries[eLibrary_GraphicsTooltips] = loadSkin(L"skinHDGraphicsTooltips.swf", L"skinHDGraphicsTooltips.swf"); + m_iggyLibraries[eLibrary_GraphicsLabels] = loadSkin(L"skinHDGraphicsLabels.swf", L"skinHDGraphicsLabels.swf"); + m_iggyLibraries[eLibrary_Labels] = loadSkin(L"skinHDLabels.swf", L"skinHDLabels.swf"); + m_iggyLibraries[eLibrary_InGame] = loadSkin(L"skinHDInGame.swf", L"skinHDInGame.swf"); + m_iggyLibraries[eLibrary_HUD] = loadSkin(L"skinHDHud.swf", L"skinHDHud.swf"); + m_iggyLibraries[eLibrary_Tooltips] = loadSkin(L"skinHDTooltips.swf", L"skinHDTooltips.swf"); + m_iggyLibraries[eLibrary_Default] = loadSkin(L"skinHD.swf", L"skinHD.swf"); +#endif } IggyLibrary UIController::loadSkin(const wstring &skinPath, const wstring &skinName) @@ -612,20 +617,20 @@ 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 IggyMemoryUseInfo memoryInfo; rrbool res; int iteration = 0; - __int64 totalStatic = 0; - while(res = IggyDebugGetMemoryUseInfo ( NULL , - lib , - "" , - 0 , - iteration , - &memoryInfo )) + int64_t totalStatic = 0; + 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); @@ -689,7 +694,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(); @@ -724,7 +729,7 @@ bool UIController::IsExpectingOrReloadingSkin() void UIController::CleanUpSkinReload() { delete m_reloadSkinThread; - m_reloadSkinThread = NULL; + m_reloadSkinThread = nullptr; if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { @@ -750,7 +755,7 @@ void UIController::CleanUpSkinReload() byteArray UIController::getMovieData(const wstring &filename) { // Cache everything we load in the current tick - __int64 targetTime = System::currentTimeMillis() + (1000LL * 60); + int64_t targetTime = System::currentTimeMillis() + (1000LL * 60); auto it = m_cachedMovieData.find(filename); if(it == m_cachedMovieData.end() ) { @@ -784,40 +789,56 @@ void UIController::tickInput() #endif { #ifdef _WINDOWS64 - if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive()) + 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, +#endif + eUILayer_Error, + eUILayer_Alert, + eUILayer_Popup, + eUILayer_Fullscreen, + eUILayer_Scene, + }; + // 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[] = { static_cast<int>(eUIGroup_Fullscreen), ProfileManager.GetPrimaryPad() + 1 }; + for (int l = 0; l < _countof(mouseLayers) && !pScene; ++l) { - UIScene *pScene = NULL; - for (int grp = 0; grp < eUIGroup_COUNT && !pScene; ++grp) + for (int g = 0; g < _countof(mouseGroups) && !pScene; ++g) { - pScene = m_groups[grp]->GetTopScene(eUILayer_Debug); - if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Tooltips); - if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Error); - if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Alert); - if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Popup); - if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Fullscreen); - if (!pScene) pScene = m_groups[grp]->GetTopScene(eUILayer_Scene); + pScene = m_groups[mouseGroups[g]]->GetTopScene(mouseLayers[l]); } + } if (pScene && pScene->getMovie()) - { - Iggy *movie = pScene->getMovie(); - int rawMouseX = g_KBMInput.GetMouseX(); - int rawMouseY = g_KBMInput.GetMouseY(); - F32 mouseX = (F32)rawMouseX; - F32 mouseY = (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 / (F32)winW); - mouseY = mouseY * (m_fScreenHeight / (F32)winH); - } - } + { + 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 @@ -826,43 +847,48 @@ void UIController::tickInput() m_lastHoverMouseX = rawMouseX; m_lastHoverMouseY = rawMouseY; - if (mouseMoved) + // Convert mouse window-pixel coords to Flash/SWF authoring coords. + // In split-screen the scene is rendered at a tile-origin offset + // and at a smaller display size, so we must: + // 1. Map window pixels -> UIController screen space + // 2. Subtract the viewport tile origin + // 3. Scale from display dimensions to SWF authoring dimensions + F32 sceneMouseX = static_cast<F32>(rawMouseX); + F32 sceneMouseY = static_cast<F32>(rawMouseY); { - IggyFocusHandle currentFocus = IGGY_FOCUS_NULL; - IggyFocusableObject focusables[64]; - S32 numFocusables = 0; - IggyPlayerGetFocusableObjects(movie, ¤tFocus, focusables, 64, &numFocusables); - - if (numFocusables > 0 && numFocusables <= 64) + extern HWND g_hWnd; + RECT rc; + if (g_hWnd && GetClientRect(g_hWnd, &rc)) { - IggyFocusHandle hitObject = IGGY_FOCUS_NULL; - for (S32 i = 0; i < numFocusables; ++i) + int winW = rc.right - rc.left; + int winH = rc.bottom - rc.top; + if (winW > 0 && winH > 0) { - if (mouseX >= focusables[i].x0 && mouseX <= focusables[i].x1 && - mouseY >= focusables[i].y0 && mouseY <= focusables[i].y1) + // Step 1: window pixels -> screen space + 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(); + S32 displayW = 0, displayH = 0; + getRenderDimensions(vp, displayW, displayH); + + F32 vpOriginX, vpOriginY, vpW, vpH; + GetViewportRect(getScreenWidth(), getScreenHeight(), vp, vpOriginX, vpOriginY, vpW, vpH); + // All viewports use Fit16x9 for menu scenes + S32 fitW, fitH, fitOffsetX, fitOffsetY; + Fit16x9(vpW, vpH, fitW, fitH, fitOffsetX, fitOffsetY); + S32 originX = static_cast<S32>(vpOriginX) + fitOffsetX; + S32 originY = static_cast<S32>(vpOriginY) + fitOffsetY; + displayW = fitW; + displayH = fitH; + + if (displayW > 0 && displayH > 0) { - hitObject = focusables[i].object; - break; + sceneMouseX = (screenX - originX) * (static_cast<F32>(pScene->getRenderWidth()) / static_cast<F32>(displayW)); + sceneMouseY = (screenY - originY) * (static_cast<F32>(pScene->getRenderHeight()) / static_cast<F32>(displayH)); } } - - if (hitObject != currentFocus) - { - IggyPlayerSetFocusRS(movie, hitObject, 0); - } - } - } - - // Convert mouse to scene/movie coordinates for slider hit testing - F32 sceneMouseX = mouseX; - F32 sceneMouseY = mouseY; - { - S32 displayWidth = 0, displayHeight = 0; - pScene->GetParentLayer()->getRenderDimensions(displayWidth, displayHeight); - if (displayWidth > 0 && displayHeight > 0) - { - sceneMouseX = mouseX * ((F32)pScene->getRenderWidth() / (F32)displayWidth); - sceneMouseY = mouseY * ((F32)pScene->getRenderHeight() / (F32)displayHeight); } } @@ -876,6 +902,110 @@ void UIController::tickInput() panelOffsetY = pMainPanel->getYPos(); } + // Mouse hover — hit test against C++ control bounds. + // Simple controls use SetFocusToElement; list controls + // use their own SetTouchFocus for Flash-side hit testing. + if (mouseMoved) + { + m_bMouseHoverHorizontalList = false; + vector<UIControl *> *controls = pScene->GetControls(); + if (controls) + { + int hitControlId = -1; + S32 hitArea = INT_MAX; + UIControl *hitCtrl = NULL; + for (size_t i = 0; i < controls->size(); ++i) + { + UIControl *ctrl = (*controls)[i]; + if (!ctrl || ctrl->getHidden() || !ctrl->getVisible() || ctrl->getId() < 0) + continue; + + UIControl::eUIControlType type = ctrl->getControlType(); + if (type != UIControl::eButton && type != UIControl::eTextInput && + type != UIControl::eCheckBox && type != UIControl::eSlider && + type != UIControl::eButtonList && type != UIControl::eTexturePackList) + continue; + + // If the scene has an active panel (e.g. tab menus), + // skip controls that aren't children of that panel. + if (pMainPanel && ctrl->getParentPanel() != pMainPanel) + continue; + + ctrl->UpdateControl(); + S32 cx = ctrl->getXPos() + panelOffsetX; + S32 cy = ctrl->getYPos() + panelOffsetY; + S32 cw = ctrl->getWidth(); + S32 ch = ctrl->getHeight(); + // TexturePackList origin is where the slot area starts, + // not the top-left of the whole control — use GetRealHeight. + if (type == UIControl::eTexturePackList) + ch = static_cast<UIControl_TexturePackList*>(ctrl)->GetRealHeight(); + if (cw <= 0 || ch <= 0) + continue; + + if (sceneMouseX >= cx && sceneMouseX <= cx + cw && + sceneMouseY >= cy && sceneMouseY <= cy + ch) + { + if (type == UIControl::eButtonList) + { + // ButtonList manages focus internally via Flash — + // pass mouse coords so it can highlight the right item. + static_cast<UIControl_ButtonList*>(ctrl)->SetTouchFocus( + static_cast<S32>(sceneMouseX), static_cast<S32>(sceneMouseY), false); + hitControlId = -1; + hitArea = INT_MAX; + hitCtrl = NULL; + break; // ButtonList takes priority + } + if (type == UIControl::eTexturePackList) + { + // TexturePackList expects coords relative to its origin. + UIControl_TexturePackList *pList = static_cast<UIControl_TexturePackList*>(ctrl); + pScene->SetFocusToElement(ctrl->getId()); + pList->SetTouchFocus( + static_cast<S32>(sceneMouseX - cx), static_cast<S32>(sceneMouseY - cy), false); + m_bMouseHoverHorizontalList = true; + hitControlId = -1; + hitArea = INT_MAX; + hitCtrl = NULL; + break; + } + S32 area = cw * ch; + if (area < hitArea) + { + hitControlId = ctrl->getId(); + hitArea = area; + hitCtrl = ctrl; + if (type == UIControl::eSlider) + m_bMouseHoverHorizontalList = true; + } + } + } + + if (hitControlId >= 0 && pScene->getControlFocus() != hitControlId) + { + // During direct editing, don't let hover move focus + // away to other TextInputs (e.g. sign lines). + if (hitCtrl && hitCtrl->getControlType() == UIControl::eTextInput + && pScene->isDirectEditBlocking()) + { + // Skip — keep focus on the actively-edited input + } + else + { + pScene->SetFocusToElement(hitControlId); + // TextInput: SetFocusToElement triggers ChangeState which + // shows the caret. Hide it immediately — the render pass + // happens after both tickInput and scene tick, so no flicker. + if (hitCtrl && hitCtrl->getControlType() == UIControl::eTextInput) + { + static_cast<UIControl_TextInput*>(hitCtrl)->setCaretVisible(false); + } + } + } + } + } + bool leftPressed = g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT); bool leftDown = leftPressed || g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT); @@ -890,13 +1020,52 @@ void UIController::tickInput() vector<UIControl *> *controls = pScene->GetControls(); if (controls) { + // Set Iggy dispatch focus for TextInput on click (not hover) + // so ACTION_MENU_OK targets the correct text field. + for (size_t i = 0; i < controls->size(); ++i) + { + UIControl *ctrl = (*controls)[i]; + if (!ctrl || ctrl->getControlType() != UIControl::eTextInput || !ctrl->getVisible()) + continue; + if (pMainPanel && ctrl->getParentPanel() != pMainPanel) + continue; + ctrl->UpdateControl(); + S32 cx = ctrl->getXPos() + panelOffsetX; + S32 cy = ctrl->getYPos() + panelOffsetY; + S32 cw = ctrl->getWidth(); + S32 ch = ctrl->getHeight(); + if (cw > 0 && ch > 0 && + sceneMouseX >= cx && sceneMouseX <= cx + cw && + sceneMouseY >= cy && sceneMouseY <= cy + ch) + { + Iggy *movie = pScene->getMovie(); + IggyFocusHandle currentFocus = IGGY_FOCUS_NULL; + IggyFocusableObject focusables[64]; + S32 numFocusables = 0; + IggyPlayerGetFocusableObjects(movie, ¤tFocus, focusables, 64, &numFocusables); + for (S32 fi = 0; fi < numFocusables && fi < 64; ++fi) + { + if (sceneMouseX >= focusables[fi].x0 && sceneMouseX <= focusables[fi].x1 && + sceneMouseY >= focusables[fi].y0 && sceneMouseY <= focusables[fi].y1) + { + IggyPlayerSetFocusRS(movie, focusables[fi].object, 0); + break; + } + } + break; + } + } + for (size_t i = 0; i < controls->size(); ++i) { UIControl *ctrl = (*controls)[i]; if (!ctrl || ctrl->getControlType() != UIControl::eSlider || !ctrl->getVisible()) continue; - UIControl_Slider *pSlider = (UIControl_Slider *)ctrl; + if (pMainPanel && ctrl->getParentPanel() != pMainPanel) + continue; + + UIControl_Slider *pSlider = static_cast<UIControl_Slider *>(ctrl); pSlider->UpdateControl(); S32 cx = pSlider->getXPos() + panelOffsetX; S32 cy = pSlider->getYPos() + panelOffsetY; @@ -925,7 +1094,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); @@ -942,6 +1111,12 @@ void UIController::tickInput() m_mouseDraggingSliderScene = eUIScene_COUNT; m_mouseDraggingSliderId = -1; } + + // Let the scene handle mouse clicks for custom navigation (e.g. crafting slots) + if (leftPressed && m_mouseDraggingSliderId < 0) + { + m_mouseClickConsumedByScene = pScene->handleMouseClick(sceneMouseX, sceneMouseY); + } } } #endif @@ -1006,7 +1181,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 @@ -1033,8 +1208,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(); @@ -1206,7 +1381,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) if ((key == ACTION_MENU_OK || key == ACTION_MENU_A) && !g_KBMInput.IsMouseGrabbed()) { - if (m_mouseDraggingSliderId < 0) + if (m_mouseDraggingSliderId < 0 && !m_mouseClickConsumedByScene) { if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT)) { pressed = true; down = true; } if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) { released = true; down = false; } @@ -1214,6 +1389,14 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) } } + // Right click → ACTION_MENU_X (pick up half stack in inventory) + if (key == ACTION_MENU_X && !g_KBMInput.IsMouseGrabbed()) + { + if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_RIGHT)) { pressed = true; down = true; } + if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_RIGHT)) { released = true; down = false; } + if (!pressed && !released && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_RIGHT)) { down = true; } + } + // Scroll wheel for list scrolling — only consume the wheel value when the // action key actually matches, so the other direction isn't lost. if (!g_KBMInput.IsMouseGrabbed() && (key == ACTION_MENU_OTHER_STICK_UP || key == ACTION_MENU_OTHER_STICK_DOWN)) @@ -1231,6 +1414,16 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) pressed = true; down = true; } + + // Remap scroll wheel to navigation actions. Use LEFT/RIGHT when + // hovering a horizontal list (e.g. TexturePackList), UP/DOWN otherwise. + if (pressed && g_KBMInput.IsKBMActive()) + { + if (m_bMouseHoverHorizontalList) + key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_LEFT : ACTION_MENU_RIGHT; + else + key = (key == ACTION_MENU_OTHER_STICK_UP) ? ACTION_MENU_UP : ACTION_MENU_DOWN; + } } } #endif @@ -1297,8 +1490,8 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) //!(app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_ToggleFont)) && key == ACTION_MENU_STICK_PRESS) { - __int64 totalStatic = 0; - __int64 totalDynamic = 0; + int64_t totalStatic = 0; + int64_t totalDynamic = 0; app.DebugPrintf(app.USER_SR, "********************************\n"); app.DebugPrintf(app.USER_SR, "BEGIN TOTAL SWF MEMORY USAGE\n\n"); for(unsigned int i = 0; i < eUIGroup_COUNT; ++i) @@ -1307,8 +1500,8 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) } for(unsigned int i = 0; i < eLibrary_Count; ++i) { - __int64 libraryStatic = 0; - __int64 libraryDynamic = 0; + int64_t libraryStatic = 0; + int64_t libraryDynamic = 0; if(m_iggyLibraries[i] != IGGY_INVALID_LIBRARY) { @@ -1316,7 +1509,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 , @@ -1347,7 +1540,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 @@ -1358,9 +1551,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); } @@ -1422,73 +1615,48 @@ void UIController::renderScenes() void UIController::getRenderDimensions(C4JRender::eViewportType viewport, S32 &width, S32 &height) { - switch( viewport ) + F32 originX, originY, viewW, viewH; + GetViewportRect(getScreenWidth(), getScreenHeight(), viewport, originX, originY, viewW, viewH); + + if(viewport == C4JRender::VIEWPORT_TYPE_FULLSCREEN) { - case C4JRender::VIEWPORT_TYPE_FULLSCREEN: - width = (S32)(getScreenWidth()); - height = (S32)(getScreenHeight()); - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: - case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - width = (S32)(getScreenWidth() / 2); - height = (S32)(getScreenHeight() / 2); - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: - case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - width = (S32)(getScreenWidth() / 2); - height = (S32)(getScreenHeight() / 2); - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: - case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: - case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: - case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - width = (S32)(getScreenWidth() / 2); - height = (S32)(getScreenHeight() / 2); - break; + S32 offsetX, offsetY; + Fit16x9(viewW, viewH, width, height, offsetX, offsetY); + } + else + { + // Split-screen: use raw viewport dims — the SWF tiling code handles non-16:9 + width = static_cast<S32>(viewW); + height = static_cast<S32>(viewH); } } void UIController::setupRenderPosition(C4JRender::eViewportType viewport) { - if(m_bCustomRenderPosition || m_currentRenderViewport != viewport) + m_currentRenderViewport = viewport; + m_bCustomRenderPosition = false; + + F32 vpOriginX, vpOriginY, vpW, vpH; + GetViewportRect(getScreenWidth(), getScreenHeight(), viewport, vpOriginX, vpOriginY, vpW, vpH); + + S32 xPos, yPos; + if(viewport == C4JRender::VIEWPORT_TYPE_FULLSCREEN) { - m_currentRenderViewport = viewport; - m_bCustomRenderPosition = false; - S32 xPos = 0; - S32 yPos = 0; - switch( viewport ) - { - case C4JRender::VIEWPORT_TYPE_SPLIT_TOP: - xPos = (S32)(getScreenWidth() / 4); - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM: - xPos = (S32)(getScreenWidth() / 4); - yPos = (S32)(getScreenHeight() / 2); - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT: - yPos = (S32)(getScreenHeight() / 4); - break; - case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT: - xPos = (S32)(getScreenWidth() / 2); - yPos = (S32)(getScreenHeight() / 4); - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT: - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: - xPos = (S32)(getScreenWidth() / 2); - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: - yPos = (S32)(getScreenHeight() / 2); - break; - case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: - xPos = (S32)(getScreenWidth() / 2); - yPos = (S32)(getScreenHeight() / 2); - break; - } - m_tileOriginX = xPos; - m_tileOriginY = yPos; - setTileOrigin(xPos, yPos); + S32 fitW, fitH, fitOffsetX, fitOffsetY; + Fit16x9(vpW, vpH, fitW, fitH, fitOffsetX, 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 = static_cast<S32>(vpOriginX); + yPos = static_cast<S32>(vpOriginY); } + + m_tileOriginX = xPos; + m_tileOriginY = yPos; + setTileOrigin(xPos, yPos); } void UIController::setupRenderPosition(S32 xOrigin, S32 yOrigin) @@ -1547,8 +1715,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__ @@ -1576,10 +1744,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; } } @@ -1623,9 +1791,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); } @@ -1637,7 +1805,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 // @@ -1652,7 +1820,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; @@ -1660,28 +1828,38 @@ GDrawTexture * RADLINK UIController::TextureSubstitutionCreateCallback ( void * // 4J Stu - All our flash controls that allow replacing textures use a special 64x64 symbol // Force this size here so that our images don't get scaled wildly - #if (defined __ORBIS__ || defined _DURANGO || defined _WINDOWS64 ) + #if (defined __ORBIS__ || defined _DURANGO ) *width = 96; *height = 96; #else *width = 64; *height = 64; + #endif + #if defined _WINDOWS64 + // Only set the size to 96x96 for 1080p on Windows + UIScene *scene = uiController->GetTopScene(0); + if (scene->getSceneResolution() == UIScene::eSceneResolution_1080) + { + *width = 96; + *height = 96; + } #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; } } @@ -1691,13 +1869,16 @@ 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); - Textures *t = Minecraft::GetInstance()->textures; - t->releaseTexture( id ); + Minecraft* mc = Minecraft::GetInstance(); + if (mc && mc->textures) + { + mc->textures->releaseTexture( id ); + } } void UIController::registerSubstitutionTexture(const wstring &textureName, PBYTE pbData, DWORD dwLength) @@ -1723,6 +1904,7 @@ void UIController::unregisterSubstitutionTexture(const wstring &textureName, boo bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUILayer layer, EUIGroup group) { static bool bSeenUpdateTextThisSession = false; + #if 0 // Disable since we don't use this // If you're navigating to the multigamejoinload, and the player hasn't seen the updates message yet, display it now // display this message the first 3 times if((scene==eUIScene_LoadOrJoinMenu) && (bSeenUpdateTextThisSession==false) && ( app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_DisplayUpdateMessage)!=0)) @@ -1730,6 +1912,7 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI scene=eUIScene_NewUpdateMessage; bSeenUpdateTextThisSession=true; } + #endif // if you're trying to navigate to the inventory,the crafting, pause or game info or any of the trigger scenes and there's already a menu up (because you were pressing a few buttons at the same time) then ignore the navigate if(GetMenuDisplayed(iPad)) @@ -1791,7 +1974,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; } @@ -1806,7 +1989,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); @@ -1821,18 +2004,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) @@ -1844,8 +2027,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; } @@ -1866,11 +2049,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 @@ -1887,11 +2070,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(); // } @@ -1925,7 +2108,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; } @@ -1935,7 +2118,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) @@ -1962,7 +2145,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() ) { @@ -1983,7 +2166,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; @@ -2006,7 +2189,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 @@ -2014,22 +2197,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) @@ -2044,14 +2227,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) @@ -2060,14 +2243,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) @@ -2076,14 +2259,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) @@ -2092,14 +2275,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) @@ -2113,14 +2296,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) @@ -2201,14 +2384,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 ) @@ -2217,14 +2400,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 ) @@ -2233,14 +2416,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) @@ -2262,14 +2445,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 ) @@ -2278,14 +2461,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) @@ -2304,7 +2487,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 @@ -2312,7 +2495,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) @@ -2322,7 +2505,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 @@ -2330,19 +2513,25 @@ 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) { - __uint64 time = System::currentTimeMillis(); + uint64_t time = System::currentTimeMillis(); // Don't play multiple SFX on the same tick // (prevents horrible sounds when programmatically setting multiple checkboxes) if (time - m_lastUiSfx < 10) { return; } m_lastUiSfx = time; - Minecraft::GetInstance()->soundEngine->playUI(eSound,1.0f,1.0f); + float pitch = 1.0f; + if (eSound == eSFX_Focus) + { + pitch += (m_randomDistribution(m_randomGenerator) - 0.5f) / 10; + } + + Minecraft::GetInstance()->soundEngine->playUI(eSound,1.0f,pitch); } void UIController::DisplayGamertag(unsigned int iPad, bool show) @@ -2352,13 +2541,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(); } } @@ -2369,7 +2558,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 @@ -2377,7 +2566,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) @@ -2430,10 +2619,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() @@ -2452,14 +2641,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) @@ -2468,7 +2657,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 @@ -2476,11 +2665,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); } } @@ -2488,9 +2677,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 @@ -2500,14 +2689,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) @@ -2516,7 +2705,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 @@ -2524,7 +2713,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; } @@ -2534,7 +2723,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) { @@ -2544,7 +2733,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 { @@ -2577,7 +2766,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) @@ -2589,7 +2778,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) { @@ -2608,11 +2797,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? @@ -2622,7 +2811,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); } @@ -2631,7 +2820,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) { @@ -2643,7 +2832,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) @@ -2651,7 +2840,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 } @@ -2668,12 +2857,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) @@ -2692,12 +2881,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 } @@ -2708,12 +2897,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 } @@ -2731,13 +2920,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() @@ -2800,7 +2989,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) @@ -2832,7 +3021,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) @@ -2870,7 +3059,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 @@ -2883,10 +3072,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 @@ -2896,16 +3085,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 @@ -3071,7 +3260,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; } |
