parent
7f41b9cc45
commit
9461449cc9
|
@ -37,6 +37,7 @@ struct
|
|||
SYMD(viewport),
|
||||
SYMD(bitmap),
|
||||
SYMD(color),
|
||||
SYMD(out_color),
|
||||
SYMD(tone),
|
||||
SYMD(rect),
|
||||
SYMD(src_rect),
|
||||
|
@ -51,6 +52,7 @@ struct
|
|||
SYMD(path),
|
||||
SYMD(array),
|
||||
SYMD(default_color),
|
||||
SYMD(default_out_color),
|
||||
SYMD(children),
|
||||
SYMD(dispose)
|
||||
};
|
||||
|
|
|
@ -38,6 +38,7 @@ enum CommonSymbol
|
|||
CSviewport,
|
||||
CSbitmap,
|
||||
CScolor,
|
||||
CSout_color,
|
||||
CStone,
|
||||
CSrect,
|
||||
CSsrc_rect,
|
||||
|
@ -52,6 +53,7 @@ enum CommonSymbol
|
|||
CSpath,
|
||||
CSarray,
|
||||
CSdefault_color,
|
||||
CSdefault_out_color,
|
||||
CSchildren,
|
||||
CSdispose,
|
||||
|
||||
|
@ -149,7 +151,8 @@ defineClass(mrb_state *mrb, const char *name)
|
|||
|
||||
#define MRB_FUN_UNUSED_PARAM { (void) mrb; }
|
||||
|
||||
#define DEF_PROP_OBJ(Klass, PropKlass, PropName, prop_iv) \
|
||||
/* Object property which is copied by value, not reference */
|
||||
#define DEF_PROP_OBJ_VAL(Klass, PropKlass, PropName, prop_iv) \
|
||||
MRB_METHOD(Klass##Get##PropName) \
|
||||
{ \
|
||||
checkDisposed(mrb, self); \
|
||||
|
@ -163,12 +166,11 @@ defineClass(mrb_state *mrb, const char *name)
|
|||
mrb_get_args(mrb, "o", &propObj); \
|
||||
prop = getPrivateDataCheck<PropKlass>(mrb, propObj, PropKlass##Type); \
|
||||
GUARD_EXC( k->set##PropName(prop); ) \
|
||||
setProperty(mrb, self, prop_iv, propObj); \
|
||||
return propObj; \
|
||||
}
|
||||
|
||||
/* Object property with allowed NIL */
|
||||
#define DEF_PROP_OBJ_NIL(Klass, PropKlass, PropName, prop_iv) \
|
||||
/* Object property which is copied by reference, with allowed NIL */
|
||||
#define DEF_PROP_OBJ_REF(Klass, PropKlass, PropName, prop_iv) \
|
||||
MRB_METHOD(Klass##Get##PropName) \
|
||||
{ \
|
||||
return getProperty(mrb, self, prop_iv); \
|
||||
|
@ -300,7 +302,7 @@ wrapObject(mrb_state *mrb, void *p, const mrb_data_type &type)
|
|||
return obj;
|
||||
}
|
||||
|
||||
inline void
|
||||
inline mrb_value
|
||||
wrapProperty(mrb_state *mrb, mrb_value self,
|
||||
void *prop, CommonSymbol iv, const mrb_data_type &type)
|
||||
{
|
||||
|
@ -310,6 +312,8 @@ wrapProperty(mrb_state *mrb, mrb_value self,
|
|||
mrb_obj_ptr(self),
|
||||
getSym(mrb, iv),
|
||||
propObj);
|
||||
|
||||
return propObj;
|
||||
}
|
||||
|
||||
inline mrb_value
|
||||
|
|
|
@ -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"
|
||||
|
@ -51,11 +52,15 @@ MRB_METHOD(bitmapInitialize)
|
|||
|
||||
/* Wrap properties */
|
||||
Font *font = new Font();
|
||||
b->setFont(font);
|
||||
font->setColor(new Color(*font->getColor()));
|
||||
b->setInitFont(font);
|
||||
font->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, font, CSfont, FontType);
|
||||
wrapProperty(mrb, getProperty(mrb, self, CSfont), font->getColor(), CScolor, ColorType);
|
||||
mrb_value fontProp = wrapProperty(mrb, self, font, CSfont, FontType);
|
||||
|
||||
wrapProperty(mrb, fontProp, font->getColor(), CScolor, ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(mrb, fontProp, font->getOutColor(), CSout_color, ColorType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -292,7 +297,6 @@ MRB_METHOD(bitmapSetFont)
|
|||
font = getPrivateDataCheck<Font>(mrb, fontObj, FontType);
|
||||
|
||||
GUARD_EXC( b->setFont(font); )
|
||||
setProperty(mrb, self, CSfont, fontObj);
|
||||
|
||||
return mrb_nil_value();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "font.h"
|
||||
#include "sharedstate.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
#include "exception.h"
|
||||
|
@ -53,9 +54,13 @@ MRB_METHOD(fontInitialize)
|
|||
setPrivateData(self, f, FontType);
|
||||
|
||||
/* Wrap property objects */
|
||||
f->setColor(new Color(*f->getColor()));
|
||||
f->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, f->getColor(), CScolor, ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(mrb, self, f->getOutColor(), CSout_color, ColorType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -69,9 +74,13 @@ MRB_METHOD(fontInitializeCopy)
|
|||
setPrivateData(self, f, FontType);
|
||||
|
||||
/* Wrap property objects */
|
||||
f->setColor(new Color(*f->getColor()));
|
||||
f->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, f->getColor(), CScolor, ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(mrb, self, f->getOutColor(), CSout_color, ColorType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -97,7 +106,10 @@ MRB_METHOD(FontSetName)
|
|||
DEF_PROP_I(Font, Size)
|
||||
DEF_PROP_B(Font, Bold)
|
||||
DEF_PROP_B(Font, Italic)
|
||||
DEF_PROP_OBJ(Font, Color, Color, CScolor)
|
||||
DEF_PROP_B(Font, Outline)
|
||||
DEF_PROP_B(Font, Shadow)
|
||||
DEF_PROP_OBJ_VAL(Font, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ_VAL(Font, Color, OutColor, CSout_color)
|
||||
|
||||
#define DEF_KLASS_PROP(Klass, mrb_type, PropName, arg_type, conv_t) \
|
||||
static mrb_value \
|
||||
|
@ -114,9 +126,11 @@ DEF_PROP_OBJ(Font, Color, Color, CScolor)
|
|||
return mrb_##conv_t##_value(value); \
|
||||
}
|
||||
|
||||
DEF_KLASS_PROP(Font, mrb_int, DefaultSize, "i", fixnum)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultBold, "b", bool)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultItalic, "b", bool)
|
||||
DEF_KLASS_PROP(Font, mrb_int, DefaultSize, "i", fixnum)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultBold, "b", bool)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultItalic, "b", bool)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultOutline, "b", bool)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultShadow, "b", bool)
|
||||
|
||||
MRB_FUNCTION(FontGetDefaultName)
|
||||
{
|
||||
|
@ -140,13 +154,33 @@ MRB_METHOD(FontGetDefaultColor)
|
|||
|
||||
MRB_METHOD(FontSetDefaultColor)
|
||||
{
|
||||
MRB_UNUSED_PARAM;
|
||||
|
||||
mrb_value colorObj;
|
||||
mrb_get_args(mrb, "o", &colorObj);
|
||||
|
||||
Color *c = getPrivateDataCheck<Color>(mrb, colorObj, ColorType);
|
||||
|
||||
Font::setDefaultColor(c);
|
||||
setProperty(mrb, self, CSdefault_color, colorObj);
|
||||
|
||||
return colorObj;
|
||||
}
|
||||
|
||||
MRB_METHOD(FontGetDefaultOutColor)
|
||||
{
|
||||
return getProperty(mrb, self, CSdefault_out_color);
|
||||
}
|
||||
|
||||
MRB_METHOD(FontSetDefaultOutColor)
|
||||
{
|
||||
MRB_UNUSED_PARAM;
|
||||
|
||||
mrb_value colorObj;
|
||||
mrb_get_args(mrb, "o", &colorObj);
|
||||
|
||||
Color *c = getPrivateDataCheck<Color>(mrb, colorObj, ColorType);
|
||||
|
||||
Font::setDefaultOutColor(c);
|
||||
|
||||
return colorObj;
|
||||
}
|
||||
|
@ -162,25 +196,48 @@ fontBindingInit(mrb_state *mrb)
|
|||
{
|
||||
RClass *klass = defineClass(mrb, "Font");
|
||||
|
||||
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
|
||||
Font::initDefaultDynAttribs();
|
||||
wrapProperty(mrb, mrb_obj_value(klass), Font::getDefaultColor(), CSdefault_color, ColorType);
|
||||
|
||||
mrb_define_class_method(mrb, klass, "exist?", fontDoesExist, MRB_ARGS_REQ(1));
|
||||
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
|
||||
}
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
|
||||
wrapProperty(mrb, mrb_obj_value(klass), Font::getDefaultOutColor(), CSdefault_out_color, ColorType);
|
||||
}
|
||||
|
||||
mrb_define_method(mrb, klass, "initialize", fontInitialize, MRB_ARGS_OPT(2));
|
||||
mrb_define_method(mrb, klass, "initialize_copy", fontInitializeCopy, MRB_ARGS_REQ(1));
|
||||
|
||||
INIT_PROP_BIND(Font, Name, "name");
|
||||
INIT_PROP_BIND(Font, Size, "size");
|
||||
INIT_PROP_BIND(Font, Bold, "bold");
|
||||
INIT_PROP_BIND(Font, Italic, "italic");
|
||||
INIT_PROP_BIND(Font, Color, "color");
|
||||
INIT_PROP_BIND(Font, Name, "name");
|
||||
INIT_PROP_BIND(Font, Size, "size");
|
||||
INIT_PROP_BIND(Font, Bold, "bold");
|
||||
INIT_PROP_BIND(Font, Italic, "italic");
|
||||
INIT_PROP_BIND(Font, Color, "color");
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
INIT_PROP_BIND(Font, Shadow, "shadow");
|
||||
}
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
INIT_PROP_BIND(Font, Outline, "outline");
|
||||
INIT_PROP_BIND(Font, OutColor, "out_color");
|
||||
}
|
||||
|
||||
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
|
||||
}
|
||||
|
|
|
@ -33,18 +33,17 @@ MRB_METHOD(planeInitialize)
|
|||
|
||||
setPrivateData(self, p, PlaneType);
|
||||
|
||||
p->setColor(new Color);
|
||||
p->setTone(new Tone);
|
||||
p->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, p->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, p->getTone(), CStone, ToneType);
|
||||
wrapProperty(mrb, self, p->getTone(), CStone, ToneType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ(Plane, Bitmap, Bitmap, CSbitmap)
|
||||
DEF_PROP_OBJ(Plane, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ(Plane, Tone, Tone, CStone)
|
||||
DEF_PROP_OBJ_REF(Plane, Bitmap, Bitmap, CSbitmap)
|
||||
DEF_PROP_OBJ_VAL(Plane, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ_VAL(Plane, Tone, Tone, CStone)
|
||||
|
||||
DEF_PROP_I(Plane, OX)
|
||||
DEF_PROP_I(Plane, OY)
|
||||
|
|
|
@ -36,9 +36,7 @@ MRB_METHOD(spriteInitialize)
|
|||
setPrivateData(self, s, SpriteType);
|
||||
|
||||
/* Wrap property objects */
|
||||
s->setSrcRect(new Rect);
|
||||
s->setColor(new Color);
|
||||
s->setTone(new Tone);
|
||||
s->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, s->getSrcRect(), CSsrc_rect, RectType);
|
||||
wrapProperty(mrb, self, s->getColor(), CScolor, ColorType);
|
||||
|
@ -47,10 +45,10 @@ MRB_METHOD(spriteInitialize)
|
|||
return self;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_NIL(Sprite, Bitmap, Bitmap, CSbitmap)
|
||||
DEF_PROP_OBJ(Sprite, Rect, SrcRect, CSsrc_rect)
|
||||
DEF_PROP_OBJ(Sprite, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ(Sprite, Tone, Tone, CStone)
|
||||
DEF_PROP_OBJ_REF(Sprite, Bitmap, Bitmap, CSbitmap)
|
||||
DEF_PROP_OBJ_VAL(Sprite, Rect, SrcRect, CSsrc_rect)
|
||||
DEF_PROP_OBJ_VAL(Sprite, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ_VAL(Sprite, Tone, Tone, CStone)
|
||||
|
||||
DEF_PROP_I(Sprite, X)
|
||||
DEF_PROP_I(Sprite, Y)
|
||||
|
|
|
@ -125,10 +125,10 @@ MRB_METHOD(tilemapGetViewport)
|
|||
return getProperty(mrb, self, CSviewport);
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ(Tilemap, Bitmap, Tileset, CStileset)
|
||||
DEF_PROP_OBJ(Tilemap, Table, MapData, CSmap_data)
|
||||
DEF_PROP_OBJ(Tilemap, Table, FlashData, CSflash_data)
|
||||
DEF_PROP_OBJ(Tilemap, Table, Priorities, CSpriorities)
|
||||
DEF_PROP_OBJ_REF(Tilemap, Bitmap, Tileset, CStileset)
|
||||
DEF_PROP_OBJ_REF(Tilemap, Table, MapData, CSmap_data)
|
||||
DEF_PROP_OBJ_REF(Tilemap, Table, FlashData, CSflash_data)
|
||||
DEF_PROP_OBJ_REF(Tilemap, Table, Priorities, CSpriorities)
|
||||
|
||||
DEF_PROP_B(Tilemap, Visible)
|
||||
|
||||
|
|
|
@ -57,9 +57,7 @@ MRB_METHOD(viewportInitialize)
|
|||
setPrivateData(self, v, ViewportType);
|
||||
|
||||
/* Wrap property objects */
|
||||
v->setRect(new Rect(*v->getRect()));
|
||||
v->setColor(new Color);
|
||||
v->setTone(new Tone);
|
||||
v->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, v->getRect(), CSrect, RectType);
|
||||
wrapProperty(mrb, self, v->getColor(), CScolor, ColorType);
|
||||
|
@ -68,9 +66,9 @@ MRB_METHOD(viewportInitialize)
|
|||
return self;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ(Viewport, Rect, Rect, CSrect)
|
||||
DEF_PROP_OBJ(Viewport, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ(Viewport, Tone, Tone, CStone)
|
||||
DEF_PROP_OBJ_VAL(Viewport, Rect, Rect, CSrect)
|
||||
DEF_PROP_OBJ_VAL(Viewport, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ_VAL(Viewport, Tone, Tone, CStone)
|
||||
|
||||
DEF_PROP_I(Viewport, OX)
|
||||
DEF_PROP_I(Viewport, OY)
|
||||
|
|
|
@ -32,7 +32,7 @@ MRB_METHOD(windowInitialize)
|
|||
|
||||
setPrivateData(self, w, WindowType);
|
||||
|
||||
w->setCursorRect(new Rect);
|
||||
w->initDynAttribs();
|
||||
wrapProperty(mrb, self, w->getCursorRect(), CScursor_rect, RectType);
|
||||
|
||||
return self;
|
||||
|
@ -47,9 +47,9 @@ MRB_METHOD(windowUpdate)
|
|||
return mrb_nil_value();
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_NIL(Window, Bitmap, Windowskin, CSwindowskin)
|
||||
DEF_PROP_OBJ_NIL(Window, Bitmap, Contents, CScontents)
|
||||
DEF_PROP_OBJ(Window, Rect, CursorRect, CScursor_rect)
|
||||
DEF_PROP_OBJ_REF(Window, Bitmap, Windowskin, CSwindowskin)
|
||||
DEF_PROP_OBJ_REF(Window, Bitmap, Contents, CScontents)
|
||||
DEF_PROP_OBJ_VAL(Window, Rect, CursorRect, CScursor_rect)
|
||||
|
||||
DEF_PROP_B(Window, Stretch)
|
||||
DEF_PROP_B(Window, Active)
|
||||
|
|
Loading…
Reference in New Issue