diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-12-15 22:23:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-12-15 22:23:26 +0300 |
commit | f03edb38328aa5ddb48e10198621bf2353096440 (patch) | |
tree | a7fe17c3e7ceee0f646663d115273852c632e0dd /src/gui/windows/updaterwindow.cpp | |
parent | d0cdad7bf81a07ba4b2f13c73a65fe1c68bb702f (diff) | |
download | ManaVerse-f03edb38328aa5ddb48e10198621bf2353096440.tar.gz ManaVerse-f03edb38328aa5ddb48e10198621bf2353096440.tar.bz2 ManaVerse-f03edb38328aa5ddb48e10198621bf2353096440.tar.xz ManaVerse-f03edb38328aa5ddb48e10198621bf2353096440.zip |
in updater window cut news to 50 lines and show link to full news.
Diffstat (limited to 'src/gui/windows/updaterwindow.cpp')
-rw-r--r-- | src/gui/windows/updaterwindow.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 9c9a3adab..36cdba6dd 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -329,8 +329,11 @@ void UpdaterWindow::loadNews() std::stringstream ss(mMemoryBuffer); std::string line; file.open(newsName.c_str(), std::ios::out); + int cnt = 0; + const int maxNews = 50; while (std::getline(ss, line, '\n')) { + cnt ++; if (firstLine) { firstLine = false; @@ -340,17 +343,25 @@ void UpdaterWindow::loadNews() if (file.is_open()) file << line << std::endl; - mBrowserBox->addRow(line); + if (cnt < maxNews) + mBrowserBox->addRow(line); } else { if (file.is_open()) file << line << std::endl; - mBrowserBox->addRow(line); + if (cnt < maxNews) + mBrowserBox->addRow(line); } } file.close(); + if (cnt > maxNews) + { + mBrowserBox->addRow(""); + mBrowserBox->addRow("news", _("Show all news (can be slow)")); + mBrowserBox->addRow(""); + } // Free the memory buffer now that we don't need it anymore free(mMemoryBuffer); mMemoryBuffer = nullptr; @@ -944,5 +955,24 @@ void UpdaterWindow::handleLink(const std::string &link, gcn::MouseEvent *event A_UNUSED) { if (strStartWith(link, "http://") || strStartWith(link, "https://")) + { openBrowser(link); + } + else if (link == "news") + { + loadFile("news"); + } +} + +void UpdaterWindow::loadFile(std::string file) +{ + mBrowserBox->clearRows(); + trim(file); + + StringVect lines; + ResourceManager::getInstance()->loadTextFileLocal( + mUpdatesDir + "/local/help/news.txt", lines); + + for (size_t i = 0, sz = lines.size(); i < sz; ++i) + mBrowserBox->addRow(lines[i]); } |