This commit is contained in:
ModMaker101 2026-03-05 15:16:58 +00:00 committed by GitHub
commit f43e7cc7b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 63 additions and 73 deletions

View file

@ -370,11 +370,9 @@ void UIScene_InGameSaveManagementMenu::GetSaveInfo( )
m_iSaveInfoC=0;
m_controlSavesTimer.setVisible(true);
m_pSaveDetails=StorageManager.ReturnSavesInfo();
if(m_pSaveDetails==NULL)
{
C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,NULL,this,"save");
}
// Always refresh the saves list to pick up newly created worlds
C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,NULL,this,"save");
m_pSaveDetails = nullptr; // Force refresh
return;

View file

@ -975,11 +975,9 @@ void UIScene_LoadOrJoinMenu::GetSaveInfo()
{
#ifdef __ORBIS__
// We need to make sure this is non-null so that we have an idea of free space
m_pSaveDetails=StorageManager.ReturnSavesInfo();
if(m_pSaveDetails==NULL)
{
C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,NULL,this,"save");
}
// Always refresh the saves list to pick up newly created worlds
C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,NULL,this,"save");
m_pSaveDetails = NULL; // Force refresh
#endif
uiSaveC = 0;
@ -1024,11 +1022,9 @@ void UIScene_LoadOrJoinMenu::GetSaveInfo()
m_iSaveInfoC=0;
m_controlSavesTimer.setVisible(true);
m_pSaveDetails=StorageManager.ReturnSavesInfo();
if(m_pSaveDetails==NULL)
{
C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,NULL,this,"save");
}
// Always refresh the saves list to pick up newly created worlds
C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,NULL,this,"save");
m_pSaveDetails = NULL; // Force refresh
#if TO_BE_IMPLEMENTED
if(eSGIStatus==C4JStorage::ESGIStatus_NoSaves)

View file

@ -44,18 +44,17 @@ void SelectWorldScreen::loadLevelList()
{
LevelStorageSource *levelSource = minecraft->getLevelSource();
levelList = levelSource->getLevelList();
// Collections.sort(levelList); // 4J - TODO - get sort functor etc.
selectedWorld = -1;
}
wstring SelectWorldScreen::getWorldId(int id)
{
return levelList->at(id)->getLevelId();
return levelList.at(id)->getLevelId();
}
wstring SelectWorldScreen::getWorldName(int id)
{
wstring levelName = levelList->at(id)->getLevelName();
wstring levelName = levelList.at(id)->getLevelName();
if ( levelName.length() == 0 )
{
@ -80,6 +79,9 @@ void SelectWorldScreen::postInit()
deleteButton->active = false;
renameButton->active = false;
// Refresh the world list in case new worlds were created
loadLevelList();
}
void SelectWorldScreen::buttonClicked(Button *button)
@ -190,7 +192,7 @@ void SelectWorldScreen::render(int xm, int ym, float a)
static bool forceCreateLevel = false;
if( count++ >= 100 )
{
if( !forceCreateLevel && levelList->size() > 0 )
if( !forceCreateLevel && levelList.size() > 0 )
{
// 4J Stu - For some obscures reason the "delete" button is called "renameButton" and vice versa.
//if( levelList->size() > 2 && deleteButton->active )
@ -200,7 +202,7 @@ void SelectWorldScreen::render(int xm, int ym, float a)
// buttonClicked(deleteButton);
//}
//else
if( levelList->size() > 1 && renameButton->active )
if( levelList.size() > 1 && renameButton->active )
{
this->selectedWorld = 1;
count = 0;
@ -235,7 +237,7 @@ SelectWorldScreen::WorldSelectionList::WorldSelectionList(SelectWorldScreen *sws
int SelectWorldScreen::WorldSelectionList::getNumberOfItems()
{
return (int)this->parent->levelList->size();
return static_cast<int>(this->parent->levelList.size());
}
void SelectWorldScreen::WorldSelectionList::selectItem(int item, bool doubleClick)
@ -259,7 +261,7 @@ bool SelectWorldScreen::WorldSelectionList::isSelectedItem(int item)
int SelectWorldScreen::WorldSelectionList::getMaxPosition()
{
return (int)parent->levelList->size() * 36;
return static_cast<int>(parent->levelList.size()) * 36;
}
void SelectWorldScreen::WorldSelectionList::renderBackground()
@ -269,7 +271,7 @@ void SelectWorldScreen::WorldSelectionList::renderBackground()
void SelectWorldScreen::WorldSelectionList::renderItem(int i, int x, int y, int h, Tesselator *t)
{
LevelSummary *levelSummary = parent->levelList->at(i);
LevelSummary *levelSummary = parent->levelList.at(i).get();
wstring name = levelSummary->getLevelName();
if (name.length()==0)

View file

@ -29,7 +29,7 @@ protected:
private:
bool done;
int selectedWorld;
vector<LevelSummary *> *levelList;
vector<shared_ptr<LevelSummary>> levelList;
WorldSelectionList *worldSelectionList;
wstring worldLang;
wstring conversionLang;

View file

@ -22,22 +22,9 @@ wstring DirectoryLevelStorageSource::getName()
return L"Old Format";
}
vector<LevelSummary *> *DirectoryLevelStorageSource::getLevelList()
vector<shared_ptr<LevelSummary>> DirectoryLevelStorageSource::getLevelList()
{
// 4J Stu - We don't use directory list with the Xbox save locations
vector<LevelSummary *> *levels = new vector<LevelSummary *>;
#if 0
for (int i = 0; i < 5; i++)
{
wstring levelId = wstring(L"World").append( _toString( (i+1) ) );
LevelData *levelData = getDataTagFor(saveFile, levelId);
if (levelData != NULL)
{
levels->push_back(new LevelSummary(levelId, L"", levelData->getLastPlayed(), levelData->getSizeOnDisk(), levelData.getGameType(), false, levelData->isHardcore()));
}
}
#endif
vector<shared_ptr<LevelSummary>> levels;
return levels;
}

View file

@ -16,7 +16,7 @@ protected:
public:
DirectoryLevelStorageSource(const File dir);
virtual wstring getName();
virtual vector<LevelSummary *> *getLevelList();
virtual vector<shared_ptr<LevelSummary>> getLevelList();
virtual void clearAll();
virtual LevelData *getDataTagFor(ConsoleSaveFile *saveFile, const wstring& levelId);
virtual void renameLevel(const wstring& levelId, const wstring& newLevelName);

View file

@ -14,7 +14,7 @@ class LevelStorageSource
public:
virtual wstring getName() = 0;
virtual shared_ptr<LevelStorage> selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir) = 0;
virtual vector<LevelSummary *> *getLevelList() = 0;
virtual vector<shared_ptr<LevelSummary>> getLevelList() = 0;
virtual void clearAll() = 0;
virtual LevelData *getDataTagFor(ConsoleSaveFile *saveFile, const wstring& levelId) = 0;

View file

@ -12,6 +12,7 @@
#include "McRegionLevelStorage.h"
#include "File.h"
#include "LevelData.h"
#include "LevelSettings.h"
#include "McRegionLevelStorageSource.h"
#include "ConsoleSaveFileIO.h"
@ -32,42 +33,48 @@ wstring McRegionLevelStorageSource::getName()
return L"Scaevolus' McRegion";
}
vector<LevelSummary *> *McRegionLevelStorageSource::getLevelList()
vector<shared_ptr<LevelSummary>> McRegionLevelStorageSource::getLevelList()
{
// 4J Stu - We don't need to do directory lookups with the xbox save files
vector<LevelSummary *> *levels = new vector<LevelSummary *>;
#if 0
vector<File *> *subFolders = baseDir.listFiles();
File *file;
AUTO_VAR(itEnd, subFolders->end());
for (AUTO_VAR(it, subFolders->begin()); it != itEnd; it++)
{
file = *it; //subFolders->at(i);
vector<shared_ptr<LevelSummary>> levels;
if (file->isDirectory())
{
continue;
}
const unique_ptr<vector<File*>> subFolders(baseDir.listFiles());
if (subFolders)
{
for (const File* file : *subFolders)
{
if (file->isDirectory())
continue;
wstring levelId = file->getName();
wstring levelId = file->getName();
LevelData *levelData = getDataTagFor(levelId);
if (levelData != NULL)
{
bool requiresConversion = levelData->getVersion() != McRegionLevelStorage::MCREGION_VERSION_ID;
wstring levelName = levelData->getLevelName();
shared_ptr<LevelData> levelData(getDataTagFor(nullptr, levelId));
if (levelData)
{
bool requiresConversion = levelData->getVersion() != McRegionLevelStorage::MCREGION_VERSION_ID;
wstring levelName = levelData->getLevelName();
if (levelName.empty()) // 4J Jev TODO: levelName can't be NULL? if (levelName == NULL || isEmpty(levelName))
{
levelName = levelId;
}
// long size = getLevelSize(folder);
long size = 0;
levels->push_back(new LevelSummary(levelId, levelName, levelData->getLastPlayed(), size, requiresConversion, levelData->isHardcore()));
}
}
#endif
return levels;
if (levelName.empty())
levelName = levelId;
long size = 0;
GameType* gameType = levelData->getGameType();
if (gameType == nullptr)
gameType = GameType::SURVIVAL;
levels.push_back(make_shared<LevelSummary>(
levelId,
levelName,
levelData->getLastPlayed(),
size,
gameType,
requiresConversion,
levelData->isHardcore(),
false));
}
}
}
return levels;
}
void McRegionLevelStorageSource::clearAll()

View file

@ -15,7 +15,7 @@ public:
McRegionLevelStorageSource(File dir);
virtual wstring getName();
virtual vector<LevelSummary *> *getLevelList();
virtual vector<shared_ptr<LevelSummary>> getLevelList();
virtual void clearAll();
virtual shared_ptr<LevelStorage> selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir);
virtual bool isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId);