summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-09-29 19:46:12 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-09-29 19:46:12 +0000
commitaac98cf8bcde36ba50ab45254866afc365a7908a (patch)
tree4e2ef7600f2ebd101484a305d3df6ca5135b39ef /src/gui
parentc00d3acf930359740ae6125533b5233ae06b765e (diff)
downloadmana-aac98cf8bcde36ba50ab45254866afc365a7908a.tar.gz
mana-aac98cf8bcde36ba50ab45254866afc365a7908a.tar.bz2
mana-aac98cf8bcde36ba50ab45254866afc365a7908a.tar.xz
mana-aac98cf8bcde36ba50ab45254866afc365a7908a.zip
Improved a lot windows reset to default size and pos. Also corrected a few the default win position. And moved the setposition from game to each win, to clarify the code.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp6
-rw-r--r--src/gui/equipmentwindow.cpp5
-rw-r--r--src/gui/inventorywindow.cpp12
-rw-r--r--src/gui/inventorywindow.h3
-rw-r--r--src/gui/menuwindow.cpp9
-rw-r--r--src/gui/minimap.cpp4
-rw-r--r--src/gui/ministatus.cpp7
-rw-r--r--src/gui/setup.cpp34
-rw-r--r--src/gui/skill.cpp6
-rw-r--r--src/gui/status.cpp7
-rw-r--r--src/gui/window.cpp21
-rw-r--r--src/gui/window.h14
12 files changed, 84 insertions, 44 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index e6868622..e30e7116 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -35,6 +35,9 @@
#include "../playerinfo.h"
#include "../log.h"
+#include "graphics.h"
+extern Graphics *graphics;
+
#include "../net/messageout.h"
#include "../net/protocol.h"
@@ -46,8 +49,9 @@ ChatWindow::ChatWindow(const std::string &logfile):
items = 0;
items_keep = 20;
- setContentSize(600, 100);
setResizable(true);
+ setDefaultSize(0, (graphics->getHeight() - 123), 600, 100);
+ loadWindowState();
chatInput = new ChatInput();
chatInput->setEventId("chatinput");
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 248e87f8..1aa5a05f 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -39,9 +39,10 @@
EquipmentWindow::EquipmentWindow():
Window("Equipment")
{
- setContentSize(200, 90);
- setPosition(40, 40);
setWindowName("Equipment");
+ setDefaultSize(5, 160, 200, 90);
+ loadWindowState();
+
ResourceManager *resman = ResourceManager::getInstance();
Image *itemImg = resman->getImage("graphics/sprites/items.png");
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 2f5841f6..af6c437e 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -45,8 +45,11 @@
InventoryWindow::InventoryWindow():
Window("Inventory")
{
- setContentSize(322, 172);
setWindowName("Inventory");
+ setResizable(true);
+ setMinWidth(240);
+ setMinHeight(172);
+ setDefaultSize(105, 25, 322, 172);
useButton = new Button("Use");
dropButton = new Button("Drop");
@@ -77,12 +80,11 @@ InventoryWindow::InventoryWindow():
add(itemEffectLabel);
add(weightLabel);
- setResizable(true);
- setMinWidth(240);
- setMinHeight(172);
-
updateWidgets();
useButton->setSize(48, useButton->getHeight());
+
+ loadWindowState();
+
}
InventoryWindow::~InventoryWindow()
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index c45245d6..59275f99 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -65,10 +65,11 @@ class InventoryWindow : public Window, gcn::ActionListener
void mouseMotion(int mx, int my);
+ void updateWidgets(); /** Updates widgets size/position */
+
Item* getItem();
private:
- void updateWidgets(); /** Updates widgets size/position */
void updateButtons(); /** Updates button states */
ItemContainer *items;
diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp
index 13d95032..ea15fccf 100644
--- a/src/gui/menuwindow.cpp
+++ b/src/gui/menuwindow.cpp
@@ -32,13 +32,15 @@
#include "status.h"
#include "skill.h"
+#include "graphics.h"
+extern Graphics *graphics;
extern Window *setupWindow;
-
MenuWindow::MenuWindow():
Window("")
{
setResizable(false);
+ setWindowName("Menu");
setMovable(false);
setTitleBarHeight(0);
@@ -74,7 +76,10 @@ MenuWindow::MenuWindow():
setupButton->setPosition(skillsButton->getX() + skillsButton->getWidth() + 3, statusButton->getY());
add(setupButton);
- setContentSize(setupButton->getX() + setupButton->getWidth(), setupButton->getY() + setupButton->getHeight());
+ int menuWidth = setupButton->getX() + setupButton->getWidth();
+ setDefaultSize((graphics->getWidth() - menuWidth - 5), 0,
+ menuWidth,
+ (setupButton->getY() + setupButton->getHeight()));
}
MenuWindow::~MenuWindow()
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index acfce00a..b23d7b1c 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -35,8 +35,8 @@ Minimap::Minimap():
mMapImage(NULL)
{
setWindowName("MiniMap");
- setContentSize(100, 100);
- setPosition(20, 20);
+ setDefaultSize(5, 25, 100, 100);
+ loadWindowState();
}
Minimap::~Minimap()
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index fe6db718..01d7330c 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -33,9 +33,10 @@
MiniStatusWindow::MiniStatusWindow():
Window("")
{
+ setWindowName("MiniStatus");
setResizable(false);
- setTitleBarHeight(0);
setMovable(false);
+ setTitleBarHeight(0);
hpBar = new ProgressBar(1.0f,
0, 3, 100, 20,
@@ -53,8 +54,8 @@ MiniStatusWindow::MiniStatusWindow():
add(hpLabel);
add(mpLabel);
- setContentSize(mpBar->getX() + mpBar->getWidth(),
- mpBar->getY() + mpBar->getHeight());
+ setDefaultSize(0, 0, mpBar->getX() + mpBar->getWidth(),
+ mpBar->getY() + mpBar->getHeight());
}
MiniStatusWindow::~MiniStatusWindow()
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index b9702e04..0b4ef4fe 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -350,31 +350,13 @@ void Setup::action(const std::string &eventId)
}
else if (eventId == "winsToDefault")
{
- int screenW = graphics->getWidth();
- int screenH = graphics->getHeight();
-
- statusWindow->setWidth(365);
- statusWindow->setHeight(255);
- statusWindow->setPosition((screenW - statusWindow->getWidth()) / 2,
- (screenH - statusWindow->getHeight()) / 2);
-
- minimap->setPosition(3, 30);
-
- chatWindow->setWidth(600);
- chatWindow->setHeight(100);
- chatWindow->setPosition(0, screenH - chatWindow->getHeight());
- if (chatWindow->getContent() != NULL)
- {
- chatWindow->getContent()->setDimension(gcn::Rectangle(0,0,594,80));
- }
-
- inventoryWindow->setWidth(322);
- inventoryWindow->setHeight(172);
- inventoryWindow->setPosition(60, 5);
-
- equipmentWindow->setPosition(5,140);
-
- helpWindow->setPosition(100,100);
-
+ statusWindow->resetToDefaultSize();
+ minimap->resetToDefaultSize();
+ chatWindow->resetToDefaultSize();
+ inventoryWindow->resetToDefaultSize();
+ inventoryWindow->updateWidgets();
+ equipmentWindow->resetToDefaultSize();
+ helpWindow->resetToDefaultSize();
+ skillDialog->resetToDefaultSize();
}
}
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 2e9b91a5..d9c224be 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -34,6 +34,9 @@
#include "../net/messageout.h"
#include "../net/protocol.h"
+#include "graphics.h"
+extern Graphics *graphics;
+
char *skill_db[] = {
// 0-99
"", "Basic", "Sword", "Two hand", "HP regeneration", "Bash", "Provoke", "Magnum", "Endure", "MP regeneration",
@@ -65,6 +68,7 @@ SkillDialog::SkillDialog():
skillPoints(0)
{
setWindowName("Skills");
+ setDefaultSize(graphics->getWidth() - 255, 25, 240, 240);
skillListBox = new ListBox(this);
skillScrollArea = new ScrollArea(skillListBox);
@@ -79,7 +83,6 @@ SkillDialog::SkillDialog():
useButton->setEventId("use");
closeButton->setEventId("close");
- setContentSize(240, 240);
skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
skillScrollArea->setDimension(gcn::Rectangle(5, 5, 230, 180));
pointsLabel->setDimension(gcn::Rectangle(8, 190, 200, 16));
@@ -102,6 +105,7 @@ SkillDialog::SkillDialog():
closeButton->addActionListener(this);
setLocationRelativeTo(getParent());
+ loadWindowState();
}
SkillDialog::~SkillDialog()
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 09c88978..8076d93b 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -34,12 +34,17 @@
#include "../net/messageout.h"
#include "../net/protocol.h"
+#include "graphics.h"
+extern Graphics *graphics;
+
StatusWindow::StatusWindow():
Window(player_info->name)
{
setWindowName("Status");
setResizable(true);
- setContentSize(365, 255);
+ setDefaultSize((graphics->getWidth() - 365) / 2,
+ (graphics->getHeight() - 255) / 2, 365, 255);
+ loadWindowState();
// ----------------------
// Status Part
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 0446e6eb..5b125bd2 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -441,3 +441,24 @@ void Window::loadWindowState()
}
}
}
+
+void Window::setDefaultSize(int defaultX, int defaultY, int defaultWidth, int defaultHeight)
+{
+ this->defaultX = defaultX;
+ this->defaultY = defaultY;
+ this->defaultWidth = defaultWidth;
+ this->defaultHeight = defaultHeight;
+
+ setPosition(defaultX, defaultY);
+ setContentSize(defaultWidth, defaultHeight);
+}
+
+void Window::resetToDefaultSize()
+{
+ setPosition(defaultX, defaultY);
+ setContentSize(defaultWidth, defaultHeight);
+ if (mContent != NULL)
+ {
+ mContent->setDimension(getContentDimension());
+ }
+}
diff --git a/src/gui/window.h b/src/gui/window.h
index 05d9291b..a48d3851 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -179,6 +179,18 @@ class Window : public gcn::Window
*/
void loadWindowState();
+ /**
+ * Set the default win pos and size.
+ * (which can be different of the actual ones.)
+ */
+ void setDefaultSize(int defaultX, int defaultY,
+ int defaultWidth, int defaultHeight);
+
+ /**
+ * Reset the win pos and size to default.
+ * Don't forget to set defaults first.
+ */
+ void resetToDefaultSize();
protected:
gcn::Container *chrome; /**< Contained container */
@@ -195,6 +207,8 @@ class Window : public gcn::Window
int minWinHeight; /**< Minimum window height */
int maxWinWidth; /**< Maximum window width */
int maxWinHeight; /**< Maximum window height */
+ int defaultX, defaultY; /**< Default Win Pos and size */
+ int defaultWidth, defaultHeight;
/** The window container windows add themselves to. */
static WindowContainer* windowContainer;