Implement RGSS2 Window class (WindowVX)

This commit is contained in:
Jonas Kulla 2014-08-12 21:50:59 +02:00
parent d654fb7dd6
commit 91d19d0a73
6 changed files with 1292 additions and 2 deletions

View File

@ -59,6 +59,10 @@ void planeBindingInit();
void windowBindingInit();
void tilemapBindingInit();
#ifdef RGSS2
void windowVXBindingInit();
#endif
void inputBindingInit();
void audioBindingInit();
void graphicsBindingInit();
@ -83,9 +87,14 @@ static void mriBindingInit()
spriteBindingInit();
viewportBindingInit();
planeBindingInit();
windowBindingInit();
tilemapBindingInit();
#ifdef RGSS2
windowVXBindingInit();
#else
windowBindingInit();
#endif
inputBindingInit();
audioBindingInit();
graphicsBindingInit();

View File

@ -0,0 +1,153 @@
/*
** 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"
DEF_TYPE(WindowVX);
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");
wrapNilProperty(self, "contents");
wrapProperty(self, w->getTone(), "tone", ToneType);
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
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);
_rb_define_method(klass, "closed?", windowVXIsClosed);
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" );
}

View File

@ -196,8 +196,12 @@ EMBED = \
assets/liberation.ttf
RGSS2 {
HEADERS += \
src/windowvx.h
SOURCES += \
src/vorbissource.cpp
src/vorbissource.cpp \
src/windowvx.cpp
EMBED += \
shader/blur.frag \
@ -311,6 +315,11 @@ BINDING_MRI {
binding-mri/audio-binding.cpp \
binding-mri/module_rpg.cpp \
binding-mri/filesystem-binding.cpp
RGSS2 {
SOURCES += \
binding-mri/windowvx-binding.cpp
}
}
OTHER_FILES += $$EMBED

View File

@ -29,6 +29,7 @@
class SceneElement;
class Viewport;
class WindowVX;
class Window;
struct ScanRow;
struct TilemapPrivate;
@ -63,6 +64,7 @@ protected:
friend class SceneElement;
friend class Window;
friend class WindowVX;
friend struct ScanRow;
};

1041
src/windowvx.cpp Normal file

File diff suppressed because it is too large Load Diff

76
src/windowvx.h Normal file
View File

@ -0,0 +1,76 @@
/*
** window-vx.h
**
** This file is part of mkxp.
**
** Copyright (C) 2014 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/>.
*/
#ifndef WINDOWVX_H
#define WINDOWVX_H
#include "viewport.h"
#include "disposable.h"
#include "util.h"
class Bitmap;
struct Rect;
struct Tone;
struct WindowVXPrivate;
class WindowVX : public ViewportElement, public Disposable
{
public:
WindowVX(Viewport *viewport = 0);
WindowVX(int x, int y, int width, int height);
~WindowVX();
void update();
void move(int x, int y, int width, int height);
bool isOpen() const;
bool isClosed() const;
DECL_ATTR( Windowskin, Bitmap* )
DECL_ATTR( Contents, Bitmap* )
DECL_ATTR( CursorRect, Rect* )
DECL_ATTR( Active, bool )
DECL_ATTR( ArrowsVisible, bool )
DECL_ATTR( Pause, bool )
DECL_ATTR( X, int )
DECL_ATTR( Y, int )
DECL_ATTR( Width, int )
DECL_ATTR( Height, int )
DECL_ATTR( OX, int )
DECL_ATTR( OY, int )
DECL_ATTR( Padding, int )
DECL_ATTR( PaddingBottom, int )
DECL_ATTR( Opacity, int )
DECL_ATTR( BackOpacity, int )
DECL_ATTR( ContentsOpacity, int )
DECL_ATTR( Openness, int )
DECL_ATTR( Tone, Tone* )
private:
WindowVXPrivate *p;
void draw();
void onGeometryChange(const Scene::Geometry &);
};
#endif // WINDOWVX_H