From 523eed88816298b1660ecb9e67db80776e4007bb Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 1 Nov 2008 03:36:47 +0000 Subject: Made NPC dialogues resizeable. (cherry picked from Aethyra commit 81299ca9acc39dec62e1e504781721ad0db0d471) Conflicts: src/gui/inventorywindow.cpp src/gui/npc_text.cpp --- src/gui/npc_text.cpp | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'src/gui/npc_text.cpp') diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 3c4beaf3..ad2ccdce 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -32,10 +32,16 @@ NpcTextDialog::NpcTextDialog(): Window("NPC") { + setResizable(true); + + setMinWidth(200); + setMinHeight(150); + mTextBox = new TextBox; mTextBox->setEditable(false); - gcn::ScrollArea *scrollArea = new ScrollArea(mTextBox); - Button *okButton = new Button("OK", "ok", this); + + scrollArea = new ScrollArea(mTextBox); + okButton = new Button("OK", "ok", this); setContentSize(260, 175); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -55,13 +61,36 @@ NpcTextDialog::NpcTextDialog(): void NpcTextDialog::setText(const std::string &text) { - mTextBox->setTextWrapped(text); + mText = text; + draw(); } void NpcTextDialog::addText(const std::string &text) { - mTextBox->setTextWrapped(mTextBox->getText() + text + "\n"); + mText = mTextBox->getText() + text + "\n"; + draw(); +} + +void NpcTextDialog::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); + draw(); +} + +void NpcTextDialog::draw() +{ + const gcn::Rectangle &area = getChildrenArea(); + const int width = area.width; + const int height = area.height; + + mTextBox->setTextWrapped(mText); + + scrollArea->setDimension(gcn::Rectangle( + 5, 5, width - 10, height - 15 - okButton->getHeight())); + okButton->setPosition( + width - 5 - okButton->getWidth(), + height - 5 - okButton->getHeight()); } void -- cgit v1.2.3-70-g09d2