This is an automated email from the git hooks/post-receive script. odyx pushed a commit to branch upstream/latest in repository colobot.
commit d2d0886b769d4561628ed009caa056bb8234a0ba Author: krzys-h <krzy...@interia.pl> Date: Sun Mar 22 13:51:14 2015 +0100 Implemented %cat% and renamed BuildSceneName to BuildScenePath --- src/common/pathman.cpp | 8 ++++---- src/object/level/parser.cpp | 25 +++++++++++++++++++------ src/object/level/parser.h | 4 +++- src/object/robotmain.cpp | 4 ++-- src/object/robotmain.h | 2 +- src/ui/maindialog.cpp | 6 +++--- src/ui/maindialog.h | 2 +- 7 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/common/pathman.cpp b/src/common/pathman.cpp index 51e7e7d..2fbb35f 100644 --- a/src/common/pathman.cpp +++ b/src/common/pathman.cpp @@ -172,16 +172,16 @@ 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::BuildSceneName(CRobotMain::GetInstancePointer()->GetSceneName(), CRobotMain::GetInstancePointer()->GetSceneRank()/100, CRobotMain::GetInstancePointer()->GetSceneRank()%100, false); + std::string lvlDir = CLevelParser::BuildScenePath(CRobotMain::GetInstancePointer()->GetSceneName(), CRobotMain::GetInstancePointer()->GetSceneRank()/100, CRobotMain::GetInstancePointer()->GetSceneRank()%100, false); boost::replace_all(newPath, "%lvl%", lvlDir); - std::string chapDir = CLevelParser::BuildSceneName(CRobotMain::GetInstancePointer()->GetSceneName(), CRobotMain::GetInstancePointer()->GetSceneRank()/100, 0, false); + std::string chapDir = CLevelParser::BuildScenePath(CRobotMain::GetInstancePointer()->GetSceneName(), CRobotMain::GetInstancePointer()->GetSceneRank()/100, 0, false); boost::replace_all(newPath, "%chap%", chapDir); + std::string catDir = CLevelParser::BuildCategoryPath(CRobotMain::GetInstancePointer()->GetSceneName()); + boost::replace_all(newPath, "%cat%", catDir); if(newPath == path && !path.empty()) { newPath = defaultDir + (!defaultDir.empty() ? "/" : "") + newPath; } - - //TODO: %cat% std::string langPath = newPath; std::string langStr(1, CApplication::GetInstancePointer()->GetLanguageChar()); diff --git a/src/object/level/parser.cpp b/src/object/level/parser.cpp index 7c612af..5b36f46 100644 --- a/src/object/level/parser.cpp +++ b/src/object/level/parser.cpp @@ -51,7 +51,7 @@ CLevelParser::CLevelParser(std::string filename) CLevelParser::CLevelParser(std::string category, int chapter, int rank) { - m_filename = BuildSceneName(category, chapter, rank); + m_filename = BuildScenePath(category, chapter, rank); } CLevelParser::~CLevelParser() @@ -62,12 +62,27 @@ CLevelParser::~CLevelParser() } } -std::string CLevelParser::BuildSceneName(std::string category, int chapter, int rank, bool sceneFile) +std::string CLevelParser::BuildCategoryPath(std::string category) { std::ostringstream outstream; + outstream << "levels/"; + if(category == "perso" || category == "win" || category == "lost") + { + outstream << "other/"; + } + else + { + outstream << category << "/"; + } + return outstream.str(); +} + +std::string CLevelParser::BuildScenePath(std::string category, int chapter, int rank, bool sceneFile) +{ + std::ostringstream outstream; + outstream << BuildCategoryPath(category); if(category == "custom") { - outstream << "levels/custom/"; outstream << CRobotMain::GetInstancePointer()->GetUserLevelName(chapter); if(rank == 000) { @@ -87,16 +102,14 @@ std::string CLevelParser::BuildSceneName(std::string category, int chapter, int } else if(category == "perso") { - outstream << "levels/other/perso.txt"; + outstream << "perso.txt"; } else if(category == "win" || category == "lost") { - outstream << "levels/other/"; outstream << category << std::setfill('0') << std::setw(3) << chapter*100+rank << ".txt"; } else { - outstream << "levels/" << category << "/"; outstream << "chapter" << std::setfill('0') << std::setw(3) << chapter; if(rank == 000) { diff --git a/src/object/level/parser.h b/src/object/level/parser.h index e0458b5..fc3b99f 100644 --- a/src/object/level/parser.h +++ b/src/object/level/parser.h @@ -43,8 +43,10 @@ public: ~CLevelParser(); + //! Build category path + static std::string BuildCategoryPath(std::string category); //! Build level filename - static std::string BuildSceneName(std::string category, int chapter, int rank, bool sceneFile = true); + static std::string BuildScenePath(std::string category, int chapter, int rank, bool sceneFile = true); //! Check if level file exists bool Exists(); diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index caee647..2ff278c 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -5850,9 +5850,9 @@ int CRobotMain::GetSceneRank() return m_dialog->GetSceneRank(); } -void CRobotMain::BuildSceneName(std::string &filename, char *base, int rank, bool sceneFile) +void CRobotMain::BuildScenePath(std::string &filename, char *base, int rank, bool sceneFile) { - m_dialog->BuildSceneName(filename, base, rank, sceneFile); + m_dialog->BuildScenePath(filename, base, rank, sceneFile); } diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 9c4281c..e1be529 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -293,7 +293,7 @@ public: float GetPersoAngle(); char* GetSceneName(); int GetSceneRank(); - void BuildSceneName(std::string &filename, char *base, int rank, bool sceneFile = true); + void BuildScenePath(std::string &filename, char *base, int rank, bool sceneFile = true); void StartMusic(); void StartPauseMusic(PauseType pause); diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index aeccc0f..75cfe48 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -3339,13 +3339,13 @@ void CMainDialog::NiceParticle(Math::Point mouse, bool bPress) // Builds the file name of a mission. -void CMainDialog::BuildSceneName(std::string &filename, char *base, int rank, bool sceneFile) +void CMainDialog::BuildScenePath(std::string &filename, char *base, int rank, bool sceneFile) { //TODO: Support for more than 9 chapters int chapter = rank/100; int new_rank = rank%100; - filename = CLevelParser::BuildSceneName(std::string(base), chapter, new_rank, sceneFile); + filename = CLevelParser::BuildScenePath(std::string(base), chapter, new_rank, sceneFile); } // Built the default descriptive name of a mission. @@ -3983,7 +3983,7 @@ void CMainDialog::IOReadName() //TODO: CLevelParser sprintf(resume, "%s %d", m_sceneName, m_chap[m_index]+1); - BuildSceneName(filename, m_sceneName, (m_chap[m_index]+1)*100); + BuildScenePath(filename, m_sceneName, (m_chap[m_index]+1)*100); sprintf(op, "Title.E"); sprintf(op_i18n, "Title.%c", m_app->GetLanguageChar() ); diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index 9d69e59..402b852 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -98,7 +98,7 @@ public: bool GetNiceReset(); bool GetHimselfDamage(); - void BuildSceneName(std::string &filename, char *base, int rank, bool sceneFile = true); + void BuildScenePath(std::string &filename, char *base, int rank, bool sceneFile = true); void BuildResumeName(char *filename, char *base, int rank); std::string & GetFilesDir(); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git _______________________________________________ Pkg-games-commits mailing list Pkg-games-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits