2014-08-12 19:50:59 +00:00
|
|
|
/*
|
|
|
|
** window-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 "windowvx.h"
|
|
|
|
#include "disposable-binding.h"
|
|
|
|
#include "viewportelement-binding.h"
|
|
|
|
#include "binding-util.h"
|
|
|
|
|
2014-08-16 21:38:04 +00:00
|
|
|
#include "bitmap.h"
|
|
|
|
|
2014-08-12 19:50:59 +00:00
|
|
|
DEF_TYPE(WindowVX);
|
|
|
|
|
2014-08-16 21:38:04 +00:00
|
|
|
void bitmapInitProps(Bitmap *b, VALUE self);
|
|
|
|
|
2014-08-12 19:50:59 +00:00
|
|
|
RB_METHOD(windowVXInitialize)
|
|
|
|
{
|
|
|
|
int x, y, width, height;
|
|
|
|
x = y = width = height = 0;
|
|
|
|
|
|
|
|
if (argc == 4)
|
|
|
|
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
|
|
|
|
|
|
|
|
WindowVX *w = new WindowVX(x, y, width, height);
|
|
|
|
|
|
|
|
setPrivateData(self, w);
|
|
|
|
|
|
|
|
w->setCursorRect(new Rect);
|
|
|
|
w->setTone(new Tone);
|
|
|
|
wrapNilProperty(self, "windowskin");
|
|
|
|
wrapProperty(self, w->getTone(), "tone", ToneType);
|
|
|
|
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
|
|
|
|
|
2014-08-16 21:38:04 +00:00
|
|
|
#ifdef RGSS2
|
|
|
|
Bitmap *contents = new Bitmap(1, 1);
|
|
|
|
VALUE contentsObj = wrapObject(contents, BitmapType);
|
|
|
|
bitmapInitProps(contents, contentsObj);
|
|
|
|
rb_iv_set(self, "contents", contentsObj);
|
|
|
|
#endif
|
|
|
|
|
2014-08-12 19:50:59 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_METHOD(windowVXUpdate)
|
|
|
|
{
|
|
|
|
RB_UNUSED_PARAM;
|
|
|
|
|
|
|
|
WindowVX *w = getPrivateData<WindowVX>(self);
|
|
|
|
|
|
|
|
w->update();
|
|
|
|
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_METHOD(windowVXMove)
|
|
|
|
{
|
|
|
|
WindowVX *w = getPrivateData<WindowVX>(self);
|
|
|
|
|
|
|
|
int x, y, width, height;
|
|
|
|
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
|
|
|
|
|
|
|
|
w->move(x, y, width, height);
|
|
|
|
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_METHOD(windowVXIsOpen)
|
|
|
|
{
|
|
|
|
RB_UNUSED_PARAM;
|
|
|
|
|
|
|
|
WindowVX *w = getPrivateData<WindowVX>(self);
|
|
|
|
|
|
|
|
return rb_bool_new(w->isOpen());
|
|
|
|
}
|
|
|
|
|
|
|
|
RB_METHOD(windowVXIsClosed)
|
|
|
|
{
|
|
|
|
RB_UNUSED_PARAM;
|
|
|
|
|
|
|
|
WindowVX *w = getPrivateData<WindowVX>(self);
|
|
|
|
|
|
|
|
return rb_bool_new(w->isClosed());
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_PROP_OBJ_NIL(WindowVX, Bitmap, Windowskin, "windowskin")
|
|
|
|
DEF_PROP_OBJ_NIL(WindowVX, Bitmap, Contents, "contents")
|
|
|
|
|
|
|
|
DEF_PROP_OBJ(WindowVX, Rect, CursorRect, "cursor_rect")
|
|
|
|
DEF_PROP_OBJ(WindowVX, Tone, Tone, "tone")
|
|
|
|
|
|
|
|
DEF_PROP_I(WindowVX, X)
|
|
|
|
DEF_PROP_I(WindowVX, Y)
|
|
|
|
DEF_PROP_I(WindowVX, OX)
|
|
|
|
DEF_PROP_I(WindowVX, OY)
|
|
|
|
DEF_PROP_I(WindowVX, Width)
|
|
|
|
DEF_PROP_I(WindowVX, Height)
|
|
|
|
DEF_PROP_I(WindowVX, Padding)
|
|
|
|
DEF_PROP_I(WindowVX, PaddingBottom)
|
|
|
|
DEF_PROP_I(WindowVX, Opacity)
|
|
|
|
DEF_PROP_I(WindowVX, BackOpacity)
|
|
|
|
DEF_PROP_I(WindowVX, ContentsOpacity)
|
|
|
|
DEF_PROP_I(WindowVX, Openness)
|
|
|
|
|
|
|
|
DEF_PROP_B(WindowVX, Active)
|
|
|
|
DEF_PROP_B(WindowVX, ArrowsVisible)
|
|
|
|
DEF_PROP_B(WindowVX, Pause)
|
|
|
|
|
|
|
|
void
|
|
|
|
windowVXBindingInit()
|
|
|
|
{
|
|
|
|
// FIXME: data type name will end up as "WindowVX"
|
|
|
|
INIT_TYPE(WindowVX);
|
|
|
|
|
|
|
|
VALUE klass = rb_define_class("Window", rb_cObject);
|
|
|
|
rb_define_alloc_func(klass, classAllocate<&WindowVXType>);
|
|
|
|
|
|
|
|
disposableBindingInit <WindowVX>(klass);
|
|
|
|
viewportElementBindingInit<WindowVX>(klass);
|
|
|
|
|
|
|
|
_rb_define_method(klass, "initialize", windowVXInitialize);
|
|
|
|
|
|
|
|
_rb_define_method(klass, "update", windowVXUpdate);
|
|
|
|
_rb_define_method(klass, "move", windowVXMove);
|
|
|
|
_rb_define_method(klass, "open?", windowVXIsOpen);
|
2014-08-15 21:09:21 +00:00
|
|
|
_rb_define_method(klass, "close?", windowVXIsClosed);
|
2014-08-12 19:50:59 +00:00
|
|
|
|
|
|
|
INIT_PROP_BIND( WindowVX, Windowskin, "windowskin" );
|
|
|
|
INIT_PROP_BIND( WindowVX, Contents, "contents" );
|
|
|
|
INIT_PROP_BIND( WindowVX, CursorRect, "cursor_rect" );
|
|
|
|
INIT_PROP_BIND( WindowVX, Active, "active" );
|
|
|
|
INIT_PROP_BIND( WindowVX, ArrowsVisible, "arrows_visible" );
|
|
|
|
INIT_PROP_BIND( WindowVX, Pause, "pause" );
|
|
|
|
INIT_PROP_BIND( WindowVX, X, "x" );
|
|
|
|
INIT_PROP_BIND( WindowVX, Y, "y" );
|
|
|
|
INIT_PROP_BIND( WindowVX, Width, "width" );
|
|
|
|
INIT_PROP_BIND( WindowVX, Height, "height" );
|
|
|
|
INIT_PROP_BIND( WindowVX, OX, "ox" );
|
|
|
|
INIT_PROP_BIND( WindowVX, OY, "oy" );
|
|
|
|
INIT_PROP_BIND( WindowVX, Padding, "padding" );
|
|
|
|
INIT_PROP_BIND( WindowVX, PaddingBottom, "padding_bottom" );
|
|
|
|
INIT_PROP_BIND( WindowVX, Opacity, "opacity" );
|
|
|
|
INIT_PROP_BIND( WindowVX, BackOpacity, "back_opacity" );
|
|
|
|
INIT_PROP_BIND( WindowVX, ContentsOpacity, "contents_opacity" );
|
|
|
|
INIT_PROP_BIND( WindowVX, Openness, "openness" );
|
|
|
|
INIT_PROP_BIND( WindowVX, Tone, "tone" );
|
|
|
|
}
|