Merge separate RGSS version build configs into one

Setup active RGSS version at runtime. Desired version can be
specified via config, or as default, auto detected from the game
files. This removes the need to build specifically for each
version, which should help packaging a lot.

This also greatly reduces the danger of introducing code that
wouldn't compile on all RGSS version paths (as certain code paths
were completely ifdef'd out).

This can be optimized more, eg. not compiling shaders that aren't
needed in the active version.
This commit is contained in:
Jonas Kulla 2014-08-28 23:11:10 +02:00
parent b1981055e1
commit 55f1542c76
41 changed files with 460 additions and 465 deletions

View file

@ -32,7 +32,10 @@
int volume = 100; \
int pitch = 100; \
double pos = 0.0; \
rb_get_args(argc, argv, "z|iif", &filename, &volume, &pitch, &pos RB_ARG_END); \
if (rgssVer >= 3) \
rb_get_args(argc, argv, "z|iif", &filename, &volume, &pitch, &pos RB_ARG_END); \
else \
rb_get_args(argc, argv, "z|ii", &filename, &volume, &pitch RB_ARG_END); \
GUARD_EXC( shState->audio().entity##Play(filename, volume, pitch, pos); ) \
return Qnil; \
} \
@ -83,13 +86,8 @@ RB_METHOD(audio_##entity##Fade) \
return rb_float_new(shState->audio().entity##Pos()); \
}
#ifdef RGSS3
DEF_PLAY_STOP_POS( bgm )
DEF_PLAY_STOP_POS( bgs )
#else
DEF_PLAY_STOP( bgm )
DEF_PLAY_STOP( bgs )
#endif
DEF_PLAY_STOP( me )
@ -124,10 +122,11 @@ audioBindingInit()
BIND_PLAY_STOP_FADE( bgs );
BIND_PLAY_STOP_FADE( me );
#ifdef RGSS3
if (rgssVer >= 3)
{
BIND_POS( bgm );
BIND_POS( bgs );
#endif
}
BIND_PLAY_STOP( se )
}

View file

@ -30,13 +30,15 @@
#include <ruby.h>
#include <ruby/encoding.h>
#include <assert.h>
#include <string>
#include <zlib.h>
#include <SDL_filesystem.h>
extern const char module_rpg[];
extern const char module_rpg1[];
extern const char module_rpg2[];
extern const char module_rpg3[];
static void mriBindingExecute();
static void mriBindingTerminate();
@ -58,11 +60,8 @@ void viewportBindingInit();
void planeBindingInit();
void windowBindingInit();
void tilemapBindingInit();
#ifdef RGSS2
void windowVXBindingInit();
void tilemapVXBindingInit();
#endif
void inputBindingInit();
void audioBindingInit();
@ -75,11 +74,8 @@ RB_METHOD(mriP);
RB_METHOD(mriDataDirectory);
RB_METHOD(mkxpPuts);
#ifdef RGSS3
RB_METHOD(mriRgssMain);
#else
RB_METHOD(_kernelCaller);
#endif
static void mriBindingInit()
{
@ -91,13 +87,16 @@ static void mriBindingInit()
viewportBindingInit();
planeBindingInit();
#ifdef RGSS2
windowVXBindingInit();
tilemapVXBindingInit();
#else
windowBindingInit();
tilemapBindingInit();
#endif
if (rgssVer == 1)
{
windowBindingInit();
tilemapBindingInit();
}
else
{
windowVXBindingInit();
tilemapVXBindingInit();
}
inputBindingInit();
audioBindingInit();
@ -105,27 +104,35 @@ static void mriBindingInit()
fileIntBindingInit();
#ifdef RGSS3
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
if (rgssVer >= 3)
{
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
_rb_define_module_function(rb_mKernel, "msgbox", mriPrint);
_rb_define_module_function(rb_mKernel, "msgbox_p", mriP);
#else
_rb_define_module_function(rb_mKernel, "print", mriPrint);
_rb_define_module_function(rb_mKernel, "p", mriP);
#endif
_rb_define_module_function(rb_mKernel, "msgbox", mriPrint);
_rb_define_module_function(rb_mKernel, "msgbox_p", mriP);
}
else
{
_rb_define_module_function(rb_mKernel, "print", mriPrint);
_rb_define_module_function(rb_mKernel, "p", mriP);
rb_eval_string(module_rpg);
rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller");
_rb_define_module_function(rb_mKernel, "caller", _kernelCaller);
}
if (rgssVer == 1)
rb_eval_string(module_rpg1);
else if (rgssVer == 2)
rb_eval_string(module_rpg2);
else if (rgssVer == 3)
rb_eval_string(module_rpg3);
else
assert(!"unreachable");
VALUE mod = rb_define_module("System");
_rb_define_module_function(mod, "data_directory", mriDataDirectory);
_rb_define_module_function(mod, "puts", mkxpPuts);
#ifndef RGSS3
rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller");
_rb_define_module_function(rb_mKernel, "caller", _kernelCaller);
#endif
rb_gv_set("MKXP", Qtrue);
}
@ -200,8 +207,6 @@ RB_METHOD(mriDataDirectory)
return pathStr;
}
#ifdef RGSS3
RB_METHOD(mriRgssMain)
{
RB_UNUSED_PARAM;
@ -212,8 +217,6 @@ RB_METHOD(mriRgssMain)
return Qnil;
}
#else
RB_METHOD(_kernelCaller)
{
RB_UNUSED_PARAM;
@ -246,8 +249,6 @@ RB_METHOD(_kernelCaller)
return trace;
}
#endif
static VALUE newStringUTF8(const char *string, long length)
{
return rb_enc_str_new(string, length, rb_utf8_encoding());
@ -287,12 +288,6 @@ static void runCustomScript(const std::string &filename)
VALUE kernelLoadDataInt(const char *filename);
#ifdef RGSS3
#define RGSS_SECTION_STR "{%04ld}"
#else
#define RGSS_SECTION_STR "Section%03ld"
#endif
static void runRMXPScripts()
{
const Config &conf = shState->rtData().config;
@ -391,7 +386,8 @@ static void runRMXPScripts()
else
{
char buf[32];
int len = snprintf(buf, sizeof(buf), RGSS_SECTION_STR, i);
const char *format = rgssVer >= 3 ? "{%04ld}" : "Section%03ld";
int len = snprintf(buf, sizeof(buf), format, i);
fname = newStringUTF8(buf, len);
}

View file

@ -47,10 +47,8 @@ struct RbData
{
VALUE exc[RbExceptionsMax];
#ifdef RGSS3
/* Input module */
/* Input module (RGSS3) */
VALUE buttoncodeHash;
#endif
RbData();
~RbData();

View file

@ -22,6 +22,7 @@
#include "bitmap.h"
#include "font.h"
#include "exception.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "binding-util.h"
#include "binding-types.h"
@ -252,17 +253,20 @@ RB_METHOD(bitmapDrawText)
VALUE rectObj;
Rect *rect;
#ifdef RGSS2
VALUE strObj;
rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END);
if (rgssVer >= 2)
{
VALUE strObj;
rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END);
if (rb_type(strObj) != RUBY_T_STRING)
strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
if (rb_type(strObj) != RUBY_T_STRING)
strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
str = RSTRING_PTR(strObj);
#else
rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END);
#endif
str = RSTRING_PTR(strObj);
}
else
{
rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END);
}
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
@ -272,17 +276,20 @@ RB_METHOD(bitmapDrawText)
{
int x, y, width, height;
#ifdef RGSS2
VALUE strObj;
rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END);
if (rgssVer >= 2)
{
VALUE strObj;
rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END);
if (rb_type(strObj) != RUBY_T_STRING)
strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
if (rb_type(strObj) != RUBY_T_STRING)
strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
str = RSTRING_PTR(strObj);
#else
rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END);
#endif
str = RSTRING_PTR(strObj);
}
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); );
}
@ -296,17 +303,20 @@ RB_METHOD(bitmapTextSize)
const char *str;
#ifdef RGSS2
VALUE strObj;
rb_get_args(argc, argv, "o", &strObj RB_ARG_END);
if (rgssVer >= 2)
{
VALUE strObj;
rb_get_args(argc, argv, "o", &strObj RB_ARG_END);
if (rb_type(strObj) != RUBY_T_STRING)
strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
if (rb_type(strObj) != RUBY_T_STRING)
strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
str = RSTRING_PTR(strObj);
#else
rb_get_args(argc, argv, "z", &str RB_ARG_END);
#endif
str = RSTRING_PTR(strObj);
}
else
{
rb_get_args(argc, argv, "z", &str RB_ARG_END);
}
IntRect value;
GUARD_EXC( value = b->textSize(str); );
@ -318,8 +328,6 @@ RB_METHOD(bitmapTextSize)
DEF_PROP_OBJ(Bitmap, Font, Font, "font")
#ifdef RGSS2
RB_METHOD(bitmapGradientFillRect)
{
Bitmap *b = getPrivateData<Bitmap>(self);
@ -408,8 +416,6 @@ RB_METHOD(bitmapRadialBlur)
return Qnil;
}
#endif
// FIXME: This isn't entire correct as the cloned bitmap
// does not get a cloned version of the original bitmap's 'font'
// attribute (the internal font attrb is the default one, whereas
@ -444,12 +450,13 @@ bitmapBindingInit()
_rb_define_method(klass, "draw_text", bitmapDrawText);
_rb_define_method(klass, "text_size", bitmapTextSize);
#ifdef RGSS2
if (rgssVer >= 2)
{
_rb_define_method(klass, "gradient_fill_rect", bitmapGradientFillRect);
_rb_define_method(klass, "clear_rect", bitmapClearRect);
_rb_define_method(klass, "blur", bitmapBlur);
_rb_define_method(klass, "radial_blur", bitmapRadialBlur);
#endif
}
INIT_PROP_BIND(Bitmap, Font, "font");
}

View file

@ -61,10 +61,11 @@ RB_METHOD(fontInitialize)
f->setColor(new Color(*f->getColor()));
wrapProperty(self, f->getColor(), "color", ColorType);
#ifdef RGSS3
if (rgssVer >= 3)
{
f->setOutColor(new Color(*f->getOutColor()));
wrapProperty(self, f->getOutColor(), "out_color", ColorType);
#endif
}
if (NIL_P(name))
name = rb_iv_get(rb_obj_class(self), "default_name");
@ -92,10 +93,11 @@ RB_METHOD(fontInitializeCopy)
f->setColor(new Color(*f->getColor()));
wrapProperty(self, f->getColor(), "color", ColorType);
#ifdef RGSS3
if (rgssVer >= 3)
{
f->setOutColor(new Color(*f->getOutColor()));
wrapProperty(self, f->getOutColor(), "out_color", ColorType);
#endif
}
return self;
}
@ -166,16 +168,10 @@ RB_METHOD(FontSetName)
DEF_PROP_I(Font, Size)
DEF_PROP_B(Font, Bold)
DEF_PROP_B(Font, Italic)
DEF_PROP_OBJ(Font, Color, Color, "color")
#ifdef RGSS2
DEF_PROP_B(Font, Shadow)
#endif
#ifdef RGSS3
DEF_PROP_B(Font, Outline)
DEF_PROP_OBJ(Font, Color, Color, "color")
DEF_PROP_OBJ(Font, Color, OutColor, "out_color")
#endif
#define DEF_KLASS_PROP(Klass, type, PropName, param_t_s, value_fun) \
RB_METHOD(Klass##Get##PropName) \
@ -195,12 +191,7 @@ DEF_PROP_OBJ(Font, Color, OutColor, "out_color")
DEF_KLASS_PROP(Font, int, DefaultSize, "i", rb_fix_new)
DEF_KLASS_PROP(Font, bool, DefaultBold, "b", rb_bool_new)
DEF_KLASS_PROP(Font, bool, DefaultItalic, "b", rb_bool_new)
#ifdef RGSS2
DEF_KLASS_PROP(Font, bool, DefaultShadow, "b", rb_bool_new)
#endif
#ifdef RGSS3
DEF_KLASS_PROP(Font, bool, DefaultOutline, "b", rb_bool_new)
RB_METHOD(FontGetDefaultOutColor)
@ -221,7 +212,6 @@ RB_METHOD(FontSetDefaultOutColor)
return colorObj;
}
#endif
RB_METHOD(FontGetDefaultName)
{
@ -285,14 +275,16 @@ fontBindingInit()
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
#ifdef RGSS2
if (rgssVer >= 2)
{
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
#endif
}
#ifdef RGSS3
if (rgssVer >= 3)
{
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
#endif
}
rb_define_class_method(klass, "exist?", fontDoesExist);
@ -305,12 +297,14 @@ fontBindingInit()
INIT_PROP_BIND(Font, Italic, "italic");
INIT_PROP_BIND(Font, Color, "color");
#ifdef RGSS2
if (rgssVer >= 2)
{
INIT_PROP_BIND(Font, Shadow, "shadow");
#endif
}
#ifdef RGSS3
if (rgssVer >= 3)
{
INIT_PROP_BIND(Font, Outline, "outline");
INIT_PROP_BIND(Font, OutColor, "out_color");
#endif
}
}

View file

@ -97,11 +97,6 @@ RB_METHOD(graphicsFrameReset)
return rb_bool_new(value); \
}
DEF_GRA_PROP_I(FrameRate)
DEF_GRA_PROP_I(FrameCount)
#ifdef RGSS2
RB_METHOD(graphicsWidth)
{
RB_UNUSED_PARAM;
@ -179,10 +174,10 @@ RB_METHOD(graphicsResizeScreen)
return Qnil;
}
DEF_GRA_PROP_I(FrameRate)
DEF_GRA_PROP_I(FrameCount)
DEF_GRA_PROP_I(Brightness)
#endif
DEF_GRA_PROP_B(Fullscreen)
DEF_GRA_PROP_B(ShowCursor)
@ -204,7 +199,8 @@ void graphicsBindingInit()
INIT_GRA_PROP_BIND( FrameRate, "frame_rate" );
INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
#ifdef RGSS2
if (rgssVer >= 2)
{
_rb_define_module_function(module, "width", graphicsWidth);
_rb_define_module_function(module, "height", graphicsHeight);
_rb_define_module_function(module, "wait", graphicsWait);
@ -214,7 +210,7 @@ void graphicsBindingInit()
_rb_define_module_function(module, "resize_screen", graphicsResizeScreen);
INIT_GRA_PROP_BIND( Brightness, "brightness" );
#endif
}
INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" );
INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );

View file

@ -38,15 +38,18 @@ static int getButtonArg(int argc, VALUE *argv)
{
int num;
#ifdef RGSS3
ID sym;
rb_get_args(argc, argv, "n", &sym RB_ARG_END);
if (rgssVer >= 3)
{
ID sym;
rb_get_args(argc, argv, "n", &sym RB_ARG_END);
VALUE symHash = getRbData()->buttoncodeHash;
num = FIX2INT(rb_hash_lookup2(symHash, ID2SYM(sym), INT2FIX(Input::None)));
#else
rb_get_args(argc, argv, "i", &num RB_ARG_END);
#endif
VALUE symHash = getRbData()->buttoncodeHash;
num = FIX2INT(rb_hash_lookup2(symHash, ID2SYM(sym), INT2FIX(Input::None)));
}
else
{
rb_get_args(argc, argv, "i", &num RB_ARG_END);
}
return num;
}
@ -161,29 +164,32 @@ inputBindingInit()
_rb_define_module_function(module, "mouse_x", inputMouseX);
_rb_define_module_function(module, "mouse_y", inputMouseY);
#ifndef RGSS3
for (size_t i = 0; i < buttonCodesN; ++i)
if (rgssVer >= 3)
{
ID sym = rb_intern(buttonCodes[i].str);
VALUE val = INT2FIX(buttonCodes[i].val);
VALUE symHash = rb_hash_new();
rb_const_set(module, sym, val);
for (size_t i = 0; i < buttonCodesN; ++i)
{
ID sym = rb_intern(buttonCodes[i].str);
VALUE val = INT2FIX(buttonCodes[i].val);
/* In RGSS3 all Input::XYZ constants are equal to :XYZ symbols,
* to be compatible with the previous convention */
rb_const_set(module, sym, ID2SYM(sym));
rb_hash_aset(symHash, ID2SYM(sym), val);
}
rb_iv_set(module, "buttoncodes", symHash);
getRbData()->buttoncodeHash = symHash;
}
#else
VALUE symHash = rb_hash_new();
for (size_t i = 0; i < buttonCodesN; ++i)
else
{
ID sym = rb_intern(buttonCodes[i].str);
VALUE val = INT2FIX(buttonCodes[i].val);
for (size_t i = 0; i < buttonCodesN; ++i)
{
ID sym = rb_intern(buttonCodes[i].str);
VALUE val = INT2FIX(buttonCodes[i].val);
/* In RGSS3 all Input::XYZ constants are equal to :XYZ symbols,
* to be compatible with the previous convention */
rb_const_set(module, sym, ID2SYM(sym));
rb_hash_aset(symHash, ID2SYM(sym), val);
rb_const_set(module, sym, val);
}
}
rb_iv_set(module, "buttoncodes", symHash);
getRbData()->buttoncodeHash = symHash;
#endif
}

View file

@ -1,8 +1,4 @@
#ifdef RGSS3
# include "module_rpg3.rb.xxd"
#elif RGSS2
# include "module_rpg1.rb.xxd"
# include "module_rpg2.rb.xxd"
#else
# include "module_rpg.rb.xxd"
#endif
# include "module_rpg3.rb.xxd"

View file

@ -1,4 +1,4 @@
extern const char module_rpg[] = {
extern const char module_rpg1[] = {
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x52, 0x50, 0x47, 0x0a, 0x20, 0x20, 0x6d, 0x6f, 0x64,
0x75, 0x6c, 0x65, 0x20, 0x43, 0x61, 0x63, 0x68, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x63,
0x61, 0x63, 0x68, 0x65, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65,
@ -2404,4 +2404,4 @@ extern const char module_rpg[] = {
0x74, 0x72, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x20, 0x3a, 0x70, 0x69, 0x74,
0x63, 0x68, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x00
};
extern const unsigned int module_rpg_len = 38461;
extern const unsigned int module_rpg1_len = 38461;

View file

@ -1,4 +1,4 @@
extern const char module_rpg[] = {
extern const char module_rpg2[] = {
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x52, 0x50, 0x47, 0x0a, 0x20, 0x20, 0x63, 0x6c, 0x61,
0x73, 0x73, 0x20, 0x4d, 0x61, 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x66, 0x20, 0x69,
0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x28, 0x77, 0x69, 0x64, 0x74, 0x68, 0x2c,
@ -1441,4 +1441,4 @@ extern const char module_rpg[] = {
0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65,
0x6e, 0x64, 0x0a, 0x00
};
extern const unsigned int module_rpg_len = 23043;
extern const unsigned int module_rpg2_len = 23043;

View file

@ -1,4 +1,4 @@
extern const char module_rpg[] = {
extern const char module_rpg3[] = {
0x0a, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x52, 0x50, 0x47, 0x0a, 0x20, 0x20, 0x63, 0x6c,
0x61, 0x73, 0x73, 0x20, 0x4d, 0x61, 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6c, 0x61, 0x73,
0x73, 0x20, 0x45, 0x6e, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x0a, 0x20, 0x20, 0x20, 0x20,
@ -1401,4 +1401,4 @@ extern const char module_rpg[] = {
0x65, 0x5f, 0x73, 0x74, 0x6f, 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20,
0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x00
};
extern const unsigned int module_rpg_len = 22410;
extern const unsigned int module_rpg3_len = 22410;

View file

@ -20,6 +20,7 @@
*/
#include "sprite.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "flashable-binding.h"
#include "sceneelement-binding.h"
@ -60,15 +61,17 @@ DEF_PROP_I(Sprite, OY)
DEF_PROP_I(Sprite, BushDepth)
DEF_PROP_I(Sprite, Opacity)
DEF_PROP_I(Sprite, BlendType)
DEF_PROP_I(Sprite, WaveAmp)
DEF_PROP_I(Sprite, WaveLength)
DEF_PROP_I(Sprite, WaveSpeed)
DEF_PROP_F(Sprite, ZoomX)
DEF_PROP_F(Sprite, ZoomY)
DEF_PROP_F(Sprite, Angle)
DEF_PROP_F(Sprite, WavePhase)
DEF_PROP_B(Sprite, Mirror)
#ifdef RGSS2
RB_METHOD(spriteWidth)
{
RB_UNUSED_PARAM;
@ -93,13 +96,6 @@ RB_METHOD(spriteHeight)
return rb_fix_new(value);
}
DEF_PROP_I(Sprite, WaveAmp)
DEF_PROP_I(Sprite, WaveLength)
DEF_PROP_I(Sprite, WaveSpeed)
DEF_PROP_F(Sprite, WavePhase)
#endif
void
spriteBindingInit()
{
@ -130,7 +126,8 @@ spriteBindingInit()
INIT_PROP_BIND( Sprite, Color, "color" );
INIT_PROP_BIND( Sprite, Tone, "tone" );
#ifdef RGSS2
if (rgssVer >= 2)
{
_rb_define_method(klass, "width", spriteWidth);
_rb_define_method(klass, "height", spriteHeight);
@ -138,5 +135,5 @@ spriteBindingInit()
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
#endif
}
}

View file

@ -23,17 +23,12 @@
#include "viewport.h"
#include "bitmap.h"
#include "table.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "binding-util.h"
#include "binding-types.h"
#ifdef RGSS3
# define FLAGS_PROP "flags"
#else
# define FLAGS_PROP "passages"
#endif
DEF_TYPE(TilemapVX);
rb_data_type_struct BitmapArrayType;
@ -93,7 +88,7 @@ DEF_PROP_OBJ_NIL(TilemapVX, Viewport, Viewport, "viewport")
DEF_PROP_OBJ(TilemapVX, Table, MapData, "map_data")
DEF_PROP_OBJ(TilemapVX, Table, FlashData, "flash_data")
DEF_PROP_OBJ(TilemapVX, Table, Flags, FLAGS_PROP)
DEF_PROP_OBJ(TilemapVX, Table, Flags, "flags")
DEF_PROP_B(TilemapVX, Visible)
@ -149,11 +144,19 @@ tilemapVXBindingInit()
INIT_PROP_BIND( TilemapVX, Viewport, "viewport" );
INIT_PROP_BIND( TilemapVX, MapData, "map_data" );
INIT_PROP_BIND( TilemapVX, FlashData, "flash_data" );
INIT_PROP_BIND( TilemapVX, Flags, FLAGS_PROP );
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" );
}
initType(BitmapArrayType, "BitmapArray", 0);
klass = rb_define_class_under(klass, "BitmapArray", rb_cObject);

View file

@ -20,6 +20,7 @@
*/
#include "viewport.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "flashable-binding.h"
#include "sceneelement-binding.h"
@ -32,14 +33,11 @@ RB_METHOD(viewportInitialize)
{
Viewport *v;
#ifdef RGSS3
if (argc == 0)
if (argc == 0 && rgssVer >= 3)
{
v = new Viewport();
}
else
#endif
if (argc == 1)
else if (argc == 1)
{
/* The rect arg is only used to init the viewport,
* and does NOT replace its 'rect' property */

View file

@ -23,6 +23,7 @@
#define VIEWPORTELEMENTBINDING_H
#include "viewport.h"
#include "sharedstate.h"
#include "binding-util.h"
#include "binding-types.h"
@ -39,8 +40,6 @@ RB_METHOD(viewportElementGetViewport)
return rb_iv_get(self, "viewport");
}
#ifdef RGSS2
template<class C>
RB_METHOD(viewportElementSetViewport)
{
@ -63,8 +62,6 @@ RB_METHOD(viewportElementSetViewport)
return viewportObj;
}
#endif
template<class C>
static C *
viewportElementInitialize(int argc, VALUE *argv, VALUE self)
@ -98,9 +95,10 @@ viewportElementBindingInit(VALUE klass)
_rb_define_method(klass, "viewport", viewportElementGetViewport<C>);
#ifdef RGSS2
if (rgssVer >= 2)
{
_rb_define_method(klass, "viewport=", viewportElementSetViewport<C>);
#endif
}
}
#endif // VIEWPORTELEMENTBINDING_H

View file

@ -34,17 +34,20 @@ RB_METHOD(windowVXInitialize)
{
WindowVX *w;
#if RGSS_VER == 3
int x, y, width, height;
x = y = width = height = 0;
if (rgssVer >= 3)
{
int x, y, width, height;
x = y = width = height = 0;
if (argc == 4)
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
if (argc == 4)
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
w = new WindowVX(x, y, width, height);
#else
w = viewportElementInitialize<WindowVX>(argc, argv, self);
#endif
w = new WindowVX(x, y, width, height);
}
else
{
w = viewportElementInitialize<WindowVX>(argc, argv, self);
}
setPrivateData(self, w);
@ -54,12 +57,13 @@ RB_METHOD(windowVXInitialize)
wrapProperty(self, w->getTone(), "tone", ToneType);
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
#ifdef RGSS2
Bitmap *contents = new Bitmap(1, 1);
VALUE contentsObj = wrapObject(contents, BitmapType);
bitmapInitProps(contents, contentsObj);
rb_iv_set(self, "contents", contentsObj);
#endif
if (rgssVer >= 2)
{
Bitmap *contents = new Bitmap(1, 1);
VALUE contentsObj = wrapObject(contents, BitmapType);
bitmapInitProps(contents, contentsObj);
rb_iv_set(self, "contents", contentsObj);
}
return self;
}