summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-13 15:53:07 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-13 15:53:07 +0300
commit5dee954413c553513d65039f0e594d01e3b227ea (patch)
tree7a2ea13834f5f9947783f1124a6e0512e03c0d43 /src/gui
parent9b578956b8cdcba74b731a78ffdf7e26b335a03d (diff)
downloadmanaverse-5dee954413c553513d65039f0e594d01e3b227ea.tar.gz
manaverse-5dee954413c553513d65039f0e594d01e3b227ea.tar.bz2
manaverse-5dee954413c553513d65039f0e594d01e3b227ea.tar.xz
manaverse-5dee954413c553513d65039f0e594d01e3b227ea.zip
Add support for tabulation to fixed browserbox rows.
Command: /tN; where N is number or characters in line. Example: "test\t10;line" will be converted into "test line"
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/didyouknowwindow.cpp1
-rw-r--r--src/gui/helpwindow.cpp1
-rw-r--r--src/gui/npcdialog.cpp1
-rw-r--r--src/gui/updaterwindow.cpp1
-rw-r--r--src/gui/widgets/browserbox.cpp21
-rw-r--r--src/gui/widgets/browserbox.h4
6 files changed, 29 insertions, 0 deletions
diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp
index 1c08010f2..338b70bf2 100644
--- a/src/gui/didyouknowwindow.cpp
+++ b/src/gui/didyouknowwindow.cpp
@@ -82,6 +82,7 @@ DidYouKnowWindow::DidYouKnowWindow() :
mBrowserBox->setProcessVersion(true);
mBrowserBox->setEnableImages(true);
mBrowserBox->setEnableKeys(true);
+ mBrowserBox->setEnableTabs(true);
place(0, 0, mScrollArea, 5, 3).setPadding(3);
place(0, 3, mOpenAgainCheckBox, 5);
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index f760a14cb..d41f8a550 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -74,6 +74,7 @@ HelpWindow::HelpWindow() :
mBrowserBox->setProcessVersion(true);
mBrowserBox->setEnableImages(true);
mBrowserBox->setEnableKeys(true);
+ mBrowserBox->setEnableTabs(true);
place(4, 3, mDYKButton);
place(0, 0, mScrollArea, 5, 3).setPadding(3);
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 03e0006b5..dd2243310 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -134,6 +134,7 @@ NpcDialog::NpcDialog(const int npcId) :
mTextBox->setLinkHandler(mItemLinkHandler);
mTextBox->setFont(gui->getNpcFont());
mTextBox->setEnableKeys(true);
+ mTextBox->setEnableTabs(true);
mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mScrollArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 55726d7d5..f17621f6f 100644
--- a/src/gui/updaterwindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -196,6 +196,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
mBrowserBox->setOpaque(false);
mBrowserBox->setLinkHandler(this);
mBrowserBox->setEnableKeys(true);
+ mBrowserBox->setEnableTabs(true);
mPlayButton->setEnabled(false);
ContainerPlacer placer;
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 50072c5d2..190e79e10 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -69,6 +69,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, const unsigned int mode,
mProcessVersion(false),
mEnableImages(false),
mEnableKeys(false),
+ mEnableTabs(false),
mPadding(0),
mNewLinePadding(15),
mBackgroundColor(getThemeColor(Theme::BACKGROUND)),
@@ -229,6 +230,26 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
if (mProcessVersion)
newRow = replaceAll(newRow, "%VER%", SMALL_VERSION);
+ if (mEnableTabs)
+ {
+ idx1 = newRow.find("\\t");
+ while (idx1 != std::string::npos)
+ {
+ const size_t idx2 = newRow.find(";", idx1);
+ if (idx2 == std::string::npos)
+ break;
+
+ const int newSize = atoi(newRow.substr(
+ idx1 + 2, idx2 - idx1 - 2).c_str());
+ std::string str = newRow.substr(0, idx1);
+ while (str.size() < newSize)
+ str.append(" ");
+ str.append(newRow.substr(idx2 + 1));
+ newRow = str;
+ idx1 = newRow.find("\\t");
+ }
+ }
+
if (atTop)
{
mTextRows.push_front(newRow);
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index c9219f9ba..51f8bb3ac 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -228,6 +228,9 @@ class BrowserBox final : public gcn::Widget,
void setEnableKeys(bool n)
{ mEnableKeys = n; }
+ void setEnableTabs(bool n)
+ { mEnableTabs = n; }
+
std::string getTextAtPos(const int x, const int y) const A_WARN_UNUSED;
int getPadding() const A_WARN_UNUSED
@@ -265,6 +268,7 @@ class BrowserBox final : public gcn::Widget,
bool mProcessVersion;
bool mEnableImages;
bool mEnableKeys;
+ bool mEnableTabs;
int mPadding;
int mNewLinePadding;