summaryrefslogtreecommitdiff
path: root/src/gui/widgets/browserbox.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-12 20:11:09 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-12 20:20:59 +0300
commitaeec9ca9881bbd4fdc332b342b09a795ee3961b4 (patch)
tree3e32a1dd828464a7e6e8c439f658421772a62f40 /src/gui/widgets/browserbox.cpp
parent36027fc87b99b8f048265f6ac470227a1c32d481 (diff)
downloadplus-aeec9ca9881bbd4fdc332b342b09a795ee3961b4.tar.gz
plus-aeec9ca9881bbd4fdc332b342b09a795ee3961b4.tar.bz2
plus-aeec9ca9881bbd4fdc332b342b09a795ee3961b4.tar.xz
plus-aeec9ca9881bbd4fdc332b342b09a795ee3961b4.zip
add ability to show assigned keys in browserbox.
Example: This is chat modifier key: ###ChatMod;. If chat mod key is left shift, it will show: "This is chat modifier key: left shift."
Diffstat (limited to 'src/gui/widgets/browserbox.cpp')
-rw-r--r--src/gui/widgets/browserbox.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index ff269d384..6527019de 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -24,6 +24,7 @@
#include "gui/widgets/browserbox.h"
#include "client.h"
+#include "inputmanager.h"
#include "gui/gui.h"
#include "gui/sdlfont.h"
@@ -67,6 +68,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, const unsigned int mode,
mAlwaysUpdate(true),
mProcessVersion(false),
mEnableImages(false),
+ mEnableKeys(false),
mPadding(0),
mNewLinePadding(15),
mBackgroundColor(getThemeColor(Theme::BACKGROUND)),
@@ -157,8 +159,26 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
BrowserLink bLink;
// Check for links in format "@@link|Caption@@"
- idx1 = tmp.find("@@");
const int sz = static_cast<int>(mTextRows.size());
+
+ if (mEnableKeys)
+ {
+ idx1 = tmp.find("###");
+ while (idx1 != std::string::npos)
+ {
+ const size_t idx2 = tmp.find(";", idx1);
+ if (idx2 == std::string::npos)
+ break;
+
+ const std::string str = inputManager.getKeyValueByName(
+ "key" + tmp.substr(idx1 + 3, idx2 - idx1 - 3));
+ tmp.replace(idx1, idx2 - idx1 + 1, str);
+
+ idx1 = tmp.find("###");
+ }
+ }
+
+ idx1 = tmp.find("@@");
while (idx1 != std::string::npos)
{
const size_t idx2 = tmp.find("|", idx1);