From 94119baeee42dd8f05dc3f68cd2743f5b75ecaad Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Fri, 6 Dec 2013 15:56:38 +0100 Subject: [PATCH] MRI-Binding: Add 'ViewportElement.viewport=' binding --- binding-mri/viewportelement-binding.h | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/binding-mri/viewportelement-binding.h b/binding-mri/viewportelement-binding.h index 996c6df..76c52a4 100644 --- a/binding-mri/viewportelement-binding.h +++ b/binding-mri/viewportelement-binding.h @@ -40,6 +40,32 @@ RB_METHOD(viewportElementGetViewport) return rb_iv_get(self, "viewport"); } +#ifdef RGSS2 + +template +RB_METHOD(viewportElementSetViewport) +{ + RB_UNUSED_PARAM; + + ViewportElement *ve = getPrivateData(self); + + VALUE viewportObj = Qnil; + Viewport *viewport = 0; + + rb_get_args(argc, argv, "o", &viewportObj, RB_ARG_END); + + if (rb_type(viewportObj) != RUBY_T_NIL) + viewport = getPrivateDataCheck(viewportObj, ViewportType); + + GUARD_EXC( ve->setViewport(viewport); ); + + rb_iv_set(self, "viewport", viewportObj); + + return viewportObj; +} + +#endif + template static C * viewportElementInitialize(int argc, VALUE *argv, VALUE self) @@ -69,6 +95,10 @@ viewportElementBindingInit(VALUE klass) sceneElementBindingInit(klass); _rb_define_method(klass, "viewport", viewportElementGetViewport); + +#ifdef RGSS2 + _rb_define_method(klass, "viewport=", viewportElementSetViewport); +#endif } #endif // VIEWPORTELEMENTBINDING_H