summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/buy.cpp3
-rw-r--r--src/gui/buysell.cpp1
-rw-r--r--src/gui/chat.cpp2
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/emotewindow.cpp2
-rw-r--r--src/gui/equipmentwindow.cpp2
-rw-r--r--src/gui/inventorywindow.cpp3
-rw-r--r--src/gui/npc_text.cpp3
-rw-r--r--src/gui/npcintegerdialog.cpp7
-rw-r--r--src/gui/npclistdialog.cpp3
-rw-r--r--src/gui/npcstringdialog.cpp7
-rw-r--r--src/gui/recorder.cpp8
-rw-r--r--src/gui/sell.cpp3
-rw-r--r--src/gui/shortcutwindow.cpp13
-rw-r--r--src/gui/skill.cpp2
-rw-r--r--src/gui/status.cpp3
-rw-r--r--src/gui/storagewindow.cpp3
-rw-r--r--src/gui/trade.cpp2
-rw-r--r--src/gui/window.cpp99
-rw-r--r--src/gui/window.h16
20 files changed, 146 insertions, 38 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 5a57dcc6..2b5aeeb7 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -47,7 +47,7 @@ BuyDialog::BuyDialog(Network *network):
setResizable(true);
setMinWidth(260);
setMinHeight(230);
- setDefaultSize(0, 0, 260, 230);
+ setDefaultSize(260, 230, ImageRect::CENTER);
mShopItems = new ShopItems;
@@ -90,7 +90,6 @@ BuyDialog::BuyDialog(Network *network):
layout.setRowHeight(0, Layout::AUTO_SET);
loadWindowState();
- setLocationRelativeTo(getParent());
}
BuyDialog::~BuyDialog()
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index dc7deef6..f7684670 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -50,7 +50,6 @@ BuySellDialog::BuySellDialog(Network *network):
buyButton->requestFocus();
setContentSize(x, 2 * y + buyButton->getHeight());
- setLocationRelativeTo(getParent());
requestFocus();
}
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 5cf8b739..098d4e46 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -55,7 +55,7 @@ Window(""), mNetwork(network), mTmpVisible(false)
setWindowName(_("Chat"));
setResizable(true);
- setDefaultSize(0, windowContainer->getHeight() - 123, 600, 123);
+ setDefaultSize(600, 123, ImageRect::LOWER_LEFT);
setMinWidth(150);
setMinHeight(90);
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index dafd604a..71855977 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -41,7 +41,7 @@ DebugWindow::DebugWindow():
setResizable(true);
setCloseButton(true);
- setDefaultSize(0, 0, 400, 60);
+ setDefaultSize(400, 60, ImageRect::CENTER);
mFPSLabel = new gcn::Label("0 FPS");
mMusicFileLabel = new gcn::Label("Music: ");
diff --git a/src/gui/emotewindow.cpp b/src/gui/emotewindow.cpp
index 30129941..77168993 100644
--- a/src/gui/emotewindow.cpp
+++ b/src/gui/emotewindow.cpp
@@ -40,7 +40,7 @@ EmoteWindow::EmoteWindow():
setCloseButton(true);
setMinWidth(80);
setMinHeight(130);
- setDefaultSize(115, 25, 322, 200);
+ setDefaultSize(322, 200, ImageRect::CENTER);
mUseButton = new Button(_("Use"), "use", this);
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 27ea38ff..0d2097f8 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -71,7 +71,7 @@ EquipmentWindow::EquipmentWindow():
setWindowName("Equipment");
setCloseButton(true);
- setDefaultSize(5, 195, 180, 300);
+ setDefaultSize(180, 300, ImageRect::CENTER);
loadWindowState();
mUnequip = new Button(_("Unequip"), "unequip", this);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 226b3178..7e75411e 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -57,7 +57,7 @@ InventoryWindow::InventoryWindow(int invSize):
setCloseButton(true);
// If you adjust these defaults, don't forget to adjust the trade window's.
- setDefaultSize(115, 25, 375, 300);
+ setDefaultSize(375, 300, ImageRect::CENTER);
std::string longestUseString = getFont()->getWidth(_("Equip")) >
getFont()->getWidth(_("Use")) ?
@@ -103,7 +103,6 @@ InventoryWindow::InventoryWindow(int invSize):
layout.setRowHeight(0, mDropButton->getHeight());
loadWindowState();
- setLocationRelativeTo(getParent());
}
InventoryWindow::~InventoryWindow()
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 58aa0c5e..f524f8ea 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -43,7 +43,7 @@ NpcTextDialog::NpcTextDialog(Network *network):
setMinWidth(200);
setMinHeight(150);
- setDefaultSize(0, 0, 260, 200);
+ setDefaultSize(260, 200, ImageRect::CENTER);
mTextBox = new TextBox;
mTextBox->setEditable(false);
@@ -63,7 +63,6 @@ NpcTextDialog::NpcTextDialog(Network *network):
layout.setRowHeight(0, Layout::AUTO_SET);
loadWindowState();
- setLocationRelativeTo(getParent());
}
void NpcTextDialog::setText(const std::string &text)
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp
index 132a7608..5b3e05aa 100644
--- a/src/gui/npcintegerdialog.cpp
+++ b/src/gui/npcintegerdialog.cpp
@@ -37,6 +37,9 @@ NpcIntegerDialog::NpcIntegerDialog(Network *network):
Window(_("NPC Number Request")), mNetwork(network)
{
mValueField = new IntTextField();
+ setWindowName("NPCInput");
+
+ setDefaultSize(175, 75, ImageRect::CENTER);
mDecButton = new Button("-", "decvalue", this);
mIncButton = new Button("+", "incvalue", this);
@@ -58,9 +61,9 @@ NpcIntegerDialog::NpcIntegerDialog(Network *network):
place(0, 0, resetButton);
place(2, 0, cancelButton);
place(3, 0, okButton);
- reflowLayout(175, 0);
+ //reflowLayout(175, 0);
- setLocationRelativeTo(getParent());
+ loadWindowState();
}
void NpcIntegerDialog::setRange(const int min, const int max)
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index f049cba7..505912ac 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -45,7 +45,7 @@ NpcListDialog::NpcListDialog(Network *network):
setMinWidth(200);
setMinHeight(150);
- setDefaultSize(0, 0, 260, 200);
+ setDefaultSize(260, 200, ImageRect::CENTER);
mItemList = new ListBox(this);
mItemList->setWrappingEnabled(true);
@@ -66,7 +66,6 @@ NpcListDialog::NpcListDialog(Network *network):
layout.setRowHeight(0, Layout::AUTO_SET);
loadWindowState();
- setLocationRelativeTo(getParent());
}
int NpcListDialog::getNumberOfElements()
diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp
index f2c7434c..58a5c0c8 100644
--- a/src/gui/npcstringdialog.cpp
+++ b/src/gui/npcstringdialog.cpp
@@ -36,17 +36,20 @@
NpcStringDialog::NpcStringDialog(Network *network):
Window(_("NPC Text Request")), mNetwork(network)
{
+ setWindowName("NPCInput");
mValueField = new TextField("");
+ setDefaultSize(175, 75, ImageRect::CENTER);
+
okButton = new Button(_("OK"), "ok", this);
cancelButton = new Button(_("Cancel"), "cancel", this);
place(0, 0, mValueField, 3);
place(1, 1, cancelButton);
place(2, 1, okButton);
- reflowLayout(175, 0);
+ //reflowLayout(175, 0);
- setLocationRelativeTo(getParent());
+ loadWindowState();
}
std::string NpcStringDialog::getValue()
diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp
index ff8825ef..9320e020 100644
--- a/src/gui/recorder.cpp
+++ b/src/gui/recorder.cpp
@@ -40,9 +40,11 @@ Recorder::Recorder(ChatWindow *chat, const std::string &title,
mChat = chat;
Button *button = new Button(buttonTxt, "activate", this);
- setDefaultSize(0, windowContainer->getHeight() - 123 - button->getHeight() -
- offsetY, button->getWidth() + offsetX, button->getHeight() +
- offsetY);
+
+ // 123 is the default chat window height. If you change this in Chat, please
+ // change it here as well
+ setDefaultSize(button->getWidth() + offsetX, button->getHeight() +
+ offsetY, ImageRect::LOWER_LEFT, 0, 123);
place(0, 0, button);
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 154d1a57..397e29a6 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -48,7 +48,7 @@ SellDialog::SellDialog(Network *network):
setResizable(true);
setMinWidth(260);
setMinHeight(230);
- setDefaultSize(0, 0, 260, 230);
+ setDefaultSize(260, 230, ImageRect::CENTER);
// Create a ShopItems instance, that is aware of duplicate entries.
mShopItems = new ShopItems(true);
@@ -94,7 +94,6 @@ SellDialog::SellDialog(Network *network):
layout.setRowHeight(0, Layout::AUTO_SET);
loadWindowState();
- setLocationRelativeTo(getParent());
}
SellDialog::~SellDialog()
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index ee32ca70..c2df1f9c 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -40,22 +40,17 @@ ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content)
mItems = content;
- mInstances++;
-
const int border = SCROLL_PADDING * 2 + getPadding() * 2;
setMinWidth(mItems->getBoxWidth() + border);
setMinHeight(mItems->getBoxHeight() + border);
setMaxWidth(mItems->getBoxWidth() * mItems->getMaxItems() + border);
setMaxHeight(mItems->getBoxHeight() * mItems->getMaxItems() + border);
- const int width = (int) config.getValue("screenwidth", 800);
- const int height = (int) config.getValue("screenheight", 600);
+ setDefaultSize(mItems->getBoxWidth() + border, (mItems->getBoxHeight() *
+ mItems->getMaxItems()) + border, ImageRect::LOWER_RIGHT,
+ mInstances * mItems->getBoxWidth(), 0);
- setDefaultSize(width - (mInstances * mItems->getBoxWidth()) -
- (mInstances * border), height - (mItems->getBoxHeight() *
- mItems->getMaxItems()) - border, mItems->getBoxWidth() +
- border, (mItems->getBoxHeight() * mItems->getMaxItems()) +
- border);
+ mInstances++;
mScrollArea = new ScrollArea(mItems);
mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING);
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 42ac4d86..a8250fce 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -135,7 +135,7 @@ SkillDialog::SkillDialog():
setWindowName(_("Skills"));
setCloseButton(true);
- setDefaultSize(windowContainer->getWidth() - 260, 25, 255, 260);
+ setDefaultSize(255, 260, ImageRect::CENTER);
setMinHeight(50 + mTableModel->getHeight());
setMinWidth(200);
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 6419eabb..e534edb8 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -41,8 +41,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
{
setWindowName(_("Status"));
setCloseButton(true);
- setDefaultSize((windowContainer->getWidth() - 365) / 2,
- (windowContainer->getHeight() - 255) / 2, 400, 345);
+ setDefaultSize(400, 345, ImageRect::CENTER);
// ----------------------
// Status Part
diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp
index d3bc7ef8..ca7a547f 100644
--- a/src/gui/storagewindow.cpp
+++ b/src/gui/storagewindow.cpp
@@ -62,7 +62,7 @@ StorageWindow::StorageWindow(Network *network, int invSize):
setCloseButton(true);
// If you adjust these defaults, don't forget to adjust the trade window's.
- setDefaultSize(115, 25, 375, 300);
+ setDefaultSize(375, 300, ImageRect::CENTER);
mStoreButton = new Button(_("Store"), "store", this);
mRetrieveButton = new Button(_("Retrieve"), "retrieve", this);
@@ -92,7 +92,6 @@ StorageWindow::StorageWindow(Network *network, int invSize):
layout.setRowHeight(0, mStoreButton->getHeight());
loadWindowState();
- setLocationRelativeTo(getParent());
}
StorageWindow::~StorageWindow()
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 76795688..a28ff0f9 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -53,7 +53,7 @@ TradeWindow::TradeWindow(Network *network):
mPartnerInventory(new Inventory(INVENTORY_SIZE, 2))
{
setWindowName(_("Trade"));
- setDefaultSize(115, 227, 342, 209);
+ setDefaultSize(342, 209, ImageRect::CENTER);
setResizable(true);
setMinWidth(342);
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 5253dd2e..f1316b4c 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -220,6 +220,53 @@ void Window::setLocationRelativeTo(gcn::Widget *widget)
getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y));
}
+void Window::setLocationRelativeTo(ImageRect::ImagePosition position)
+{
+ int x = 0, y = 0;
+
+ if (position == ImageRect::UPPER_LEFT)
+ {
+ }
+ else if (position == ImageRect::UPPER_CENTER)
+ {
+ x = (windowContainer->getWidth() - getWidth()) / 2;
+ }
+ else if (position == ImageRect::UPPER_RIGHT)
+ {
+ x = windowContainer->getWidth() - getWidth();
+ }
+ else if (position == ImageRect::LEFT)
+ {
+ y = (windowContainer->getHeight() - getHeight()) / 2;
+ }
+ else if (position == ImageRect::CENTER)
+ {
+ x = (windowContainer->getWidth() - getWidth()) / 2;
+ y = (windowContainer->getHeight() - getHeight()) / 2;
+ }
+ else if (position == ImageRect::RIGHT)
+ {
+ x = windowContainer->getWidth() - getWidth();
+ y = (windowContainer->getHeight() - getHeight()) / 2;
+ }
+ else if (position == ImageRect::LOWER_LEFT)
+ {
+ y = windowContainer->getHeight() - getHeight();
+ }
+ else if (position == ImageRect::LOWER_CENTER)
+ {
+ x = (windowContainer->getWidth() - getWidth()) / 2;
+ y = windowContainer->getHeight() - getHeight();
+ }
+ else if (position == ImageRect::LOWER_RIGHT)
+ {
+ x = windowContainer->getWidth() - getWidth();
+ y = windowContainer->getHeight() - getHeight();
+ }
+
+ setPosition(x, y);
+}
+
void Window::setMinWidth(unsigned int width)
{
mMinWinWidth = width;
@@ -540,6 +587,58 @@ void Window::setDefaultSize(int defaultX, int defaultY,
mDefaultHeight = defaultHeight;
}
+void Window::setDefaultSize(int defaultWidth, int defaultHeight,
+ ImageRect::ImagePosition position,
+ int offsetX, int offsetY)
+{
+ int x = 0, y = 0;
+
+ if (position == ImageRect::UPPER_LEFT)
+ {
+ }
+ else if (position == ImageRect::UPPER_CENTER)
+ {
+ x = (windowContainer->getWidth() - defaultWidth) / 2;
+ }
+ else if (position == ImageRect::UPPER_RIGHT)
+ {
+ x = windowContainer->getWidth() - defaultWidth;
+ }
+ else if (position == ImageRect::LEFT)
+ {
+ y = (windowContainer->getHeight() - defaultHeight) / 2;
+ }
+ else if (position == ImageRect::CENTER)
+ {
+ x = (windowContainer->getWidth() - defaultWidth) / 2;
+ y = (windowContainer->getHeight() - defaultHeight) / 2;
+ }
+ else if (position == ImageRect::RIGHT)
+ {
+ x = windowContainer->getWidth() - defaultWidth;
+ y = (windowContainer->getHeight() - defaultHeight) / 2;
+ }
+ else if (position == ImageRect::LOWER_LEFT)
+ {
+ y = windowContainer->getHeight() - defaultHeight;
+ }
+ else if (position == ImageRect::LOWER_CENTER)
+ {
+ x = (windowContainer->getWidth() - defaultWidth) / 2;
+ y = windowContainer->getHeight() - defaultHeight;
+ }
+ else if (position == ImageRect::LOWER_RIGHT)
+ {
+ x = windowContainer->getWidth() - defaultWidth;
+ y = windowContainer->getHeight() - defaultHeight;
+ }
+
+ mDefaultX = x - offsetX;
+ mDefaultY = y - offsetY;
+ mDefaultWidth = defaultWidth;
+ mDefaultHeight = defaultHeight;
+}
+
void Window::resetToDefaultSize()
{
setPosition(mDefaultX, mDefaultY);
diff --git a/src/gui/window.h b/src/gui/window.h
index bf15dedb..c24bde76 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -34,7 +34,6 @@ class ConfigListener;
class GCContainer;
class ContainerPlacer;
class Image;
-class ImageRect;
class Layout;
class LayoutCell;
class ResizeGrip;
@@ -91,6 +90,11 @@ class Window : public gcn::Window, gcn::WidgetListener
void setLocationRelativeTo(gcn::Widget *widget);
/**
+ * Sets the location relative to the given enumerated position.
+ */
+ void setLocationRelativeTo(ImageRect::ImagePosition position);
+
+ /**
* Sets whether or not the window can be resized.
*/
void setResizable(bool resize);
@@ -247,6 +251,16 @@ class Window : public gcn::Window, gcn::WidgetListener
int defaultWidth, int defaultHeight);
/**
+ * Set the default win pos and size.
+ * (which can be different of the actual ones.)
+ * This version of setDefaultSize sets the window's position based
+ * on a relative enumerated position, rather than a coordinate position.
+ */
+ void setDefaultSize(int defaultWidth, int defaultHeight,
+ ImageRect::ImagePosition position,
+ int offsetx = 0, int offsetY = 0);
+
+ /**
* Reset the win pos and size to default. Don't forget to set defaults
* first.
*/