parent
7f41b9cc45
commit
9461449cc9
9 changed files with 117 additions and 55 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue