summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-23 17:43:47 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-23 17:43:47 +0000
commit33587089cf7d87bbc2104e80746fdddc7a5498e1 (patch)
treec748b8312f41cb7a63591161d1356c437350418d
parent919f87fd15fb02b4b20bf0061f49c55b527af3e4 (diff)
downloadmana-33587089cf7d87bbc2104e80746fdddc7a5498e1.tar.gz
mana-33587089cf7d87bbc2104e80746fdddc7a5498e1.tar.bz2
mana-33587089cf7d87bbc2104e80746fdddc7a5498e1.tar.xz
mana-33587089cf7d87bbc2104e80746fdddc7a5498e1.zip
Help files are now loaded through the resource manager.
-rw-r--r--src/gui/help.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index a842d42e..5a5f42cc 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -26,7 +26,7 @@
#include "button.h"
#include "textbox.h"
#include "../main.h"
-#include <fstream>
+#include "../resources/resourcemanager.h"
HelpWindow::HelpWindow():
Window("Help")
@@ -86,23 +86,28 @@ void HelpWindow::loadHelp(const std::string &helpFile)
void HelpWindow::loadFile(const std::string &file)
{
- std::string filePath = TMW_DATADIR "data/help/" + file + ".txt";
+ ResourceManager *resman = ResourceManager::getInstance();
+ const std::string filePath = "help/" + file + ".txt";
+ int contentsLength;
+ char *fileContents = (char*)resman->loadFile(filePath, contentsLength);
- std::ifstream fin;
- fin.open(filePath.c_str());
-
- if (fin.fail())
+ if (!fileContents)
{
logger->log("Couldn't load help file: %s", filePath.c_str());
return;
}
- while (!fin.eof())
+ // 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)
{
- std::string line = "";
- getline(fin, line);
browserBox->addRow(line);
+ line = strtok(NULL, "\n");
}
- fin.close();
+ free(fileContents);
}