Finished support for up to 999 chapters and levels
parent
ea9361fbb4
commit
86f473ac16
|
@ -65,8 +65,7 @@ void CController::StartApp()
|
|||
|
||||
void CController::StartGame(LevelCategory cat, int chap, int lvl)
|
||||
{
|
||||
m_dialog->SetLevelCategory(cat);
|
||||
m_dialog->SetLevelRank(chap*100+lvl);
|
||||
m_dialog->SetLevel(cat, chap, lvl);
|
||||
m_main->ChangePhase(PHASE_LOADING);
|
||||
}
|
||||
|
||||
|
|
|
@ -172,9 +172,9 @@ void CPathManager::LoadModsFromDir(const std::string &dir)
|
|||
std::string CPathManager::InjectLevelDir(std::string path, const std::string& defaultDir)
|
||||
{
|
||||
std::string newPath = path;
|
||||
std::string lvlDir = CLevelParser::BuildScenePath(CRobotMain::GetInstancePointer()->GetLevelCategory(), CRobotMain::GetInstancePointer()->GetLevelRank()/100, CRobotMain::GetInstancePointer()->GetLevelRank()%100, false);
|
||||
std::string lvlDir = CLevelParser::BuildScenePath(CRobotMain::GetInstancePointer()->GetLevelCategory(), CRobotMain::GetInstancePointer()->GetLevelChap(), CRobotMain::GetInstancePointer()->GetLevelRank(), false);
|
||||
boost::replace_all(newPath, "%lvl%", lvlDir);
|
||||
std::string chapDir = CLevelParser::BuildScenePath(CRobotMain::GetInstancePointer()->GetLevelCategory(), CRobotMain::GetInstancePointer()->GetLevelRank()/100, 0, false);
|
||||
std::string chapDir = CLevelParser::BuildScenePath(CRobotMain::GetInstancePointer()->GetLevelCategory(), CRobotMain::GetInstancePointer()->GetLevelChap(), 0, false);
|
||||
boost::replace_all(newPath, "%chap%", chapDir);
|
||||
std::string catDir = CLevelParser::BuildCategoryPath(CRobotMain::GetInstancePointer()->GetLevelCategory());
|
||||
boost::replace_all(newPath, "%cat%", catDir);
|
||||
|
|
|
@ -87,7 +87,7 @@ std::string CLevelParser::BuildScenePath(std::string category, int chapter, int
|
|||
if (category == "custom")
|
||||
{
|
||||
outstream << CRobotMain::GetInstancePointer()->GetCustomLevelName(chapter);
|
||||
if (rank == 000)
|
||||
if (rank == 0)
|
||||
{
|
||||
if (sceneFile)
|
||||
{
|
||||
|
@ -105,11 +105,14 @@ std::string CLevelParser::BuildScenePath(std::string category, int chapter, int
|
|||
}
|
||||
else if (category == "perso")
|
||||
{
|
||||
assert(chapter == 0);
|
||||
assert(rank == 0);
|
||||
outstream << "perso.txt";
|
||||
}
|
||||
else if (category == "win" || category == "lost")
|
||||
{
|
||||
outstream << category << std::setfill('0') << std::setw(3) << chapter*100 + rank << ".txt";
|
||||
assert(chapter == 0);
|
||||
outstream << category << std::setfill('0') << std::setw(3) << rank << ".txt";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -442,17 +442,19 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
|
||||
if (m_gameTime > 10.0f) // did you play at least 10 seconds?
|
||||
{
|
||||
int chap = m_dialog->GetLevelChap();
|
||||
int rank = m_dialog->GetLevelRank();
|
||||
int numTry = m_dialog->GetGamerInfoTry(rank);
|
||||
m_dialog->SetGamerInfoTry(rank, numTry+1);
|
||||
int numTry = m_dialog->GetGamerInfoTry(chap, rank);
|
||||
m_dialog->SetGamerInfoTry(chap, rank, numTry+1);
|
||||
m_dialog->WriteGamerInfo();
|
||||
}
|
||||
}
|
||||
|
||||
if (phase == PHASE_WIN) // wins a simulation?
|
||||
{
|
||||
int chap = m_dialog->GetLevelChap();
|
||||
int rank = m_dialog->GetLevelRank();
|
||||
m_dialog->SetGamerInfoPassed(rank, true);
|
||||
m_dialog->SetGamerInfoPassed(chap, rank, true);
|
||||
m_dialog->NextMission(); // passes to the next mission
|
||||
m_dialog->WriteGamerInfo();
|
||||
}
|
||||
|
@ -591,8 +593,7 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
else
|
||||
{
|
||||
m_winTerminate = (m_endingWinRank == 904);
|
||||
m_dialog->SetLevelCategory(LevelCategory::Win);
|
||||
m_dialog->SetLevelRank(m_endingWinRank);
|
||||
m_dialog->SetLevel(LevelCategory::Win, 0, m_endingWinRank);
|
||||
try
|
||||
{
|
||||
CreateScene(false, true, false); // sets scene
|
||||
|
@ -638,8 +639,7 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
else
|
||||
{
|
||||
m_winTerminate = false;
|
||||
m_dialog->SetLevelCategory(LevelCategory::Lost);
|
||||
m_dialog->SetLevelRank(m_endingLostRank);
|
||||
m_dialog->SetLevel(LevelCategory::Lost, 0, m_endingLostRank);
|
||||
try
|
||||
{
|
||||
CreateScene(false, true, false); // sets scene
|
||||
|
@ -2831,8 +2831,7 @@ void CRobotMain::ScenePerso()
|
|||
ChangeColor();
|
||||
|
||||
|
||||
m_dialog->SetLevelCategory(LevelCategory::Perso);
|
||||
m_dialog->SetLevelRank(0);
|
||||
m_dialog->SetLevel(LevelCategory::Perso, 0, 0);
|
||||
try
|
||||
{
|
||||
CreateScene(false, true, false); // sets scene
|
||||
|
@ -2860,6 +2859,7 @@ void CRobotMain::ScenePerso()
|
|||
void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||
{
|
||||
LevelCategory category = m_dialog->GetLevelCategory();
|
||||
int chap = m_dialog->GetLevelChap();
|
||||
int rank = m_dialog->GetLevelRank();
|
||||
const char* read = m_dialog->GetSceneRead().c_str();
|
||||
const char* stack = m_dialog->GetStackRead().c_str();
|
||||
|
@ -2938,8 +2938,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
m_engine->SetSecondTexture("");
|
||||
m_engine->SetForegroundName("");
|
||||
|
||||
m_dialog->BuildResumeName(m_title, GetLevelCategoryDir(category), rank);
|
||||
m_dialog->BuildResumeName(m_resume, GetLevelCategoryDir(category), rank);
|
||||
m_dialog->BuildResumeName(m_title, GetLevelCategoryDir(category), chap, rank);
|
||||
m_dialog->BuildResumeName(m_resume, GetLevelCategoryDir(category), chap, rank);
|
||||
std::string scriptNameStr;
|
||||
GetResource(RES_TEXT, RT_SCRIPT_NEW, scriptNameStr);
|
||||
strcpy(m_scriptName, scriptNameStr.c_str());
|
||||
|
@ -2961,7 +2961,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
|
||||
try
|
||||
{
|
||||
CLevelParser levelParser(category, rank/100, rank%100);
|
||||
CLevelParser levelParser(category, chap, rank);
|
||||
levelParser.Load();
|
||||
|
||||
int rankObj = 0;
|
||||
|
@ -4604,6 +4604,7 @@ void CRobotMain::LoadOneScript(CObject *obj, int &nbError)
|
|||
if (objRank == -1) return;
|
||||
|
||||
char categoryChar = GetLevelCategoryDir(m_dialog->GetLevelCategory())[0];
|
||||
int chap = m_dialog->GetLevelChap();
|
||||
int rank = m_dialog->GetLevelRank();
|
||||
|
||||
for (unsigned int i = 0; i <= 999; i++)
|
||||
|
@ -4611,8 +4612,8 @@ void CRobotMain::LoadOneScript(CObject *obj, int &nbError)
|
|||
//? if (brain->GetCompile(i)) continue;
|
||||
|
||||
char filename[MAX_FNAME];
|
||||
sprintf(filename, "%s/%s/%c%.3d%.3d%.3d.txt",
|
||||
GetSavegameDir(), m_gamerName.c_str(), categoryChar, rank, objRank, i);
|
||||
sprintf(filename, "%s/%s/%c%.3d%.3d%.3d%.3d.txt",
|
||||
GetSavegameDir(), m_gamerName.c_str(), categoryChar, chap, rank, objRank, i);
|
||||
|
||||
if (CResourceManager::Exists(filename))
|
||||
{
|
||||
|
@ -4678,6 +4679,7 @@ void CRobotMain::SaveOneScript(CObject *obj)
|
|||
if (objRank == -1) return;
|
||||
|
||||
char categoryChar = GetLevelCategoryDir(m_dialog->GetLevelCategory())[0];
|
||||
int chap = m_dialog->GetLevelChap();
|
||||
int rank = m_dialog->GetLevelRank();
|
||||
|
||||
auto& programs = brain->GetPrograms();
|
||||
|
@ -4685,8 +4687,8 @@ void CRobotMain::SaveOneScript(CObject *obj)
|
|||
for (unsigned int i = 0; i <= 999; i++)
|
||||
{
|
||||
char filename[MAX_FNAME];
|
||||
sprintf(filename, "%s/%s/%c%.3d%.3d%.3d.txt",
|
||||
GetSavegameDir(), m_gamerName.c_str(), categoryChar, rank, objRank, i);
|
||||
sprintf(filename, "%s/%s/%c%.3d%.3d%.3d%.3d.txt",
|
||||
GetSavegameDir(), m_gamerName.c_str(), categoryChar, chap, rank, objRank, i);
|
||||
if (i < programs.size())
|
||||
{
|
||||
brain->WriteProgram(programs[i].get(), filename);
|
||||
|
@ -4915,14 +4917,13 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
|||
line->AddParam("date", MakeUnique<CLevelParserParam>(GetCurrentTimestamp()));
|
||||
levelParser.AddLine(std::move(line));
|
||||
|
||||
char* name = m_dialog->GetSceneName();
|
||||
line = MakeUnique<CLevelParserLine>("Mission");
|
||||
line->AddParam("base", MakeUnique<CLevelParserParam>(std::string(name)));
|
||||
line->AddParam("rank", MakeUnique<CLevelParserParam>(m_dialog->GetSceneRank()));
|
||||
if (std::string(name) == "custom")
|
||||
{
|
||||
line->AddParam("dir", MakeUnique<CLevelParserParam>(std::string(m_dialog->GetSceneDir())));
|
||||
}
|
||||
line->AddParam("base", MakeUnique<CLevelParserParam>(GetLevelCategoryDir(m_dialog->GetLevelCategory())));
|
||||
if (m_dialog->GetLevelCategory() == LevelCategory::CustomLevels)
|
||||
line->AddParam("dir", MakeUnique<CLevelParserParam>(m_dialog->GetCustomLevelDir()));
|
||||
else
|
||||
line->AddParam("chap", MakeUnique<CLevelParserParam>(m_dialog->GetLevelChap()));
|
||||
line->AddParam("rank", MakeUnique<CLevelParserParam>(m_dialog->GetLevelRank()));
|
||||
levelParser.AddLine(std::move(line));
|
||||
|
||||
line = MakeUnique<CLevelParserLine>("Map");
|
||||
|
@ -5747,6 +5748,11 @@ LevelCategory CRobotMain::GetLevelCategory()
|
|||
return m_dialog->GetLevelCategory();
|
||||
}
|
||||
|
||||
int CRobotMain::GetLevelChap()
|
||||
{
|
||||
return m_dialog->GetLevelChap();
|
||||
}
|
||||
|
||||
int CRobotMain::GetLevelRank()
|
||||
{
|
||||
return m_dialog->GetLevelRank();
|
||||
|
|
|
@ -264,7 +264,9 @@ public:
|
|||
int GetGamerGlasses();
|
||||
bool GetGamerOnlyHead();
|
||||
float GetPersoAngle();
|
||||
|
||||
LevelCategory GetLevelCategory();
|
||||
int GetLevelChap();
|
||||
int GetLevelRank();
|
||||
|
||||
void StartMusic();
|
||||
|
|
|
@ -130,7 +130,8 @@ CMainDialog::CMainDialog()
|
|||
m_phaseTerm = PHASE_TRAINER;
|
||||
m_sceneRead[0] = 0;
|
||||
m_stackRead[0] = 0;
|
||||
m_sceneRank = 0;
|
||||
m_levelChap = 0;
|
||||
m_levelRank = 0;
|
||||
m_bSceneSoluce = false;
|
||||
m_bSimulSetup = false;
|
||||
|
||||
|
@ -854,7 +855,7 @@ void CMainDialog::ChangePhase(Phase phase)
|
|||
}
|
||||
m_bSceneSoluce = false;
|
||||
|
||||
UpdateSceneResume((m_chap[m_category]+1)*100+(m_sel[m_category]+1));
|
||||
UpdateSceneResume(m_chap[m_category]+1, m_sel[m_category]+1);
|
||||
|
||||
if ( m_phase == PHASE_MISSION ||
|
||||
m_phase == PHASE_FREE ||
|
||||
|
@ -2245,14 +2246,14 @@ bool CMainDialog::EventProcess(const Event &event)
|
|||
if ( pl == 0 ) break;
|
||||
m_chap[m_category] = pl->GetSelect();
|
||||
UpdateSceneList(m_chap[m_category], m_sel[m_category]);
|
||||
UpdateSceneResume((m_chap[m_category]+1)*100+(m_sel[m_category]+1));
|
||||
UpdateSceneResume(m_chap[m_category]+1, m_sel[m_category]+1);
|
||||
break;
|
||||
|
||||
case EVENT_INTERFACE_LIST:
|
||||
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_LIST));
|
||||
if ( pl == 0 ) break;
|
||||
m_sel[m_category] = pl->GetSelect();
|
||||
UpdateSceneResume((m_chap[m_category]+1)*100+(m_sel[m_category]+1));
|
||||
UpdateSceneResume(m_chap[m_category]+1, m_sel[m_category]+1);
|
||||
break;
|
||||
|
||||
case EVENT_INTERFACE_SOLUCE:
|
||||
|
@ -2263,7 +2264,8 @@ bool CMainDialog::EventProcess(const Event &event)
|
|||
break;
|
||||
|
||||
case EVENT_INTERFACE_PLAY:
|
||||
m_sceneRank = (m_chap[m_category]+1)*100+(m_sel[m_category]+1);
|
||||
m_levelChap = m_chap[m_category]+1;
|
||||
m_levelRank = m_sel[m_category]+1;
|
||||
m_phaseTerm = m_phase;
|
||||
m_main->ChangePhase(PHASE_LOADING);
|
||||
break;
|
||||
|
@ -3353,9 +3355,9 @@ void CMainDialog::NiceParticle(Math::Point mouse, bool bPress)
|
|||
|
||||
// Built the default descriptive name of a mission.
|
||||
|
||||
void CMainDialog::BuildResumeName(char *filename, std::string base, int rank)
|
||||
void CMainDialog::BuildResumeName(char *filename, std::string base, int chap, int rank)
|
||||
{
|
||||
sprintf(filename, "Scene %s %d", base.c_str(), rank);
|
||||
sprintf(filename, "%s %d.%d", base.c_str(), chap, rank);
|
||||
}
|
||||
|
||||
// Returns the name of the file or save the files.
|
||||
|
@ -4213,7 +4215,7 @@ bool CMainDialog::IOReadScene()
|
|||
{
|
||||
CWindow* pw;
|
||||
CList* pl;
|
||||
int sel, i;
|
||||
int sel;
|
||||
|
||||
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
|
||||
if ( pw == nullptr ) return false;
|
||||
|
@ -4234,29 +4236,42 @@ bool CMainDialog::IOReadScene()
|
|||
|
||||
CLevelParserLine* line = levelParser.Get("Mission");
|
||||
m_category = GetLevelCategoryFromDir(line->GetParam("base")->AsString());
|
||||
m_sceneRank = line->GetParam("rank")->AsInt();
|
||||
|
||||
m_levelRank = line->GetParam("rank")->AsInt();
|
||||
if (m_category == LevelCategory::CustomLevels)
|
||||
{
|
||||
m_sceneRank = m_sceneRank%100;
|
||||
|
||||
m_levelChap = 0;
|
||||
std::string dir = line->GetParam("dir")->AsString();
|
||||
for ( i=0 ; i<m_userTotal ; i++ )
|
||||
for (unsigned int i = 0; i < m_customLevelList.size(); i++)
|
||||
{
|
||||
if ( m_userList[i] == dir )
|
||||
if (m_customLevelList[i] == dir)
|
||||
{
|
||||
m_sceneRank += (i+1)*100;
|
||||
m_levelChap = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( m_sceneRank/100 == 0 )
|
||||
if (m_levelChap == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(line->GetParam("chap")->IsDefined())
|
||||
{
|
||||
m_levelChap = line->GetParam("chap")->AsInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Backwards combatibility
|
||||
int rank = line->GetParam("rank")->AsInt();
|
||||
m_levelChap = rank/100;
|
||||
m_levelRank = rank%100;
|
||||
}
|
||||
}
|
||||
|
||||
m_chap[m_category] = (m_sceneRank / 100)-1;
|
||||
m_sel[m_category] = (m_sceneRank % 100)-1;
|
||||
m_chap[m_category] = m_levelChap-1;
|
||||
m_sel[m_category] = m_levelRank-1;
|
||||
|
||||
m_sceneRead = fileName;
|
||||
m_stackRead = fileCbot;
|
||||
|
@ -4268,18 +4283,16 @@ bool CMainDialog::IOReadScene()
|
|||
|
||||
int CMainDialog::GetChapPassed()
|
||||
{
|
||||
int j;
|
||||
if ( m_main->GetShowAll() ) return MAXSCENE;
|
||||
|
||||
if ( m_main->GetShowAll() ) return 9;
|
||||
|
||||
for ( j=0 ; j<9 ; j++ )
|
||||
for ( int j = 1; j <= MAXSCENE; j++ )
|
||||
{
|
||||
if ( !GetGamerInfoPassed((j+1)*100) )
|
||||
if ( !GetGamerInfoPassed(j, 0) )
|
||||
{
|
||||
return j;
|
||||
}
|
||||
}
|
||||
return 9;
|
||||
return MAXSCENE;
|
||||
}
|
||||
|
||||
// Updates the lists according to the cheat code.
|
||||
|
@ -4306,7 +4319,6 @@ void CMainDialog::UpdateSceneChap(int &chap)
|
|||
|
||||
std::string fileName;
|
||||
char line[500];
|
||||
int j;
|
||||
bool bPassed;
|
||||
|
||||
memset(line, 0, 500);
|
||||
|
@ -4318,15 +4330,14 @@ void CMainDialog::UpdateSceneChap(int &chap)
|
|||
|
||||
pl->Flush();
|
||||
|
||||
unsigned int j;
|
||||
if ( m_phase == PHASE_USER )
|
||||
{
|
||||
j = 0;
|
||||
auto userLevelDirs = CResourceManager::ListDirectories("levels/custom/");
|
||||
std::sort(userLevelDirs.begin(), userLevelDirs.end());
|
||||
m_userList = userLevelDirs;
|
||||
m_userTotal = m_userList.size();
|
||||
m_customLevelList = userLevelDirs;
|
||||
|
||||
for ( j=0 ; j<m_userTotal ; j++ )
|
||||
for ( j=0 ; j<m_customLevelList.size() ; j++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -4344,7 +4355,7 @@ void CMainDialog::UpdateSceneChap(int &chap)
|
|||
}
|
||||
else
|
||||
{
|
||||
for ( j=0 ; j<9 ; j++ )
|
||||
for ( j=0 ; j<MAXSCENE ; j++ )
|
||||
{
|
||||
CLevelParser levelParser(m_category, j+1, 0);
|
||||
if (!levelParser.Exists())
|
||||
|
@ -4359,7 +4370,7 @@ void CMainDialog::UpdateSceneChap(int &chap)
|
|||
sprintf(line, "%s", (std::string("[ERROR]: ")+e.what()).c_str());
|
||||
}
|
||||
|
||||
bPassed = GetGamerInfoPassed((j+1)*100);
|
||||
bPassed = GetGamerInfoPassed(j+1, 0);
|
||||
pl->SetItemName(j, line);
|
||||
pl->SetCheck(j, bPassed);
|
||||
pl->SetEnable(j, true);
|
||||
|
@ -4407,7 +4418,7 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
|
|||
if (chap < 0) return;
|
||||
|
||||
bool readAll = true;
|
||||
for ( j=0 ; j<99 ; j++ )
|
||||
for ( j=0 ; j<MAXSCENE ; j++ )
|
||||
{
|
||||
CLevelParser levelParser(m_category, chap+1, j+1);
|
||||
if (!levelParser.Exists())
|
||||
|
@ -4430,7 +4441,7 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
|
|||
sprintf(line, "%s", (std::string("[ERROR]: ")+e.what()).c_str());
|
||||
}
|
||||
|
||||
bPassed = GetGamerInfoPassed((chap+1)*100+(j+1));
|
||||
bPassed = GetGamerInfoPassed(chap+1, j+1);
|
||||
pl->SetItemName(j, line);
|
||||
pl->SetCheck(j, bPassed);
|
||||
pl->SetEnable(j, true);
|
||||
|
@ -4496,7 +4507,7 @@ void CMainDialog::ShowSoluceUpdate()
|
|||
|
||||
// Updates a summary of exercise or mission.
|
||||
|
||||
void CMainDialog::UpdateSceneResume(int rank)
|
||||
void CMainDialog::UpdateSceneResume(int chap, int rank)
|
||||
{
|
||||
CWindow* pw;
|
||||
CEdit* pe;
|
||||
|
@ -4517,8 +4528,8 @@ void CMainDialog::UpdateSceneResume(int rank)
|
|||
}
|
||||
else
|
||||
{
|
||||
numTry = GetGamerInfoTry(rank);
|
||||
bPassed = GetGamerInfoPassed(rank);
|
||||
numTry = GetGamerInfoTry(chap, rank);
|
||||
bPassed = GetGamerInfoPassed(chap, rank);
|
||||
bVisible = ( numTry > 2 || bPassed || m_main->GetShowSoluce() );
|
||||
if ( !GetSoluce4() ) bVisible = false;
|
||||
pc->SetState(STATE_VISIBLE, bVisible);
|
||||
|
@ -4529,11 +4540,11 @@ void CMainDialog::UpdateSceneResume(int rank)
|
|||
}
|
||||
}
|
||||
|
||||
if (rank<100) return;
|
||||
if(chap == 0) return;
|
||||
|
||||
try
|
||||
{
|
||||
CLevelParser levelParser(m_category, rank/100, rank%100);
|
||||
CLevelParser levelParser(m_category, chap, rank);
|
||||
levelParser.Load();
|
||||
pe->SetText(levelParser.Get("Resume")->GetParam("text")->AsString().c_str());
|
||||
}
|
||||
|
@ -5898,44 +5909,35 @@ std::string & CMainDialog::GetStackRead()
|
|||
return m_stackRead;
|
||||
}
|
||||
|
||||
// Specifies the name of the chosen to play scene.
|
||||
|
||||
void CMainDialog::SetLevelCategory(LevelCategory category)
|
||||
void CMainDialog::SetLevel(LevelCategory cat, int chap, int rank)
|
||||
{
|
||||
m_category = category;
|
||||
m_category = cat;
|
||||
m_levelChap = chap;
|
||||
m_levelRank = rank;
|
||||
}
|
||||
|
||||
// Returns the name of the chosen to play scene.
|
||||
|
||||
LevelCategory CMainDialog::GetLevelCategory()
|
||||
{
|
||||
return m_category;
|
||||
}
|
||||
|
||||
// Specifies the rank of the chosen to play scene.
|
||||
|
||||
void CMainDialog::SetLevelRank(int rank)
|
||||
int CMainDialog::GetLevelChap()
|
||||
{
|
||||
m_sceneRank = rank;
|
||||
return m_levelChap;
|
||||
}
|
||||
|
||||
// Returns the rank of the chosen to play scene.
|
||||
|
||||
int CMainDialog::GetLevelRank()
|
||||
{
|
||||
return m_sceneRank;
|
||||
return m_levelRank;
|
||||
}
|
||||
|
||||
// Returns folder name of the scene that user selected to play.
|
||||
|
||||
const char* CMainDialog::GetCustomLevelDir()
|
||||
std::string CMainDialog::GetCustomLevelDir()
|
||||
{
|
||||
int i;
|
||||
|
||||
i = (m_sceneRank/100)-1;
|
||||
|
||||
if ( i < 0 || i >= m_userTotal ) return 0;
|
||||
return m_userList[i].c_str();
|
||||
if (m_levelChap-1 < 0 || m_levelChap-1 >= m_customLevelList.size()) return "";
|
||||
return m_customLevelList[m_levelChap-1];
|
||||
}
|
||||
|
||||
// Whether to show the solution.
|
||||
|
@ -6115,13 +6117,8 @@ Gfx::Color CMainDialog::GetGamerColorBand()
|
|||
bool CMainDialog::ReadGamerInfo()
|
||||
{
|
||||
std::string line;
|
||||
int chap, i, numTry, passed;
|
||||
|
||||
for ( i=0 ; i<MAXSCENE ; i++ )
|
||||
{
|
||||
m_sceneInfo[i].numTry = 0;
|
||||
m_sceneInfo[i].bPassed = false;
|
||||
}
|
||||
m_sceneInfo.clear();
|
||||
|
||||
if (!CResourceManager::Exists(GetSavegameDir()+"/"+m_main->GetGamerName()+"/"+GetLevelCategoryDir(m_category)+".gam"))
|
||||
return false;
|
||||
|
@ -6135,9 +6132,10 @@ bool CMainDialog::ReadGamerInfo()
|
|||
}
|
||||
|
||||
std::getline(file, line);
|
||||
sscanf(line.c_str(), "CurrentChapter=%d CurrentSel=%d\n", &chap, &i);
|
||||
int chap, rank;
|
||||
sscanf(line.c_str(), "CurrentChapter=%d CurrentSel=%d\n", &chap, &rank);
|
||||
m_chap[m_category] = chap-1;
|
||||
m_sel[m_category] = i-1;
|
||||
m_sel[m_category] = rank-1;
|
||||
|
||||
while (!file.eof())
|
||||
{
|
||||
|
@ -6148,15 +6146,15 @@ bool CMainDialog::ReadGamerInfo()
|
|||
break;
|
||||
}
|
||||
|
||||
int numTry, passed;
|
||||
sscanf(line.c_str(), "Chapter %d: Scene %d: numTry=%d passed=%d\n",
|
||||
&chap, &i, &numTry, &passed);
|
||||
&chap, &rank, &numTry, &passed);
|
||||
|
||||
i += chap*100;
|
||||
if ( i >= 0 && i < MAXSCENE )
|
||||
{
|
||||
m_sceneInfo[i].numTry = numTry;
|
||||
m_sceneInfo[i].bPassed = passed;
|
||||
}
|
||||
if ( chap < 0 || chap > MAXSCENE ) continue;
|
||||
if ( rank < 0 || rank > MAXSCENE ) continue;
|
||||
|
||||
m_sceneInfo[chap][rank].numTry = numTry;
|
||||
m_sceneInfo[chap][rank].bPassed = passed;
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
@ -6167,8 +6165,6 @@ bool CMainDialog::ReadGamerInfo()
|
|||
|
||||
bool CMainDialog::WriteGamerInfo()
|
||||
{
|
||||
int i;
|
||||
|
||||
COutputStream file;
|
||||
file.open(GetSavegameDir()+"/"+m_main->GetGamerName()+"/"+GetLevelCategoryDir(m_category)+".gam");
|
||||
if (!file.is_open())
|
||||
|
@ -6179,55 +6175,59 @@ bool CMainDialog::WriteGamerInfo()
|
|||
|
||||
file << "CurrentChapter=" << m_chap[m_category]+1 << " CurrentSel=" << m_sel[m_category]+1 << "\n";
|
||||
|
||||
for ( i=0 ; i<MAXSCENE ; i++ )
|
||||
for ( int i=0 ; i<MAXSCENE ; i++ )
|
||||
{
|
||||
if ( m_sceneInfo[i].numTry == 0 && !m_sceneInfo[i].bPassed ) continue;
|
||||
if (m_sceneInfo.find(i) == m_sceneInfo.end()) continue;
|
||||
for ( int j=0 ; j<MAXSCENE ; j++ )
|
||||
{
|
||||
if (m_sceneInfo[i].find(j) == m_sceneInfo[i].end()) continue;
|
||||
if ( m_sceneInfo[i][j].numTry == 0 && !m_sceneInfo[i][j].bPassed ) continue;
|
||||
|
||||
file << "Chapter " << i/100 << ": Scene " << i%100 << ": numTry=" << m_sceneInfo[i].numTry << " passed=" << (m_sceneInfo[i].bPassed ? "1" : "0") << "\n";
|
||||
file << "Chapter " << i << ": Scene " << j << ": numTry=" << m_sceneInfo[i][j].numTry << " passed=" << (m_sceneInfo[i][j].bPassed ? "1" : "0") << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMainDialog::SetGamerInfoTry(int rank, int numTry)
|
||||
void CMainDialog::SetGamerInfoTry(int chap, int rank, int numTry)
|
||||
{
|
||||
if ( rank < 0 || rank >= MAXSCENE ) return;
|
||||
if ( numTry > 100 ) numTry = 100;
|
||||
m_sceneInfo[rank].numTry = numTry;
|
||||
if ( chap < 0 || chap > MAXSCENE ) return;
|
||||
if ( rank < 0 || rank > MAXSCENE ) return;
|
||||
m_sceneInfo[chap][rank].numTry = numTry;
|
||||
}
|
||||
|
||||
int CMainDialog::GetGamerInfoTry(int rank)
|
||||
int CMainDialog::GetGamerInfoTry(int chap, int rank)
|
||||
{
|
||||
if ( rank < 0 || rank >= MAXSCENE ) return 0;
|
||||
return m_sceneInfo[rank].numTry;
|
||||
if ( chap < 0 || chap > MAXSCENE ) return 0;
|
||||
if ( rank < 0 || rank > MAXSCENE ) return 0;
|
||||
return m_sceneInfo[chap][rank].numTry;
|
||||
}
|
||||
|
||||
void CMainDialog::SetGamerInfoPassed(int rank, bool bPassed)
|
||||
void CMainDialog::SetGamerInfoPassed(int chap, int rank, bool bPassed)
|
||||
{
|
||||
int chap, i;
|
||||
bool bAll;
|
||||
|
||||
if ( rank < 0 || rank >= MAXSCENE ) return;
|
||||
m_sceneInfo[rank].bPassed = bPassed;
|
||||
if ( chap < 0 || chap > MAXSCENE ) return;
|
||||
if ( rank < 0 || rank > MAXSCENE ) return;
|
||||
m_sceneInfo[chap][rank].bPassed = bPassed;
|
||||
|
||||
if ( bPassed )
|
||||
{
|
||||
bAll = true;
|
||||
chap = rank/100;
|
||||
for ( i=0 ; i<m_maxList ; i++ )
|
||||
bool bAll = true;
|
||||
for ( int i=0 ; i<m_maxList ; i++ )
|
||||
{
|
||||
bAll &= m_sceneInfo[chap*100+i+1].bPassed;
|
||||
bAll &= m_sceneInfo[chap][i+1].bPassed;
|
||||
}
|
||||
m_sceneInfo[chap*100].numTry ++;
|
||||
m_sceneInfo[chap*100].bPassed = bAll;
|
||||
m_sceneInfo[chap][0].numTry ++;
|
||||
m_sceneInfo[chap][0].bPassed = bAll;
|
||||
}
|
||||
}
|
||||
|
||||
bool CMainDialog::GetGamerInfoPassed(int rank)
|
||||
bool CMainDialog::GetGamerInfoPassed(int chap, int rank)
|
||||
{
|
||||
if ( rank < 0 || rank >= MAXSCENE ) return false;
|
||||
return m_sceneInfo[rank].bPassed;
|
||||
if ( chap < 0 || chap > MAXSCENE ) return false;
|
||||
if ( rank < 0 || rank > MAXSCENE ) return false;
|
||||
return m_sceneInfo[chap][rank].bPassed;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6248,7 +6248,7 @@ bool CMainDialog::NextMission()
|
|||
|
||||
std::string& CMainDialog::GetCustomLevelName(int id)
|
||||
{
|
||||
return m_userList[id-1];
|
||||
return m_customLevelList[id-1];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
// maindialog.h
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
@ -49,7 +46,7 @@ class CControl;
|
|||
|
||||
|
||||
const int USERLISTMAX = 100;
|
||||
const int MAXSCENE = 1000;
|
||||
const int MAXSCENE = 999;
|
||||
|
||||
|
||||
struct SceneInfo
|
||||
|
@ -85,12 +82,12 @@ public:
|
|||
void SetStackRead(const char* name);
|
||||
std::string & GetStackRead();
|
||||
|
||||
void SetLevelCategory(LevelCategory category);
|
||||
void SetLevel(LevelCategory cat, int chap, int rank);
|
||||
LevelCategory GetLevelCategory();
|
||||
void SetLevelRank(int rank);
|
||||
int GetLevelChap();
|
||||
int GetLevelRank();
|
||||
std::string GetCustomLevelDir();
|
||||
|
||||
const char* GetCustomLevelDir();
|
||||
bool GetSceneSoluce();
|
||||
std::string & GetSavegameDir();
|
||||
std::string & GetPublicDir();
|
||||
|
@ -102,7 +99,7 @@ public:
|
|||
bool GetNiceReset();
|
||||
bool GetHimselfDamage();
|
||||
|
||||
void BuildResumeName(char *filename, std::string base, int rank);
|
||||
void BuildResumeName(char *filename, std::string base, int chap, int rank);
|
||||
std::string & GetFilesDir();
|
||||
|
||||
void StartAbort();
|
||||
|
@ -122,10 +119,10 @@ public:
|
|||
|
||||
bool ReadGamerInfo();
|
||||
bool WriteGamerInfo();
|
||||
void SetGamerInfoTry(int rank, int numTry);
|
||||
int GetGamerInfoTry(int rank);
|
||||
void SetGamerInfoPassed(int rank, bool bPassed);
|
||||
bool GetGamerInfoPassed(int rank);
|
||||
void SetGamerInfoTry(int chap, int rank, int numTry);
|
||||
int GetGamerInfoTry(int chap, int rank);
|
||||
void SetGamerInfoPassed(int chap, int rank, bool bPassed);
|
||||
bool GetGamerInfoPassed(int chap, int rank);
|
||||
bool NextMission();
|
||||
|
||||
void WriteGamerPerso(char *gamer);
|
||||
|
@ -174,7 +171,7 @@ protected:
|
|||
int GetChapPassed();
|
||||
void UpdateSceneChap(int &chap);
|
||||
void UpdateSceneList(int chap, int &sel);
|
||||
void UpdateSceneResume(int rank);
|
||||
void UpdateSceneResume(int chap, int rank);
|
||||
void UpdateDisplayMode();
|
||||
void ChangeDisplay();
|
||||
void UpdateApply();
|
||||
|
@ -216,7 +213,8 @@ protected:
|
|||
int m_accessChap;
|
||||
std::string m_sceneRead; // name of the scene to read
|
||||
std::string m_stackRead; // name of the scene to read
|
||||
int m_sceneRank; // rank of the scene to play
|
||||
int m_levelChap; // chapter of the level to play
|
||||
int m_levelRank; // rank of the level to play
|
||||
bool m_bSceneSoluce; // shows the solution
|
||||
bool m_bSimulSetup; // adjustment during the game
|
||||
bool m_accessEnable;
|
||||
|
@ -224,9 +222,7 @@ protected:
|
|||
bool m_accessUser;
|
||||
bool m_bDeleteGamer;
|
||||
|
||||
int m_userTotal;
|
||||
|
||||
std::vector<std::string> m_userList;
|
||||
std::vector<std::string> m_customLevelList;
|
||||
|
||||
int m_shotDelay; // number of frames before copy
|
||||
std::string m_shotName; // generate a file name
|
||||
|
@ -267,7 +263,7 @@ protected:
|
|||
float m_partiTime[10];
|
||||
Math::Point m_partiPos[10];
|
||||
|
||||
SceneInfo m_sceneInfo[MAXSCENE];
|
||||
std::map<int, std::map<int, SceneInfo>> m_sceneInfo;
|
||||
|
||||
std::vector<std::string> m_saveList;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue