mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-04-21 21:52:04 +02:00
OLD_RUBY -> RAPI_MAJOR/RAPI_MINOR/RAPI_TEENY/RAPI_FULL
This commit is contained in:
parent
41e604b992
commit
1434e9e313
20 changed files with 1950 additions and 2199 deletions
|
@ -38,7 +38,7 @@
|
|||
extern "C" {
|
||||
#include <ruby.h>
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL >= 190
|
||||
#include <ruby/encoding.h>
|
||||
#endif
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ RB_METHOD(mriRgssMain) {
|
|||
|
||||
while (true) {
|
||||
VALUE exc = Qnil;
|
||||
#if RUBYCOMPAT < 270
|
||||
#if RAPI_FULL < 270
|
||||
rb_rescue2((VALUE(*)(ANYARGS))rgssMainCb, rb_block_proc(),
|
||||
(VALUE(*)(ANYARGS))rgssMainRescue, (VALUE)&exc, rb_eException,
|
||||
(VALUE)0);
|
||||
|
@ -431,7 +431,7 @@ RB_METHOD(_kernelCaller) {
|
|||
return trace;
|
||||
}
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
static VALUE newStringUTF8(const char *string, long length) {
|
||||
return rb_enc_str_new(string, length, rb_utf8_encoding());
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ static void runRMXPScripts(BacktraceData &btData) {
|
|||
#endif
|
||||
|
||||
while (true) {
|
||||
#if defined(OLD_RUBY) && defined(NO_CONSOLE)
|
||||
#if RAPI_FULL < 200 && defined(NO_CONSOLE)
|
||||
VALUE iostr = rb_str_new2(NULL_IO);
|
||||
// Sysinit isn't a thing yet, so send io to /dev/null instead
|
||||
rb_funcall(rb_gv_get("$stderr"), rb_intern("reopen"), 1, iostr);
|
||||
|
@ -694,7 +694,7 @@ static void showExc(VALUE exc, const BacktraceData &btData) {
|
|||
}
|
||||
|
||||
static void mriBindingExecute() {
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 200
|
||||
/* Normally only a ruby executable would do a sysinit,
|
||||
* but not doing it will lead to crashes due to closed
|
||||
* stdio streams on some platforms (eg. Windows) */
|
||||
|
@ -750,7 +750,7 @@ static void mriBindingExecute() {
|
|||
runRMXPScripts(btData);
|
||||
#endif
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
VALUE exc = rb_errinfo();
|
||||
#else
|
||||
VALUE exc = rb_gv_get("$!");
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "binding-util.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DECL_TYPE(Table);
|
||||
DECL_TYPE(Rect);
|
||||
DECL_TYPE(Color);
|
||||
|
@ -59,7 +59,7 @@ DECL_TYPE(MiniFFI);
|
|||
|
||||
#ifdef HAVE_DISCORDSDK
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DECL_TYPE(DCActivity);
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,76 +21,61 @@
|
|||
|
||||
#include "binding-util.h"
|
||||
|
||||
#include "sharedstate.h"
|
||||
#include "exception.h"
|
||||
#include "sharedstate.h"
|
||||
#include "src/util.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
RbData *getRbData()
|
||||
{
|
||||
return static_cast<RbData*>(shState->bindingData());
|
||||
}
|
||||
RbData *getRbData() { return static_cast<RbData *>(shState->bindingData()); }
|
||||
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
RbException id;
|
||||
const char *name;
|
||||
} static customExc[] =
|
||||
{
|
||||
{ MKXP, "MKXPError" },
|
||||
{ PHYSFS, "PHYSFSError" },
|
||||
{ SDL, "SDLError" }
|
||||
};
|
||||
} static customExc[] = {
|
||||
{MKXP, "MKXPError"}, {PHYSFS, "PHYSFSError"}, {SDL, "SDLError"}};
|
||||
|
||||
RbData::RbData()
|
||||
{
|
||||
RbData::RbData() {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(customExc); ++i)
|
||||
exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException);
|
||||
|
||||
exc[RGSS] = rb_define_class("RGSSError", rb_eStandardError);
|
||||
exc[Reset] = rb_define_class(rgssVer >= 3 ? "RGSSReset" : "Reset", rb_eException);
|
||||
exc[Reset] =
|
||||
rb_define_class(rgssVer >= 3 ? "RGSSReset" : "Reset", rb_eException);
|
||||
|
||||
exc[ErrnoENOENT] = rb_const_get(rb_const_get(rb_cObject, rb_intern("Errno")), rb_intern("ENOENT"));
|
||||
exc[ErrnoENOENT] = rb_const_get(rb_const_get(rb_cObject, rb_intern("Errno")),
|
||||
rb_intern("ENOENT"));
|
||||
exc[IOError] = rb_eIOError;
|
||||
exc[TypeError] = rb_eTypeError;
|
||||
exc[ArgumentError] = rb_eArgError;
|
||||
}
|
||||
|
||||
RbData::~RbData()
|
||||
{
|
||||
|
||||
}
|
||||
RbData::~RbData() {}
|
||||
|
||||
/* Indexed with Exception::Type */
|
||||
static const RbException excToRbExc[] =
|
||||
{
|
||||
static const RbException excToRbExc[] = {
|
||||
RGSS, /* RGSSError */
|
||||
ErrnoENOENT, /* NoFileError */
|
||||
IOError,
|
||||
|
||||
TypeError,
|
||||
ArgumentError,
|
||||
TypeError, ArgumentError,
|
||||
|
||||
PHYSFS, /* PHYSFSError */
|
||||
SDL, /* SDLError */
|
||||
MKXP /* MKXPError */
|
||||
};
|
||||
|
||||
void raiseRbExc(const Exception &exc)
|
||||
{
|
||||
void raiseRbExc(const Exception &exc) {
|
||||
RbData *data = getRbData();
|
||||
VALUE excClass = data->exc[excToRbExc[exc.type]];
|
||||
|
||||
rb_raise(excClass, "%s", exc.msg.c_str());
|
||||
}
|
||||
|
||||
void
|
||||
raiseDisposedAccess(VALUE self)
|
||||
{
|
||||
#ifndef OLD_RUBY
|
||||
void raiseDisposedAccess(VALUE self) {
|
||||
#if RAPI_FULL > 187
|
||||
const char *klassName = RTYPEDDATA_TYPE(self)->wrap_struct_name;
|
||||
#else
|
||||
const char *klassName = rb_obj_classname(self);
|
||||
|
@ -103,9 +88,7 @@ raiseDisposedAccess(VALUE self)
|
|||
rb_raise(getRbData()->exc[RGSS], "disposed %s", buf);
|
||||
}
|
||||
|
||||
int
|
||||
rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
||||
{
|
||||
int rb_get_args(int argc, VALUE *argv, const char *format, ...) {
|
||||
char c;
|
||||
VALUE *arg = argv;
|
||||
va_list ap;
|
||||
|
@ -114,11 +97,9 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
|
||||
va_start(ap, format);
|
||||
|
||||
while ((c = *format++))
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '|' :
|
||||
while ((c = *format++)) {
|
||||
switch (c) {
|
||||
case '|':
|
||||
break;
|
||||
default:
|
||||
// FIXME print num of needed args vs provided
|
||||
|
@ -131,14 +112,12 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
if (argI >= argc)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 'o' :
|
||||
{
|
||||
switch (c) {
|
||||
case 'o': {
|
||||
if (argI >= argc)
|
||||
break;
|
||||
|
||||
VALUE *obj = va_arg(ap, VALUE*);
|
||||
VALUE *obj = va_arg(ap, VALUE *);
|
||||
|
||||
*obj = *arg++;
|
||||
++argI;
|
||||
|
@ -146,12 +125,11 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
case 'S' :
|
||||
{
|
||||
case 'S': {
|
||||
if (argI >= argc)
|
||||
break;
|
||||
|
||||
VALUE *str = va_arg(ap, VALUE*);
|
||||
VALUE *str = va_arg(ap, VALUE *);
|
||||
VALUE tmp = *arg;
|
||||
|
||||
if (!RB_TYPE_P(tmp, RUBY_T_STRING))
|
||||
|
@ -163,13 +141,12 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
case 's' :
|
||||
{
|
||||
case 's': {
|
||||
if (argI >= argc)
|
||||
break;
|
||||
|
||||
const char **s = va_arg(ap, const char**);
|
||||
int *len = va_arg(ap, int*);
|
||||
const char **s = va_arg(ap, const char **);
|
||||
int *len = va_arg(ap, int *);
|
||||
|
||||
VALUE tmp = *arg;
|
||||
|
||||
|
@ -183,12 +160,11 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
case 'z' :
|
||||
{
|
||||
case 'z': {
|
||||
if (argI >= argc)
|
||||
break;
|
||||
|
||||
const char **s = va_arg(ap, const char**);
|
||||
const char **s = va_arg(ap, const char **);
|
||||
|
||||
VALUE tmp = *arg++;
|
||||
|
||||
|
@ -201,12 +177,11 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
case 'f' :
|
||||
{
|
||||
case 'f': {
|
||||
if (argI >= argc)
|
||||
break;
|
||||
|
||||
double *f = va_arg(ap, double*);
|
||||
double *f = va_arg(ap, double *);
|
||||
VALUE fVal = *arg++;
|
||||
|
||||
rb_float_arg(fVal, f, argI);
|
||||
|
@ -215,12 +190,11 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
case 'i' :
|
||||
{
|
||||
case 'i': {
|
||||
if (argI >= argc)
|
||||
break;
|
||||
|
||||
int *i = va_arg(ap, int*);
|
||||
int *i = va_arg(ap, int *);
|
||||
VALUE iVal = *arg++;
|
||||
|
||||
rb_int_arg(iVal, i, argI);
|
||||
|
@ -229,12 +203,11 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
case 'b' :
|
||||
{
|
||||
case 'b': {
|
||||
if (argI >= argc)
|
||||
break;
|
||||
|
||||
bool *b = va_arg(ap, bool*);
|
||||
bool *b = va_arg(ap, bool *);
|
||||
VALUE bVal = *arg++;
|
||||
|
||||
rb_bool_arg(bVal, b, argI);
|
||||
|
@ -243,12 +216,11 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
case 'n' :
|
||||
{
|
||||
case 'n': {
|
||||
if (argI >= argc)
|
||||
break;
|
||||
|
||||
ID *sym = va_arg(ap, ID*);
|
||||
ID *sym = va_arg(ap, ID *);
|
||||
|
||||
VALUE symVal = *arg++;
|
||||
|
||||
|
@ -261,7 +233,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
case '|' :
|
||||
case '|':
|
||||
opt = true;
|
||||
break;
|
||||
|
||||
|
@ -276,34 +248,32 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
* the stack to check for RB_ARG_END */
|
||||
format--;
|
||||
|
||||
while ((c = *format++))
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'o' :
|
||||
case 'S' :
|
||||
va_arg(ap, VALUE*);
|
||||
while ((c = *format++)) {
|
||||
switch (c) {
|
||||
case 'o':
|
||||
case 'S':
|
||||
va_arg(ap, VALUE *);
|
||||
break;
|
||||
|
||||
case 's' :
|
||||
va_arg(ap, const char**);
|
||||
va_arg(ap, int*);
|
||||
case 's':
|
||||
va_arg(ap, const char **);
|
||||
va_arg(ap, int *);
|
||||
break;
|
||||
|
||||
case 'z' :
|
||||
va_arg(ap, const char**);
|
||||
case 'z':
|
||||
va_arg(ap, const char **);
|
||||
break;
|
||||
|
||||
case 'f' :
|
||||
va_arg(ap, double*);
|
||||
case 'f':
|
||||
va_arg(ap, double *);
|
||||
break;
|
||||
|
||||
case 'i' :
|
||||
va_arg(ap, int*);
|
||||
case 'i':
|
||||
va_arg(ap, int *);
|
||||
break;
|
||||
|
||||
case 'b' :
|
||||
va_arg(ap, bool*);
|
||||
case 'b':
|
||||
va_arg(ap, bool *);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -313,8 +283,8 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
|||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
|
||||
/* Verify correct termination */
|
||||
void *argEnd = va_arg(ap, void*);
|
||||
(void) argEnd;
|
||||
void *argEnd = va_arg(ap, void *);
|
||||
(void)argEnd;
|
||||
assert(argEnd == RB_ARG_END_VAL);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,9 +23,25 @@
|
|||
#define BINDING_UTIL_H
|
||||
|
||||
#include <ruby.h>
|
||||
#ifndef LEGACY_RUBY
|
||||
#include <ruby/version.h>
|
||||
#else
|
||||
#include <version.h>
|
||||
#endif
|
||||
|
||||
#include "exception.h"
|
||||
|
||||
#ifdef RUBY_API_VERSION_MAJOR
|
||||
#define RAPI_MAJOR RUBY_API_VERSION_MAJOR
|
||||
#define RAPI_MINOR RUBY_API_VERSION_MINOR
|
||||
#define RAPI_TEENY RUBY_API_VERSION_TEENY
|
||||
#else
|
||||
#define RAPI_MAJOR RUBY_VERSION_MAJOR
|
||||
#define RAPI_MINOR RUBY_VERSION_MINOR
|
||||
#define RAPI_TEENY RUBY_VERSION_TEENY
|
||||
#endif
|
||||
#define RAPI_FULL ((RAPI_MAJOR * 100) + (RAPI_MINOR * 10) + RAPI_TEENY)
|
||||
|
||||
enum RbException {
|
||||
RGSS = 0,
|
||||
Reset,
|
||||
|
@ -59,12 +75,11 @@ struct Exception;
|
|||
|
||||
void raiseRbExc(const Exception &exc);
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
#define DECL_TYPE(Klass) extern rb_data_type_t Klass##Type
|
||||
|
||||
/* 2.1 has added a new field (flags) to rb_data_type_t */
|
||||
#include <ruby/version.h>
|
||||
#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 1
|
||||
#if RAPI_FULL >= 210
|
||||
/* TODO: can mkxp use RUBY_TYPED_FREE_IMMEDIATELY here? */
|
||||
#define DEF_TYPE_FLAGS 0
|
||||
#else
|
||||
|
@ -72,15 +87,14 @@ void raiseRbExc(const Exception &exc);
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RUBYCOMPAT < 270
|
||||
#if RAPI_MAJOR > 1
|
||||
#if RAPI_FULL < 270
|
||||
#define DEF_TYPE_CUSTOMNAME_AND_FREE(Klass, Name, Free) \
|
||||
rb_data_type_t Klass##Type = { \
|
||||
Name, {0, Free, 0, {0, 0}}, 0, 0, DEF_TYPE_FLAGS}
|
||||
#else
|
||||
#define DEF_TYPE_CUSTOMNAME_AND_FREE(Klass, Name, Free) \
|
||||
rb_data_type_t Klass##Type = { \
|
||||
Name, {0, Free, 0, 0, 0}, 0, 0, DEF_TYPE_FLAGS}
|
||||
rb_data_type_t Klass##Type = {Name, {0, Free, 0, 0, 0}, 0, 0, DEF_TYPE_FLAGS}
|
||||
#endif
|
||||
|
||||
#define DEF_TYPE_CUSTOMFREE(Klass, Free) \
|
||||
|
@ -93,7 +107,7 @@ void raiseRbExc(const Exception &exc);
|
|||
#endif
|
||||
|
||||
// Ruby 1.8 helper stuff
|
||||
#ifdef OLD_RUBY
|
||||
#if RAPI_FULL <= 187
|
||||
|
||||
#define RUBY_T_FIXNUM T_FIXNUM
|
||||
#define RUBY_T_TRUE T_TRUE
|
||||
|
@ -144,10 +158,10 @@ void raiseRbExc(const Exception &exc);
|
|||
#endif
|
||||
// end
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
template <rb_data_type_t *rbType> static VALUE classAllocate(VALUE klass) {
|
||||
/* 2.3 has changed the name of this function */
|
||||
#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 3
|
||||
#if RAPI_FULL >= 230
|
||||
return rb_data_typed_object_wrap(klass, 0, rbType);
|
||||
#else
|
||||
return rb_data_typed_object_alloc(klass, 0, rbType);
|
||||
|
@ -162,7 +176,7 @@ template <class C> static void freeInstance(void *inst) {
|
|||
void raiseDisposedAccess(VALUE self);
|
||||
|
||||
template <class C> inline C *getPrivateData(VALUE self) {
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
C *c = static_cast<C *>(RTYPEDDATA_DATA(self));
|
||||
#else
|
||||
C *c = static_cast<C *>(DATA_PTR(self));
|
||||
|
@ -172,13 +186,13 @@ template <class C> inline C *getPrivateData(VALUE self) {
|
|||
|
||||
template <class C>
|
||||
static inline C *
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
getPrivateDataCheck(VALUE self, const rb_data_type_t &type)
|
||||
#else
|
||||
getPrivateDataCheck(VALUE self, const char *type)
|
||||
#endif
|
||||
{
|
||||
#ifdef OLD_RUBY
|
||||
#if RAPI_FULL <= 187
|
||||
rb_check_type(self, T_DATA);
|
||||
VALUE otherObj = rb_const_get(rb_cObject, rb_intern(type));
|
||||
#else
|
||||
|
@ -197,7 +211,7 @@ getPrivateDataCheck(VALUE self, const char *type)
|
|||
}
|
||||
|
||||
static inline void setPrivateData(VALUE self, void *p) {
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
RTYPEDDATA_DATA(self) = p;
|
||||
#else
|
||||
DATA_PTR(self) = p;
|
||||
|
@ -205,13 +219,13 @@ static inline void setPrivateData(VALUE self, void *p) {
|
|||
}
|
||||
|
||||
inline VALUE
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
wrapObject(void *p, const rb_data_type_t &type, VALUE underKlass = rb_cObject)
|
||||
#else
|
||||
wrapObject(void *p, const char *type, VALUE underKlass = rb_cObject)
|
||||
#endif
|
||||
{
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
VALUE klass = rb_const_get(underKlass, rb_intern(type.wrap_struct_name));
|
||||
#else
|
||||
VALUE klass = rb_const_get(underKlass, rb_intern(type));
|
||||
|
@ -224,7 +238,7 @@ wrapObject(void *p, const char *type, VALUE underKlass = rb_cObject)
|
|||
}
|
||||
|
||||
inline VALUE wrapProperty(VALUE self, void *prop, const char *iv,
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
const rb_data_type_t &type,
|
||||
#else
|
||||
const char *type,
|
||||
|
@ -346,7 +360,7 @@ inline void rb_check_argc(int actual, int expected) {
|
|||
expected);
|
||||
}
|
||||
|
||||
#ifdef OLD_RUBY
|
||||
#if RAPI_FULL <= 187
|
||||
static inline void rb_error_arity(int argc, int min, int max) {
|
||||
if (argc > max || argc < min)
|
||||
rb_raise(rb_eArgError, "Finish me! rb_error_arity()"); // TODO
|
||||
|
@ -395,7 +409,7 @@ static inline VALUE rb_file_open_str(VALUE filename, const char *mode) {
|
|||
* FIXME: Getter assumes prop is disposable,
|
||||
* because self.disposed? is not checked in this case.
|
||||
* Should make this more clear */
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
#define DEF_PROP_OBJ_REF(Klass, PropKlass, PropName, prop_iv) \
|
||||
RB_METHOD(Klass##Get##PropName) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
|
@ -438,7 +452,7 @@ static inline VALUE rb_file_open_str(VALUE filename, const char *mode) {
|
|||
#endif
|
||||
|
||||
/* Object property which is copied by value, not reference */
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
#define DEF_PROP_OBJ_VAL(Klass, PropKlass, PropName, prop_iv) \
|
||||
RB_METHOD(Klass##Get##PropName) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
|
|
|
@ -19,28 +19,26 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "bitmap.h"
|
||||
#include "font.h"
|
||||
#include "exception.h"
|
||||
#include "sharedstate.h"
|
||||
#include "disposable-binding.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
#include "binding-util.h"
|
||||
#include "bitmap.h"
|
||||
#include "disposable-binding.h"
|
||||
#include "exception.h"
|
||||
#include "font.h"
|
||||
#include "sharedstate.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE(Bitmap);
|
||||
#else
|
||||
DEF_ALLOCFUNC(Bitmap);
|
||||
#endif
|
||||
|
||||
static const char *objAsStringPtr(VALUE obj)
|
||||
{
|
||||
static const char *objAsStringPtr(VALUE obj) {
|
||||
VALUE str = rb_obj_as_string(obj);
|
||||
return RSTRING_PTR(str);
|
||||
}
|
||||
|
||||
void bitmapInitProps(Bitmap *b, VALUE self)
|
||||
{
|
||||
void bitmapInitProps(Bitmap *b, VALUE self) {
|
||||
/* Wrap properties */
|
||||
VALUE fontKlass = rb_const_get(rb_cObject, rb_intern("Font"));
|
||||
VALUE fontObj = rb_obj_alloc(fontKlass);
|
||||
|
@ -52,23 +50,19 @@ void bitmapInitProps(Bitmap *b, VALUE self)
|
|||
rb_iv_set(self, "font", fontObj);
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapInitialize)
|
||||
{
|
||||
RB_METHOD(bitmapInitialize) {
|
||||
Bitmap *b = 0;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
if (argc == 1) {
|
||||
char *filename;
|
||||
rb_get_args(argc, argv, "z", &filename RB_ARG_END);
|
||||
|
||||
GUARD_EXC( b = new Bitmap(filename); )
|
||||
}
|
||||
else
|
||||
{
|
||||
GUARD_EXC(b = new Bitmap(filename);)
|
||||
} else {
|
||||
int width, height;
|
||||
rb_get_args(argc, argv, "ii", &width, &height RB_ARG_END);
|
||||
|
||||
GUARD_EXC( b = new Bitmap(width, height); )
|
||||
GUARD_EXC(b = new Bitmap(width, height);)
|
||||
}
|
||||
|
||||
setPrivateData(self, b);
|
||||
|
@ -77,46 +71,42 @@ RB_METHOD(bitmapInitialize)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapWidth)
|
||||
{
|
||||
RB_METHOD(bitmapWidth) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
int value = 0;
|
||||
GUARD_EXC( value = b->width(); );
|
||||
GUARD_EXC(value = b->width(););
|
||||
|
||||
return INT2FIX(value);
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapHeight)
|
||||
{
|
||||
RB_METHOD(bitmapHeight) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
int value = 0;
|
||||
GUARD_EXC( value = b->height(); );
|
||||
GUARD_EXC(value = b->height(););
|
||||
|
||||
return INT2FIX(value);
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapRect)
|
||||
{
|
||||
RB_METHOD(bitmapRect) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
IntRect rect;
|
||||
GUARD_EXC( rect = b->rect(); );
|
||||
GUARD_EXC(rect = b->rect(););
|
||||
|
||||
Rect *r = new Rect(rect);
|
||||
|
||||
return wrapObject(r, RectType);
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapBlt)
|
||||
{
|
||||
RB_METHOD(bitmapBlt) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
int x, y;
|
||||
|
@ -127,18 +117,18 @@ RB_METHOD(bitmapBlt)
|
|||
Bitmap *src;
|
||||
Rect *srcRect;
|
||||
|
||||
rb_get_args(argc, argv, "iioo|i", &x, &y, &srcObj, &srcRectObj, &opacity RB_ARG_END);
|
||||
rb_get_args(argc, argv, "iioo|i", &x, &y, &srcObj, &srcRectObj,
|
||||
&opacity RB_ARG_END);
|
||||
|
||||
src = getPrivateDataCheck<Bitmap>(srcObj, BitmapType);
|
||||
srcRect = getPrivateDataCheck<Rect>(srcRectObj, RectType);
|
||||
|
||||
GUARD_EXC( b->blt(x, y, *src, srcRect->toIntRect(), opacity); );
|
||||
GUARD_EXC(b->blt(x, y, *src, srcRect->toIntRect(), opacity););
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapStretchBlt)
|
||||
{
|
||||
RB_METHOD(bitmapStretchBlt) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
VALUE destRectObj;
|
||||
|
@ -149,26 +139,26 @@ RB_METHOD(bitmapStretchBlt)
|
|||
Bitmap *src;
|
||||
Rect *destRect, *srcRect;
|
||||
|
||||
rb_get_args(argc, argv, "ooo|i", &destRectObj, &srcObj, &srcRectObj, &opacity RB_ARG_END);
|
||||
rb_get_args(argc, argv, "ooo|i", &destRectObj, &srcObj, &srcRectObj,
|
||||
&opacity RB_ARG_END);
|
||||
|
||||
src = getPrivateDataCheck<Bitmap>(srcObj, BitmapType);
|
||||
destRect = getPrivateDataCheck<Rect>(destRectObj, RectType);
|
||||
srcRect = getPrivateDataCheck<Rect>(srcRectObj, RectType);
|
||||
|
||||
GUARD_EXC( b->stretchBlt(destRect->toIntRect(), *src, srcRect->toIntRect(), opacity); );
|
||||
GUARD_EXC(b->stretchBlt(destRect->toIntRect(), *src, srcRect->toIntRect(),
|
||||
opacity););
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapFillRect)
|
||||
{
|
||||
RB_METHOD(bitmapFillRect) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
VALUE colorObj;
|
||||
Color *color;
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
if (argc == 2) {
|
||||
VALUE rectObj;
|
||||
Rect *rect;
|
||||
|
||||
|
@ -177,35 +167,32 @@ RB_METHOD(bitmapFillRect)
|
|||
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
|
||||
color = getPrivateDataCheck<Color>(colorObj, ColorType);
|
||||
|
||||
GUARD_EXC( b->fillRect(rect->toIntRect(), color->norm); );
|
||||
}
|
||||
else
|
||||
{
|
||||
GUARD_EXC(b->fillRect(rect->toIntRect(), color->norm););
|
||||
} else {
|
||||
int x, y, width, height;
|
||||
|
||||
rb_get_args(argc, argv, "iiiio", &x, &y, &width, &height, &colorObj RB_ARG_END);
|
||||
rb_get_args(argc, argv, "iiiio", &x, &y, &width, &height,
|
||||
&colorObj RB_ARG_END);
|
||||
|
||||
color = getPrivateDataCheck<Color>(colorObj, ColorType);
|
||||
|
||||
GUARD_EXC( b->fillRect(x, y, width, height, color->norm); );
|
||||
GUARD_EXC(b->fillRect(x, y, width, height, color->norm););
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapClear)
|
||||
{
|
||||
RB_METHOD(bitmapClear) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
GUARD_EXC( b->clear(); )
|
||||
GUARD_EXC(b->clear();)
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapGetPixel)
|
||||
{
|
||||
RB_METHOD(bitmapGetPixel) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
int x, y;
|
||||
|
@ -213,15 +200,14 @@ RB_METHOD(bitmapGetPixel)
|
|||
rb_get_args(argc, argv, "ii", &x, &y RB_ARG_END);
|
||||
|
||||
Color value;
|
||||
GUARD_EXC( value = b->getPixel(x, y); );
|
||||
GUARD_EXC(value = b->getPixel(x, y););
|
||||
|
||||
Color *color = new Color(value);
|
||||
|
||||
return wrapObject(color, ColorType);
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapSetPixel)
|
||||
{
|
||||
RB_METHOD(bitmapSetPixel) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
int x, y;
|
||||
|
@ -233,94 +219,81 @@ RB_METHOD(bitmapSetPixel)
|
|||
|
||||
color = getPrivateDataCheck<Color>(colorObj, ColorType);
|
||||
|
||||
GUARD_EXC( b->setPixel(x, y, *color); );
|
||||
GUARD_EXC(b->setPixel(x, y, *color););
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapHueChange)
|
||||
{
|
||||
RB_METHOD(bitmapHueChange) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
int hue;
|
||||
|
||||
rb_get_args(argc, argv, "i", &hue RB_ARG_END);
|
||||
|
||||
GUARD_EXC( b->hueChange(hue); );
|
||||
GUARD_EXC(b->hueChange(hue););
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapDrawText)
|
||||
{
|
||||
RB_METHOD(bitmapDrawText) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
const char *str;
|
||||
int align = Bitmap::Left;
|
||||
|
||||
if (argc == 2 || argc == 3)
|
||||
{
|
||||
if (argc == 2 || argc == 3) {
|
||||
VALUE rectObj;
|
||||
Rect *rect;
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
if (rgssVer >= 2) {
|
||||
VALUE strObj;
|
||||
rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END);
|
||||
|
||||
str = objAsStringPtr(strObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END);
|
||||
}
|
||||
|
||||
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
|
||||
|
||||
GUARD_EXC( b->drawText(rect->toIntRect(), str, align); );
|
||||
}
|
||||
else
|
||||
{
|
||||
GUARD_EXC(b->drawText(rect->toIntRect(), str, align););
|
||||
} else {
|
||||
int x, y, width, height;
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
if (rgssVer >= 2) {
|
||||
VALUE strObj;
|
||||
rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END);
|
||||
rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj,
|
||||
&align RB_ARG_END);
|
||||
|
||||
str = objAsStringPtr(strObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END);
|
||||
} else {
|
||||
rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str,
|
||||
&align RB_ARG_END);
|
||||
}
|
||||
|
||||
GUARD_EXC( b->drawText(x, y, width, height, str, align); );
|
||||
GUARD_EXC(b->drawText(x, y, width, height, str, align););
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapTextSize)
|
||||
{
|
||||
RB_METHOD(bitmapTextSize) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
const char *str;
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
if (rgssVer >= 2) {
|
||||
VALUE strObj;
|
||||
rb_get_args(argc, argv, "o", &strObj RB_ARG_END);
|
||||
|
||||
str = objAsStringPtr(strObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rb_get_args(argc, argv, "z", &str RB_ARG_END);
|
||||
}
|
||||
|
||||
IntRect value;
|
||||
GUARD_EXC( value = b->textSize(str); );
|
||||
GUARD_EXC(value = b->textSize(str););
|
||||
|
||||
Rect *rect = new Rect(value);
|
||||
|
||||
|
@ -329,50 +302,46 @@ RB_METHOD(bitmapTextSize)
|
|||
|
||||
DEF_PROP_OBJ_VAL(Bitmap, Font, Font, "font")
|
||||
|
||||
RB_METHOD(bitmapGradientFillRect)
|
||||
{
|
||||
RB_METHOD(bitmapGradientFillRect) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
VALUE color1Obj, color2Obj;
|
||||
Color *color1, *color2;
|
||||
bool vertical = false;
|
||||
|
||||
if (argc == 3 || argc == 4)
|
||||
{
|
||||
if (argc == 3 || argc == 4) {
|
||||
VALUE rectObj;
|
||||
Rect *rect;
|
||||
|
||||
rb_get_args(argc, argv, "ooo|b", &rectObj,
|
||||
&color1Obj, &color2Obj, &vertical RB_ARG_END);
|
||||
rb_get_args(argc, argv, "ooo|b", &rectObj, &color1Obj, &color2Obj,
|
||||
&vertical RB_ARG_END);
|
||||
|
||||
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
|
||||
color1 = getPrivateDataCheck<Color>(color1Obj, ColorType);
|
||||
color2 = getPrivateDataCheck<Color>(color2Obj, ColorType);
|
||||
|
||||
GUARD_EXC( b->gradientFillRect(rect->toIntRect(), color1->norm, color2->norm, vertical); );
|
||||
}
|
||||
else
|
||||
{
|
||||
GUARD_EXC(b->gradientFillRect(rect->toIntRect(), color1->norm, color2->norm,
|
||||
vertical););
|
||||
} else {
|
||||
int x, y, width, height;
|
||||
|
||||
rb_get_args(argc, argv, "iiiioo|b", &x, &y, &width, &height,
|
||||
&color1Obj, &color2Obj, &vertical RB_ARG_END);
|
||||
rb_get_args(argc, argv, "iiiioo|b", &x, &y, &width, &height, &color1Obj,
|
||||
&color2Obj, &vertical RB_ARG_END);
|
||||
|
||||
color1 = getPrivateDataCheck<Color>(color1Obj, ColorType);
|
||||
color2 = getPrivateDataCheck<Color>(color2Obj, ColorType);
|
||||
|
||||
GUARD_EXC( b->gradientFillRect(x, y, width, height, color1->norm, color2->norm, vertical); );
|
||||
GUARD_EXC(b->gradientFillRect(x, y, width, height, color1->norm,
|
||||
color2->norm, vertical););
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapClearRect)
|
||||
{
|
||||
RB_METHOD(bitmapClearRect) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
if (argc == 1) {
|
||||
VALUE rectObj;
|
||||
Rect *rect;
|
||||
|
||||
|
@ -380,22 +349,19 @@ RB_METHOD(bitmapClearRect)
|
|||
|
||||
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
|
||||
|
||||
GUARD_EXC( b->clearRect(rect->toIntRect()); );
|
||||
}
|
||||
else
|
||||
{
|
||||
GUARD_EXC(b->clearRect(rect->toIntRect()););
|
||||
} else {
|
||||
int x, y, width, height;
|
||||
|
||||
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
|
||||
|
||||
GUARD_EXC( b->clearRect(x, y, width, height); );
|
||||
GUARD_EXC(b->clearRect(x, y, width, height););
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapBlur)
|
||||
{
|
||||
RB_METHOD(bitmapBlur) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
@ -405,8 +371,7 @@ RB_METHOD(bitmapBlur)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapRadialBlur)
|
||||
{
|
||||
RB_METHOD(bitmapRadialBlur) {
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
int angle, divisions;
|
||||
|
@ -417,21 +382,19 @@ RB_METHOD(bitmapRadialBlur)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapGetRawData)
|
||||
{
|
||||
RB_METHOD(bitmapGetRawData) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
int size = b->width()*b->height()*4;
|
||||
int size = b->width() * b->height() * 4;
|
||||
VALUE ret = rb_str_new(0, size);
|
||||
|
||||
GUARD_EXC ( b->getRaw(RSTRING_PTR(ret), size); );
|
||||
GUARD_EXC(b->getRaw(RSTRING_PTR(ret), size););
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapSetRawData)
|
||||
{
|
||||
RB_METHOD(bitmapSetRawData) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
VALUE str;
|
||||
|
@ -440,13 +403,12 @@ RB_METHOD(bitmapSetRawData)
|
|||
|
||||
Bitmap *b = getPrivateData<Bitmap>(self);
|
||||
|
||||
GUARD_EXC( b->replaceRaw(RSTRING_PTR(str), RSTRING_LEN(str)); );
|
||||
GUARD_EXC(b->replaceRaw(RSTRING_PTR(str), RSTRING_LEN(str)););
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapSaveToFile)
|
||||
{
|
||||
RB_METHOD(bitmapSaveToFile) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
VALUE str;
|
||||
|
@ -464,8 +426,7 @@ RB_METHOD(bitmapSaveToFile)
|
|||
return RUBY_Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapInitializeCopy)
|
||||
{
|
||||
RB_METHOD(bitmapInitializeCopy) {
|
||||
rb_check_argc(argc, 1);
|
||||
VALUE origObj = argv[0];
|
||||
|
||||
|
@ -474,7 +435,7 @@ RB_METHOD(bitmapInitializeCopy)
|
|||
|
||||
Bitmap *orig = getPrivateData<Bitmap>(origObj);
|
||||
Bitmap *b = 0;
|
||||
GUARD_EXC( b = new Bitmap(*orig); );
|
||||
GUARD_EXC(b = new Bitmap(*orig););
|
||||
|
||||
bitmapInitProps(b, self);
|
||||
b->setFont(orig->getFont());
|
||||
|
@ -484,12 +445,9 @@ RB_METHOD(bitmapInitializeCopy)
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bitmapBindingInit()
|
||||
{
|
||||
void bitmapBindingInit() {
|
||||
VALUE klass = rb_define_class("Bitmap", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&BitmapType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, BitmapAllocate);
|
||||
|
|
|
@ -1,46 +1,39 @@
|
|||
#include <discord_game_sdk.h>
|
||||
|
||||
#include "binding-types.h"
|
||||
#include "binding-util.h"
|
||||
#include "discordstate.h"
|
||||
#include "sharedstate.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
|
||||
//NYI
|
||||
void discordResultCb(void *callback_data, enum EDiscordResult result)
|
||||
{
|
||||
// NYI
|
||||
void discordResultCb(void *callback_data, enum EDiscordResult result) {}
|
||||
|
||||
}
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE_CUSTOMFREE(DCActivity, free);
|
||||
#else
|
||||
DEF_ALLOCFUNC_CUSTOMFREE(DCActivity, free);
|
||||
#endif
|
||||
|
||||
RB_METHOD(DiscordConnected)
|
||||
{
|
||||
RB_METHOD(DiscordConnected) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
// Checking to make sure callbacks have actually fired
|
||||
return rb_bool_new(shState->discord().userId());
|
||||
}
|
||||
|
||||
RB_METHOD(DiscordGetUsername)
|
||||
{
|
||||
RB_METHOD(DiscordGetUsername) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_str_new_cstr(shState->discord().userName().c_str());
|
||||
}
|
||||
|
||||
RB_METHOD(DiscordGetDiscriminator)
|
||||
{
|
||||
RB_METHOD(DiscordGetDiscriminator) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_str_new_cstr(shState->discord().userDiscrim().c_str());
|
||||
}
|
||||
|
||||
RB_METHOD(DiscordGetUserId)
|
||||
{
|
||||
RB_METHOD(DiscordGetUserId) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return LL2NUM(shState->discord().userId());
|
||||
|
@ -48,36 +41,34 @@ RB_METHOD(DiscordGetUserId)
|
|||
|
||||
void bitmapInitProps(Bitmap *b, VALUE self);
|
||||
|
||||
RB_METHOD(DiscordGetUserAvatar)
|
||||
{
|
||||
RB_METHOD(DiscordGetUserAvatar) {
|
||||
RB_UNUSED_PARAM;
|
||||
int size = 32;
|
||||
rb_get_args(argc, argv, "|i", &size RB_ARG_END);
|
||||
|
||||
Bitmap *result = shState->discord().userAvatar(size);
|
||||
if (!result) return RUBY_Qnil;
|
||||
if (!result)
|
||||
return RUBY_Qnil;
|
||||
|
||||
VALUE ret = wrapObject(result, BitmapType);
|
||||
bitmapInitProps(result, ret);
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
RB_METHOD(DiscordActivitySend)
|
||||
{
|
||||
RB_METHOD(DiscordActivitySend) {
|
||||
RB_UNUSED_PARAM;
|
||||
IDiscordActivityManager *am = shState->discord().activityManager();
|
||||
|
||||
DiscordActivity *activity = getPrivateData<DiscordActivity>(self);
|
||||
|
||||
if (am) am->update_activity(am, activity, 0, discordResultCb);
|
||||
if (am)
|
||||
am->update_activity(am, activity, 0, discordResultCb);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(DiscordActivityInitialize)
|
||||
{
|
||||
RB_METHOD(DiscordActivityInitialize) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
DiscordActivity *activity = ALLOC(DiscordActivity);
|
||||
|
@ -87,16 +78,14 @@ RB_METHOD(DiscordActivityInitialize)
|
|||
|
||||
activity->type = DiscordActivityType_Playing;
|
||||
|
||||
if (rb_block_given_p())
|
||||
{
|
||||
if (rb_block_given_p()) {
|
||||
rb_yield(self);
|
||||
DiscordActivitySend(0, 0, self);
|
||||
};
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(DiscordActivityInitializeCopy)
|
||||
{
|
||||
RB_METHOD(DiscordActivityInitializeCopy) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
rb_check_argc(argc, 1);
|
||||
|
@ -114,138 +103,124 @@ RB_METHOD(DiscordActivityInitializeCopy)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(DiscordActivityClear)
|
||||
{
|
||||
RB_METHOD(DiscordActivityClear) {
|
||||
RB_UNUSED_PARAM;
|
||||
IDiscordActivityManager *am = shState->discord().activityManager();
|
||||
if (am) am->clear_activity(am, 0, discordResultCb);
|
||||
if (am)
|
||||
am->clear_activity(am, 0, discordResultCb);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
#define DEF_DCPROP_ACTPARTYSZ(n) \
|
||||
RB_METHOD(DiscordActivityGetParty##n) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
DiscordActivity *p = getPrivateData<DiscordActivity>(self); \
|
||||
return INT2NUM(p->party.size.n); \
|
||||
} \
|
||||
RB_METHOD(DiscordActivitySetParty##n) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
int num; \
|
||||
rb_get_args(argc, argv, "i", &num); \
|
||||
DiscordActivity *p = getPrivateData<DiscordActivity>(self); \
|
||||
p->party.size.n = num; \
|
||||
return INT2NUM(num); \
|
||||
}
|
||||
RB_METHOD(DiscordActivityGetParty##n) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
DiscordActivity *p = getPrivateData<DiscordActivity>(self); \
|
||||
return INT2NUM(p->party.size.n); \
|
||||
} \
|
||||
RB_METHOD(DiscordActivitySetParty##n) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
int num; \
|
||||
rb_get_args(argc, argv, "i", &num); \
|
||||
DiscordActivity *p = getPrivateData<DiscordActivity>(self); \
|
||||
p->party.size.n = num; \
|
||||
return INT2NUM(num); \
|
||||
}
|
||||
|
||||
DEF_DCPROP_ACTPARTYSZ(current_size);
|
||||
DEF_DCPROP_ACTPARTYSZ(max_size);
|
||||
|
||||
#define DEF_DCPROP_S(basename, propname, maxsz) \
|
||||
RB_METHOD(Discord##basename##Get##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return rb_str_new_cstr(p->propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
VALUE str; \
|
||||
rb_scan_args(argc, argv, "1", &str); \
|
||||
SafeStringValue(str); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
strncpy(p->propname, RSTRING_PTR(str), maxsz); \
|
||||
return str; \
|
||||
}
|
||||
RB_METHOD(Discord##basename##Get##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return rb_str_new_cstr(p->propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
VALUE str; \
|
||||
rb_scan_args(argc, argv, "1", &str); \
|
||||
SafeStringValue(str); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
strncpy(p->propname, RSTRING_PTR(str), maxsz); \
|
||||
return str; \
|
||||
}
|
||||
|
||||
#define DEF_DCPROP_S_SUB(basename, subname, propname, maxsz) \
|
||||
RB_METHOD(Discord##basename##Get##subname##_##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return rb_str_new_cstr(p->subname.propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##subname##_##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
VALUE str; \
|
||||
rb_scan_args(argc, argv, "1", &str); \
|
||||
SafeStringValue(str); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
strncpy(p->subname.propname, RSTRING_PTR(str), maxsz); \
|
||||
return str; \
|
||||
}
|
||||
RB_METHOD(Discord##basename##Get##subname##_##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return rb_str_new_cstr(p->subname.propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##subname##_##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
VALUE str; \
|
||||
rb_scan_args(argc, argv, "1", &str); \
|
||||
SafeStringValue(str); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
strncpy(p->subname.propname, RSTRING_PTR(str), maxsz); \
|
||||
return str; \
|
||||
}
|
||||
|
||||
#define DEF_DCPROP_I(basename, propname, convtype, cast) \
|
||||
RB_METHOD(Discord##basename##Get##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return convtype##2NUM(p->propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
VALUE num; \
|
||||
rb_scan_args(argc, argv, "1", &num); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
p->propname = (cast)NUM2##convtype(num); \
|
||||
return num; \
|
||||
}
|
||||
RB_METHOD(Discord##basename##Get##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return convtype##2NUM(p->propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
VALUE num; \
|
||||
rb_scan_args(argc, argv, "1", &num); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
p->propname = (cast)NUM2##convtype(num); \
|
||||
return num; \
|
||||
}
|
||||
|
||||
#define DEF_DCPROP_I_SUB(basename, subname, propname, convtype, cast) \
|
||||
RB_METHOD(Discord##basename##Get##subname##_##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return convtype##2NUM(p->subname.propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##subname##_##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
VALUE num; \
|
||||
rb_scan_args(argc, argv, "1", &num); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
p->subname.propname = (cast)NUM2##convtype(num); \
|
||||
return num; \
|
||||
}
|
||||
RB_METHOD(Discord##basename##Get##subname##_##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return convtype##2NUM(p->subname.propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##subname##_##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
VALUE num; \
|
||||
rb_scan_args(argc, argv, "1", &num); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
p->subname.propname = (cast)NUM2##convtype(num); \
|
||||
return num; \
|
||||
}
|
||||
|
||||
#define DEF_DCPROP_B(basename, propname) \
|
||||
RB_METHOD(Discord##basename##Get##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return rb_bool_new(p->propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
bool b; \
|
||||
rb_get_args(argc, argv, "b", &b RB_ARG_END); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
p->propname = b; \
|
||||
return rb_bool_new(b); \
|
||||
}
|
||||
RB_METHOD(Discord##basename##Get##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return rb_bool_new(p->propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
bool b; \
|
||||
rb_get_args(argc, argv, "b", &b RB_ARG_END); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
p->propname = b; \
|
||||
return rb_bool_new(b); \
|
||||
}
|
||||
|
||||
#define DEF_DCPROP_B_SUB(basename, propname, subname) \
|
||||
RB_METHOD(Discord##basename##Get##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return rb_bool_new(p->subname.propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##propname) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
bool b; \
|
||||
rb_get_args(argc, argv, "b", &b RB_ARG_END); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
p->subname.propname = b; \
|
||||
return rb_bool_new(b); \
|
||||
}
|
||||
RB_METHOD(Discord##basename##Get##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
return rb_bool_new(p->subname.propname); \
|
||||
} \
|
||||
RB_METHOD(Discord##basename##Set##propname) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
bool b; \
|
||||
rb_get_args(argc, argv, "b", &b RB_ARG_END); \
|
||||
Discord##basename *p = getPrivateData<Discord##basename>(self); \
|
||||
p->subname.propname = b; \
|
||||
return rb_bool_new(b); \
|
||||
}
|
||||
|
||||
DEF_DCPROP_S(Activity, state, 128);
|
||||
DEF_DCPROP_S(Activity, details, 128);
|
||||
|
@ -261,28 +236,28 @@ DEF_DCPROP_I_SUB(Activity, timestamps, end, LL, DiscordTimestamp);
|
|||
DEF_DCPROP_B(Activity, instance);
|
||||
|
||||
#define BIND_DCPROP(basename, b, f) \
|
||||
_rb_define_method(activityClass, b, Discord##basename##Get##f); \
|
||||
_rb_define_method(activityClass, b "=", Discord##basename##Set##f);
|
||||
_rb_define_method(activityClass, b, Discord##basename##Get##f); \
|
||||
_rb_define_method(activityClass, b "=", Discord##basename##Set##f);
|
||||
|
||||
|
||||
void DiscordBindingInit()
|
||||
{
|
||||
void DiscordBindingInit() {
|
||||
VALUE mod = rb_define_module("Discord");
|
||||
_rb_define_module_function(mod, "connected?", DiscordConnected);
|
||||
_rb_define_module_function(mod, "user_name", DiscordGetUsername);
|
||||
_rb_define_module_function(mod, "user_discriminator", DiscordGetDiscriminator);
|
||||
_rb_define_module_function(mod, "user_discriminator",
|
||||
DiscordGetDiscriminator);
|
||||
_rb_define_module_function(mod, "user_id", DiscordGetUserId);
|
||||
_rb_define_module_function(mod, "user_avatar", DiscordGetUserAvatar);
|
||||
|
||||
VALUE activityClass = rb_define_class_under(mod, "Activity", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(activityClass, classAllocate<&DCActivityType>);
|
||||
#else
|
||||
rb_define_alloc_func(activityClass, DCActivityAllocate);
|
||||
#endif
|
||||
|
||||
_rb_define_method(activityClass, "initialize", DiscordActivityInitialize);
|
||||
_rb_define_method(activityClass, "initialize_copy", DiscordActivityInitializeCopy);
|
||||
_rb_define_method(activityClass, "initialize_copy",
|
||||
DiscordActivityInitializeCopy);
|
||||
|
||||
rb_define_class_method(activityClass, "clear", DiscordActivityClear);
|
||||
|
||||
|
@ -302,5 +277,4 @@ void DiscordBindingInit()
|
|||
BIND_DCPROP(Activity, "start_time", timestamps_start);
|
||||
BIND_DCPROP(Activity, "end_time", timestamps_end);
|
||||
BIND_DCPROP(Activity, "instance", instance);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "etc.h"
|
||||
#include "binding-util.h"
|
||||
#include "etc.h"
|
||||
#include "serializable-binding.h"
|
||||
#include "sharedstate.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE(Color);
|
||||
DEF_TYPE(Tone);
|
||||
DEF_TYPE(Rect);
|
||||
|
@ -35,14 +35,12 @@ DEF_ALLOCFUNC(Rect);
|
|||
#endif
|
||||
|
||||
#define ATTR_RW(Klass, Attr, arg_type, arg_t_s, value_fun) \
|
||||
RB_METHOD(Klass##Get##Attr) \
|
||||
{ \
|
||||
RB_METHOD(Klass##Get##Attr) { \
|
||||
RB_UNUSED_PARAM \
|
||||
Klass *p = getPrivateData<Klass>(self); \
|
||||
return value_fun(p->get##Attr()); \
|
||||
} \
|
||||
RB_METHOD(Klass##Set##Attr) \
|
||||
{ \
|
||||
RB_METHOD(Klass##Set##Attr) { \
|
||||
Klass *p = getPrivateData<Klass>(self); \
|
||||
arg_type arg; \
|
||||
rb_get_args(argc, argv, arg_t_s, &arg RB_ARG_END); \
|
||||
|
@ -50,7 +48,8 @@ DEF_ALLOCFUNC(Rect);
|
|||
return *argv; \
|
||||
}
|
||||
|
||||
#define ATTR_DOUBLE_RW(Klass, Attr) ATTR_RW(Klass, Attr, double, "f", rb_float_new)
|
||||
#define ATTR_DOUBLE_RW(Klass, Attr) \
|
||||
ATTR_RW(Klass, Attr, double, "f", rb_float_new)
|
||||
#define ATTR_INT_RW(Klass, Attr) ATTR_RW(Klass, Attr, int, "i", rb_fix_new)
|
||||
|
||||
ATTR_DOUBLE_RW(Color, Red)
|
||||
|
@ -68,10 +67,9 @@ ATTR_INT_RW(Rect, Y)
|
|||
ATTR_INT_RW(Rect, Width)
|
||||
ATTR_INT_RW(Rect, Height)
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
#define EQUAL_FUN(Klass) \
|
||||
RB_METHOD(Klass##Equal) \
|
||||
{ \
|
||||
RB_METHOD(Klass##Equal) { \
|
||||
Klass *p = getPrivateData<Klass>(self); \
|
||||
VALUE otherObj; \
|
||||
Klass *other; \
|
||||
|
@ -84,8 +82,7 @@ ATTR_INT_RW(Rect, Height)
|
|||
}
|
||||
#else
|
||||
#define EQUAL_FUN(Klass) \
|
||||
RB_METHOD(Klass##Equal) \
|
||||
{ \
|
||||
RB_METHOD(Klass##Equal) { \
|
||||
Klass *p = getPrivateData<Klass>(self); \
|
||||
VALUE otherObj; \
|
||||
Klass *other; \
|
||||
|
@ -101,15 +98,11 @@ EQUAL_FUN(Tone)
|
|||
EQUAL_FUN(Rect)
|
||||
|
||||
#define INIT_FUN(Klass, param_type, param_t_s, last_param_def) \
|
||||
RB_METHOD(Klass##Initialize) \
|
||||
{ \
|
||||
RB_METHOD(Klass##Initialize) { \
|
||||
Klass *k; \
|
||||
if (argc == 0) \
|
||||
{ \
|
||||
if (argc == 0) { \
|
||||
k = new Klass(); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
} else { \
|
||||
param_type p1, p2, p3, p4 = last_param_def; \
|
||||
rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
|
||||
k = new Klass(p1, p2, p3, p4); \
|
||||
|
@ -122,19 +115,15 @@ INIT_FUN(Color, double, "fff|f", 255)
|
|||
INIT_FUN(Tone, double, "fff|f", 0)
|
||||
INIT_FUN(Rect, int, "iiii", 0)
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
#define SET_FUN(Klass, param_type, param_t_s, last_param_def) \
|
||||
RB_METHOD(Klass##Set) \
|
||||
{ \
|
||||
RB_METHOD(Klass##Set) { \
|
||||
Klass *k = getPrivateData<Klass>(self); \
|
||||
if (argc == 1) \
|
||||
{ \
|
||||
if (argc == 1) { \
|
||||
VALUE otherObj = argv[0]; \
|
||||
Klass *other = getPrivateDataCheck<Klass>(otherObj, Klass##Type); \
|
||||
*k = *other; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
} else { \
|
||||
param_type p1, p2, p3, p4 = last_param_def; \
|
||||
rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
|
||||
k->set(p1, p2, p3, p4); \
|
||||
|
@ -143,17 +132,13 @@ INIT_FUN(Rect, int, "iiii", 0)
|
|||
}
|
||||
#else
|
||||
#define SET_FUN(Klass, param_type, param_t_s, last_param_def) \
|
||||
RB_METHOD(Klass##Set) \
|
||||
{ \
|
||||
RB_METHOD(Klass##Set) { \
|
||||
Klass *k = getPrivateData<Klass>(self); \
|
||||
if (argc == 1) \
|
||||
{ \
|
||||
if (argc == 1) { \
|
||||
VALUE otherObj = argv[0]; \
|
||||
Klass *other = getPrivateDataCheck<Klass>(otherObj, #Klass); \
|
||||
*k = *other; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
} else { \
|
||||
param_type p1, p2, p3, p4 = last_param_def; \
|
||||
rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
|
||||
k->set(p1, p2, p3, p4); \
|
||||
|
@ -166,63 +151,53 @@ SET_FUN(Color, double, "fff|f", 255)
|
|||
SET_FUN(Tone, double, "fff|f", 0)
|
||||
SET_FUN(Rect, int, "iiii", 0)
|
||||
|
||||
RB_METHOD(rectEmpty)
|
||||
{
|
||||
RB_METHOD(rectEmpty) {
|
||||
RB_UNUSED_PARAM;
|
||||
Rect *r = getPrivateData<Rect>(self);
|
||||
r->empty();
|
||||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(ColorStringify)
|
||||
{
|
||||
RB_METHOD(ColorStringify) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Color *c = getPrivateData<Color>(self);
|
||||
#ifndef OLD_RUBY
|
||||
return rb_sprintf("(%f, %f, %f, %f)",
|
||||
c->red, c->green, c->blue, c->alpha);
|
||||
#if RAPI_FULL > 187
|
||||
return rb_sprintf("(%f, %f, %f, %f)", c->red, c->green, c->blue, c->alpha);
|
||||
#else
|
||||
char buf[50] = {0};
|
||||
sprintf((char*)&buf, "(%f, %f, %f, %f)",
|
||||
c->red, c->green, c->blue, c->alpha);
|
||||
sprintf((char *)&buf, "(%f, %f, %f, %f)", c->red, c->green, c->blue,
|
||||
c->alpha);
|
||||
return rb_str_new2(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
RB_METHOD(ToneStringify)
|
||||
{
|
||||
RB_METHOD(ToneStringify) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Tone *t = getPrivateData<Tone>(self);
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
return rb_sprintf("(%f, %f, %f, %f)",
|
||||
t->red, t->green, t->blue, t->gray);
|
||||
#if RAPI_FULL > 187
|
||||
return rb_sprintf("(%f, %f, %f, %f)", t->red, t->green, t->blue, t->gray);
|
||||
#else
|
||||
char buf[50] = {0};
|
||||
sprintf((char*)&buf, "(%f, %f, %f, %f)",
|
||||
t->red, t->green, t->blue, t->gray);
|
||||
sprintf((char *)&buf, "(%f, %f, %f, %f)", t->red, t->green, t->blue, t->gray);
|
||||
return rb_str_new2(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
RB_METHOD(RectStringify)
|
||||
{
|
||||
RB_METHOD(RectStringify) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Rect *r = getPrivateData<Rect>(self);
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
return rb_sprintf("(%d, %d, %d, %d)",
|
||||
r->x, r->y, r->width, r->height);
|
||||
#if RAPI_FULL > 187
|
||||
return rb_sprintf("(%d, %d, %d, %d)", r->x, r->y, r->width, r->height);
|
||||
#else
|
||||
char buf[50] = {0};
|
||||
sprintf((char*)&buf, "(%d, %d, %d, %d)",
|
||||
r->x, r->y, r->width, r->height);
|
||||
sprintf((char *)&buf, "(%d, %d, %d, %d)", r->x, r->y, r->width, r->height);
|
||||
return rb_str_new2(buf);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
MARSH_LOAD_FUN(Color)
|
||||
|
@ -233,9 +208,9 @@ INITCOPY_FUN(Tone)
|
|||
INITCOPY_FUN(Color)
|
||||
INITCOPY_FUN(Rect)
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
#define INIT_BIND(Klass) \
|
||||
{ \
|
||||
{ \
|
||||
klass = rb_define_class(#Klass, rb_cObject); \
|
||||
rb_define_alloc_func(klass, classAllocate<&Klass##Type>); \
|
||||
rb_define_class_method(klass, "_load", Klass##Load); \
|
||||
|
@ -248,10 +223,10 @@ INITCOPY_FUN(Rect)
|
|||
_rb_define_method(klass, "eql?", Klass##Equal); \
|
||||
_rb_define_method(klass, "to_s", Klass##Stringify); \
|
||||
_rb_define_method(klass, "inspect", Klass##Stringify); \
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define INIT_BIND(Klass) \
|
||||
{ \
|
||||
{ \
|
||||
klass = rb_define_class(#Klass, rb_cObject); \
|
||||
rb_define_alloc_func(klass, Klass##Allocate); \
|
||||
rb_define_class_method(klass, "_load", Klass##Load); \
|
||||
|
@ -264,21 +239,30 @@ INITCOPY_FUN(Rect)
|
|||
_rb_define_method(klass, "eql?", Klass##Equal); \
|
||||
_rb_define_method(klass, "to_s", Klass##Stringify); \
|
||||
_rb_define_method(klass, "inspect", Klass##Stringify); \
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MRB_ATTR_R(Class, attr) mrb_define_method(mrb, klass, #attr, Class##Get_##attr, MRB_ARGS_NONE())
|
||||
#define MRB_ATTR_W(Class, attr) mrb_define_method(mrb, klass, #attr "=", Class##Set_##attr, MRB_ARGS_REQ(1))
|
||||
#define MRB_ATTR_RW(Class, attr) { MRB_ATTR_R(Class, attr); MRB_ATTR_W(Class, attr); }
|
||||
#define MRB_ATTR_R(Class, attr) \
|
||||
mrb_define_method(mrb, klass, #attr, Class##Get_##attr, MRB_ARGS_NONE())
|
||||
#define MRB_ATTR_W(Class, attr) \
|
||||
mrb_define_method(mrb, klass, #attr "=", Class##Set_##attr, MRB_ARGS_REQ(1))
|
||||
#define MRB_ATTR_RW(Class, attr) \
|
||||
{ \
|
||||
MRB_ATTR_R(Class, attr); \
|
||||
MRB_ATTR_W(Class, attr); \
|
||||
}
|
||||
|
||||
#define RB_ATTR_R(Klass, Attr, attr) _rb_define_method(klass, #attr, Klass##Get##Attr)
|
||||
#define RB_ATTR_W(Klass, Attr, attr) _rb_define_method(klass, #attr "=", Klass##Set##Attr)
|
||||
#define RB_ATTR_R(Klass, Attr, attr) \
|
||||
_rb_define_method(klass, #attr, Klass##Get##Attr)
|
||||
#define RB_ATTR_W(Klass, Attr, attr) \
|
||||
_rb_define_method(klass, #attr "=", Klass##Set##Attr)
|
||||
#define RB_ATTR_RW(Klass, Attr, attr) \
|
||||
{ RB_ATTR_R(Klass, Attr, attr); RB_ATTR_W(Klass, Attr, attr); }
|
||||
{ \
|
||||
RB_ATTR_R(Klass, Attr, attr); \
|
||||
RB_ATTR_W(Klass, Attr, attr); \
|
||||
}
|
||||
|
||||
void
|
||||
etcBindingInit()
|
||||
{
|
||||
void etcBindingInit() {
|
||||
VALUE klass;
|
||||
|
||||
INIT_BIND(Color);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "src/config.h"
|
||||
#include "src/util.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
#include "ruby/encoding.h"
|
||||
#include "ruby/intern.h"
|
||||
#else
|
||||
|
@ -40,7 +40,7 @@ static void fileIntFreeInstance(void *inst) {
|
|||
SDL_FreeRW(ops);
|
||||
}
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
|
||||
#else
|
||||
DEF_ALLOCFUNC_CUSTOMFREE(FileInt, fileIntFreeInstance);
|
||||
|
@ -200,8 +200,8 @@ RB_METHOD(kernelSaveData) {
|
|||
|
||||
return Qnil;
|
||||
}
|
||||
#ifndef OLD_RUBY
|
||||
#if RUBYCOMPAT < 270
|
||||
#if RAPI_FULL > 187
|
||||
#if RAPI_FULL < 270
|
||||
static VALUE stringForceUTF8(VALUE arg)
|
||||
#else
|
||||
static VALUE stringForceUTF8(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, arg))
|
||||
|
@ -213,7 +213,7 @@ static VALUE stringForceUTF8(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, arg))
|
|||
return arg;
|
||||
}
|
||||
|
||||
#if RUBYCOMPAT < 270
|
||||
#if RAPI_FULL < 270
|
||||
static VALUE customProc(VALUE arg, VALUE proc) {
|
||||
VALUE obj = stringForceUTF8(arg);
|
||||
obj = rb_funcall2(proc, rb_intern("call"), 1, &obj);
|
||||
|
@ -224,7 +224,7 @@ static VALUE customProc(VALUE arg, VALUE proc) {
|
|||
|
||||
RB_METHOD(_marshalLoad) {
|
||||
RB_UNUSED_PARAM;
|
||||
#if RUBYCOMPAT < 270
|
||||
#if RAPI_FULL < 270
|
||||
VALUE port, proc = Qnil;
|
||||
rb_get_args(argc, argv, "o|o", &port, &proc RB_ARG_END);
|
||||
#else
|
||||
|
@ -233,7 +233,7 @@ RB_METHOD(_marshalLoad) {
|
|||
#endif
|
||||
|
||||
VALUE utf8Proc;
|
||||
#if RUBYCOMPAT < 270
|
||||
#if RAPI_FULL < 270
|
||||
if (NIL_P(proc))
|
||||
|
||||
utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(stringForceUTF8), Qnil);
|
||||
|
@ -250,9 +250,9 @@ RB_METHOD(_marshalLoad) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void fileIntBindingInit() {
|
||||
void fileIntBindingInit() {
|
||||
VALUE klass = rb_define_class("FileInt", rb_cIO);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&FileIntType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, FileIntAllocate);
|
||||
|
@ -260,7 +260,7 @@ RB_METHOD(_marshalLoad) {
|
|||
|
||||
_rb_define_method(klass, "read", fileIntRead);
|
||||
_rb_define_method(klass, "getbyte", fileIntGetByte);
|
||||
#ifdef OLD_RUBY
|
||||
#if RAPI_FULL <= 187
|
||||
// Ruby doesn't see this as an initialized stream,
|
||||
// so either that has to be fixed or necessary
|
||||
// IO functions have to be overridden
|
||||
|
@ -273,7 +273,7 @@ RB_METHOD(_marshalLoad) {
|
|||
_rb_define_module_function(rb_mKernel, "load_data", kernelLoadData);
|
||||
_rb_define_module_function(rb_mKernel, "save_data", kernelSaveData);
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
/* We overload the built-in 'Marshal::load()' function to silently
|
||||
* insert our utf8proc that ensures all read strings will be
|
||||
* UTF-8 encoded */
|
||||
|
@ -281,4 +281,4 @@ RB_METHOD(_marshalLoad) {
|
|||
rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load");
|
||||
_rb_define_module_function(marsh, "load", _marshalLoad);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,26 +19,19 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "font.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
#include "binding-util.h"
|
||||
#include "exception.h"
|
||||
#include "font.h"
|
||||
#include "sharedstate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static void
|
||||
collectStrings(VALUE obj, std::vector<std::string> &out)
|
||||
{
|
||||
if (RB_TYPE_P(obj, RUBY_T_STRING))
|
||||
{
|
||||
static void collectStrings(VALUE obj, std::vector<std::string> &out) {
|
||||
if (RB_TYPE_P(obj, RUBY_T_STRING)) {
|
||||
out.push_back(RSTRING_PTR(obj));
|
||||
}
|
||||
else if (RB_TYPE_P(obj, RUBY_T_ARRAY))
|
||||
{
|
||||
for (long i = 0; i < RARRAY_LEN(obj); ++i)
|
||||
{
|
||||
} else if (RB_TYPE_P(obj, RUBY_T_ARRAY)) {
|
||||
for (long i = 0; i < RARRAY_LEN(obj); ++i) {
|
||||
VALUE str = rb_ary_entry(obj, i);
|
||||
|
||||
/* Non-string objects are tolerated (ignored) */
|
||||
|
@ -50,14 +43,13 @@ collectStrings(VALUE obj, std::vector<std::string> &out)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE(Font);
|
||||
#else
|
||||
DEF_ALLOCFUNC(Font);
|
||||
#endif
|
||||
|
||||
RB_METHOD(fontDoesExist)
|
||||
{
|
||||
RB_METHOD(fontDoesExist) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
const char *name = 0;
|
||||
|
@ -73,8 +65,7 @@ RB_METHOD(fontDoesExist)
|
|||
|
||||
RB_METHOD(FontSetName);
|
||||
|
||||
RB_METHOD(fontInitialize)
|
||||
{
|
||||
RB_METHOD(fontInitialize) {
|
||||
VALUE namesObj = Qnil;
|
||||
int size = 0;
|
||||
|
||||
|
@ -82,13 +73,10 @@ RB_METHOD(fontInitialize)
|
|||
|
||||
Font *f;
|
||||
|
||||
if (NIL_P(namesObj))
|
||||
{
|
||||
if (NIL_P(namesObj)) {
|
||||
namesObj = rb_iv_get(rb_obj_class(self), "default_name");
|
||||
f = new Font(0, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
std::vector<std::string> names;
|
||||
collectStrings(namesObj, names);
|
||||
|
||||
|
@ -113,8 +101,7 @@ RB_METHOD(fontInitialize)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(fontInitializeCopy)
|
||||
{
|
||||
RB_METHOD(fontInitializeCopy) {
|
||||
VALUE origObj;
|
||||
rb_get_args(argc, argv, "o", &origObj RB_ARG_END);
|
||||
|
||||
|
@ -136,15 +123,13 @@ RB_METHOD(fontInitializeCopy)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(FontGetName)
|
||||
{
|
||||
RB_METHOD(FontGetName) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_iv_get(self, "name");
|
||||
}
|
||||
|
||||
RB_METHOD(FontSetName)
|
||||
{
|
||||
RB_METHOD(FontSetName) {
|
||||
Font *f = getPrivateData<Font>(self);
|
||||
|
||||
rb_check_argc(argc, 1);
|
||||
|
@ -158,8 +143,7 @@ RB_METHOD(FontSetName)
|
|||
return argv[0];
|
||||
}
|
||||
|
||||
template<class C>
|
||||
static void checkDisposed(VALUE) {}
|
||||
template <class C> static void checkDisposed(VALUE) {}
|
||||
|
||||
DEF_PROP_OBJ_VAL(Font, Color, Color, "color")
|
||||
DEF_PROP_OBJ_VAL(Font, Color, OutColor, "out_color")
|
||||
|
@ -172,13 +156,11 @@ DEF_PROP_B(Font, Shadow)
|
|||
DEF_PROP_B(Font, Outline)
|
||||
|
||||
#define DEF_KLASS_PROP(Klass, type, PropName, param_t_s, value_fun) \
|
||||
RB_METHOD(Klass##Get##PropName) \
|
||||
{ \
|
||||
RB_METHOD(Klass##Get##PropName) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
return value_fun(Klass::get##PropName()); \
|
||||
} \
|
||||
RB_METHOD(Klass##Set##PropName) \
|
||||
{ \
|
||||
RB_METHOD(Klass##Set##PropName) { \
|
||||
RB_UNUSED_PARAM; \
|
||||
type value; \
|
||||
rb_get_args(argc, argv, param_t_s, &value RB_ARG_END); \
|
||||
|
@ -192,14 +174,12 @@ DEF_KLASS_PROP(Font, bool, DefaultItalic, "b", rb_bool_new)
|
|||
DEF_KLASS_PROP(Font, bool, DefaultShadow, "b", rb_bool_new)
|
||||
DEF_KLASS_PROP(Font, bool, DefaultOutline, "b", rb_bool_new)
|
||||
|
||||
RB_METHOD(FontGetDefaultOutColor)
|
||||
{
|
||||
RB_METHOD(FontGetDefaultOutColor) {
|
||||
RB_UNUSED_PARAM;
|
||||
return rb_iv_get(self, "default_out_color");
|
||||
}
|
||||
|
||||
RB_METHOD(FontSetDefaultOutColor)
|
||||
{
|
||||
RB_METHOD(FontSetDefaultOutColor) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
VALUE colorObj;
|
||||
|
@ -212,15 +192,13 @@ RB_METHOD(FontSetDefaultOutColor)
|
|||
return colorObj;
|
||||
}
|
||||
|
||||
RB_METHOD(FontGetDefaultName)
|
||||
{
|
||||
RB_METHOD(FontGetDefaultName) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_iv_get(self, "default_name");
|
||||
}
|
||||
|
||||
RB_METHOD(FontSetDefaultName)
|
||||
{
|
||||
RB_METHOD(FontSetDefaultName) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
rb_check_argc(argc, 1);
|
||||
|
@ -234,15 +212,12 @@ RB_METHOD(FontSetDefaultName)
|
|||
return argv[0];
|
||||
}
|
||||
|
||||
RB_METHOD(FontGetDefaultColor)
|
||||
{
|
||||
RB_METHOD(FontGetDefaultColor) {
|
||||
RB_UNUSED_PARAM;
|
||||
return rb_iv_get(self, "default_color");
|
||||
}
|
||||
|
||||
|
||||
RB_METHOD(FontSetDefaultColor)
|
||||
{
|
||||
RB_METHOD(FontSetDefaultColor) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
VALUE colorObj;
|
||||
|
@ -256,16 +231,14 @@ RB_METHOD(FontSetDefaultColor)
|
|||
}
|
||||
|
||||
#define INIT_KLASS_PROP_BIND(Klass, PropName, prop_name_s) \
|
||||
{ \
|
||||
{ \
|
||||
rb_define_class_method(klass, prop_name_s, Klass##Get##PropName); \
|
||||
rb_define_class_method(klass, prop_name_s "=", Klass##Set##PropName); \
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fontBindingInit()
|
||||
{
|
||||
void fontBindingInit() {
|
||||
VALUE klass = rb_define_class("Font", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&FontType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, FontAllocate);
|
||||
|
@ -278,12 +251,9 @@ fontBindingInit()
|
|||
const std::vector<std::string> &defNames = Font::getInitialDefaultNames();
|
||||
VALUE defNamesObj;
|
||||
|
||||
if (defNames.size() == 1)
|
||||
{
|
||||
if (defNames.size() == 1) {
|
||||
defNamesObj = rb_str_new_cstr(defNames[0].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
defNamesObj = rb_ary_new2(defNames.size());
|
||||
|
||||
for (size_t i = 0; i < defNames.size(); ++i)
|
||||
|
@ -293,7 +263,8 @@ fontBindingInit()
|
|||
rb_iv_set(klass, "default_name", defNamesObj);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color", ColorType);
|
||||
wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color",
|
||||
ColorType);
|
||||
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
|
||||
|
@ -301,13 +272,11 @@ fontBindingInit()
|
|||
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
if (rgssVer >= 2) {
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
|
||||
}
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
if (rgssVer >= 3) {
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
|
||||
}
|
||||
|
@ -323,13 +292,11 @@ fontBindingInit()
|
|||
INIT_PROP_BIND(Font, Italic, "italic");
|
||||
INIT_PROP_BIND(Font, Color, "color");
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
if (rgssVer >= 2) {
|
||||
INIT_PROP_BIND(Font, Shadow, "shadow");
|
||||
}
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
if (rgssVer >= 3) {
|
||||
INIT_PROP_BIND(Font, Outline, "outline");
|
||||
INIT_PROP_BIND(Font, OutColor, "out_color");
|
||||
}
|
||||
|
|
|
@ -19,17 +19,16 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "binding-util.h"
|
||||
#include "exception.h"
|
||||
#include "input.h"
|
||||
#include "sharedstate.h"
|
||||
#include "exception.h"
|
||||
#include "binding-util.h"
|
||||
#include "src/util.h"
|
||||
|
||||
#include <string>
|
||||
#include <SDL_joystick.h>
|
||||
#include <string>
|
||||
|
||||
RB_METHOD(inputUpdate)
|
||||
{
|
||||
RB_METHOD(inputUpdate) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
shState->input().update();
|
||||
|
@ -37,18 +36,14 @@ RB_METHOD(inputUpdate)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
static int getButtonArg(VALUE *argv)
|
||||
{
|
||||
static int getButtonArg(VALUE *argv) {
|
||||
int num;
|
||||
|
||||
if (FIXNUM_P(*argv))
|
||||
{
|
||||
if (FIXNUM_P(*argv)) {
|
||||
num = FIX2INT(*argv);
|
||||
}
|
||||
else if (SYMBOL_P(*argv) && rgssVer >= 3)
|
||||
{
|
||||
} else if (SYMBOL_P(*argv) && rgssVer >= 3) {
|
||||
VALUE symHash = getRbData()->buttoncodeHash;
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
num = FIX2INT(rb_hash_lookup2(symHash, *argv, INT2FIX(Input::None)));
|
||||
#else
|
||||
VALUE res = rb_hash_aref(symHash, *argv);
|
||||
|
@ -57,9 +52,7 @@ static int getButtonArg(VALUE *argv)
|
|||
else
|
||||
num = Input::None;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// FIXME: RMXP allows only few more types that
|
||||
// don't make sense (symbols in pre 3, floats)
|
||||
num = 0;
|
||||
|
@ -68,24 +61,19 @@ static int getButtonArg(VALUE *argv)
|
|||
return num;
|
||||
}
|
||||
|
||||
static int getScancodeArg(VALUE *argv)
|
||||
{
|
||||
static int getScancodeArg(VALUE *argv) {
|
||||
const char *scancode = rb_id2name(SYM2ID(*argv));
|
||||
int code{};
|
||||
try
|
||||
{
|
||||
try {
|
||||
code = strToScancode[scancode];
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
} catch (...) {
|
||||
rb_raise(rb_eRuntimeError, "%s is not a valid key.", scancode);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
RB_METHOD(inputPress)
|
||||
{
|
||||
RB_METHOD(inputPress) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
rb_check_argc(argc, 1);
|
||||
|
@ -95,8 +83,7 @@ RB_METHOD(inputPress)
|
|||
|
||||
int num{};
|
||||
|
||||
if (SYMBOL_P(button))
|
||||
{
|
||||
if (SYMBOL_P(button)) {
|
||||
num = getScancodeArg(&button);
|
||||
return rb_bool_new(shState->input().isPressedEx(num, 0));
|
||||
}
|
||||
|
@ -106,8 +93,7 @@ RB_METHOD(inputPress)
|
|||
return rb_bool_new(shState->input().isPressed(num));
|
||||
}
|
||||
|
||||
RB_METHOD(inputTrigger)
|
||||
{
|
||||
RB_METHOD(inputTrigger) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
rb_check_argc(argc, 1);
|
||||
|
@ -117,8 +103,7 @@ RB_METHOD(inputTrigger)
|
|||
|
||||
int num{};
|
||||
|
||||
if (SYMBOL_P(button))
|
||||
{
|
||||
if (SYMBOL_P(button)) {
|
||||
num = getScancodeArg(&button);
|
||||
return rb_bool_new(shState->input().isTriggeredEx(num, 0));
|
||||
}
|
||||
|
@ -128,8 +113,7 @@ RB_METHOD(inputTrigger)
|
|||
return rb_bool_new(shState->input().isTriggered(num));
|
||||
}
|
||||
|
||||
RB_METHOD(inputRepeat)
|
||||
{
|
||||
RB_METHOD(inputRepeat) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
rb_check_argc(argc, 1);
|
||||
|
@ -139,8 +123,7 @@ RB_METHOD(inputRepeat)
|
|||
|
||||
int num{};
|
||||
|
||||
if (SYMBOL_P(button))
|
||||
{
|
||||
if (SYMBOL_P(button)) {
|
||||
num = getScancodeArg(&button);
|
||||
return rb_bool_new(shState->input().isRepeatedEx(num, 0));
|
||||
}
|
||||
|
@ -150,8 +133,7 @@ RB_METHOD(inputRepeat)
|
|||
return rb_bool_new(shState->input().isRepeated(num));
|
||||
}
|
||||
|
||||
RB_METHOD(inputPressEx)
|
||||
{
|
||||
RB_METHOD(inputPressEx) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
int num;
|
||||
|
@ -160,8 +142,7 @@ RB_METHOD(inputPressEx)
|
|||
return rb_bool_new(shState->input().isPressedEx(num, 1));
|
||||
}
|
||||
|
||||
RB_METHOD(inputTriggerEx)
|
||||
{
|
||||
RB_METHOD(inputTriggerEx) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
int num;
|
||||
|
@ -170,8 +151,7 @@ RB_METHOD(inputTriggerEx)
|
|||
return rb_bool_new(shState->input().isTriggeredEx(num, 1));
|
||||
}
|
||||
|
||||
RB_METHOD(inputRepeatEx)
|
||||
{
|
||||
RB_METHOD(inputRepeatEx) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
int num;
|
||||
|
@ -180,43 +160,38 @@ RB_METHOD(inputRepeatEx)
|
|||
return rb_bool_new(shState->input().isRepeatedEx(num, 1));
|
||||
}
|
||||
|
||||
RB_METHOD(inputDir4)
|
||||
{
|
||||
RB_METHOD(inputDir4) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_fix_new(shState->input().dir4Value());
|
||||
}
|
||||
|
||||
RB_METHOD(inputDir8)
|
||||
{
|
||||
RB_METHOD(inputDir8) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_fix_new(shState->input().dir8Value());
|
||||
}
|
||||
|
||||
/* Non-standard extensions */
|
||||
RB_METHOD(inputMouseX)
|
||||
{
|
||||
RB_METHOD(inputMouseX) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_fix_new(shState->input().mouseX());
|
||||
}
|
||||
|
||||
RB_METHOD(inputMouseY)
|
||||
{
|
||||
RB_METHOD(inputMouseY) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_fix_new(shState->input().mouseY());
|
||||
}
|
||||
|
||||
#define M_SYMBOL(x) ID2SYM(rb_intern(x))
|
||||
#define POWERCASE(v,c) \
|
||||
case SDL_JOYSTICK_POWER_##c: \
|
||||
v = M_SYMBOL(#c); \
|
||||
break;
|
||||
#define POWERCASE(v, c) \
|
||||
case SDL_JOYSTICK_POWER_##c: \
|
||||
v = M_SYMBOL(#c); \
|
||||
break;
|
||||
|
||||
RB_METHOD(inputJoystickInfo)
|
||||
{
|
||||
RB_METHOD(inputJoystickInfo) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
if (!shState->input().getJoystickConnected())
|
||||
|
@ -224,7 +199,8 @@ RB_METHOD(inputJoystickInfo)
|
|||
|
||||
VALUE ret = rb_hash_new();
|
||||
|
||||
rb_hash_aset(ret, M_SYMBOL("name"), rb_str_new_cstr(shState->input().getJoystickName()));
|
||||
rb_hash_aset(ret, M_SYMBOL("name"),
|
||||
rb_str_new_cstr(shState->input().getJoystickName()));
|
||||
|
||||
VALUE power;
|
||||
|
||||
|
@ -243,13 +219,11 @@ RB_METHOD(inputJoystickInfo)
|
|||
|
||||
rb_hash_aset(ret, M_SYMBOL("power"), power);
|
||||
return ret;
|
||||
|
||||
}
|
||||
#undef POWERCASE
|
||||
#undef M_SYMBOL
|
||||
|
||||
RB_METHOD(inputRumble)
|
||||
{
|
||||
RB_METHOD(inputRumble) {
|
||||
RB_UNUSED_PARAM;
|
||||
VALUE duration, strength, attack, fade;
|
||||
rb_scan_args(argc, argv, "13", &duration, &strength, &attack, &fade);
|
||||
|
@ -264,15 +238,13 @@ RB_METHOD(inputRumble)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(inputGetMode)
|
||||
{
|
||||
RB_METHOD(inputGetMode) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_bool_new(shState->input().getTextInputMode());
|
||||
}
|
||||
|
||||
RB_METHOD(inputSetMode)
|
||||
{
|
||||
RB_METHOD(inputSetMode) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
bool mode;
|
||||
|
@ -283,8 +255,7 @@ RB_METHOD(inputSetMode)
|
|||
return mode;
|
||||
}
|
||||
|
||||
RB_METHOD(inputGets)
|
||||
{
|
||||
RB_METHOD(inputGets) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
VALUE ret = rb_str_new_cstr(shState->input().getText());
|
||||
|
@ -293,8 +264,7 @@ RB_METHOD(inputGets)
|
|||
return ret;
|
||||
}
|
||||
|
||||
RB_METHOD(inputGetClipboard)
|
||||
{
|
||||
RB_METHOD(inputGetClipboard) {
|
||||
RB_UNUSED_PARAM;
|
||||
VALUE ret;
|
||||
try {
|
||||
|
@ -305,8 +275,7 @@ RB_METHOD(inputGetClipboard)
|
|||
return ret;
|
||||
}
|
||||
|
||||
RB_METHOD(inputSetClipboard)
|
||||
{
|
||||
RB_METHOD(inputSetClipboard) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
VALUE str;
|
||||
|
@ -322,54 +291,46 @@ RB_METHOD(inputSetClipboard)
|
|||
return str;
|
||||
}
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
const char *str;
|
||||
Input::ButtonCode val;
|
||||
}
|
||||
static buttonCodes[] =
|
||||
{
|
||||
{ "DOWN", Input::Down },
|
||||
{ "LEFT", Input::Left },
|
||||
{ "RIGHT", Input::Right },
|
||||
{ "UP", Input::Up },
|
||||
} static buttonCodes[] = {{"DOWN", Input::Down},
|
||||
{"LEFT", Input::Left},
|
||||
{"RIGHT", Input::Right},
|
||||
{"UP", Input::Up},
|
||||
|
||||
#ifdef MARIN
|
||||
{ "ZL", Input::ZL },
|
||||
{ "ZR", Input::ZR },
|
||||
{"ZL", Input::ZL},
|
||||
{"ZR", Input::ZR},
|
||||
#else
|
||||
{ "C", Input::ZL },
|
||||
{ "Z", Input::ZR },
|
||||
{"C", Input::ZL},
|
||||
{"Z", Input::ZR},
|
||||
#endif
|
||||
|
||||
{ "A", Input::A },
|
||||
{ "B", Input::B },
|
||||
{ "X", Input::X },
|
||||
{ "Y", Input::Y },
|
||||
{ "L", Input::L },
|
||||
{ "R", Input::R },
|
||||
{"A", Input::A},
|
||||
{"B", Input::B},
|
||||
{"X", Input::X},
|
||||
{"Y", Input::Y},
|
||||
{"L", Input::L},
|
||||
{"R", Input::R},
|
||||
|
||||
{ "SHIFT", Input::Shift },
|
||||
{ "CTRL", Input::Ctrl },
|
||||
{ "ALT", Input::Alt },
|
||||
{"SHIFT", Input::Shift},
|
||||
{"CTRL", Input::Ctrl},
|
||||
{"ALT", Input::Alt},
|
||||
|
||||
{ "F5", Input::F5 },
|
||||
{ "F6", Input::F6 },
|
||||
{ "F7", Input::F7 },
|
||||
{ "F8", Input::F8 },
|
||||
{ "F9", Input::F9 },
|
||||
{"F5", Input::F5},
|
||||
{"F6", Input::F6},
|
||||
{"F7", Input::F7},
|
||||
{"F8", Input::F8},
|
||||
{"F9", Input::F9},
|
||||
|
||||
{ "MOUSELEFT", Input::MouseLeft },
|
||||
{ "MOUSEMIDDLE", Input::MouseMiddle },
|
||||
{ "MOUSERIGHT", Input::MouseRight }
|
||||
};
|
||||
{"MOUSELEFT", Input::MouseLeft},
|
||||
{"MOUSEMIDDLE", Input::MouseMiddle},
|
||||
{"MOUSERIGHT", Input::MouseRight}};
|
||||
|
||||
static elementsN(buttonCodes);
|
||||
|
||||
void
|
||||
inputBindingInit()
|
||||
{
|
||||
void inputBindingInit() {
|
||||
VALUE module = rb_define_module("Input");
|
||||
|
||||
_rb_define_module_function(module, "update", inputUpdate);
|
||||
|
@ -395,12 +356,10 @@ inputBindingInit()
|
|||
_rb_define_module_function(module, "clipboard", inputGetClipboard);
|
||||
_rb_define_module_function(module, "clipboard=", inputSetClipboard);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
if (rgssVer >= 3) {
|
||||
VALUE symHash = rb_hash_new();
|
||||
|
||||
for (size_t i = 0; i < buttonCodesN; ++i)
|
||||
{
|
||||
for (size_t i = 0; i < buttonCodesN; ++i) {
|
||||
ID sym = rb_intern(buttonCodes[i].str);
|
||||
VALUE val = INT2FIX(buttonCodes[i].val);
|
||||
|
||||
|
@ -412,11 +371,8 @@ inputBindingInit()
|
|||
|
||||
rb_iv_set(module, "buttoncodes", symHash);
|
||||
getRbData()->buttoncodeHash = symHash;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < buttonCodesN; ++i)
|
||||
{
|
||||
} else {
|
||||
for (size_t i = 0; i < buttonCodesN; ++i) {
|
||||
ID sym = rb_intern(buttonCodes[i].str);
|
||||
VALUE val = INT2FIX(buttonCodes[i].val);
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
|
||||
if get_option('mri_includes') == ''
|
||||
ver = get_option('mri_version')
|
||||
if ver.version_compare('>1.8') == false
|
||||
add_project_arguments('-DOLD_RUBY', language: ['cpp','objc','objcpp'])
|
||||
endif
|
||||
if ver.version_compare('>=2.7') == true
|
||||
add_project_arguments('-DRUBYCOMPAT=270', language: ['cpp', 'objc', 'objcpp'])
|
||||
if ver.version_compare('<=1.9')
|
||||
global_args += '-DLEGACY_RUBY'
|
||||
endif
|
||||
global_dependencies += dependency('ruby-' + ver)
|
||||
else
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef PREFABI void *(*MINIFFI_FUNC)(unsigned long, unsigned long,
|
|||
// MiniFFI class, also named Win32API on Windows
|
||||
// Uses LoadLibrary/GetProcAddress on Windows, dlopen/dlsym everywhere else
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE_CUSTOMFREE(MiniFFI, SDL_UnloadObject);
|
||||
#else
|
||||
DEF_ALLOCFUNC_CUSTOMFREE(MiniFFI, SDL_UnloadObject);
|
||||
|
@ -308,7 +308,7 @@ RB_METHOD(MiniFFI_call) {
|
|||
|
||||
void MiniFFIBindingInit() {
|
||||
VALUE cMiniFFI = rb_define_class("MiniFFI", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(cMiniFFI, classAllocate<&MiniFFIType>);
|
||||
#else
|
||||
rb_define_alloc_func(cMiniFFI, MiniFFIAllocate);
|
||||
|
|
|
@ -19,20 +19,19 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "plane.h"
|
||||
#include "disposable-binding.h"
|
||||
#include "viewportelement-binding.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
#include "binding-util.h"
|
||||
#include "disposable-binding.h"
|
||||
#include "plane.h"
|
||||
#include "viewportelement-binding.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE(Plane);
|
||||
#else
|
||||
DEF_ALLOCFUNC(Plane);
|
||||
#endif
|
||||
|
||||
RB_METHOD(planeInitialize)
|
||||
{
|
||||
RB_METHOD(planeInitialize) {
|
||||
Plane *p = viewportElementInitialize<Plane>(argc, argv, self);
|
||||
|
||||
setPrivateData(self, p);
|
||||
|
@ -57,29 +56,26 @@ DEF_PROP_I(Plane, BlendType)
|
|||
DEF_PROP_F(Plane, ZoomX)
|
||||
DEF_PROP_F(Plane, ZoomY)
|
||||
|
||||
|
||||
void
|
||||
planeBindingInit()
|
||||
{
|
||||
void planeBindingInit() {
|
||||
VALUE klass = rb_define_class("Plane", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&PlaneType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, PlaneAllocate);
|
||||
#endif
|
||||
|
||||
disposableBindingInit<Plane> (klass);
|
||||
disposableBindingInit<Plane>(klass);
|
||||
viewportElementBindingInit<Plane>(klass);
|
||||
|
||||
_rb_define_method(klass, "initialize", planeInitialize);
|
||||
|
||||
INIT_PROP_BIND( Plane, Bitmap, "bitmap" );
|
||||
INIT_PROP_BIND( Plane, OX, "ox" );
|
||||
INIT_PROP_BIND( Plane, OY, "oy" );
|
||||
INIT_PROP_BIND( Plane, ZoomX, "zoom_x" );
|
||||
INIT_PROP_BIND( Plane, ZoomY, "zoom_y" );
|
||||
INIT_PROP_BIND( Plane, Opacity, "opacity" );
|
||||
INIT_PROP_BIND( Plane, BlendType, "blend_type" );
|
||||
INIT_PROP_BIND( Plane, Color, "color" );
|
||||
INIT_PROP_BIND( Plane, Tone, "tone" );
|
||||
INIT_PROP_BIND(Plane, Bitmap, "bitmap");
|
||||
INIT_PROP_BIND(Plane, OX, "ox");
|
||||
INIT_PROP_BIND(Plane, OY, "oy");
|
||||
INIT_PROP_BIND(Plane, ZoomX, "zoom_x");
|
||||
INIT_PROP_BIND(Plane, ZoomY, "zoom_y");
|
||||
INIT_PROP_BIND(Plane, Opacity, "opacity");
|
||||
INIT_PROP_BIND(Plane, BlendType, "blend_type");
|
||||
INIT_PROP_BIND(Plane, Color, "color");
|
||||
INIT_PROP_BIND(Plane, Tone, "tone");
|
||||
}
|
||||
|
|
|
@ -19,23 +19,22 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "sprite.h"
|
||||
#include "sharedstate.h"
|
||||
#include "binding-types.h"
|
||||
#include "binding-util.h"
|
||||
#include "disposable-binding.h"
|
||||
#include "flashable-binding.h"
|
||||
#include "sceneelement-binding.h"
|
||||
#include "sharedstate.h"
|
||||
#include "sprite.h"
|
||||
#include "viewportelement-binding.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE(Sprite);
|
||||
#else
|
||||
DEF_ALLOCFUNC(Sprite);
|
||||
#endif
|
||||
|
||||
RB_METHOD(spriteInitialize)
|
||||
{
|
||||
RB_METHOD(spriteInitialize) {
|
||||
Sprite *s = viewportElementInitialize<Sprite>(argc, argv, self);
|
||||
|
||||
setPrivateData(self, s);
|
||||
|
@ -74,72 +73,67 @@ DEF_PROP_F(Sprite, WavePhase)
|
|||
|
||||
DEF_PROP_B(Sprite, Mirror)
|
||||
|
||||
RB_METHOD(spriteWidth)
|
||||
{
|
||||
RB_METHOD(spriteWidth) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Sprite *s = getPrivateData<Sprite>(self);
|
||||
|
||||
int value = 0;
|
||||
GUARD_EXC( value = s->getWidth(); )
|
||||
GUARD_EXC(value = s->getWidth();)
|
||||
|
||||
return rb_fix_new(value);
|
||||
}
|
||||
|
||||
RB_METHOD(spriteHeight)
|
||||
{
|
||||
RB_METHOD(spriteHeight) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Sprite *s = getPrivateData<Sprite>(self);
|
||||
|
||||
int value = 0;
|
||||
GUARD_EXC( value = s->getHeight(); )
|
||||
GUARD_EXC(value = s->getHeight();)
|
||||
|
||||
return rb_fix_new(value);
|
||||
}
|
||||
|
||||
void
|
||||
spriteBindingInit()
|
||||
{
|
||||
void spriteBindingInit() {
|
||||
VALUE klass = rb_define_class("Sprite", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&SpriteType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, SpriteAllocate);
|
||||
#endif
|
||||
|
||||
disposableBindingInit <Sprite>(klass);
|
||||
flashableBindingInit <Sprite>(klass);
|
||||
disposableBindingInit<Sprite>(klass);
|
||||
flashableBindingInit<Sprite>(klass);
|
||||
viewportElementBindingInit<Sprite>(klass);
|
||||
|
||||
_rb_define_method(klass, "initialize", spriteInitialize);
|
||||
|
||||
INIT_PROP_BIND( Sprite, Bitmap, "bitmap" );
|
||||
INIT_PROP_BIND( Sprite, SrcRect, "src_rect" );
|
||||
INIT_PROP_BIND( Sprite, X, "x" );
|
||||
INIT_PROP_BIND( Sprite, Y, "y" );
|
||||
INIT_PROP_BIND( Sprite, OX, "ox" );
|
||||
INIT_PROP_BIND( Sprite, OY, "oy" );
|
||||
INIT_PROP_BIND( Sprite, ZoomX, "zoom_x" );
|
||||
INIT_PROP_BIND( Sprite, ZoomY, "zoom_y" );
|
||||
INIT_PROP_BIND( Sprite, Angle, "angle" );
|
||||
INIT_PROP_BIND( Sprite, Mirror, "mirror" );
|
||||
INIT_PROP_BIND( Sprite, BushDepth, "bush_depth" );
|
||||
INIT_PROP_BIND( Sprite, Opacity, "opacity" );
|
||||
INIT_PROP_BIND( Sprite, BlendType, "blend_type" );
|
||||
INIT_PROP_BIND( Sprite, Color, "color" );
|
||||
INIT_PROP_BIND( Sprite, Tone, "tone" );
|
||||
INIT_PROP_BIND(Sprite, Bitmap, "bitmap");
|
||||
INIT_PROP_BIND(Sprite, SrcRect, "src_rect");
|
||||
INIT_PROP_BIND(Sprite, X, "x");
|
||||
INIT_PROP_BIND(Sprite, Y, "y");
|
||||
INIT_PROP_BIND(Sprite, OX, "ox");
|
||||
INIT_PROP_BIND(Sprite, OY, "oy");
|
||||
INIT_PROP_BIND(Sprite, ZoomX, "zoom_x");
|
||||
INIT_PROP_BIND(Sprite, ZoomY, "zoom_y");
|
||||
INIT_PROP_BIND(Sprite, Angle, "angle");
|
||||
INIT_PROP_BIND(Sprite, Mirror, "mirror");
|
||||
INIT_PROP_BIND(Sprite, BushDepth, "bush_depth");
|
||||
INIT_PROP_BIND(Sprite, Opacity, "opacity");
|
||||
INIT_PROP_BIND(Sprite, BlendType, "blend_type");
|
||||
INIT_PROP_BIND(Sprite, Color, "color");
|
||||
INIT_PROP_BIND(Sprite, Tone, "tone");
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
if (rgssVer >= 2) {
|
||||
_rb_define_method(klass, "width", spriteWidth);
|
||||
_rb_define_method(klass, "height", spriteHeight);
|
||||
|
||||
INIT_PROP_BIND( Sprite, BushOpacity, "bush_opacity" );
|
||||
INIT_PROP_BIND(Sprite, BushOpacity, "bush_opacity");
|
||||
|
||||
INIT_PROP_BIND( Sprite, WaveAmp, "wave_amp" );
|
||||
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
|
||||
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
|
||||
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
|
||||
INIT_PROP_BIND(Sprite, WaveAmp, "wave_amp");
|
||||
INIT_PROP_BIND(Sprite, WaveLength, "wave_length");
|
||||
INIT_PROP_BIND(Sprite, WaveSpeed, "wave_speed");
|
||||
INIT_PROP_BIND(Sprite, WavePhase, "wave_phase");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,23 +19,20 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "table.h"
|
||||
#include "binding-util.h"
|
||||
#include "serializable-binding.h"
|
||||
#include "table.h"
|
||||
#include <algorithm>
|
||||
|
||||
static int num2TableSize(VALUE v)
|
||||
{
|
||||
static int num2TableSize(VALUE v) {
|
||||
int i = NUM2INT(v);
|
||||
return std::max(0, i);
|
||||
}
|
||||
|
||||
static void parseArgsTableSizes(int argc, VALUE *argv, int *x, int *y, int *z)
|
||||
{
|
||||
static void parseArgsTableSizes(int argc, VALUE *argv, int *x, int *y, int *z) {
|
||||
*y = *z = 1;
|
||||
|
||||
switch (argc)
|
||||
{
|
||||
switch (argc) {
|
||||
case 3:
|
||||
*z = num2TableSize(argv[2]);
|
||||
/* fall through */
|
||||
|
@ -49,14 +46,13 @@ static void parseArgsTableSizes(int argc, VALUE *argv, int *x, int *y, int *z)
|
|||
rb_error_arity(argc, 1, 3);
|
||||
}
|
||||
}
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE(Table);
|
||||
#else
|
||||
DEF_ALLOCFUNC(Table);
|
||||
#endif
|
||||
|
||||
RB_METHOD(tableInitialize)
|
||||
{
|
||||
RB_METHOD(tableInitialize) {
|
||||
int x, y, z;
|
||||
|
||||
parseArgsTableSizes(argc, argv, &x, &y, &z);
|
||||
|
@ -68,8 +64,7 @@ RB_METHOD(tableInitialize)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(tableResize)
|
||||
{
|
||||
RB_METHOD(tableResize) {
|
||||
Table *t = getPrivateData<Table>(self);
|
||||
|
||||
int x, y, z;
|
||||
|
@ -81,8 +76,7 @@ RB_METHOD(tableResize)
|
|||
}
|
||||
|
||||
#define TABLE_SIZE(d, D) \
|
||||
RB_METHOD(table##D##Size) \
|
||||
{ \
|
||||
RB_METHOD(table##D##Size) { \
|
||||
RB_UNUSED_PARAM \
|
||||
Table *t = getPrivateData<Table>(self); \
|
||||
return INT2NUM(t->d##Size()); \
|
||||
|
@ -92,8 +86,7 @@ TABLE_SIZE(x, X)
|
|||
TABLE_SIZE(y, Y)
|
||||
TABLE_SIZE(z, Z)
|
||||
|
||||
RB_METHOD(tableGetAt)
|
||||
{
|
||||
RB_METHOD(tableGetAt) {
|
||||
Table *t = getPrivateData<Table>(self);
|
||||
|
||||
int x, y, z;
|
||||
|
@ -108,10 +101,8 @@ RB_METHOD(tableGetAt)
|
|||
if (argc > 3)
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
|
||||
if (x < 0 || x >= t->xSize()
|
||||
|| y < 0 || y >= t->ySize()
|
||||
|| z < 0 || z >= t->zSize())
|
||||
{
|
||||
if (x < 0 || x >= t->xSize() || y < 0 || y >= t->ySize() || z < 0 ||
|
||||
z >= t->zSize()) {
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
@ -120,8 +111,7 @@ RB_METHOD(tableGetAt)
|
|||
return INT2FIX(result); /* short always fits in a Fixnum */
|
||||
}
|
||||
|
||||
RB_METHOD(tableSetAt)
|
||||
{
|
||||
RB_METHOD(tableSetAt) {
|
||||
Table *t = getPrivateData<Table>(self);
|
||||
|
||||
int x, y, z, value;
|
||||
|
@ -130,21 +120,20 @@ RB_METHOD(tableSetAt)
|
|||
if (argc < 2)
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
|
||||
switch (argc)
|
||||
{
|
||||
switch (argc) {
|
||||
default:
|
||||
case 2 :
|
||||
case 2:
|
||||
x = NUM2INT(argv[0]);
|
||||
value = NUM2INT(argv[1]);
|
||||
|
||||
break;
|
||||
case 3 :
|
||||
case 3:
|
||||
x = NUM2INT(argv[0]);
|
||||
y = NUM2INT(argv[1]);
|
||||
value = NUM2INT(argv[2]);
|
||||
|
||||
break;
|
||||
case 4 :
|
||||
case 4:
|
||||
x = NUM2INT(argv[0]);
|
||||
y = NUM2INT(argv[1]);
|
||||
z = NUM2INT(argv[2]);
|
||||
|
@ -161,11 +150,9 @@ RB_METHOD(tableSetAt)
|
|||
MARSH_LOAD_FUN(Table)
|
||||
INITCOPY_FUN(Table)
|
||||
|
||||
void
|
||||
tableBindingInit()
|
||||
{
|
||||
void tableBindingInit() {
|
||||
VALUE klass = rb_define_class("Table", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&TableType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, TableAllocate);
|
||||
|
@ -183,5 +170,4 @@ tableBindingInit()
|
|||
_rb_define_method(klass, "zsize", tableZSize);
|
||||
_rb_define_method(klass, "[]", tableGetAt);
|
||||
_rb_define_method(klass, "[]=", tableSetAt);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,23 +19,22 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "tilemap.h"
|
||||
#include "viewport.h"
|
||||
#include "bitmap.h"
|
||||
#include "table.h"
|
||||
#include "tilemap.h"
|
||||
#include "viewport.h"
|
||||
|
||||
#include "disposable-binding.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
#include "binding-util.h"
|
||||
#include "disposable-binding.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE_CUSTOMFREE(TilemapAutotiles, RUBY_TYPED_NEVER_FREE);
|
||||
#else
|
||||
#define TilemapAutotilesType "TilemapAutotiles"
|
||||
#endif
|
||||
|
||||
RB_METHOD(tilemapAutotilesSet)
|
||||
{
|
||||
RB_METHOD(tilemapAutotilesSet) {
|
||||
Tilemap::Autotiles *a = getPrivateData<Tilemap::Autotiles>(self);
|
||||
|
||||
int i;
|
||||
|
@ -53,10 +52,9 @@ RB_METHOD(tilemapAutotilesSet)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(tilemapAutotilesGet)
|
||||
{
|
||||
RB_METHOD(tilemapAutotilesGet) {
|
||||
int i;
|
||||
rb_get_args (argc, argv, "i", &i RB_ARG_END);
|
||||
rb_get_args(argc, argv, "i", &i RB_ARG_END);
|
||||
|
||||
if (i < 0 || i > 6)
|
||||
return Qnil;
|
||||
|
@ -66,14 +64,13 @@ RB_METHOD(tilemapAutotilesGet)
|
|||
return rb_ary_entry(ary, i);
|
||||
}
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE(Tilemap);
|
||||
#else
|
||||
DEF_ALLOCFUNC(Tilemap);
|
||||
#endif
|
||||
|
||||
RB_METHOD(tilemapInitialize)
|
||||
{
|
||||
RB_METHOD(tilemapInitialize) {
|
||||
Tilemap *t;
|
||||
|
||||
/* Get parameters */
|
||||
|
@ -109,8 +106,7 @@ RB_METHOD(tilemapInitialize)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(tilemapGetAutotiles)
|
||||
{
|
||||
RB_METHOD(tilemapGetAutotiles) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
checkDisposed<Tilemap>(self);
|
||||
|
@ -118,8 +114,7 @@ RB_METHOD(tilemapGetAutotiles)
|
|||
return rb_iv_get(self, "autotiles");
|
||||
}
|
||||
|
||||
RB_METHOD(tilemapUpdate)
|
||||
{
|
||||
RB_METHOD(tilemapUpdate) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Tilemap *t = getPrivateData<Tilemap>(self);
|
||||
|
@ -129,8 +124,7 @@ RB_METHOD(tilemapUpdate)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(tilemapGetViewport)
|
||||
{
|
||||
RB_METHOD(tilemapGetViewport) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
checkDisposed<Tilemap>(self);
|
||||
|
@ -148,11 +142,9 @@ DEF_PROP_B(Tilemap, Visible)
|
|||
DEF_PROP_I(Tilemap, OX)
|
||||
DEF_PROP_I(Tilemap, OY)
|
||||
|
||||
void
|
||||
tilemapBindingInit()
|
||||
{
|
||||
void tilemapBindingInit() {
|
||||
VALUE klass = rb_define_class("TilemapAutotiles", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&TilemapAutotilesType>);
|
||||
#endif
|
||||
|
||||
|
@ -160,7 +152,7 @@ tilemapBindingInit()
|
|||
_rb_define_method(klass, "[]", tilemapAutotilesGet);
|
||||
|
||||
klass = rb_define_class("Tilemap", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&TilemapType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, TilemapAllocate);
|
||||
|
@ -174,11 +166,11 @@ tilemapBindingInit()
|
|||
|
||||
_rb_define_method(klass, "viewport", tilemapGetViewport);
|
||||
|
||||
INIT_PROP_BIND( Tilemap, Tileset, "tileset" );
|
||||
INIT_PROP_BIND( Tilemap, MapData, "map_data" );
|
||||
INIT_PROP_BIND( Tilemap, FlashData, "flash_data" );
|
||||
INIT_PROP_BIND( Tilemap, Priorities, "priorities" );
|
||||
INIT_PROP_BIND( Tilemap, Visible, "visible" );
|
||||
INIT_PROP_BIND( Tilemap, OX, "ox" );
|
||||
INIT_PROP_BIND( Tilemap, OY, "oy" );
|
||||
INIT_PROP_BIND(Tilemap, Tileset, "tileset");
|
||||
INIT_PROP_BIND(Tilemap, MapData, "map_data");
|
||||
INIT_PROP_BIND(Tilemap, FlashData, "flash_data");
|
||||
INIT_PROP_BIND(Tilemap, Priorities, "priorities");
|
||||
INIT_PROP_BIND(Tilemap, Visible, "visible");
|
||||
INIT_PROP_BIND(Tilemap, OX, "ox");
|
||||
INIT_PROP_BIND(Tilemap, OY, "oy");
|
||||
}
|
||||
|
|
|
@ -19,17 +19,17 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "bitmap.h"
|
||||
#include "sharedstate.h"
|
||||
#include "table.h"
|
||||
#include "tilemapvx.h"
|
||||
#include "viewport.h"
|
||||
#include "bitmap.h"
|
||||
#include "table.h"
|
||||
#include "sharedstate.h"
|
||||
|
||||
#include "disposable-binding.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
#include "binding-util.h"
|
||||
#include "disposable-binding.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE_CUSTOMNAME(TilemapVX, "Tilemap");
|
||||
|
||||
DEF_TYPE_CUSTOMFREE(BitmapArray, RUBY_TYPED_NEVER_FREE);
|
||||
|
@ -38,8 +38,7 @@ DEF_ALLOCFUNC(TilemapVX);
|
|||
#define BitmapArrayType "BitmapArray"
|
||||
#endif
|
||||
|
||||
RB_METHOD(tilemapVXInitialize)
|
||||
{
|
||||
RB_METHOD(tilemapVXInitialize) {
|
||||
TilemapVX *t;
|
||||
|
||||
/* Get parameters */
|
||||
|
@ -76,8 +75,7 @@ RB_METHOD(tilemapVXInitialize)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(tilemapVXGetBitmapArray)
|
||||
{
|
||||
RB_METHOD(tilemapVXGetBitmapArray) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
checkDisposed<TilemapVX>(self);
|
||||
|
@ -85,8 +83,7 @@ RB_METHOD(tilemapVXGetBitmapArray)
|
|||
return rb_iv_get(self, "bitmap_array");
|
||||
}
|
||||
|
||||
RB_METHOD(tilemapVXUpdate)
|
||||
{
|
||||
RB_METHOD(tilemapVXUpdate) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
TilemapVX *t = getPrivateData<TilemapVX>(self);
|
||||
|
@ -106,8 +103,7 @@ DEF_PROP_B(TilemapVX, Visible)
|
|||
DEF_PROP_I(TilemapVX, OX)
|
||||
DEF_PROP_I(TilemapVX, OY)
|
||||
|
||||
RB_METHOD(tilemapVXBitmapsSet)
|
||||
{
|
||||
RB_METHOD(tilemapVXBitmapsSet) {
|
||||
TilemapVX::BitmapArray *a = getPrivateData<TilemapVX::BitmapArray>(self);
|
||||
|
||||
int i;
|
||||
|
@ -125,10 +121,9 @@ RB_METHOD(tilemapVXBitmapsSet)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(tilemapVXBitmapsGet)
|
||||
{
|
||||
RB_METHOD(tilemapVXBitmapsGet) {
|
||||
int i;
|
||||
rb_get_args (argc, argv, "i", &i RB_ARG_END);
|
||||
rb_get_args(argc, argv, "i", &i RB_ARG_END);
|
||||
|
||||
if (i < 0 || i > 8)
|
||||
return Qnil;
|
||||
|
@ -138,11 +133,9 @@ RB_METHOD(tilemapVXBitmapsGet)
|
|||
return rb_ary_entry(ary, i);
|
||||
}
|
||||
|
||||
void
|
||||
tilemapVXBindingInit()
|
||||
{
|
||||
void tilemapVXBindingInit() {
|
||||
VALUE klass = rb_define_class("Tilemap", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&TilemapVXType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, TilemapVXAllocate);
|
||||
|
@ -154,24 +147,21 @@ tilemapVXBindingInit()
|
|||
_rb_define_method(klass, "bitmaps", tilemapVXGetBitmapArray);
|
||||
_rb_define_method(klass, "update", tilemapVXUpdate);
|
||||
|
||||
INIT_PROP_BIND( TilemapVX, Viewport, "viewport" );
|
||||
INIT_PROP_BIND( TilemapVX, MapData, "map_data" );
|
||||
INIT_PROP_BIND( TilemapVX, FlashData, "flash_data" );
|
||||
INIT_PROP_BIND( TilemapVX, Visible, "visible" );
|
||||
INIT_PROP_BIND( TilemapVX, OX, "ox" );
|
||||
INIT_PROP_BIND( TilemapVX, OY, "oy" );
|
||||
INIT_PROP_BIND(TilemapVX, Viewport, "viewport");
|
||||
INIT_PROP_BIND(TilemapVX, MapData, "map_data");
|
||||
INIT_PROP_BIND(TilemapVX, FlashData, "flash_data");
|
||||
INIT_PROP_BIND(TilemapVX, Visible, "visible");
|
||||
INIT_PROP_BIND(TilemapVX, OX, "ox");
|
||||
INIT_PROP_BIND(TilemapVX, OY, "oy");
|
||||
|
||||
if (rgssVer == 3)
|
||||
{
|
||||
INIT_PROP_BIND( TilemapVX, Flags, "flags" );
|
||||
}
|
||||
else
|
||||
{
|
||||
INIT_PROP_BIND( TilemapVX, Flags, "passages" );
|
||||
if (rgssVer == 3) {
|
||||
INIT_PROP_BIND(TilemapVX, Flags, "flags");
|
||||
} else {
|
||||
INIT_PROP_BIND(TilemapVX, Flags, "passages");
|
||||
}
|
||||
|
||||
klass = rb_define_class_under(klass, "BitmapArray", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&BitmapArrayType>);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -19,30 +19,26 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "viewport.h"
|
||||
#include "sharedstate.h"
|
||||
#include "binding-types.h"
|
||||
#include "binding-util.h"
|
||||
#include "disposable-binding.h"
|
||||
#include "flashable-binding.h"
|
||||
#include "sceneelement-binding.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
#include "sharedstate.h"
|
||||
#include "viewport.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE(Viewport);
|
||||
#else
|
||||
DEF_ALLOCFUNC(Viewport);
|
||||
#endif
|
||||
|
||||
RB_METHOD(viewportInitialize)
|
||||
{
|
||||
RB_METHOD(viewportInitialize) {
|
||||
Viewport *v;
|
||||
|
||||
if (argc == 0 && rgssVer >= 3)
|
||||
{
|
||||
if (argc == 0 && rgssVer >= 3) {
|
||||
v = new Viewport();
|
||||
}
|
||||
else if (argc == 1)
|
||||
{
|
||||
} else if (argc == 1) {
|
||||
/* The rect arg is only used to init the viewport,
|
||||
* and does NOT replace its 'rect' property */
|
||||
VALUE rectObj;
|
||||
|
@ -53,9 +49,7 @@ RB_METHOD(viewportInitialize)
|
|||
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
|
||||
|
||||
v = new Viewport(rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int x, y, width, height;
|
||||
|
||||
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
|
||||
|
@ -87,27 +81,23 @@ DEF_PROP_OBJ_VAL(Viewport, Tone, Tone, "tone")
|
|||
DEF_PROP_I(Viewport, OX)
|
||||
DEF_PROP_I(Viewport, OY)
|
||||
|
||||
|
||||
void
|
||||
viewportBindingInit()
|
||||
{
|
||||
void viewportBindingInit() {
|
||||
VALUE klass = rb_define_class("Viewport", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&ViewportType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, ViewportAllocate);
|
||||
#endif
|
||||
|
||||
disposableBindingInit <Viewport>(klass);
|
||||
flashableBindingInit <Viewport>(klass);
|
||||
disposableBindingInit<Viewport>(klass);
|
||||
flashableBindingInit<Viewport>(klass);
|
||||
sceneElementBindingInit<Viewport>(klass);
|
||||
|
||||
_rb_define_method(klass, "initialize", viewportInitialize);
|
||||
|
||||
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" );
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -19,19 +19,18 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "window.h"
|
||||
#include "binding-util.h"
|
||||
#include "disposable-binding.h"
|
||||
#include "viewportelement-binding.h"
|
||||
#include "binding-util.h"
|
||||
#include "window.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE(Window);
|
||||
#else
|
||||
DEF_ALLOCFUNC(Window);
|
||||
#endif
|
||||
|
||||
RB_METHOD(windowInitialize)
|
||||
{
|
||||
RB_METHOD(windowInitialize) {
|
||||
Window *w = viewportElementInitialize<Window>(argc, argv, self);
|
||||
|
||||
setPrivateData(self, w);
|
||||
|
@ -43,8 +42,7 @@ RB_METHOD(windowInitialize)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(windowUpdate)
|
||||
{
|
||||
RB_METHOD(windowUpdate) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Window *w = getPrivateData<Window>(self);
|
||||
|
@ -72,37 +70,33 @@ DEF_PROP_I(Window, Opacity)
|
|||
DEF_PROP_I(Window, BackOpacity)
|
||||
DEF_PROP_I(Window, ContentsOpacity)
|
||||
|
||||
|
||||
void
|
||||
windowBindingInit()
|
||||
{
|
||||
void windowBindingInit() {
|
||||
VALUE klass = rb_define_class("Window", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&WindowType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, WindowAllocate);
|
||||
#endif
|
||||
|
||||
|
||||
disposableBindingInit <Window>(klass);
|
||||
disposableBindingInit<Window>(klass);
|
||||
viewportElementBindingInit<Window>(klass);
|
||||
|
||||
_rb_define_method(klass, "initialize", windowInitialize);
|
||||
_rb_define_method(klass, "update", windowUpdate);
|
||||
|
||||
INIT_PROP_BIND( Window, Windowskin, "windowskin" );
|
||||
INIT_PROP_BIND( Window, Contents, "contents" );
|
||||
INIT_PROP_BIND( Window, Stretch, "stretch" );
|
||||
INIT_PROP_BIND( Window, CursorRect, "cursor_rect" );
|
||||
INIT_PROP_BIND( Window, Active, "active" );
|
||||
INIT_PROP_BIND( Window, Pause, "pause" );
|
||||
INIT_PROP_BIND( Window, X, "x" );
|
||||
INIT_PROP_BIND( Window, Y, "y" );
|
||||
INIT_PROP_BIND( Window, Width, "width" );
|
||||
INIT_PROP_BIND( Window, Height, "height" );
|
||||
INIT_PROP_BIND( Window, OX, "ox" );
|
||||
INIT_PROP_BIND( Window, OY, "oy" );
|
||||
INIT_PROP_BIND( Window, Opacity, "opacity" );
|
||||
INIT_PROP_BIND( Window, BackOpacity, "back_opacity" );
|
||||
INIT_PROP_BIND( Window, ContentsOpacity, "contents_opacity" );
|
||||
INIT_PROP_BIND(Window, Windowskin, "windowskin");
|
||||
INIT_PROP_BIND(Window, Contents, "contents");
|
||||
INIT_PROP_BIND(Window, Stretch, "stretch");
|
||||
INIT_PROP_BIND(Window, CursorRect, "cursor_rect");
|
||||
INIT_PROP_BIND(Window, Active, "active");
|
||||
INIT_PROP_BIND(Window, Pause, "pause");
|
||||
INIT_PROP_BIND(Window, X, "x");
|
||||
INIT_PROP_BIND(Window, Y, "y");
|
||||
INIT_PROP_BIND(Window, Width, "width");
|
||||
INIT_PROP_BIND(Window, Height, "height");
|
||||
INIT_PROP_BIND(Window, OX, "ox");
|
||||
INIT_PROP_BIND(Window, OY, "oy");
|
||||
INIT_PROP_BIND(Window, Opacity, "opacity");
|
||||
INIT_PROP_BIND(Window, BackOpacity, "back_opacity");
|
||||
INIT_PROP_BIND(Window, ContentsOpacity, "contents_opacity");
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "windowvx.h"
|
||||
#include "binding-util.h"
|
||||
#include "disposable-binding.h"
|
||||
#include "viewportelement-binding.h"
|
||||
#include "binding-util.h"
|
||||
#include "windowvx.h"
|
||||
|
||||
#include "bitmap.h"
|
||||
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
DEF_TYPE_CUSTOMNAME(WindowVX, "Window");
|
||||
#else
|
||||
DEF_ALLOCFUNC(WindowVX);
|
||||
|
@ -34,12 +34,10 @@ DEF_ALLOCFUNC(WindowVX);
|
|||
|
||||
void bitmapInitProps(Bitmap *b, VALUE self);
|
||||
|
||||
RB_METHOD(windowVXInitialize)
|
||||
{
|
||||
RB_METHOD(windowVXInitialize) {
|
||||
WindowVX *w;
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
if (rgssVer >= 3) {
|
||||
int x, y, width, height;
|
||||
x = y = width = height = 0;
|
||||
|
||||
|
@ -47,9 +45,7 @@ RB_METHOD(windowVXInitialize)
|
|||
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
|
||||
|
||||
w = new WindowVX(x, y, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
w = viewportElementInitialize<WindowVX>(argc, argv, self);
|
||||
}
|
||||
|
||||
|
@ -70,8 +66,7 @@ RB_METHOD(windowVXInitialize)
|
|||
return self;
|
||||
}
|
||||
|
||||
RB_METHOD(windowVXUpdate)
|
||||
{
|
||||
RB_METHOD(windowVXUpdate) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
WindowVX *w = getPrivateData<WindowVX>(self);
|
||||
|
@ -81,8 +76,7 @@ RB_METHOD(windowVXUpdate)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(windowVXMove)
|
||||
{
|
||||
RB_METHOD(windowVXMove) {
|
||||
WindowVX *w = getPrivateData<WindowVX>(self);
|
||||
|
||||
int x, y, width, height;
|
||||
|
@ -93,8 +87,7 @@ RB_METHOD(windowVXMove)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(windowVXIsOpen)
|
||||
{
|
||||
RB_METHOD(windowVXIsOpen) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
WindowVX *w = getPrivateData<WindowVX>(self);
|
||||
|
@ -102,8 +95,7 @@ RB_METHOD(windowVXIsOpen)
|
|||
return rb_bool_new(w->isOpen());
|
||||
}
|
||||
|
||||
RB_METHOD(windowVXIsClosed)
|
||||
{
|
||||
RB_METHOD(windowVXIsClosed) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
WindowVX *w = getPrivateData<WindowVX>(self);
|
||||
|
@ -134,47 +126,44 @@ DEF_PROP_B(WindowVX, Active)
|
|||
DEF_PROP_B(WindowVX, ArrowsVisible)
|
||||
DEF_PROP_B(WindowVX, Pause)
|
||||
|
||||
void
|
||||
windowVXBindingInit()
|
||||
{
|
||||
void windowVXBindingInit() {
|
||||
VALUE klass = rb_define_class("Window", rb_cObject);
|
||||
#ifndef OLD_RUBY
|
||||
#if RAPI_FULL > 187
|
||||
rb_define_alloc_func(klass, classAllocate<&WindowVXType>);
|
||||
#else
|
||||
rb_define_alloc_func(klass, WindowVXAllocate);
|
||||
#endif
|
||||
|
||||
disposableBindingInit <WindowVX>(klass);
|
||||
disposableBindingInit<WindowVX>(klass);
|
||||
viewportElementBindingInit<WindowVX>(klass);
|
||||
|
||||
_rb_define_method(klass, "initialize", windowVXInitialize);
|
||||
_rb_define_method(klass, "update", windowVXUpdate);
|
||||
|
||||
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, 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, 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, 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, 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, Opacity, "opacity");
|
||||
INIT_PROP_BIND(WindowVX, BackOpacity, "back_opacity");
|
||||
INIT_PROP_BIND(WindowVX, ContentsOpacity, "contents_opacity");
|
||||
INIT_PROP_BIND(WindowVX, Openness, "openness");
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
if (rgssVer >= 3) {
|
||||
_rb_define_method(klass, "move", windowVXMove);
|
||||
_rb_define_method(klass, "open?", windowVXIsOpen);
|
||||
_rb_define_method(klass, "close?", windowVXIsClosed);
|
||||
|
||||
INIT_PROP_BIND( WindowVX, ArrowsVisible, "arrows_visible" );
|
||||
INIT_PROP_BIND( WindowVX, Padding, "padding" );
|
||||
INIT_PROP_BIND( WindowVX, PaddingBottom, "padding_bottom" );
|
||||
INIT_PROP_BIND( WindowVX, Tone, "tone" );
|
||||
INIT_PROP_BIND(WindowVX, ArrowsVisible, "arrows_visible");
|
||||
INIT_PROP_BIND(WindowVX, Padding, "padding");
|
||||
INIT_PROP_BIND(WindowVX, PaddingBottom, "padding_bottom");
|
||||
INIT_PROP_BIND(WindowVX, Tone, "tone");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue