From f5a178b9bba8771fb53669742adbade3ba33880a Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Thu, 17 Oct 2013 02:18:16 +0200 Subject: [PATCH] Add config option "fixedFramerate" --- README.md | 1 + src/config.cpp | 2 ++ src/config.h | 2 ++ src/graphics.cpp | 7 +++++++ 4 files changed, 12 insertions(+) diff --git a/README.md b/README.md index d2af8ac..6fccdc4 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ mkxp reads configuration data from the file "mkxp.conf" contained in the current | vsync | bool | false | Sync screen redraws to the monitor refresh rate | | defScreenW | int | 640 | Width the game window starts in (this is **not** the game resolution) | | defScreenH | int | 480 | Height the game window starts in | +| fixedFramerate | int | 0 | FPS will be fixed to this amount. Ignored if 0. | | solidFonts | bool | false | Don't use alpha blending for fonts | | gameFolder | string | "." | mkxp will look for all game related files here | | customScript | string | "" | Execute a raw ruby script file instead of an RPG Maker game. | diff --git a/src/config.cpp b/src/config.cpp index 8ec62d5..0b24682 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -37,6 +37,7 @@ Config::Config() vsync(false), defScreenW(640), defScreenH(480), + fixedFramerate(0), solidFonts(false), gameFolder(".") {} @@ -55,6 +56,7 @@ void Config::read() READ_VAL(vsync, Bool); READ_VAL(defScreenW, Int); READ_VAL(defScreenH, Int); + READ_VAL(fixedFramerate, Int); READ_VAL(solidFonts, Bool); READ_VAL(gameFolder, ByteArray); READ_VAL(customScript, ByteArray); diff --git a/src/config.h b/src/config.h index 6d1492a..29c949e 100644 --- a/src/config.h +++ b/src/config.h @@ -40,6 +40,8 @@ struct Config int defScreenW; int defScreenH; + int fixedFramerate; + bool solidFonts; QByteArray gameFolder; diff --git a/src/graphics.cpp b/src/graphics.cpp index 7dc3db2..fd78535 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -451,6 +451,9 @@ Graphics::Graphics(RGSSThreadData *data) { p = new GraphicsPrivate; p->threadData = data; + + if (data->config.fixedFramerate > 0) + p->fpsLimiter.setDesiredFPS(data->config.fixedFramerate); } Graphics::~Graphics() @@ -580,6 +583,10 @@ DEF_ATTR_SIMPLE(Graphics, FrameCount, int, p->frameCount) void Graphics::setFrameRate(int value) { p->frameRate = clamp(value, 10, 120); + + if (p->threadData->config.fixedFramerate > 0) + return; + p->fpsLimiter.setDesiredFPS(p->frameRate); }