From 4e79d92c24cfaf786c3f141193ef0834b29193e0 Mon Sep 17 00:00:00 2001 From: str1k3r <115313679+S1l3ntStr1ke87@users.noreply.github.com> Date: Wed, 30 Sep 2026 03:20:03 -0400 Subject: [PATCH] fix(windows64): save space indicator --- .../UI/UIScene_LaunchMoreOptionsMenu.cpp | 1 - .../Common/UI/UIScene_LoadMenu.cpp | 6 ++- .../Common/UI/UIScene_LoadOrJoinMenu.cpp | 45 +++++++++++++++---- .../Common/UI/UIScene_LoadOrJoinMenu.h | 6 +-- Minecraft.Client/Windows64/Windows64_App.cpp | 9 ++++ Minecraft.Client/Windows64/Windows64_App.h | 3 ++ 6 files changed, 56 insertions(+), 14 deletions(-) diff --git a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp index dab2db22..da6cf2d5 100644 --- a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp @@ -70,7 +70,6 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu(int iPad, void *ini m_checkboxes[eLaunchCheckbox_ResetNether].init(app.GetString(IDS_RESET_NETHER),eLaunchCheckbox_ResetNether,m_params->bResetNether); m_checkboxes[eLaunchCheckbox_Structures].init(app.GetString(IDS_GENERATE_STRUCTURES),eLaunchCheckbox_Structures,m_params->bStructures); m_checkboxes[eLaunchCheckbox_FlatWorld].init(app.GetString(IDS_SUPERFLAT_WORLD),eLaunchCheckbox_FlatWorld,m_params->bFlatWorld); - m_checkboxes[eLaunchCheckbox_BonusChest].init(app.GetString(IDS_BONUS_CHEST),eLaunchCheckbox_BonusChest,m_params->bBonusChest); if(m_loadedResolution == eSceneResolution_1080) { diff --git a/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp index f08fc727..26d8c7a4 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadMenu.cpp @@ -191,7 +191,7 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye else { -#if defined(__PS3__) || defined(__ORBIS__)|| defined(_DURANGO) || defined (__PSVITA__) +#if defined(__PS3__) || defined(__ORBIS__)|| defined(_DURANGO) || defined (__PSVITA__) || defined(_WINDOWS64) // convert to utf16 uint16_t u16Message[MAX_SAVEFILENAME_LENGTH]; size_t srclen,dstlen; @@ -202,7 +202,7 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye #elif defined(_DURANGO) // Already utf16 on durango memcpy(u16Message,params->saveDetails->UTF16SaveFilename, MAX_SAVEFILENAME_LENGTH); -#else // __ORBIS__ +#elif __ORBIS__ // __ORBIS__ { SceCesUcsContext Context; sceCesUcsContextInit( &Context ); @@ -211,6 +211,7 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye } #endif m_thumbnailName = (wchar_t *)u16Message; +#ifndef _WINDOWS64 if(params->saveDetails->pbThumbnailData) { m_pbThumbnailData = params->saveDetails->pbThumbnailData; @@ -218,6 +219,7 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye m_bSaveThumbnailReady = true; } else +#endif { app.DebugPrintf("Requesting the save thumbnail\n"); // set the save to load diff --git a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp index 1d90da77..fcb56c0c 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.cpp @@ -111,8 +111,11 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void *initData, UILayer m_controlJoinTimer.setVisible( true ); -#if defined(_XBOX_ONE) || defined(__ORBIS__) - m_spaceIndicatorSaves.init(L"",eControl_SpaceIndicator,0, (4LL *1024LL * 1024LL * 1024LL) ); +#if defined _XBOX_ONE || __ORBIS__ || _WINDOWS64 + if(ui.getScreenWidth() >= 1920) + { + m_spaceIndicatorSaves.init(L"",eControl_SpaceIndicator,0, (4LL *1024LL * 1024LL * 1024LL) ); + } #endif m_bUpdateSaveSize = false; @@ -158,7 +161,7 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void *initData, UILayer } #endif -#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) || defined(_DURANGO) +#if defined __PS3__ || __ORBIS__ || __PSVITA__ || _DURANGO || _WINDOWS64 // Always clear the saves when we enter this menu StorageManager.ClearSavesInfo(); #endif @@ -560,7 +563,7 @@ void UIScene_LoadOrJoinMenu::tick() // Stop loading thumbnails if we navigate forwards if(hasFocus(m_iPad)) { -#if defined(_XBOX_ONE) || defined(__ORBIS__) +#if defined _XBOX_ONE || __ORBIS__ || _WINDOWS64 if(m_bUpdateSaveSize) { if((m_iDefaultButtonsC > 0) && (m_iSaveListIndex >= m_iDefaultButtonsC)) @@ -581,8 +584,11 @@ void UIScene_LoadOrJoinMenu::tick() if(m_pSaveDetails!=NULL) { //CD - Fix - Adding define for ORBIS/XBOXONE -#if defined(_XBOX_ONE) || defined(__ORBIS__) - m_spaceIndicatorSaves.reset(); +#if defined _XBOX_ONE || __ORBIS__ || _WINDOWS64 + if(ui.getScreenWidth() >= 1920) + { + m_spaceIndicatorSaves.reset(); + } #endif AddDefaultButtons(); @@ -605,10 +611,33 @@ void UIScene_LoadOrJoinMenu::tick() m_iSaveDetailsCount = m_pSaveDetails->iSaveC; for(unsigned int i = 0; i < m_pSaveDetails->iSaveC; ++i) { -#if defined(_XBOX_ONE) +#ifdef _XBOX_ONE m_spaceIndicatorSaves.addSave(m_pSaveDetails->SaveInfoA[i].totalSize); -#elif defined(__ORBIS__) +#elif __ORBIS__ m_spaceIndicatorSaves.addSave(m_pSaveDetails->SaveInfoA[i].blocksUsed * (32 * 1024) ); +#elif _WINDOWS64 + if(ui.getScreenWidth() >= 1920) + { + ZeroMemory(m_saveDetails[i].UTF8SaveFilename, MAX_SAVEFILENAME_LENGTH); + memcpy(m_saveDetails[i].UTF8SaveFilename, m_pSaveDetails->SaveInfoA[i].UTF8SaveFilename, MAX_SAVEFILENAME_LENGTH - 1); + wstring folderPath = wstring(L"Windows64\\GameHDD\\") + app.UTF8ToWide(m_saveDetails[i].UTF8SaveFilename) + L"\\*"; + + DWORD fileSize = 0; + WIN32_FIND_DATAW findData; + HANDLE hFile = FindFirstFileW(folderPath.c_str(), &findData); + + if (hFile != INVALID_HANDLE_VALUE) { + do { + if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + fileSize = findData.nFileSizeLow; + break; + } + } while (FindNextFileW(hFile, &findData)); + FindClose(hFile); + } + m_spaceIndicatorSaves.addSave(fileSize); + } #endif #ifdef _DURANGO m_buttonListSaves.addItem(m_pSaveDetails->SaveInfoA[i].UTF16SaveTitle, L""); diff --git a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.h b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.h index 01d94b05..84c2d9d7 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_LoadOrJoinMenu.h @@ -20,7 +20,7 @@ private: { eControl_SavesList, eControl_GamesList, -#if defined(_XBOX_ONE) || defined(__ORBIS__) +#if defined _XBOX_ONE || __ORBIS__ || _WINDOWS64 eControl_SpaceIndicator, #endif }; @@ -52,7 +52,7 @@ protected: UIControl_SaveList m_buttonListGames; UIControl_Label m_labelSavesListTitle, m_labelJoinListTitle, m_labelNoGames; UIControl m_controlSavesTimer, m_controlJoinTimer; -#if defined(_XBOX_ONE) || defined(__ORBIS__) +#if defined _XBOX_ONE || __ORBIS__ || _WINDOWS64 UIControl_SpaceIndicatorBar m_spaceIndicatorSaves; #endif @@ -68,7 +68,7 @@ private: UI_MAP_ELEMENT( m_controlSavesTimer, "SavesTimer") UI_MAP_ELEMENT( m_controlJoinTimer, "JoinTimer") -#if defined(_XBOX_ONE) || defined(__ORBIS__) +#if defined _XBOX_ONE || __ORBIS__ || _WINDOWS64 UI_MAP_ELEMENT( m_spaceIndicatorSaves, "SaveSizeBar") #endif UI_END_MAP_ELEMENTS_AND_NAMES() diff --git a/Minecraft.Client/Windows64/Windows64_App.cpp b/Minecraft.Client/Windows64/Windows64_App.cpp index 5358ea62..e3731ffe 100644 --- a/Minecraft.Client/Windows64/Windows64_App.cpp +++ b/Minecraft.Client/Windows64/Windows64_App.cpp @@ -227,3 +227,12 @@ int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType) { } + +std::wstring CConsoleMinecraftApp::UTF8ToWide(const char* utf8) +{ + int size = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, nullptr, 0); + std::wstring wstr(size, 0); + MultiByteToWideChar(CP_UTF8, 0, utf8, -1, &wstr[0], size); + wstr.resize(size - 1); + return wstr; +} \ No newline at end of file diff --git a/Minecraft.Client/Windows64/Windows64_App.h b/Minecraft.Client/Windows64/Windows64_App.h index 39351d55..168ef1e1 100644 --- a/Minecraft.Client/Windows64/Windows64_App.h +++ b/Minecraft.Client/Windows64/Windows64_App.h @@ -29,6 +29,9 @@ public: // original code virtual void TemporaryCreateGameStart(); + + // str1k3r - UTF8 to wchar + std::wstring UTF8ToWide(const char* utf8); }; extern CConsoleMinecraftApp app;