Allow using custom paths for win/lost scenes
parent
bd72086704
commit
250047579f
2
data
2
data
|
@ -1 +1 @@
|
||||||
Subproject commit 229394cda28955dfa6ec554c58365d11c647f55c
|
Subproject commit cbd7b5b46a2098b8d88a96370cc8d9aeb05a71f7
|
|
@ -30,10 +30,6 @@ const std::map<LevelCategory, std::string> CATEGORY_DIR_MAP = {
|
||||||
{ LevelCategory::Challenges, "challenges" },
|
{ LevelCategory::Challenges, "challenges" },
|
||||||
{ LevelCategory::CodeBattles, "battles" },
|
{ LevelCategory::CodeBattles, "battles" },
|
||||||
{ LevelCategory::CustomLevels, "custom" },
|
{ LevelCategory::CustomLevels, "custom" },
|
||||||
|
|
||||||
{ LevelCategory::Win, "win" },
|
|
||||||
{ LevelCategory::Lost, "lost" },
|
|
||||||
{ LevelCategory::Perso, "perso" },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string GetLevelCategoryDir(LevelCategory category)
|
std::string GetLevelCategoryDir(LevelCategory category)
|
||||||
|
|
|
@ -30,11 +30,6 @@ enum class LevelCategory
|
||||||
CodeBattles,
|
CodeBattles,
|
||||||
CustomLevels,
|
CustomLevels,
|
||||||
Max,
|
Max,
|
||||||
|
|
||||||
// These are special types not runnable by the user
|
|
||||||
Win,
|
|
||||||
Lost,
|
|
||||||
Perso,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string GetLevelCategoryDir(LevelCategory category);
|
std::string GetLevelCategoryDir(LevelCategory category);
|
||||||
|
|
|
@ -228,8 +228,6 @@ CRobotMain::CRobotMain()
|
||||||
m_tooltipName.clear();
|
m_tooltipName.clear();
|
||||||
m_tooltipTime = 0.0f;
|
m_tooltipTime = 0.0f;
|
||||||
|
|
||||||
m_endingWinRank = 0;
|
|
||||||
m_endingLostRank = 0;
|
|
||||||
m_winTerminate = false;
|
m_winTerminate = false;
|
||||||
|
|
||||||
m_globalMagnifyDamage = 1.0f;
|
m_globalMagnifyDamage = 1.0f;
|
||||||
|
@ -570,14 +568,14 @@ void CRobotMain::ChangePhase(Phase phase)
|
||||||
if (m_phase == PHASE_WIN)
|
if (m_phase == PHASE_WIN)
|
||||||
{
|
{
|
||||||
m_sound->StopAll();
|
m_sound->StopAll();
|
||||||
if (m_endingWinRank == -1)
|
if (m_endingWin.empty())
|
||||||
{
|
{
|
||||||
ChangePhase(PHASE_LEVEL_LIST);
|
ChangePhase(PHASE_LEVEL_LIST);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_winTerminate = (m_endingWinRank == 904);
|
m_winTerminate = (m_endingWin.substr(m_endingWin.find_last_of("/")+1) == "win904.txt");
|
||||||
SetLevel(LevelCategory::Win, 0, m_endingWinRank);
|
m_levelFile = m_endingWin;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateScene(false, true, false); // sets scene
|
CreateScene(false, true, false); // sets scene
|
||||||
|
@ -614,14 +612,14 @@ void CRobotMain::ChangePhase(Phase phase)
|
||||||
if (m_phase == PHASE_LOST)
|
if (m_phase == PHASE_LOST)
|
||||||
{
|
{
|
||||||
m_sound->StopAll();
|
m_sound->StopAll();
|
||||||
if (m_endingLostRank == -1)
|
if (m_endingLost.empty())
|
||||||
{
|
{
|
||||||
ChangePhase(PHASE_LEVEL_LIST);
|
ChangePhase(PHASE_LEVEL_LIST);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_winTerminate = false;
|
m_winTerminate = false;
|
||||||
SetLevel(LevelCategory::Lost, 0, m_endingLostRank);
|
m_levelFile = m_endingLost;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateScene(false, true, false); // sets scene
|
CreateScene(false, true, false); // sets scene
|
||||||
|
@ -2793,7 +2791,7 @@ void CRobotMain::ScenePerso()
|
||||||
m_lightMan->FlushLights();
|
m_lightMan->FlushLights();
|
||||||
m_particle->FlushParticle();
|
m_particle->FlushParticle();
|
||||||
|
|
||||||
SetLevel(LevelCategory::Perso, 0, 0);
|
m_levelFile = "levels/other/perso000.txt";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateScene(false, true, false); // sets scene
|
CreateScene(false, true, false); // sets scene
|
||||||
|
@ -2844,8 +2842,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
m_displayText->SetEnable(true);
|
m_displayText->SetEnable(true);
|
||||||
m_immediatSatCom = false;
|
m_immediatSatCom = false;
|
||||||
m_lockedSatCom = false;
|
m_lockedSatCom = false;
|
||||||
m_endingWinRank = 0;
|
m_endingWin = "";
|
||||||
m_endingLostRank = 0;
|
m_endingLost = "";
|
||||||
m_audioChange.clear();
|
m_audioChange.clear();
|
||||||
m_endTake.clear();
|
m_endTake.clear();
|
||||||
m_endTakeImmediat = false;
|
m_endTakeImmediat = false;
|
||||||
|
@ -2890,7 +2888,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
m_missionResultFromScript = false;
|
m_missionResultFromScript = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: Reset timer always, even when only resetting object positions
|
// NOTE: Reset timer always, even when only resetting object positions
|
||||||
m_missionTimerEnabled = false;
|
m_missionTimerEnabled = false;
|
||||||
m_missionTimerStarted = false;
|
m_missionTimerStarted = false;
|
||||||
m_missionTimer = 0.0f;
|
m_missionTimer = 0.0f;
|
||||||
|
@ -2905,7 +2903,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_ui->GetLoadingScreen()->SetProgress(0.05f, RT_LOADING_PROCESSING);
|
m_ui->GetLoadingScreen()->SetProgress(0.05f, RT_LOADING_PROCESSING);
|
||||||
CLevelParser levelParser(m_levelCategory, m_levelChap, m_levelRank);
|
GetLogger()->Info("Loading level: %s\n", m_levelFile.c_str());
|
||||||
|
CLevelParser levelParser(m_levelFile);
|
||||||
|
levelParser.SetLevelPaths(m_levelCategory, m_levelChap, m_levelRank);
|
||||||
levelParser.Load();
|
levelParser.Load();
|
||||||
int numObjects = levelParser.CountLines("CreateObject");
|
int numObjects = levelParser.CountLines("CreateObject");
|
||||||
m_ui->GetLoadingScreen()->SetProgress(0.1f, RT_LOADING_LEVEL_SETTINGS);
|
m_ui->GetLoadingScreen()->SetProgress(0.1f, RT_LOADING_LEVEL_SETTINGS);
|
||||||
|
@ -2913,11 +2913,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
int rankObj = 0;
|
int rankObj = 0;
|
||||||
CObject* sel = nullptr;
|
CObject* sel = nullptr;
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: Moving frequently used lines to the top
|
|
||||||
* may speed up loading
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (auto& line : levelParser.GetLines())
|
for (auto& line : levelParser.GetLines())
|
||||||
{
|
{
|
||||||
if (line->GetCommand() == "Title" && !resetObject)
|
if (line->GetCommand() == "Title" && !resetObject)
|
||||||
|
@ -2979,9 +2974,36 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
|
|
||||||
if (line->GetCommand() == "EndingFile" && !resetObject)
|
if (line->GetCommand() == "EndingFile" && !resetObject)
|
||||||
{
|
{
|
||||||
// NOTE: The old default was 0, but I think -1 is more correct - 0 means "ending file 000", while -1 means "no ending file"
|
auto Process = [&](const std::string& type) -> std::string
|
||||||
m_endingWinRank = line->GetParam("win")->AsInt(-1);
|
{
|
||||||
m_endingLostRank = line->GetParam("lost")->AsInt(-1);
|
if (line->GetParam(type)->IsDefined())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int rank = boost::lexical_cast<int>(line->GetParam(type)->GetValue());
|
||||||
|
if (rank >= 0)
|
||||||
|
{
|
||||||
|
GetLogger()->Warn("This level is using deprecated way of defining %1$s scene. Please change the %1$s= parameter in EndingFile from %2$d to \"levels/other/%1$s%2$03d.txt\".\n", type.c_str(), rank);
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "levels/other/" << type << std::setfill('0') << std::setw(3) << rank << ".txt";
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetLogger()->Warn("This level is using deprecated way of defining %1$s scene. Please remove the %1$s= parameter in EndingFile.\n", type.c_str());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (boost::bad_lexical_cast &e)
|
||||||
|
{
|
||||||
|
return line->GetParam(type)->AsPath("levels");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
m_endingWin = Process("win");
|
||||||
|
m_endingLost = Process("lost");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5288,9 +5310,11 @@ float CRobotMain::GetPersoAngle()
|
||||||
|
|
||||||
void CRobotMain::SetLevel(LevelCategory cat, int chap, int rank)
|
void CRobotMain::SetLevel(LevelCategory cat, int chap, int rank)
|
||||||
{
|
{
|
||||||
|
GetLogger()->Debug("Change level to %s %d %d\n", GetLevelCategoryDir(cat).c_str(), chap, rank);
|
||||||
m_levelCategory = cat;
|
m_levelCategory = cat;
|
||||||
m_levelChap = chap;
|
m_levelChap = chap;
|
||||||
m_levelRank = rank;
|
m_levelRank = rank;
|
||||||
|
m_levelFile = CLevelParser::BuildScenePath(m_levelCategory, m_levelChap, m_levelRank);
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelCategory CRobotMain::GetLevelCategory()
|
LevelCategory CRobotMain::GetLevelCategory()
|
||||||
|
|
|
@ -458,6 +458,8 @@ protected:
|
||||||
LevelCategory m_levelCategory;
|
LevelCategory m_levelCategory;
|
||||||
int m_levelChap = 0;
|
int m_levelChap = 0;
|
||||||
int m_levelRank = 0;
|
int m_levelRank = 0;
|
||||||
|
//! if set, loads this file instead of building from category/chap/rank
|
||||||
|
std::string m_levelFile = "";
|
||||||
std::string m_sceneReadPath;
|
std::string m_sceneReadPath;
|
||||||
|
|
||||||
float m_winDelay = 0.0f;
|
float m_winDelay = 0.0f;
|
||||||
|
@ -517,8 +519,8 @@ protected:
|
||||||
|
|
||||||
std::string m_scriptName = "";
|
std::string m_scriptName = "";
|
||||||
std::string m_scriptFile = "";
|
std::string m_scriptFile = "";
|
||||||
int m_endingWinRank = 0;
|
std::string m_endingWin = "";
|
||||||
int m_endingLostRank = 0;
|
std::string m_endingLost = "";
|
||||||
bool m_winTerminate = false;
|
bool m_winTerminate = false;
|
||||||
|
|
||||||
float m_globalMagnifyDamage = 0.0f;
|
float m_globalMagnifyDamage = 0.0f;
|
||||||
|
|
|
@ -47,7 +47,6 @@ namespace Ui
|
||||||
CScreenLevelList::CScreenLevelList(CMainDialog* mainDialog)
|
CScreenLevelList::CScreenLevelList(CMainDialog* mainDialog)
|
||||||
: m_dialog(mainDialog),
|
: m_dialog(mainDialog),
|
||||||
m_category{},
|
m_category{},
|
||||||
m_listCategory{},
|
|
||||||
m_sceneSoluce{false},
|
m_sceneSoluce{false},
|
||||||
m_maxList{0},
|
m_maxList{0},
|
||||||
m_accessChap{0}
|
m_accessChap{0}
|
||||||
|
@ -57,15 +56,6 @@ CScreenLevelList::CScreenLevelList(CMainDialog* mainDialog)
|
||||||
void CScreenLevelList::SetLevelCategory(LevelCategory category)
|
void CScreenLevelList::SetLevelCategory(LevelCategory category)
|
||||||
{
|
{
|
||||||
m_category = category;
|
m_category = category;
|
||||||
|
|
||||||
if ( static_cast<int>(m_category) >= static_cast<int>(LevelCategory::Max) )
|
|
||||||
{
|
|
||||||
m_category = m_listCategory;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_listCategory = m_category;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScreenLevelList::CreateInterface()
|
void CScreenLevelList::CreateInterface()
|
||||||
|
|
|
@ -63,7 +63,6 @@ protected:
|
||||||
Ui::CMainDialog* m_dialog;
|
Ui::CMainDialog* m_dialog;
|
||||||
|
|
||||||
LevelCategory m_category;
|
LevelCategory m_category;
|
||||||
LevelCategory m_listCategory;
|
|
||||||
|
|
||||||
bool m_sceneSoluce;
|
bool m_sceneSoluce;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue