Core/MRI: Fix handling of Etc/Font properties
The gist of it is that for Etc and Font props, the assignment operator (eg. 'sprite.color=') does not take a reference of the right hand parameter and replaces its previous one with it (this was the old behavior). Rather, it keeps its internal property object and copies the parameter object into it by value. The getter is unchanged; it still returns a reference to the internal property object. s = Sprite.new c = Color.new s.color = c p s.color == c # => true p s.color.object_id == c.object_id # => false (true before) c = s.color p s.color.object_id == c.object_id # => true
This commit is contained in:
parent
f665d8b41c
commit
f8c26fc515
|
@ -316,30 +316,11 @@ rb_check_argc(int actual, int expected)
|
||||||
return self; \
|
return self; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEF_PROP_OBJ(Klass, PropKlass, PropName, prop_iv) \
|
/* Object property which is copied by reference, with allowed NIL
|
||||||
RB_METHOD(Klass##Get##PropName) \
|
|
||||||
{ \
|
|
||||||
RB_UNUSED_PARAM; \
|
|
||||||
checkDisposed(self); \
|
|
||||||
return rb_iv_get(self, prop_iv); \
|
|
||||||
} \
|
|
||||||
RB_METHOD(Klass##Set##PropName) \
|
|
||||||
{ \
|
|
||||||
rb_check_argc(argc, 1); \
|
|
||||||
Klass *k = getPrivateData<Klass>(self); \
|
|
||||||
VALUE propObj = *argv; \
|
|
||||||
PropKlass *prop; \
|
|
||||||
prop = getPrivateDataCheck<PropKlass>(propObj, PropKlass##Type); \
|
|
||||||
GUARD_EXC( k->set##PropName(prop); ) \
|
|
||||||
rb_iv_set(self, prop_iv, propObj); \
|
|
||||||
return propObj; \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Object property with allowed NIL
|
|
||||||
* FIXME: Getter assumes prop is disposable,
|
* FIXME: Getter assumes prop is disposable,
|
||||||
* because self.disposed? is not checked in this case.
|
* because self.disposed? is not checked in this case.
|
||||||
* Should make this more clear */
|
* Should make this more clear */
|
||||||
#define DEF_PROP_OBJ_NIL(Klass, PropKlass, PropName, prop_iv) \
|
#define DEF_PROP_OBJ_REF(Klass, PropKlass, PropName, prop_iv) \
|
||||||
RB_METHOD(Klass##Get##PropName) \
|
RB_METHOD(Klass##Get##PropName) \
|
||||||
{ \
|
{ \
|
||||||
RB_UNUSED_PARAM; \
|
RB_UNUSED_PARAM; \
|
||||||
|
@ -361,6 +342,25 @@ rb_check_argc(int actual, int expected)
|
||||||
return propObj; \
|
return propObj; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Object property which is copied by value, not reference */
|
||||||
|
#define DEF_PROP_OBJ_VAL(Klass, PropKlass, PropName, prop_iv) \
|
||||||
|
RB_METHOD(Klass##Get##PropName) \
|
||||||
|
{ \
|
||||||
|
RB_UNUSED_PARAM; \
|
||||||
|
checkDisposed(self); \
|
||||||
|
return rb_iv_get(self, prop_iv); \
|
||||||
|
} \
|
||||||
|
RB_METHOD(Klass##Set##PropName) \
|
||||||
|
{ \
|
||||||
|
rb_check_argc(argc, 1); \
|
||||||
|
Klass *k = getPrivateData<Klass>(self); \
|
||||||
|
VALUE propObj = *argv; \
|
||||||
|
PropKlass *prop; \
|
||||||
|
prop = getPrivateDataCheck<PropKlass>(propObj, PropKlass##Type); \
|
||||||
|
GUARD_EXC( k->set##PropName(prop); ) \
|
||||||
|
return propObj; \
|
||||||
|
}
|
||||||
|
|
||||||
#define DEF_PROP(Klass, type, PropName, arg_fun, value_fun) \
|
#define DEF_PROP(Klass, type, PropName, arg_fun, value_fun) \
|
||||||
RB_METHOD(Klass##Get##PropName) \
|
RB_METHOD(Klass##Get##PropName) \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
@ -43,7 +43,7 @@ void bitmapInitProps(Bitmap *b, VALUE self)
|
||||||
rb_obj_call_init(fontObj, 0, 0);
|
rb_obj_call_init(fontObj, 0, 0);
|
||||||
|
|
||||||
Font *font = getPrivateData<Font>(fontObj);
|
Font *font = getPrivateData<Font>(fontObj);
|
||||||
b->setFont(font);
|
b->setInitFont(font);
|
||||||
|
|
||||||
rb_iv_set(self, "font", fontObj);
|
rb_iv_set(self, "font", fontObj);
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ RB_METHOD(bitmapTextSize)
|
||||||
return wrapObject(rect, RectType);
|
return wrapObject(rect, RectType);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_PROP_OBJ(Bitmap, Font, Font, "font")
|
DEF_PROP_OBJ_VAL(Bitmap, Font, Font, "font")
|
||||||
|
|
||||||
RB_METHOD(bitmapGradientFillRect)
|
RB_METHOD(bitmapGradientFillRect)
|
||||||
{
|
{
|
||||||
|
@ -413,12 +413,25 @@ RB_METHOD(bitmapRadialBlur)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This isn't entire correct as the cloned bitmap
|
RB_METHOD(bitmapInitializeCopy)
|
||||||
// does not get a cloned version of the original bitmap's 'font'
|
{
|
||||||
// attribute (the internal font attrb is the default one, whereas
|
rb_check_argc(argc, 1);
|
||||||
// the stored iv visible to ruby would still be the same as the original)
|
VALUE origObj = argv[0];
|
||||||
// Not sure if this needs fixing though
|
|
||||||
INITCOPY_FUN(Bitmap)
|
if (!OBJ_INIT_COPY(self, origObj))
|
||||||
|
return self;
|
||||||
|
|
||||||
|
Bitmap *orig = getPrivateData<Bitmap>(origObj);
|
||||||
|
Bitmap *b = 0;
|
||||||
|
GUARD_EXC( b = new Bitmap(*orig); );
|
||||||
|
|
||||||
|
bitmapInitProps(b, self);
|
||||||
|
b->setFont(orig->getFont());
|
||||||
|
|
||||||
|
setPrivateData(self, b);
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -430,7 +443,7 @@ bitmapBindingInit()
|
||||||
disposableBindingInit<Bitmap>(klass);
|
disposableBindingInit<Bitmap>(klass);
|
||||||
|
|
||||||
_rb_define_method(klass, "initialize", bitmapInitialize);
|
_rb_define_method(klass, "initialize", bitmapInitialize);
|
||||||
_rb_define_method(klass, "initialize_copy", BitmapInitializeCopy);
|
_rb_define_method(klass, "initialize_copy", bitmapInitializeCopy);
|
||||||
|
|
||||||
_rb_define_method(klass, "width", bitmapWidth);
|
_rb_define_method(klass, "width", bitmapWidth);
|
||||||
_rb_define_method(klass, "height", bitmapHeight);
|
_rb_define_method(klass, "height", bitmapHeight);
|
||||||
|
|
|
@ -110,7 +110,7 @@ INIT_FUN(Rect, int, "iiii", 0)
|
||||||
{ \
|
{ \
|
||||||
VALUE otherObj = argv[0]; \
|
VALUE otherObj = argv[0]; \
|
||||||
Klass *other = getPrivateDataCheck<Klass>(otherObj, Klass##Type); \
|
Klass *other = getPrivateDataCheck<Klass>(otherObj, Klass##Type); \
|
||||||
k->set(*other); \
|
*k = *other; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
@ -58,14 +58,12 @@ RB_METHOD(fontInitialize)
|
||||||
setPrivateData(self, f);
|
setPrivateData(self, f);
|
||||||
|
|
||||||
/* Wrap property objects */
|
/* Wrap property objects */
|
||||||
f->setColor(new Color(*f->getColor()));
|
f->initDynAttribs();
|
||||||
|
|
||||||
wrapProperty(self, f->getColor(), "color", ColorType);
|
wrapProperty(self, f->getColor(), "color", ColorType);
|
||||||
|
|
||||||
if (rgssVer >= 3)
|
if (rgssVer >= 3)
|
||||||
{
|
|
||||||
f->setOutColor(new Color(*f->getOutColor()));
|
|
||||||
wrapProperty(self, f->getOutColor(), "out_color", ColorType);
|
wrapProperty(self, f->getOutColor(), "out_color", ColorType);
|
||||||
}
|
|
||||||
|
|
||||||
if (NIL_P(name))
|
if (NIL_P(name))
|
||||||
name = rb_iv_get(rb_obj_class(self), "default_name");
|
name = rb_iv_get(rb_obj_class(self), "default_name");
|
||||||
|
@ -90,14 +88,12 @@ RB_METHOD(fontInitializeCopy)
|
||||||
setPrivateData(self, f);
|
setPrivateData(self, f);
|
||||||
|
|
||||||
/* Wrap property objects */
|
/* Wrap property objects */
|
||||||
f->setColor(new Color(*f->getColor()));
|
f->initDynAttribs();
|
||||||
|
|
||||||
wrapProperty(self, f->getColor(), "color", ColorType);
|
wrapProperty(self, f->getColor(), "color", ColorType);
|
||||||
|
|
||||||
if (rgssVer >= 3)
|
if (rgssVer >= 3)
|
||||||
{
|
|
||||||
f->setOutColor(new Color(*f->getOutColor()));
|
|
||||||
wrapProperty(self, f->getOutColor(), "out_color", ColorType);
|
wrapProperty(self, f->getOutColor(), "out_color", ColorType);
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -164,13 +160,15 @@ RB_METHOD(FontSetName)
|
||||||
return argv[0];
|
return argv[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEF_PROP_OBJ_VAL(Font, Color, Color, "color")
|
||||||
|
DEF_PROP_OBJ_VAL(Font, Color, OutColor, "out_color")
|
||||||
|
|
||||||
DEF_PROP_I(Font, Size)
|
DEF_PROP_I(Font, Size)
|
||||||
|
|
||||||
DEF_PROP_B(Font, Bold)
|
DEF_PROP_B(Font, Bold)
|
||||||
DEF_PROP_B(Font, Italic)
|
DEF_PROP_B(Font, Italic)
|
||||||
DEF_PROP_B(Font, Shadow)
|
DEF_PROP_B(Font, Shadow)
|
||||||
DEF_PROP_B(Font, Outline)
|
DEF_PROP_B(Font, Outline)
|
||||||
DEF_PROP_OBJ(Font, Color, Color, "color")
|
|
||||||
DEF_PROP_OBJ(Font, Color, OutColor, "out_color")
|
|
||||||
|
|
||||||
#define DEF_KLASS_PROP(Klass, type, PropName, param_t_s, value_fun) \
|
#define DEF_KLASS_PROP(Klass, type, PropName, param_t_s, value_fun) \
|
||||||
RB_METHOD(Klass##Get##PropName) \
|
RB_METHOD(Klass##Get##PropName) \
|
||||||
|
@ -201,13 +199,14 @@ RB_METHOD(FontGetDefaultOutColor)
|
||||||
|
|
||||||
RB_METHOD(FontSetDefaultOutColor)
|
RB_METHOD(FontSetDefaultOutColor)
|
||||||
{
|
{
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
VALUE colorObj;
|
VALUE colorObj;
|
||||||
rb_get_args(argc, argv, "o", &colorObj RB_ARG_END);
|
rb_get_args(argc, argv, "o", &colorObj RB_ARG_END);
|
||||||
|
|
||||||
Color *c = getPrivateDataCheck<Color>(colorObj, ColorType);
|
Color *c = getPrivateDataCheck<Color>(colorObj, ColorType);
|
||||||
|
|
||||||
Font::setDefaultOutColor(c);
|
Font::setDefaultOutColor(c);
|
||||||
rb_iv_set(self, "default_out_color", colorObj);
|
|
||||||
|
|
||||||
return colorObj;
|
return colorObj;
|
||||||
}
|
}
|
||||||
|
@ -239,13 +238,14 @@ RB_METHOD(FontGetDefaultColor)
|
||||||
|
|
||||||
RB_METHOD(FontSetDefaultColor)
|
RB_METHOD(FontSetDefaultColor)
|
||||||
{
|
{
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
VALUE colorObj;
|
VALUE colorObj;
|
||||||
rb_get_args(argc, argv, "o", &colorObj RB_ARG_END);
|
rb_get_args(argc, argv, "o", &colorObj RB_ARG_END);
|
||||||
|
|
||||||
Color *c = getPrivateDataCheck<Color>(colorObj, ColorType);
|
Color *c = getPrivateDataCheck<Color>(colorObj, ColorType);
|
||||||
|
|
||||||
Font::setDefaultColor(c);
|
Font::setDefaultColor(c);
|
||||||
rb_iv_set(self, "default_color", colorObj);
|
|
||||||
|
|
||||||
return colorObj;
|
return colorObj;
|
||||||
}
|
}
|
||||||
|
@ -262,10 +262,13 @@ fontBindingInit()
|
||||||
VALUE klass = rb_define_class("Font", rb_cObject);
|
VALUE klass = rb_define_class("Font", rb_cObject);
|
||||||
rb_define_alloc_func(klass, classAllocate<&FontType>);
|
rb_define_alloc_func(klass, classAllocate<&FontType>);
|
||||||
|
|
||||||
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
|
Font::initDefaultDynAttribs();
|
||||||
wrapProperty(klass, Font::getDefaultColor(), "default_color", ColorType);
|
wrapProperty(klass, Font::getDefaultColor(), "default_color", ColorType);
|
||||||
rb_iv_set(klass, "default_name", rb_str_new_cstr(Font::getDefaultName()));
|
rb_iv_set(klass, "default_name", rb_str_new_cstr(Font::getDefaultName()));
|
||||||
|
|
||||||
|
if (rgssVer >= 3)
|
||||||
|
wrapProperty(klass, Font::getDefaultOutColor(), "default_out_color", ColorType);
|
||||||
|
|
||||||
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
|
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
|
||||||
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
|
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
|
||||||
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
|
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
|
||||||
|
|
|
@ -33,8 +33,7 @@ RB_METHOD(planeInitialize)
|
||||||
|
|
||||||
setPrivateData(self, p);
|
setPrivateData(self, p);
|
||||||
|
|
||||||
p->setColor(new Color);
|
p->initDynAttribs();
|
||||||
p->setTone(new Tone);
|
|
||||||
|
|
||||||
wrapNilProperty(self, "bitmap");
|
wrapNilProperty(self, "bitmap");
|
||||||
wrapProperty(self, p->getColor(), "color", ColorType);
|
wrapProperty(self, p->getColor(), "color", ColorType);
|
||||||
|
@ -43,9 +42,9 @@ RB_METHOD(planeInitialize)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_PROP_OBJ_NIL(Plane, Bitmap, Bitmap, "bitmap")
|
DEF_PROP_OBJ_REF(Plane, Bitmap, Bitmap, "bitmap")
|
||||||
DEF_PROP_OBJ(Plane, Color, Color, "color")
|
DEF_PROP_OBJ_VAL(Plane, Color, Color, "color")
|
||||||
DEF_PROP_OBJ(Plane, Tone, Tone, "tone")
|
DEF_PROP_OBJ_VAL(Plane, Tone, Tone, "tone")
|
||||||
|
|
||||||
DEF_PROP_I(Plane, OX)
|
DEF_PROP_I(Plane, OX)
|
||||||
DEF_PROP_I(Plane, OY)
|
DEF_PROP_I(Plane, OY)
|
||||||
|
|
|
@ -37,9 +37,7 @@ RB_METHOD(spriteInitialize)
|
||||||
setPrivateData(self, s);
|
setPrivateData(self, s);
|
||||||
|
|
||||||
/* Wrap property objects */
|
/* Wrap property objects */
|
||||||
s->setSrcRect(new Rect);
|
s->initDynAttribs();
|
||||||
s->setColor(new Color);
|
|
||||||
s->setTone(new Tone);
|
|
||||||
|
|
||||||
wrapNilProperty(self, "bitmap");
|
wrapNilProperty(self, "bitmap");
|
||||||
wrapProperty(self, s->getSrcRect(), "src_rect", RectType);
|
wrapProperty(self, s->getSrcRect(), "src_rect", RectType);
|
||||||
|
@ -49,10 +47,10 @@ RB_METHOD(spriteInitialize)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_PROP_OBJ_NIL(Sprite, Bitmap, Bitmap, "bitmap")
|
DEF_PROP_OBJ_REF(Sprite, Bitmap, Bitmap, "bitmap")
|
||||||
DEF_PROP_OBJ(Sprite, Rect, SrcRect, "src_rect")
|
DEF_PROP_OBJ_VAL(Sprite, Rect, SrcRect, "src_rect")
|
||||||
DEF_PROP_OBJ(Sprite, Color, Color, "color")
|
DEF_PROP_OBJ_VAL(Sprite, Color, Color, "color")
|
||||||
DEF_PROP_OBJ(Sprite, Tone, Tone, "tone")
|
DEF_PROP_OBJ_VAL(Sprite, Tone, Tone, "tone")
|
||||||
|
|
||||||
DEF_PROP_I(Sprite, X)
|
DEF_PROP_I(Sprite, X)
|
||||||
DEF_PROP_I(Sprite, Y)
|
DEF_PROP_I(Sprite, Y)
|
||||||
|
|
|
@ -124,10 +124,10 @@ RB_METHOD(tilemapGetViewport)
|
||||||
return rb_iv_get(self, "viewport");
|
return rb_iv_get(self, "viewport");
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_PROP_OBJ(Tilemap, Bitmap, Tileset, "tileset")
|
DEF_PROP_OBJ_REF(Tilemap, Bitmap, Tileset, "tileset")
|
||||||
DEF_PROP_OBJ(Tilemap, Table, MapData, "map_data")
|
DEF_PROP_OBJ_REF(Tilemap, Table, MapData, "map_data")
|
||||||
DEF_PROP_OBJ(Tilemap, Table, FlashData, "flash_data")
|
DEF_PROP_OBJ_REF(Tilemap, Table, FlashData, "flash_data")
|
||||||
DEF_PROP_OBJ(Tilemap, Table, Priorities, "priorities")
|
DEF_PROP_OBJ_REF(Tilemap, Table, Priorities, "priorities")
|
||||||
|
|
||||||
DEF_PROP_B(Tilemap, Visible)
|
DEF_PROP_B(Tilemap, Visible)
|
||||||
|
|
||||||
|
|
|
@ -85,11 +85,10 @@ RB_METHOD(tilemapVXUpdate)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_PROP_OBJ_NIL(TilemapVX, Viewport, Viewport, "viewport")
|
DEF_PROP_OBJ_REF(TilemapVX, Viewport, Viewport, "viewport")
|
||||||
|
DEF_PROP_OBJ_REF(TilemapVX, Table, MapData, "map_data")
|
||||||
DEF_PROP_OBJ(TilemapVX, Table, MapData, "map_data")
|
DEF_PROP_OBJ_REF(TilemapVX, Table, FlashData, "flash_data")
|
||||||
DEF_PROP_OBJ(TilemapVX, Table, FlashData, "flash_data")
|
DEF_PROP_OBJ_REF(TilemapVX, Table, Flags, "flags")
|
||||||
DEF_PROP_OBJ(TilemapVX, Table, Flags, "flags")
|
|
||||||
|
|
||||||
DEF_PROP_B(TilemapVX, Visible)
|
DEF_PROP_B(TilemapVX, Visible)
|
||||||
|
|
||||||
|
|
|
@ -62,9 +62,7 @@ RB_METHOD(viewportInitialize)
|
||||||
setPrivateData(self, v);
|
setPrivateData(self, v);
|
||||||
|
|
||||||
/* Wrap property objects */
|
/* Wrap property objects */
|
||||||
v->setRect(new Rect(*v->getRect()));
|
v->initDynAttribs();
|
||||||
v->setColor(new Color);
|
|
||||||
v->setTone(new Tone);
|
|
||||||
|
|
||||||
wrapProperty(self, v->getRect(), "rect", RectType);
|
wrapProperty(self, v->getRect(), "rect", RectType);
|
||||||
wrapProperty(self, v->getColor(), "color", ColorType);
|
wrapProperty(self, v->getColor(), "color", ColorType);
|
||||||
|
@ -78,9 +76,9 @@ RB_METHOD(viewportInitialize)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_PROP_OBJ(Viewport, Rect, Rect, "rect")
|
DEF_PROP_OBJ_VAL(Viewport, Rect, Rect, "rect")
|
||||||
DEF_PROP_OBJ(Viewport, Color, Color, "color")
|
DEF_PROP_OBJ_VAL(Viewport, Color, Color, "color")
|
||||||
DEF_PROP_OBJ(Viewport, Tone, Tone, "tone")
|
DEF_PROP_OBJ_VAL(Viewport, Tone, Tone, "tone")
|
||||||
|
|
||||||
DEF_PROP_I(Viewport, OX)
|
DEF_PROP_I(Viewport, OX)
|
||||||
DEF_PROP_I(Viewport, OY)
|
DEF_PROP_I(Viewport, OY)
|
||||||
|
|
|
@ -32,7 +32,8 @@ RB_METHOD(windowInitialize)
|
||||||
|
|
||||||
setPrivateData(self, w);
|
setPrivateData(self, w);
|
||||||
|
|
||||||
w->setCursorRect(new Rect);
|
w->initDynAttribs();
|
||||||
|
|
||||||
wrapNilProperty(self, "windowskin");
|
wrapNilProperty(self, "windowskin");
|
||||||
wrapNilProperty(self, "contents");
|
wrapNilProperty(self, "contents");
|
||||||
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
|
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
|
||||||
|
@ -51,9 +52,9 @@ RB_METHOD(windowUpdate)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_PROP_OBJ_NIL(Window, Bitmap, Windowskin, "windowskin")
|
DEF_PROP_OBJ_REF(Window, Bitmap, Windowskin, "windowskin")
|
||||||
DEF_PROP_OBJ_NIL(Window, Bitmap, Contents, "contents")
|
DEF_PROP_OBJ_REF(Window, Bitmap, Contents, "contents")
|
||||||
DEF_PROP_OBJ(Window, Rect, CursorRect, "cursor_rect")
|
DEF_PROP_OBJ_VAL(Window, Rect, CursorRect, "cursor_rect")
|
||||||
|
|
||||||
DEF_PROP_B(Window, Stretch)
|
DEF_PROP_B(Window, Stretch)
|
||||||
DEF_PROP_B(Window, Active)
|
DEF_PROP_B(Window, Active)
|
||||||
|
|
|
@ -51,8 +51,8 @@ RB_METHOD(windowVXInitialize)
|
||||||
|
|
||||||
setPrivateData(self, w);
|
setPrivateData(self, w);
|
||||||
|
|
||||||
w->setCursorRect(new Rect);
|
w->initDynAttribs();
|
||||||
w->setTone(new Tone);
|
|
||||||
wrapNilProperty(self, "windowskin");
|
wrapNilProperty(self, "windowskin");
|
||||||
wrapProperty(self, w->getTone(), "tone", ToneType);
|
wrapProperty(self, w->getTone(), "tone", ToneType);
|
||||||
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
|
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
|
||||||
|
@ -109,11 +109,11 @@ RB_METHOD(windowVXIsClosed)
|
||||||
return rb_bool_new(w->isClosed());
|
return rb_bool_new(w->isClosed());
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_PROP_OBJ_NIL(WindowVX, Bitmap, Windowskin, "windowskin")
|
DEF_PROP_OBJ_REF(WindowVX, Bitmap, Windowskin, "windowskin")
|
||||||
DEF_PROP_OBJ_NIL(WindowVX, Bitmap, Contents, "contents")
|
DEF_PROP_OBJ_REF(WindowVX, Bitmap, Contents, "contents")
|
||||||
|
|
||||||
DEF_PROP_OBJ(WindowVX, Rect, CursorRect, "cursor_rect")
|
DEF_PROP_OBJ_VAL(WindowVX, Rect, CursorRect, "cursor_rect")
|
||||||
DEF_PROP_OBJ(WindowVX, Tone, Tone, "tone")
|
DEF_PROP_OBJ_VAL(WindowVX, Tone, Tone, "tone")
|
||||||
|
|
||||||
DEF_PROP_I(WindowVX, X)
|
DEF_PROP_I(WindowVX, X)
|
||||||
DEF_PROP_I(WindowVX, Y)
|
DEF_PROP_I(WindowVX, Y)
|
||||||
|
|
|
@ -1067,7 +1067,17 @@ IntRect Bitmap::textSize(const char *str)
|
||||||
return IntRect(0, 0, w, h);
|
return IntRect(0, 0, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_ATTR_SIMPLE(Bitmap, Font, Font*, p->font)
|
DEF_ATTR_RD_SIMPLE(Bitmap, Font, Font*, p->font)
|
||||||
|
|
||||||
|
void Bitmap::setFont(Font *value)
|
||||||
|
{
|
||||||
|
*p->font = *value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bitmap::setInitFont(Font *value)
|
||||||
|
{
|
||||||
|
p->font = value;
|
||||||
|
}
|
||||||
|
|
||||||
TEXFBO &Bitmap::getGLTypes()
|
TEXFBO &Bitmap::getGLTypes()
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,6 +101,10 @@ public:
|
||||||
|
|
||||||
DECL_ATTR(Font, Font*)
|
DECL_ATTR(Font, Font*)
|
||||||
|
|
||||||
|
/* Sets initial reference without copying by value,
|
||||||
|
* use at construction */
|
||||||
|
void setInitFont(Font *value);
|
||||||
|
|
||||||
/* <internal> */
|
/* <internal> */
|
||||||
TEXFBO &getGLTypes();
|
TEXFBO &getGLTypes();
|
||||||
SDL_Surface *megaSurface() const;
|
SDL_Surface *megaSurface() const;
|
||||||
|
|
104
src/etc.cpp
104
src/etc.cpp
|
@ -52,20 +52,15 @@ bool Color::operator==(const Color &o) const
|
||||||
alpha == o.alpha;
|
alpha == o.alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color::updateInternal()
|
const Color &Color::operator=(const Color &o)
|
||||||
{
|
{
|
||||||
norm.x = red / 255;
|
red = o.red;
|
||||||
norm.y = green / 255;
|
green = o.green;
|
||||||
norm.z = blue / 255;
|
blue = o.blue;
|
||||||
norm.w = alpha / 255;
|
alpha = o.alpha;
|
||||||
}
|
norm = o.norm;
|
||||||
|
|
||||||
void Color::updateExternal()
|
return o;
|
||||||
{
|
|
||||||
red = norm.x * 255;
|
|
||||||
green = norm.y * 255;
|
|
||||||
blue = norm.z * 255;
|
|
||||||
alpha = norm.w * 255;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color::set(double red, double green, double blue, double alpha)
|
void Color::set(double red, double green, double blue, double alpha)
|
||||||
|
@ -78,15 +73,6 @@ void Color::set(double red, double green, double blue, double alpha)
|
||||||
updateInternal();
|
updateInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color::set(const Color &other)
|
|
||||||
{
|
|
||||||
red = other.red;
|
|
||||||
green = other.green;
|
|
||||||
blue = other.blue;
|
|
||||||
alpha = other.alpha;
|
|
||||||
norm = other.norm;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Color::setRed(double value)
|
void Color::setRed(double value)
|
||||||
{
|
{
|
||||||
red = value;
|
red = value;
|
||||||
|
@ -111,15 +97,6 @@ void Color::setAlpha(double value)
|
||||||
norm.w = clamp<double>(value, 0, 255) / 255;
|
norm.w = clamp<double>(value, 0, 255) / 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Color::toSDLColor(SDL_Color &c) const
|
|
||||||
{
|
|
||||||
c.r = clamp<double>(red, 0, 255);
|
|
||||||
c.g = clamp<double>(green, 0, 255);
|
|
||||||
c.b = clamp<double>(blue, 0, 255);
|
|
||||||
// c.a = clamp<double>(alpha, 0, 255);
|
|
||||||
c.a = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Serializable */
|
/* Serializable */
|
||||||
int Color::serialSize() const
|
int Color::serialSize() const
|
||||||
{
|
{
|
||||||
|
@ -153,6 +130,31 @@ Color *Color::deserialize(const char *data, int len)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Color::updateInternal()
|
||||||
|
{
|
||||||
|
norm.x = red / 255;
|
||||||
|
norm.y = green / 255;
|
||||||
|
norm.z = blue / 255;
|
||||||
|
norm.w = alpha / 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Color::updateExternal()
|
||||||
|
{
|
||||||
|
red = norm.x * 255;
|
||||||
|
green = norm.y * 255;
|
||||||
|
blue = norm.z * 255;
|
||||||
|
alpha = norm.w * 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Color::toSDLColor(SDL_Color &c) const
|
||||||
|
{
|
||||||
|
c.r = clamp<double>(red, 0, 255);
|
||||||
|
c.g = clamp<double>(green, 0, 255);
|
||||||
|
c.b = clamp<double>(blue, 0, 255);
|
||||||
|
// c.a = clamp<double>(alpha, 0, 255);
|
||||||
|
c.a = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Tone::Tone(double red, double green, double blue, double gray)
|
Tone::Tone(double red, double green, double blue, double gray)
|
||||||
: red(red), green(green), blue(blue), gray(gray)
|
: red(red), green(green), blue(blue), gray(gray)
|
||||||
|
@ -173,14 +175,6 @@ bool Tone::operator==(const Tone &o) const
|
||||||
gray == o.gray;
|
gray == o.gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tone::updateInternal()
|
|
||||||
{
|
|
||||||
norm.x = (float) clamp<double>(red, -255, 255) / 255;
|
|
||||||
norm.y = (float) clamp<double>(green, -255, 255) / 255;
|
|
||||||
norm.z = (float) clamp<double>(blue, -255, 255) / 255;
|
|
||||||
norm.w = (float) clamp<double>(gray, 0, 255) / 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Tone::set(double red, double green, double blue, double gray)
|
void Tone::set(double red, double green, double blue, double gray)
|
||||||
{
|
{
|
||||||
this->red = red;
|
this->red = red;
|
||||||
|
@ -192,15 +186,17 @@ void Tone::set(double red, double green, double blue, double gray)
|
||||||
valueChanged();
|
valueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tone::set(const Tone &other)
|
const Tone& Tone::operator=(const Tone &o)
|
||||||
{
|
{
|
||||||
red = other.red;
|
red = o.red;
|
||||||
green= other.green;
|
green = o.green;
|
||||||
blue = other.blue;
|
blue = o.blue;
|
||||||
gray = other.gray;
|
gray = o.gray;
|
||||||
norm = other.norm;
|
norm = o.norm;
|
||||||
|
|
||||||
valueChanged();
|
valueChanged();
|
||||||
|
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tone::setRed(double value)
|
void Tone::setRed(double value)
|
||||||
|
@ -268,6 +264,14 @@ Tone *Tone::deserialize(const char *data, int len)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tone::updateInternal()
|
||||||
|
{
|
||||||
|
norm.x = (float) clamp<double>(red, -255, 255) / 255;
|
||||||
|
norm.y = (float) clamp<double>(green, -255, 255) / 255;
|
||||||
|
norm.z = (float) clamp<double>(blue, -255, 255) / 255;
|
||||||
|
norm.w = (float) clamp<double>(gray, 0, 255) / 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Rect::Rect(int x, int y, int width, int height)
|
Rect::Rect(int x, int y, int width, int height)
|
||||||
: x(x), y(y), width(width), height(height)
|
: x(x), y(y), width(width), height(height)
|
||||||
|
@ -315,14 +319,16 @@ void Rect::set(int x, int y, int w, int h)
|
||||||
valueChanged();
|
valueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rect::set(const Rect &other)
|
const Rect &Rect::operator=(const Rect &o)
|
||||||
{
|
{
|
||||||
x = other.x;
|
x = o.x;
|
||||||
y = other.y;
|
y = o.y;
|
||||||
width = other.width;
|
width = o.width;
|
||||||
height = other.height;
|
height = o.height;
|
||||||
|
|
||||||
valueChanged();
|
valueChanged();
|
||||||
|
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rect::empty()
|
void Rect::empty()
|
||||||
|
|
64
src/etc.h
64
src/etc.h
|
@ -50,13 +50,10 @@ struct Color : public Serializable
|
||||||
|
|
||||||
virtual ~Color() {}
|
virtual ~Color() {}
|
||||||
|
|
||||||
bool operator==(const Color &o) const;
|
const Color &operator=(const Color &o);
|
||||||
|
|
||||||
void updateInternal();
|
|
||||||
void updateExternal();
|
|
||||||
|
|
||||||
void set(double red, double green, double blue, double alpha);
|
void set(double red, double green, double blue, double alpha);
|
||||||
void set(const Color &other);
|
|
||||||
|
bool operator==(const Color &o) const;
|
||||||
|
|
||||||
void setRed(double value);
|
void setRed(double value);
|
||||||
void setGreen(double value);
|
void setGreen(double value);
|
||||||
|
@ -68,6 +65,15 @@ struct Color : public Serializable
|
||||||
double getBlue() const { return blue; }
|
double getBlue() const { return blue; }
|
||||||
double getAlpha() const { return alpha; }
|
double getAlpha() const { return alpha; }
|
||||||
|
|
||||||
|
/* Serializable */
|
||||||
|
int serialSize() const;
|
||||||
|
void serialize(char *buffer) const;
|
||||||
|
static Color *deserialize(const char *data, int len);
|
||||||
|
|
||||||
|
/* Internal */
|
||||||
|
void updateInternal();
|
||||||
|
void updateExternal();
|
||||||
|
|
||||||
bool hasEffect() const
|
bool hasEffect() const
|
||||||
{
|
{
|
||||||
return (alpha != 0);
|
return (alpha != 0);
|
||||||
|
@ -75,11 +81,6 @@ struct Color : public Serializable
|
||||||
|
|
||||||
void toSDLColor(SDL_Color &c) const;
|
void toSDLColor(SDL_Color &c) const;
|
||||||
|
|
||||||
/* Serializable */
|
|
||||||
int serialSize() const;
|
|
||||||
void serialize(char *buffer) const;
|
|
||||||
static Color *deserialize(const char *data, int len);
|
|
||||||
|
|
||||||
/* Range (0.0 ~ 255.0) */
|
/* Range (0.0 ~ 255.0) */
|
||||||
double red;
|
double red;
|
||||||
double green;
|
double green;
|
||||||
|
@ -103,10 +104,8 @@ struct Tone : public Serializable
|
||||||
|
|
||||||
bool operator==(const Tone &o) const;
|
bool operator==(const Tone &o) const;
|
||||||
|
|
||||||
void updateInternal();
|
|
||||||
|
|
||||||
void set(double red, double green, double blue, double gray);
|
void set(double red, double green, double blue, double gray);
|
||||||
void set(const Tone &other);
|
const Tone &operator=(const Tone &o);
|
||||||
|
|
||||||
void setRed(double value);
|
void setRed(double value);
|
||||||
void setGreen(double value);
|
void setGreen(double value);
|
||||||
|
@ -118,6 +117,14 @@ struct Tone : public Serializable
|
||||||
double getBlue() const { return blue; }
|
double getBlue() const { return blue; }
|
||||||
double getGray() const { return gray; }
|
double getGray() const { return gray; }
|
||||||
|
|
||||||
|
/* Serializable */
|
||||||
|
int serialSize() const;
|
||||||
|
void serialize(char *buffer) const;
|
||||||
|
static Tone *deserialize(const char *data, int len);
|
||||||
|
|
||||||
|
/* Internal */
|
||||||
|
void updateInternal();
|
||||||
|
|
||||||
bool hasEffect() const
|
bool hasEffect() const
|
||||||
{
|
{
|
||||||
return ((int)red != 0 ||
|
return ((int)red != 0 ||
|
||||||
|
@ -126,11 +133,6 @@ struct Tone : public Serializable
|
||||||
(int)gray != 0);
|
(int)gray != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Serializable */
|
|
||||||
int serialSize() const;
|
|
||||||
void serialize(char *buffer) const;
|
|
||||||
static Tone *deserialize(const char *data, int len);
|
|
||||||
|
|
||||||
/* Range (-255.0 ~ 255.0) */
|
/* Range (-255.0 ~ 255.0) */
|
||||||
double red;
|
double red;
|
||||||
double green;
|
double green;
|
||||||
|
@ -159,17 +161,7 @@ struct Rect : public Serializable
|
||||||
bool operator==(const Rect &o) const;
|
bool operator==(const Rect &o) const;
|
||||||
void operator=(const IntRect &rect);
|
void operator=(const IntRect &rect);
|
||||||
void set(int x, int y, int w, int h);
|
void set(int x, int y, int w, int h);
|
||||||
void set(const Rect &other);
|
const Rect &operator=(const Rect &o);
|
||||||
|
|
||||||
FloatRect toFloatRect() const
|
|
||||||
{
|
|
||||||
return FloatRect(x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
IntRect toIntRect()
|
|
||||||
{
|
|
||||||
return IntRect(x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void empty();
|
void empty();
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
@ -184,10 +176,22 @@ struct Rect : public Serializable
|
||||||
int getWidth() const { return width; }
|
int getWidth() const { return width; }
|
||||||
int getHeight() const { return height; }
|
int getHeight() const { return height; }
|
||||||
|
|
||||||
|
/* Serializable */
|
||||||
int serialSize() const;
|
int serialSize() const;
|
||||||
void serialize(char *buffer) const;
|
void serialize(char *buffer) const;
|
||||||
static Rect *deserialize(const char *data, int len);
|
static Rect *deserialize(const char *data, int len);
|
||||||
|
|
||||||
|
/* Internal */
|
||||||
|
FloatRect toFloatRect() const
|
||||||
|
{
|
||||||
|
return FloatRect(x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
IntRect toIntRect()
|
||||||
|
{
|
||||||
|
return IntRect(x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int width;
|
int width;
|
||||||
|
|
57
src/font.cpp
57
src/font.cpp
|
@ -255,6 +255,20 @@ struct FontPrivate
|
||||||
outColorTmp(*other.outColor),
|
outColorTmp(*other.outColor),
|
||||||
sdlFont(other.sdlFont)
|
sdlFont(other.sdlFont)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void operator=(const FontPrivate &o)
|
||||||
|
{
|
||||||
|
name = o.name;
|
||||||
|
size = o.size;
|
||||||
|
bold = o.bold;
|
||||||
|
italic = o.italic;
|
||||||
|
outline = o.outline;
|
||||||
|
shadow = o.shadow;
|
||||||
|
*color = *o.color;
|
||||||
|
*outColor = *o.outColor;
|
||||||
|
|
||||||
|
sdlFont = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string FontPrivate::defaultName = "Arial";
|
std::string FontPrivate::defaultName = "Arial";
|
||||||
|
@ -269,12 +283,6 @@ Color *FontPrivate::defaultOutColor = &FontPrivate::defaultOutColorTmp;
|
||||||
Color FontPrivate::defaultColorTmp(255, 255, 255, 255);
|
Color FontPrivate::defaultColorTmp(255, 255, 255, 255);
|
||||||
Color FontPrivate::defaultOutColorTmp(0, 0, 0, 128);
|
Color FontPrivate::defaultOutColorTmp(0, 0, 0, 128);
|
||||||
|
|
||||||
void Font::initDefaults()
|
|
||||||
{
|
|
||||||
FontPrivate::defaultOutline = (rgssVer >= 3 ? true : false);
|
|
||||||
FontPrivate::defaultShadow = (rgssVer >= 3 ? false : true );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Font::doesExist(const char *name)
|
bool Font::doesExist(const char *name)
|
||||||
{
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
|
@ -299,6 +307,13 @@ Font::~Font()
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Font &Font::operator=(const Font &o)
|
||||||
|
{
|
||||||
|
*p = *o.p;
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
const char *Font::getName() const
|
const char *Font::getName() const
|
||||||
{
|
{
|
||||||
return p->name.c_str();
|
return p->name.c_str();
|
||||||
|
@ -332,18 +347,18 @@ void Font::setSize(int value)
|
||||||
DEF_ATTR_RD_SIMPLE(Font, Size, int, p->size)
|
DEF_ATTR_RD_SIMPLE(Font, Size, int, p->size)
|
||||||
DEF_ATTR_SIMPLE (Font, Bold, bool, p->bold)
|
DEF_ATTR_SIMPLE (Font, Bold, bool, p->bold)
|
||||||
DEF_ATTR_SIMPLE (Font, Italic, bool, p->italic)
|
DEF_ATTR_SIMPLE (Font, Italic, bool, p->italic)
|
||||||
DEF_ATTR_SIMPLE(Font, Color, Color*, p->color)
|
|
||||||
DEF_ATTR_SIMPLE (Font, Shadow, bool, p->shadow)
|
DEF_ATTR_SIMPLE (Font, Shadow, bool, p->shadow)
|
||||||
DEF_ATTR_SIMPLE (Font, Outline, bool, p->outline)
|
DEF_ATTR_SIMPLE (Font, Outline, bool, p->outline)
|
||||||
DEF_ATTR_SIMPLE(Font, OutColor, Color*, p->outColor)
|
DEF_ATTR_OBJ_VALUE(Font, Color, Color*, p->color)
|
||||||
|
DEF_ATTR_OBJ_VALUE(Font, OutColor, Color*, p->outColor)
|
||||||
|
|
||||||
DEF_ATTR_SIMPLE_STATIC (Font, DefaultSize, int, FontPrivate::defaultSize)
|
DEF_ATTR_SIMPLE_STATIC (Font, DefaultSize, int, FontPrivate::defaultSize)
|
||||||
DEF_ATTR_SIMPLE_STATIC (Font, DefaultBold, bool, FontPrivate::defaultBold)
|
DEF_ATTR_SIMPLE_STATIC (Font, DefaultBold, bool, FontPrivate::defaultBold)
|
||||||
DEF_ATTR_SIMPLE_STATIC (Font, DefaultItalic, bool, FontPrivate::defaultItalic)
|
DEF_ATTR_SIMPLE_STATIC (Font, DefaultItalic, bool, FontPrivate::defaultItalic)
|
||||||
DEF_ATTR_SIMPLE_STATIC(Font, DefaultColor, Color*, FontPrivate::defaultColor)
|
|
||||||
DEF_ATTR_SIMPLE_STATIC (Font, DefaultShadow, bool, FontPrivate::defaultShadow)
|
DEF_ATTR_SIMPLE_STATIC (Font, DefaultShadow, bool, FontPrivate::defaultShadow)
|
||||||
DEF_ATTR_SIMPLE_STATIC (Font, DefaultOutline, bool, FontPrivate::defaultOutline)
|
DEF_ATTR_SIMPLE_STATIC (Font, DefaultOutline, bool, FontPrivate::defaultOutline)
|
||||||
DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutColor, Color*, FontPrivate::defaultOutColor)
|
DEF_ATTR_OBJ_VALUE_STATIC(Font, DefaultColor, Color*, FontPrivate::defaultColor)
|
||||||
|
DEF_ATTR_OBJ_VALUE_STATIC(Font, DefaultOutColor, Color*, FontPrivate::defaultOutColor)
|
||||||
|
|
||||||
const char *Font::getDefaultName()
|
const char *Font::getDefaultName()
|
||||||
{
|
{
|
||||||
|
@ -355,6 +370,28 @@ void Font::setDefaultName(const char *value)
|
||||||
FontPrivate::defaultName = value;
|
FontPrivate::defaultName = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Font::initDynAttribs()
|
||||||
|
{
|
||||||
|
p->color = new Color(p->colorTmp);
|
||||||
|
|
||||||
|
if (rgssVer >= 3)
|
||||||
|
p->outColor = new Color(p->outColorTmp);;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Font::initDefaultDynAttribs()
|
||||||
|
{
|
||||||
|
FontPrivate::defaultColor = new Color(FontPrivate::defaultColorTmp);
|
||||||
|
|
||||||
|
if (rgssVer >= 3)
|
||||||
|
FontPrivate::defaultOutColor = new Color(FontPrivate::defaultOutColorTmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Font::initDefaults()
|
||||||
|
{
|
||||||
|
FontPrivate::defaultOutline = (rgssVer >= 3 ? true : false);
|
||||||
|
FontPrivate::defaultShadow = (rgssVer >= 3 ? false : true );
|
||||||
|
}
|
||||||
|
|
||||||
_TTF_Font *Font::getSdlFont()
|
_TTF_Font *Font::getSdlFont()
|
||||||
{
|
{
|
||||||
if (!p->sdlFont)
|
if (!p->sdlFont)
|
||||||
|
|
|
@ -82,6 +82,8 @@ public:
|
||||||
Font(const Font &other);
|
Font(const Font &other);
|
||||||
~Font();
|
~Font();
|
||||||
|
|
||||||
|
const Font &operator=(const Font &o);
|
||||||
|
|
||||||
const char *getName() const;
|
const char *getName() const;
|
||||||
void setName(const char *value);
|
void setName(const char *value);
|
||||||
|
|
||||||
|
@ -102,6 +104,12 @@ public:
|
||||||
DECL_ATTR_STATIC( DefaultOutline, bool )
|
DECL_ATTR_STATIC( DefaultOutline, bool )
|
||||||
DECL_ATTR_STATIC( DefaultOutColor, Color* )
|
DECL_ATTR_STATIC( DefaultOutColor, Color* )
|
||||||
|
|
||||||
|
/* Assigns heap allocated objects to object properties;
|
||||||
|
* using this in pure C++ will cause memory leaks
|
||||||
|
* (ie. only to be used in GCed language bindings */
|
||||||
|
void initDynAttribs();
|
||||||
|
static void initDefaultDynAttribs();
|
||||||
|
|
||||||
static void initDefaults();
|
static void initDefaults();
|
||||||
|
|
||||||
/* internal */
|
/* internal */
|
||||||
|
|
|
@ -164,8 +164,8 @@ DEF_ATTR_RD_SIMPLE(Plane, ZoomY, float, p->zoomY)
|
||||||
DEF_ATTR_RD_SIMPLE(Plane, BlendType, int, p->blendType)
|
DEF_ATTR_RD_SIMPLE(Plane, BlendType, int, p->blendType)
|
||||||
|
|
||||||
DEF_ATTR_SIMPLE (Plane, Opacity, int, p->opacity)
|
DEF_ATTR_SIMPLE (Plane, Opacity, int, p->opacity)
|
||||||
DEF_ATTR_SIMPLE(Plane, Color, Color*, p->color)
|
DEF_ATTR_OBJ_VALUE(Plane, Color, Color*, p->color)
|
||||||
DEF_ATTR_SIMPLE(Plane, Tone, Tone*, p->tone)
|
DEF_ATTR_OBJ_VALUE(Plane, Tone, Tone*, p->tone)
|
||||||
|
|
||||||
Plane::~Plane()
|
Plane::~Plane()
|
||||||
{
|
{
|
||||||
|
@ -238,6 +238,11 @@ void Plane::setBlendType(int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Plane::initDynAttribs()
|
||||||
|
{
|
||||||
|
p->color = new Color;
|
||||||
|
p->tone = new Tone;
|
||||||
|
}
|
||||||
|
|
||||||
void Plane::draw()
|
void Plane::draw()
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,8 @@ public:
|
||||||
DECL_ATTR( Color, Color* )
|
DECL_ATTR( Color, Color* )
|
||||||
DECL_ATTR( Tone, Tone* )
|
DECL_ATTR( Tone, Tone* )
|
||||||
|
|
||||||
|
void initDynAttribs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlanePrivate *p;
|
PlanePrivate *p;
|
||||||
|
|
||||||
|
|
|
@ -304,7 +304,6 @@ Sprite::~Sprite()
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_ATTR_RD_SIMPLE(Sprite, Bitmap, Bitmap*, p->bitmap)
|
DEF_ATTR_RD_SIMPLE(Sprite, Bitmap, Bitmap*, p->bitmap)
|
||||||
DEF_ATTR_RD_SIMPLE(Sprite, SrcRect, Rect*, p->srcRect)
|
|
||||||
DEF_ATTR_RD_SIMPLE(Sprite, X, int, p->trans.getPosition().x)
|
DEF_ATTR_RD_SIMPLE(Sprite, X, int, p->trans.getPosition().x)
|
||||||
DEF_ATTR_RD_SIMPLE(Sprite, Y, int, p->trans.getPosition().y)
|
DEF_ATTR_RD_SIMPLE(Sprite, Y, int, p->trans.getPosition().y)
|
||||||
DEF_ATTR_RD_SIMPLE(Sprite, OX, int, p->trans.getOrigin().x)
|
DEF_ATTR_RD_SIMPLE(Sprite, OX, int, p->trans.getOrigin().x)
|
||||||
|
@ -324,8 +323,10 @@ DEF_ATTR_RD_SIMPLE(Sprite, WavePhase, float, p->wave.phase)
|
||||||
|
|
||||||
DEF_ATTR_SIMPLE (Sprite, BushOpacity, int, p->bushOpacity)
|
DEF_ATTR_SIMPLE (Sprite, BushOpacity, int, p->bushOpacity)
|
||||||
DEF_ATTR_SIMPLE (Sprite, Opacity, int, p->opacity)
|
DEF_ATTR_SIMPLE (Sprite, Opacity, int, p->opacity)
|
||||||
DEF_ATTR_SIMPLE(Sprite, Color, Color*, p->color)
|
|
||||||
DEF_ATTR_SIMPLE(Sprite, Tone, Tone*, p->tone)
|
DEF_ATTR_OBJ_VALUE(Sprite, SrcRect, Rect*, p->srcRect)
|
||||||
|
DEF_ATTR_OBJ_VALUE(Sprite, Color, Color*, p->color)
|
||||||
|
DEF_ATTR_OBJ_VALUE(Sprite, Tone, Tone*, p->tone)
|
||||||
|
|
||||||
void Sprite::setBitmap(Bitmap *bitmap)
|
void Sprite::setBitmap(Bitmap *bitmap)
|
||||||
{
|
{
|
||||||
|
@ -347,18 +348,6 @@ void Sprite::setBitmap(Bitmap *bitmap)
|
||||||
p->wave.dirty = true;
|
p->wave.dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::setSrcRect(Rect *rect)
|
|
||||||
{
|
|
||||||
if (p->srcRect == rect)
|
|
||||||
return;
|
|
||||||
|
|
||||||
p->srcRect = rect;
|
|
||||||
p->updateSrcRectCon();
|
|
||||||
|
|
||||||
if (p->bitmap)
|
|
||||||
p->onSrcRectChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sprite::setX(int value)
|
void Sprite::setX(int value)
|
||||||
{
|
{
|
||||||
if (p->trans.getPosition().x == value)
|
if (p->trans.getPosition().x == value)
|
||||||
|
@ -476,6 +465,15 @@ DEF_WAVE_SETTER(Phase, phase, float)
|
||||||
|
|
||||||
#undef DEF_WAVE_SETTER
|
#undef DEF_WAVE_SETTER
|
||||||
|
|
||||||
|
void Sprite::initDynAttribs()
|
||||||
|
{
|
||||||
|
p->srcRect = new Rect;
|
||||||
|
p->color = new Color;
|
||||||
|
p->tone = new Tone;
|
||||||
|
|
||||||
|
p->updateSrcRectCon();
|
||||||
|
}
|
||||||
|
|
||||||
/* Flashable */
|
/* Flashable */
|
||||||
void Sprite::update()
|
void Sprite::update()
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
DECL_ATTR( WaveSpeed, int )
|
DECL_ATTR( WaveSpeed, int )
|
||||||
DECL_ATTR( WavePhase, float )
|
DECL_ATTR( WavePhase, float )
|
||||||
|
|
||||||
|
void initDynAttribs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SpritePrivate *p;
|
SpritePrivate *p;
|
||||||
|
|
||||||
|
|
14
src/util.h
14
src/util.h
|
@ -137,4 +137,18 @@ inline bool contains(const C &c, const V &v)
|
||||||
#define DEF_ATTR_SIMPLE_STATIC(klass, name, type, location) \
|
#define DEF_ATTR_SIMPLE_STATIC(klass, name, type, location) \
|
||||||
DEF_ATTR_SIMPLE_DETAILED(klass, name, type, location, )
|
DEF_ATTR_SIMPLE_DETAILED(klass, name, type, location, )
|
||||||
|
|
||||||
|
#define DEF_ATTR_OBJ_VALUE(klass, name, type, location) \
|
||||||
|
DEF_ATTR_RD_SIMPLE_DETAILED(klass, name, type, location, const) \
|
||||||
|
void klass :: set##name(type value) \
|
||||||
|
{ \
|
||||||
|
*location = *value; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEF_ATTR_OBJ_VALUE_STATIC(klass, name, type, location) \
|
||||||
|
DEF_ATTR_RD_SIMPLE_DETAILED(klass, name, type, location, ) \
|
||||||
|
void klass :: set##name(type value) \
|
||||||
|
{ \
|
||||||
|
*location = *value; \
|
||||||
|
}
|
||||||
|
|
||||||
#endif // UTIL_H
|
#endif // UTIL_H
|
||||||
|
|
|
@ -141,10 +141,10 @@ Viewport::~Viewport()
|
||||||
|
|
||||||
DEF_ATTR_RD_SIMPLE(Viewport, OX, int, geometry.xOrigin)
|
DEF_ATTR_RD_SIMPLE(Viewport, OX, int, geometry.xOrigin)
|
||||||
DEF_ATTR_RD_SIMPLE(Viewport, OY, int, geometry.yOrigin)
|
DEF_ATTR_RD_SIMPLE(Viewport, OY, int, geometry.yOrigin)
|
||||||
DEF_ATTR_RD_SIMPLE(Viewport, Rect, Rect*, p->rect)
|
|
||||||
|
|
||||||
DEF_ATTR_SIMPLE(Viewport, Color, Color*, p->color)
|
DEF_ATTR_OBJ_VALUE(Viewport, Rect, Rect*, p->rect)
|
||||||
DEF_ATTR_SIMPLE(Viewport, Tone, Tone*, p->tone)
|
DEF_ATTR_OBJ_VALUE(Viewport, Color, Color*, p->color)
|
||||||
|
DEF_ATTR_OBJ_VALUE(Viewport, Tone, Tone*, p->tone)
|
||||||
|
|
||||||
void Viewport::setOX(int value)
|
void Viewport::setOX(int value)
|
||||||
{
|
{
|
||||||
|
@ -164,14 +164,13 @@ void Viewport::setOY(int value)
|
||||||
notifyGeometryChange();
|
notifyGeometryChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewport::setRect(Rect *value)
|
void Viewport::initDynAttribs()
|
||||||
{
|
{
|
||||||
if (p->rect == value)
|
p->rect = new Rect(*p->rect);
|
||||||
return;
|
p->color = new Color;
|
||||||
|
p->tone = new Tone;
|
||||||
|
|
||||||
p->rect = value;
|
|
||||||
p->updateRectCon();
|
p->updateRectCon();
|
||||||
p->onRectChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scene */
|
/* Scene */
|
||||||
|
|
|
@ -43,6 +43,8 @@ public:
|
||||||
DECL_ATTR( Color, Color* )
|
DECL_ATTR( Color, Color* )
|
||||||
DECL_ATTR( Tone, Tone* )
|
DECL_ATTR( Tone, Tone* )
|
||||||
|
|
||||||
|
void initDynAttribs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initViewport(int x, int y, int width, int height);
|
void initViewport(int x, int y, int width, int height);
|
||||||
void geometryChanged();
|
void geometryChanged();
|
||||||
|
|
|
@ -711,7 +711,6 @@ DEF_ATTR_SIMPLE(Window, Y, int, p->position.y)
|
||||||
DEF_ATTR_RD_SIMPLE(Window, Windowskin, Bitmap*, p->windowskin)
|
DEF_ATTR_RD_SIMPLE(Window, Windowskin, Bitmap*, p->windowskin)
|
||||||
DEF_ATTR_RD_SIMPLE(Window, Contents, Bitmap*, p->contents)
|
DEF_ATTR_RD_SIMPLE(Window, Contents, Bitmap*, p->contents)
|
||||||
DEF_ATTR_RD_SIMPLE(Window, Stretch, bool, p->bgStretch)
|
DEF_ATTR_RD_SIMPLE(Window, Stretch, bool, p->bgStretch)
|
||||||
DEF_ATTR_RD_SIMPLE(Window, CursorRect, Rect*, p->cursorRect)
|
|
||||||
DEF_ATTR_RD_SIMPLE(Window, Active, bool, p->active)
|
DEF_ATTR_RD_SIMPLE(Window, Active, bool, p->active)
|
||||||
DEF_ATTR_RD_SIMPLE(Window, Pause, bool, p->pause)
|
DEF_ATTR_RD_SIMPLE(Window, Pause, bool, p->pause)
|
||||||
DEF_ATTR_RD_SIMPLE(Window, Width, int, p->size.x)
|
DEF_ATTR_RD_SIMPLE(Window, Width, int, p->size.x)
|
||||||
|
@ -722,6 +721,8 @@ DEF_ATTR_RD_SIMPLE(Window, Opacity, int, p->opacity)
|
||||||
DEF_ATTR_RD_SIMPLE(Window, BackOpacity, int, p->backOpacity)
|
DEF_ATTR_RD_SIMPLE(Window, BackOpacity, int, p->backOpacity)
|
||||||
DEF_ATTR_RD_SIMPLE(Window, ContentsOpacity, int, p->contentsOpacity)
|
DEF_ATTR_RD_SIMPLE(Window, ContentsOpacity, int, p->contentsOpacity)
|
||||||
|
|
||||||
|
DEF_ATTR_OBJ_VALUE(Window, CursorRect, Rect*, p->cursorRect)
|
||||||
|
|
||||||
void Window::setWindowskin(Bitmap *value)
|
void Window::setWindowskin(Bitmap *value)
|
||||||
{
|
{
|
||||||
p->windowskin = value;
|
p->windowskin = value;
|
||||||
|
@ -758,17 +759,6 @@ void Window::setStretch(bool value)
|
||||||
p->baseVertDirty = true;
|
p->baseVertDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::setCursorRect(Rect *value)
|
|
||||||
{
|
|
||||||
if (p->cursorRect == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
p->cursorRect = value;
|
|
||||||
|
|
||||||
p->refreshCursorRectCon();
|
|
||||||
p->markControlVertDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::setActive(bool value)
|
void Window::setActive(bool value)
|
||||||
{
|
{
|
||||||
if (p->active == value)
|
if (p->active == value)
|
||||||
|
@ -852,6 +842,13 @@ void Window::setContentsOpacity(int value)
|
||||||
p->contentsQuad.setColor(Vec4(1, 1, 1, p->contentsOpacity.norm));
|
p->contentsQuad.setColor(Vec4(1, 1, 1, p->contentsOpacity.norm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::initDynAttribs()
|
||||||
|
{
|
||||||
|
p->cursorRect = new Rect;
|
||||||
|
|
||||||
|
p->refreshCursorRectCon();
|
||||||
|
}
|
||||||
|
|
||||||
void Window::draw()
|
void Window::draw()
|
||||||
{
|
{
|
||||||
p->drawBase();
|
p->drawBase();
|
||||||
|
|
|
@ -56,6 +56,8 @@ public:
|
||||||
DECL_ATTR( BackOpacity, int )
|
DECL_ATTR( BackOpacity, int )
|
||||||
DECL_ATTR( ContentsOpacity, int )
|
DECL_ATTR( ContentsOpacity, int )
|
||||||
|
|
||||||
|
void initDynAttribs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WindowPrivate *p;
|
WindowPrivate *p;
|
||||||
|
|
||||||
|
|
|
@ -870,7 +870,6 @@ DEF_ATTR_SIMPLE(WindowVX, Y, int, p->geo.y)
|
||||||
|
|
||||||
DEF_ATTR_RD_SIMPLE(WindowVX, Windowskin, Bitmap*, p->windowskin)
|
DEF_ATTR_RD_SIMPLE(WindowVX, Windowskin, Bitmap*, p->windowskin)
|
||||||
DEF_ATTR_RD_SIMPLE(WindowVX, Contents, Bitmap*, p->contents)
|
DEF_ATTR_RD_SIMPLE(WindowVX, Contents, Bitmap*, p->contents)
|
||||||
DEF_ATTR_RD_SIMPLE(WindowVX, CursorRect, Rect*, p->cursorRect)
|
|
||||||
DEF_ATTR_RD_SIMPLE(WindowVX, Active, bool, p->active)
|
DEF_ATTR_RD_SIMPLE(WindowVX, Active, bool, p->active)
|
||||||
DEF_ATTR_RD_SIMPLE(WindowVX, ArrowsVisible, bool, p->arrowsVisible)
|
DEF_ATTR_RD_SIMPLE(WindowVX, ArrowsVisible, bool, p->arrowsVisible)
|
||||||
DEF_ATTR_RD_SIMPLE(WindowVX, Pause, bool, p->pause)
|
DEF_ATTR_RD_SIMPLE(WindowVX, Pause, bool, p->pause)
|
||||||
|
@ -884,7 +883,9 @@ DEF_ATTR_RD_SIMPLE(WindowVX, Opacity, int, p->opacity)
|
||||||
DEF_ATTR_RD_SIMPLE(WindowVX, BackOpacity, int, p->backOpacity)
|
DEF_ATTR_RD_SIMPLE(WindowVX, BackOpacity, int, p->backOpacity)
|
||||||
DEF_ATTR_RD_SIMPLE(WindowVX, ContentsOpacity, int, p->contentsOpacity)
|
DEF_ATTR_RD_SIMPLE(WindowVX, ContentsOpacity, int, p->contentsOpacity)
|
||||||
DEF_ATTR_RD_SIMPLE(WindowVX, Openness, int, p->openness)
|
DEF_ATTR_RD_SIMPLE(WindowVX, Openness, int, p->openness)
|
||||||
DEF_ATTR_RD_SIMPLE(WindowVX, Tone, Tone*, p->tone)
|
|
||||||
|
DEF_ATTR_OBJ_VALUE(WindowVX, CursorRect, Rect*, p->cursorRect)
|
||||||
|
DEF_ATTR_OBJ_VALUE(WindowVX, Tone, Tone*, p->tone)
|
||||||
|
|
||||||
void WindowVX::setWindowskin(Bitmap *value)
|
void WindowVX::setWindowskin(Bitmap *value)
|
||||||
{
|
{
|
||||||
|
@ -909,16 +910,6 @@ void WindowVX::setContents(Bitmap *value)
|
||||||
p->ctrlVertDirty = true;
|
p->ctrlVertDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowVX::setCursorRect(Rect *value)
|
|
||||||
{
|
|
||||||
if (p->cursorRect == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
p->cursorRect = value;
|
|
||||||
p->cursorVertDirty = true;
|
|
||||||
p->refreshCursorRectCon();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowVX::setActive(bool value)
|
void WindowVX::setActive(bool value)
|
||||||
{
|
{
|
||||||
if (p->active == value)
|
if (p->active == value)
|
||||||
|
@ -1050,12 +1041,12 @@ void WindowVX::setOpenness(int value)
|
||||||
p->updateBaseQuad();
|
p->updateBaseQuad();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowVX::setTone(Tone *value)
|
void WindowVX::initDynAttribs()
|
||||||
{
|
{
|
||||||
if (p->tone == value)
|
p->cursorRect = new Rect;
|
||||||
return;
|
p->tone = new Tone;
|
||||||
|
|
||||||
p->tone = value;
|
p->refreshCursorRectCon();
|
||||||
p->refreshToneCon();
|
p->refreshToneCon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,8 @@ public:
|
||||||
DECL_ATTR( Openness, int )
|
DECL_ATTR( Openness, int )
|
||||||
DECL_ATTR( Tone, Tone* )
|
DECL_ATTR( Tone, Tone* )
|
||||||
|
|
||||||
|
void initDynAttribs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WindowVXPrivate *p;
|
WindowVXPrivate *p;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue