diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 2 | ||||
-rw-r--r-- | src/gui/equipmentwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/help.cpp | 2 | ||||
-rw-r--r-- | src/gui/inventorywindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/minimap.cpp | 2 | ||||
-rw-r--r-- | src/gui/skill.cpp | 2 | ||||
-rw-r--r-- | src/gui/status.cpp | 2 | ||||
-rw-r--r-- | src/gui/window.cpp | 25 | ||||
-rw-r--r-- | src/gui/window.h | 10 |
9 files changed, 42 insertions, 7 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 0b31c8d6..e6868622 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -41,7 +41,7 @@ ChatWindow::ChatWindow(const std::string &logfile): Window("") { - setName("Chat"); + setWindowName("Chat"); chatlog_file.open(logfile.c_str(), std::ios::out | std::ios::app); items = 0; items_keep = 20; diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 93104c24..248e87f8 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -41,7 +41,7 @@ EquipmentWindow::EquipmentWindow(): { setContentSize(200, 90); setPosition(40, 40); - setName("Equipment"); + setWindowName("Equipment"); ResourceManager *resman = ResourceManager::getInstance(); Image *itemImg = resman->getImage("graphics/sprites/items.png"); diff --git a/src/gui/help.cpp b/src/gui/help.cpp index ac6d8c61..80ddbc9a 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -36,7 +36,7 @@ HelpWindow::HelpWindow(): Window("Help") { setContentSize(455, 350); - setName("Help"); + setWindowName("Help"); browserBox = new BrowserBox(); browserBox->setOpaque(false); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index bb4e8a4e..2f5841f6 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -46,7 +46,7 @@ InventoryWindow::InventoryWindow(): Window("Inventory") { setContentSize(322, 172); - setName("Inventory"); + setWindowName("Inventory"); useButton = new Button("Use"); dropButton = new Button("Drop"); diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index dedebcea..acfce00a 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -34,7 +34,7 @@ Minimap::Minimap(): Window("Map"), mMapImage(NULL) { - setName("MiniMap"); + setWindowName("MiniMap"); setContentSize(100, 100); setPosition(20, 20); } diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 6b33bf36..2e9b91a5 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -64,7 +64,7 @@ SkillDialog::SkillDialog(): Window("Skills"), skillPoints(0) { - setName("Skills"); + setWindowName("Skills"); skillListBox = new ListBox(this); skillScrollArea = new ScrollArea(skillListBox); diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 8b27146a..09c88978 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -37,7 +37,7 @@ StatusWindow::StatusWindow(): Window(player_info->name) { - setName("Status"); + setWindowName("Status"); setResizable(true); setContentSize(365, 255); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 706780be..0446e6eb 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -131,6 +131,15 @@ Window::~Window() { logger->log("Window::~Window(\"%s\")", getCaption().c_str()); + // Saving X, Y and Width and Height for resizables in the config + config.setValue(std::string(getWindowName() + "WinX"), getX()); + config.setValue(std::string(getWindowName() + "WinY"), getY()); + if ( resizable ) + { + config.setValue(std::string(getWindowName() + "WinWidth"), getWidth()); + config.setValue(std::string(getWindowName() + "WinHeight"), getHeight()); + } + instances--; if (instances == 0) @@ -416,3 +425,19 @@ std::string Window::getWindowName() { return mWindowName; } + +void Window::loadWindowState() +{ + setPosition((int)config.getValue(std::string(getWindowName() + "WinX"), getX()), + (int)config.getValue(std::string(getWindowName() + "WinY"), getY()) ); + + if ( resizable ) + { + setWidth((int)config.getValue(std::string(getWindowName() + "WinWidth"), getWidth()) ); + setHeight((int)config.getValue(std::string(getWindowName() + "WinHeight"), getHeight()) ); + if (mContent != NULL) + { + mContent->setDimension(getContentDimension()); + } + } +} diff --git a/src/gui/window.h b/src/gui/window.h index 057981ef..05d9291b 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -169,6 +169,16 @@ class Window : public gcn::Window */ std::string getWindowName(); + /** + * Read the X, Y, and Width and Height for resizables + * in the config based on its internal name. + * That function let the values set with set{X, Y, Height, width}() + * if no config value is found. + * Don't forget to set these default values and resizable before + * calling this function. + */ + void loadWindowState(); + protected: gcn::Container *chrome; /**< Contained container */ |