Etc: Implement missing RGSS3 functionality (and bind in MRI)

This commit is contained in:
Jonas Kulla 2014-08-15 22:53:42 +02:00
parent 0c5e84eb4b
commit 5bc6f6f32c
3 changed files with 58 additions and 6 deletions

View File

@ -78,10 +78,18 @@ EQUAL_FUN(Rect)
#define INIT_FUN(Klass, param_type, param_t_s, last_param_def) \ #define INIT_FUN(Klass, param_type, param_t_s, last_param_def) \
RB_METHOD(Klass##Initialize) \ RB_METHOD(Klass##Initialize) \
{ \
Klass *k; \
if (argc == 0) \
{ \
k = new Klass(); \
} \
else \
{ \ { \
param_type p1, p2, p3, p4 = last_param_def; \ param_type p1, p2, p3, p4 = last_param_def; \
rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \ rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
Klass *k = new Klass(p1, p2, p3, p4); \ k = new Klass(p1, p2, p3, p4); \
} \
setPrivateData(self, k); \ setPrivateData(self, k); \
return self; \ return self; \
} }
@ -92,11 +100,20 @@ INIT_FUN(Rect, int, "iiii", 0)
#define SET_FUN(Klass, param_type, param_t_s, last_param_def) \ #define SET_FUN(Klass, param_type, param_t_s, last_param_def) \
RB_METHOD(Klass##Set) \ RB_METHOD(Klass##Set) \
{ \
Klass *k = getPrivateData<Klass>(self); \
if (argc == 1) \
{ \
VALUE otherObj = argv[0]; \
Klass *other = getPrivateDataCheck<Klass>(otherObj, Klass##Type); \
k->set(*other); \
} \
else \
{ \ { \
param_type p1, p2, p3, p4 = last_param_def; \ param_type p1, p2, p3, p4 = last_param_def; \
rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \ rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
Klass *k = getPrivateData<Klass>(self); \
k->set(p1, p2, p3, p4); \ k->set(p1, p2, p3, p4); \
} \
return self; \ return self; \
} }

View File

@ -78,6 +78,15 @@ 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;
@ -183,6 +192,17 @@ void Tone::set(double red, double green, double blue, double gray)
valueChanged(); valueChanged();
} }
void Tone::set(const Tone &other)
{
red = other.red;
green= other.green;
blue = other.blue;
gray = other.gray;
norm = other.norm;
valueChanged();
}
void Tone::setRed(double value) void Tone::setRed(double value)
{ {
red = value; red = value;
@ -295,6 +315,16 @@ void Rect::set(int x, int y, int w, int h)
valueChanged(); valueChanged();
} }
void Rect::set(const Rect &other)
{
x = other.x;
y = other.y;
width = other.width;
height = other.height;
valueChanged();
}
void Rect::empty() void Rect::empty()
{ {
if (!(x || y || width || height)) if (!(x || y || width || height))

View File

@ -56,6 +56,8 @@ struct Color : public Serializable
void updateExternal(); 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);
void setRed(double value); void setRed(double value);
void setGreen(double value); void setGreen(double value);
void setBlue(double value); void setBlue(double value);
@ -104,6 +106,8 @@ struct Tone : public Serializable
void updateInternal(); 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);
void setRed(double value); void setRed(double value);
void setGreen(double value); void setGreen(double value);
void setBlue(double value); void setBlue(double value);
@ -155,6 +159,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);
FloatRect toFloatRect() const FloatRect toFloatRect() const
{ {