summaryrefslogtreecommitdiff
path: root/src/gui/npc_text.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-05 21:29:13 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-05 21:29:13 +0000
commitcb5a80c169e10adf6d6b9392bba7c9946edf087d (patch)
tree321f9be819b01406dbbd6cf31cb7ddbb2244b3c1 /src/gui/npc_text.cpp
parent7c7c50bf115299cd3a160b0eb9abfa8d7fdb2fd5 (diff)
downloadmana-cb5a80c169e10adf6d6b9392bba7c9946edf087d.tar.gz
mana-cb5a80c169e10adf6d6b9392bba7c9946edf087d.tar.bz2
mana-cb5a80c169e10adf6d6b9392bba7c9946edf087d.tar.xz
mana-cb5a80c169e10adf6d6b9392bba7c9946edf087d.zip
Implemented wrapping for textbox (still could use a small fix) and made death
notice dialog release modal focus immediately.
Diffstat (limited to 'src/gui/npc_text.cpp')
-rw-r--r--src/gui/npc_text.cpp29
1 files changed, 6 insertions, 23 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index b6bd962f..7fc59343 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -37,6 +37,8 @@ NpcTextDialog::NpcTextDialog():
okButton = new Button("OK");
setContentSize(260, 175);
+ scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
+ scrollArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
scrollArea->setDimension(gcn::Rectangle(
5, 5, 250, 160 - okButton->getHeight()));
okButton->setPosition(
@@ -61,32 +63,13 @@ NpcTextDialog::~NpcTextDialog()
void NpcTextDialog::setText(const char *text)
{
- std::string tmp = "";
- int lineWidth = 0;
- int w = scrollArea->getWidth();
- for (unsigned int i = 0; i < strlen(text); i++)
- {
- if (text[i] != '\n')
- {
- std::string tmpChar = ""; tmpChar += text[i];
- lineWidth += getFont()->getWidth(tmpChar);
- if (lineWidth > w) {
- tmp += '\n';
- lineWidth = 0;
- }
- } else
- {
- lineWidth = 0;
- }
- tmp += text[i];
- }
- textBox->setText(tmp);
+ textBox->setText(text);
}
void NpcTextDialog::addText(const char *text)
{
- std::string tmp = textBox->getText() + std::string(text) + std::string("\n");
- setText(tmp.c_str());
+ textBox->setText(
+ textBox->getText() + std::string(text) + std::string("\n"));
}
void NpcTextDialog::action(const std::string& eventId)
@@ -96,5 +79,5 @@ void NpcTextDialog::action(const std::string& eventId)
WFIFOSET(6);
setText("");
setVisible(false);
- current_npc = 0;
+ current_npc = 0;
}