add another cleanup remembering last windowed position code

This commit is contained in:
thrust26 2019-05-18 09:04:06 +02:00
parent 53597938b6
commit 49585250fd
6 changed files with 13 additions and 14 deletions

View File

@ -52,8 +52,7 @@ FrameBufferSDL2::FrameBufferSDL2(OSystem& osystem)
// been created // been created
myPixelFormat = SDL_AllocFormat(SDL_PIXELFORMAT_ARGB8888); myPixelFormat = SDL_AllocFormat(SDL_PIXELFORMAT_ARGB8888);
myPosX = myOSystem.settings().getInt("pos.x"); myWindowedPos = myOSystem.settings().getPoint("windowedpos");
myPosY = myOSystem.settings().getInt("pos.y");
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -175,9 +174,8 @@ void FrameBufferSDL2::updateWindowedPos()
if (!myCenter && myWindow && !(SDL_GetWindowFlags(myWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP)) if (!myCenter && myWindow && !(SDL_GetWindowFlags(myWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP))
{ {
// save current windowed position // save current windowed position
SDL_GetWindowPosition(myWindow, &myPosX, &myPosY); SDL_GetWindowPosition(myWindow, &myWindowedPos.x, &myWindowedPos.y);
myOSystem.settings().setValue("pos.x", myPosX); myOSystem.settings().setValue("windowedpos", myWindowedPos);
myOSystem.settings().setValue("pos.y", myPosY);
} }
} }
@ -223,8 +221,8 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode)
posX = posY = SDL_WINDOWPOS_CENTERED_DISPLAY(displayIndex); posX = posY = SDL_WINDOWPOS_CENTERED_DISPLAY(displayIndex);
else else
{ {
posX = myPosX, posX = myWindowedPos.x,
posY = myPosY; posY = myWindowedPos.y;
} }
uInt32 flags = mode.fsIndex != -1 ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0; uInt32 flags = mode.fsIndex != -1 ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0;

View File

@ -193,8 +193,7 @@ class FrameBufferSDL2 : public FrameBuffer
bool myCenter; bool myCenter;
// last position of windowed window // last position of windowed window
int myPosX; Common::Point myWindowedPos;
int myPosY;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -32,12 +32,12 @@ namespace Common {
*/ */
struct Point struct Point
{ {
uInt32 x; //!< The horizontal part of the point Int32 x; //!< The horizontal part of the point
uInt32 y; //!< The vertical part of the point Int32 y; //!< The vertical part of the point
Point() : x(0), y(0) { } Point() : x(0), y(0) { }
Point(const Point& p) : x(p.x), y(p.y) { } Point(const Point& p) : x(p.x), y(p.y) { }
explicit Point(uInt32 x1, uInt32 y1) : x(x1), y(y1) { } explicit Point(Int32 x1, Int32 y1) : x(x1), y(y1) { }
explicit Point(const string& p) : x(0), y(0) { explicit Point(const string& p) : x(0), y(0) {
char c = '\0'; char c = '\0';
istringstream buf(p); istringstream buf(p);

View File

@ -53,6 +53,7 @@ class Variant
Variant(double d) { buf().str(""); buf() << d; data = buf().str(); } Variant(double d) { buf().str(""); buf() << d; data = buf().str(); }
Variant(bool b) { buf().str(""); buf() << b; data = buf().str(); } Variant(bool b) { buf().str(""); buf() << b; data = buf().str(); }
Variant(const Common::Size& s) { buf().str(""); buf() << s; data = buf().str(); } Variant(const Common::Size& s) { buf().str(""); buf() << s; data = buf().str(); }
Variant(const Common::Point& s) { buf().str(""); buf() << s; data = buf().str(); }
// Conversion methods // Conversion methods
const string& toString() const { return data; } const string& toString() const { return data; }
@ -73,6 +74,7 @@ class Variant
} }
bool toBool() const { return data == "1" || data == "true"; } bool toBool() const { return data == "1" || data == "true"; }
Common::Size toSize() const { return Common::Size(data); } Common::Size toSize() const { return Common::Size(data); }
Common::Point toPoint() const { return Common::Point(data); }
// Comparison // Comparison
bool operator==(const Variant& v) const { return data == v.data; } bool operator==(const Variant& v) const { return data == v.data; }

View File

@ -38,8 +38,7 @@ Settings::Settings()
setPermanent("speed", "1.0"); setPermanent("speed", "1.0");
setPermanent("vsync", "true"); setPermanent("vsync", "true");
setPermanent("center", "true"); setPermanent("center", "true");
setPermanent("pos.x", 50); setPermanent("windowedpos", Common::Point(50, 50));
setPermanent("pos.y", 50);
setPermanent("display", 0); setPermanent("display", 0);
setPermanent("palette", "standard"); setPermanent("palette", "standard");
setPermanent("uimessages", "true"); setPermanent("uimessages", "true");

View File

@ -101,6 +101,7 @@ class Settings
bool getBool(const string& key) const { return value(key).toBool(); } bool getBool(const string& key) const { return value(key).toBool(); }
const string& getString(const string& key) const { return value(key).toString(); } const string& getString(const string& key) const { return value(key).toString(); }
const Common::Size getSize(const string& key) const { return value(key).toSize(); } const Common::Size getSize(const string& key) const { return value(key).toSize(); }
const Common::Point getPoint(const string& key) const { return value(key).toPoint(); }
protected: protected:
/** /**