Etc: Implement missing RGSS3 functionality (and bind in MRI)
This commit is contained in:
		
							parent
							
								
									0c5e84eb4b
								
							
						
					
					
						commit
						5bc6f6f32c
					
				
					 3 changed files with 58 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -79,9 +79,17 @@ EQUAL_FUN(Rect)
 | 
			
		|||
#define INIT_FUN(Klass, param_type, param_t_s, last_param_def) \
 | 
			
		||||
	RB_METHOD(Klass##Initialize) \
 | 
			
		||||
	{ \
 | 
			
		||||
		param_type p1, p2, p3, p4 = last_param_def; \
 | 
			
		||||
		rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
 | 
			
		||||
		Klass *k = new Klass(p1, p2, p3, p4); \
 | 
			
		||||
		Klass *k; \
 | 
			
		||||
		if (argc == 0) \
 | 
			
		||||
		{ \
 | 
			
		||||
			k = new Klass(); \
 | 
			
		||||
		} \
 | 
			
		||||
		else \
 | 
			
		||||
		{ \
 | 
			
		||||
			param_type p1, p2, p3, p4 = last_param_def; \
 | 
			
		||||
			rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
 | 
			
		||||
			k = new Klass(p1, p2, p3, p4); \
 | 
			
		||||
		} \
 | 
			
		||||
		setPrivateData(self, k); \
 | 
			
		||||
		return self; \
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -93,10 +101,19 @@ INIT_FUN(Rect, int, "iiii", 0)
 | 
			
		|||
#define SET_FUN(Klass, param_type, param_t_s, last_param_def) \
 | 
			
		||||
	RB_METHOD(Klass##Set) \
 | 
			
		||||
	{ \
 | 
			
		||||
		param_type p1, p2, p3, p4 = last_param_def; \
 | 
			
		||||
		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); \
 | 
			
		||||
		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; \
 | 
			
		||||
			rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
 | 
			
		||||
			k->set(p1, p2, p3, p4); \
 | 
			
		||||
		} \
 | 
			
		||||
		return self; \
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										30
									
								
								src/etc.cpp
									
										
									
									
									
								
							
							
						
						
									
										30
									
								
								src/etc.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -78,6 +78,15 @@ void Color::set(double red, double green, double blue, double alpha)
 | 
			
		|||
	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)
 | 
			
		||||
{
 | 
			
		||||
	red = value;
 | 
			
		||||
| 
						 | 
				
			
			@ -183,6 +192,17 @@ void Tone::set(double red, double green, double blue, double gray)
 | 
			
		|||
	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)
 | 
			
		||||
{
 | 
			
		||||
	red = value;
 | 
			
		||||
| 
						 | 
				
			
			@ -295,6 +315,16 @@ void Rect::set(int x, int y, int w, int h)
 | 
			
		|||
	valueChanged();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Rect::set(const Rect &other)
 | 
			
		||||
{
 | 
			
		||||
	x      = other.x;
 | 
			
		||||
	y      = other.y;
 | 
			
		||||
	width  = other.width;
 | 
			
		||||
	height = other.height;
 | 
			
		||||
 | 
			
		||||
	valueChanged();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Rect::empty()
 | 
			
		||||
{
 | 
			
		||||
	if (!(x || y || width || height))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,6 +56,8 @@ struct Color : public Serializable
 | 
			
		|||
	void updateExternal();
 | 
			
		||||
 | 
			
		||||
	void set(double red, double green, double blue, double alpha);
 | 
			
		||||
	void set(const Color &other);
 | 
			
		||||
 | 
			
		||||
	void setRed(double value);
 | 
			
		||||
	void setGreen(double value);
 | 
			
		||||
	void setBlue(double value);
 | 
			
		||||
| 
						 | 
				
			
			@ -104,6 +106,8 @@ struct Tone : public Serializable
 | 
			
		|||
	void updateInternal();
 | 
			
		||||
 | 
			
		||||
	void set(double red, double green, double blue, double gray);
 | 
			
		||||
	void set(const Tone &other);
 | 
			
		||||
 | 
			
		||||
	void setRed(double value);
 | 
			
		||||
	void setGreen(double value);
 | 
			
		||||
	void setBlue(double value);
 | 
			
		||||
| 
						 | 
				
			
			@ -155,6 +159,7 @@ struct Rect : public Serializable
 | 
			
		|||
	bool operator==(const Rect &o) const;
 | 
			
		||||
	void operator=(const IntRect &rect);
 | 
			
		||||
	void set(int x, int y, int w, int h);
 | 
			
		||||
	void set(const Rect &other);
 | 
			
		||||
 | 
			
		||||
	FloatRect toFloatRect() const
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue