Merge kbm-ig into kbm

This commit is contained in:
qloak committed 2026-09-14 16:26:34 -07:00
commit 3521b06611
1371 files changed
+260387 -267883

No files matched your search

+90 -87
View File
@@ -58,10 +58,11 @@ static float MovieSpaceY(UIScene *pScene,int v);
#ifdef _WINDOWS64
wstring controlTooltipsPath = L"";
wstring skinName = L"";
EControllerType m_LastControllerType;
#endif
CRITICAL_SECTION UIController::ms_reloadSkinCS;
bool UIController::ms_bReloadSkinCSInitialised = false;
CRITICAL_SECTION UIController::ms_reloadSkinsCS;
bool UIController::ms_bReloadSkinsCSInitialised = false;
#ifdef _WINDOWS64
CRITICAL_SECTION UIController::ms_controllerPollCS;
@@ -180,7 +181,7 @@ static void RADLINK DeallocateFunction ( void * alloc_callback_user_data , void
UIController::UIController()
{
m_uiDebugConsole = NULL;
m_reloadSkinThread = NULL;
m_reloadSkinsThread = NULL;
m_navigateToHomeOnReload = false;
@@ -210,24 +211,6 @@ UIController::UIController()
InitializeCriticalSection(&m_Allocatorlock);
#endif
// 4J Stu - This is a bit of a hack until we change the Minecraft initialisation to store the proper screen size for other platforms
#if defined _DURANGO || defined __ORBIS__
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<int>(m_fScreenWidth), static_cast<int>(m_fScreenHeight));
#endif
#else
m_fScreenWidth = 1280.0f;
m_fScreenHeight = 720.0f;
m_bScreenWidthSetup = false;
#endif
for(unsigned int i = 0; i < eLibrary_Count; ++i)
{
m_iggyLibraries[i] = IGGY_INVALID_LIBRARY;
@@ -266,11 +249,11 @@ UIController::UIController()
m_bTouchscreenPressed=false;
#endif
if(!ms_bReloadSkinCSInitialised)
if(!ms_bReloadSkinsCSInitialised)
{
// MGH - added to prevent crash loading Iggy movies while the skins were being reloaded
InitializeCriticalSection(&ms_reloadSkinCS);
ms_bReloadSkinCSInitialised = true;
InitializeCriticalSection(&ms_reloadSkinsCS);
ms_bReloadSkinsCSInitialised = true;
}
#ifdef _WINDOWS64
@@ -298,10 +281,15 @@ void UIController::SetSystemUIShowing(LPVOID lpParam,bool bVal)
// SETUP
void UIController::preInit(S32 width, S32 height)
{
//str1k3r - 4J previously hardcoded this in UIController(), this is already set per platform so just use this :3
m_fScreenWidth = width;
m_fScreenHeight = height;
m_bScreenWidthSetup = true;
#ifdef _DEBUG
app.DebugPrintf("[UIController] Width: %d, Height: %d\n", static_cast<int>(m_fScreenWidth), static_cast<int>(m_fScreenHeight));
#endif
#ifdef ENABLE_IGGY_ALLOCATOR
IggyAllocator allocator;
allocator.user_callback_data = this;
@@ -384,13 +372,13 @@ UITTFFont *UIController::createFont(EFont fontLanguage)
{
switch(fontLanguage)
{
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
#if !(defined _DURANGO || _WINDOWS64)
case eFont_Japanese: return new UITTFFont("Mojangles_TTF_jaJP", "Common/Media/font/JPN/DF-DotDotGothic16.ttf", 0x203B); // JPN
case eFont_TradChinese: return new UITTFFont("Mojangles_TTF_cnTD", "Common/Media/font/CHT/DFTT_R5.TTC", 0x203B); // CHT
case eFont_Korean: return new UITTFFont("Mojangles_TTF_koKR", "Common/Media/font/KOR/candadite2.ttf", 0x203B); // KOR
#else
case eFont_Japanese: return new UITTFFont("Mojangles_TTF_jaJP", "Common/Media/font/JPN/DFGMaruGothic-Md.ttf", 0x2022); // JPN
#if defined(_DURANGO) || defined(_WINDOWS64)
#if (defined _DURANGO || _WINDOWS64)
case eFont_SimpChinese: return new UITTFFont("Mojangled_TTF_cnCN", "Common/Media/font/CHS/MSYH.ttf", 0x2022); // CHS
#endif
case eFont_TradChinese: return new UITTFFont("Mojangles_TTF_cnTD", "Common/Media/font/CHT/DFHeiMedium-B5.ttf", 0x2022); // CHT
@@ -490,9 +478,9 @@ void UIController::tick()
{
SetupFont(); // If necessary, change font.
if ( (m_navigateToHomeOnReload || m_bCleanupOnReload) && !ui.IsReloadingSkin() )
if ( (m_navigateToHomeOnReload || m_bCleanupOnReload) && !ui.IsReloadingSkins() )
{
ui.CleanUpSkinReload();
ui.CleanUpSkinsReload();
if (m_navigateToHomeOnReload || !g_NetworkManager.IsInSession())
{
@@ -556,7 +544,7 @@ int UIController::controllerPollThreadProc(void* lpParam)
while(true)
{
EControllerType polled = controller->GetControllerType(InputManager.PollControllerType(0));
EControllerType polled = ConvertControllerType(InputManager.GetControllerType(0));
EnterCriticalSection(&ms_controllerPollCS);
if(polled != EControllerType::UNKNOWN && polled != controller->m_LastControllerType)
@@ -578,7 +566,7 @@ wstring UIController::GetControlTooltipsPath(EControllerType ControllerType)
{
if(ControllerType == EControllerType::UNSET)
{
EControllerType ControllerType = GetControllerType(InputManager.PollControllerType(0));
ControllerType = ConvertControllerType(InputManager.GetControllerType(0));
}
switch(ControllerType)
@@ -606,18 +594,20 @@ wstring UIController::GetControlTooltipsPath(EControllerType ControllerType)
}
}
UIController::EControllerType UIController::GetControllerType(const char* controllerType)
UIController::EControllerType UIController::ConvertControllerType(::EControllerType t)
{
if (strcmp(controllerType, "PS3") == 0) return EControllerType::PS3;
if (strcmp(controllerType, "PS4") == 0) return EControllerType::PS4;
if (strcmp(controllerType, "PS5") == 0) return EControllerType::PS5;
if (strcmp(controllerType, "XBOXONE") == 0) return EControllerType::XBOXONE;
if (strcmp(controllerType, "XBOX360") == 0) return EControllerType::XBOX360;
if (strcmp(controllerType, "SWITCH") == 0) return EControllerType::SWITCH;
if (strcmp(controllerType, "GAMECUBE") == 0) return EControllerType::GAMECUBE;
if (strcmp(controllerType, "STANDARD") == 0) return EControllerType::STANDARD;
return EControllerType::UNKNOWN;
switch (t)
{
case ::EControllerType_PS3: return EControllerType::PS3;
case ::EControllerType_PS4: return EControllerType::PS4;
case ::EControllerType_PS5: return EControllerType::PS5;
case ::EControllerType_XboxOne: return EControllerType::XBOXONE;
case ::EControllerType_Xbox360: return EControllerType::XBOX360;
case ::EControllerType_Switch: return EControllerType::SWITCH;
case ::EControllerType_Gamecube: return EControllerType::GAMECUBE;
case ::EControllerType_Default: return EControllerType::STANDARD;
default: return EControllerType::UNKNOWN;
}
}
void UIController::fetchControlTooltipSWF()
@@ -625,10 +615,10 @@ void UIController::fetchControlTooltipSWF()
if (!m_bControllerTypeChanged)
return;
if (IsReloadingSkin())
if (IsReloadingSkins())
return;
EControllerType ControllerType = GetControllerType(InputManager.PollControllerType(0));
EControllerType ControllerType = ConvertControllerType(InputManager.GetControllerType(0));
if (ControllerType == EControllerType::UNKNOWN)
return; // str1k3r - ignore UNKNOWN, keep last tooltip
@@ -645,12 +635,15 @@ void UIController::fetchControlTooltipSWF()
controlTooltipsPath = GetControlTooltipsPath(ControllerType);
skinName = (m_fScreenHeight >= 1080.0f) ? L"skinControlTooltipsHD.swf" : L"skinControlTooltips.swf";
reloadSingleSkin(eLibrary_ControlTooltips, controlTooltipsPath, skinName);
}
ReloadSkin(eLibrary_ControlTooltips, controlTooltipsPath, skinName);
#endif
}
void UIController::loadSkins()
{
#ifdef _WINDOWS64
wstring tooltipsSkinPath = L"";
#endif
wstring platformSkinPath = L"";
#ifdef __PS3__
@@ -658,40 +651,47 @@ void UIController::loadSkins()
#elif defined __PSVITA__
platformSkinPath = L"skinVita.swf";
#elif defined _WINDOWS64
if(m_fScreenWidth >= 1920.0f)
if(ui.getScreenWidth() >= 1920.0f)
{
tooltipsSkinPath = GetControlTooltipsPath();
platformSkinPath = L"skinHDWin.swf";
controlTooltipsPath = GetControlTooltipsPath();
}
else if (ui.getScreenWidth() >= 960.0f && ui.getScreenWidth() < 1280.0f) //str1k3r - we need to check this to make sure we dont load the vita skin on 720p
{
tooltipsSkinPath = GetControlTooltipsPath();
platformSkinPath = L"skinWinVita.swf";
}
else
{
tooltipsSkinPath = GetControlTooltipsPath();
platformSkinPath = L"skinWin.swf";
controlTooltipsPath = GetControlTooltipsPath();
}
#elif defined _DURANGO
if(m_fScreenHeight==1080.0f)
{
//if(m_fScreenHeight==1080.0f)
//{
platformSkinPath = L"skinHDDurango.swf";
}
else
{
platformSkinPath = L"skinDurango.swf";
}
//}
//else
//{
// platformSkinPath = L"skinDurango.swf";
//}
#elif defined __ORBIS__
if(m_fScreenHeight==1080.0f)
{
//if(m_fScreenHeight==1080.0f)
//{
platformSkinPath = L"skinHDOrbis.swf";
}
else
{
platformSkinPath = L"skinOrbis.swf";
}
//}
//else
//{
// platformSkinPath = L"skinOrbis.swf";
//}
#endif
// str1k3r - Fixes 720p/480p Crashes on Windows64, also allows this to be used on 1080p consoles instead of just Windows64
// This also cleans up some 4J code and turns 3 if statements into 1.
if (m_fScreenWidth >= 1920.0f)
if (ui.getScreenWidth() >= 1920.0f)
{
m_iggyLibraries[eLibrary_Platform] = loadSkin(platformSkinPath, L"platformskinHD.swf");
m_iggyLibraries[eLibrary_GraphicsDefault] = loadSkin(L"skinHDGraphics.swf", L"skinHDGraphics.swf");
@@ -700,7 +700,7 @@ void UIController::loadSkins()
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(controlTooltipsPath, L"skinControlTooltipsHD.swf");
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");
@@ -717,7 +717,7 @@ void UIController::loadSkins()
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(controlTooltipsPath, L"skinControlTooltips.swf");
m_iggyLibraries[eLibrary_ControlTooltips] = loadSkin(tooltipsSkinPath, L"skinControlTooltips.swf");
#endif
m_iggyLibraries[eLibrary_Labels] = loadSkin(L"skinLabels.swf", L"skinLabels.swf");
m_iggyLibraries[eLibrary_InGame] = loadSkin(L"skinInGame.swf", L"skinInGame.swf");
@@ -810,7 +810,8 @@ IggyLibrary UIController::loadSkin(const wstring &skinPath, const wstring &skinN
return lib;
}
void UIController::reloadSingleSkin(ELibraries lib, const wstring &skinPath, const wstring &skinName)
//str1k3r - reloads a single skin
void UIController::ReloadSkin(ELibraries lib, const wstring &skinPath, const wstring &skinName)
{
if(m_iggyLibraries[lib] != IGGY_INVALID_LIBRARY)
{
@@ -840,7 +841,8 @@ void UIController::reloadSingleSkin(ELibraries lib, const wstring &skinPath, con
}
}
void UIController::ReloadSkin()
//str1k3r - reloads every skin
void UIController::ReloadSkins()
{
// Destroy all scene swf
for(unsigned int i = 0; i < eUIGroup_COUNT; ++i)
@@ -857,8 +859,8 @@ void UIController::ReloadSkin()
m_iggyLibraries[i] = IGGY_INVALID_LIBRARY;
}
m_reloadSkinThread = new C4JThread(reloadSkinThreadProc, (void*)this, "Reload skin thread");
m_reloadSkinThread->SetProcessor(CPU_CORE_UI_SCENE);
m_reloadSkinsThread = new C4JThread(reloadSkinsThreadProc, (void*)this, "Reload skin thread");
m_reloadSkinsThread->SetProcessor(CPU_CORE_UI_SCENE);
// Navigate to the timer scene so that we can display something while the loading is happening
// str1k3r - Exclude this from windows64 as its not needed
@@ -868,7 +870,7 @@ void UIController::ReloadSkin()
// str1k3r - Fixes 4J's issue with the screen staying on the timer scene if on another thread on windows64
#ifdef _WINDOWS64
m_reloadSkinThread->Run();
m_reloadSkinsThread->Run();
#endif
//// Load new skin
@@ -884,14 +886,14 @@ void UIController::ReloadSkin()
//m_groups[eUIGroup_Fullscreen]->ReloadAll();
}
void UIController::StartReloadSkinThread()
void UIController::StartReloadSkinsThread()
{
if(m_reloadSkinThread) m_reloadSkinThread->Run();
if(m_reloadSkinsThread) m_reloadSkinsThread->Run();
}
int UIController::reloadSkinThreadProc(void* lpParam)
int UIController::reloadSkinsThreadProc(void* lpParam)
{
EnterCriticalSection(&ms_reloadSkinCS); // MGH - added to prevent crash loading Iggy movies while the skins were being reloaded
EnterCriticalSection(&ms_reloadSkinsCS); // MGH - added to prevent crash loading Iggy movies while the skins were being reloaded
UIController *controller = (UIController *)lpParam;
// Load new skin
controller->loadSkins();
@@ -909,31 +911,31 @@ int UIController::reloadSkinThreadProc(void* lpParam)
#ifndef _WINDOW64
controller->NavigateBack(0, false, eUIScene_COUNT, eUILayer_Tooltips);
#endif
LeaveCriticalSection(&ms_reloadSkinCS);
LeaveCriticalSection(&ms_reloadSkinsCS);
return 0;
}
bool UIController::IsReloadingSkin()
bool UIController::IsReloadingSkins()
{
return m_reloadSkinThread && (!m_reloadSkinThread->hasStarted() || m_reloadSkinThread->isRunning());
return m_reloadSkinsThread && (!m_reloadSkinsThread->hasStarted() || m_reloadSkinsThread->isRunning());
}
bool UIController::IsExpectingOrReloadingSkin()
bool UIController::IsExpectingOrReloadingSkins()
{
return Minecraft::GetInstance()->skins->getSelected()->isLoadingData() || Minecraft::GetInstance()->skins->needsUIUpdate() || IsReloadingSkin() || PendingFontChange();
return Minecraft::GetInstance()->skins->getSelected()->isLoadingData() || Minecraft::GetInstance()->skins->needsUIUpdate() || IsReloadingSkins() || PendingFontChange();
}
void UIController::CleanUpSkinReload()
void UIController::CleanUpSkinsReload()
{
delete m_reloadSkinThread;
m_reloadSkinThread = NULL;
delete m_reloadSkinsThread;
m_reloadSkinsThread = NULL;
if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin())
{
if(!Minecraft::GetInstance()->skins->getSelected()->hasAudio())
{
#ifdef _DURANGO
#if (defined _DURANGO || _WINDOWS64)
DWORD result = StorageManager.UnmountInstalledDLC(L"TPACK");
#else
DWORD result = StorageManager.UnmountInstalledDLC("TPACK");
@@ -1143,7 +1145,8 @@ 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, NULL, NULL, firstUnfocussedUnhandledPad );
ProfileManager.RequestSignInUI(false, false, false, false, true, static_cast<int (*)(LPVOID, const bool, const int)>(NULL), NULL, firstUnfocussedUnhandledPad );
}
}
#endif
@@ -2207,7 +2210,7 @@ void UIController::NavigateToHomeMenu()
// {
// pDLCTexPack->m_pSoundBank->Destroy();
// }
#ifdef _XBOX_ONE
#if (defined _XBOX_ONE || _WINDOWS64)
DWORD result = StorageManager.UnmountInstalledDLC(L"TPACK");
#else
DWORD result = StorageManager.UnmountInstalledDLC("TPACK");
@@ -3059,7 +3062,7 @@ void UIController::ClearPressStart()
C4JStorage::EMessageResult UIController::RequestAlertMessage(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult),LPVOID lpParam, WCHAR *pwchFormatString)
{
#ifndef __ORBIS__
#if !(defined __ORBIS__ || _XBOX_ONE)
return RequestMessageBox(uiTitle, uiText, uiOptionA, uiOptionC, dwPad, Func, lpParam, pwchFormatString, 0, false);
#else
return RequestMessageBox(uiTitle, uiText, uiOptionA, uiOptionC, dwPad, Func, lpParam, NULL, pwchFormatString, 0, false);
@@ -3068,14 +3071,14 @@ C4JStorage::EMessageResult UIController::RequestAlertMessage(UINT uiTitle, UINT
C4JStorage::EMessageResult UIController::RequestErrorMessage(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult),LPVOID lpParam, WCHAR *pwchFormatString)
{
#ifndef __ORBIS__
#if !(defined __ORBIS__ || _XBOX_ONE)
return RequestMessageBox(uiTitle, uiText, uiOptionA, uiOptionC, dwPad, Func, lpParam, pwchFormatString, 0, true);
#else
return RequestMessageBox(uiTitle, uiText, uiOptionA, uiOptionC, dwPad, Func, lpParam, NULL, pwchFormatString, 0, true);
#endif
}
#ifndef __ORBIS__
#if !(defined __ORBIS__ || _XBOX_ONE)
C4JStorage::EMessageResult UIController::RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad,
int( *Func)(LPVOID,int,const C4JStorage::EMessageResult),LPVOID lpParam, WCHAR *pwchFormatString,DWORD dwFocusButton, bool bIsError)
#else
@@ -3098,7 +3101,7 @@ C4JStorage::EMessageResult UIController::RequestMessageBox(UINT uiTitle, UINT ui
EUILayer layer = bIsError?eUILayer_Error:eUILayer_Alert;
bool completed = false;
if(ui.IsReloadingSkin())
if(ui.IsReloadingSkins())
{
// Queue this message box
QueuedMessageBoxData *queuedData = new QueuedMessageBoxData();