diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-09-28 21:26:23 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-09-28 21:26:23 +0000 |
commit | eb8dc37bfa07e1185308bc8d4748d92c69af1783 (patch) | |
tree | 43f8b726cc7f2c071c0641fdacb187c747aaaf5a /src | |
parent | e93e064373c382b80ecb37919335fbfe424efeea (diff) | |
download | mana-eb8dc37bfa07e1185308bc8d4748d92c69af1783.tar.gz mana-eb8dc37bfa07e1185308bc8d4748d92c69af1783.tar.bz2 mana-eb8dc37bfa07e1185308bc8d4748d92c69af1783.tar.xz mana-eb8dc37bfa07e1185308bc8d4748d92c69af1783.zip |
Save and load X, Y, Height, and Width to useful wins.
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 14 | ||||
-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 |
10 files changed, 54 insertions, 9 deletions
diff --git a/src/game.cpp b/src/game.cpp index 6897c036..c968fba7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -223,12 +223,21 @@ void createGuiWindows() 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(screenW - statusWindow->getWidth() - - inventoryWindow->getWidth() - 10, 5); + + inventoryWindow->setPosition(60, 5); + inventoryWindow->loadWindowState(); + chargeDialog->setPosition( screenW - 5 - chargeDialog->getWidth(), screenH - chargeDialog->getHeight() - 15); @@ -238,6 +247,7 @@ void createGuiWindows() /*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 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 */ |