summaryrefslogtreecommitdiff
path: root/src/gui/helpwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-06-19 01:31:14 +0300
committerAndrei Karas <akaras@inbox.ru>2012-06-19 01:33:40 +0300
commite9c84384d8d0e5b91678eb4722ae30bd3693703f (patch)
tree6f30e3d8500f9b0c4620a6c5393df498a04c0a0c /src/gui/helpwindow.cpp
parent0a068a5f08b1805d5b385b8f81aaf3c7199bff06 (diff)
downloadmanaplus-e9c84384d8d0e5b91678eb4722ae30bd3693703f.tar.gz
manaplus-e9c84384d8d0e5b91678eb4722ae30bd3693703f.tar.bz2
manaplus-e9c84384d8d0e5b91678eb4722ae30bd3693703f.tar.xz
manaplus-e9c84384d8d0e5b91678eb4722ae30bd3693703f.zip
Add help search commands (?text).
Example: ?warps It will open help page about warps.
Diffstat (limited to 'src/gui/helpwindow.cpp')
-rw-r--r--src/gui/helpwindow.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index 82a70bca9..c2b0d873f 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -80,6 +80,7 @@ HelpWindow::HelpWindow():
layout.setRowHeight(0, Layout::AUTO_SET);
loadWindowState();
+ loadTags();
}
void HelpWindow::action(const gcn::ActionEvent &event)
@@ -120,3 +121,56 @@ void HelpWindow::loadFile(const std::string &file)
for (unsigned int i = 0; i < lines.size(); ++i)
mBrowserBox->addRow(lines[i]);
}
+
+void HelpWindow::loadTags()
+{
+ std::string helpPath = branding.getStringValue("helpPath");
+ if (helpPath.empty())
+ helpPath = paths.getStringValue("help");
+ StringVect lines;
+ ResourceManager::loadTextFile(helpPath + "tags.idx", lines);
+ for (StringVectCIter it = lines.begin(), it_end = lines.end();
+ it != it_end; ++ it)
+ {
+ const std::string &str = *it;
+ size_t idx = str.find('|');
+ if (idx != std::string::npos)
+ mTagFileMap[str.substr(idx + 1)].insert(str.substr(0, idx));
+ }
+}
+
+void HelpWindow::search(const std::string &text0)
+{
+ std::string text = text0;
+ toLower(text);
+ if (mTagFileMap.find(text) == mTagFileMap.end())
+ {
+ loadHelp("searchnotfound");
+ }
+ else
+ {
+ const HelpNames &names = mTagFileMap[text];
+ if (names.size() == 1)
+ {
+ loadHelp(*names.begin());
+ }
+ else
+ {
+ if (!translator)
+ return;
+ mBrowserBox->clearRows();
+ loadFile("header");
+ loadFile("searchmany");
+ for (HelpNamesCIter it = names.begin(), it_end = names.end();
+ it != it_end; ++ it)
+ {
+ const char *str = (*it).c_str();
+ mBrowserBox->addRow(strprintf(" -> @@%s|%s@@", str,
+ translator->getChar(str)));
+ }
+ loadFile("footer");
+ mScrollArea->setVerticalScrollAmount(0);
+ setVisible(true);
+ }
+ }
+}