mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-07-19 00:38:17 +00:00
Add RmlUi
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
#include "stdafx.h"
|
||||
#include "IUIScene_PauseMenu.h"
|
||||
#include "..\..\Minecraft.h"
|
||||
#include "..\..\MinecraftServer.h"
|
||||
#include "..\..\MultiPlayerLevel.h"
|
||||
#include "..\..\ProgressRenderer.h"
|
||||
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
|
||||
#include "..\..\..\Minecraft.World\net.minecraft.world.phys.h"
|
||||
#include "..\..\TexturePackRepository.h"
|
||||
#include "..\..\TexturePack.h"
|
||||
#include "..\..\DLCTexturePack.h"
|
||||
#include "..\..\..\Minecraft.World\StringHelpers.h"
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../MinecraftServer.h"
|
||||
#include "../../MultiPlayerLevel.h"
|
||||
#include "../../ProgressRenderer.h"
|
||||
#include "../../../Minecraft.World/net.minecraft.world.level.h"
|
||||
#include "../../../Minecraft.World/net.minecraft.world.phys.h"
|
||||
#include "../../TexturePackRepository.h"
|
||||
#include "../../TexturePack.h"
|
||||
#include "../../../Minecraft.World/StringHelpers.h"
|
||||
|
||||
#ifndef _XBOX
|
||||
#include "UI.h"
|
||||
#include "../DLC/DLCPack.h"
|
||||
#endif
|
||||
|
||||
|
||||
int IUIScene_PauseMenu::ExitGameDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
@@ -40,43 +42,14 @@ int IUIScene_PauseMenu::ExitGameSaveDialogReturned(void *pParam,int iPad,C4JStor
|
||||
#endif
|
||||
|
||||
// Exit with or without saving
|
||||
// Decline means save in this dialog
|
||||
if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption)
|
||||
if(result==C4JStorage::EMessage_ResultAccept || result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption)
|
||||
{
|
||||
if( result==C4JStorage::EMessage_ResultAccept ) // Cancel
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if( result==C4JStorage::EMessage_ResultDecline ) // Save
|
||||
{
|
||||
// 4J-PB - Is the player trying to save but they are using a trial texturepack ?
|
||||
if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin())
|
||||
{
|
||||
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
|
||||
DLCTexturePack *pDLCTexPack=static_cast<DLCTexturePack *>(tPack);
|
||||
|
||||
DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack();
|
||||
if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" ))
|
||||
{
|
||||
#ifdef _XBOX
|
||||
// upsell
|
||||
ULONGLONG ullOfferID_Full;
|
||||
// get the dlc texture pack
|
||||
DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
|
||||
|
||||
app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullOfferID_Full);
|
||||
|
||||
// tell sentient about the upsell of the full version of the skin pack
|
||||
TelemetryManager->RecordUpsellPresented(iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF);
|
||||
#endif
|
||||
|
||||
UINT uiIDA[2];
|
||||
uiIDA[0]=IDS_CONFIRM_OK;
|
||||
uiIDA[1]=IDS_CONFIRM_CANCEL;
|
||||
|
||||
// Give the player a warning about the trial version of the texture pack
|
||||
//ui.RequestAlertMessage(IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE, IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad() , &IUIScene_PauseMenu::WarningTrialTexturePackReturned, pParam);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// does the save exist?
|
||||
bool bSaveExists;
|
||||
StorageManager.DoesSaveExist(&bSaveExists);
|
||||
@@ -98,7 +71,7 @@ int IUIScene_PauseMenu::ExitGameSaveDialogReturned(void *pParam,int iPad,C4JStor
|
||||
MinecraftServer::getInstance()->setSaveOnExit( true );
|
||||
}
|
||||
}
|
||||
else
|
||||
else // EMessage_ResultThirdOption - Don't Save
|
||||
{
|
||||
// been a few requests for a confirm on exit without saving
|
||||
UINT uiIDA[2];
|
||||
@@ -212,141 +185,6 @@ int IUIScene_PauseMenu::ExitGameDeclineSaveReturned(void *pParam,int iPad,C4JSto
|
||||
|
||||
|
||||
|
||||
int IUIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
if(!ProfileManager.IsSignedInLive(iPad))
|
||||
{
|
||||
// you're not signed in to PSN!
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4J-PB - need to check this user can access the store
|
||||
bool bContentRestricted;
|
||||
ProfileManager.GetChatAndContentRestrictions(iPad,true,nullptr,&bContentRestricted,nullptr);
|
||||
if(bContentRestricted)
|
||||
{
|
||||
UINT uiIDA[1];
|
||||
uiIDA[0]=IDS_CONFIRM_OK;
|
||||
ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad);
|
||||
}
|
||||
else
|
||||
{
|
||||
// need to get info on the pack to see if the user has already downloaded it
|
||||
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
|
||||
DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
|
||||
|
||||
// retrieve the store name for the skin pack
|
||||
DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();//tPack->getDLCPack();
|
||||
const char *pchPackName=wstringtofilename(pDLCPack->getName());
|
||||
app.DebugPrintf("Texture Pack - %s\n",pchPackName);
|
||||
SONYDLC *pSONYDLCInfo=app.GetSONYDLCInfo((char *)pchPackName);
|
||||
|
||||
if(pSONYDLCInfo!=nullptr)
|
||||
{
|
||||
char chName[42];
|
||||
char chSkuID[SCE_NP_COMMERCE2_SKU_ID_LEN];
|
||||
|
||||
memset(chSkuID,0,SCE_NP_COMMERCE2_SKU_ID_LEN);
|
||||
// find the info on the skin pack
|
||||
// we have to retrieve the skuid from the store info, it can't be hardcoded since Sony may change it.
|
||||
// So we assume the first sku for the product is the one we want
|
||||
#ifdef __ORBIS__
|
||||
sprintf(chName,"%s",pSONYDLCInfo->chDLCKeyname);
|
||||
#else
|
||||
sprintf(chName,"%s-%s",app.GetCommerceCategory(),pSONYDLCInfo->chDLCKeyname);
|
||||
#endif
|
||||
app.GetDLCSkuIDFromProductList(chName,chSkuID);
|
||||
// 4J-PB - need to check for an empty store
|
||||
#if defined __ORBIS__ || defined __PSVITA__ || defined __PS3__
|
||||
if(app.CheckForEmptyStore(iPad)==false)
|
||||
#endif
|
||||
{
|
||||
if(app.DLCAlreadyPurchased(chSkuID))
|
||||
{
|
||||
app.DownloadAlreadyPurchased(chSkuID);
|
||||
}
|
||||
else
|
||||
{
|
||||
app.Checkout(chSkuID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //
|
||||
|
||||
#ifdef _XBOX_ONE
|
||||
IUIScene_PauseMenu* pScene = (IUIScene_PauseMenu*)pParam;
|
||||
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
if(ProfileManager.IsSignedIn(iPad))
|
||||
{
|
||||
if (ProfileManager.IsSignedInLive(iPad))
|
||||
{
|
||||
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
|
||||
// get the dlc texture pack
|
||||
DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
|
||||
|
||||
DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack();
|
||||
|
||||
DLC_INFO *pDLCInfo=app.GetDLCInfoForProductName((WCHAR *)pDLCPack->getName().c_str());
|
||||
|
||||
StorageManager.InstallOffer(1,(WCHAR *)pDLCInfo->wsProductId.c_str(),nullptr,nullptr);
|
||||
|
||||
// the license change coming in when the offer has been installed will cause this scene to refresh
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4J-JEV: Fix for XB1: #165863 - XR-074: Compliance: With no active network connection user is unable to convert from Trial to Full texture pack and is not messaged why.
|
||||
UINT uiIDA[1] = { IDS_CONFIRM_OK };
|
||||
ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _XBOX
|
||||
IUIScene_PauseMenu* pScene = (IUIScene_PauseMenu*)pParam;
|
||||
|
||||
//pScene->m_bIgnoreInput = false;
|
||||
pScene->ShowScene( true );
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
if(ProfileManager.IsSignedIn(iPad))
|
||||
{
|
||||
ULONGLONG ullIndexA[1];
|
||||
|
||||
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
|
||||
// get the dlc texture pack
|
||||
DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tPack;
|
||||
|
||||
// Need to get the parent packs id, since this may be one of many child packs with their own ids
|
||||
app.GetDLCFullOfferIDForPackID(pDLCTexPack->getDLCParentPackId(),&ullIndexA[0]);
|
||||
|
||||
// need to allow downloads here, or the player would need to quit the game to let the download of a texture pack happen. This might affect the network traffic, since the download could take all the bandwidth...
|
||||
XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW);
|
||||
|
||||
StorageManager.InstallOffer(1,ullIndexA,nullptr,nullptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TelemetryManager->RecordUpsellResponded(iPad, eSet_UpsellID_Texture_DLC, ( pScene->m_pDLCPack->getPurchaseOfferId() & 0xFFFFFFFF ), eSen_UpsellOutcome_Declined);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int IUIScene_PauseMenu::SaveWorldThreadProc( LPVOID lpParameter )
|
||||
{
|
||||
bool bAutosave=static_cast<bool>(lpParameter);
|
||||
@@ -407,11 +245,73 @@ int IUIScene_PauseMenu::ExitWorldThreadProc( void* lpParameter )
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
static bool Win64_DeleteSaveDirectory(const wchar_t* wPath)
|
||||
{
|
||||
wchar_t wSearch[MAX_PATH];
|
||||
swprintf_s(wSearch, MAX_PATH, L"%s\\*", wPath);
|
||||
WIN32_FIND_DATAW fd;
|
||||
HANDLE hFind = FindFirstFileW(wSearch, &fd);
|
||||
if (hFind != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (wcscmp(fd.cFileName, L".") == 0 || wcscmp(fd.cFileName, L"..") == 0) continue;
|
||||
wchar_t wChild[MAX_PATH];
|
||||
swprintf_s(wChild, MAX_PATH, L"%s\\%s", wPath, fd.cFileName);
|
||||
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
Win64_DeleteSaveDirectory(wChild);
|
||||
else
|
||||
DeleteFileW(wChild);
|
||||
} while (FindNextFileW(hFind, &fd));
|
||||
FindClose(hFind);
|
||||
}
|
||||
return RemoveDirectoryW(wPath) != 0;
|
||||
}
|
||||
#endif // _WINDOWS64
|
||||
|
||||
// This function performs the meat of exiting from a level. It should be called from a thread other than the main thread.
|
||||
void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter)
|
||||
{
|
||||
#ifndef MINECRAFT_SERVER_BUILD
|
||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||
|
||||
// 4J Added: Capture hardcore delete info before the server is destroyed
|
||||
#ifdef _WINDOWS64
|
||||
bool shouldDeleteHardcoreWorld = false;
|
||||
wstring hardcoreSaveFolderName;
|
||||
if (MinecraftServer::getInstance() != nullptr && MinecraftServer::getInstance()->getDeleteWorldOnExit())
|
||||
{
|
||||
shouldDeleteHardcoreWorld = true;
|
||||
// Try 1: Use the save folder name stored by UIScene_LoadMenu::StartGameFromSave (works for existing saves)
|
||||
hardcoreSaveFolderName = app.GetCurrentSaveFolderName();
|
||||
if (!hardcoreSaveFolderName.empty())
|
||||
{
|
||||
app.DebugPrintf("Hardcore mode: save folder from app = '%ls'\n", hardcoreSaveFolderName.c_str());
|
||||
}
|
||||
// Try 2: StorageManager (may work for new saves after first autosave)
|
||||
if (hardcoreSaveFolderName.empty())
|
||||
{
|
||||
char szSaveFolder[MAX_SAVEFILENAME_LENGTH] = {};
|
||||
StorageManager.GetSaveUniqueFilename(szSaveFolder);
|
||||
if (szSaveFolder[0] != '\0')
|
||||
{
|
||||
wchar_t wSaveFolder[MAX_SAVEFILENAME_LENGTH] = {};
|
||||
mbstowcs(wSaveFolder, szSaveFolder, MAX_SAVEFILENAME_LENGTH - 1);
|
||||
hardcoreSaveFolderName = wSaveFolder;
|
||||
app.DebugPrintf("Hardcore mode: save folder from StorageManager = '%s'\n", szSaveFolder);
|
||||
}
|
||||
}
|
||||
// Try 3: Stored during loadLevel
|
||||
if (hardcoreSaveFolderName.empty())
|
||||
{
|
||||
hardcoreSaveFolderName = MinecraftServer::getInstance()->getSaveFolderName();
|
||||
app.DebugPrintf("Hardcore mode: save folder from server = '%ls'\n", hardcoreSaveFolderName.c_str());
|
||||
}
|
||||
MinecraftServer::getInstance()->setDeleteWorldOnExit(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
int exitReasonStringId = pMinecraft->progressRenderer->getCurrentTitle();
|
||||
int exitReasonTitleId = IDS_CONNECTION_LOST;
|
||||
|
||||
@@ -622,6 +522,17 @@ void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter)
|
||||
{
|
||||
Sleep(1);
|
||||
}
|
||||
// 4J Added: Hardcore mode — delete world save data now that the server is fully stopped
|
||||
#ifdef _WINDOWS64
|
||||
if (shouldDeleteHardcoreWorld && !hardcoreSaveFolderName.empty())
|
||||
{
|
||||
wchar_t wFolderPath[MAX_PATH] = {};
|
||||
swprintf_s(wFolderPath, MAX_PATH, L"Windows64\\GameHDD\\%s", hardcoreSaveFolderName.c_str());
|
||||
app.DebugPrintf("Hardcore mode: Deleting world save folder '%ls'\n", wFolderPath);
|
||||
Win64_DeleteSaveDirectory(wFolderPath);
|
||||
}
|
||||
#endif
|
||||
|
||||
pMinecraft->setLevel(nullptr,exitReasonStringId,nullptr,saveStats);
|
||||
|
||||
TelemetryManager->Flush();
|
||||
@@ -649,6 +560,7 @@ void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter)
|
||||
// Make sure we don't think saving is disabled in the menus
|
||||
StorageManager.SetSaveDisabled(false);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -705,4 +617,4 @@ int IUIScene_PauseMenu::DisableAutosaveDialogReturned(void *pParam,int iPad,C4JS
|
||||
app.SetAction(iPad,eAppAction_SaveGame);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user