MRI-Binding: Bitmap: 'draw_text' and 'text_size' should call #to_s (RGSS2)

This commit is contained in:
Jonas Kulla 2014-08-15 22:49:22 +02:00
parent 3224950a1c
commit 5b319020ea
1 changed files with 30 additions and 0 deletions

View File

@ -252,7 +252,17 @@ 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 (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
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
@ -262,7 +272,17 @@ 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 (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
GUARD_EXC( b->drawText(x, y, width, height, str, align); );
}
@ -276,7 +296,17 @@ RB_METHOD(bitmapTextSize)
const char *str;
#ifdef RGSS2
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);
str = RSTRING_PTR(strObj);
#else
rb_get_args(argc, argv, "z", &str RB_ARG_END);
#endif
IntRect value;
GUARD_EXC( value = b->textSize(str); );