summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/buy.cpp7
-rw-r--r--src/gui/buy.h4
-rw-r--r--src/gui/buysell.cpp16
-rw-r--r--src/gui/buysell.h4
-rw-r--r--src/gui/npcintegerdialog.cpp2
-rw-r--r--src/gui/npclistdialog.cpp3
-rw-r--r--src/gui/npcstringdialog.cpp4
-rw-r--r--src/gui/sell.cpp7
-rw-r--r--src/gui/sell.h4
-rw-r--r--src/gui/window.cpp2
-rw-r--r--src/net/buysellhandler.cpp7
-rw-r--r--src/net/playerhandler.cpp5
12 files changed, 44 insertions, 21 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index d267e5ad..3107c529 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -247,3 +247,10 @@ void BuyDialog::logic()
if (!current_npc) setVisible(false);
}
+
+void BuyDialog::setVisible(bool visible)
+{
+ Window::setVisible(visible);
+
+ if (visible) requestFocus();
+}
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 2555e139..5e2f0b8f 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -100,6 +100,8 @@ class BuyDialog : public Window, public gcn::ActionListener,
*/
void logic();
+ void setVisible(bool visible);
+
private:
Network *mNetwork;
gcn::Button *mBuyButton;
@@ -121,4 +123,6 @@ class BuyDialog : public Window, public gcn::ActionListener,
Uint32 mMaxItems;
};
+extern BuyDialog *buyDialog;
+
#endif
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index 0550a822..75c49b1f 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -32,6 +32,7 @@
BuySellDialog::BuySellDialog(Network *network):
Window(_("Shop")), mNetwork(network)
{
+ setWindowName("BuySell");
Button *buyButton = 0;
static const char *buttonNames[] = {
N_("Buy"), N_("Sell"), N_("Cancel"), 0
@@ -48,16 +49,25 @@ BuySellDialog::BuySellDialog(Network *network):
}
buyButton->requestFocus();
- setContentSize(x, 2 * y + buyButton->getHeight());
+ loadWindowState();
- requestFocus();
+ setContentSize(x, 2 * y + buyButton->getHeight());
}
void BuySellDialog::logic()
{
Window::logic();
- if (!current_npc) setVisible(false);
+ if (isVisible() && !current_npc) {
+ setVisible(false);
+ }
+}
+
+void BuySellDialog::setVisible(bool visible)
+{
+ Window::setVisible(visible);
+
+ if (visible) requestFocus();
}
void BuySellDialog::action(const gcn::ActionEvent &event)
diff --git a/src/gui/buysell.h b/src/gui/buysell.h
index 197c1a2b..4b137554 100644
--- a/src/gui/buysell.h
+++ b/src/gui/buysell.h
@@ -49,6 +49,8 @@ class BuySellDialog : public Window, public gcn::ActionListener
*/
void logic();
+ void setVisible(bool visible);
+
/**
* Called when receiving actions from the widgets.
*/
@@ -58,4 +60,6 @@ class BuySellDialog : public Window, public gcn::ActionListener
Network *mNetwork;
};
+extern BuySellDialog *buySellDialog;
+
#endif
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp
index fad37700..c1460f8d 100644
--- a/src/gui/npcintegerdialog.cpp
+++ b/src/gui/npcintegerdialog.cpp
@@ -34,8 +34,6 @@
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
-extern NpcTextDialog *npcTextDialog;
-
NpcIntegerDialog::NpcIntegerDialog(Network *network):
Window(_("NPC Number Request")), mNetwork(network)
{
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index 95fe5983..3960cb21 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -37,8 +37,6 @@
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
-extern NpcTextDialog *npcTextDialog;
-
NpcListDialog::NpcListDialog(Network *network):
Window(_("NPC")), mNetwork(network)
{
@@ -69,7 +67,6 @@ NpcListDialog::NpcListDialog(Network *network):
layout.setRowHeight(0, Layout::AUTO_SET);
loadWindowState();
- resetToDefaultSize(false);
}
int NpcListDialog::getNumberOfElements()
diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp
index 7c9f78af..4d170208 100644
--- a/src/gui/npcstringdialog.cpp
+++ b/src/gui/npcstringdialog.cpp
@@ -34,12 +34,10 @@
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
-extern NpcTextDialog *npcTextDialog;
-
NpcStringDialog::NpcStringDialog(Network *network):
Window(_("NPC Text Request")), mNetwork(network)
{
- setWindowName("NPCList");
+ setWindowName("NPCString");
mValueField = new TextField("");
gcn::Button *okButton = new Button(_("OK"), "ok", this);
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index b53a23c1..4cdabe68 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -273,3 +273,10 @@ void SellDialog::logic()
if (!current_npc) setVisible(false);
}
+
+void SellDialog::setVisible(bool visible)
+{
+ Window::setVisible(visible);
+
+ if (visible) requestFocus();
+}
diff --git a/src/gui/sell.h b/src/gui/sell.h
index 3777b91e..3ae5e320 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -86,6 +86,8 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener
*/
void logic();
+ void setVisible(bool visible);
+
private:
/**
* Updates the state of buttons and labels.
@@ -112,4 +114,6 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener
int mAmountItems;
};
+extern SellDialog *sellDialog;
+
#endif
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index be63ff21..4bc0e4d0 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -120,7 +120,7 @@ Window::~Window()
const std::string &name = mWindowName;
// Saving X, Y and Width and Height for resizables in the config
- if (!name.empty())
+ if (!name.empty() && name != "window")
{
config.setValue(name + "WinX", getX());
config.setValue(name + "WinY", getY());
diff --git a/src/net/buysellhandler.cpp b/src/net/buysellhandler.cpp
index 520a1fe6..dcefe905 100644
--- a/src/net/buysellhandler.cpp
+++ b/src/net/buysellhandler.cpp
@@ -32,15 +32,12 @@
#include "../npc.h"
#include "../gui/buy.h"
+#include "../gui/buysell.h"
#include "../gui/chat.h"
#include "../gui/sell.h"
#include "../utils/gettext.h"
-extern BuyDialog *buyDialog;
-extern Window *buySellDialog;
-extern SellDialog *sellDialog;
-
BuySellHandler::BuySellHandler()
{
static const Uint16 _messages[] = {
@@ -64,8 +61,8 @@ void BuySellHandler::handleMessage(MessageIn *msg)
buyDialog->reset();
sellDialog->setVisible(false);
sellDialog->reset();
- buySellDialog->setVisible(true);
current_npc = msg->readInt32();
+ buySellDialog->setVisible(true);
break;
case SMSG_NPC_BUY:
diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp
index 4cc29568..aa0ef16c 100644
--- a/src/net/playerhandler.cpp
+++ b/src/net/playerhandler.cpp
@@ -30,6 +30,7 @@
#include "../units.h"
#include "../gui/buy.h"
+#include "../gui/buysell.h"
#include "../gui/chat.h"
#include "../gui/gui.h"
#include "../gui/npc_text.h"
@@ -49,10 +50,6 @@
OkDialog *weightNotice = NULL;
OkDialog *deathNotice = NULL;
-extern BuyDialog *buyDialog;
-extern SellDialog *sellDialog;
-extern Window *buySellDialog;
-
// Max. distance we are willing to scroll after a teleport;
// everything beyond will reset the port hard.
static const int MAP_TELEPORT_SCROLL_DISTANCE = 8;