From 0b478a22bfd5134dd6f43b5e4ade3ebacd8777f1 Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sun, 21 Oct 2007 19:05:56 +0000 Subject: Changed to use default values when restoring missing settings. --- ChangeLog | 2 ++ src/gui/window.cpp | 15 ++++++++------- src/gui/window.h | 7 +++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5802edbe..0bd9bdd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,8 @@ * data/maps/new_1-1.tmx: Added back a Lua script for testing. * src/gui/trade.cpp: Added persistent positioning. * src/gui/menuwindow.cpp: Fixed missing pixels at bottom and right. + * src/gui/window.cpp, src/gui/window.h: Changed to use default values + when restoring missing settings. 2007-10-20 Guillaume Melquiond diff --git a/src/gui/window.cpp b/src/gui/window.cpp index f8d4a503..1509ac92 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -525,13 +525,17 @@ void Window::loadWindowState(std::string const &name) { mConfigName = name; - setPosition((int) config.getValue(name + "WinX", getX()), - (int) config.getValue(name + "WinY", getY())); + setPosition((int) config.getValue(name + "WinX", mDefaultX), + (int) config.getValue(name + "WinY", mDefaultY)); if (mGrip) { - setSize((int) config.getValue(name + "WinWidth", getWidth()), - (int) config.getValue(name + "WinHeight", getHeight())); + setSize((int) config.getValue(name + "WinWidth", mDefaultWidth), + (int) config.getValue(name + "WinHeight", mDefaultHeight)); + } + else + { + setSize(mDefaultWidth, mDefaultHeight); } } @@ -542,9 +546,6 @@ void Window::setDefaultSize(int defaultX, int defaultY, mDefaultY = defaultY; mDefaultWidth = defaultWidth; mDefaultHeight = defaultHeight; - - setPosition(mDefaultX, mDefaultY); - setContentSize(mDefaultWidth, mDefaultHeight); } void Window::resetToDefaultSize() diff --git a/src/gui/window.h b/src/gui/window.h index 651a8a4e..a09a9bbc 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -240,10 +240,9 @@ class Window : public gcn::Window void mouseExited(gcn::MouseEvent &event); /** - * Read the x, y, and width and height for resizables in the config - * based on the given string. - * That function let the values set with set{X, Y, Height, width}() - * if no config value is found. + * Reads the position (and the size for resizable windows) in the + * configuration based on the given string. + * Uses the default values when config values are missing. * Don't forget to set these default values and resizable before * calling this function. */ -- cgit v1.2.3-70-g09d2