LiteRGSS 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/ext/LiteRGSS/Bitmap.cpp +316 -0
  3. data/ext/LiteRGSS/Bitmap.h +24 -0
  4. data/ext/LiteRGSS/BlendMode.cpp +202 -0
  5. data/ext/LiteRGSS/BlendMode.h +20 -0
  6. data/ext/LiteRGSS/CBitmap_Element.cpp +50 -0
  7. data/ext/LiteRGSS/CBitmap_Element.h +17 -0
  8. data/ext/LiteRGSS/CDrawable_Element.cpp +38 -0
  9. data/ext/LiteRGSS/CDrawable_Element.h +30 -0
  10. data/ext/LiteRGSS/CRect_Element.h +15 -0
  11. data/ext/LiteRGSS/CShaderSprite_Element.cpp +17 -0
  12. data/ext/LiteRGSS/CShaderSprite_Element.h +17 -0
  13. data/ext/LiteRGSS/CSprite_Element.cpp +15 -0
  14. data/ext/LiteRGSS/CSprite_Element.h +36 -0
  15. data/ext/LiteRGSS/CText_Element.cpp +12 -0
  16. data/ext/LiteRGSS/CText_Element.h +29 -0
  17. data/ext/LiteRGSS/CTone_Element.h +17 -0
  18. data/ext/LiteRGSS/CViewport_Element.cpp +224 -0
  19. data/ext/LiteRGSS/CViewport_Element.h +57 -0
  20. data/ext/LiteRGSS/Color.cpp +200 -0
  21. data/ext/LiteRGSS/Color.h +22 -0
  22. data/ext/LiteRGSS/Fonts.cpp +126 -0
  23. data/ext/LiteRGSS/Fonts.h +20 -0
  24. data/ext/LiteRGSS/Graphics.cpp +314 -0
  25. data/ext/LiteRGSS/Graphics.h +31 -0
  26. data/ext/LiteRGSS/Graphics.local.cpp +365 -0
  27. data/ext/LiteRGSS/Graphics.local.h +37 -0
  28. data/ext/LiteRGSS/Image.cpp +460 -0
  29. data/ext/LiteRGSS/Image.h +32 -0
  30. data/ext/LiteRGSS/Input.cpp +664 -0
  31. data/ext/LiteRGSS/Input.h +38 -0
  32. data/ext/LiteRGSS/LiteRGSS.cpp +34 -0
  33. data/ext/LiteRGSS/LiteRGSS.h +113 -0
  34. data/ext/LiteRGSS/Rect.cpp +324 -0
  35. data/ext/LiteRGSS/Rect.h +24 -0
  36. data/ext/LiteRGSS/Shader.cpp +279 -0
  37. data/ext/LiteRGSS/Shader.h +13 -0
  38. data/ext/LiteRGSS/ShaderSprite.cpp +78 -0
  39. data/ext/LiteRGSS/ShaderSprite.h +8 -0
  40. data/ext/LiteRGSS/Sprite.cpp +495 -0
  41. data/ext/LiteRGSS/Sprite.h +43 -0
  42. data/ext/LiteRGSS/Table.cpp +228 -0
  43. data/ext/LiteRGSS/Table.h +29 -0
  44. data/ext/LiteRGSS/Table32.cpp +228 -0
  45. data/ext/LiteRGSS/Table32.h +29 -0
  46. data/ext/LiteRGSS/Text.cpp +574 -0
  47. data/ext/LiteRGSS/Text.h +52 -0
  48. data/ext/LiteRGSS/Texture.hpp +735 -0
  49. data/ext/LiteRGSS/Tone.cpp +228 -0
  50. data/ext/LiteRGSS/Tone.h +22 -0
  51. data/ext/LiteRGSS/Viewport.cpp +491 -0
  52. data/ext/LiteRGSS/Viewport.h +33 -0
  53. data/ext/LiteRGSS/Yuki.cpp +29 -0
  54. data/ext/LiteRGSS/Yuki.h +8 -0
  55. data/ext/LiteRGSS/Yuki_Gif.cpp +218 -0
  56. data/ext/LiteRGSS/Yuki_Gif.h +25 -0
  57. data/ext/LiteRGSS/extconf.rb +8 -0
  58. data/ext/LiteRGSS/libnsgif.c +1169 -0
  59. data/ext/LiteRGSS/libnsgif.h +183 -0
  60. data/ext/LiteRGSS/libnsgif.hpp +184 -0
  61. data/ext/LiteRGSS/lodepng.cpp +6245 -0
  62. data/ext/LiteRGSS/lodepng.h +1769 -0
  63. data/ext/LiteRGSS/lzw.c +377 -0
  64. data/ext/LiteRGSS/lzw.h +105 -0
  65. data/ext/LiteRGSS/sf_Text2.cpp +690 -0
  66. data/ext/LiteRGSS/sf_Text2.hpp +549 -0
  67. data/ext/LiteRGSS/utils/log.h +21 -0
  68. metadata +112 -0
@@ -0,0 +1,38 @@
1
+ #ifndef L_INPUT_HEADER
2
+ #define L_INPUT_HEADER
3
+
4
+ void L_Input_Reset_Clocks();
5
+ void L_Input_Update_Key(sf::Keyboard::Key code, bool state);
6
+ void L_Input_Update_Joy(unsigned int joy_id, unsigned int key, bool state);
7
+ void L_Input_Update_JoyPos(unsigned int joy_id, long axis, float position);
8
+ void L_Input_Setusec_threshold(long usec);
9
+ void L_Input_Mouse_Pos_Update(int x, int y);
10
+ void L_Input_Mouse_Wheel_Update(long delta);
11
+ void L_Input_Mouse_Button_Update(long button, bool state);
12
+
13
+ VALUE rb_Input_Press(VALUE self, VALUE key_sym);
14
+ VALUE rb_Input_Trigger(VALUE self, VALUE key_sym);
15
+ VALUE rb_Input_Repeat(VALUE self, VALUE key_sym);
16
+ VALUE rb_Input_Released(VALUE self, VALUE key_sym);
17
+ VALUE rb_Input_dir4(VALUE self);
18
+ VALUE rb_Input_dir8(VALUE self);
19
+ VALUE rb_Input_setMainJoypad(VALUE self, VALUE id);
20
+ VALUE rb_Input_setMainXAxis(VALUE self, VALUE axis);
21
+ VALUE rb_Input_setMainYAxis(VALUE self, VALUE axis);
22
+ VALUE rb_Input_getMainJoypad(VALUE self);
23
+ VALUE rb_Input_getMainXAxis(VALUE self);
24
+ VALUE rb_Input_getMainYAxis(VALUE self);
25
+ VALUE rb_Input_getText(VALUE self);
26
+
27
+ VALUE rb_Mouse_Press(VALUE self, VALUE key_sym);
28
+ VALUE rb_Mouse_Trigger(VALUE self, VALUE key_sym);
29
+ VALUE rb_Mouse_Released(VALUE self, VALUE key_sym);
30
+ VALUE rb_Mouse_x(VALUE self);
31
+ VALUE rb_Mouse_y(VALUE self);
32
+ VALUE rb_Mouse_Wheel(VALUE self);
33
+ VALUE rb_Mouse_Wheel_set(VALUE self, VALUE val);
34
+
35
+ VALUE rb_KeyBoard_Press(VALUE self, VALUE val);
36
+
37
+ extern std::string L_EnteredText;
38
+ #endif
@@ -0,0 +1,34 @@
1
+ #include "LiteRGSS.h"
2
+
3
+ VALUE rb_mLiteRGSS = Qnil;
4
+ VALUE rb_mConfig = Qnil;
5
+ VALUE rb_eRGSSError = Qnil;
6
+ ID rb_iElementTable = Qnil;
7
+
8
+ extern "C" {
9
+ void Init_LiteRGSS() {
10
+ rb_mLiteRGSS = rb_define_module("LiteRGSS");
11
+ rb_mConfig = rb_define_module_under(rb_mLiteRGSS, "Config");
12
+ rb_eRGSSError = rb_define_class_under(rb_mLiteRGSS, "Error",rb_eStandardError);
13
+ rb_iElementTable = rb_intern("@__elementtable");
14
+
15
+ Init_Graphics();
16
+ Init_Bitmap();
17
+ Init_Image();
18
+ Init_Sprite();
19
+ Init_Rect();
20
+ Init_Viewport();
21
+ Init_Color();
22
+ Init_Tone();
23
+ Init_Fonts();
24
+ Init_Text();
25
+ Init_Input();
26
+ Init_Table();
27
+ Init_Table32();
28
+ Init_Yuki();
29
+ Init_BlendMode();
30
+ Init_Shader();
31
+ Init_ShaderSprite();
32
+ Init_YukiGifReader();
33
+ }
34
+ }
@@ -0,0 +1,113 @@
1
+ #ifndef LITERGSS_HEADER_FILE
2
+ #define LITERGSS_HEADER_FILE
3
+ #include <iostream>
4
+ #include <vector>
5
+ #include <string>
6
+ #include <cmath>
7
+ #include "ruby.h" // Windows Patch
8
+ #include "Texture.hpp"
9
+ #include <SFML/Graphics.hpp>
10
+ #include "Graphics.h"
11
+ #include "Color.h"
12
+ #include "Tone.h"
13
+ #include "Rect.h"
14
+ #include "Bitmap.h"
15
+ #include "Image.h"
16
+ #include "Viewport.h"
17
+ #include "Sprite.h"
18
+ #include "Fonts.h"
19
+ #include "Text.h"
20
+ #include "Input.h"
21
+ #include "Table.h"
22
+ #include "Table32.h"
23
+ #include "Yuki.h"
24
+ #include "BlendMode.h"
25
+ #include "Shader.h"
26
+ #include "ShaderSprite.h"
27
+ #include "Yuki_Gif.h"
28
+
29
+ #define _rbf (VALUE (*)(...))
30
+
31
+ extern long ScreenWidth;
32
+ extern long ScreenHeight;
33
+ extern unsigned long frame_count;
34
+ extern unsigned long frame_rate;
35
+ extern bool SmoothScreen;
36
+ extern VALUE rb_mLiteRGSS;
37
+ extern VALUE rb_mGraphics;
38
+ extern VALUE rb_mConfig;
39
+ extern VALUE rb_cBitmap;
40
+ extern VALUE rb_cImage;
41
+ extern VALUE rb_cSprite;
42
+ extern VALUE rb_cRect;
43
+ extern VALUE rb_cViewport;
44
+ extern VALUE rb_cColor;
45
+ extern VALUE rb_cTone;
46
+ extern VALUE rb_mFonts;
47
+ extern VALUE rb_cText;
48
+ extern VALUE rb_mInput;
49
+ extern VALUE rb_mMouse;
50
+ extern VALUE rb_cTable;
51
+ extern VALUE rb_cTable32;
52
+ extern VALUE rb_mYuki;
53
+ extern VALUE rb_cYukiGifReader;
54
+ extern VALUE rb_cBlendMode;
55
+ extern VALUE rb_cShader;
56
+ extern VALUE rb_cShaderSprite;
57
+
58
+ extern VALUE rb_eRGSSError;
59
+ extern VALUE rb_eStoppedGraphics;
60
+ extern VALUE rb_eClosedWindow;
61
+
62
+ extern ID rb_iElementTable;
63
+
64
+ void Init_Graphics();
65
+
66
+ void Init_Bitmap();
67
+ void Init_Image();
68
+ void Init_Sprite();
69
+ void Init_Rect();
70
+ void Init_Viewport();
71
+ void Init_Color();
72
+ void Init_Tone();
73
+ void Init_Fonts();
74
+ void Init_Text();
75
+ void Init_Input();
76
+ void Init_Table();
77
+ void Init_Table32();
78
+ void Init_Yuki();
79
+ void Init_Shader();
80
+ void Init_ShaderSprite();
81
+ void Init_YukiGifReader();
82
+ void Init_BlendMode();
83
+
84
+ inline long normalize_long(long value, long min, long max) {
85
+ if(value < min)
86
+ return min;
87
+ if(value > max)
88
+ return max;
89
+ return value;
90
+ }
91
+ inline double normalize_double(double value, double min, double max) {
92
+ if(value < min)
93
+ return min;
94
+ if(value > max)
95
+ return max;
96
+ return value;
97
+ }
98
+
99
+ inline void rect_copy(sf::IntRect* dest, const sf::IntRect* src) {
100
+ dest->left = src->left;
101
+ dest->top = src->top;
102
+ dest->width = src->width;
103
+ dest->height = src->height;
104
+ }
105
+
106
+ inline void tone_copy(sf::Glsl::Vec4* dest, const sf::Glsl::Vec4* src)
107
+ {
108
+ dest->x = src->x;
109
+ dest->y = src->y;
110
+ dest->z = src->z;
111
+ dest->w = src->w;
112
+ }
113
+ #endif
@@ -0,0 +1,324 @@
1
+ #include "LiteRGSS.h"
2
+ #include "CRect_Element.h"
3
+ #include "CViewport_Element.h"
4
+
5
+ VALUE rb_cRect = Qnil;
6
+
7
+ #define RECT_PROTECT if(RDATA(self)->data == nullptr) { rb_raise(rb_eRGSSError, "Disposed Rect.");; }
8
+
9
+ #define GET_RECT CRect_Element* rect; \
10
+ Data_Get_Struct(self, CRect_Element, rect); \
11
+ RECT_PROTECT
12
+
13
+ void __Rect_Check_LinkedObject(CRect_Element* rect);
14
+
15
+ void rb_Rect_Free(void* data)
16
+ {
17
+ CRect_Element* rect = reinterpret_cast<CRect_Element*>(data);
18
+ if(rect)
19
+ {
20
+ CDrawable_Element* element = rect->getElement();
21
+ if(element != nullptr)
22
+ element->setLinkedRect(nullptr);
23
+ delete rect;
24
+ }
25
+ }
26
+
27
+ VALUE rb_Rect_Alloc(VALUE klass)
28
+ {
29
+ CRect_Element* rect = new CRect_Element();
30
+ return Data_Wrap_Struct(klass, NULL, rb_Rect_Free, rect);
31
+ }
32
+
33
+ void Init_Rect()
34
+ {
35
+ rb_cRect = rb_define_class_under(rb_mLiteRGSS, "Rect", rb_cObject);
36
+
37
+ rb_define_alloc_func(rb_cRect, rb_Rect_Alloc);
38
+
39
+ rb_define_method(rb_cRect, "initialize", _rbf rb_Rect_initialize, -1);
40
+ rb_define_method(rb_cRect, "initialize_copy", _rbf rb_Rect_initialize_copy, 1);
41
+ rb_define_method(rb_cRect, "set", _rbf rb_Rect_set, -1);
42
+ rb_define_method(rb_cRect, "x", _rbf rb_Rect_getX, 0);
43
+ rb_define_method(rb_cRect, "x=", _rbf rb_Rect_setX, 1);
44
+ rb_define_method(rb_cRect, "y", _rbf rb_Rect_getY, 0);
45
+ rb_define_method(rb_cRect, "y=", _rbf rb_Rect_setY, 1);
46
+ rb_define_method(rb_cRect, "width", _rbf rb_Rect_getWidth, 0);
47
+ rb_define_method(rb_cRect, "width=", _rbf rb_Rect_setWidth, 1);
48
+ rb_define_method(rb_cRect, "height", _rbf rb_Rect_getHeight, 0);
49
+ rb_define_method(rb_cRect, "height=", _rbf rb_Rect_setHeight, 1);
50
+ rb_define_method(rb_cRect, "==", _rbf rb_Rect_eql, 1);
51
+ rb_define_method(rb_cRect, "===", _rbf rb_Rect_eql, 1);
52
+ rb_define_method(rb_cRect, "eql?", _rbf rb_Rect_eql, 1);
53
+ rb_define_method(rb_cRect, "to_s", _rbf rb_Rect_to_s, 0);
54
+ rb_define_method(rb_cRect, "inspect", _rbf rb_Rect_to_s, 0);
55
+ rb_define_method(rb_cRect, "empty", _rbf rb_Rect_empty, 0);
56
+ rb_define_method(rb_cRect, "_dump", _rbf rb_Rect_save, 1);
57
+ rb_define_singleton_method(rb_cRect, "_load", _rbf rb_Rect_load, 1);
58
+ }
59
+
60
+ /*
61
+ * Initialisation :
62
+ * Rect.new(width, height)
63
+ * Rect.new(x, width, height)
64
+ * Rect.new(x, y, width, height)
65
+ */
66
+ VALUE rb_Rect_initialize(int argc, VALUE* argv, VALUE self)
67
+ {
68
+ VALUE x, y, width, height;
69
+ rb_scan_args(argc, argv, "22", &x, &y, &width, &height);
70
+ GET_RECT
71
+ /* Parameter normalization */
72
+ if(NIL_P(width))
73
+ {
74
+ width = x;
75
+ height = y;
76
+ x = LONG2FIX(0);
77
+ y = LONG2FIX(0);
78
+ }
79
+ else if(NIL_P(height))
80
+ {
81
+ height = width;
82
+ width = y;
83
+ y = LONG2FIX(0);
84
+ }
85
+ /* Rect definition */
86
+ sf::IntRect* srect = rect->getRect();
87
+ srect->left = rb_num2long(x);
88
+ srect->top = rb_num2long(y);
89
+ srect->width = rb_num2long(width);
90
+ srect->height = rb_num2long(height);
91
+ /* Pointed element nullification */
92
+ rect->setElement(nullptr);
93
+ return self;
94
+ }
95
+
96
+ VALUE rb_Rect_initialize_copy(VALUE self, VALUE other)
97
+ {
98
+ GET_RECT
99
+ CRect_Element* rect2;
100
+ Data_Get_Struct(other, CRect_Element, rect2);
101
+ if(RDATA(other)->data == nullptr) { return Qnil; }
102
+ rect_copy(rect->getRect(), rect2->getRect());
103
+ rect->setElement(nullptr);
104
+ return self;
105
+ }
106
+ /*
107
+ * rect.set(x)
108
+ * rect.set(x,y)
109
+ * rect.set(x,y,width)
110
+ * rect.set(x,y,width,height)
111
+ * rect.set(x, nil, width) etc...
112
+ */
113
+ VALUE rb_Rect_set(int argc, VALUE* argv, VALUE self)
114
+ {
115
+ VALUE x, y, width, height;
116
+ rb_scan_args(argc, argv, "13", &x, &y, &width, &height);
117
+ GET_RECT
118
+ sf::IntRect* srect = rect->getRect();
119
+ if(!NIL_P(x))
120
+ srect->left = rb_num2long(x);
121
+ if(!NIL_P(y))
122
+ srect->top = rb_num2long(y);
123
+ if(!NIL_P(width))
124
+ srect->width = rb_num2long(width);
125
+ if(!NIL_P(height))
126
+ srect->height = rb_num2long(height);
127
+ __Rect_Check_LinkedObject(rect);
128
+ return self;
129
+ }
130
+
131
+ VALUE rb_Rect_getX(VALUE self)
132
+ {
133
+ GET_RECT
134
+ return rb_int2inum(rect->getRect()->left);
135
+ }
136
+
137
+ VALUE rb_Rect_setX(VALUE self, VALUE val)
138
+ {
139
+ GET_RECT
140
+ rect->getRect()->left = rb_num2long(val);
141
+ __Rect_Check_LinkedObject(rect);
142
+ return val;
143
+ }
144
+
145
+ VALUE rb_Rect_getY(VALUE self)
146
+ {
147
+ GET_RECT
148
+ return rb_int2inum(rect->getRect()->top);
149
+ }
150
+
151
+ VALUE rb_Rect_setY(VALUE self, VALUE val)
152
+ {
153
+ GET_RECT
154
+ rect->getRect()->top = rb_num2long(val);
155
+ __Rect_Check_LinkedObject(rect);
156
+ return val;
157
+ }
158
+
159
+ VALUE rb_Rect_getWidth(VALUE self)
160
+ {
161
+ GET_RECT
162
+ return rb_int2inum(rect->getRect()->width);
163
+ }
164
+
165
+ VALUE rb_Rect_setWidth(VALUE self, VALUE val)
166
+ {
167
+ GET_RECT
168
+ rect->getRect()->width = rb_num2long(val);
169
+ __Rect_Check_LinkedObject(rect);
170
+ return val;
171
+ }
172
+
173
+ VALUE rb_Rect_getHeight(VALUE self)
174
+ {
175
+ GET_RECT
176
+ return rb_int2inum(rect->getRect()->height);
177
+ }
178
+
179
+ VALUE rb_Rect_setHeight(VALUE self, VALUE val)
180
+ {
181
+ GET_RECT
182
+ rect->getRect()->height = rb_num2long(val);
183
+ __Rect_Check_LinkedObject(rect);
184
+ return val;
185
+ }
186
+
187
+ VALUE rb_Rect_load(VALUE self, VALUE str)
188
+ {
189
+ rb_check_type(str, T_STRING);
190
+ VALUE arr[4];
191
+ if(RSTRING_LEN(str) < (sizeof(int) * 4))
192
+ {
193
+ arr[1] = arr[0] = LONG2FIX(1);
194
+ return rb_class_new_instance(2, arr, self);
195
+ }
196
+ int* rc = reinterpret_cast<int*>(RSTRING_PTR(str));
197
+ arr[0] = LONG2FIX(rc[0]);
198
+ arr[1] = LONG2FIX(rc[1]);
199
+ arr[2] = LONG2FIX(rc[2]);
200
+ arr[3] = LONG2FIX(rc[3]);
201
+ return rb_class_new_instance(4, arr, self);
202
+ }
203
+
204
+ VALUE rb_Rect_save(VALUE self, VALUE limit)
205
+ {
206
+ GET_RECT
207
+ sf::IntRect* srect = rect->getRect();
208
+ int rc[4];
209
+ rc[0] = srect->left;
210
+ rc[1] = srect->top;
211
+ rc[2] = srect->width;
212
+ rc[3] = srect->height;
213
+ return rb_str_new(reinterpret_cast<const char*>(rc), sizeof(int) * 4);
214
+ }
215
+
216
+ VALUE rb_Rect_eql_rect(CRect_Element* rect, VALUE self)
217
+ {
218
+ CRect_Element* rect2;
219
+ Data_Get_Struct(self, CRect_Element, rect2);
220
+ RECT_PROTECT
221
+ sf::IntRect* or1 = rect->getRect();
222
+ sf::IntRect* or2 = rect2->getRect();
223
+ if(or1->left != or2->left)
224
+ return Qfalse;
225
+ if(or1->top != or2->top)
226
+ return Qfalse;
227
+ if(or1->width != or2->width)
228
+ return Qfalse;
229
+ if(or1->height != or2->height)
230
+ return Qfalse;
231
+ return Qtrue;
232
+ }
233
+
234
+ VALUE rb_Rect_eql_array(CRect_Element* rect, VALUE oth)
235
+ {
236
+ sf::IntRect* or1 = rect->getRect();
237
+ if(RARRAY_LEN(oth) != 4)
238
+ return Qfalse;
239
+ VALUE* arr = RARRAY_PTR(oth);
240
+ if(rb_num2long(arr[0]) != or1->left)
241
+ return Qfalse;
242
+ if(rb_num2long(arr[1]) != or1->top)
243
+ return Qfalse;
244
+ if(rb_num2long(arr[2]) != or1->width)
245
+ return Qfalse;
246
+ if(rb_num2long(arr[3]) != or1->height)
247
+ return Qfalse;
248
+ return Qtrue;
249
+ }
250
+
251
+ VALUE rb_Rect_eql(VALUE self, VALUE other)
252
+ {
253
+ GET_RECT
254
+ if(rb_obj_is_kind_of(other, rb_cRect) == Qtrue)
255
+ {
256
+ return rb_Rect_eql_rect(rect, other);
257
+ }
258
+ else if(rb_obj_is_kind_of(other, rb_cArray) == Qtrue)
259
+ {
260
+ return rb_Rect_eql_array(rect, other);
261
+ }
262
+ return Qfalse;
263
+ }
264
+
265
+ VALUE rb_Rect_empty(VALUE self)
266
+ {
267
+ GET_RECT
268
+ sf::IntRect* srect = rect->getRect();
269
+ srect->left = srect->top = srect->width = srect->height = 0;
270
+ return self;
271
+ }
272
+
273
+ VALUE rb_Rect_to_s(VALUE self)
274
+ {
275
+ GET_RECT
276
+ sf::IntRect* srect = rect->getRect();
277
+ return rb_sprintf("(%d, %d, %d, %d)", srect->left, srect->top, srect->width, srect->height);
278
+ }
279
+
280
+ CRect_Element* rb_Rect_get_rect(VALUE self)
281
+ {
282
+ rb_Rect_test_rect(self);
283
+ GET_RECT;
284
+ return rect;
285
+ }
286
+
287
+ void rb_Rect_test_rect(VALUE self)
288
+ {
289
+ if (rb_obj_is_kind_of(self, rb_cRect) != Qtrue)
290
+ {
291
+ rb_raise(rb_eTypeError, "Expected Rect got %s.", RSTRING_PTR(rb_class_name(CLASS_OF(self))));
292
+ }
293
+ }
294
+
295
+ void __Rect_Check_LinkedObject(CRect_Element* rect)
296
+ {
297
+ CDrawable_Element* el = rect->getElement();
298
+ if(el == nullptr)
299
+ return;
300
+ /* Viewport processing */
301
+ if(el->isViewport())
302
+ {
303
+ sf::IntRect* srect = rect->getRect();
304
+ Viewport_SetView(reinterpret_cast<CViewport_Element*>(el),
305
+ srect->left, srect->top, srect->width, srect->height);
306
+ }
307
+ /* Sprite Processing */
308
+ else if(el->isPureSprite())
309
+ {
310
+ sf::IntRect tmp_rect = *rect->getRect();
311
+ CSprite_Element* sprite = reinterpret_cast<CSprite_Element*>(el);
312
+ if (RTEST(sprite->rMirror))
313
+ {
314
+ tmp_rect.left += tmp_rect.width;
315
+ tmp_rect.width = -tmp_rect.width;
316
+ }
317
+ sprite->getSprite()->setTextureRect(tmp_rect);
318
+ }
319
+ /* Window Processing */
320
+ else
321
+ {
322
+
323
+ }
324
+ }