diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-07-15 23:43:22 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-07-15 23:43:22 +0000 |
commit | 9cea91975451a7abb6f15e08f7fb6c20efed152c (patch) | |
tree | ddf2aaf22597d8fa63a33dd62a57cb50e083f7e3 /src/gui/help.cpp | |
parent | 97cac06ae12026f4be3765f68b0aea3caf02d8f0 (diff) | |
download | mana-9cea91975451a7abb6f15e08f7fb6c20efed152c.tar.gz mana-9cea91975451a7abb6f15e08f7fb6c20efed152c.tar.bz2 mana-9cea91975451a7abb6f15e08f7fb6c20efed152c.tar.xz mana-9cea91975451a7abb6f15e08f7fb6c20efed152c.zip |
Fixed compiler warnings and added plain text file loading to resource manager.
Diffstat (limited to 'src/gui/help.cpp')
-rw-r--r-- | src/gui/help.cpp | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/src/gui/help.cpp b/src/gui/help.cpp index cff36da8..3ff8f0f4 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -87,27 +87,11 @@ void HelpWindow::loadHelp(const std::string &helpFile) void HelpWindow::loadFile(const std::string &file) { ResourceManager *resman = ResourceManager::getInstance(); - const std::string filePath = "help/" + file + ".txt"; - int contentsLength; - char *fileContents = (char*)resman->loadFile(filePath, contentsLength); + std::vector<std::string> lines = + resman->loadTextFile("help/" + file + ".txt"); - if (!fileContents) + for (unsigned int i = 0; i < lines.size(); ++i) { - logger->log("Couldn't load help file: %s", filePath.c_str()); - return; + browserBox->addRow(lines[i]); } - - // Reallocate and include terminating 0 character - fileContents = (char*)realloc(fileContents, contentsLength + 1); - fileContents[contentsLength] = '\0'; - - // Tokenize and add each line separately - char *line = strtok(fileContents, "\n"); - while (line != NULL) - { - browserBox->addRow(line); - line = strtok(NULL, "\n"); - } - - free(fileContents); } |