mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-23 15:23:44 +02:00
Implement plane bindings for binding-sandbox
This commit is contained in:
parent
74ebe267ee
commit
a75cf4ae22
14 changed files with 1115 additions and 14 deletions
|
@ -32,6 +32,7 @@
|
|||
#include "font-binding.h"
|
||||
#include "graphics-binding.h"
|
||||
#include "input-binding.h"
|
||||
#include "plane-binding.h"
|
||||
#include "sprite-binding.h"
|
||||
#include "table-binding.h"
|
||||
#include "tilemap-binding.h"
|
||||
|
@ -249,6 +250,7 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(bitmap_binding_init);
|
||||
SANDBOX_AWAIT(sprite_binding_init);
|
||||
SANDBOX_AWAIT(viewport_binding_init);
|
||||
SANDBOX_AWAIT(plane_binding_init);
|
||||
|
||||
// TODO: pick the correct window and tilemap bindings depending on RPG Maker version
|
||||
SANDBOX_AWAIT(window_binding_init);
|
||||
|
|
|
@ -183,10 +183,54 @@ namespace mkxp_sandbox {
|
|||
return sb()->bind<struct rb_ull2inum>()()(get_private_data<Bitmap>(self)->width());
|
||||
}
|
||||
|
||||
static VALUE rect(VALUE self) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
ID id;
|
||||
VALUE klass;
|
||||
VALUE obj;
|
||||
|
||||
VALUE operator()(VALUE self) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(id, rb_intern, "Color");
|
||||
SANDBOX_AWAIT_AND_SET(klass, rb_const_get, sb()->rb_cObject(), id);
|
||||
SANDBOX_AWAIT_AND_SET(obj, rb_class_new_instance, 0, NULL, klass);
|
||||
set_private_data(obj, new Rect(get_private_data<Bitmap>(self)->rect()));
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self);
|
||||
}
|
||||
|
||||
static VALUE height(VALUE self) {
|
||||
return sb()->bind<struct rb_ull2inum>()()(get_private_data<Bitmap>(self)->height());
|
||||
}
|
||||
|
||||
static VALUE text_size(VALUE self, VALUE text) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
wasm_ptr_t str;
|
||||
ID id;
|
||||
VALUE klass;
|
||||
VALUE obj;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE text) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(str, rb_string_value_cstr, &text);
|
||||
SANDBOX_AWAIT_AND_SET(id, rb_intern, "Rect");
|
||||
SANDBOX_AWAIT_AND_SET(klass, rb_const_get, sb()->rb_cObject(), id);
|
||||
SANDBOX_AWAIT_AND_SET(obj, rb_class_new_instance, 0, NULL, klass);
|
||||
set_private_data(obj, new Rect(get_private_data<Bitmap>(self)->textSize((const char *)(**sb() + str))));
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, text);
|
||||
}
|
||||
|
||||
VALUE klass;
|
||||
|
||||
void operator()() {
|
||||
|
@ -203,6 +247,8 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_method, klass, "font", (VALUE (*)(ANYARGS))get_font, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "width", (VALUE (*)(ANYARGS))width, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "height", (VALUE (*)(ANYARGS))height, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "rect", (VALUE (*)(ANYARGS))rect, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "text_size", (VALUE (*)(ANYARGS))text_size, 1);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -102,6 +102,90 @@ namespace mkxp_sandbox {
|
|||
return sb()->bind<struct coro>()()(argc, argv, self);
|
||||
}
|
||||
|
||||
static VALUE get_red(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Color>(self)->getRed());
|
||||
}
|
||||
|
||||
static VALUE set_red(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int red;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(red, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Color>(self)->setRed(red));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_green(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Color>(self)->getGreen());
|
||||
}
|
||||
|
||||
static VALUE set_green(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int green;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(green, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Color>(self)->setGreen(green));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_blue(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Color>(self)->getBlue());
|
||||
}
|
||||
|
||||
static VALUE set_blue(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int blue;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(blue, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Color>(self)->setBlue(blue));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_alpha(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Color>(self)->getAlpha());
|
||||
}
|
||||
|
||||
static VALUE set_alpha(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int alpha;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(alpha, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Color>(self)->setAlpha(alpha));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
VALUE klass;
|
||||
|
||||
void operator()() {
|
||||
|
@ -112,6 +196,14 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_singleton_method, klass, "_load", (VALUE (*)(ANYARGS))load, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "initialize", (VALUE (*)(ANYARGS))initialize, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "set", (VALUE (*)(ANYARGS))set, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "red", (VALUE (*)(ANYARGS))get_red, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "red=", (VALUE (*)(ANYARGS))set_red, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "green", (VALUE (*)(ANYARGS))get_green, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "green=", (VALUE (*)(ANYARGS))set_green, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "blue", (VALUE (*)(ANYARGS))get_blue, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "blue=", (VALUE (*)(ANYARGS))set_blue, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "alpha", (VALUE (*)(ANYARGS))get_alpha, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "alpha=", (VALUE (*)(ANYARGS))set_alpha, 1);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -186,6 +278,90 @@ namespace mkxp_sandbox {
|
|||
return sb()->bind<struct coro>()()(argc, argv, self);
|
||||
}
|
||||
|
||||
static VALUE get_red(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Tone>(self)->getRed());
|
||||
}
|
||||
|
||||
static VALUE set_red(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int red;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(red, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Tone>(self)->setRed(red));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_green(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Tone>(self)->getGreen());
|
||||
}
|
||||
|
||||
static VALUE set_green(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int green;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(green, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Tone>(self)->setGreen(green));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_blue(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Tone>(self)->getBlue());
|
||||
}
|
||||
|
||||
static VALUE set_blue(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int blue;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(blue, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Tone>(self)->setBlue(blue));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_gray(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Tone>(self)->getGray());
|
||||
}
|
||||
|
||||
static VALUE set_gray(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int gray;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(gray, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Tone>(self)->setGray(gray));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
VALUE klass;
|
||||
|
||||
void operator()() {
|
||||
|
@ -196,6 +372,14 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_singleton_method, klass, "_load", (VALUE (*)(ANYARGS))load, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "initialize", (VALUE (*)(ANYARGS))initialize, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "set", (VALUE (*)(ANYARGS))set, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "red", (VALUE (*)(ANYARGS))get_red, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "red=", (VALUE (*)(ANYARGS))set_red, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "green", (VALUE (*)(ANYARGS))get_green, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "green=", (VALUE (*)(ANYARGS))set_green, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "blue", (VALUE (*)(ANYARGS))get_blue, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "blue=", (VALUE (*)(ANYARGS))set_blue, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "gray", (VALUE (*)(ANYARGS))get_gray, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "gray=", (VALUE (*)(ANYARGS))set_gray, 1);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -262,6 +446,95 @@ namespace mkxp_sandbox {
|
|||
return sb()->bind<struct coro>()()(argc, argv, self);
|
||||
}
|
||||
|
||||
static VALUE empty(VALUE self) {
|
||||
get_private_data<Rect>(self)->empty();
|
||||
return self;
|
||||
}
|
||||
|
||||
static VALUE get_x(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Rect>(self)->getX());
|
||||
}
|
||||
|
||||
static VALUE set_x(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int x;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(x, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Rect>(self)->setX(x));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_y(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Rect>(self)->getY());
|
||||
}
|
||||
|
||||
static VALUE set_y(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int y;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(y, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Rect>(self)->setY(y));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_width(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Rect>(self)->getWidth());
|
||||
}
|
||||
|
||||
static VALUE set_width(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int width;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(width, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Rect>(self)->setWidth(width));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_height(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Rect>(self)->getHeight());
|
||||
}
|
||||
|
||||
static VALUE set_height(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int height;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(height, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Rect>(self)->setHeight(height));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
VALUE klass;
|
||||
|
||||
void operator()() {
|
||||
|
@ -272,6 +545,15 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_singleton_method, klass, "_load", (VALUE (*)(ANYARGS))load, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "initialize", (VALUE (*)(ANYARGS))initialize, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "set", (VALUE (*)(ANYARGS))set, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "empty", (VALUE (*)(ANYARGS))empty, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "x", (VALUE (*)(ANYARGS))get_x, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "x=", (VALUE (*)(ANYARGS))set_x, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "y", (VALUE (*)(ANYARGS))get_y, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "y=", (VALUE (*)(ANYARGS))set_y, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "width", (VALUE (*)(ANYARGS))get_width, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "width=", (VALUE (*)(ANYARGS))set_width, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "height", (VALUE (*)(ANYARGS))get_height, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "height=", (VALUE (*)(ANYARGS))set_height, 1);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -23,11 +23,44 @@
|
|||
#define MKXPZ_SANDBOX_FONT_BINDING_H
|
||||
|
||||
#include "sandbox.h"
|
||||
#include "binding-util.h"
|
||||
#include "etc.h"
|
||||
|
||||
namespace mkxp_sandbox {
|
||||
SANDBOX_COROUTINE(font_binding_init,
|
||||
VALUE klass;
|
||||
|
||||
static VALUE initialize(int32_t argc, wasm_ptr_t argv, VALUE self) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
ID id;
|
||||
VALUE klass;
|
||||
VALUE obj;
|
||||
|
||||
VALUE operator()(int32_t argc, wasm_ptr_t argv, VALUE self) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(id, rb_intern, "Color");
|
||||
SANDBOX_AWAIT_AND_SET(klass, rb_const_get, sb()->rb_cObject(), id);
|
||||
SANDBOX_AWAIT_AND_SET(obj, rb_class_new_instance, 0, NULL, klass);
|
||||
set_private_data(obj, new Color());
|
||||
SANDBOX_AWAIT(rb_iv_set, self, "color", obj);
|
||||
}
|
||||
|
||||
return SANDBOX_NIL;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(argc, argv, self);
|
||||
}
|
||||
|
||||
static VALUE get_color(VALUE self) {
|
||||
return sb()->bind<struct rb_iv_get>()()(self, "color");
|
||||
}
|
||||
|
||||
static VALUE set_color(VALUE self, VALUE value) {
|
||||
sb()->bind<struct rb_iv_set>()()(self, "color", value);
|
||||
return value;
|
||||
}
|
||||
|
||||
static VALUE todo(int32_t argc, wasm_ptr_t argv, VALUE self) {
|
||||
return SANDBOX_NIL;
|
||||
}
|
||||
|
@ -35,11 +68,13 @@ namespace mkxp_sandbox {
|
|||
void operator()() {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(klass, rb_define_class, "Font", sb()->rb_cObject());
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "initialize", (VALUE (*)(ANYARGS))initialize, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "name=", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "size=", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "bold=", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "italic=", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "color=", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "color", (VALUE (*)(ANYARGS))get_color, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "color=", (VALUE (*)(ANYARGS))set_color, 1);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -40,6 +40,10 @@ namespace mkxp_sandbox {
|
|||
return sb()->bind<struct coro>()()(self);
|
||||
}
|
||||
|
||||
static VALUE get_frame_rate(VALUE self) {
|
||||
return sb()->bind<struct rb_float_new>()()(60.0); // TODO: use actual FPS
|
||||
}
|
||||
|
||||
static VALUE todo(int32_t argc, wasm_ptr_t argv, VALUE self) {
|
||||
return SANDBOX_NIL;
|
||||
}
|
||||
|
@ -59,6 +63,7 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_module_function, module, "frame_reset", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_module_function, module, "frame_count", (VALUE (*)(ANYARGS))todo_number, -1);
|
||||
SANDBOX_AWAIT(rb_define_module_function, module, "frame_count=", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_module_function, module, "frame_rate", (VALUE (*)(ANYARGS))get_frame_rate, 0);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
354
binding-sandbox/plane-binding.h
Normal file
354
binding-sandbox/plane-binding.h
Normal file
|
@ -0,0 +1,354 @@
|
|||
/*
|
||||
** plane-binding.h
|
||||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
**
|
||||
** 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 MKXPZ_SANDBOX_PLANE_BINDING_H
|
||||
#define MKXPZ_SANDBOX_PLANE_BINDING_H
|
||||
|
||||
#include "sandbox.h"
|
||||
#include "binding-util.h"
|
||||
#include "plane.h"
|
||||
|
||||
namespace mkxp_sandbox {
|
||||
static struct mkxp_sandbox::bindings::rb_data_type plane_type;
|
||||
|
||||
SANDBOX_COROUTINE(plane_binding_init,
|
||||
SANDBOX_DEF_ALLOC(plane_type)
|
||||
SANDBOX_DEF_DFREE(Plane)
|
||||
|
||||
static VALUE initialize(int32_t argc, wasm_ptr_t argv, VALUE self) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
Plane *plane;
|
||||
VALUE viewport_obj;
|
||||
Viewport *viewport;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t w;
|
||||
int32_t h;
|
||||
ID id;
|
||||
VALUE klass;
|
||||
VALUE obj;
|
||||
VALUE ary;
|
||||
unsigned int i;
|
||||
|
||||
VALUE operator()(int32_t argc, wasm_ptr_t argv, VALUE self) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
viewport_obj = SANDBOX_NIL;
|
||||
viewport = NULL;
|
||||
if (argc > 0) {
|
||||
viewport_obj = *(VALUE *)(**sb() + argv);
|
||||
if (viewport_obj != SANDBOX_NIL) {
|
||||
viewport = get_private_data<Viewport>(viewport_obj);
|
||||
}
|
||||
}
|
||||
|
||||
GFX_LOCK
|
||||
plane = new Plane(viewport);
|
||||
|
||||
set_private_data(self, plane);
|
||||
|
||||
plane->initDynAttribs();
|
||||
|
||||
SANDBOX_AWAIT_AND_SET(id, rb_intern, "Color");
|
||||
SANDBOX_AWAIT_AND_SET(klass, rb_const_get, sb()->rb_cObject(), id);
|
||||
SANDBOX_AWAIT_AND_SET(obj, rb_class_new_instance, 0, NULL, klass);
|
||||
set_private_data(obj, &plane->getColor());
|
||||
SANDBOX_AWAIT(rb_iv_set, self, "color", obj);
|
||||
|
||||
SANDBOX_AWAIT_AND_SET(id, rb_intern, "Tone");
|
||||
SANDBOX_AWAIT_AND_SET(klass, rb_const_get, sb()->rb_cObject(), id);
|
||||
SANDBOX_AWAIT_AND_SET(obj, rb_class_new_instance, 0, NULL, klass);
|
||||
set_private_data(obj, &plane->getTone());
|
||||
SANDBOX_AWAIT(rb_iv_set, self, "tone", obj);
|
||||
|
||||
GFX_UNLOCK
|
||||
}
|
||||
|
||||
return SANDBOX_NIL;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(argc, argv, self);
|
||||
}
|
||||
|
||||
static VALUE dispose(VALUE self) {
|
||||
Plane *plane = get_private_data<Plane>(self);
|
||||
if (plane != NULL) {
|
||||
plane->dispose();
|
||||
}
|
||||
return SANDBOX_NIL;
|
||||
}
|
||||
|
||||
static VALUE disposed(VALUE self) {
|
||||
Plane *plane = get_private_data<Plane>(self);
|
||||
return plane == NULL || plane->isDisposed() ? SANDBOX_TRUE : SANDBOX_FALSE;
|
||||
}
|
||||
|
||||
static VALUE get_bitmap(VALUE self) {
|
||||
return sb()->bind<struct rb_iv_get>()()(self, "bitmap");
|
||||
}
|
||||
|
||||
static VALUE set_bitmap(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setBitmap(get_private_data<Bitmap>(value)));
|
||||
SANDBOX_AWAIT(rb_iv_set, self, "bitmap", value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_color(VALUE self) {
|
||||
return sb()->bind<struct rb_iv_get>()()(self, "color");
|
||||
}
|
||||
|
||||
static VALUE set_color(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setColor(*get_private_data<Color>(value)));
|
||||
SANDBOX_AWAIT(rb_iv_set, self, "color", value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_tone(VALUE self) {
|
||||
return sb()->bind<struct rb_iv_get>()()(self, "tone");
|
||||
}
|
||||
|
||||
static VALUE set_tone(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setTone(*get_private_data<Tone>(value)));
|
||||
SANDBOX_AWAIT(rb_iv_set, self, "tone", value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_visible(VALUE self) {
|
||||
return get_private_data<Plane>(self)->getVisible() ? SANDBOX_TRUE : SANDBOX_FALSE;
|
||||
}
|
||||
|
||||
static VALUE set_visible(VALUE self, VALUE value) {
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setVisible(value != SANDBOX_FALSE && value != SANDBOX_NIL));
|
||||
return value;
|
||||
}
|
||||
|
||||
static VALUE get_ox(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Plane>(self)->getOX());
|
||||
}
|
||||
|
||||
static VALUE set_ox(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t ox;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(ox, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setOX(ox));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_oy(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Plane>(self)->getOY());
|
||||
}
|
||||
|
||||
static VALUE set_oy(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t oy;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(oy, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setOY(oy));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_zoom_x(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Plane>(self)->getZoomX());
|
||||
}
|
||||
|
||||
static VALUE set_zoom_x(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t zoom_x;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(zoom_x, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setZoomX(zoom_x));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_zoom_y(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Plane>(self)->getZoomY());
|
||||
}
|
||||
|
||||
static VALUE set_zoom_y(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t zoom_y;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(zoom_y, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setZoomY(zoom_y));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_z(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Plane>(self)->getZ());
|
||||
}
|
||||
|
||||
static VALUE set_z(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t z;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(z, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setZ(z));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_opacity(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Plane>(self)->getOpacity());
|
||||
}
|
||||
|
||||
static VALUE set_opacity(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t opacity;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(opacity, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setOpacity(opacity));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_blend_type(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Plane>(self)->getBlendType());
|
||||
}
|
||||
|
||||
static VALUE set_blend_type(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t blend_type;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(blend_type, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Plane>(self)->setBlendType(blend_type));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
VALUE klass;
|
||||
|
||||
void operator()() {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
plane_type = sb()->rb_data_type("Plane", NULL, dfree, NULL, NULL, 0, 0, 0);
|
||||
SANDBOX_AWAIT_AND_SET(klass, rb_define_class, "Plane", sb()->rb_cObject());
|
||||
SANDBOX_AWAIT(rb_define_alloc_func, klass, alloc);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "initialize", (VALUE (*)(ANYARGS))initialize, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "dispose", (VALUE (*)(ANYARGS))dispose, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "disposed?", (VALUE (*)(ANYARGS))disposed, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "bitmap", (VALUE (*)(ANYARGS))get_bitmap, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "bitmap=", (VALUE (*)(ANYARGS))set_bitmap, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "color", (VALUE (*)(ANYARGS))get_color, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "color=", (VALUE (*)(ANYARGS))set_color, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "tone", (VALUE (*)(ANYARGS))get_tone, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "tone=", (VALUE (*)(ANYARGS))set_tone, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "visible", (VALUE (*)(ANYARGS))get_visible, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "visible=", (VALUE (*)(ANYARGS))set_visible, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "ox", (VALUE (*)(ANYARGS))get_ox, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "ox=", (VALUE (*)(ANYARGS))set_ox, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "oy", (VALUE (*)(ANYARGS))get_oy, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "oy=", (VALUE (*)(ANYARGS))set_oy, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "zoom_x", (VALUE (*)(ANYARGS))get_zoom_x, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "zoom_x=", (VALUE (*)(ANYARGS))set_zoom_x, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "zoom_y", (VALUE (*)(ANYARGS))get_zoom_y, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "zoom_y=", (VALUE (*)(ANYARGS))set_zoom_y, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "z", (VALUE (*)(ANYARGS))get_z, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "z=", (VALUE (*)(ANYARGS))set_z, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "opacity", (VALUE (*)(ANYARGS))get_opacity, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "opacity=", (VALUE (*)(ANYARGS))set_opacity, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "blend_type", (VALUE (*)(ANYARGS))get_blend_type, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "blend_type=", (VALUE (*)(ANYARGS))set_blend_type, 1);
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
#endif // MKXPZ_SANDBOX_PLANE_BINDING_H
|
|
@ -102,6 +102,13 @@ namespace mkxp_sandbox {
|
|||
return sprite == NULL || sprite->isDisposed() ? SANDBOX_TRUE : SANDBOX_FALSE;
|
||||
}
|
||||
|
||||
static VALUE update(VALUE self, VALUE value) {
|
||||
GFX_LOCK;
|
||||
get_private_data<Sprite>(self)->update();
|
||||
GFX_UNLOCK;
|
||||
return SANDBOX_NIL;
|
||||
}
|
||||
|
||||
static VALUE get_bitmap(VALUE self) {
|
||||
return sb()->bind<struct rb_iv_get>()()(self, "bitmap");
|
||||
}
|
||||
|
@ -178,6 +185,246 @@ namespace mkxp_sandbox {
|
|||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_visible(VALUE self) {
|
||||
return get_private_data<Sprite>(self)->getVisible() ? SANDBOX_TRUE : SANDBOX_FALSE;
|
||||
}
|
||||
|
||||
static VALUE set_visible(VALUE self, VALUE value) {
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setVisible(value != SANDBOX_FALSE && value != SANDBOX_NIL));
|
||||
return value;
|
||||
}
|
||||
|
||||
static VALUE get_x(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getX());
|
||||
}
|
||||
|
||||
static VALUE set_x(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t x;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(x, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setX(x));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_y(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getY());
|
||||
}
|
||||
|
||||
static VALUE set_y(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t y;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(y, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setY(y));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_ox(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getOX());
|
||||
}
|
||||
|
||||
static VALUE set_ox(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t ox;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(ox, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setOX(ox));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_oy(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getOY());
|
||||
}
|
||||
|
||||
static VALUE set_oy(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t oy;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(oy, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setOY(oy));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_zoom_x(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getZoomX());
|
||||
}
|
||||
|
||||
static VALUE set_zoom_x(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t zoom_x;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(zoom_x, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setZoomX(zoom_x));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_zoom_y(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getZoomY());
|
||||
}
|
||||
|
||||
static VALUE set_zoom_y(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t zoom_y;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(zoom_y, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setZoomY(zoom_y));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_z(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getZ());
|
||||
}
|
||||
|
||||
static VALUE set_z(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t z;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(z, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setZ(z));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_bush_depth(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getBushDepth());
|
||||
}
|
||||
|
||||
static VALUE set_bush_depth(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t bush_depth;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(bush_depth, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setBushDepth(bush_depth));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_bush_opacity(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getBushOpacity());
|
||||
}
|
||||
|
||||
static VALUE set_bush_opacity(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t bush_opacity;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(bush_opacity, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setBushOpacity(bush_opacity));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_opacity(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getOpacity());
|
||||
}
|
||||
|
||||
static VALUE set_opacity(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t opacity;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(opacity, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setOpacity(opacity));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_blend_type(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Sprite>(self)->getBlendType());
|
||||
}
|
||||
|
||||
static VALUE set_blend_type(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
int32_t blend_type;
|
||||
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(blend_type, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Sprite>(self)->setBlendType(blend_type));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE todo(int32_t argc, wasm_ptr_t argv, VALUE self) {
|
||||
return SANDBOX_NIL;
|
||||
}
|
||||
|
@ -192,6 +439,7 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_method, klass, "initialize", (VALUE (*)(ANYARGS))initialize, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "dispose", (VALUE (*)(ANYARGS))dispose, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "disposed?", (VALUE (*)(ANYARGS))disposed, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "update", (VALUE (*)(ANYARGS))update, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "bitmap", (VALUE (*)(ANYARGS))get_bitmap, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "bitmap=", (VALUE (*)(ANYARGS))set_bitmap, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "src_rect", (VALUE (*)(ANYARGS))get_src_rect, 0);
|
||||
|
@ -200,6 +448,30 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_method, klass, "color=", (VALUE (*)(ANYARGS))set_color, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "tone", (VALUE (*)(ANYARGS))get_tone, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "tone=", (VALUE (*)(ANYARGS))set_tone, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "visible", (VALUE (*)(ANYARGS))get_visible, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "visible=", (VALUE (*)(ANYARGS))set_visible, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "x", (VALUE (*)(ANYARGS))get_x, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "x=", (VALUE (*)(ANYARGS))set_x, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "y", (VALUE (*)(ANYARGS))get_y, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "y=", (VALUE (*)(ANYARGS))set_y, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "ox", (VALUE (*)(ANYARGS))get_ox, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "ox=", (VALUE (*)(ANYARGS))set_ox, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "oy", (VALUE (*)(ANYARGS))get_oy, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "oy=", (VALUE (*)(ANYARGS))set_oy, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "zoom_x", (VALUE (*)(ANYARGS))get_zoom_x, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "zoom_x=", (VALUE (*)(ANYARGS))set_zoom_x, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "zoom_y", (VALUE (*)(ANYARGS))get_zoom_y, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "zoom_y=", (VALUE (*)(ANYARGS))set_zoom_y, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "z", (VALUE (*)(ANYARGS))get_z, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "z=", (VALUE (*)(ANYARGS))set_z, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "bush_depth", (VALUE (*)(ANYARGS))get_bush_depth, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "bush_depth=", (VALUE (*)(ANYARGS))set_bush_depth, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "bush_opacity", (VALUE (*)(ANYARGS))get_bush_opacity, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "bush_opacity=", (VALUE (*)(ANYARGS))set_bush_opacity, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "opacity", (VALUE (*)(ANYARGS))get_opacity, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "opacity=", (VALUE (*)(ANYARGS))set_opacity, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "blend_type", (VALUE (*)(ANYARGS))get_blend_type, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "blend_type=", (VALUE (*)(ANYARGS))set_blend_type, 1);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -196,10 +196,6 @@ namespace mkxp_sandbox {
|
|||
return tilemap == NULL || tilemap->isDisposed() ? SANDBOX_TRUE : SANDBOX_FALSE;
|
||||
}
|
||||
|
||||
static VALUE autotiles(VALUE self) {
|
||||
return sb()->bind<struct rb_iv_get>()()(self, "autotiles");
|
||||
}
|
||||
|
||||
static VALUE update(VALUE self, VALUE value) {
|
||||
GFX_LOCK;
|
||||
get_private_data<Tilemap>(self)->update();
|
||||
|
@ -207,6 +203,10 @@ namespace mkxp_sandbox {
|
|||
return SANDBOX_NIL;
|
||||
}
|
||||
|
||||
static VALUE autotiles(VALUE self) {
|
||||
return sb()->bind<struct rb_iv_get>()()(self, "autotiles");
|
||||
}
|
||||
|
||||
static VALUE get_tileset(VALUE self) {
|
||||
return sb()->bind<struct rb_iv_get>()()(self, "tileset");
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ namespace mkxp_sandbox {
|
|||
}
|
||||
|
||||
static VALUE get_visible(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Tilemap>(self)->getOX());
|
||||
return get_private_data<Tilemap>(self)->getVisible() ? SANDBOX_TRUE : SANDBOX_FALSE;
|
||||
}
|
||||
|
||||
static VALUE set_visible(VALUE self, VALUE value) {
|
||||
|
@ -426,6 +426,7 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_method, klass, "initialize", (VALUE (*)(ANYARGS))initialize, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "dispose", (VALUE (*)(ANYARGS))dispose, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "disposed?", (VALUE (*)(ANYARGS))disposed, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "update", (VALUE (*)(ANYARGS))update, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "autotiles", (VALUE (*)(ANYARGS))autotiles, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "tileset", (VALUE (*)(ANYARGS))get_tileset, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "tileset=", (VALUE (*)(ANYARGS))set_tileset, 1);
|
||||
|
|
|
@ -104,6 +104,13 @@ namespace mkxp_sandbox {
|
|||
return viewport == NULL || viewport->isDisposed() ? SANDBOX_TRUE : SANDBOX_FALSE;
|
||||
}
|
||||
|
||||
static VALUE update(VALUE self, VALUE value) {
|
||||
GFX_LOCK;
|
||||
get_private_data<Viewport>(self)->update();
|
||||
GFX_UNLOCK;
|
||||
return SANDBOX_NIL;
|
||||
}
|
||||
|
||||
static VALUE get_rect(VALUE self) {
|
||||
return sb()->bind<struct rb_iv_get>()()(self, "rect");
|
||||
}
|
||||
|
@ -234,6 +241,7 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_method, klass, "initialize", (VALUE (*)(ANYARGS))initialize, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "dispose", (VALUE (*)(ANYARGS))dispose, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "disposed?", (VALUE (*)(ANYARGS))disposed, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "update", (VALUE (*)(ANYARGS))update, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "rect", (VALUE (*)(ANYARGS))get_rect, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "rect=", (VALUE (*)(ANYARGS))set_rect, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "color", (VALUE (*)(ANYARGS))get_color, 0);
|
||||
|
|
|
@ -111,6 +111,15 @@ namespace mkxp_sandbox {
|
|||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_stretch(VALUE self) {
|
||||
return get_private_data<Window>(self)->getStretch() ? SANDBOX_TRUE : SANDBOX_FALSE;
|
||||
}
|
||||
|
||||
static VALUE set_stretch(VALUE self, VALUE value) {
|
||||
GFX_GUARD_EXC(get_private_data<Window>(self)->setStretch(value != SANDBOX_FALSE && value != SANDBOX_NIL);)
|
||||
return value;
|
||||
}
|
||||
|
||||
static VALUE get_cursor_rect(VALUE self) {
|
||||
return sb()->bind<struct rb_iv_get>()()(self, "cursor_rect");
|
||||
}
|
||||
|
@ -139,6 +148,24 @@ namespace mkxp_sandbox {
|
|||
return value;
|
||||
}
|
||||
|
||||
static VALUE get_visible(VALUE self) {
|
||||
return get_private_data<Window>(self)->getVisible() ? SANDBOX_TRUE : SANDBOX_FALSE;
|
||||
}
|
||||
|
||||
static VALUE set_visible(VALUE self, VALUE value) {
|
||||
GFX_GUARD_EXC(get_private_data<Window>(self)->setVisible(value != SANDBOX_FALSE && value != SANDBOX_NIL));
|
||||
return value;
|
||||
}
|
||||
|
||||
static VALUE get_pause(VALUE self) {
|
||||
return get_private_data<Window>(self)->getPause() ? SANDBOX_TRUE : SANDBOX_FALSE;
|
||||
}
|
||||
|
||||
static VALUE set_pause(VALUE self, VALUE value) {
|
||||
GFX_GUARD_EXC(get_private_data<Window>(self)->setPause(value != SANDBOX_FALSE && value != SANDBOX_NIL));
|
||||
return value;
|
||||
}
|
||||
|
||||
static VALUE get_x(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Window>(self)->getX());
|
||||
}
|
||||
|
@ -265,6 +292,27 @@ namespace mkxp_sandbox {
|
|||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_z(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Window>(self)->getZ());
|
||||
}
|
||||
|
||||
static VALUE set_z(VALUE self, VALUE value) {
|
||||
SANDBOX_COROUTINE(coro,
|
||||
int z;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(z, rb_num2int, value);
|
||||
GFX_GUARD_EXC(get_private_data<Window>(self)->setZ(z));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
)
|
||||
|
||||
return sb()->bind<struct coro>()()(self, value);
|
||||
}
|
||||
|
||||
static VALUE get_opacity(VALUE self) {
|
||||
return sb()->bind<struct rb_ll2inum>()()(get_private_data<Window>(self)->getOpacity());
|
||||
}
|
||||
|
@ -346,12 +394,16 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_method, klass, "windowskin=", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "contents", (VALUE (*)(ANYARGS))get_contents, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "contents=", (VALUE (*)(ANYARGS))set_contents, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "stretch=", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "stretch", (VALUE (*)(ANYARGS))get_stretch, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "stretch=", (VALUE (*)(ANYARGS))set_stretch, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "cursor_rect", (VALUE (*)(ANYARGS))get_cursor_rect, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "cursor_rect=", (VALUE (*)(ANYARGS))set_cursor_rect, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "active", (VALUE (*)(ANYARGS))get_active, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "active=", (VALUE (*)(ANYARGS))set_active, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "pause=", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "visible", (VALUE (*)(ANYARGS))get_visible, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "visible=", (VALUE (*)(ANYARGS))set_visible, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "pause", (VALUE (*)(ANYARGS))get_pause, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "pause=", (VALUE (*)(ANYARGS))set_pause, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "x", (VALUE (*)(ANYARGS))get_x, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "x=", (VALUE (*)(ANYARGS))set_x, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "y", (VALUE (*)(ANYARGS))get_y, 0);
|
||||
|
@ -370,7 +422,8 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_AWAIT(rb_define_method, klass, "back_opacity=", (VALUE (*)(ANYARGS))set_back_opacity, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "contents_opacity", (VALUE (*)(ANYARGS))get_contents_opacity, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "contents_opacity=", (VALUE (*)(ANYARGS))set_contents_opacity, 1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "z=", (VALUE (*)(ANYARGS))todo, -1);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "z", (VALUE (*)(ANYARGS))get_z, 0);
|
||||
SANDBOX_AWAIT(rb_define_method, klass, "z=", (VALUE (*)(ANYARGS))set_z, 1);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -256,6 +256,7 @@ if get_option('retro') == true
|
|||
'src/audio/vorbissource.cpp',
|
||||
'src/crypto/rgssad.cpp',
|
||||
'src/display/bitmap.cpp',
|
||||
'src/display/plane.cpp',
|
||||
'src/display/sprite.cpp',
|
||||
'src/display/tilemap.cpp',
|
||||
'src/display/viewport.cpp',
|
||||
|
|
|
@ -21,24 +21,30 @@
|
|||
|
||||
#include "plane.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "sharedstate.h"
|
||||
#include "bitmap.h"
|
||||
#include "etc.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
#include "gl-util.h"
|
||||
#include "quad.h"
|
||||
#include "quadarray.h"
|
||||
#include "transform.h"
|
||||
#endif // MKXPZ_RETRO
|
||||
#include "etc-internal.h"
|
||||
#ifndef MKXPZ_RETRO
|
||||
#include "shader.h"
|
||||
#include "glstate.h"
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
#include "sigslot/signal.hpp"
|
||||
|
||||
static float fwrap(float value, float range)
|
||||
{
|
||||
float res = fmod(value, range);
|
||||
float res = std::fmod(value, range);
|
||||
return res < 0 ? res + range : res;
|
||||
}
|
||||
|
||||
|
@ -60,7 +66,9 @@ struct PlanePrivate
|
|||
|
||||
bool quadSourceDirty;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
SimpleQuadArray qArray;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
EtcTemps tmp;
|
||||
|
||||
|
@ -79,7 +87,9 @@ struct PlanePrivate
|
|||
prepareCon = shState->prepareDraw.connect
|
||||
(&PlanePrivate::prepare, this);
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
qArray.resize(1);
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
~PlanePrivate()
|
||||
|
@ -97,6 +107,7 @@ struct PlanePrivate
|
|||
|
||||
void updateQuadSource()
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (gl.npot_repeat)
|
||||
{
|
||||
FloatRect srcRect;
|
||||
|
@ -110,6 +121,7 @@ struct PlanePrivate
|
|||
|
||||
return;
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
if (nullOrDisposed(bitmap))
|
||||
return;
|
||||
|
@ -132,6 +144,7 @@ struct PlanePrivate
|
|||
|
||||
FloatRect tex = bitmap->rect();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
qArray.resize(tilesX * tilesY);
|
||||
|
||||
for (size_t y = 0; y < tilesY; ++y)
|
||||
|
@ -144,6 +157,7 @@ struct PlanePrivate
|
|||
}
|
||||
|
||||
qArray.commit();
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void prepare()
|
||||
|
@ -279,6 +293,7 @@ void Plane::draw()
|
|||
if (!p->opacity)
|
||||
return;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
ShaderBase *base;
|
||||
|
||||
if (p->color->hasEffect() || p->tone->hasEffect() || p->opacity != 255)
|
||||
|
@ -318,12 +333,15 @@ void Plane::draw()
|
|||
TEX::setRepeat(false);
|
||||
|
||||
glState.blendMode.pop();
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void Plane::onGeometryChange(const Scene::Geometry &geo)
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (gl.npot_repeat)
|
||||
Quad::setPosRect(&p->qArray.vertices[0], FloatRect(geo.rect));
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
p->sceneGeo = geo;
|
||||
p->quadSourceDirty = true;
|
||||
|
|
|
@ -53,7 +53,15 @@ struct SpritePrivate
|
|||
|
||||
sigslot::connection bitmapDispCon;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
#ifdef MKXPZ_RETRO
|
||||
// TODO: use the corresponding properties from `trans` instead of adding them here separately
|
||||
int x;
|
||||
int y;
|
||||
int ox;
|
||||
int oy;
|
||||
float zoom_x;
|
||||
float zoom_y;
|
||||
#else
|
||||
Quad quad;
|
||||
Transform trans;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
@ -109,6 +117,14 @@ struct SpritePrivate
|
|||
|
||||
SpritePrivate()
|
||||
: bitmap(0),
|
||||
#ifdef MKXPZ_RETRO
|
||||
x(0),
|
||||
y(0),
|
||||
ox(0),
|
||||
oy(0),
|
||||
zoom_x(1.0f),
|
||||
zoom_y(1.0f),
|
||||
#endif // MKXPZ_RETRO
|
||||
srcRect(&tmp.rect),
|
||||
mirrored(false),
|
||||
bushDepth(0),
|
||||
|
@ -379,7 +395,14 @@ Sprite::~Sprite()
|
|||
}
|
||||
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, Bitmap, Bitmap*, p->bitmap)
|
||||
#ifndef MKXPZ_RETRO
|
||||
#ifdef MKXPZ_RETRO
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, X, int, p->x)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, Y, int, p->y)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, OX, int, p->ox)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, OY, int, p->oy)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, ZoomX, float, p->zoom_x)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, ZoomY, float, p->zoom_y)
|
||||
#else
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, X, int, p->trans.getPosition().x)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, Y, int, p->trans.getPosition().y)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, OX, int, p->trans.getOrigin().x)
|
||||
|
|
|
@ -58,13 +58,14 @@ public:
|
|||
|
||||
void initDynAttribs();
|
||||
|
||||
void setZ(int value);
|
||||
void setVisible(bool value);
|
||||
|
||||
private:
|
||||
WindowPrivate *p;
|
||||
|
||||
void draw();
|
||||
void onGeometryChange(const Scene::Geometry &);
|
||||
void setZ(int value);
|
||||
void setVisible(bool value);
|
||||
|
||||
void onViewportChange();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue