Graphics: Expose "fixed_aspect_ratio" as attribute

This commit is contained in:
Jonas Kulla 2017-03-02 11:56:55 +01:00
parent 85452bf2cf
commit ea742be6b0
3 changed files with 20 additions and 0 deletions

View File

@ -202,6 +202,8 @@ DEF_GRA_PROP_I(Brightness)
DEF_GRA_PROP_B(Fullscreen)
DEF_GRA_PROP_B(ShowCursor)
DEF_GRA_PROP_B(FixedAspectRatio)
#define INIT_GRA_PROP_BIND(PropName, prop_name_s) \
{ \
_rb_define_module_function(module, prop_name_s, graphics##Get##PropName); \
@ -222,6 +224,8 @@ void graphicsBindingInit()
INIT_GRA_PROP_BIND( FrameRate, "frame_rate" );
INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
INIT_GRA_PROP_BIND( FixedAspectRatio, "fixed_aspect_ratio" );
if (rgssVer >= 2)
{
_rb_define_module_function(module, "width", graphicsWidth);

View File

@ -1024,6 +1024,20 @@ void Graphics::setShowCursor(bool value)
p->threadData->ethread->requestShowCursor(value);
}
bool Graphics::getFixedAspectRatio() const
{
// It's a bit hacky to expose config values as a Graphics
// attribute, but there's really no point in state duplication
return shState->config().fixedAspectRatio;
}
void Graphics::setFixedAspectRatio(bool value)
{
shState->config().fixedAspectRatio = value;
p->recalculateScreenSize(p->threadData);
p->updateScreenResoRatio(p->threadData);
}
Scene *Graphics::getScreen() const
{
return &p->screen;

View File

@ -62,6 +62,8 @@ public:
DECL_ATTR( Fullscreen, bool )
DECL_ATTR( ShowCursor, bool )
DECL_ATTR( FixedAspectRatio, bool )
/* <internal> */
Scene *getScreen() const;
/* Repaint screen with static image until exitCond