diff --git a/binding/graphics-binding.cpp b/binding/graphics-binding.cpp index de2c6e67..3f8e3666 100644 --- a/binding/graphics-binding.cpp +++ b/binding/graphics-binding.cpp @@ -242,7 +242,8 @@ DEF_GRA_PROP_I(Brightness) DEF_GRA_PROP_B(Fullscreen) DEF_GRA_PROP_B(ShowCursor) -DEF_GRA_PROP_F(Scale); +DEF_GRA_PROP_F(Scale) +DEF_GRA_PROP_B(Frameskip) #define INIT_GRA_PROP_BIND(PropName, prop_name_s) \ { \ @@ -286,4 +287,5 @@ void graphicsBindingInit() INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" ); INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" ); INIT_GRA_PROP_BIND( Scale, "scale" ); + INIT_GRA_PROP_BIND( Frameskip, "frameskip" ); } diff --git a/mkxp.json.sample b/mkxp.json.sample index 0f8da5e2..2cf8b571 100644 --- a/mkxp.json.sample +++ b/mkxp.json.sample @@ -114,7 +114,9 @@ // "fixedFramerate": 0, - // Skip (don't draw) frames when behind + // Skip (don't draw) frames when behind. + // Can be changed at runtime, but this is the + // default value when the game starts. // (default: disabled) // // "frameSkip": false, diff --git a/src/graphics.cpp b/src/graphics.cpp index 24584209..92cd511d 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -425,6 +425,9 @@ struct GraphicsPrivate { FPSLimiter fpsLimiter; + // Can be set from Ruby. Takes priority over config setting. + bool useFrameSkip; + bool frozen; TEXFBO frozenScene; Quad screenQuad; @@ -438,7 +441,8 @@ struct GraphicsPrivate { winSize(rtData->config.defScreenW, rtData->config.defScreenH), screen(scRes.x, scRes.y), threadData(rtData), glCtx(SDL_GL_GetCurrentContext()), frameRate(DEF_FRAMERATE), - frameCount(0), brightness(255), fpsLimiter(frameRate), frozen(false) { + frameCount(0), brightness(255), fpsLimiter(frameRate), + useFrameSkip(rtData->config.frameSkip), frozen(false) { recalculateScreenSize(rtData); updateScreenResoRatio(rtData); @@ -595,7 +599,7 @@ void Graphics::update() { return; if (p->fpsLimiter.frameSkipRequired()) { - if (p->threadData->config.frameSkip) { + if (p->useFrameSkip) { /* Skip frame */ p->fpsLimiter.delay(); ++p->frameCount; @@ -928,7 +932,11 @@ void Graphics::reset() { setBrightness(255); } -void Graphics::center() { p->threadData->ethread->requestWindowCenter(); } +void Graphics::center() { + if (getFullscreen()) + return; + p->threadData->ethread->requestWindowCenter(); +} bool Graphics::getFullscreen() const { return p->threadData->ethread->getFullscreen(); @@ -968,6 +976,10 @@ void Graphics::setScale(double factor) { } } +bool Graphics::getFrameskip() const { return p->useFrameSkip; } + +void Graphics::setFrameskip(bool value) { p->useFrameSkip = value; } + Scene *Graphics::getScreen() const { return &p->screen; } void Graphics::repaintWait(const AtomicFlag &exitCond, bool checkReset) { diff --git a/src/graphics.h b/src/graphics.h index d32035ae..8c9b8ed9 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -63,7 +63,8 @@ public: /* Non-standard extension */ DECL_ATTR( Fullscreen, bool ) DECL_ATTR( ShowCursor, bool ) - DECL_ATTR( Scale, double ) + DECL_ATTR( Scale, double ) + DECL_ATTR( Frameskip, bool ) /* */ Scene *getScreen() const;