summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/npcintegerdialog.cpp150
-rw-r--r--src/gui/npcintegerdialog.h96
-rw-r--r--src/gui/npclistdialog.cpp150
-rw-r--r--src/gui/npclistdialog.h96
-rw-r--r--src/gui/npcstringdialog.cpp110
-rw-r--r--src/gui/npcstringdialog.h80
-rw-r--r--src/gui/npctextdialog.cpp138
-rw-r--r--src/gui/npctextdialog.h113
-rw-r--r--src/gui/setup.cpp2
-rw-r--r--src/gui/widgets/window.cpp24
-rw-r--r--src/gui/widgets/window.h7
11 files changed, 31 insertions, 935 deletions
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp
deleted file mode 100644
index 41b6985c..00000000
--- a/src/gui/npcintegerdialog.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "gui/npcintegerdialog.h"
-
-#include "gui/npctextdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/inttextfield.h"
-#include "gui/widgets/layout.h"
-
-#include "npc.h"
-
-#include "net/net.h"
-#include "net/npchandler.h"
-
-#include "utils/gettext.h"
-#include "utils/strprintf.h"
-
-NpcIntegerDialog::NpcIntegerDialog()
- : Window(_("NPC Number Request"))
-{
- setWindowName("NPCInteger");
- mValueField = new IntTextField;
-
- setDefaultSize(175, 75, ImageRect::CENTER);
-
- mDecButton = new Button("-", "decvalue", this);
- mIncButton = new Button("+", "incvalue", this);
- gcn::Button *okButton = new Button(_("OK"), "ok", this);
- gcn::Button *cancelButton = new Button(_("Cancel"), "cancel", this);
- gcn::Button *resetButton = new Button(_("Reset"), "reset", this);
-
- mDecButton->adjustSize();
- mDecButton->setWidth(mIncButton->getWidth());
-
- ContainerPlacer place;
- place = getPlacer(0, 0);
-
- place(0, 0, mDecButton);
- place(1, 0, mValueField, 3);
- place(4, 0, mIncButton);
- place.getCell().matchColWidth(1, 0);
- place = getPlacer(0, 1);
- place(0, 0, resetButton);
- place(2, 0, cancelButton);
- place(3, 0, okButton);
- reflowLayout(175, 0);
-
- center();
- setDefaultSize();
- loadWindowState();
-}
-
-void NpcIntegerDialog::setRange(int min, int max)
-{
- mValueField->setRange(min, max);
-}
-
-int NpcIntegerDialog::getValue()
-{
- return mValueField->getValue();
-}
-
-void NpcIntegerDialog::reset()
-{
- mValueField->reset();
-}
-
-void NpcIntegerDialog::action(const gcn::ActionEvent &event)
-{
- bool finish = false;
-
- if (event.getId() == "ok")
- {
- finish = true;
- npcTextDialog->addText(strprintf("\n> %d\n", mValueField->getValue()));
- }
- else if (event.getId() == "cancel")
- {
- finish = true;
- mValueField->reset();
- npcTextDialog->addText(_("\n> Cancel\n"));
- }
- else if (event.getId() == "decvalue")
- {
- mValueField->setValue(mValueField->getValue() - 1);
- }
- else if (event.getId() == "incvalue")
- {
- mValueField->setValue(mValueField->getValue() + 1);
- }
- else if (event.getId() == "reset")
- {
- mValueField->reset();
- }
-
- if (finish)
- {
- setVisible(false);
- NPC::isTalking = false;
-
- Net::getNpcHandler()->integerInput(current_npc, mValueField->getValue());
-
- mValueField->reset();
- }
-}
-
-void NpcIntegerDialog::setDefaultValue(int value)
-{
- mValueField->setDefaultValue(value);
-}
-
-bool NpcIntegerDialog::isInputFocused()
-{
- return mValueField->isFocused();
-}
-
-void NpcIntegerDialog::requestFocus()
-{
- mValueField->requestFocus();
-}
-
-void NpcIntegerDialog::setVisible(bool visible)
-{
- if (visible) {
- npcTextDialog->setVisible(true);
- requestFocus();
- }
-
- Window::setVisible(visible);
-}
diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h
deleted file mode 100644
index 835372f7..00000000
--- a/src/gui/npcintegerdialog.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef GUI_NPCINTEGERDIALOG_H
-#define GUI_NPCINTEGERDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include <guichan/actionlistener.hpp>
-
-class IntTextField;
-
-/**
- * The npc integer input dialog.
- *
- * \ingroup Interface
- */
-class NpcIntegerDialog : public Window, public gcn::ActionListener
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- NpcIntegerDialog();
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const gcn::ActionEvent &event);
-
- /**
- * Returns the current value.
- */
- int getValue();
-
- /**
- * Resets the integer input field.
- */
- void reset();
-
- /**
- * Prepares the NPC dialog.
- *
- * @param min The minimum value to allow
- * @param max The maximum value to allow
- */
- void setRange(int min, int max);
-
- /**
- * Sets the default value.
- *
- * @param value The new default value
- */
- void setDefaultValue(int value);
-
- /**
- * Checks whether NpcStringDialog is Focused or not.
- */
- bool isInputFocused();
-
- /**
- * Requests the textfield to take focus for input.
- */
- void requestFocus();
-
- void setVisible(bool visible);
-
- private:
- gcn::Button *mDecButton;
- gcn::Button *mIncButton;
- IntTextField *mValueField;
-};
-
-extern NpcIntegerDialog *npcIntegerDialog;
-
-#endif // GUI_NPCINTEGERDIALOG_H
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
deleted file mode 100644
index 65e4263e..00000000
--- a/src/gui/npclistdialog.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "gui/npclistdialog.h"
-
-#include "gui/npctextdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/listbox.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "npc.h"
-
-#include "net/net.h"
-#include "net/npchandler.h"
-
-#include "utils/gettext.h"
-#include "utils/strprintf.h"
-
-#include <sstream>
-
-NpcListDialog::NpcListDialog()
- : Window("NPC")
-{
- setWindowName("NPCList");
- setResizable(true);
-
- setMinWidth(200);
- setMinHeight(150);
-
- setDefaultSize(260, 200, ImageRect::CENTER);
-
- mItemList = new ListBox(this);
- mItemList->setWrappingEnabled(true);
-
- gcn::ScrollArea *scrollArea = new ScrollArea(mItemList);
-
- gcn::Button *okButton = new Button(_("OK"), "ok", this);
- gcn::Button *cancelButton = new Button(_("Cancel"), "cancel", this);
-
- setContentSize(260, 175);
- scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
-
- place(0, 0, scrollArea, 5).setPadding(3);
- place(3, 1, cancelButton);
- place(4, 1, okButton);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, Layout::AUTO_SET);
-
- center();
- loadWindowState();
-}
-
-int NpcListDialog::getNumberOfElements()
-{
- return mItems.size();
-}
-
-std::string NpcListDialog::getElementAt(int i)
-{
- return mItems[i];
-}
-
-void NpcListDialog::addItem(const std::string &item)
-{
- mItems.push_back(item);
-}
-
-void NpcListDialog::parseItems(const std::string &itemString)
-{
- std::istringstream iss(itemString);
-
- std::string tmp;
- while (getline(iss, tmp, ':'))
- mItems.push_back(tmp);
-}
-
-void NpcListDialog::reset()
-{
- NPC::isTalking = false;
- mItemList->setSelected(-1);
- mItems.clear();
-}
-
-void NpcListDialog::action(const gcn::ActionEvent &event)
-{
- int choice = 0;
- if (event.getId() == "ok")
- {
- // Send the selected index back to the server
- int selectedIndex = mItemList->getSelected();
-
- if (selectedIndex > -1)
- {
- choice = selectedIndex + 1;
- npcTextDialog->addText(strprintf("\n> \"%s\"\n",
- mItems[selectedIndex].c_str()));
- }
- }
- else if (event.getId() == "cancel")
- {
- choice = 0xff; // 0xff means cancel
- npcTextDialog->addText(_("\n> Cancel\n"));
- npcTextDialog->showCloseButton();
- }
-
- if (choice)
- {
- setVisible(false);
- saveWindowState();
- reset();
-
- Net::getNpcHandler()->listInput(current_npc, choice);
- }
-}
-
-void NpcListDialog::setVisible(bool visible)
-{
- if (visible) {
- npcTextDialog->setVisible(true);
- }
-
- Window::setVisible(visible);
-}
-
-void NpcListDialog::requestFocus()
-{
- mItemList->requestFocus();
- mItemList->setSelected(0);
-}
diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h
deleted file mode 100644
index b0279e11..00000000
--- a/src/gui/npclistdialog.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef GUI_NPCLISTDIALOG_H
-#define GUI_NPCLISTDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include <guichan/actionlistener.hpp>
-#include <guichan/listmodel.hpp>
-
-#include <vector>
-
-/**
- * The npc list dialog.
- *
- * \ingroup Interface
- */
-class NpcListDialog : public Window, public gcn::ActionListener,
- public gcn::ListModel
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- NpcListDialog();
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const gcn::ActionEvent &event);
-
- /**
- * Returns the number of items in the choices list.
- */
- int getNumberOfElements();
-
- /**
- * Returns the name of item number i of the choices list.
- */
- std::string getElementAt(int i);
-
- /**
- * Adds an item to the option list.
- */
- void addItem(const std::string &);
-
- /**
- * Fills the options list for an NPC dialog.
- *
- * @param itemString A string with the options separated with colons.
- */
- void parseItems(const std::string &itemString);
-
- /**
- * Resets the list by removing all items.
- */
- void reset();
-
- void setVisible(bool visible);
-
- /**
- * Requests the listbox to take focus for input and sets window width
- * to the last known setting.
- */
- void requestFocus();
-
- private:
- gcn::ListBox *mItemList;
-
- std::vector<std::string> mItems;
-};
-
-extern NpcListDialog *npcListDialog;
-
-#endif // GUI_NPCLISTDIALOG_H
diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp
deleted file mode 100644
index e5767c5f..00000000
--- a/src/gui/npcstringdialog.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "gui/npcstringdialog.h"
-
-#include "gui/npctextdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/textfield.h"
-
-#include "npc.h"
-
-#include "net/net.h"
-#include "net/npchandler.h"
-
-#include "utils/gettext.h"
-#include "utils/strprintf.h"
-
-NpcStringDialog::NpcStringDialog()
- : Window(_("NPC Text Request"))
-{
- setWindowName("NPCString");
- mValueField = new TextField("");
-
- setDefaultSize(175, 75, ImageRect::CENTER);
-
- gcn::Button *okButton = new Button(_("OK"), "ok", this);
- gcn::Button *cancelButton = new Button(_("Cancel"), "cancel", this);
-
- place(0, 0, mValueField, 3);
- place(1, 1, cancelButton);
- place(2, 1, okButton);
- reflowLayout(175, 0);
-
- center();
- setDefaultSize();
- loadWindowState();
-}
-
-std::string NpcStringDialog::getValue()
-{
- return mValueField->getText();
-}
-
-void NpcStringDialog::setValue(const std::string &value)
-{
- mValueField->setText(value);
- mDefault = value;
-}
-
-void NpcStringDialog::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == "cancel")
- {
- mValueField->setText(mDefault);
- npcTextDialog->addText(_("\n> Cancel\n"));
- }
- else
- {
- npcTextDialog->addText(strprintf("\n> \"%s\"\n",
- mValueField->getText().c_str()));
- }
-
- setVisible(false);
- NPC::isTalking = false;
-
- std::string text = mValueField->getText();
- mValueField->setText("");
-
- Net::getNpcHandler()->stringInput(current_npc, text);
-}
-
-bool NpcStringDialog::isInputFocused()
-{
- return mValueField->isFocused();
-}
-
-void NpcStringDialog::requestFocus()
-{
- mValueField->requestFocus();
-}
-
-void NpcStringDialog::setVisible(bool visible)
-{
- if (visible) {
- npcTextDialog->setVisible(true);
- requestFocus();
- }
-
- Window::setVisible(visible);
-}
diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h
deleted file mode 100644
index e6bbd7ba..00000000
--- a/src/gui/npcstringdialog.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef GUI_NPCSTRINGDIALOG_H
-#define GUI_NPCSTRINGDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include <guichan/actionlistener.hpp>
-
-/**
- * The npc integer input dialog.
- *
- * \ingroup Interface
- */
-class NpcStringDialog : public Window, public gcn::ActionListener
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- NpcStringDialog();
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const gcn::ActionEvent &event);
-
- /**
- * Returns the current value.
- */
- std::string getValue();
-
- /**
- * Chnages the current value.
- *
- * @param value The new value
- */
- void setValue(const std::string &value);
-
- /**
- * Checks whether NpcStringDialog is Focused or not.
- */
- bool isInputFocused();
-
- /**
- * Requests the textfield to take focus for input.
- */
- void requestFocus();
-
- void setVisible(bool visible);
-
- private:
- gcn::TextField *mValueField;
- std::string mDefault;
-};
-
-extern NpcStringDialog *npcStringDialog;
-
-#endif // GUI_NPCSTRINGDIALOG_H
diff --git a/src/gui/npctextdialog.cpp b/src/gui/npctextdialog.cpp
deleted file mode 100644
index 849c94ec..00000000
--- a/src/gui/npctextdialog.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "gui/npctextdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/textbox.h"
-
-#include "npc.h"
-
-#include "net/net.h"
-#include "net/npchandler.h"
-
-#include "utils/gettext.h"
-
-NpcTextDialog::NpcTextDialog()
- : Window(_("NPC"))
- , mState(NPC_TEXT_STATE_WAITING)
-{
- setWindowName("NPCText");
- setResizable(true);
-
- setMinWidth(200);
- setMinHeight(150);
-
- setDefaultSize(260, 200, ImageRect::CENTER);
-
- mTextBox = new TextBox;
- mTextBox->setEditable(false);
- mTextBox->setOpaque(false);
-
- mScrollArea = new ScrollArea(mTextBox);
- mButton = new Button(_("Waiting for server"), "ok", this);
-
- mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mScrollArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
-
- place(0, 0, mScrollArea, 5).setPadding(3);
- place(4, 1, mButton);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, Layout::AUTO_SET);
-
- center();
- loadWindowState();
-}
-
-void NpcTextDialog::clearText()
-{
- NPC::isTalking = false;
- setText("");
-}
-
-void NpcTextDialog::setText(const std::string &text)
-{
- mText = text;
- mTextBox->setTextWrapped(mText, mScrollArea->getWidth() - 15);
-}
-
-void NpcTextDialog::addText(const std::string &text)
-{
- setText(mText + text + "\n");
- mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
-}
-
-void NpcTextDialog::showNextButton()
-{
- mButton->setCaption(_("Next"));
- mState = NPC_TEXT_STATE_NEXT;
- mButton->setEnabled(true);
-}
-
-void NpcTextDialog::showCloseButton()
-{
- mButton->setCaption(_("Close"));
- mState = NPC_TEXT_STATE_CLOSE;
- mButton->setEnabled(true);
-}
-
-void NpcTextDialog::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == "ok")
- {
- if (mState == NPC_TEXT_STATE_NEXT && current_npc) {
- nextDialog();
- addText("\n> Next\n");
- } else if (mState == NPC_TEXT_STATE_CLOSE ||
- (mState == NPC_TEXT_STATE_NEXT && !current_npc)) {
- setText("");
- if (current_npc) nextDialog();
- setVisible(false);
- current_npc = 0;
- NPC::isTalking = false;
- } else return;
- }
- else return;
-
- mButton->setEnabled(false);
- mButton->setCaption(_("Waiting for server"));
- mState = NPC_TEXT_STATE_WAITING;
-}
-
-void NpcTextDialog::nextDialog(int npcID)
-{
- Net::getNpcHandler()->nextDialog(npcID);
-}
-
-void NpcTextDialog::closeDialog(int npcID)
-{
- Net::getNpcHandler()->closeDialog(npcID);
-}
-
-void NpcTextDialog::widgetResized(const gcn::Event &event)
-{
- Window::widgetResized(event);
-
- setText(mText);
-}
diff --git a/src/gui/npctextdialog.h b/src/gui/npctextdialog.h
deleted file mode 100644
index ad32fdf4..00000000
--- a/src/gui/npctextdialog.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef NPC_TEXT_H
-#define NPC_TEXT_H
-
-#include "gui/widgets/window.h"
-
-#include "npc.h"
-
-#include <guichan/actionlistener.hpp>
-
-#include <string>
-
-class TextBox;
-
-/**
- * The npc text dialog.
- *
- * \ingroup Interface
- */
-class NpcTextDialog : public Window, public gcn::ActionListener
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- NpcTextDialog();
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const gcn::ActionEvent &event);
-
- /**
- * Clears the text shown in the dialog.
- */
- void clearText();
-
- /**
- * Sets the text shows in the dialog.
- *
- * @param string The new text.
- */
- void setText(const std::string &string);
-
- /**
- * Adds the text to the text shows in the dialog. Also adds a newline
- * to the end.
- *
- * @param string The text to add.
- */
- void addText(const std::string &string);
-
- void showNextButton();
-
- void showCloseButton();
-
- /**
- * Notifies the server that the client has performed a next action.
- */
- void nextDialog(int npcID = current_npc);
-
- /**
- * Notifies the server that the client has performed a close action.
- */
- void closeDialog(int npcID = current_npc);
-
- /**
- * Called when resizing the window.
- *
- * @param event The calling event
- */
- void widgetResized(const gcn::Event &event);
-
- private:
- gcn::ScrollArea *mScrollArea;
- TextBox *mTextBox;
- gcn::Button *mButton;
-
- std::string mText;
-
- enum NPCTextState {
- NPC_TEXT_STATE_WAITING,
- NPC_TEXT_STATE_NEXT,
- NPC_TEXT_STATE_CLOSE
- };
- NPCTextState mState;
-};
-
-extern NpcTextDialog *npcTextDialog;
-
-#endif // NPC_TEXT_H
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 6e5e7809..5dbce81b 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -146,8 +146,6 @@ void Setup::action(const gcn::ActionEvent &event)
#endif
inventoryWindow->resetToDefaultSize();
emoteWindow->resetToDefaultSize();
- npcTextDialog->resetToDefaultSize();
- npcStringDialog->resetToDefaultSize();
skillDialog->resetToDefaultSize();
minimap->resetToDefaultSize();
equipmentWindow->resetToDefaultSize();
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 7de09994..87051686 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -687,6 +687,19 @@ Layout &Window::getLayout()
return *mLayout;
}
+void Window::clearLayout()
+{
+ clear(); // This removes widgets from the container
+
+ while (!mWidgets.empty())
+ delete mWidgets.front();
+
+ if (!mLayout)
+ delete mLayout;
+ mLayout = new Layout;
+
+}
+
LayoutCell &Window::place(int x, int y, gcn::Widget *wg, int w, int h)
{
add(wg);
@@ -707,6 +720,17 @@ void Window::reflowLayout(int w, int h)
setContentSize(w, h);
}
+void Window::redraw()
+{
+ if (mLayout)
+ {
+ const gcn::Rectangle area = getChildrenArea();
+ int w = area.width;
+ int h = area.height;
+ mLayout->reflow(w, h);
+ }
+}
+
void Window::center()
{
setLocationRelativeTo(getParent());
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index aa9872d3..11193654 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -95,6 +95,8 @@ class Window : public gcn::Window, gcn::WidgetListener
*/
void setResizable(bool resize);
+ void redraw();
+
/**
* Called whenever the widget changes size.
*/
@@ -293,6 +295,11 @@ class Window : public gcn::Window, gcn::WidgetListener
Layout &getLayout();
/**
+ * Clears the Window's layout (useful for redesigning the window)
+ */
+ void clearLayout();
+
+ /**
* Computes the position of the widgets according to the current
* layout. Resizes the window so that the layout fits. Deletes the
* layout.