Merge branch 'dev'
This commit is contained in:
		
						commit
						58d86039d5
					
				
					 46 changed files with 1121 additions and 632 deletions
				
			
		| 
						 | 
				
			
			@ -88,8 +88,13 @@ static void mriBindingInit()
 | 
			
		|||
 | 
			
		||||
	fileIntBindingInit();
 | 
			
		||||
 | 
			
		||||
#ifdef RGSS3
 | 
			
		||||
	_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_eval_string(module_rpg);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -237,6 +237,24 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
 | 
			
		|||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		case 'n' :
 | 
			
		||||
		{
 | 
			
		||||
			if (argI >= argc)
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			ID *sym = va_arg(ap, ID*);
 | 
			
		||||
 | 
			
		||||
			VALUE symVal = *arg++;
 | 
			
		||||
 | 
			
		||||
			if (!SYMBOL_P(symVal))
 | 
			
		||||
				rb_raise(rb_eTypeError, "Argument %d: Expected symbol", argI);
 | 
			
		||||
 | 
			
		||||
			*sym = SYM2ID(symVal);
 | 
			
		||||
			++argI;
 | 
			
		||||
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		case '|' :
 | 
			
		||||
			opt = true;
 | 
			
		||||
			break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -131,7 +131,7 @@ wrapNilProperty(VALUE self, const char *iv)
 | 
			
		|||
	rb_iv_set(self, iv, Qnil);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Implemented: oSszfib| */
 | 
			
		||||
/* Implemented: oSszfibn| */
 | 
			
		||||
int
 | 
			
		||||
rb_get_args(int argc, VALUE *argv, const char *format, ...);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,12 +52,14 @@ RB_METHOD(bitmapInitialize)
 | 
			
		|||
	setPrivateData(self, b);
 | 
			
		||||
 | 
			
		||||
	/* Wrap properties */
 | 
			
		||||
	Font *font = new Font();
 | 
			
		||||
	b->setFont(font);
 | 
			
		||||
	font->setColor(new Color(*font->getColor()));
 | 
			
		||||
	VALUE fontKlass = rb_const_get(rb_cObject, rb_intern("Font"));
 | 
			
		||||
	VALUE fontObj = rb_obj_alloc(fontKlass);
 | 
			
		||||
	rb_obj_call_init(fontObj, 0, 0);
 | 
			
		||||
 | 
			
		||||
	VALUE fontProp = wrapProperty(self, font, "font", FontType);
 | 
			
		||||
	wrapProperty(fontProp, font->getColor(), "color", ColorType);
 | 
			
		||||
	Font *font = getPrivateData<Font>(fontObj);
 | 
			
		||||
	b->setFont(font);
 | 
			
		||||
 | 
			
		||||
	rb_iv_set(self, "font", fontObj);
 | 
			
		||||
 | 
			
		||||
	return self;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -202,7 +204,7 @@ RB_METHOD(bitmapGetPixel)
 | 
			
		|||
	            return Qnil;
 | 
			
		||||
	         )
 | 
			
		||||
 | 
			
		||||
	Vec4 value;
 | 
			
		||||
	Color value;
 | 
			
		||||
	GUARD_EXC( value = b->getPixel(x, y); );
 | 
			
		||||
 | 
			
		||||
	Color *color = new Color(value);
 | 
			
		||||
| 
						 | 
				
			
			@ -223,7 +225,7 @@ RB_METHOD(bitmapSetPixel)
 | 
			
		|||
 | 
			
		||||
	color = getPrivateDataCheck<Color>(colorObj, ColorType);
 | 
			
		||||
 | 
			
		||||
	GUARD_EXC( b->setPixel(x, y, color->norm); );
 | 
			
		||||
	GUARD_EXC( b->setPixel(x, y, *color); );
 | 
			
		||||
 | 
			
		||||
	return self;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,6 +23,9 @@
 | 
			
		|||
#include "binding-util.h"
 | 
			
		||||
#include "binding-types.h"
 | 
			
		||||
#include "exception.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
DEF_TYPE(Font);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -36,14 +39,16 @@ RB_METHOD(fontDoesExist)
 | 
			
		|||
	return rb_bool_new(Font::doesExist(name));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(FontSetName);
 | 
			
		||||
 | 
			
		||||
RB_METHOD(fontInitialize)
 | 
			
		||||
{
 | 
			
		||||
	const char *name = 0;
 | 
			
		||||
	VALUE name = Qnil;
 | 
			
		||||
	int size = 0;
 | 
			
		||||
 | 
			
		||||
	rb_get_args(argc, argv, "|zi", &name, &size RB_ARG_END);
 | 
			
		||||
	rb_get_args(argc, argv, "|oi", &name, &size RB_ARG_END);
 | 
			
		||||
 | 
			
		||||
	Font *f = new Font(name, size);
 | 
			
		||||
	Font *f = new Font(0, size);
 | 
			
		||||
 | 
			
		||||
	setPrivateData(self, f);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -51,6 +56,13 @@ RB_METHOD(fontInitialize)
 | 
			
		|||
	f->setColor(new Color(*f->getColor()));
 | 
			
		||||
	wrapProperty(self, f->getColor(), "color", ColorType);
 | 
			
		||||
 | 
			
		||||
	if (NIL_P(name))
 | 
			
		||||
		name = rb_iv_get(rb_obj_class(self), "default_name");
 | 
			
		||||
 | 
			
		||||
	/* Going over the 'name=' function automatically causes
 | 
			
		||||
	 * a possbile name array to be re-verified for existing fonts */
 | 
			
		||||
	FontSetName(1, &name, self);
 | 
			
		||||
 | 
			
		||||
	return self;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -77,21 +89,63 @@ RB_METHOD(FontGetName)
 | 
			
		|||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	Font *f = getPrivateData<Font>(self);
 | 
			
		||||
	return rb_iv_get(self, "name");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
	return rb_str_new_cstr(f->getName());
 | 
			
		||||
static void
 | 
			
		||||
fontSetNameHelper(VALUE self, int argc, VALUE *argv,
 | 
			
		||||
                  const char *nameIv, char *outBuf, size_t outLen)
 | 
			
		||||
{
 | 
			
		||||
	rb_check_argc(argc, 1);
 | 
			
		||||
 | 
			
		||||
	VALUE arg = argv[0];
 | 
			
		||||
	int type = rb_type(arg);
 | 
			
		||||
 | 
			
		||||
	// Fixme: in RGSS3, specifying "" (and only that) as font name results in
 | 
			
		||||
	// no text being drawn (everything else is substituted with Arial I think)
 | 
			
		||||
	strncpy(outBuf, "", outLen);
 | 
			
		||||
 | 
			
		||||
	if (type == RUBY_T_STRING)
 | 
			
		||||
	{
 | 
			
		||||
		strncpy(outBuf, RSTRING_PTR(arg), outLen);
 | 
			
		||||
	}
 | 
			
		||||
	else if (type == RUBY_T_ARRAY)
 | 
			
		||||
	{
 | 
			
		||||
		for (long i = 0; i < RARRAY_LEN(arg); ++i)
 | 
			
		||||
		{
 | 
			
		||||
			VALUE str = rb_ary_entry(arg, i);
 | 
			
		||||
 | 
			
		||||
			/* Non-string objects are tolerated (ignored) */
 | 
			
		||||
			if (rb_type(str) != RUBY_T_STRING)
 | 
			
		||||
				continue;
 | 
			
		||||
 | 
			
		||||
			const char *family = RSTRING_PTR(str);
 | 
			
		||||
 | 
			
		||||
			/* We only set the core Font object's name attribute
 | 
			
		||||
			 * to the actually existing font name */
 | 
			
		||||
			if (!shState->fontState().fontPresent(family))
 | 
			
		||||
				continue;
 | 
			
		||||
 | 
			
		||||
			strncpy(outBuf, family, outLen);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* RMXP doesn't even care if the argument type is
 | 
			
		||||
	 * something other than string/array. Whatever... */
 | 
			
		||||
	rb_iv_set(self, nameIv, arg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(FontSetName)
 | 
			
		||||
{
 | 
			
		||||
	Font *f = getPrivateData<Font>(self);
 | 
			
		||||
 | 
			
		||||
	VALUE name;
 | 
			
		||||
	rb_get_args(argc, argv, "S", &name RB_ARG_END);
 | 
			
		||||
	char result[256];
 | 
			
		||||
	fontSetNameHelper(self, argc, argv, "default_name",
 | 
			
		||||
	                  result, sizeof(result));
 | 
			
		||||
 | 
			
		||||
	f->setName(RSTRING_PTR(name));
 | 
			
		||||
	f->setName(result);
 | 
			
		||||
 | 
			
		||||
	return name;
 | 
			
		||||
	return argv[0];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#undef DEF_PROP_CHK_DISP
 | 
			
		||||
| 
						 | 
				
			
			@ -124,18 +178,19 @@ DEF_KLASS_PROP(Font, bool, DefaultItalic, "b", rb_bool_new)
 | 
			
		|||
RB_METHOD(FontGetDefaultName)
 | 
			
		||||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
	return rb_str_new_cstr(Font::getDefaultName());
 | 
			
		||||
 | 
			
		||||
	return rb_iv_get(self, "default_name");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(FontSetDefaultName)
 | 
			
		||||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
	VALUE nameObj;
 | 
			
		||||
	rb_get_args(argc, argv, "S", &nameObj RB_ARG_END);
 | 
			
		||||
	char result[256];
 | 
			
		||||
	fontSetNameHelper(self, argc, argv, "default_name",
 | 
			
		||||
	                  result, sizeof(result));
 | 
			
		||||
 | 
			
		||||
	Font::setDefaultName(RSTRING_PTR(nameObj));
 | 
			
		||||
	Font::setDefaultName(result);
 | 
			
		||||
 | 
			
		||||
	return nameObj;
 | 
			
		||||
	return argv[0];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(FontGetDefaultColor)
 | 
			
		||||
| 
						 | 
				
			
			@ -174,6 +229,7 @@ fontBindingInit()
 | 
			
		|||
 | 
			
		||||
	Font::setDefaultColor(new Color(*Font::getDefaultColor()));
 | 
			
		||||
	wrapProperty(klass, Font::getDefaultColor(), "default_color", ColorType);
 | 
			
		||||
	rb_iv_set(klass, "default_name", rb_str_new_cstr(Font::getDefaultName()));
 | 
			
		||||
 | 
			
		||||
	INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
 | 
			
		||||
	INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,6 +99,24 @@ RB_METHOD(graphicsFrameReset)
 | 
			
		|||
DEF_GRA_PROP_I(FrameRate)
 | 
			
		||||
DEF_GRA_PROP_I(FrameCount)
 | 
			
		||||
 | 
			
		||||
#ifdef RGSS2
 | 
			
		||||
 | 
			
		||||
RB_METHOD(graphicsWidth)
 | 
			
		||||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	return rb_fix_new(shState->graphics().width());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(graphicsHeight)
 | 
			
		||||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	return rb_fix_new(shState->graphics().height());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
DEF_GRA_PROP_B(Fullscreen)
 | 
			
		||||
DEF_GRA_PROP_B(ShowCursor)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -120,6 +138,11 @@ void graphicsBindingInit()
 | 
			
		|||
	INIT_GRA_PROP_BIND( FrameRate,  "frame_rate"  );
 | 
			
		||||
	INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
 | 
			
		||||
 | 
			
		||||
#ifdef RGSS2
 | 
			
		||||
	_rb_define_module_function(module, "width",  graphicsWidth);
 | 
			
		||||
	_rb_define_module_function(module, "height", graphicsHeight);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	INIT_GRA_PROP_BIND( Fullscreen, "fullscreen"  );
 | 
			
		||||
	INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,40 +33,45 @@ RB_METHOD(inputUpdate)
 | 
			
		|||
	return Qnil;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int getButtonArg(VALUE self, int argc, VALUE *argv)
 | 
			
		||||
{
 | 
			
		||||
	int num;
 | 
			
		||||
 | 
			
		||||
#ifdef RGSS3
 | 
			
		||||
	ID sym;
 | 
			
		||||
	rb_get_args(argc, argv, "n", &sym RB_ARG_END);
 | 
			
		||||
 | 
			
		||||
	if (rb_const_defined(self, sym))
 | 
			
		||||
		num = FIX2INT(rb_const_get(self, sym));
 | 
			
		||||
	else
 | 
			
		||||
		num = 0;
 | 
			
		||||
#else
 | 
			
		||||
	(void) self;
 | 
			
		||||
	rb_get_args(argc, argv, "i", &num RB_ARG_END);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	return num;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(inputPress)
 | 
			
		||||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
	int num = getButtonArg(self, argc, argv);
 | 
			
		||||
 | 
			
		||||
	int num;
 | 
			
		||||
	rb_get_args(argc, argv, "i", &num RB_ARG_END);
 | 
			
		||||
 | 
			
		||||
	Input::ButtonCode bc = (Input::ButtonCode) num;
 | 
			
		||||
 | 
			
		||||
	return rb_bool_new(shState->input().isPressed(bc));
 | 
			
		||||
	return rb_bool_new(shState->input().isPressed(num));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(inputTrigger)
 | 
			
		||||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
	int num = getButtonArg(self, argc, argv);
 | 
			
		||||
 | 
			
		||||
	int num;
 | 
			
		||||
	rb_get_args(argc, argv, "i", &num RB_ARG_END);
 | 
			
		||||
 | 
			
		||||
	Input::ButtonCode bc = (Input::ButtonCode) num;
 | 
			
		||||
 | 
			
		||||
	return rb_bool_new(shState->input().isTriggered(bc));
 | 
			
		||||
	return rb_bool_new(shState->input().isTriggered(num));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(inputRepeat)
 | 
			
		||||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
	int num = getButtonArg(self, argc, argv);
 | 
			
		||||
 | 
			
		||||
	int num;
 | 
			
		||||
	rb_get_args(argc, argv, "i", &num RB_ARG_END);
 | 
			
		||||
 | 
			
		||||
	Input::ButtonCode bc = (Input::ButtonCode) num;
 | 
			
		||||
 | 
			
		||||
	return rb_bool_new(shState->input().isRepeated(bc));
 | 
			
		||||
	return rb_bool_new(shState->input().isRepeated(num));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(inputDir4)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,6 +69,39 @@ DEF_PROP_F(Sprite, Angle)
 | 
			
		|||
 | 
			
		||||
DEF_PROP_B(Sprite, Mirror)
 | 
			
		||||
 | 
			
		||||
#ifdef RGSS2
 | 
			
		||||
 | 
			
		||||
RB_METHOD(spriteWidth)
 | 
			
		||||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	Sprite *s = getPrivateData<Sprite>(self);
 | 
			
		||||
 | 
			
		||||
	int value;
 | 
			
		||||
	GUARD_EXC( value = s->getWidth(); )
 | 
			
		||||
 | 
			
		||||
	return rb_fix_new(value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(spriteHeight)
 | 
			
		||||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
 | 
			
		||||
	Sprite *s = getPrivateData<Sprite>(self);
 | 
			
		||||
 | 
			
		||||
	int value;
 | 
			
		||||
	GUARD_EXC( value = s->getHeight(); )
 | 
			
		||||
 | 
			
		||||
	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()
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -98,4 +131,14 @@ spriteBindingInit()
 | 
			
		|||
	INIT_PROP_BIND( Sprite, BlendType, "blend_type" );
 | 
			
		||||
	INIT_PROP_BIND( Sprite, Color,     "color"      );
 | 
			
		||||
	INIT_PROP_BIND( Sprite, Tone,      "tone"       );
 | 
			
		||||
 | 
			
		||||
#ifdef RGSS2
 | 
			
		||||
	_rb_define_method(klass, "width", spriteWidth);
 | 
			
		||||
	_rb_define_method(klass, "height", spriteHeight);
 | 
			
		||||
 | 
			
		||||
	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"  );
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue