From 4020b168643e0233162567174930ac83b3d71595 Mon Sep 17 00:00:00 2001 From: str1k3r <115313679+S1l3ntStr1ke87@users.noreply.github.com> Date: Wed, 2 Sep 2026 22:45:39 -0400 Subject: [PATCH] feat: auto switching tooltips (not fully done) --- Minecraft.Client/Common/UI/UIController.cpp | 111 ++++++++++++++++++-- Minecraft.Client/Common/UI/UIController.h | 6 ++ Minecraft.Client/Windows64/4JLibs | 2 +- 3 files changed, 111 insertions(+), 8 deletions(-) diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 35abacd7..dee0d554 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -15,6 +15,7 @@ #include #elif _WINDOWS64 #include "Windows64\Windows64_Minecraft.h" +string m_LastControllerType = "mrow"; #endif // 4J Stu - Enable this to override the Iggy Allocator @@ -185,13 +186,6 @@ UIController::UIController() m_fScreenWidth = 1920.0f; m_fScreenHeight = 1080.0f; m_bScreenWidthSetup = true; -#elif _WINDOWS64 - m_fScreenWidth = g_iScreenWidth; - m_fScreenHeight = g_iScreenHeight; - m_bScreenWidthSetup = true; -#ifdef _DEBUG - app.DebugPrintf("[UIController] Width: %d, Height: %d\n", static_cast(m_fScreenWidth), static_cast(m_fScreenHeight)); -#endif #else m_fScreenWidth = 1280.0f; m_fScreenHeight = 720.0f; @@ -264,6 +258,10 @@ void UIController::preInit(S32 width, S32 height) m_fScreenHeight = height; m_bScreenWidthSetup = true; +#ifdef _DEBUG + app.DebugPrintf("[UIController] Width: %d, Height: %d\n", static_cast(m_fScreenWidth), static_cast(m_fScreenHeight)); +#endif + #ifdef ENABLE_IGGY_ALLOCATOR IggyAllocator allocator; allocator.user_callback_data = this; @@ -497,10 +495,89 @@ void UIController::tick() ++it; } } + +#ifdef _WINDOWS64 + //GetControllerType(); +#endif +} + +//str1k3r - this is what actually does all the autoswitching +void UIController::GetControllerType() +{ + const char* ControllerType = InputManager.GetControllerType(0); + wstring controlTooltipsPath = L""; + + if(ControllerType != m_LastControllerType) + { + m_LastControllerType = ControllerType; + + if (strcmp(ControllerType, "PS3") == 0) + { + controlTooltipsPath = (ui.getScreenWidth() >= 1920) ? L"ControlTooltips\\HD\\PS3HDControls.swf" : L"ControlTooltips\\PS3Controls.swf"; + } + else if (strcmp(ControllerType, "PS4") == 0) + { + controlTooltipsPath = (ui.getScreenWidth() >= 1920) ? L"ControlTooltips\\HD\\OrbisHDControls.swf" : L"ControlTooltips\\OrbisControls.swf"; + } + else if (strcmp(ControllerType, "XBOXONE") == 0 || strcmp(ControllerType, "UNKNOWN") == 0) + { + controlTooltipsPath = (ui.getScreenWidth() >= 1920) ? L"ControlTooltips\\HD\\DurangoHDControls.swf" : L"ControlTooltips\\DurangoControls.swf"; + } + else if (ControllerType == "XBOX360") + { + controlTooltipsPath = (ui.getScreenWidth() >= 1920) ? L"ControlTooltips\\HD\\XboxHDControls.swf" : L"ControlTooltips\\XboxControls.swf"; + } + else + { + controlTooltipsPath = (ui.getScreenWidth() >= 1920) ? L"ControlTooltips\\HD\\Windows64HDControls.swf" : L"ControlTooltips\\Windows64Controls.swf"; + } + + //ReloadSingleSkin(eLibrary_ControlTooltips, controlTooltipsPath, (m_fScreenHeight >= 1080.0f) ? L"skinControlTooltipsHD.swf" : L"skinControlTooltips.swf"); + + for(unsigned int i = 0; i < eUIGroup_COUNT; ++i) + { + if(m_groups[i]->getTooltips()) + m_groups[i]->getTooltips()->destroyMovie(); + if(m_groups[i]->getPressStartToPlay()) + m_groups[i]->getPressStartToPlay()->destroyMovie(); + + if(m_groups[i]->getTooltips()) + m_groups[i]->getTooltips()->reloadMovie(true); + if(m_groups[i]->getPressStartToPlay()) + m_groups[i]->getPressStartToPlay()->reloadMovie(true); + } + } +} + +wstring UIController::GetTooltipSkinPath() +{ + const char* ControllerType = InputManager.GetControllerType(0); + + if (strcmp(ControllerType, "PS3") == 0) + { + return ui.getScreenWidth() >= 1920 ? L"ControlTooltips\\HD\\PS3HDControls.swf" : L"ControlTooltips\\PS3Controls.swf"; + } + else if (strcmp(ControllerType, "PS4") == 0) + { + return ui.getScreenWidth() >= 1920 ? L"ControlTooltips\\HD\\OrbisHDControls.swf" : L"ControlTooltips\\OrbisControls.swf"; + } + else if (strcmp(ControllerType, "XBOXONE") == 0 || strcmp(ControllerType, "UNKNOWN") == 0) + { + return ui.getScreenWidth() >= 1920 ? L"ControlTooltips\\HD\\DurangoHDControls.swf" : L"ControlTooltips\\DurangoControls.swf"; + } + else if (strcmp(ControllerType, "XBOX360") == 0) + { + return ui.getScreenWidth() >= 1920 ? L"ControlTooltips\\HD\\XboxHDControls.swf" : L"ControlTooltips\\XboxControls.swf"; + } + else + { + return ui.getScreenWidth() >= 1920 ? L"ControlTooltips\\HD\\Windows64HDControls.swf" : L"ControlTooltips\\Windows64Controls.swf"; + } } void UIController::loadSkins() { + wstring tooltipsSkinPath = L""; wstring platformSkinPath = L""; #ifdef __PS3__ @@ -510,14 +587,17 @@ void UIController::loadSkins() #elif defined _WINDOWS64 if(m_fScreenWidth >= 1920.0f) { + //tooltipsSkinPath = GetTooltipSkinPath(); platformSkinPath = L"skinHDWin.swf"; } else if (m_fScreenWidth >= 960.0f && m_fScreenWidth < 1280.0f) //str1k3r - we need to check this to make sure we dont load the vita skin on 720p { + //tooltipsSkinPath = GetTooltipSkinPath(); platformSkinPath = L"skinWinVita.swf"; } else { + //tooltipsSkinPath = GetTooltipSkinPath(); platformSkinPath = L"skinWin.swf"; } #elif defined _DURANGO @@ -551,6 +631,9 @@ void UIController::loadSkins() 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"); +#ifdef _WINDOWS64 + //m_iggyLibraries[eLibrary_ControlTooltips] = loadSkin(tooltipsSkinPath, L"skinControlTooltipsHD.swf"); +#endif 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"); @@ -565,6 +648,9 @@ void UIController::loadSkins() 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"); +#ifdef _WINDOWS64 + //m_iggyLibraries[eLibrary_ControlTooltips] = loadSkin(tooltipsSkinPath, L"skinControlTooltipsHD.swf"); +#endif 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"); @@ -606,6 +692,17 @@ IggyLibrary UIController::loadSkin(const wstring &skinPath, const wstring &skinN return lib; } +void UIController::ReloadSingleSkin(ELibraries lib, const wstring &skinPath, const wstring &skinName) +{ + if(m_iggyLibraries[lib] != IGGY_INVALID_LIBRARY) + { + IggyLibraryDestroy(m_iggyLibraries[lib]); + m_iggyLibraries[lib] = IGGY_INVALID_LIBRARY; + } + + m_iggyLibraries[lib] = loadSkin(skinPath, skinName); +} + void UIController::ReloadSkin() { // Destroy all scene swf diff --git a/Minecraft.Client/Common/UI/UIController.h b/Minecraft.Client/Common/UI/UIController.h index 2a81694f..636766ea 100644 --- a/Minecraft.Client/Common/UI/UIController.h +++ b/Minecraft.Client/Common/UI/UIController.h @@ -91,6 +91,9 @@ private: eLibrary_GraphicsInGame, eLibrary_GraphicsTooltips, eLibrary_GraphicsLabels, +#ifdef _WINDOWS64 + //eLibrary_ControlTooltips, +#endif eLibrary_Labels, eLibrary_InGame, eLibrary_HUD, @@ -201,10 +204,13 @@ public: virtual void tick(); private: + void GetControllerType(); + wstring GetTooltipSkinPath(); void loadSkins(); IggyLibrary loadSkin(const wstring &skinPath, const wstring &skinName); public: + void ReloadSingleSkin(ELibraries lib, const wstring &skinPath, const wstring &skinName); void ReloadSkin(); virtual void StartReloadSkinThread(); virtual bool IsReloadingSkin(); diff --git a/Minecraft.Client/Windows64/4JLibs b/Minecraft.Client/Windows64/4JLibs index e00f0215..758549ce 160000 --- a/Minecraft.Client/Windows64/4JLibs +++ b/Minecraft.Client/Windows64/4JLibs @@ -1 +1 @@ -Subproject commit e00f0215ccb8a3ca1f44d8981cf06442429336b5 +Subproject commit 758549ceca01945629b66be70ae63da82b6a4162