mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-23 16:24:43 +00:00
refactor: extract GameSettingsManager, DLCController, NetworkController, MenuController from Game
This commit is contained in:
parent
d61d3cddab
commit
3b47b80762
719
targets/app/common/DLCController.cpp
Normal file
719
targets/app/common/DLCController.cpp
Normal file
|
|
@ -0,0 +1,719 @@
|
|||
#include "app/common/DLCController.h"
|
||||
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/DLC/DLCPack.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "app/common/DLC/DLCSkinFile.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/linux/Linux_UIController.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/skins/TexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "platform/sdl2/Profile.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
|
||||
DLCController::DLCController() {
|
||||
m_pDLCFileBuffer = nullptr;
|
||||
m_dwDLCFileSize = 0;
|
||||
m_bDefaultCapeInstallAttempted = false;
|
||||
m_bDLCInstallProcessCompleted = false;
|
||||
m_bDLCInstallPending = false;
|
||||
m_iTotalDLC = 0;
|
||||
m_iTotalDLCInstalled = 0;
|
||||
m_bNewDLCAvailable = false;
|
||||
m_bSeenNewDLCTip = false;
|
||||
m_iDLCOfferC = 0;
|
||||
m_bAllDLCContentRetrieved = true;
|
||||
m_bAllTMSContentRetrieved = true;
|
||||
m_bTickTMSDLCFiles = true;
|
||||
}
|
||||
|
||||
std::unordered_map<PlayerUID, MOJANG_DATA*> DLCController::MojangData;
|
||||
std::unordered_map<int, uint64_t> DLCController::DLCTextures_PackID;
|
||||
std::unordered_map<uint64_t, DLC_INFO*> DLCController::DLCInfo_Trial;
|
||||
std::unordered_map<uint64_t, DLC_INFO*> DLCController::DLCInfo_Full;
|
||||
std::unordered_map<std::wstring, uint64_t> DLCController::DLCInfo_SkinName;
|
||||
|
||||
std::uint32_t DLCController::m_dwContentTypeA[e_Marketplace_MAX] = {
|
||||
XMARKETPLACE_OFFERING_TYPE_CONTENT,
|
||||
XMARKETPLACE_OFFERING_TYPE_THEME,
|
||||
XMARKETPLACE_OFFERING_TYPE_AVATARITEM,
|
||||
XMARKETPLACE_OFFERING_TYPE_TILE,
|
||||
};
|
||||
|
||||
int DLCController::marketplaceCountsCallback(
|
||||
void* pParam, C4JStorage::DLC_TMS_DETAILS* pTMSDetails, int iPad) {
|
||||
app.DebugPrintf("Marketplace Counts= New - %d Total - %d\n",
|
||||
pTMSDetails->dwNewOffers, pTMSDetails->dwTotalOffers);
|
||||
|
||||
if (pTMSDetails->dwNewOffers > 0) {
|
||||
app.m_dlcController.m_bNewDLCAvailable = true;
|
||||
app.m_dlcController.m_bSeenNewDLCTip = false;
|
||||
} else {
|
||||
app.m_dlcController.m_bNewDLCAvailable = false;
|
||||
app.m_dlcController.m_bSeenNewDLCTip = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DLCController::startInstallDLCProcess(int iPad) {
|
||||
app.DebugPrintf("--- DLCController::startInstallDLCProcess: pad=%i.\n",
|
||||
iPad);
|
||||
|
||||
if ((dlcInstallProcessCompleted() == false) &&
|
||||
(m_bDLCInstallPending == false)) {
|
||||
app.m_dlcManager.resetUnnamedCorruptCount();
|
||||
m_bDLCInstallPending = true;
|
||||
m_iTotalDLC = 0;
|
||||
m_iTotalDLCInstalled = 0;
|
||||
app.DebugPrintf(
|
||||
"--- DLCController::startInstallDLCProcess - "
|
||||
"StorageManager.GetInstalledDLC\n");
|
||||
|
||||
StorageManager.GetInstalledDLC(
|
||||
iPad, [this](int iInstalledC, int pad) {
|
||||
return dlcInstalledCallback(iInstalledC, pad);
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"--- DLCController::startInstallDLCProcess - nothing to do\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int DLCController::dlcInstalledCallback(int iInstalledC, int iPad) {
|
||||
app.DebugPrintf(
|
||||
"--- DLCController::dlcInstalledCallback: totalDLC=%i, pad=%i.\n",
|
||||
iInstalledC, iPad);
|
||||
m_iTotalDLC = iInstalledC;
|
||||
mountNextDLC(iPad);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DLCController::mountNextDLC(int iPad) {
|
||||
app.DebugPrintf("--- DLCController::mountNextDLC: pad=%i.\n", iPad);
|
||||
if (m_iTotalDLCInstalled < m_iTotalDLC) {
|
||||
if (StorageManager.MountInstalledDLC(
|
||||
iPad, m_iTotalDLCInstalled,
|
||||
[this](int pad, std::uint32_t dwErr,
|
||||
std::uint32_t dwLicenceMask) {
|
||||
return dlcMountedCallback(pad, dwErr, dwLicenceMask);
|
||||
}) != ERROR_IO_PENDING) {
|
||||
app.DebugPrintf("Failed to mount DLC %d for pad %d\n",
|
||||
m_iTotalDLCInstalled, iPad);
|
||||
++m_iTotalDLCInstalled;
|
||||
mountNextDLC(iPad);
|
||||
} else {
|
||||
app.DebugPrintf("StorageManager.MountInstalledDLC ok\n");
|
||||
}
|
||||
} else {
|
||||
m_bDLCInstallPending = false;
|
||||
m_bDLCInstallProcessCompleted = true;
|
||||
ui.HandleDLCMountingComplete();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS64)
|
||||
#define CONTENT_DATA_DISPLAY_NAME(a) (a.szDisplayName)
|
||||
#else
|
||||
#define CONTENT_DATA_DISPLAY_NAME(a) (a.wszDisplayName)
|
||||
#endif
|
||||
|
||||
int DLCController::dlcMountedCallback(int iPad, std::uint32_t dwErr,
|
||||
std::uint32_t dwLicenceMask) {
|
||||
#if defined(_WINDOWS64)
|
||||
app.DebugPrintf("--- DLCController::dlcMountedCallback\n");
|
||||
|
||||
if (dwErr != ERROR_SUCCESS) {
|
||||
app.DebugPrintf("Failed to mount DLC for pad %d: %u\n", iPad, dwErr);
|
||||
app.m_dlcManager.incrementUnnamedCorruptCount();
|
||||
} else {
|
||||
XCONTENT_DATA ContentData =
|
||||
StorageManager.GetDLC(m_iTotalDLCInstalled);
|
||||
|
||||
DLCPack* pack =
|
||||
app.m_dlcManager.getPack(CONTENT_DATA_DISPLAY_NAME(ContentData));
|
||||
|
||||
if (pack != nullptr && pack->IsCorrupt()) {
|
||||
app.DebugPrintf(
|
||||
"Pack '%ls' is corrupt, removing it from the DLC Manager.\n",
|
||||
CONTENT_DATA_DISPLAY_NAME(ContentData));
|
||||
app.m_dlcManager.removePack(pack);
|
||||
pack = nullptr;
|
||||
}
|
||||
|
||||
if (pack == nullptr) {
|
||||
app.DebugPrintf("Pack \"%ls\" is not installed, so adding it\n",
|
||||
CONTENT_DATA_DISPLAY_NAME(ContentData));
|
||||
|
||||
#if defined(_WINDOWS64)
|
||||
pack = new DLCPack(ContentData.szDisplayName, dwLicenceMask);
|
||||
#else
|
||||
pack = new DLCPack(ContentData.wszDisplayName, dwLicenceMask);
|
||||
#endif
|
||||
pack->SetDLCMountIndex(m_iTotalDLCInstalled);
|
||||
pack->SetDLCDeviceID(ContentData.DeviceID);
|
||||
app.m_dlcManager.addPack(pack);
|
||||
handleDLC(pack);
|
||||
|
||||
if (pack->getDLCItemsCount(DLCManager::e_DLCType_Texture) > 0) {
|
||||
Minecraft::GetInstance()->skins->addTexturePackFromDLC(
|
||||
pack, pack->GetPackId());
|
||||
}
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"Pack \"%ls\" is already installed. Updating license to %u\n",
|
||||
CONTENT_DATA_DISPLAY_NAME(ContentData), dwLicenceMask);
|
||||
|
||||
pack->SetDLCMountIndex(m_iTotalDLCInstalled);
|
||||
pack->SetDLCDeviceID(ContentData.DeviceID);
|
||||
pack->updateLicenseMask(dwLicenceMask);
|
||||
}
|
||||
|
||||
StorageManager.UnmountInstalledDLC();
|
||||
}
|
||||
++m_iTotalDLCInstalled;
|
||||
mountNextDLC(iPad);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#undef CONTENT_DATA_DISPLAY_NAME
|
||||
|
||||
void DLCController::handleDLC(DLCPack* pack) {
|
||||
unsigned int dwFilesProcessed = 0;
|
||||
#if defined(_WINDOWS64) || defined(__linux__)
|
||||
std::vector<std::string> dlcFilenames;
|
||||
#endif
|
||||
StorageManager.GetMountedDLCFileList("DLCDrive", dlcFilenames);
|
||||
for (int i = 0; i < dlcFilenames.size(); i++) {
|
||||
app.m_dlcManager.readDLCDataFile(dwFilesProcessed, dlcFilenames[i],
|
||||
pack);
|
||||
}
|
||||
if (dwFilesProcessed == 0) app.m_dlcManager.removePack(pack);
|
||||
}
|
||||
|
||||
void DLCController::addCreditText(const wchar_t* lpStr) {
|
||||
app.DebugPrintf("ADDING CREDIT - %ls\n", lpStr);
|
||||
SCreditTextItemDef* pCreditStruct = new SCreditTextItemDef;
|
||||
pCreditStruct->m_eType = eSmallText;
|
||||
pCreditStruct->m_iStringID[0] = NO_TRANSLATED_STRING;
|
||||
pCreditStruct->m_iStringID[1] = NO_TRANSLATED_STRING;
|
||||
pCreditStruct->m_Text = new wchar_t[wcslen(lpStr) + 1];
|
||||
wcscpy((wchar_t*)pCreditStruct->m_Text, lpStr);
|
||||
vDLCCredits.push_back(pCreditStruct);
|
||||
}
|
||||
|
||||
bool DLCController::alreadySeenCreditText(const std::wstring& wstemp) {
|
||||
for (unsigned int i = 0; i < m_vCreditText.size(); i++) {
|
||||
std::wstring temp = m_vCreditText.at(i);
|
||||
if (temp.compare(wstemp) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
m_vCreditText.push_back((wchar_t*)wstemp.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int DLCController::getDLCCreditsCount() {
|
||||
return (unsigned int)vDLCCredits.size();
|
||||
}
|
||||
|
||||
SCreditTextItemDef* DLCController::getDLCCredits(int iIndex) {
|
||||
return vDLCCredits.at(iIndex);
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS64)
|
||||
int32_t DLCController::registerDLCData(wchar_t* pType, wchar_t* pBannerName,
|
||||
int iGender, uint64_t ullOfferID_Full,
|
||||
uint64_t ullOfferID_Trial,
|
||||
wchar_t* pFirstSkin,
|
||||
unsigned int uiSortIndex, int iConfig,
|
||||
wchar_t* pDataFile) {
|
||||
int32_t hr = 0;
|
||||
DLC_INFO* pDLCData = new DLC_INFO;
|
||||
memset(pDLCData, 0, sizeof(DLC_INFO));
|
||||
pDLCData->ullOfferID_Full = ullOfferID_Full;
|
||||
pDLCData->ullOfferID_Trial = ullOfferID_Trial;
|
||||
pDLCData->eDLCType = e_DLC_NotDefined;
|
||||
pDLCData->iGender = iGender;
|
||||
pDLCData->uiSortIndex = uiSortIndex;
|
||||
pDLCData->iConfig = iConfig;
|
||||
|
||||
if (pBannerName != L"") {
|
||||
wcsncpy_s(pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE);
|
||||
}
|
||||
if (pDataFile[0] != 0) {
|
||||
wcsncpy_s(pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE);
|
||||
}
|
||||
|
||||
if (pType != nullptr) {
|
||||
if (wcscmp(pType, L"Skin") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_SkinPack;
|
||||
} else if (wcscmp(pType, L"Gamerpic") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_Gamerpics;
|
||||
} else if (wcscmp(pType, L"Theme") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_Themes;
|
||||
} else if (wcscmp(pType, L"Avatar") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_AvatarItems;
|
||||
} else if (wcscmp(pType, L"MashUpPack") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_MashupPacks;
|
||||
DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full;
|
||||
} else if (wcscmp(pType, L"TexturePack") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_TexturePacks;
|
||||
DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full;
|
||||
}
|
||||
}
|
||||
|
||||
if (ullOfferID_Trial != 0ll) DLCInfo_Trial[ullOfferID_Trial] = pDLCData;
|
||||
if (ullOfferID_Full != 0ll) DLCInfo_Full[ullOfferID_Full] = pDLCData;
|
||||
if (pFirstSkin[0] != 0) DLCInfo_SkinName[pFirstSkin] = ullOfferID_Full;
|
||||
|
||||
return hr;
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
int32_t DLCController::registerDLCData(wchar_t* pType, wchar_t* pBannerName,
|
||||
int iGender, uint64_t ullOfferID_Full,
|
||||
uint64_t ullOfferID_Trial,
|
||||
wchar_t* pFirstSkin,
|
||||
unsigned int uiSortIndex, int iConfig,
|
||||
wchar_t* pDataFile) {
|
||||
fprintf(stderr,
|
||||
"warning: DLCController::registerDLCData unimplemented for "
|
||||
"platform `__linux__`\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool DLCController::getDLCFullOfferIDForSkinID(const std::wstring& FirstSkin,
|
||||
uint64_t* pullVal) {
|
||||
auto it = DLCInfo_SkinName.find(FirstSkin);
|
||||
if (it == DLCInfo_SkinName.end()) {
|
||||
return false;
|
||||
} else {
|
||||
*pullVal = (uint64_t)it->second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool DLCController::getDLCFullOfferIDForPackID(const int iPackID,
|
||||
uint64_t* pullVal) {
|
||||
auto it = DLCTextures_PackID.find(iPackID);
|
||||
if (it == DLCTextures_PackID.end()) {
|
||||
*pullVal = (uint64_t)0;
|
||||
return false;
|
||||
} else {
|
||||
*pullVal = (uint64_t)it->second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoForTrialOfferID(
|
||||
uint64_t ullOfferID_Trial) {
|
||||
if (DLCInfo_Trial.size() > 0) {
|
||||
auto it = DLCInfo_Trial.find(ullOfferID_Trial);
|
||||
if (it == DLCInfo_Trial.end()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return it->second;
|
||||
}
|
||||
} else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoForFullOfferID(uint64_t ullOfferID_Full) {
|
||||
if (DLCInfo_Full.size() > 0) {
|
||||
auto it = DLCInfo_Full.find(ullOfferID_Full);
|
||||
if (it == DLCInfo_Full.end()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return it->second;
|
||||
}
|
||||
} else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoTrialOffer(int iIndex) {
|
||||
std::unordered_map<uint64_t, DLC_INFO*>::iterator it =
|
||||
DLCInfo_Trial.begin();
|
||||
for (int i = 0; i < iIndex; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoFullOffer(int iIndex) {
|
||||
std::unordered_map<uint64_t, DLC_INFO*>::iterator it = DLCInfo_Full.begin();
|
||||
for (int i = 0; i < iIndex; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
uint64_t DLCController::getDLCInfoTexturesFullOffer(int iIndex) {
|
||||
std::unordered_map<int, uint64_t>::iterator it = DLCTextures_PackID.begin();
|
||||
for (int i = 0; i < iIndex; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
int DLCController::getDLCInfoTrialOffersCount() {
|
||||
return (int)DLCInfo_Trial.size();
|
||||
}
|
||||
|
||||
int DLCController::getDLCInfoFullOffersCount() {
|
||||
return (int)DLCInfo_Full.size();
|
||||
}
|
||||
|
||||
int DLCController::getDLCInfoTexturesOffersCount() {
|
||||
return (int)DLCTextures_PackID.size();
|
||||
}
|
||||
|
||||
unsigned int DLCController::addDLCRequest(eDLCMarketplaceType eType,
|
||||
bool bPromote) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
|
||||
|
||||
int iPosition = 0;
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->dwType == m_dwContentTypeA[eType]) {
|
||||
if (pCurrent->eState == e_DLC_ContentState_Retrieving ||
|
||||
pCurrent->eState == e_DLC_ContentState_Retrieved) {
|
||||
return 0;
|
||||
} else {
|
||||
if (bPromote) {
|
||||
m_DLCDownloadQueue.erase(m_DLCDownloadQueue.begin() +
|
||||
iPosition);
|
||||
m_DLCDownloadQueue.insert(m_DLCDownloadQueue.begin(),
|
||||
pCurrent);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
iPosition++;
|
||||
}
|
||||
|
||||
DLCRequest* pDLCreq = new DLCRequest;
|
||||
pDLCreq->dwType = m_dwContentTypeA[eType];
|
||||
pDLCreq->eState = e_DLC_ContentState_Idle;
|
||||
m_DLCDownloadQueue.push_back(pDLCreq);
|
||||
m_bAllDLCContentRetrieved = false;
|
||||
}
|
||||
|
||||
app.DebugPrintf("[Consoles_App] Added DLC request.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool DLCController::retrieveNextDLCContent() {
|
||||
int primPad = ProfileManager.GetPrimaryPad();
|
||||
if (primPad == -1 || !ProfileManager.IsSignedInLive(primPad)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->eState == e_DLC_ContentState_Retrieving) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->eState == e_DLC_ContentState_Idle) {
|
||||
#if defined(_DEBUG)
|
||||
app.DebugPrintf("RetrieveNextDLCContent - type = %d\n",
|
||||
pCurrent->dwType);
|
||||
#endif
|
||||
C4JStorage::EDLCStatus status = StorageManager.GetDLCOffers(
|
||||
ProfileManager.GetPrimaryPad(),
|
||||
[this](int iOfferC, std::uint32_t dwType, int pad) {
|
||||
return dlcOffersReturned(iOfferC, dwType, pad);
|
||||
},
|
||||
pCurrent->dwType);
|
||||
if (status == C4JStorage::EDLC_Pending) {
|
||||
pCurrent->eState = e_DLC_ContentState_Retrieving;
|
||||
} else {
|
||||
app.DebugPrintf("RetrieveNextDLCContent - PROBLEM\n");
|
||||
pCurrent->eState = e_DLC_ContentState_Retrieved;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.DebugPrintf("[Consoles_App] Finished downloading dlc content.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DLCController::checkTMSDLCCanStop() {
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
if (pCurrent->eState == e_TMS_ContentState_Retrieving) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int DLCController::dlcOffersReturned(int iOfferC, std::uint32_t dwType,
|
||||
int iPad) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->dwType == static_cast<std::uint32_t>(dwType)) {
|
||||
m_iDLCOfferC = iOfferC;
|
||||
app.DebugPrintf(
|
||||
"DLCOffersReturned - type %u, count %d - setting to "
|
||||
"retrieved\n",
|
||||
dwType, iOfferC);
|
||||
pCurrent->eState = e_DLC_ContentState_Retrieved;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
eDLCContentType DLCController::find_eDLCContentType(std::uint32_t dwType) {
|
||||
for (int i = 0; i < e_DLC_MAX; i++) {
|
||||
if (m_dwContentTypeA[i] == dwType) {
|
||||
return (eDLCContentType)i;
|
||||
}
|
||||
}
|
||||
return (eDLCContentType)0;
|
||||
}
|
||||
|
||||
bool DLCController::dlcContentRetrieved(eDLCMarketplaceType eType) {
|
||||
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin(); it != m_DLCDownloadQueue.end();
|
||||
++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if ((pCurrent->dwType == m_dwContentTypeA[eType]) &&
|
||||
(pCurrent->eState == e_DLC_ContentState_Retrieved)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DLCController::tickDLCOffersRetrieved() {
|
||||
if (!m_bAllDLCContentRetrieved) {
|
||||
if (!retrieveNextDLCContent()) {
|
||||
app.DebugPrintf("[Consoles_App] All content retrieved.\n");
|
||||
m_bAllDLCContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DLCController::clearAndResetDLCDownloadQueue() {
|
||||
app.DebugPrintf("[Consoles_App] Clear and reset download queue.\n");
|
||||
|
||||
int iPosition = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
delete pCurrent;
|
||||
iPosition++;
|
||||
}
|
||||
m_DLCDownloadQueue.clear();
|
||||
m_bAllDLCContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool DLCController::retrieveNextTMSPPContent() { return false; }
|
||||
|
||||
void DLCController::tickTMSPPFilesRetrieved() {
|
||||
if (m_bTickTMSDLCFiles && !m_bAllTMSContentRetrieved) {
|
||||
if (retrieveNextTMSPPContent() == false) {
|
||||
m_bAllTMSContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DLCController::clearTMSPPFilesRetrieved() {
|
||||
int iPosition = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
delete pCurrent;
|
||||
iPosition++;
|
||||
}
|
||||
m_TMSPPDownloadQueue.clear();
|
||||
m_bAllTMSContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int DLCController::addTMSPPFileTypeRequest(eDLCContentType eType,
|
||||
bool bPromote) {
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
|
||||
if (eType == e_DLC_TexturePackData) {
|
||||
int iCount = getDLCInfoFullOffersCount();
|
||||
|
||||
for (int i = 0; i < iCount; i++) {
|
||||
DLC_INFO* pDLC = getDLCInfoFullOffer(i);
|
||||
|
||||
if ((pDLC->eDLCType == e_DLC_TexturePacks) ||
|
||||
(pDLC->eDLCType == e_DLC_MashupPacks)) {
|
||||
if (pDLC->wchDataFile[0] != 0) {
|
||||
{
|
||||
bool bPresent = app.IsFileInTPD(pDLC->iConfig);
|
||||
|
||||
if (!bPresent) {
|
||||
bool bAlreadyInQueue = false;
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
if (wcscmp(pDLC->wchDataFile,
|
||||
pCurrent->wchFilename) == 0) {
|
||||
bAlreadyInQueue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bAlreadyInQueue) {
|
||||
TMSPPRequest* pTMSPPreq = new TMSPPRequest;
|
||||
pTMSPPreq->CallbackFunc =
|
||||
&DLCController::tmsPPFileReturned;
|
||||
pTMSPPreq->lpCallbackParam = this;
|
||||
pTMSPPreq->eStorageFacility =
|
||||
C4JStorage::eGlobalStorage_Title;
|
||||
pTMSPPreq->eFileTypeVal =
|
||||
C4JStorage::TMS_FILETYPE_BINARY;
|
||||
memcpy(pTMSPPreq->wchFilename,
|
||||
pDLC->wchDataFile,
|
||||
sizeof(wchar_t) * MAX_BANNERNAME_SIZE);
|
||||
pTMSPPreq->eType = e_DLC_TexturePackData;
|
||||
pTMSPPreq->eState = e_TMS_ContentState_Queued;
|
||||
m_bAllTMSContentRetrieved = false;
|
||||
m_TMSPPDownloadQueue.push_back(pTMSPPreq);
|
||||
}
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"Texture data already present in the TPD\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int iCount;
|
||||
iCount = getDLCInfoFullOffersCount();
|
||||
for (int i = 0; i < iCount; i++) {
|
||||
DLC_INFO* pDLC = getDLCInfoFullOffer(i);
|
||||
if (pDLC->eDLCType == eType) {
|
||||
wchar_t* cString = pDLC->wchBanner;
|
||||
{
|
||||
bool bPresent = app.IsFileInMemoryTextures(cString);
|
||||
|
||||
if (!bPresent) {
|
||||
bool bAlreadyInQueue = false;
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
if (wcscmp(pDLC->wchBanner,
|
||||
pCurrent->wchFilename) == 0) {
|
||||
bAlreadyInQueue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bAlreadyInQueue) {
|
||||
TMSPPRequest* pTMSPPreq = new TMSPPRequest;
|
||||
memset(pTMSPPreq, 0, sizeof(TMSPPRequest));
|
||||
pTMSPPreq->CallbackFunc =
|
||||
&DLCController::tmsPPFileReturned;
|
||||
pTMSPPreq->lpCallbackParam = this;
|
||||
pTMSPPreq->eStorageFacility =
|
||||
C4JStorage::eGlobalStorage_Title;
|
||||
pTMSPPreq->eFileTypeVal =
|
||||
C4JStorage::TMS_FILETYPE_BINARY;
|
||||
memcpy(pTMSPPreq->wchFilename, pDLC->wchBanner,
|
||||
sizeof(wchar_t) * MAX_BANNERNAME_SIZE);
|
||||
pTMSPPreq->eType = eType;
|
||||
pTMSPPreq->eState = e_TMS_ContentState_Queued;
|
||||
m_bAllTMSContentRetrieved = false;
|
||||
m_TMSPPDownloadQueue.push_back(pTMSPPreq);
|
||||
app.DebugPrintf(
|
||||
"===m_TMSPPDownloadQueue Adding %ls, q size is "
|
||||
"%d\n",
|
||||
pTMSPPreq->wchFilename,
|
||||
m_TMSPPDownloadQueue.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DLCController::tmsPPFileReturned(void* pParam, int iPad, int iUserData,
|
||||
C4JStorage::PTMSPP_FILEDATA pFileData,
|
||||
const char* szFilename) {
|
||||
DLCController* pClass = (DLCController*)pParam;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(pClass->csTMSPPDownloadQueue);
|
||||
for (auto it = pClass->m_TMSPPDownloadQueue.begin();
|
||||
it != pClass->m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
#if defined(_WINDOWS64)
|
||||
char szFile[MAX_TMSFILENAME_SIZE];
|
||||
wcstombs(szFile, pCurrent->wchFilename, MAX_TMSFILENAME_SIZE);
|
||||
|
||||
if (strcmp(szFilename, szFile) == 0)
|
||||
#endif
|
||||
{
|
||||
pCurrent->eState = e_TMS_ContentState_Retrieved;
|
||||
|
||||
if (pFileData != nullptr) {
|
||||
switch (pCurrent->eType) {
|
||||
case e_DLC_TexturePackData: {
|
||||
app.DebugPrintf("--- Got texturepack data %ls\n",
|
||||
pCurrent->wchFilename);
|
||||
int iConfig =
|
||||
app.GetTPConfigVal(pCurrent->wchFilename);
|
||||
app.AddMemoryTPDFile(iConfig, pFileData->pbData,
|
||||
pFileData->size);
|
||||
} break;
|
||||
default:
|
||||
app.DebugPrintf("--- Got image data - %ls\n",
|
||||
pCurrent->wchFilename);
|
||||
app.AddMemoryTextureFile(pCurrent->wchFilename,
|
||||
pFileData->pbData,
|
||||
pFileData->size);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
app.DebugPrintf("TMSImageReturned failed (%s)...\n",
|
||||
szFilename);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
137
targets/app/common/DLCController.h
Normal file
137
targets/app/common/DLCController.h
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
struct SCreditTextItemDef;
|
||||
|
||||
class DLCPack;
|
||||
|
||||
class DLCController {
|
||||
public:
|
||||
DLCController();
|
||||
|
||||
// Install process
|
||||
bool startInstallDLCProcess(int iPad);
|
||||
int dlcInstalledCallback(int iInstalledC, int iPad);
|
||||
void mountNextDLC(int iPad);
|
||||
int dlcMountedCallback(int iPad, std::uint32_t dwErr,
|
||||
std::uint32_t dwLicenceMask);
|
||||
void handleDLC(DLCPack* pack);
|
||||
|
||||
bool dlcInstallPending() { return m_bDLCInstallPending; }
|
||||
bool dlcInstallProcessCompleted() { return m_bDLCInstallProcessCompleted; }
|
||||
void clearDLCInstalled() { m_bDLCInstallProcessCompleted = false; }
|
||||
|
||||
static int marketplaceCountsCallback(void* pParam,
|
||||
C4JStorage::DLC_TMS_DETAILS*,
|
||||
int iPad);
|
||||
|
||||
// DLC info registration
|
||||
static int32_t registerDLCData(wchar_t*, wchar_t*, int, uint64_t, uint64_t,
|
||||
wchar_t*, unsigned int, int,
|
||||
wchar_t* pDataFile);
|
||||
bool getDLCFullOfferIDForSkinID(const std::wstring& FirstSkin,
|
||||
uint64_t* pullVal);
|
||||
bool getDLCFullOfferIDForPackID(const int iPackID, uint64_t* pullVal);
|
||||
DLC_INFO* getDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial);
|
||||
DLC_INFO* getDLCInfoForFullOfferID(uint64_t ullOfferID_Full);
|
||||
DLC_INFO* getDLCInfoTrialOffer(int iIndex);
|
||||
DLC_INFO* getDLCInfoFullOffer(int iIndex);
|
||||
uint64_t getDLCInfoTexturesFullOffer(int iIndex);
|
||||
int getDLCInfoTrialOffersCount();
|
||||
int getDLCInfoFullOffersCount();
|
||||
int getDLCInfoTexturesOffersCount();
|
||||
|
||||
// DLC content/offers
|
||||
unsigned int addDLCRequest(eDLCMarketplaceType eContentType,
|
||||
bool bPromote = false);
|
||||
bool retrieveNextDLCContent();
|
||||
bool checkTMSDLCCanStop();
|
||||
int dlcOffersReturned(int iOfferC, std::uint32_t dwType, int iPad);
|
||||
std::uint32_t getDLCContentType(eDLCContentType eType) {
|
||||
return m_dwContentTypeA[eType];
|
||||
}
|
||||
eDLCContentType find_eDLCContentType(std::uint32_t dwType);
|
||||
int getDLCOffersCount() { return m_iDLCOfferC; }
|
||||
bool dlcContentRetrieved(eDLCMarketplaceType eType);
|
||||
void tickDLCOffersRetrieved();
|
||||
void clearAndResetDLCDownloadQueue();
|
||||
|
||||
// TMS/TMSPP
|
||||
bool retrieveNextTMSPPContent();
|
||||
void tickTMSPPFilesRetrieved();
|
||||
void clearTMSPPFilesRetrieved();
|
||||
unsigned int addTMSPPFileTypeRequest(eDLCContentType eType,
|
||||
bool bPromote = false);
|
||||
static int tmsPPFileReturned(void* pParam, int iPad, int iUserData,
|
||||
C4JStorage::PTMSPP_FILEDATA pFileData,
|
||||
const char* szFilename);
|
||||
|
||||
// Credit text
|
||||
void addCreditText(const wchar_t* lpStr);
|
||||
bool alreadySeenCreditText(const std::wstring& wstemp);
|
||||
unsigned int getDLCCreditsCount();
|
||||
SCreditTextItemDef* getDLCCredits(int iIndex);
|
||||
|
||||
// New DLC available
|
||||
void clearNewDLCAvailable() {
|
||||
m_bNewDLCAvailable = false;
|
||||
m_bSeenNewDLCTip = true;
|
||||
}
|
||||
bool getNewDLCAvailable() { return m_bNewDLCAvailable; }
|
||||
void displayNewDLCTipAgain() { m_bSeenNewDLCTip = false; }
|
||||
bool displayNewDLCTip() {
|
||||
if (!m_bSeenNewDLCTip) {
|
||||
m_bSeenNewDLCTip = true;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
void setTickTMSDLCFiles(bool bVal) { m_bTickTMSDLCFiles = bVal; }
|
||||
|
||||
// Public data needed by other parts
|
||||
std::vector<std::wstring> m_vCreditText;
|
||||
std::uint8_t* m_pDLCFileBuffer;
|
||||
unsigned int m_dwDLCFileSize;
|
||||
|
||||
// DLC install counters (accessed by dlcMountedCallback)
|
||||
int m_iTotalDLC;
|
||||
int m_iTotalDLCInstalled;
|
||||
|
||||
// Static maps
|
||||
static std::unordered_map<PlayerUID, MOJANG_DATA*> MojangData;
|
||||
static std::unordered_map<int, uint64_t> DLCTextures_PackID;
|
||||
static std::unordered_map<uint64_t, DLC_INFO*> DLCInfo_Trial;
|
||||
static std::unordered_map<uint64_t, DLC_INFO*> DLCInfo_Full;
|
||||
static std::unordered_map<std::wstring, uint64_t> DLCInfo_SkinName;
|
||||
static std::uint32_t m_dwContentTypeA[e_Marketplace_MAX];
|
||||
|
||||
private:
|
||||
std::vector<SCreditTextItemDef*> vDLCCredits;
|
||||
std::vector<DLCRequest*> m_DLCDownloadQueue;
|
||||
std::vector<TMSPPRequest*> m_TMSPPDownloadQueue;
|
||||
|
||||
int m_iDLCOfferC;
|
||||
bool m_bAllDLCContentRetrieved;
|
||||
bool m_bAllTMSContentRetrieved;
|
||||
bool m_bTickTMSDLCFiles;
|
||||
std::mutex csDLCDownloadQueue;
|
||||
std::mutex csTMSPPDownloadQueue;
|
||||
|
||||
bool m_bDLCInstallProcessCompleted;
|
||||
bool m_bDLCInstallPending;
|
||||
bool m_bDefaultCapeInstallAttempted;
|
||||
|
||||
bool m_bNewDLCAvailable;
|
||||
bool m_bSeenNewDLCTip;
|
||||
};
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -12,9 +12,13 @@
|
|||
#include "app/common/ArchiveManager.h"
|
||||
#include "app/common/BannedListManager.h"
|
||||
#include "app/common/DebugOptions.h"
|
||||
#include "app/common/DLCController.h"
|
||||
#include "app/common/GameSettingsManager.h"
|
||||
#include "app/common/IPlatformGame.h"
|
||||
#include "app/common/App_structs.h"
|
||||
#include "app/common/LocalizationManager.h"
|
||||
#include "app/common/MenuController.h"
|
||||
#include "app/common/NetworkController.h"
|
||||
#include "app/common/SaveManager.h"
|
||||
#include "app/common/SkinManager.h"
|
||||
#include "app/common/TerrainFeatureManager.h"
|
||||
|
|
@ -32,11 +36,7 @@
|
|||
#include "minecraft/network/packet/DisconnectPacket.h"
|
||||
#include "minecraft/world/entity/item/MinecartHopper.h"
|
||||
|
||||
typedef struct _JoinFromInviteData {
|
||||
std::uint32_t dwUserIndex; // dwUserIndex
|
||||
std::uint32_t dwLocalUsersMask; // dwUserMask
|
||||
const INVITE_INFO* pInviteInfo; // pInviteInfo
|
||||
} JoinFromInviteData;
|
||||
// JoinFromInviteData moved to NetworkController.h
|
||||
|
||||
class Player;
|
||||
class Inventory;
|
||||
|
|
@ -82,10 +82,13 @@ public:
|
|||
LocalizationManager m_localizationManager;
|
||||
ArchiveManager m_archiveManager;
|
||||
SkinManager m_skinManager;
|
||||
GameSettingsManager m_gameSettingsManager;
|
||||
DLCController m_dlcController;
|
||||
NetworkController m_networkController;
|
||||
MenuController m_menuController;
|
||||
|
||||
// storing credits text from the DLC
|
||||
std::vector<std::wstring> m_vCreditText; // hold the credit text lines so
|
||||
// we can avoid duplicating them
|
||||
// storing credits text from the DLC - delegated to DLCController
|
||||
std::vector<std::wstring>& m_vCreditText = m_dlcController.m_vCreditText;
|
||||
|
||||
// In builds prior to TU5, the size of the GAME_SETTINGS struct was 204
|
||||
// bytes. We added a few new values to the internal struct in TU5, and even
|
||||
|
|
@ -128,7 +131,7 @@ public:
|
|||
static const int USER_UI =
|
||||
7; // 4J Stu - This also makes it appear on the UI console
|
||||
|
||||
void HandleButtonPresses();
|
||||
void HandleButtonPresses() { m_gameSettingsManager.handleButtonPresses(); }
|
||||
bool IntroRunning() { return m_bIntroRunning; }
|
||||
void SetIntroRunning(bool bSet) { m_bIntroRunning = bSet; }
|
||||
#if defined(_CONTENT_PACKAGE)
|
||||
|
|
@ -142,7 +145,9 @@ public:
|
|||
|
||||
bool IsAppPaused();
|
||||
void SetAppPaused(bool val);
|
||||
int displaySavingMessage(const C4JStorage::ESavingMessage eMsg, int iPad);
|
||||
int displaySavingMessage(const C4JStorage::ESavingMessage eMsg, int iPad) {
|
||||
return m_gameSettingsManager.displaySavingMessage(eMsg, iPad);
|
||||
}
|
||||
bool GetGameStarted() { return m_bGameStarted; }
|
||||
void SetGameStarted(bool bVal) {
|
||||
if (bVal)
|
||||
|
|
@ -154,51 +159,87 @@ public:
|
|||
}
|
||||
int GetLocalPlayerCount(void);
|
||||
bool LoadInventoryMenu(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
bool bNavigateBack = false);
|
||||
bool bNavigateBack = false) {
|
||||
return m_menuController.loadInventoryMenu(iPad, player, bNavigateBack);
|
||||
}
|
||||
bool LoadCreativeMenu(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
bool bNavigateBack = false);
|
||||
bool bNavigateBack = false) {
|
||||
return m_menuController.loadCreativeMenu(iPad, player, bNavigateBack);
|
||||
}
|
||||
bool LoadEnchantingMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
int x, int y, int z, Level* level,
|
||||
const std::wstring& name);
|
||||
const std::wstring& name) {
|
||||
return m_menuController.loadEnchantingMenu(iPad, inventory, x, y, z, level, name);
|
||||
}
|
||||
bool LoadFurnaceMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<FurnaceTileEntity> furnace);
|
||||
std::shared_ptr<FurnaceTileEntity> furnace) {
|
||||
return m_menuController.loadFurnaceMenu(iPad, inventory, furnace);
|
||||
}
|
||||
bool LoadBrewingStandMenu(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand);
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand) {
|
||||
return m_menuController.loadBrewingStandMenu(iPad, inventory, brewingStand);
|
||||
}
|
||||
bool LoadContainerMenu(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<Container> container);
|
||||
std::shared_ptr<Container> container) {
|
||||
return m_menuController.loadContainerMenu(iPad, inventory, container);
|
||||
}
|
||||
bool LoadTrapMenu(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<DispenserTileEntity> trap);
|
||||
bool LoadCrafting2x2Menu(int iPad, std::shared_ptr<LocalPlayer> player);
|
||||
std::shared_ptr<DispenserTileEntity> trap) {
|
||||
return m_menuController.loadTrapMenu(iPad, inventory, trap);
|
||||
}
|
||||
bool LoadCrafting2x2Menu(int iPad, std::shared_ptr<LocalPlayer> player) {
|
||||
return m_menuController.loadCrafting2x2Menu(iPad, player);
|
||||
}
|
||||
bool LoadCrafting3x3Menu(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
int x, int y, int z);
|
||||
int x, int y, int z) {
|
||||
return m_menuController.loadCrafting3x3Menu(iPad, player, x, y, z);
|
||||
}
|
||||
bool LoadFireworksMenu(int iPad, std::shared_ptr<LocalPlayer> player, int x,
|
||||
int y, int z);
|
||||
bool LoadSignEntryMenu(int iPad, std::shared_ptr<SignTileEntity> sign);
|
||||
int y, int z) {
|
||||
return m_menuController.loadFireworksMenu(iPad, player, x, y, z);
|
||||
}
|
||||
bool LoadSignEntryMenu(int iPad, std::shared_ptr<SignTileEntity> sign) {
|
||||
return m_menuController.loadSignEntryMenu(iPad, sign);
|
||||
}
|
||||
bool LoadRepairingMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
Level* level, int x, int y, int z);
|
||||
Level* level, int x, int y, int z) {
|
||||
return m_menuController.loadRepairingMenu(iPad, inventory, level, x, y, z);
|
||||
}
|
||||
bool LoadTradingMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Merchant> trader, Level* level,
|
||||
const std::wstring& name);
|
||||
const std::wstring& name) {
|
||||
return m_menuController.loadTradingMenu(iPad, inventory, trader, level, name);
|
||||
}
|
||||
|
||||
bool LoadCommandBlockMenu(
|
||||
int iPad, std::shared_ptr<CommandBlockEntity> commandBlock) {
|
||||
return false;
|
||||
}
|
||||
bool LoadHopperMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<HopperTileEntity> hopper);
|
||||
std::shared_ptr<HopperTileEntity> hopper) {
|
||||
return m_menuController.loadHopperMenu(iPad, inventory, hopper);
|
||||
}
|
||||
bool LoadHopperMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<MinecartHopper> hopper);
|
||||
std::shared_ptr<MinecartHopper> hopper) {
|
||||
return m_menuController.loadHopperMenu(iPad, inventory, hopper);
|
||||
}
|
||||
bool LoadHorseMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> container,
|
||||
std::shared_ptr<EntityHorse> horse);
|
||||
std::shared_ptr<EntityHorse> horse) {
|
||||
return m_menuController.loadHorseMenu(iPad, inventory, container, horse);
|
||||
}
|
||||
bool LoadBeaconMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BeaconTileEntity> beacon);
|
||||
std::shared_ptr<BeaconTileEntity> beacon) {
|
||||
return m_menuController.loadBeaconMenu(iPad, inventory, beacon);
|
||||
}
|
||||
|
||||
bool GetTutorialMode() { return m_bTutorialMode; }
|
||||
void SetTutorialMode(bool bSet) { m_bTutorialMode = bSet; }
|
||||
|
||||
void SetSpecialTutorialCompletionFlag(int iPad, int index);
|
||||
void SetSpecialTutorialCompletionFlag(int iPad, int index) {
|
||||
m_gameSettingsManager.setSpecialTutorialCompletionFlag(iPad, index);
|
||||
}
|
||||
|
||||
static const wchar_t* GetString(int iID);
|
||||
StringTable* getStringTable() const { return m_localizationManager.getStringTable(); }
|
||||
|
|
@ -206,50 +247,53 @@ public:
|
|||
eGameMode GetGameMode() { return m_eGameMode; }
|
||||
void SetGameMode(eGameMode eMode) { m_eGameMode = eMode; }
|
||||
|
||||
eXuiAction GetGlobalXuiAction() { return m_eGlobalXuiAction; }
|
||||
void SetGlobalXuiAction(eXuiAction action) { m_eGlobalXuiAction = action; }
|
||||
eXuiAction GetXuiAction(int iPad) { return m_eXuiAction[iPad]; }
|
||||
void SetAction(int iPad, eXuiAction action, void* param = nullptr);
|
||||
void SetTMSAction(int iPad, eTMSAction action) {
|
||||
m_eTMSAction[iPad] = action;
|
||||
eXuiAction GetGlobalXuiAction() { return m_menuController.getGlobalXuiAction(); }
|
||||
void SetGlobalXuiAction(eXuiAction action) { m_menuController.setGlobalXuiAction(action); }
|
||||
eXuiAction GetXuiAction(int iPad) { return m_menuController.getXuiAction(iPad); }
|
||||
void SetAction(int iPad, eXuiAction action, void* param = nullptr) {
|
||||
m_menuController.setAction(iPad, action, param);
|
||||
}
|
||||
eTMSAction GetTMSAction(int iPad) { return m_eTMSAction[iPad]; }
|
||||
void SetTMSAction(int iPad, eTMSAction action) {
|
||||
m_menuController.setTMSAction(iPad, action);
|
||||
}
|
||||
eTMSAction GetTMSAction(int iPad) { return m_menuController.getTMSAction(iPad); }
|
||||
eXuiServerAction GetXuiServerAction(int iPad) {
|
||||
return m_eXuiServerAction[iPad];
|
||||
return m_menuController.getXuiServerAction(iPad);
|
||||
}
|
||||
void* GetXuiServerActionParam(int iPad) {
|
||||
return m_eXuiServerActionParam[iPad];
|
||||
return m_menuController.getXuiServerActionParam(iPad);
|
||||
}
|
||||
void SetXuiServerAction(int iPad, eXuiServerAction action,
|
||||
void* param = nullptr) {
|
||||
m_eXuiServerAction[iPad] = action;
|
||||
m_eXuiServerActionParam[iPad] = param;
|
||||
m_menuController.setXuiServerAction(iPad, action, param);
|
||||
}
|
||||
eXuiServerAction GetGlobalXuiServerAction() {
|
||||
return m_eGlobalXuiServerAction;
|
||||
return m_menuController.getGlobalXuiServerAction();
|
||||
}
|
||||
void SetGlobalXuiServerAction(eXuiServerAction action) {
|
||||
m_eGlobalXuiServerAction = action;
|
||||
m_menuController.setGlobalXuiServerAction(action);
|
||||
}
|
||||
|
||||
DisconnectPacket::eDisconnectReason GetDisconnectReason() {
|
||||
return m_disconnectReason;
|
||||
return m_networkController.getDisconnectReason();
|
||||
}
|
||||
void SetDisconnectReason(DisconnectPacket::eDisconnectReason bVal) {
|
||||
m_disconnectReason = bVal;
|
||||
m_networkController.setDisconnectReason(bVal);
|
||||
}
|
||||
|
||||
bool GetChangingSessionType() { return m_bChangingSessionType; }
|
||||
void SetChangingSessionType(bool bVal) { m_bChangingSessionType = bVal; }
|
||||
bool GetChangingSessionType() { return m_networkController.getChangingSessionType(); }
|
||||
void SetChangingSessionType(bool bVal) { m_networkController.setChangingSessionType(bVal); }
|
||||
|
||||
bool GetReallyChangingSessionType() { return m_bReallyChangingSessionType; }
|
||||
bool GetReallyChangingSessionType() { return m_networkController.getReallyChangingSessionType(); }
|
||||
void SetReallyChangingSessionType(bool bVal) {
|
||||
m_bReallyChangingSessionType = bVal;
|
||||
m_networkController.setReallyChangingSessionType(bVal);
|
||||
}
|
||||
|
||||
// 4J Stu - Added so that we can call this when a confirmation box is
|
||||
// selected
|
||||
static void SetActionConfirmed(void* param);
|
||||
static void SetActionConfirmed(void* param) {
|
||||
GameSettingsManager::setActionConfirmed(param);
|
||||
}
|
||||
void HandleXuiActions(void);
|
||||
|
||||
// 4J Stu - Functions used for Minecon and other promo work
|
||||
|
|
@ -292,21 +336,33 @@ public:
|
|||
// void GetPreviewImage(int iPad,XSOCIAL_PREVIEWIMAGE
|
||||
// *preview);
|
||||
|
||||
void InitGameSettings();
|
||||
void InitGameSettings() { m_gameSettingsManager.initGameSettings(); }
|
||||
static int OldProfileVersionCallback(void* pParam, unsigned char* pucData,
|
||||
const unsigned short usVersion,
|
||||
const int iPad);
|
||||
const int iPad) {
|
||||
return GameSettingsManager::oldProfileVersionCallback(pParam, pucData, usVersion, iPad);
|
||||
}
|
||||
|
||||
static int DefaultOptionsCallback(void* pParam,
|
||||
C_4JProfile::PROFILESETTINGS* pSettings,
|
||||
const int iPad);
|
||||
const int iPad) {
|
||||
return GameSettingsManager::defaultOptionsCallback(pParam, pSettings, iPad);
|
||||
}
|
||||
int SetDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings,
|
||||
const int iPad);
|
||||
const int iPad) {
|
||||
return m_gameSettingsManager.setDefaultOptions(pSettings, iPad);
|
||||
}
|
||||
void SetRichPresenceContext(int iPad, int contextId) override = 0;
|
||||
|
||||
void SetGameSettings(int iPad, eGameSetting eVal, unsigned char ucVal);
|
||||
unsigned char GetGameSettings(int iPad, eGameSetting eVal);
|
||||
unsigned char GetGameSettings(eGameSetting eVal); // for the primary pad
|
||||
void SetGameSettings(int iPad, eGameSetting eVal, unsigned char ucVal) {
|
||||
m_gameSettingsManager.setGameSettings(iPad, eVal, ucVal);
|
||||
}
|
||||
unsigned char GetGameSettings(int iPad, eGameSetting eVal) {
|
||||
return m_gameSettingsManager.getGameSettings(iPad, eVal);
|
||||
}
|
||||
unsigned char GetGameSettings(eGameSetting eVal) {
|
||||
return m_gameSettingsManager.getGameSettings(eVal);
|
||||
}
|
||||
void SetPlayerSkin(int iPad, const std::wstring& name) {
|
||||
m_skinManager.setPlayerSkin(iPad, name, GameSettingsA);
|
||||
}
|
||||
|
|
@ -338,28 +394,41 @@ public:
|
|||
m_skinManager.validateFavoriteSkins(iPad, GameSettingsA, m_dlcManager);
|
||||
}
|
||||
|
||||
// Mash-up pack worlds hide/display
|
||||
void HideMashupPackWorld(int iPad, unsigned int iMashupPackID);
|
||||
void EnableMashupPackWorlds(int iPad);
|
||||
unsigned int GetMashupPackWorlds(int iPad);
|
||||
// Mash-up pack worlds hide/display - delegated to GameSettingsManager
|
||||
void HideMashupPackWorld(int iPad, unsigned int iMashupPackID) {
|
||||
m_gameSettingsManager.hideMashupPackWorld(iPad, iMashupPackID);
|
||||
}
|
||||
void EnableMashupPackWorlds(int iPad) {
|
||||
m_gameSettingsManager.enableMashupPackWorlds(iPad);
|
||||
}
|
||||
unsigned int GetMashupPackWorlds(int iPad) {
|
||||
return m_gameSettingsManager.getMashupPackWorlds(iPad);
|
||||
}
|
||||
|
||||
// Minecraft language select - implementations remain in Game.cpp
|
||||
// (they access GameSettingsA directly)
|
||||
void SetMinecraftLanguage(int iPad, unsigned char ucLanguage);
|
||||
unsigned char GetMinecraftLanguage(int iPad);
|
||||
void SetMinecraftLocale(int iPad, unsigned char ucLanguage);
|
||||
unsigned char GetMinecraftLocale(int iPad);
|
||||
// Minecraft language select - delegated to GameSettingsManager
|
||||
void SetMinecraftLanguage(int iPad, unsigned char ucLanguage) {
|
||||
m_gameSettingsManager.setMinecraftLanguage(iPad, ucLanguage);
|
||||
}
|
||||
unsigned char GetMinecraftLanguage(int iPad) {
|
||||
return m_gameSettingsManager.getMinecraftLanguage(iPad);
|
||||
}
|
||||
void SetMinecraftLocale(int iPad, unsigned char ucLanguage) {
|
||||
m_gameSettingsManager.setMinecraftLocale(iPad, ucLanguage);
|
||||
}
|
||||
unsigned char GetMinecraftLocale(int iPad) {
|
||||
return m_gameSettingsManager.getMinecraftLocale(iPad);
|
||||
}
|
||||
|
||||
// 4J-PB - set a timer when the user navigates the quickselect, so we can
|
||||
// bring the opacity back to defaults for a short time
|
||||
unsigned int GetOpacityTimer(int iPad) {
|
||||
return m_uiOpacityCountDown[iPad];
|
||||
return m_menuController.getOpacityTimer(iPad);
|
||||
}
|
||||
void SetOpacityTimer(int iPad) {
|
||||
m_uiOpacityCountDown[iPad] = 120;
|
||||
m_menuController.setOpacityTimer(iPad);
|
||||
} // 6 seconds
|
||||
void TickOpacityTimer(int iPad) {
|
||||
if (m_uiOpacityCountDown[iPad] > 0) m_uiOpacityCountDown[iPad]--;
|
||||
m_menuController.tickOpacityTimer(iPad);
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
@ -379,28 +448,54 @@ public:
|
|||
return m_skinManager.getAdditionalModelParts(iPad);
|
||||
}
|
||||
void CheckGameSettingsChanged(bool bOverride5MinuteTimer = false,
|
||||
int iPad = XUSER_INDEX_ANY);
|
||||
void ApplyGameSettingsChanged(int iPad);
|
||||
void ClearGameSettingsChangedFlag(int iPad);
|
||||
void ActionGameSettings(int iPad, eGameSetting eVal);
|
||||
int iPad = XUSER_INDEX_ANY) {
|
||||
m_gameSettingsManager.checkGameSettingsChanged(bOverride5MinuteTimer, iPad);
|
||||
}
|
||||
void ApplyGameSettingsChanged(int iPad) {
|
||||
m_gameSettingsManager.applyGameSettingsChanged(iPad);
|
||||
}
|
||||
void ClearGameSettingsChangedFlag(int iPad) {
|
||||
m_gameSettingsManager.clearGameSettingsChangedFlag(iPad);
|
||||
}
|
||||
void ActionGameSettings(int iPad, eGameSetting eVal) {
|
||||
m_gameSettingsManager.actionGameSettings(iPad, eVal);
|
||||
}
|
||||
unsigned int GetGameSettingsDebugMask(int iPad = -1,
|
||||
bool bOverridePlayer = false);
|
||||
void SetGameSettingsDebugMask(int iPad, unsigned int uiVal);
|
||||
void ActionDebugMask(int iPad, bool bSetAllClear = false);
|
||||
bool bOverridePlayer = false) {
|
||||
return m_gameSettingsManager.getGameSettingsDebugMask(iPad, bOverridePlayer);
|
||||
}
|
||||
void SetGameSettingsDebugMask(int iPad, unsigned int uiVal) {
|
||||
m_gameSettingsManager.setGameSettingsDebugMask(iPad, uiVal);
|
||||
}
|
||||
void ActionDebugMask(int iPad, bool bSetAllClear = false) {
|
||||
m_gameSettingsManager.actionDebugMask(iPad, bSetAllClear);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsLocalMultiplayerAvailable();
|
||||
|
||||
// for sign in change monitoring
|
||||
// for sign in change monitoring - delegated to NetworkController
|
||||
static void SignInChangeCallback(void* pParam, bool bVal,
|
||||
unsigned int uiSignInData);
|
||||
static void ClearSignInChangeUsersMask();
|
||||
static int SignoutExitWorldThreadProc(void* lpParameter);
|
||||
unsigned int uiSignInData) {
|
||||
NetworkController::signInChangeCallback(pParam, bVal, uiSignInData);
|
||||
}
|
||||
static void ClearSignInChangeUsersMask() {
|
||||
NetworkController::clearSignInChangeUsersMask();
|
||||
}
|
||||
static int SignoutExitWorldThreadProc(void* lpParameter) {
|
||||
return NetworkController::signoutExitWorldThreadProc(lpParameter);
|
||||
}
|
||||
static int PrimaryPlayerSignedOutReturned(void* pParam, int iPad,
|
||||
const C4JStorage::EMessageResult);
|
||||
const C4JStorage::EMessageResult result) {
|
||||
return NetworkController::primaryPlayerSignedOutReturned(pParam, iPad, result);
|
||||
}
|
||||
static int EthernetDisconnectReturned(void* pParam, int iPad,
|
||||
const C4JStorage::EMessageResult);
|
||||
static void ProfileReadErrorCallback(void* pParam);
|
||||
const C4JStorage::EMessageResult result) {
|
||||
return NetworkController::ethernetDisconnectReturned(pParam, iPad, result);
|
||||
}
|
||||
static void ProfileReadErrorCallback(void* pParam) {
|
||||
NetworkController::profileReadErrorCallback(pParam);
|
||||
}
|
||||
|
||||
// FATAL LOAD ERRORS
|
||||
virtual void FatalLoadError();
|
||||
|
|
@ -408,12 +503,16 @@ public:
|
|||
// Notifications from the game listener to be passed to the qnet listener
|
||||
static void NotificationsCallback(void* pParam,
|
||||
std::uint32_t dwNotification,
|
||||
unsigned int uiParam);
|
||||
unsigned int uiParam) {
|
||||
NetworkController::notificationsCallback(pParam, dwNotification, uiParam);
|
||||
}
|
||||
|
||||
// for the ethernet being disconnected
|
||||
static void LiveLinkChangeCallback(void* pParam, bool bConnected);
|
||||
bool GetLiveLinkRequired() { return m_bLiveLinkRequired; }
|
||||
void SetLiveLinkRequired(bool required) { m_bLiveLinkRequired = required; }
|
||||
static void LiveLinkChangeCallback(void* pParam, bool bConnected) {
|
||||
NetworkController::liveLinkChangeCallback(pParam, bConnected);
|
||||
}
|
||||
bool GetLiveLinkRequired() { return m_networkController.getLiveLinkRequired(); }
|
||||
void SetLiveLinkRequired(bool required) { m_networkController.setLiveLinkRequired(required); }
|
||||
|
||||
#if defined(_DEBUG_MENUS_ENABLED)
|
||||
bool DebugSettingsOn() { return m_debugOptions.settingsOn(); }
|
||||
|
|
@ -426,39 +525,34 @@ public:
|
|||
// bool UploadFileToGlobalStorage(int iQuadrant,
|
||||
// C4JStorage::eGlobalStorage eStorageFacility, std::wstring *wsFile );
|
||||
|
||||
// Installed DLC
|
||||
bool StartInstallDLCProcess(int iPad);
|
||||
int dlcInstalledCallback(int iOfferC, int iPad);
|
||||
// Installed DLC - delegated to DLCController
|
||||
bool StartInstallDLCProcess(int iPad) { return m_dlcController.startInstallDLCProcess(iPad); }
|
||||
int dlcInstalledCallback(int iOfferC, int iPad) { return m_dlcController.dlcInstalledCallback(iOfferC, iPad); }
|
||||
void HandleDLCLicenseChange();
|
||||
int dlcMountedCallback(int iPad, std::uint32_t dwErr,
|
||||
std::uint32_t dwLicenceMask);
|
||||
void MountNextDLC(int iPad);
|
||||
// static int DLCReadCallback(void* pParam,C4JStorage::DLC_FILE_DETAILS
|
||||
// *pDLCData);
|
||||
void HandleDLC(DLCPack* pack);
|
||||
bool DLCInstallPending() { return m_bDLCInstallPending; }
|
||||
bool DLCInstallProcessCompleted() { return m_bDLCInstallProcessCompleted; }
|
||||
void ClearDLCInstalled() { m_bDLCInstallProcessCompleted = false; }
|
||||
std::uint32_t dwLicenceMask) {
|
||||
return m_dlcController.dlcMountedCallback(iPad, dwErr, dwLicenceMask);
|
||||
}
|
||||
void MountNextDLC(int iPad) { m_dlcController.mountNextDLC(iPad); }
|
||||
void HandleDLC(DLCPack* pack) { m_dlcController.handleDLC(pack); }
|
||||
bool DLCInstallPending() { return m_dlcController.dlcInstallPending(); }
|
||||
bool DLCInstallProcessCompleted() { return m_dlcController.dlcInstallProcessCompleted(); }
|
||||
void ClearDLCInstalled() { m_dlcController.clearDLCInstalled(); }
|
||||
static int MarketplaceCountsCallback(void* pParam,
|
||||
C4JStorage::DLC_TMS_DETAILS*,
|
||||
int iPad);
|
||||
|
||||
bool AlreadySeenCreditText(const std::wstring& wstemp);
|
||||
|
||||
void ClearNewDLCAvailable(void) {
|
||||
m_bNewDLCAvailable = false;
|
||||
m_bSeenNewDLCTip = true;
|
||||
C4JStorage::DLC_TMS_DETAILS* details,
|
||||
int iPad) {
|
||||
return DLCController::marketplaceCountsCallback(pParam, details, iPad);
|
||||
}
|
||||
bool GetNewDLCAvailable() { return m_bNewDLCAvailable; }
|
||||
void DisplayNewDLCTipAgain() { m_bSeenNewDLCTip = false; }
|
||||
bool DisplayNewDLCTip() {
|
||||
if (!m_bSeenNewDLCTip) {
|
||||
m_bSeenNewDLCTip = true;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
|
||||
bool AlreadySeenCreditText(const std::wstring& wstemp) {
|
||||
return m_dlcController.alreadySeenCreditText(wstemp);
|
||||
}
|
||||
|
||||
void ClearNewDLCAvailable(void) { m_dlcController.clearNewDLCAvailable(); }
|
||||
bool GetNewDLCAvailable() { return m_dlcController.getNewDLCAvailable(); }
|
||||
void DisplayNewDLCTipAgain() { m_dlcController.displayNewDLCTipAgain(); }
|
||||
bool DisplayNewDLCTip() { return m_dlcController.displayNewDLCTip(); }
|
||||
|
||||
// functions to store launch data, and to exit the game - required due to
|
||||
// possibly being on a demo disc
|
||||
virtual void StoreLaunchData();
|
||||
|
|
@ -509,20 +603,19 @@ public:
|
|||
// void InstallDefaultCape(); // attempt to install the default cape once
|
||||
// per game launch
|
||||
|
||||
// invites
|
||||
// void ProcessInvite(JoinFromInviteData *pJoinData);
|
||||
// invites - delegated to NetworkController
|
||||
void ProcessInvite(std::uint32_t dwUserIndex,
|
||||
std::uint32_t dwLocalUsersMask,
|
||||
const INVITE_INFO* pInviteInfo);
|
||||
const INVITE_INFO* pInviteInfo) {
|
||||
m_networkController.processInvite(dwUserIndex, dwLocalUsersMask, pInviteInfo);
|
||||
}
|
||||
|
||||
// Add credits for DLC installed
|
||||
void AddCreditText(const wchar_t* lpStr);
|
||||
// Add credits for DLC installed - delegated to DLCController
|
||||
void AddCreditText(const wchar_t* lpStr) { m_dlcController.addCreditText(lpStr); }
|
||||
|
||||
private:
|
||||
std::unordered_map<PlayerUID, std::uint8_t*> m_GTS_Files;
|
||||
|
||||
VNOTIFICATIONS m_vNotifications;
|
||||
|
||||
public:
|
||||
// launch data
|
||||
std::uint8_t* m_pLaunchData;
|
||||
|
|
@ -561,8 +654,7 @@ public:
|
|||
bool m_bTutorialMode;
|
||||
bool m_bIsAppPaused;
|
||||
|
||||
bool m_bChangingSessionType;
|
||||
bool m_bReallyChangingSessionType;
|
||||
// m_bChangingSessionType and m_bReallyChangingSessionType moved to NetworkController
|
||||
|
||||
// trial, and trying to unlock full
|
||||
// version on an upsell
|
||||
|
|
@ -587,9 +679,9 @@ private:
|
|||
static int BannedLevelDialogReturned(void* pParam, int iPad,
|
||||
const C4JStorage::EMessageResult);
|
||||
static int TexturePackDialogReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
|
||||
void HandleButtonPresses(int iPad);
|
||||
C4JStorage::EMessageResult result) {
|
||||
return MenuController::texturePackDialogReturned(pParam, iPad, result);
|
||||
}
|
||||
|
||||
bool m_bResourcesLoaded;
|
||||
|
||||
|
|
@ -610,20 +702,13 @@ private:
|
|||
|
||||
eGameMode m_eGameMode; // single or multiplayer
|
||||
|
||||
static unsigned int m_uiLastSignInData;
|
||||
// GameSettingsA reference alias into GameSettingsManager
|
||||
GAME_SETTINGS* (&GameSettingsA)[XUSER_MAX_COUNT] = m_gameSettingsManager.GameSettingsA;
|
||||
|
||||
// We've got sizeof(GAME_SETTINGS) bytes reserved at the start of the
|
||||
// gamedefined data per player for settings
|
||||
GAME_SETTINGS* GameSettingsA[XUSER_MAX_COUNT];
|
||||
// m_uiLastSignInData moved to NetworkController
|
||||
|
||||
// Debug options now in m_debugOptions
|
||||
|
||||
// 4J : WESTY : For taking screen shots.
|
||||
// bool m_bInterfaceRenderingOff;
|
||||
// bool m_bHandRenderingOff;
|
||||
|
||||
DisconnectPacket::eDisconnectReason m_disconnectReason;
|
||||
|
||||
public:
|
||||
virtual void RunFrame() {};
|
||||
|
||||
|
|
@ -637,45 +722,53 @@ public:
|
|||
void SetTrialTimerStart(void);
|
||||
float getTrialTimer(void);
|
||||
|
||||
// notifications from the game for qnet
|
||||
VNOTIFICATIONS* GetNotifications() { return &m_vNotifications; }
|
||||
// notifications from the game for qnet - delegated to NetworkController
|
||||
NetworkController::VNOTIFICATIONS* GetNotifications() {
|
||||
return m_networkController.getNotifications();
|
||||
}
|
||||
|
||||
private:
|
||||
// To avoid problems with threads being kicked off from xuis that alter
|
||||
// things that may be in progress within the run_middle, we'll action these
|
||||
// at the end of the game loop
|
||||
eXuiAction m_eXuiAction[XUSER_MAX_COUNT];
|
||||
eTMSAction m_eTMSAction[XUSER_MAX_COUNT];
|
||||
void* m_eXuiActionParam[XUSER_MAX_COUNT];
|
||||
eXuiAction m_eGlobalXuiAction;
|
||||
eXuiServerAction m_eXuiServerAction[XUSER_MAX_COUNT];
|
||||
void* m_eXuiServerActionParam[XUSER_MAX_COUNT];
|
||||
eXuiServerAction m_eGlobalXuiServerAction;
|
||||
|
||||
bool m_bLiveLinkRequired;
|
||||
|
||||
static int UnlockFullExitReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
C4JStorage::EMessageResult result) {
|
||||
return MenuController::unlockFullExitReturned(pParam, iPad, result);
|
||||
}
|
||||
static int UnlockFullSaveReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
C4JStorage::EMessageResult result) {
|
||||
return MenuController::unlockFullSaveReturned(pParam, iPad, result);
|
||||
}
|
||||
static int UnlockFullInviteReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
C4JStorage::EMessageResult result) {
|
||||
return MenuController::unlockFullInviteReturned(pParam, iPad, result);
|
||||
}
|
||||
static int TrialOverReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
C4JStorage::EMessageResult result) {
|
||||
return MenuController::trialOverReturned(pParam, iPad, result);
|
||||
}
|
||||
static int ExitAndJoinFromInvite(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
C4JStorage::EMessageResult result) {
|
||||
return NetworkController::exitAndJoinFromInvite(pParam, iPad, result);
|
||||
}
|
||||
static int ExitAndJoinFromInviteSaveDialogReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
return NetworkController::exitAndJoinFromInviteSaveDialogReturned(pParam, iPad, result);
|
||||
}
|
||||
static int ExitAndJoinFromInviteAndSaveReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
return NetworkController::exitAndJoinFromInviteAndSaveReturned(pParam, iPad, result);
|
||||
}
|
||||
static int ExitAndJoinFromInviteDeclineSaveReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
return NetworkController::exitAndJoinFromInviteDeclineSaveReturned(pParam, iPad, result);
|
||||
}
|
||||
static int FatalErrorDialogReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
static int WarningTrialTexturePackReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
return NetworkController::warningTrialTexturePackReturned(pParam, iPad, result);
|
||||
}
|
||||
|
||||
JoinFromInviteData m_InviteData;
|
||||
JoinFromInviteData& m_InviteData = m_networkController.m_InviteData;
|
||||
// m_bDebugOptions moved to m_debugOptions
|
||||
|
||||
// Trial timer
|
||||
|
|
@ -717,10 +810,16 @@ public:
|
|||
float getAppTime() { return m_Time.fAppTime; }
|
||||
void UpdateTrialPausedTimer() { mfTrialPausedTime += m_Time.fElapsedTime; }
|
||||
|
||||
static int RemoteSaveThreadProc(void* lpParameter);
|
||||
static void ExitGameFromRemoteSave(void* lpParameter);
|
||||
static int RemoteSaveThreadProc(void* lpParameter) {
|
||||
return MenuController::remoteSaveThreadProc(lpParameter);
|
||||
}
|
||||
static void ExitGameFromRemoteSave(void* lpParameter) {
|
||||
MenuController::exitGameFromRemoteSave(lpParameter);
|
||||
}
|
||||
static int ExitGameFromRemoteSaveDialogReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
return MenuController::exitGameFromRemoteSaveDialogReturned(pParam, iPad, result);
|
||||
}
|
||||
|
||||
// XML
|
||||
public:
|
||||
|
|
@ -741,16 +840,24 @@ public:
|
|||
MOJANG_DATA* GetMojangDataForXuid(PlayerUID xuid);
|
||||
static int32_t RegisterConfigValues(wchar_t* pType, int iValue);
|
||||
|
||||
static int32_t RegisterDLCData(wchar_t*, wchar_t*, int, uint64_t, uint64_t,
|
||||
wchar_t*, unsigned int, int,
|
||||
wchar_t* pDataFile);
|
||||
static int32_t RegisterDLCData(wchar_t* a, wchar_t* b, int c, uint64_t d, uint64_t e,
|
||||
wchar_t* f, unsigned int g, int h,
|
||||
wchar_t* pDataFile) {
|
||||
return DLCController::registerDLCData(a, b, c, d, e, f, g, h, pDataFile);
|
||||
}
|
||||
bool GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin,
|
||||
uint64_t* pullVal);
|
||||
DLC_INFO* GetDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial);
|
||||
DLC_INFO* GetDLCInfoForFullOfferID(uint64_t ullOfferID_Full);
|
||||
uint64_t* pullVal) {
|
||||
return m_dlcController.getDLCFullOfferIDForSkinID(FirstSkin, pullVal);
|
||||
}
|
||||
DLC_INFO* GetDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial) {
|
||||
return m_dlcController.getDLCInfoForTrialOfferID(ullOfferID_Trial);
|
||||
}
|
||||
DLC_INFO* GetDLCInfoForFullOfferID(uint64_t ullOfferID_Full) {
|
||||
return m_dlcController.getDLCInfoForFullOfferID(ullOfferID_Full);
|
||||
}
|
||||
|
||||
unsigned int GetDLCCreditsCount();
|
||||
SCreditTextItemDef* GetDLCCredits(int iIndex);
|
||||
unsigned int GetDLCCreditsCount() { return m_dlcController.getDLCCreditsCount(); }
|
||||
SCreditTextItemDef* GetDLCCredits(int iIndex) { return m_dlcController.getDLCCredits(iIndex); }
|
||||
|
||||
// TMS
|
||||
void ReadDLCFileFromTMS(int iPad, eTMSAction action,
|
||||
|
|
@ -769,39 +876,10 @@ public:
|
|||
void ReadBannedList(int iPad, eTMSAction action = (eTMSAction)0,
|
||||
bool bCallback = false) override = 0;
|
||||
|
||||
private:
|
||||
std::vector<SCreditTextItemDef*> vDLCCredits;
|
||||
|
||||
static std::unordered_map<PlayerUID, MOJANG_DATA*> MojangData;
|
||||
static std::unordered_map<int, uint64_t>
|
||||
DLCTextures_PackID; // for mash-up packs & texture packs
|
||||
static std::unordered_map<uint64_t, DLC_INFO*>
|
||||
DLCInfo_Trial; // full offerid, dlc_info
|
||||
static std::unordered_map<uint64_t, DLC_INFO*>
|
||||
DLCInfo_Full; // full offerid, dlc_info
|
||||
static std::unordered_map<std::wstring, uint64_t>
|
||||
DLCInfo_SkinName; // skin name, full offer id
|
||||
// bool m_bRead_TMS_XUIDS_XML; // track whether we have already read the
|
||||
// TMS xuids.xml file bool m_bRead_TMS_DLCINFO_XML; // track whether
|
||||
// we have already read the TMS DLC.xml file
|
||||
|
||||
bool m_bDefaultCapeInstallAttempted; // have we attempted to install the
|
||||
// default cape from tms
|
||||
|
||||
// bool m_bwasHidingGui; // 4J Stu - Removed 1.8.2 bug fix (TU6) as not
|
||||
// needed
|
||||
bool m_bDLCInstallProcessCompleted;
|
||||
bool m_bDLCInstallPending;
|
||||
int m_iTotalDLC;
|
||||
int m_iTotalDLCInstalled;
|
||||
// DLC data members moved to DLCController
|
||||
// Sign-in info moved to NetworkController
|
||||
|
||||
public:
|
||||
// 4J Stu - We need to be able to detect when a guest player signs in or out
|
||||
// causing other guest players to change their xuid The simplest way to do
|
||||
// this is to check if their guest number has changed, so store the last
|
||||
// known one here 4J Stu - Now storing the whole XUSER_SIGNIN_INFO so we can
|
||||
// detect xuid changes
|
||||
XUSER_SIGNIN_INFO m_currentSigninInfo[XUSER_MAX_COUNT];
|
||||
|
||||
// void OverrideFontRenderer(bool set, bool immediate = true);
|
||||
// void ToggleFontRenderer() {
|
||||
|
|
@ -821,32 +899,28 @@ public:
|
|||
bool AutosaveDue(void) { return m_saveManager.autosaveDue(); }
|
||||
int64_t SecondsToAutosave() { return m_saveManager.secondsToAutosave(); }
|
||||
|
||||
private:
|
||||
unsigned int m_uiOpacityCountDown[XUSER_MAX_COUNT];
|
||||
|
||||
// DLC
|
||||
bool m_bNewDLCAvailable;
|
||||
bool m_bSeenNewDLCTip;
|
||||
|
||||
// Host options
|
||||
private:
|
||||
unsigned int m_uiGameHostSettings;
|
||||
static unsigned char m_szPNG[8];
|
||||
// m_uiOpacityCountDown moved to MenuController
|
||||
// DLC flags moved to DLCController
|
||||
// Host options - m_uiGameHostSettings moved to GameSettingsManager
|
||||
unsigned int& m_uiGameHostSettings = m_gameSettingsManager.m_uiGameHostSettings;
|
||||
|
||||
#if defined(_LARGE_WORLDS)
|
||||
unsigned int m_GameNewWorldSize;
|
||||
bool m_bGameNewWorldSizeUseMoat;
|
||||
unsigned int m_GameNewHellScale;
|
||||
#endif
|
||||
unsigned int FromBigEndian(unsigned int uiValue);
|
||||
|
||||
public:
|
||||
void SetGameHostOption(eGameHostOption eVal, unsigned int uiVal);
|
||||
void SetGameHostOption(unsigned int& uiHostSettings, eGameHostOption eVal,
|
||||
unsigned int uiVal);
|
||||
unsigned int uiVal) {
|
||||
m_gameSettingsManager.setGameHostOption(uiHostSettings, eVal, uiVal);
|
||||
}
|
||||
unsigned int GetGameHostOption(eGameHostOption eVal);
|
||||
unsigned int GetGameHostOption(unsigned int uiHostSettings,
|
||||
eGameHostOption eVal);
|
||||
eGameHostOption eVal) {
|
||||
return m_gameSettingsManager.getGameHostOption(uiHostSettings, eVal);
|
||||
}
|
||||
|
||||
#if defined(_LARGE_WORLDS)
|
||||
void SetGameNewWorldSize(unsigned int newSize, bool useMoat) {
|
||||
|
|
@ -864,15 +938,21 @@ public:
|
|||
#endif
|
||||
void SetResetNether(bool bResetNether) { m_bResetNether = bResetNether; }
|
||||
bool GetResetNether() { return m_bResetNether; }
|
||||
bool CanRecordStatsAndAchievements();
|
||||
bool CanRecordStatsAndAchievements() {
|
||||
return m_gameSettingsManager.canRecordStatsAndAchievements();
|
||||
}
|
||||
|
||||
// World seed from png image
|
||||
// World seed from png image - delegated to MenuController
|
||||
void GetImageTextData(std::uint8_t* imageData, unsigned int imageBytes,
|
||||
unsigned char* seedText, unsigned int& uiHostOptions,
|
||||
bool& bHostOptionsRead, std::uint32_t& uiTexturePack);
|
||||
bool& bHostOptionsRead, std::uint32_t& uiTexturePack) {
|
||||
m_menuController.getImageTextData(imageData, imageBytes, seedText, uiHostOptions, bHostOptionsRead, uiTexturePack);
|
||||
}
|
||||
unsigned int CreateImageTextData(std::uint8_t* textMetadata, int64_t seed,
|
||||
bool hasSeed, unsigned int uiHostOptions,
|
||||
unsigned int uiTexturePackId);
|
||||
unsigned int uiTexturePackId) {
|
||||
return m_menuController.createImageTextData(textMetadata, seed, hasSeed, uiHostOptions, uiTexturePackId);
|
||||
}
|
||||
|
||||
// Game rules
|
||||
GameRuleManager m_gameRules;
|
||||
|
|
@ -893,50 +973,69 @@ public:
|
|||
}
|
||||
const wchar_t* GetGameRulesString(const std::wstring& key);
|
||||
|
||||
private:
|
||||
std::uint8_t m_playerColours[MINECRAFT_NET_MAX_PLAYERS]; // An array of
|
||||
// QNet small-id's
|
||||
unsigned int m_playerGamePrivileges[MINECRAFT_NET_MAX_PLAYERS];
|
||||
// m_playerColours and m_playerGamePrivileges moved to NetworkController
|
||||
|
||||
public:
|
||||
void UpdatePlayerInfo(std::uint8_t networkSmallId,
|
||||
int16_t playerColourIndex,
|
||||
unsigned int playerGamePrivileges);
|
||||
short GetPlayerColour(std::uint8_t networkSmallId);
|
||||
unsigned int GetPlayerPrivileges(std::uint8_t networkSmallId);
|
||||
unsigned int playerGamePrivileges) {
|
||||
m_networkController.updatePlayerInfo(networkSmallId, playerColourIndex, playerGamePrivileges);
|
||||
}
|
||||
short GetPlayerColour(std::uint8_t networkSmallId) {
|
||||
return m_networkController.getPlayerColour(networkSmallId);
|
||||
}
|
||||
unsigned int GetPlayerPrivileges(std::uint8_t networkSmallId) {
|
||||
return m_networkController.getPlayerPrivileges(networkSmallId);
|
||||
}
|
||||
|
||||
std::wstring getEntityName(eINSTANCEOF type);
|
||||
|
||||
unsigned int AddDLCRequest(eDLCMarketplaceType eContentType,
|
||||
bool bPromote = false);
|
||||
bool RetrieveNextDLCContent();
|
||||
bool CheckTMSDLCCanStop();
|
||||
int dlcOffersReturned(int iOfferC, std::uint32_t dwType, int iPad);
|
||||
std::uint32_t GetDLCContentType(eDLCContentType eType) {
|
||||
return m_dwContentTypeA[eType];
|
||||
bool bPromote = false) {
|
||||
return m_dlcController.addDLCRequest(eContentType, bPromote);
|
||||
}
|
||||
eDLCContentType Find_eDLCContentType(std::uint32_t dwType);
|
||||
int GetDLCOffersCount() { return m_iDLCOfferC; }
|
||||
bool DLCContentRetrieved(eDLCMarketplaceType eType);
|
||||
void TickDLCOffersRetrieved();
|
||||
void ClearAndResetDLCDownloadQueue();
|
||||
bool RetrieveNextTMSPPContent();
|
||||
void TickTMSPPFilesRetrieved();
|
||||
void ClearTMSPPFilesRetrieved();
|
||||
bool RetrieveNextDLCContent() { return m_dlcController.retrieveNextDLCContent(); }
|
||||
bool CheckTMSDLCCanStop() { return m_dlcController.checkTMSDLCCanStop(); }
|
||||
int dlcOffersReturned(int iOfferC, std::uint32_t dwType, int iPad) {
|
||||
return m_dlcController.dlcOffersReturned(iOfferC, dwType, iPad);
|
||||
}
|
||||
std::uint32_t GetDLCContentType(eDLCContentType eType) {
|
||||
return m_dlcController.getDLCContentType(eType);
|
||||
}
|
||||
eDLCContentType Find_eDLCContentType(std::uint32_t dwType) {
|
||||
return m_dlcController.find_eDLCContentType(dwType);
|
||||
}
|
||||
int GetDLCOffersCount() { return m_dlcController.getDLCOffersCount(); }
|
||||
bool DLCContentRetrieved(eDLCMarketplaceType eType) {
|
||||
return m_dlcController.dlcContentRetrieved(eType);
|
||||
}
|
||||
void TickDLCOffersRetrieved() { m_dlcController.tickDLCOffersRetrieved(); }
|
||||
void ClearAndResetDLCDownloadQueue() { m_dlcController.clearAndResetDLCDownloadQueue(); }
|
||||
bool RetrieveNextTMSPPContent() { return m_dlcController.retrieveNextTMSPPContent(); }
|
||||
void TickTMSPPFilesRetrieved() { m_dlcController.tickTMSPPFilesRetrieved(); }
|
||||
void ClearTMSPPFilesRetrieved() { m_dlcController.clearTMSPPFilesRetrieved(); }
|
||||
unsigned int AddTMSPPFileTypeRequest(eDLCContentType eType,
|
||||
bool bPromote = false);
|
||||
int GetDLCInfoTexturesOffersCount();
|
||||
bool bPromote = false) {
|
||||
return m_dlcController.addTMSPPFileTypeRequest(eType, bPromote);
|
||||
}
|
||||
int GetDLCInfoTexturesOffersCount() { return m_dlcController.getDLCInfoTexturesOffersCount(); }
|
||||
|
||||
static int TMSPPFileReturned(void* pParam, int iPad, int iUserData,
|
||||
C4JStorage::PTMSPP_FILEDATA pFileData,
|
||||
const char* szFilename);
|
||||
DLC_INFO* GetDLCInfoTrialOffer(int iIndex);
|
||||
DLC_INFO* GetDLCInfoFullOffer(int iIndex);
|
||||
const char* szFilename) {
|
||||
return DLCController::tmsPPFileReturned(pParam, iPad, iUserData, pFileData, szFilename);
|
||||
}
|
||||
DLC_INFO* GetDLCInfoTrialOffer(int iIndex) { return m_dlcController.getDLCInfoTrialOffer(iIndex); }
|
||||
DLC_INFO* GetDLCInfoFullOffer(int iIndex) { return m_dlcController.getDLCInfoFullOffer(iIndex); }
|
||||
|
||||
int GetDLCInfoTrialOffersCount();
|
||||
int GetDLCInfoFullOffersCount();
|
||||
bool GetDLCFullOfferIDForPackID(const int iPackID, uint64_t* pullVal);
|
||||
uint64_t GetDLCInfoTexturesFullOffer(int iIndex);
|
||||
int GetDLCInfoTrialOffersCount() { return m_dlcController.getDLCInfoTrialOffersCount(); }
|
||||
int GetDLCInfoFullOffersCount() { return m_dlcController.getDLCInfoFullOffersCount(); }
|
||||
bool GetDLCFullOfferIDForPackID(const int iPackID, uint64_t* pullVal) {
|
||||
return m_dlcController.getDLCFullOfferIDForPackID(iPackID, pullVal);
|
||||
}
|
||||
uint64_t GetDLCInfoTexturesFullOffer(int iIndex) {
|
||||
return m_dlcController.getDLCInfoTexturesFullOffer(iIndex);
|
||||
}
|
||||
|
||||
void SetCorruptSaveDeleted(bool bVal) { m_bCorruptSaveDeleted = bVal; }
|
||||
bool GetCorruptSaveDeleted(void) { return m_bCorruptSaveDeleted; }
|
||||
|
|
@ -944,27 +1043,15 @@ public:
|
|||
void lockSaveNotification() { m_saveManager.lock(); }
|
||||
void unlockSaveNotification() { m_saveManager.unlock(); }
|
||||
|
||||
private:
|
||||
// Download Status
|
||||
|
||||
// Request current_download;
|
||||
std::vector<DLCRequest*> m_DLCDownloadQueue;
|
||||
std::vector<TMSPPRequest*> m_TMSPPDownloadQueue;
|
||||
static std::uint32_t m_dwContentTypeA[e_Marketplace_MAX];
|
||||
int m_iDLCOfferC;
|
||||
bool m_bAllDLCContentRetrieved;
|
||||
bool m_bAllTMSContentRetrieved;
|
||||
bool m_bTickTMSDLCFiles;
|
||||
std::mutex csDLCDownloadQueue;
|
||||
std::mutex csTMSPPDownloadQueue;
|
||||
// Download status members moved to DLCController
|
||||
bool m_bCorruptSaveDeleted;
|
||||
|
||||
std::uint8_t*& m_pBannedListFileBuffer = m_bannedListManager.m_pBannedListFileBuffer;
|
||||
unsigned int& m_dwBannedListFileSize = m_bannedListManager.m_dwBannedListFileSize;
|
||||
|
||||
public:
|
||||
unsigned int m_dwDLCFileSize;
|
||||
std::uint8_t* m_pDLCFileBuffer;
|
||||
unsigned int& m_dwDLCFileSize = m_dlcController.m_dwDLCFileSize;
|
||||
std::uint8_t*& m_pDLCFileBuffer = m_dlcController.m_pDLCFileBuffer;
|
||||
|
||||
// static int CallbackReadXuidsFileFromTMS(void* lpParam, wchar_t
|
||||
// *wchFilename, int iPad, bool bResult, int iAction); static int
|
||||
|
|
@ -1056,7 +1143,7 @@ public:
|
|||
return m_localizationManager.get_xcLang(pwchLocale);
|
||||
}
|
||||
|
||||
void SetTickTMSDLCFiles(bool bVal);
|
||||
void SetTickTMSDLCFiles(bool bVal) { m_dlcController.setTickTMSDLCFiles(bVal); }
|
||||
|
||||
std::wstring getFilePath(std::uint32_t packId, std::wstring filename,
|
||||
bool bAddDataFolder,
|
||||
|
|
|
|||
1449
targets/app/common/GameSettingsManager.cpp
Normal file
1449
targets/app/common/GameSettingsManager.cpp
Normal file
File diff suppressed because it is too large
Load diff
77
targets/app/common/GameSettingsManager.h
Normal file
77
targets/app/common/GameSettingsManager.h
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "platform/sdl2/Profile.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
class GameSettingsManager {
|
||||
public:
|
||||
GameSettingsManager();
|
||||
|
||||
void initGameSettings();
|
||||
static int oldProfileVersionCallback(void* pParam, unsigned char* pucData,
|
||||
const unsigned short usVersion,
|
||||
const int iPad);
|
||||
static int defaultOptionsCallback(void* pParam,
|
||||
C_4JProfile::PROFILESETTINGS* pSettings,
|
||||
const int iPad);
|
||||
int setDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings,
|
||||
const int iPad);
|
||||
|
||||
void setGameSettings(int iPad, eGameSetting eVal, unsigned char ucVal);
|
||||
unsigned char getGameSettings(int iPad, eGameSetting eVal);
|
||||
unsigned char getGameSettings(eGameSetting eVal);
|
||||
|
||||
void checkGameSettingsChanged(bool bOverride5MinuteTimer = false,
|
||||
int iPad = XUSER_INDEX_ANY);
|
||||
void applyGameSettingsChanged(int iPad);
|
||||
void clearGameSettingsChangedFlag(int iPad);
|
||||
void actionGameSettings(int iPad, eGameSetting eVal);
|
||||
|
||||
unsigned int getGameSettingsDebugMask(int iPad = -1,
|
||||
bool bOverridePlayer = false);
|
||||
void setGameSettingsDebugMask(int iPad, unsigned int uiVal);
|
||||
void actionDebugMask(int iPad, bool bSetAllClear = false);
|
||||
|
||||
void setSpecialTutorialCompletionFlag(int iPad, int index);
|
||||
|
||||
// Mash-up pack worlds
|
||||
void hideMashupPackWorld(int iPad, unsigned int iMashupPackID);
|
||||
void enableMashupPackWorlds(int iPad);
|
||||
unsigned int getMashupPackWorlds(int iPad);
|
||||
|
||||
// Language/locale
|
||||
void setMinecraftLanguage(int iPad, unsigned char ucLanguage);
|
||||
unsigned char getMinecraftLanguage(int iPad);
|
||||
void setMinecraftLocale(int iPad, unsigned char ucLocale);
|
||||
unsigned char getMinecraftLocale(int iPad);
|
||||
|
||||
// Game host options (bitfield versions)
|
||||
void setGameHostOption(unsigned int& uiHostSettings, eGameHostOption eVal,
|
||||
unsigned int uiVal);
|
||||
unsigned int getGameHostOption(unsigned int uiHostSettings,
|
||||
eGameHostOption eVal);
|
||||
|
||||
bool canRecordStatsAndAchievements();
|
||||
|
||||
// HandleXuiActions and HandleButtonPresses
|
||||
void handleXuiActions();
|
||||
void handleButtonPresses();
|
||||
|
||||
// Action-related
|
||||
static void setActionConfirmed(void* param);
|
||||
|
||||
// Saving message
|
||||
int displaySavingMessage(const C4JStorage::ESavingMessage eMsg, int iPad);
|
||||
|
||||
// Game settings array - public, referenced by Game via alias
|
||||
GAME_SETTINGS* GameSettingsA[XUSER_MAX_COUNT];
|
||||
|
||||
// Game host settings bitfield
|
||||
unsigned int m_uiGameHostSettings;
|
||||
|
||||
private:
|
||||
void handleButtonPresses(int iPad);
|
||||
};
|
||||
664
targets/app/common/MenuController.cpp
Normal file
664
targets/app/common/MenuController.cpp
Normal file
|
|
@ -0,0 +1,664 @@
|
|||
#include "app/common/MenuController.h"
|
||||
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/UI/All Platforms/UIEnums.h"
|
||||
#include "app/common/UI/All Platforms/UIStructs.h"
|
||||
#include "app/common/UI/Scenes/UIScene_FullscreenProgress.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/linux/Linux_UIController.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/ProgressRenderer.h"
|
||||
#include "minecraft/client/renderer/GameRenderer.h"
|
||||
#include "minecraft/server/MinecraftServer.h"
|
||||
#include "minecraft/world/Container.h"
|
||||
#include "minecraft/world/entity/item/MinecartHopper.h"
|
||||
#include "minecraft/world/entity/player/Player.h"
|
||||
#include "minecraft/world/item/crafting/Recipy.h"
|
||||
#include "minecraft/world/level/tile/Tile.h"
|
||||
#include "minecraft/world/level/tile/entity/HopperTileEntity.h"
|
||||
#include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h"
|
||||
#include "platform/sdl2/Profile.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
unsigned char MenuController::m_szPNG[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
MenuController::MenuController() {
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
||||
m_eTMSAction[i] = eTMSAction_Idle;
|
||||
m_eXuiAction[i] = eAppAction_Idle;
|
||||
m_eXuiActionParam[i] = nullptr;
|
||||
m_uiOpacityCountDown[i] = 0;
|
||||
}
|
||||
m_eGlobalXuiAction = eAppAction_Idle;
|
||||
m_eGlobalXuiServerAction = eXuiServerAction_Idle;
|
||||
}
|
||||
|
||||
void MenuController::setAction(int iPad, eXuiAction action, void* param) {
|
||||
if ((m_eXuiAction[iPad] == eAppAction_ReloadTexturePack) &&
|
||||
(action == eAppAction_EthernetDisconnected)) {
|
||||
app.DebugPrintf(
|
||||
"Invalid change of App action for pad %d from %d to %d, ignoring\n",
|
||||
iPad, m_eXuiAction[iPad], action);
|
||||
} else if ((m_eXuiAction[iPad] == eAppAction_ReloadTexturePack) &&
|
||||
(action == eAppAction_ExitWorld)) {
|
||||
app.DebugPrintf(
|
||||
"Invalid change of App action for pad %d from %d to %d, ignoring\n",
|
||||
iPad, m_eXuiAction[iPad], action);
|
||||
} else if (m_eXuiAction[iPad] == eAppAction_ExitWorldCapturedThumbnail &&
|
||||
action != eAppAction_Idle) {
|
||||
app.DebugPrintf(
|
||||
"Invalid change of App action for pad %d from %d to %d, ignoring\n",
|
||||
iPad, m_eXuiAction[iPad], action);
|
||||
} else {
|
||||
app.DebugPrintf("Changing App action for pad %d from %d to %d\n", iPad,
|
||||
m_eXuiAction[iPad], action);
|
||||
m_eXuiAction[iPad] = action;
|
||||
m_eXuiActionParam[iPad] = param;
|
||||
}
|
||||
}
|
||||
|
||||
bool MenuController::loadInventoryMenu(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
bool bNavigateBack) {
|
||||
bool success = true;
|
||||
|
||||
InventoryScreenInput* initData = new InventoryScreenInput();
|
||||
initData->player = player;
|
||||
initData->bNavigateBack = bNavigateBack;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_InventoryMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_InventoryMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadCreativeMenu(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
bool bNavigateBack) {
|
||||
bool success = true;
|
||||
|
||||
InventoryScreenInput* initData = new InventoryScreenInput();
|
||||
initData->player = player;
|
||||
initData->bNavigateBack = bNavigateBack;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_CreativeMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_CreativeMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadCrafting2x2Menu(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player) {
|
||||
bool success = true;
|
||||
|
||||
CraftingPanelScreenInput* initData = new CraftingPanelScreenInput();
|
||||
initData->player = player;
|
||||
initData->iContainerType = RECIPE_TYPE_2x2;
|
||||
initData->iPad = iPad;
|
||||
initData->x = 0;
|
||||
initData->y = 0;
|
||||
initData->z = 0;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_Crafting2x2Menu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_Crafting2x2Menu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadCrafting3x3Menu(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
int x, int y, int z) {
|
||||
bool success = true;
|
||||
|
||||
CraftingPanelScreenInput* initData = new CraftingPanelScreenInput();
|
||||
initData->player = player;
|
||||
initData->iContainerType = RECIPE_TYPE_3x3;
|
||||
initData->iPad = iPad;
|
||||
initData->x = x;
|
||||
initData->y = y;
|
||||
initData->z = z;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_Crafting3x3Menu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_Crafting3x3Menu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadFireworksMenu(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
int x, int y, int z) {
|
||||
bool success = true;
|
||||
|
||||
FireworksScreenInput* initData = new FireworksScreenInput();
|
||||
initData->player = player;
|
||||
initData->iPad = iPad;
|
||||
initData->x = x;
|
||||
initData->y = y;
|
||||
initData->z = z;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_FireworksMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_FireworksMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadEnchantingMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
int x, int y, int z, Level* level,
|
||||
const std::wstring& name) {
|
||||
bool success = true;
|
||||
|
||||
EnchantingScreenInput* initData = new EnchantingScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->level = level;
|
||||
initData->x = x;
|
||||
initData->y = y;
|
||||
initData->z = z;
|
||||
initData->iPad = iPad;
|
||||
initData->name = name;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_EnchantingMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_EnchantingMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadFurnaceMenu(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<FurnaceTileEntity> furnace) {
|
||||
bool success = true;
|
||||
|
||||
FurnaceScreenInput* initData = new FurnaceScreenInput();
|
||||
initData->furnace = furnace;
|
||||
initData->inventory = inventory;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_FurnaceMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_FurnaceMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadBrewingStandMenu(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand) {
|
||||
bool success = true;
|
||||
|
||||
BrewingScreenInput* initData = new BrewingScreenInput();
|
||||
initData->brewingStand = brewingStand;
|
||||
initData->inventory = inventory;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_BrewingStandMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_BrewingStandMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadContainerMenu(int iPad,
|
||||
std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<Container> container) {
|
||||
bool success = true;
|
||||
|
||||
ContainerScreenInput* initData = new ContainerScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->container = container;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
|
||||
bool bLargeChest =
|
||||
(initData->container->getContainerSize() > 3 * 9) ? true : false;
|
||||
if (bLargeChest) {
|
||||
success =
|
||||
ui.NavigateToScene(iPad, eUIScene_LargeContainerMenu, initData);
|
||||
} else {
|
||||
success =
|
||||
ui.NavigateToScene(iPad, eUIScene_ContainerMenu, initData);
|
||||
}
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_ContainerMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadTrapMenu(
|
||||
int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<DispenserTileEntity> trap) {
|
||||
bool success = true;
|
||||
|
||||
TrapScreenInput* initData = new TrapScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->trap = trap;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_DispenserMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_DispenserMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadSignEntryMenu(
|
||||
int iPad, std::shared_ptr<SignTileEntity> sign) {
|
||||
bool success = true;
|
||||
|
||||
SignEntryScreenInput* initData = new SignEntryScreenInput();
|
||||
initData->sign = sign;
|
||||
initData->iPad = iPad;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_SignEntryMenu, initData);
|
||||
|
||||
delete initData;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadRepairingMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
Level* level, int x, int y, int z) {
|
||||
bool success = true;
|
||||
|
||||
AnvilScreenInput* initData = new AnvilScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->level = level;
|
||||
initData->x = x;
|
||||
initData->y = y;
|
||||
initData->z = z;
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_AnvilMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadTradingMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Merchant> trader,
|
||||
Level* level, const std::wstring& name) {
|
||||
bool success = true;
|
||||
|
||||
TradingScreenInput* initData = new TradingScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->trader = trader;
|
||||
initData->level = level;
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_TradingMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadHopperMenu(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<HopperTileEntity> hopper) {
|
||||
bool success = true;
|
||||
|
||||
HopperScreenInput* initData = new HopperScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->hopper = hopper;
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_HopperMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadHopperMenu(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<MinecartHopper> hopper) {
|
||||
bool success = true;
|
||||
|
||||
HopperScreenInput* initData = new HopperScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->hopper = std::dynamic_pointer_cast<Container>(hopper);
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_HopperMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadHorseMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> container,
|
||||
std::shared_ptr<EntityHorse> horse) {
|
||||
bool success = true;
|
||||
|
||||
HorseScreenInput* initData = new HorseScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->container = container;
|
||||
initData->horse = horse;
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_HorseMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadBeaconMenu(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BeaconTileEntity> beacon) {
|
||||
bool success = true;
|
||||
|
||||
BeaconScreenInput* initData = new BeaconScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->beacon = beacon;
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_BeaconMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
int MenuController::texturePackDialogReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuController::unlockFullInviteReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
bool bNoPlayer;
|
||||
|
||||
if (pMinecraft->player == nullptr) {
|
||||
bNoPlayer = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuController::unlockFullSaveReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuController::unlockFullExitReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
Game* pApp = (Game*)pParam;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (result != C4JStorage::EMessage_ResultAccept) {
|
||||
pApp->SetAction(pMinecraft->player->GetXboxPad(),
|
||||
eAppAction_ExitWorldTrial);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuController::trialOverReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result) {
|
||||
Game* pApp = (Game*)pParam;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (result != C4JStorage::EMessage_ResultAccept) {
|
||||
pApp->SetAction(pMinecraft->player->GetXboxPad(), eAppAction_ExitTrial);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuController::remoteSaveThreadProc(void* lpParameter) {
|
||||
Compression::UseDefaultThreadStorage();
|
||||
Tile::CreateNewThreadStorage();
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
pMinecraft->progressRenderer->progressStartNoAbort(
|
||||
IDS_PROGRESS_HOST_SAVING);
|
||||
pMinecraft->progressRenderer->progressStage(-1);
|
||||
pMinecraft->progressRenderer->progressStagePercentage(0);
|
||||
|
||||
while (!app.GetGameStarted() &&
|
||||
app.GetXuiAction(ProfileManager.GetPrimaryPad()) ==
|
||||
eAppAction_WaitRemoteServerSaveComplete) {
|
||||
pMinecraft->tickAllConnections();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
if (app.GetXuiAction(ProfileManager.GetPrimaryPad()) !=
|
||||
eAppAction_WaitRemoteServerSaveComplete) {
|
||||
return ERROR_CANCELLED;
|
||||
}
|
||||
app.SetAction(ProfileManager.GetPrimaryPad(), eAppAction_Idle);
|
||||
|
||||
ui.UpdatePlayerBasePositions();
|
||||
|
||||
Tile::ReleaseThreadStorage();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MenuController::exitGameFromRemoteSave(void* lpParameter) {
|
||||
int primaryPad = ProfileManager.GetPrimaryPad();
|
||||
|
||||
unsigned int uiIDA[3];
|
||||
uiIDA[0] = IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1] = IDS_CONFIRM_OK;
|
||||
|
||||
ui.RequestAlertMessage(
|
||||
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, primaryPad,
|
||||
&MenuController::exitGameFromRemoteSaveDialogReturned, nullptr);
|
||||
}
|
||||
|
||||
int MenuController::exitGameFromRemoteSaveDialogReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
if (result == C4JStorage::EMessage_ResultDecline) {
|
||||
app.SetAction(iPad, eAppAction_ExitWorld);
|
||||
} else {
|
||||
UIScene_FullscreenProgress* pScene =
|
||||
(UIScene_FullscreenProgress*)ui.FindScene(
|
||||
eUIScene_FullscreenProgress);
|
||||
if (pScene != nullptr) {
|
||||
pScene->SetWasCancelled(false);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define PNG_TAG_tEXt 0x74455874
|
||||
|
||||
unsigned int MenuController::fromBigEndian(unsigned int uiValue) {
|
||||
unsigned int uiReturn =
|
||||
((uiValue >> 24) & 0x000000ff) | ((uiValue >> 8) & 0x0000ff00) |
|
||||
((uiValue << 8) & 0x00ff0000) | ((uiValue << 24) & 0xff000000);
|
||||
return uiReturn;
|
||||
}
|
||||
|
||||
void MenuController::getImageTextData(std::uint8_t* imageData,
|
||||
unsigned int imageBytes,
|
||||
unsigned char* seedText,
|
||||
unsigned int& uiHostOptions,
|
||||
bool& bHostOptionsRead,
|
||||
std::uint32_t& uiTexturePack) {
|
||||
auto readPngUInt32 = [](const std::uint8_t* data) -> unsigned int {
|
||||
unsigned int value = 0;
|
||||
std::memcpy(&value, data, sizeof(value));
|
||||
return value;
|
||||
};
|
||||
|
||||
std::uint8_t* ucPtr = imageData;
|
||||
unsigned int uiCount = 0;
|
||||
unsigned int uiChunkLen;
|
||||
unsigned int uiChunkType;
|
||||
unsigned int uiCRC;
|
||||
char szKeyword[80];
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (m_szPNG[i] != ucPtr[i]) return;
|
||||
}
|
||||
|
||||
uiCount += 8;
|
||||
|
||||
while (uiCount < imageBytes) {
|
||||
uiChunkLen = fromBigEndian(readPngUInt32(&ucPtr[uiCount]));
|
||||
uiCount += sizeof(int);
|
||||
uiChunkType = fromBigEndian(readPngUInt32(&ucPtr[uiCount]));
|
||||
uiCount += sizeof(int);
|
||||
|
||||
if (uiChunkType == PNG_TAG_tEXt) {
|
||||
unsigned char* pszKeyword = &ucPtr[uiCount];
|
||||
while (pszKeyword < ucPtr + uiCount + uiChunkLen) {
|
||||
memset(szKeyword, 0, 80);
|
||||
unsigned int uiKeywordC = 0;
|
||||
while (*pszKeyword != 0) {
|
||||
szKeyword[uiKeywordC++] = *pszKeyword;
|
||||
pszKeyword++;
|
||||
}
|
||||
pszKeyword++;
|
||||
if (strcmp(szKeyword, "4J_SEED") == 0) {
|
||||
unsigned int uiValueC = 0;
|
||||
while (*pszKeyword != 0 &&
|
||||
(pszKeyword < ucPtr + uiCount + uiChunkLen)) {
|
||||
seedText[uiValueC++] = *pszKeyword;
|
||||
pszKeyword++;
|
||||
}
|
||||
} else if (strcmp(szKeyword, "4J_HOSTOPTIONS") == 0) {
|
||||
bHostOptionsRead = true;
|
||||
unsigned int uiValueC = 0;
|
||||
unsigned char pszHostOptions[9];
|
||||
memset(&pszHostOptions, 0, 9);
|
||||
while (*pszKeyword != 0 &&
|
||||
(pszKeyword < ucPtr + uiCount + uiChunkLen) &&
|
||||
uiValueC < 8) {
|
||||
pszHostOptions[uiValueC++] = *pszKeyword;
|
||||
pszKeyword++;
|
||||
}
|
||||
|
||||
uiHostOptions = 0;
|
||||
std::stringstream ss;
|
||||
ss << pszHostOptions;
|
||||
ss >> std::hex >> uiHostOptions;
|
||||
} else if (strcmp(szKeyword, "4J_TEXTUREPACK") == 0) {
|
||||
unsigned int uiValueC = 0;
|
||||
unsigned char pszTexturePack[9];
|
||||
memset(&pszTexturePack, 0, 9);
|
||||
while (*pszKeyword != 0 &&
|
||||
(pszKeyword < ucPtr + uiCount + uiChunkLen) &&
|
||||
uiValueC < 8) {
|
||||
pszTexturePack[uiValueC++] = *pszKeyword;
|
||||
pszKeyword++;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << pszTexturePack;
|
||||
ss >> std::hex >> uiTexturePack;
|
||||
}
|
||||
}
|
||||
}
|
||||
uiCount += uiChunkLen;
|
||||
uiCRC = fromBigEndian(readPngUInt32(&ucPtr[uiCount]));
|
||||
uiCount += sizeof(int);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int MenuController::createImageTextData(
|
||||
std::uint8_t* textMetadata, int64_t seed, bool hasSeed,
|
||||
unsigned int uiHostOptions, unsigned int uiTexturePackId) {
|
||||
int iTextMetadataBytes = 0;
|
||||
if (hasSeed) {
|
||||
strcpy((char*)textMetadata, "4J_SEED");
|
||||
snprintf((char*)&textMetadata[8], 42, "%lld", (long long)seed);
|
||||
|
||||
iTextMetadataBytes += 8;
|
||||
while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++;
|
||||
++iTextMetadataBytes;
|
||||
}
|
||||
|
||||
strcpy((char*)&textMetadata[iTextMetadataBytes], "4J_HOSTOPTIONS");
|
||||
snprintf((char*)&textMetadata[iTextMetadataBytes + 15], 9, "%X",
|
||||
uiHostOptions);
|
||||
|
||||
iTextMetadataBytes += 15;
|
||||
while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++;
|
||||
++iTextMetadataBytes;
|
||||
|
||||
strcpy((char*)&textMetadata[iTextMetadataBytes], "4J_TEXTUREPACK");
|
||||
snprintf((char*)&textMetadata[iTextMetadataBytes + 15], 9, "%X",
|
||||
uiHostOptions);
|
||||
|
||||
iTextMetadataBytes += 15;
|
||||
while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++;
|
||||
|
||||
return iTextMetadataBytes;
|
||||
}
|
||||
151
targets/app/common/MenuController.h
Normal file
151
targets/app/common/MenuController.h
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
class Player;
|
||||
class Inventory;
|
||||
class Level;
|
||||
class FurnaceTileEntity;
|
||||
class Container;
|
||||
class DispenserTileEntity;
|
||||
class SignTileEntity;
|
||||
class BrewingStandTileEntity;
|
||||
class HopperTileEntity;
|
||||
class MinecartHopper;
|
||||
class EntityHorse;
|
||||
class BeaconTileEntity;
|
||||
class LocalPlayer;
|
||||
class Merchant;
|
||||
class CommandBlockEntity;
|
||||
|
||||
class MenuController {
|
||||
public:
|
||||
MenuController();
|
||||
|
||||
// Load menu methods
|
||||
bool loadInventoryMenu(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
bool bNavigateBack = false);
|
||||
bool loadCreativeMenu(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
bool bNavigateBack = false);
|
||||
bool loadEnchantingMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
int x, int y, int z, Level* level,
|
||||
const std::wstring& name);
|
||||
bool loadFurnaceMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<FurnaceTileEntity> furnace);
|
||||
bool loadBrewingStandMenu(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand);
|
||||
bool loadContainerMenu(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<Container> container);
|
||||
bool loadTrapMenu(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<DispenserTileEntity> trap);
|
||||
bool loadCrafting2x2Menu(int iPad, std::shared_ptr<LocalPlayer> player);
|
||||
bool loadCrafting3x3Menu(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
int x, int y, int z);
|
||||
bool loadFireworksMenu(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
int x, int y, int z);
|
||||
bool loadSignEntryMenu(int iPad, std::shared_ptr<SignTileEntity> sign);
|
||||
bool loadRepairingMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
Level* level, int x, int y, int z);
|
||||
bool loadTradingMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Merchant> trader, Level* level,
|
||||
const std::wstring& name);
|
||||
bool loadHopperMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<HopperTileEntity> hopper);
|
||||
bool loadHopperMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<MinecartHopper> hopper);
|
||||
bool loadHorseMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> container,
|
||||
std::shared_ptr<EntityHorse> horse);
|
||||
bool loadBeaconMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BeaconTileEntity> beacon);
|
||||
|
||||
// Action management
|
||||
void setAction(int iPad, eXuiAction action, void* param = nullptr);
|
||||
eXuiAction getXuiAction(int iPad) { return m_eXuiAction[iPad]; }
|
||||
void setXuiServerAction(int iPad, eXuiServerAction action,
|
||||
void* param = nullptr) {
|
||||
m_eXuiServerAction[iPad] = action;
|
||||
m_eXuiServerActionParam[iPad] = param;
|
||||
}
|
||||
eXuiServerAction getXuiServerAction(int iPad) {
|
||||
return m_eXuiServerAction[iPad];
|
||||
}
|
||||
void* getXuiServerActionParam(int iPad) {
|
||||
return m_eXuiServerActionParam[iPad];
|
||||
}
|
||||
eXuiAction getGlobalXuiAction() { return m_eGlobalXuiAction; }
|
||||
void setGlobalXuiAction(eXuiAction action) { m_eGlobalXuiAction = action; }
|
||||
eXuiServerAction getGlobalXuiServerAction() {
|
||||
return m_eGlobalXuiServerAction;
|
||||
}
|
||||
void setGlobalXuiServerAction(eXuiServerAction action) {
|
||||
m_eGlobalXuiServerAction = action;
|
||||
}
|
||||
|
||||
// TMS action
|
||||
void setTMSAction(int iPad, eTMSAction action) {
|
||||
m_eTMSAction[iPad] = action;
|
||||
}
|
||||
eTMSAction getTMSAction(int iPad) { return m_eTMSAction[iPad]; }
|
||||
|
||||
// Dialog callbacks
|
||||
static int texturePackDialogReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
static int fatalErrorDialogReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
static int trialOverReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
static int unlockFullExitReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
static int unlockFullSaveReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
static int unlockFullInviteReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
|
||||
// Remote save
|
||||
static int remoteSaveThreadProc(void* lpParameter);
|
||||
static void exitGameFromRemoteSave(void* lpParameter);
|
||||
static int exitGameFromRemoteSaveDialogReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
|
||||
// Image text data
|
||||
void getImageTextData(std::uint8_t* imageData, unsigned int imageBytes,
|
||||
unsigned char* seedText, unsigned int& uiHostOptions,
|
||||
bool& bHostOptionsRead, std::uint32_t& uiTexturePack);
|
||||
unsigned int createImageTextData(std::uint8_t* textMetadata, int64_t seed,
|
||||
bool hasSeed, unsigned int uiHostOptions,
|
||||
unsigned int uiTexturePackId);
|
||||
|
||||
// Opacity timer
|
||||
unsigned int getOpacityTimer(int iPad) {
|
||||
return m_uiOpacityCountDown[iPad];
|
||||
}
|
||||
void setOpacityTimer(int iPad) { m_uiOpacityCountDown[iPad] = 120; }
|
||||
void tickOpacityTimer(int iPad) {
|
||||
if (m_uiOpacityCountDown[iPad] > 0) m_uiOpacityCountDown[iPad]--;
|
||||
}
|
||||
|
||||
// Action param accessor (needed by HandleXuiActions)
|
||||
void* getXuiActionParam(int iPad) { return m_eXuiActionParam[iPad]; }
|
||||
|
||||
private:
|
||||
eXuiAction m_eXuiAction[XUSER_MAX_COUNT];
|
||||
eTMSAction m_eTMSAction[XUSER_MAX_COUNT];
|
||||
void* m_eXuiActionParam[XUSER_MAX_COUNT];
|
||||
eXuiAction m_eGlobalXuiAction;
|
||||
eXuiServerAction m_eXuiServerAction[XUSER_MAX_COUNT];
|
||||
void* m_eXuiServerActionParam[XUSER_MAX_COUNT];
|
||||
eXuiServerAction m_eGlobalXuiServerAction;
|
||||
|
||||
unsigned int m_uiOpacityCountDown[XUSER_MAX_COUNT];
|
||||
|
||||
static unsigned char m_szPNG[8];
|
||||
unsigned int fromBigEndian(unsigned int uiValue);
|
||||
};
|
||||
518
targets/app/common/NetworkController.cpp
Normal file
518
targets/app/common/NetworkController.cpp
Normal file
|
|
@ -0,0 +1,518 @@
|
|||
#include "app/common/NetworkController.h"
|
||||
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/linux/Linux_UIController.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/ProgressRenderer.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerLevel.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
|
||||
#include "minecraft/client/renderer/GameRenderer.h"
|
||||
#include "minecraft/client/skins/DLCTexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "minecraft/server/MinecraftServer.h"
|
||||
#include "minecraft/stats/StatsCounter.h"
|
||||
#include "minecraft/world/entity/player/Player.h"
|
||||
#include "minecraft/world/level/tile/Tile.h"
|
||||
#include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h"
|
||||
#include "platform/sdl2/Input.h"
|
||||
#include "platform/sdl2/Profile.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "app/common/Audio/SoundEngine.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
unsigned int NetworkController::m_uiLastSignInData = 0;
|
||||
|
||||
NetworkController::NetworkController() {
|
||||
m_disconnectReason = DisconnectPacket::eDisconnect_None;
|
||||
m_bLiveLinkRequired = false;
|
||||
m_bChangingSessionType = false;
|
||||
m_bReallyChangingSessionType = false;
|
||||
|
||||
memset(&m_InviteData, 0, sizeof(JoinFromInviteData));
|
||||
memset(m_playerColours, 0, MINECRAFT_NET_MAX_PLAYERS);
|
||||
memset(m_playerGamePrivileges, 0, sizeof(m_playerGamePrivileges));
|
||||
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
||||
if (FAILED(XUserGetSigninInfo(i,
|
||||
XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY,
|
||||
&m_currentSigninInfo[i]))) {
|
||||
m_currentSigninInfo[i].xuid = INVALID_XUID;
|
||||
m_currentSigninInfo[i].dwGuestNumber = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkController::updatePlayerInfo(std::uint8_t networkSmallId,
|
||||
int16_t playerColourIndex,
|
||||
unsigned int playerGamePrivileges) {
|
||||
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) {
|
||||
if (m_playerColours[i] == networkSmallId) {
|
||||
m_playerColours[i] = 0;
|
||||
m_playerGamePrivileges[i] = 0;
|
||||
}
|
||||
}
|
||||
if (playerColourIndex >= 0 &&
|
||||
playerColourIndex < MINECRAFT_NET_MAX_PLAYERS) {
|
||||
m_playerColours[playerColourIndex] = networkSmallId;
|
||||
m_playerGamePrivileges[playerColourIndex] = playerGamePrivileges;
|
||||
}
|
||||
}
|
||||
|
||||
short NetworkController::getPlayerColour(std::uint8_t networkSmallId) {
|
||||
short index = -1;
|
||||
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) {
|
||||
if (m_playerColours[i] == networkSmallId) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
unsigned int NetworkController::getPlayerPrivileges(
|
||||
std::uint8_t networkSmallId) {
|
||||
unsigned int privileges = 0;
|
||||
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) {
|
||||
if (m_playerColours[i] == networkSmallId) {
|
||||
privileges = m_playerGamePrivileges[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return privileges;
|
||||
}
|
||||
|
||||
void NetworkController::processInvite(std::uint32_t dwUserIndex,
|
||||
std::uint32_t dwLocalUsersMask,
|
||||
const INVITE_INFO* pInviteInfo) {
|
||||
m_InviteData.dwUserIndex = dwUserIndex;
|
||||
m_InviteData.dwLocalUsersMask = dwLocalUsersMask;
|
||||
m_InviteData.pInviteInfo = pInviteInfo;
|
||||
app.SetAction(dwUserIndex, eAppAction_ExitAndJoinFromInvite);
|
||||
}
|
||||
|
||||
int NetworkController::primaryPlayerSignedOutReturned(
|
||||
void* pParam, int iPad, const C4JStorage::EMessageResult) {
|
||||
if (g_NetworkManager.IsInSession()) {
|
||||
app.SetAction(iPad, eAppAction_PrimaryPlayerSignedOutReturned);
|
||||
} else {
|
||||
app.SetAction(iPad, eAppAction_PrimaryPlayerSignedOutReturned_Menus);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NetworkController::ethernetDisconnectReturned(
|
||||
void* pParam, int iPad, const C4JStorage::EMessageResult) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (Minecraft::GetInstance()->player != nullptr) {
|
||||
app.SetAction(pMinecraft->player->GetXboxPad(),
|
||||
eAppAction_EthernetDisconnectedReturned);
|
||||
} else {
|
||||
app.SetAction(iPad, eAppAction_EthernetDisconnectedReturned_Menus);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NetworkController::profileReadErrorCallback(void* pParam) {
|
||||
Game* pApp = (Game*)pParam;
|
||||
int iPrimaryPlayer = ProfileManager.GetPrimaryPad();
|
||||
pApp->SetAction(iPrimaryPlayer, eAppAction_ProfileReadError);
|
||||
}
|
||||
|
||||
int NetworkController::signoutExitWorldThreadProc(void* lpParameter) {
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
int exitReasonStringId = -1;
|
||||
|
||||
bool saveStats = false;
|
||||
if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession()) {
|
||||
if (lpParameter != nullptr) {
|
||||
switch (app.GetDisconnectReason()) {
|
||||
case DisconnectPacket::eDisconnect_Kicked:
|
||||
exitReasonStringId = IDS_DISCONNECTED_KICKED;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
|
||||
exitReasonStringId =
|
||||
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
|
||||
exitReasonStringId =
|
||||
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_NoFlying:
|
||||
exitReasonStringId = IDS_DISCONNECTED_FLYING;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_OutdatedServer:
|
||||
exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_OutdatedClient:
|
||||
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
|
||||
break;
|
||||
default:
|
||||
exitReasonStringId = IDS_DISCONNECTED;
|
||||
}
|
||||
pMinecraft->progressRenderer->progressStartNoAbort(
|
||||
exitReasonStringId);
|
||||
if (pMinecraft->levels[0] != nullptr)
|
||||
pMinecraft->levels[0]->disconnect(false);
|
||||
if (pMinecraft->levels[1] != nullptr)
|
||||
pMinecraft->levels[1]->disconnect(false);
|
||||
} else {
|
||||
exitReasonStringId = IDS_EXITING_GAME;
|
||||
pMinecraft->progressRenderer->progressStartNoAbort(
|
||||
IDS_EXITING_GAME);
|
||||
|
||||
if (pMinecraft->levels[0] != nullptr)
|
||||
pMinecraft->levels[0]->disconnect();
|
||||
if (pMinecraft->levels[1] != nullptr)
|
||||
pMinecraft->levels[1]->disconnect();
|
||||
}
|
||||
|
||||
MinecraftServer::HaltServer(true);
|
||||
saveStats = false;
|
||||
g_NetworkManager.LeaveGame(false);
|
||||
} else {
|
||||
if (lpParameter != nullptr) {
|
||||
switch (app.GetDisconnectReason()) {
|
||||
case DisconnectPacket::eDisconnect_Kicked:
|
||||
exitReasonStringId = IDS_DISCONNECTED_KICKED;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
|
||||
exitReasonStringId =
|
||||
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
|
||||
exitReasonStringId =
|
||||
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_OutdatedServer:
|
||||
exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_OutdatedClient:
|
||||
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
|
||||
default:
|
||||
exitReasonStringId = IDS_DISCONNECTED;
|
||||
}
|
||||
pMinecraft->progressRenderer->progressStartNoAbort(
|
||||
exitReasonStringId);
|
||||
}
|
||||
}
|
||||
pMinecraft->setLevel(nullptr, exitReasonStringId, nullptr, saveStats, true);
|
||||
|
||||
app.m_gameRules.unloadCurrentGameRules();
|
||||
|
||||
MinecraftServer::resetFlags();
|
||||
|
||||
while (g_NetworkManager.IsInSession()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NetworkController::clearSignInChangeUsersMask() {
|
||||
int iPrimaryPlayer = ProfileManager.GetPrimaryPad();
|
||||
|
||||
if (m_uiLastSignInData != 0) {
|
||||
if (iPrimaryPlayer >= 0) {
|
||||
m_uiLastSignInData = 1 << iPrimaryPlayer;
|
||||
} else {
|
||||
m_uiLastSignInData = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkController::signInChangeCallback(void* pParam,
|
||||
bool bPrimaryPlayerChanged,
|
||||
unsigned int uiSignInData) {
|
||||
Game* pApp = (Game*)pParam;
|
||||
int iPrimaryPlayer = ProfileManager.GetPrimaryPad();
|
||||
|
||||
if ((ProfileManager.GetLockedProfile() != -1) && iPrimaryPlayer != -1) {
|
||||
if (((uiSignInData & (1 << iPrimaryPlayer)) == 0) ||
|
||||
bPrimaryPlayerChanged) {
|
||||
pApp->SetAction(iPrimaryPlayer, eAppAction_PrimaryPlayerSignedOut);
|
||||
pApp->InvalidateBannedList(iPrimaryPlayer);
|
||||
StorageManager.ClearDLCOffers();
|
||||
pApp->ClearAndResetDLCDownloadQueue();
|
||||
pApp->ClearDLCInstalled();
|
||||
} else {
|
||||
unsigned int uiChangedPlayers = uiSignInData ^ m_uiLastSignInData;
|
||||
|
||||
if (g_NetworkManager.IsInSession()) {
|
||||
bool hasGuestIdChanged = false;
|
||||
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
unsigned int guestNumber = 0;
|
||||
if (ProfileManager.IsSignedIn(i)) {
|
||||
XUSER_SIGNIN_INFO info;
|
||||
XUserGetSigninInfo(
|
||||
i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, &info);
|
||||
pApp->DebugPrintf(
|
||||
"Player at index %d has guest number %d\n", i,
|
||||
info.dwGuestNumber);
|
||||
guestNumber = info.dwGuestNumber;
|
||||
}
|
||||
if (pApp->m_networkController.m_currentSigninInfo[i]
|
||||
.dwGuestNumber != 0 &&
|
||||
guestNumber != 0 &&
|
||||
pApp->m_networkController.m_currentSigninInfo[i]
|
||||
.dwGuestNumber != guestNumber) {
|
||||
hasGuestIdChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasGuestIdChanged) {
|
||||
unsigned int uiIDA[1];
|
||||
uiIDA[0] = IDS_CONFIRM_OK;
|
||||
ui.RequestErrorMessage(IDS_GUEST_ORDER_CHANGED_TITLE,
|
||||
IDS_GUEST_ORDER_CHANGED_TEXT, uiIDA,
|
||||
1, ProfileManager.GetPrimaryPad());
|
||||
}
|
||||
|
||||
bool switchToOffline = false;
|
||||
if (!ProfileManager.IsSignedInLive(
|
||||
ProfileManager.GetLockedProfile()) &&
|
||||
!g_NetworkManager.IsLocalGame()) {
|
||||
switchToOffline = true;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
if (i == iPrimaryPlayer) continue;
|
||||
|
||||
if (hasGuestIdChanged &&
|
||||
pApp->m_networkController.m_currentSigninInfo[i]
|
||||
.dwGuestNumber != 0 &&
|
||||
g_NetworkManager.GetLocalPlayerByUserIndex(i) !=
|
||||
nullptr) {
|
||||
pApp->DebugPrintf(
|
||||
"Recommending removal of player at index %d "
|
||||
"because their guest id changed\n",
|
||||
i);
|
||||
pApp->SetAction(i, eAppAction_ExitPlayer);
|
||||
} else {
|
||||
XUSER_SIGNIN_INFO info;
|
||||
XUserGetSigninInfo(
|
||||
i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, &info);
|
||||
|
||||
bool bPlayerChanged =
|
||||
(uiChangedPlayers & (1 << i)) == (1 << i);
|
||||
bool bPlayerSignedIn = ((uiSignInData & (1 << i)) != 0);
|
||||
|
||||
if (bPlayerChanged &&
|
||||
(!bPlayerSignedIn ||
|
||||
(bPlayerSignedIn &&
|
||||
!ProfileManager.AreXUIDSEqual(
|
||||
pApp->m_networkController
|
||||
.m_currentSigninInfo[i]
|
||||
.xuid,
|
||||
info.xuid)))) {
|
||||
pApp->DebugPrintf(
|
||||
"Player at index %d Left - invalidating their "
|
||||
"banned list\n",
|
||||
i);
|
||||
pApp->InvalidateBannedList(i);
|
||||
|
||||
if (g_NetworkManager.GetLocalPlayerByUserIndex(i) !=
|
||||
nullptr ||
|
||||
Minecraft::GetInstance()->localplayers[i] !=
|
||||
nullptr) {
|
||||
pApp->DebugPrintf("Player %d signed out\n", i);
|
||||
pApp->SetAction(i, eAppAction_ExitPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (switchToOffline) {
|
||||
pApp->SetAction(iPrimaryPlayer,
|
||||
eAppAction_EthernetDisconnected);
|
||||
}
|
||||
|
||||
g_NetworkManager.HandleSignInChange();
|
||||
} else if (pApp->GetLiveLinkRequired() &&
|
||||
!ProfileManager.IsSignedInLive(
|
||||
ProfileManager.GetLockedProfile())) {
|
||||
{
|
||||
pApp->SetAction(iPrimaryPlayer,
|
||||
eAppAction_EthernetDisconnected);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_uiLastSignInData = uiSignInData;
|
||||
} else if (iPrimaryPlayer != -1) {
|
||||
pApp->InvalidateBannedList(iPrimaryPlayer);
|
||||
StorageManager.ClearDLCOffers();
|
||||
pApp->ClearAndResetDLCDownloadQueue();
|
||||
pApp->ClearDLCInstalled();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
if (FAILED(XUserGetSigninInfo(
|
||||
i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY,
|
||||
&pApp->m_networkController.m_currentSigninInfo[i]))) {
|
||||
pApp->m_networkController.m_currentSigninInfo[i].xuid =
|
||||
INVALID_XUID;
|
||||
pApp->m_networkController.m_currentSigninInfo[i].dwGuestNumber = 0;
|
||||
}
|
||||
app.DebugPrintf(
|
||||
"Player at index %d has guest number %d\n", i,
|
||||
pApp->m_networkController.m_currentSigninInfo[i].dwGuestNumber);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkController::notificationsCallback(void* pParam,
|
||||
std::uint32_t dwNotification,
|
||||
unsigned int uiParam) {
|
||||
Game* pClass = (Game*)pParam;
|
||||
|
||||
PNOTIFICATION pNotification = new NOTIFICATION;
|
||||
pNotification->dwNotification = dwNotification;
|
||||
pNotification->uiParam = uiParam;
|
||||
|
||||
switch (dwNotification) {
|
||||
case XN_SYS_SIGNINCHANGED: {
|
||||
pClass->DebugPrintf("Signing changed - %d\n", uiParam);
|
||||
} break;
|
||||
case XN_SYS_INPUTDEVICESCHANGED:
|
||||
if (app.GetGameStarted() && g_NetworkManager.IsInSession()) {
|
||||
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
if (!InputManager.IsPadConnected(i) &&
|
||||
Minecraft::GetInstance()->localplayers[i] != nullptr &&
|
||||
!ui.IsPauseMenuDisplayed(i) &&
|
||||
!ui.IsSceneInStack(i, eUIScene_EndPoem)) {
|
||||
ui.CloseUIScenes(i);
|
||||
ui.NavigateToScene(i, eUIScene_PauseMenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XN_LIVE_CONTENT_INSTALLED: {
|
||||
app.ClearDLCInstalled();
|
||||
ui.HandleDLCInstalled(ProfileManager.GetPrimaryPad());
|
||||
} break;
|
||||
case XN_SYS_STORAGEDEVICESCHANGED: {
|
||||
} break;
|
||||
}
|
||||
|
||||
pClass->m_networkController.m_vNotifications.push_back(pNotification);
|
||||
}
|
||||
|
||||
void NetworkController::liveLinkChangeCallback(void* pParam, bool bConnected) {
|
||||
// Implementation is platform-specific, stub here
|
||||
}
|
||||
|
||||
int NetworkController::exitAndJoinFromInvite(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
Game* pApp = (Game*)pParam;
|
||||
|
||||
if (result == C4JStorage::EMessage_ResultDecline) {
|
||||
pApp->SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NetworkController::exitAndJoinFromInviteSaveDialogReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
Game* pClass = (Game*)pParam;
|
||||
if (result == C4JStorage::EMessage_ResultDecline ||
|
||||
result == C4JStorage::EMessage_ResultThirdOption) {
|
||||
if (result == C4JStorage::EMessage_ResultDecline) {
|
||||
if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) {
|
||||
TexturePack* tPack =
|
||||
Minecraft::GetInstance()->skins->getSelected();
|
||||
DLCPack* pDLCPack = tPack->getDLCPack();
|
||||
if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture,
|
||||
L"")) {
|
||||
unsigned int uiIDA[2];
|
||||
uiIDA[0] = IDS_CONFIRM_OK;
|
||||
uiIDA[1] = IDS_CONFIRM_CANCEL;
|
||||
|
||||
ui.RequestErrorMessage(
|
||||
IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE,
|
||||
IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,
|
||||
&NetworkController::warningTrialTexturePackReturned,
|
||||
pClass);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
bool bSaveExists;
|
||||
StorageManager.DoesSaveExist(&bSaveExists);
|
||||
if (bSaveExists) {
|
||||
unsigned int uiIDA[2];
|
||||
uiIDA[0] = IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1] = IDS_CONFIRM_OK;
|
||||
ui.RequestErrorMessage(
|
||||
IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2,
|
||||
ProfileManager.GetPrimaryPad(),
|
||||
&NetworkController::exitAndJoinFromInviteAndSaveReturned,
|
||||
pClass);
|
||||
return 0;
|
||||
} else {
|
||||
MinecraftServer::getInstance()->setSaveOnExit(true);
|
||||
}
|
||||
} else {
|
||||
unsigned int uiIDA[2];
|
||||
uiIDA[0] = IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1] = IDS_CONFIRM_OK;
|
||||
ui.RequestErrorMessage(
|
||||
IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME,
|
||||
uiIDA, 2, ProfileManager.GetPrimaryPad(),
|
||||
&NetworkController::exitAndJoinFromInviteDeclineSaveReturned,
|
||||
pClass);
|
||||
return 0;
|
||||
}
|
||||
|
||||
app.SetAction(ProfileManager.GetPrimaryPad(),
|
||||
eAppAction_ExitAndJoinFromInviteConfirmed);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NetworkController::warningTrialTexturePackReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NetworkController::exitAndJoinFromInviteAndSaveReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
if (result == C4JStorage::EMessage_ResultDecline) {
|
||||
if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) {
|
||||
TexturePack* tPack = Minecraft::GetInstance()->skins->getSelected();
|
||||
DLCPack* pDLCPack = tPack->getDLCPack();
|
||||
if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture,
|
||||
L"")) {
|
||||
unsigned int uiIDA[2];
|
||||
uiIDA[0] = IDS_CONFIRM_OK;
|
||||
uiIDA[1] = IDS_CONFIRM_CANCEL;
|
||||
ui.RequestErrorMessage(
|
||||
IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE,
|
||||
IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,
|
||||
&NetworkController::warningTrialTexturePackReturned,
|
||||
nullptr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
MinecraftServer::getInstance()->setSaveOnExit(true);
|
||||
app.SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NetworkController::exitAndJoinFromInviteDeclineSaveReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result) {
|
||||
if (result == C4JStorage::EMessage_ResultDecline) {
|
||||
MinecraftServer::getInstance()->setSaveOnExit(false);
|
||||
app.SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
106
targets/app/common/NetworkController.h
Normal file
106
targets/app/common/NetworkController.h
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "platform/NetTypes.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "protocol/DisconnectPacket.h"
|
||||
|
||||
struct INVITE_INFO;
|
||||
|
||||
typedef struct _JoinFromInviteData {
|
||||
std::uint32_t dwUserIndex;
|
||||
std::uint32_t dwLocalUsersMask;
|
||||
const INVITE_INFO* pInviteInfo;
|
||||
} JoinFromInviteData;
|
||||
|
||||
class NetworkController {
|
||||
public:
|
||||
NetworkController();
|
||||
|
||||
// Player info
|
||||
void updatePlayerInfo(std::uint8_t networkSmallId,
|
||||
int16_t playerColourIndex,
|
||||
unsigned int playerGamePrivileges);
|
||||
short getPlayerColour(std::uint8_t networkSmallId);
|
||||
unsigned int getPlayerPrivileges(std::uint8_t networkSmallId);
|
||||
|
||||
// Sign-in change
|
||||
static void signInChangeCallback(void* pParam, bool bVal,
|
||||
unsigned int uiSignInData);
|
||||
static void clearSignInChangeUsersMask();
|
||||
static int signoutExitWorldThreadProc(void* lpParameter);
|
||||
static int primaryPlayerSignedOutReturned(void* pParam, int iPad,
|
||||
const C4JStorage::EMessageResult);
|
||||
static int ethernetDisconnectReturned(void* pParam, int iPad,
|
||||
const C4JStorage::EMessageResult);
|
||||
static void profileReadErrorCallback(void* pParam);
|
||||
|
||||
// Notifications
|
||||
static void notificationsCallback(void* pParam,
|
||||
std::uint32_t dwNotification,
|
||||
unsigned int uiParam);
|
||||
|
||||
// Ethernet/Live link
|
||||
static void liveLinkChangeCallback(void* pParam, bool bConnected);
|
||||
|
||||
// Invites
|
||||
void processInvite(std::uint32_t dwUserIndex,
|
||||
std::uint32_t dwLocalUsersMask,
|
||||
const INVITE_INFO* pInviteInfo);
|
||||
static int exitAndJoinFromInvite(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
static int exitAndJoinFromInviteSaveDialogReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
static int exitAndJoinFromInviteAndSaveReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
static int exitAndJoinFromInviteDeclineSaveReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
static int warningTrialTexturePackReturned(
|
||||
void* pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
|
||||
// Disconnect
|
||||
DisconnectPacket::eDisconnectReason getDisconnectReason() {
|
||||
return m_disconnectReason;
|
||||
}
|
||||
void setDisconnectReason(DisconnectPacket::eDisconnectReason bVal) {
|
||||
m_disconnectReason = bVal;
|
||||
}
|
||||
|
||||
// Session type flags
|
||||
bool getChangingSessionType() { return m_bChangingSessionType; }
|
||||
void setChangingSessionType(bool bVal) { m_bChangingSessionType = bVal; }
|
||||
bool getReallyChangingSessionType() { return m_bReallyChangingSessionType; }
|
||||
void setReallyChangingSessionType(bool bVal) {
|
||||
m_bReallyChangingSessionType = bVal;
|
||||
}
|
||||
|
||||
// Live link
|
||||
bool getLiveLinkRequired() { return m_bLiveLinkRequired; }
|
||||
void setLiveLinkRequired(bool required) { m_bLiveLinkRequired = required; }
|
||||
|
||||
// Sign-in info
|
||||
XUSER_SIGNIN_INFO m_currentSigninInfo[XUSER_MAX_COUNT];
|
||||
|
||||
// Invite data
|
||||
JoinFromInviteData m_InviteData;
|
||||
|
||||
// Notifications
|
||||
typedef std::vector<PNOTIFICATION> VNOTIFICATIONS;
|
||||
VNOTIFICATIONS m_vNotifications;
|
||||
VNOTIFICATIONS* getNotifications() { return &m_vNotifications; }
|
||||
|
||||
// Static sign-in data
|
||||
static unsigned int m_uiLastSignInData;
|
||||
|
||||
private:
|
||||
std::uint8_t m_playerColours[MINECRAFT_NET_MAX_PLAYERS];
|
||||
unsigned int m_playerGamePrivileges[MINECRAFT_NET_MAX_PLAYERS];
|
||||
|
||||
DisconnectPacket::eDisconnectReason m_disconnectReason;
|
||||
bool m_bChangingSessionType;
|
||||
bool m_bReallyChangingSessionType;
|
||||
bool m_bLiveLinkRequired;
|
||||
};
|
||||
|
|
@ -382,13 +382,13 @@ typedef struct _SignInInfo {
|
|||
} SignInInfo;
|
||||
|
||||
// Credits
|
||||
typedef struct {
|
||||
struct SCreditTextItemDef {
|
||||
const wchar_t* m_Text; // Should contain string, optionally with %s to add
|
||||
// in translated string ... e.g. "Andy West - %s"
|
||||
int m_iStringID[2]; // May be NO_TRANSLATED_STRING if we do not require to
|
||||
// add any translated string.
|
||||
ECreditTextTypes m_eType;
|
||||
} SCreditTextItemDef;
|
||||
};
|
||||
|
||||
// Message box
|
||||
typedef struct _MessageBoxInfo {
|
||||
|
|
|
|||
Loading…
Reference in a new issue