fix: achievements (2)

Make menu more accurate
Add Achievements option to Main Menu
Force achievements to save when saving the level
Fix a random crash i was getting
This commit is contained in:
SevenToaster509 2026-04-26 20:12:34 +01:00
parent ae5a86d082
commit 57de83add1
7 changed files with 25 additions and 9 deletions

View file

@ -929,7 +929,11 @@ void CPlatformNetworkManagerStub::SearchForGames()
strncpy_s(info->data.hostIP, sizeof(info->data.hostIP), ipBuf, _TRUNCATE);
info->data.hostPort = port;
info->sessionId = static_cast<uint64_t>(inet_addr(ipBuf)) | static_cast<uint64_t>(port) << 32;
friendsSessions[0].push_back(info);
//Fix null crash? I think its here...
if (info) {
friendsSessions[0].push_back(info);
}
}
}
}

View file

@ -1916,7 +1916,7 @@ GDrawTexture * RADLINK UIController::TextureSubstitutionCreateCallback ( void *
UIScene *scene = uiController->GetTopScene(0);
//Fix for icon size changing on Achievements
if (scene) {
if (scene->getSceneResolution() == UIScene::eSceneResolution_1080 && scene->getSceneType() != eUIScene_PauseMenu && isSub == false)
if (scene->getSceneResolution() == UIScene::eSceneResolution_1080 && (scene->getSceneType() != eUIScene_PauseMenu && scene->getSceneType() != eUIScene_MainMenu && scene->getSceneType() != eUIScene_AchievementsMenu) && isSub == false)
{
*width = 96;
*height = 96;

View file

@ -16,13 +16,13 @@ UIScene_AchievementsMenu::UIScene_AchievementsMenu(int iPad, void* _initData, UI
// Setup all the Iggy references we need for this scene
initialiseMovie();
RECT rc;
/*RECT rc;
GetClientRect(g_hWnd, &rc);
POINT center;
center.x = rc.left;
center.y = rc.top;
ClientToScreen(g_hWnd, &center);
SetCursorPos(center.x, center.y);
SetCursorPos(center.x, center.y);*/
m_labelAchievements.init(L"Achievements");
//m_labelDesc.init(L"");
@ -46,7 +46,13 @@ UIScene_AchievementsMenu::UIScene_AchievementsMenu(int iPad, void* _initData, UI
std::string result = "Graphics\\Achievements\\" "TROP" + Achievements::achievements->at(i)->iconInt + ".png"; //media\\
m_achievementsList.addnewItem(i+1, path);
if (Minecraft::GetInstance()->stats[Minecraft::GetInstance()->player->GetXboxPad()]->hasTaken(Achievements::achievements->at(i)))
int newPad = 0;
if (Minecraft::GetInstance()->player != nullptr) {
newPad = Minecraft::GetInstance()->player->GetXboxPad();
}
if (Minecraft::GetInstance()->stats[newPad]->hasTaken(Achievements::achievements->at(i)))
{
m_achievementsList.EnableButton(i, true);
}
@ -63,8 +69,7 @@ UIScene_AchievementsMenu::UIScene_AchievementsMenu(int iPad, void* _initData, UI
void UIScene_AchievementsMenu::handleDestroy()
{
#ifdef _WINDOWS64
#endif
m_parentLayer->showComponent(m_iPad, eUIComponent_MenuBackground, false);
}
void UIScene_AchievementsMenu::SetAchievementDescription(wstring desc) {
@ -102,8 +107,12 @@ wstring UIScene_AchievementsMenu::getMoviePath()
void UIScene_AchievementsMenu::updateComponents()
{
bool bNotInGame = (Minecraft::GetInstance()->level == nullptr);
if (!bNotInGame)
{
m_parentLayer->showComponent(m_iPad, eUIComponent_MenuBackground, true);
}
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false);
m_parentLayer->showComponent(m_iPad, eUIComponent_MenuBackground, false);
}
void UIScene_AchievementsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool& handled)

View file

@ -28,7 +28,6 @@ private:
UI_MAP_ELEMENT(m_labelAchievements, "AcheivementsLabel")
UI_MAP_ELEMENT(m_labelName, "AchievementName")
UI_MAP_ELEMENT(m_labelDesc, "AchievementDescription")
UI_MAP_ELEMENT(m_cursorPath1, "cursor")
//UI_MAP_ELEMENT(m_achievementsList, "AchievementsList")
UI_MAP_ELEMENT(m_controlMainPanel, "AchievementsListContainer")
UI_MAP_NAME(m_funcSetDesc, L"SetAchievementDescription")

View file

@ -2040,6 +2040,7 @@ void UIScene_MainMenu::RunAchievements(int iPad)
XShowAchievementsUI( iPad );
}
#endif
ui.NavigateToScene(iPad, eUIScene_AchievementsMenu);
}
void UIScene_MainMenu::RunHelpAndOptions(int iPad)

View file

@ -993,6 +993,7 @@ int UIScene_PauseMenu::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::
ProfileManager.DisplayFullVersionPurchase(false,pMinecraft->player->GetXboxPad(),eSen_UpsellID_Full_Version_Of_Game);
}
}
pMinecraft->forceStatsSave(pMinecraft->player->GetXboxPad());
}
else
{

View file

@ -11,6 +11,7 @@
#include "LevelData.h"
#include "DirectoryLevelStorage.h"
#include "ConsoleSaveFileIO.h"
#include "../Minecraft.Client/Minecraft.h"
const wstring DirectoryLevelStorage::sc_szPlayerDir(L"players/");
@ -391,6 +392,7 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
if( playerXuid != INVALID_XUID && !player->isGuest() )
#endif
{
Minecraft::GetInstance()->forceStatsSave(player->getPlayerIndex());
CompoundTag *tag = new CompoundTag();
player->saveWithoutId(tag);
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)