From 7a099e23f9fb23d0eec2a17edb91f29640e44dcb Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 17 Sep 2010 23:28:05 -0300 Subject: [PATCH] Add some comments to GfxMode / CurrentGfxModeGuard. --- src/gfxmode.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/gfxmode.h b/src/gfxmode.h index 81452cf8a..f57074146 100644 --- a/src/gfxmode.h +++ b/src/gfxmode.h @@ -19,6 +19,7 @@ #ifndef GFXMODE_H_INCLUDED #define GFXMODE_H_INCLUDED +// Holds settings about a graphics mode. class GfxMode { public: @@ -46,19 +47,40 @@ private: int m_scaling; }; +// Tries a new graphics mode, and restores it back in the +// destructor. If the keep() method is used, the mode is not +// restored. class CurrentGfxModeGuard { public: + // Saves the current graphics mode as "the original" one. CurrentGfxModeGuard(); + + // Restores the graphics mode to its original in case we have used + // tryGfxMode() and we did not call keep(). After calling keep(), + // this destructor will do just nothing. ~CurrentGfxModeGuard(); + // Changes the current graphics mode. Returns true if the mode was + // changed successfully. If the function cannot change the new mode + // and cannot restore the original one, it finishes the program + // (with exit()). bool tryGfxMode(const GfxMode& newMode); + + // Keeps the last graphics mode set with tryGfxMode(). Indicates + // that the destructor should not restore the graphics mode to the + // original one. void keep(); + // It is the original graphics mode configured when the constructor + // of this class was called. const GfxMode& getOriginal() const; private: + // The original gfx mode. GfxMode m_oldMode; + + // True if we should keep any mode set with tryGfxMode() method. bool m_keep; };