2013-09-01 14:27:21 +00:00
|
|
|
/*
|
|
|
|
** viewport-binding.cpp
|
|
|
|
**
|
|
|
|
** This file is part of mkxp.
|
|
|
|
**
|
|
|
|
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
|
|
|
**
|
|
|
|
** mkxp is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 2 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** mkxp is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "viewport.h"
|
|
|
|
#include "disposable-binding.h"
|
|
|
|
#include "flashable-binding.h"
|
|
|
|
#include "sceneelement-binding.h"
|
|
|
|
#include "binding-util.h"
|
|
|
|
#include "binding-types.h"
|
|
|
|
|
|
|
|
DEF_TYPE(Viewport);
|
|
|
|
|
|
|
|
MRB_METHOD(viewportInitialize)
|
|
|
|
{
|
|
|
|
Viewport *v;
|
|
|
|
|
|
|
|
if (mrb->c->ci->argc == 1)
|
|
|
|
{
|
|
|
|
/* The rect arg is only used to init the viewport,
|
|
|
|
* and does NOT replace its 'rect' property */
|
|
|
|
mrb_value rectObj;
|
|
|
|
Rect *rect;
|
|
|
|
|
|
|
|
mrb_get_args(mrb, "o", &rectObj);
|
|
|
|
|
|
|
|
rect = getPrivateDataCheck<Rect>(mrb, rectObj, RectType);
|
|
|
|
|
|
|
|
v = new Viewport(rect);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mrb_int x, y, width, height;
|
|
|
|
|
|
|
|
mrb_get_args(mrb, "iiii", &x, &y, &width, &height);
|
|
|
|
|
|
|
|
v = new Viewport(x, y, width, height);
|
|
|
|
}
|
|
|
|
|
2014-08-09 08:38:42 +00:00
|
|
|
setPrivateData(self, v, ViewportType);
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
/* Wrap property objects */
|
|
|
|
v->setRect(new Rect(*v->getRect()));
|
|
|
|
v->setColor(new Color);
|
|
|
|
v->setTone(new Tone);
|
|
|
|
|
|
|
|
wrapProperty(mrb, self, v->getRect(), CSrect, RectType);
|
|
|
|
wrapProperty(mrb, self, v->getColor(), CScolor, ColorType);
|
|
|
|
wrapProperty(mrb, self, v->getTone(), CStone, ToneType);
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DISP_CLASS_NAME "viewport"
|
|
|
|
|
|
|
|
DEF_PROP_OBJ(Viewport, Rect, Rect, CSrect)
|
|
|
|
DEF_PROP_OBJ(Viewport, Color, Color, CScolor)
|
|
|
|
DEF_PROP_OBJ(Viewport, Tone, Tone, CStone)
|
|
|
|
|
|
|
|
DEF_PROP_I(Viewport, OX)
|
|
|
|
DEF_PROP_I(Viewport, OY)
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
viewportBindingInit(mrb_state *mrb)
|
|
|
|
{
|
2014-07-19 00:22:22 +00:00
|
|
|
RClass *klass = defineClass(mrb, "Viewport");
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
disposableBindingInit <Viewport>(mrb, klass);
|
|
|
|
flashableBindingInit <Viewport>(mrb, klass);
|
|
|
|
sceneElementBindingInit<Viewport>(mrb, klass);
|
|
|
|
|
|
|
|
mrb_define_method(mrb, klass, "initialize", viewportInitialize, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(3));
|
|
|
|
|
|
|
|
INIT_PROP_BIND( Viewport, Rect, "rect" );
|
|
|
|
INIT_PROP_BIND( Viewport, OX, "ox" );
|
|
|
|
INIT_PROP_BIND( Viewport, OY, "oy" );
|
|
|
|
INIT_PROP_BIND( Viewport, Color, "color" );
|
|
|
|
INIT_PROP_BIND( Viewport, Tone, "tone" );
|
|
|
|
|
|
|
|
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
|
|
|
|
}
|