diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/edit.cpp | 26 | ||||
-rw-r--r-- | src/ui/maindialog.cpp | 23 | ||||
-rw-r--r-- | src/ui/maindialog.h | 2 |
3 files changed, 31 insertions, 20 deletions
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index f9b7837..a0387bf 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -22,10 +22,13 @@ #include "clipboard/clipboard.h" +#include "object/robotmain.h" + #include "common/resources/inputstream.h" #include "common/resources/outputstream.h" #include <string.h> +#include <boost/algorithm/string.hpp> namespace Ui { @@ -784,14 +787,9 @@ void CEdit::HyperJump(std::string name, std::string marker) sMarker = marker; - if ( name[0] == '%' ) - { - filename = GetProfile().GetUserBasedPath(name, "") + ".txt"; - } - else - { - filename = name + std::string(".txt"); - } + filename = name + std::string(".txt"); + CRobotMain::InjectLevelDir(filename, "help/%lng%"); + boost::replace_all(filename, "\\", "/"); //TODO: Fix this in files if ( ReadText(filename) ) { @@ -1146,6 +1144,9 @@ void CEdit::DrawImage(Math::Point pos, std::string name, float width, std::string filename; filename = name + ".png"; + CRobotMain::InjectLevelDir(filename, "icons"); + boost::replace_all(filename, "\\", "/"); //TODO: Fix this in files + filename = "../" + filename; m_engine->SetTexture(filename); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); @@ -1434,7 +1435,9 @@ void CEdit::LoadImage(std::string name) { std::string filename; filename = name + ".png"; - m_engine->LoadTexture(filename); + CRobotMain::InjectLevelDir(filename, "icons"); + boost::replace_all(filename, "\\", "/"); //TODO: Fix this in files + m_engine->LoadTexture("../"+filename); } // Read from a text file. @@ -1449,13 +1452,14 @@ bool CEdit::ReadText(std::string filename, int addSize) InputSlot slot; bool bInSoluce, bBOL; - if ( filename[0] == 0 ) return false; + if ( filename == "" ) return false; CInputStream stream; - stream.open(filename); + stream.open(filename); if (!stream.is_open()) { + CLogger::GetInstancePointer()->Error("Failed to load text file %s\n", filename.c_str()); return false; } diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index fd6cd2e..068732d 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -3290,7 +3290,7 @@ void CMainDialog::SetUserDir(char *base, int rank) // Builds the file name of a mission. -void CMainDialog::BuildSceneName(std::string &filename, char *base, int rank) +void CMainDialog::BuildSceneName(std::string &filename, char *base, int rank, bool sceneFile) { //TODO: Support for more than 9 chapters int chapter = rank/100; @@ -3311,20 +3311,27 @@ void CMainDialog::BuildSceneName(std::string &filename, char *base, int rank) else if( strcmp(base, "win") == 0 || strcmp(base, "lost") == 0 ) { outstream << "levels/other/"; - outstream << base << std::setfill('0') << std::setw(3) << chapter << "/"; - outstream << "scene.txt"; - std::cout << outstream.str() << std::endl; + outstream << base << std::setfill('0') << std::setw(3) << rank << ".txt"; filename = outstream.str(); } else { outstream << "levels/" << base << "/"; outstream << "chapter" << std::setfill('0') << std::setw(3) << chapter << "/"; - if(new_rank == 000) { - outstream << "chaptertitle.txt"; - } else { + if(new_rank == 000) + { + if(sceneFile) + { + outstream << "chaptertitle.txt"; + } + } + else + { outstream << "level" << std::setfill('0') << std::setw(3) << new_rank << "/"; - outstream << "scene.txt"; + if(sceneFile) + { + outstream << "scene.txt"; + } } filename = outstream.str(); } diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index 7732f9f..cb26426 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -99,7 +99,7 @@ public: bool GetHimselfDamage(); void SetUserDir(char *base, int rank); - void BuildSceneName(std::string &filename, char *base, int rank); + void BuildSceneName(std::string &filename, char *base, int rank, bool sceneFile = true); void BuildResumeName(char *filename, char *base, int rank); std::string & GetFilesDir(); |