diff options
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | src/game.cpp | 19 | ||||
-rw-r--r-- | src/gui/chat.cpp | 6 | ||||
-rw-r--r-- | src/gui/equipmentwindow.cpp | 5 | ||||
-rw-r--r-- | src/gui/inventorywindow.cpp | 12 | ||||
-rw-r--r-- | src/gui/inventorywindow.h | 3 | ||||
-rw-r--r-- | src/gui/menuwindow.cpp | 9 | ||||
-rw-r--r-- | src/gui/minimap.cpp | 4 | ||||
-rw-r--r-- | src/gui/ministatus.cpp | 7 | ||||
-rw-r--r-- | src/gui/setup.cpp | 34 | ||||
-rw-r--r-- | src/gui/skill.cpp | 6 | ||||
-rw-r--r-- | src/gui/status.cpp | 7 | ||||
-rw-r--r-- | src/gui/window.cpp | 21 | ||||
-rw-r--r-- | src/gui/window.h | 14 |
14 files changed, 100 insertions, 65 deletions
@@ -1,9 +1,21 @@ +2005-09-29 Yohann Ferreira <bertram@cegetel.net> + + * src/game.cpp, src/gui/window.h, src/gui/window.cpp, src/gui/setup.h, + src/gui/setup.cpp, src/gui/chat.cpp, src/gui/inventorywindow.h, + src/gui/inventorywindow.cpp, src/gui/skill.cpp, + src/gui/equipmentwindow.cpp, src/gui/menuwindow.cpp, + src/gui/ministatus.cpp, src/gui/minimap.cpp, src/gui/status.cpp: + 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. + 2005-09-29 Bjørn Lindeijer <bjorn@lindeijer.nl> * src/map.cpp, src/map.h, src/tileset.h, src/resources/mapreader.cpp, src/resources/mapreader.h: Moved tileset management into the map class and made sure the tilesets are cleaned up properly on switching maps. + 2005-09-28 Yohann Ferreira <bertram@cegetel.net> * src/gui/updaterwindow.cpp: Fixed the scroll bug in the update window. @@ -14,8 +26,10 @@ src/gui/inventorywindow.cpp, src/gui/minimap.cpp, src/gui/chat.cpp: Added window internal name to later get X, Y, height and width be saved. - * src/gui/window.h, src/gui/window.cpp, src/game.cpp: Load and save X, - Y, Width and Height of windows when useful. + * src/gui/window.h, src/gui/window.cpp, src/game.cpp: Load and save X, Y, + Width and Height of windows when useful. + * src/gui/setup.cpp, src/gui/setup.h; src/gui/minimap.h: Added a 'Reset + Windows to Default' Button in the Setup Window. 2005-09-28 Björn Steinbrink <B.Steinbrink@gmx.de> diff --git a/src/game.cpp b/src/game.cpp index c968fba7..136fe347 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -221,23 +221,6 @@ void createGuiWindows() int screenW = graphics->getWidth(); int screenH = graphics->getHeight(); - statusWindow->setPosition((screenW - statusWindow->getWidth()) / 2, - (screenH - statusWindow->getHeight()) / 2); - statusWindow->loadWindowState(); - - miniStatusWindow->setPosition(0, 0); - - minimap->setPosition(3, 30); - minimap->loadWindowState(); - - chatWindow->setPosition(0, screenH - chatWindow->getHeight()); - chatWindow->loadWindowState(); - - menuWindow->setPosition(screenW - menuWindow->getWidth(), 0); - - inventoryWindow->setPosition(60, 5); - inventoryWindow->loadWindowState(); - chargeDialog->setPosition( screenW - 5 - chargeDialog->getWidth(), screenH - chargeDialog->getHeight() - 15); @@ -246,8 +229,6 @@ void createGuiWindows() inventoryWindow->getY() + inventoryWindow->getHeight()); /*buddyWindow->setPosition(10, minimap->getHeight() + 30);*/ - equipmentWindow->setPosition(5,140); - equipmentWindow->loadWindowState(); // Set initial window visibility chatWindow->setVisible(true); 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; |