ruby-miyako 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +275 -20
- data/extern.h +21 -1
- data/install_miyako.rb +5 -3
- data/lib/Miyako/API/audio.rb +11 -6
- data/lib/Miyako/API/basic_data.rb +0 -985
- data/lib/Miyako/API/bitmap.rb +19 -22
- data/lib/Miyako/API/choices.rb +203 -69
- data/lib/Miyako/API/collision.rb +451 -9
- data/lib/Miyako/API/color.rb +177 -0
- data/lib/Miyako/API/diagram.rb +18 -20
- data/lib/Miyako/API/fixedmap.rb +207 -73
- data/lib/Miyako/API/font.rb +111 -18
- data/lib/Miyako/API/i_yuki.rb +1201 -0
- data/lib/Miyako/API/input.rb +65 -0
- data/lib/Miyako/API/layout.rb +41 -29
- data/lib/Miyako/API/map.rb +202 -157
- data/lib/Miyako/API/map_event.rb +86 -19
- data/lib/Miyako/API/map_struct.rb +268 -0
- data/lib/Miyako/API/modules.rb +136 -37
- data/lib/Miyako/API/movie.rb +8 -8
- data/lib/Miyako/API/parts.rb +63 -20
- data/lib/Miyako/API/plane.rb +4 -4
- data/lib/Miyako/API/screen.rb +16 -8
- data/lib/Miyako/API/sprite.rb +290 -23
- data/lib/Miyako/API/sprite_animation.rb +23 -11
- data/lib/Miyako/API/sprite_list.rb +406 -183
- data/lib/Miyako/API/story.rb +4 -65
- data/lib/Miyako/API/struct_point.rb +157 -0
- data/lib/Miyako/API/struct_rect.rb +233 -0
- data/lib/Miyako/API/struct_segment.rb +641 -0
- data/lib/Miyako/API/struct_size.rb +158 -0
- data/lib/Miyako/API/struct_square.rb +253 -0
- data/lib/Miyako/API/textbox.rb +49 -35
- data/lib/Miyako/API/viewport.rb +5 -5
- data/lib/Miyako/API/wait_counter.rb +350 -0
- data/lib/Miyako/API/yuki.rb +95 -60
- data/lib/Miyako/EXT/raster_scroll.rb +30 -8
- data/lib/Miyako/EXT/slides.rb +6 -6
- data/lib/Miyako/miyako.rb +25 -11
- data/lib/miyako.rb +28 -0
- data/lib/miyako_require_only.rb +35 -0
- data/miyako_basicdata.c +201 -17
- data/miyako_collision.c +315 -6
- data/miyako_diagram.c +331 -0
- data/miyako_drawing.c +26 -7
- data/miyako_font.c +259 -129
- data/miyako_input_audio.c +24 -14
- data/miyako_layout.c +106 -8
- data/miyako_no_katana.c +398 -171
- data/miyako_sprite2.c +275 -38
- data/miyako_transform.c +113 -107
- data/miyako_utility.c +34 -48
- data/miyako_yuki.c +241 -0
- data/sample/Diagram_sample/diagram_sample_yuki2.rb +30 -30
- data/sample/Room3/blue.rb +19 -19
- data/sample/Room3/green.rb +9 -9
- data/sample/Room3/main.rb +12 -12
- data/sample/Room3/red.rb +12 -12
- data/sample/Room3/title.rb +15 -10
- data/sample/collision_test2.rb +2 -1
- data/sample/fixed_map_test/fixed_map_sample.rb +7 -6
- data/sample/map_test/main_scene.rb +12 -10
- data/sample/map_test/map_manager.rb +14 -13
- data/sample/rasterscroll.rb +5 -5
- data/sample/takahashi.rb +3 -3
- data/sample/textbox_sample.rb +7 -6
- data/sample/transform.rb +2 -1
- data/uninstall_miyako.rb +4 -1
- data/win/miyako_no_katana.so +0 -0
- metadata +15 -4
- data/lib/Miyako/EXT/miyako_cairo.rb +0 -62
- data/sample/cairo_sample.rb +0 -25
data/miyako_layout.c
CHANGED
@@ -40,14 +40,60 @@ static volatile ID id_render = Qnil;
|
|
40
40
|
static volatile ID id_to_a = Qnil;
|
41
41
|
static volatile int zero = Qnil;
|
42
42
|
static volatile int one = Qnil;
|
43
|
+
static const char *str_lo = "@layout";
|
43
44
|
|
44
45
|
static VALUE layout_snap(int argc, VALUE *argv, VALUE self);
|
45
46
|
static VALUE layout_move(VALUE self, VALUE dx, VALUE dy);
|
46
47
|
|
48
|
+
static VALUE get_layout(VALUE self)
|
49
|
+
{
|
50
|
+
return rb_iv_get(self, str_lo);
|
51
|
+
}
|
52
|
+
|
53
|
+
static VALUE layout_pos(VALUE self)
|
54
|
+
{
|
55
|
+
return *(RSTRUCT_PTR(get_layout(self)));
|
56
|
+
}
|
57
|
+
|
58
|
+
VALUE _miyako_layout_pos(VALUE self)
|
59
|
+
{
|
60
|
+
return layout_pos(self);
|
61
|
+
}
|
62
|
+
|
63
|
+
static VALUE layout_size(VALUE self)
|
64
|
+
{
|
65
|
+
return *(RSTRUCT_PTR(get_layout(self))+1);
|
66
|
+
}
|
67
|
+
|
68
|
+
VALUE _miyako_layout_size(VALUE self)
|
69
|
+
{
|
70
|
+
return layout_size(self);
|
71
|
+
}
|
72
|
+
|
73
|
+
static VALUE layout_x(VALUE self)
|
74
|
+
{
|
75
|
+
return *(RSTRUCT_PTR(layout_pos(self))+0);
|
76
|
+
}
|
77
|
+
|
78
|
+
VALUE _miyako_layout_x(VALUE self)
|
79
|
+
{
|
80
|
+
return layout_x(self);
|
81
|
+
}
|
82
|
+
|
83
|
+
static VALUE layout_y(VALUE self)
|
84
|
+
{
|
85
|
+
return *(RSTRUCT_PTR(layout_pos(self))+1);
|
86
|
+
}
|
87
|
+
|
88
|
+
VALUE _miyako_layout_y(VALUE self)
|
89
|
+
{
|
90
|
+
return layout_y(self);
|
91
|
+
}
|
92
|
+
|
47
93
|
static VALUE layout_update_layout(VALUE self, VALUE dx, VALUE dy)
|
48
94
|
{
|
49
95
|
rb_funcall(self, rb_intern("update_layout_position"), 0);
|
50
|
-
VALUE layout =
|
96
|
+
VALUE layout = get_layout(self);
|
51
97
|
VALUE children = *(RSTRUCT_PTR(*(RSTRUCT_PTR(layout)+3))+1);
|
52
98
|
int i;
|
53
99
|
for(i=0; i<RARRAY_LEN(children); i++)
|
@@ -59,7 +105,7 @@ static VALUE layout_update_layout(VALUE self, VALUE dx, VALUE dy)
|
|
59
105
|
|
60
106
|
static VALUE layout_move(VALUE self, VALUE dx, VALUE dy)
|
61
107
|
{
|
62
|
-
VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(
|
108
|
+
VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(get_layout(self))));
|
63
109
|
VALUE *pox = pos+0;
|
64
110
|
VALUE *poy = pos+1;
|
65
111
|
VALUE tx = *pox;
|
@@ -67,7 +113,7 @@ static VALUE layout_move(VALUE self, VALUE dx, VALUE dy)
|
|
67
113
|
*pox = INT2NUM(NUM2INT(tx)+NUM2INT(dx));
|
68
114
|
*poy = INT2NUM(NUM2INT(ty)+NUM2INT(dy));
|
69
115
|
layout_update_layout(self, dx, dy);
|
70
|
-
VALUE on_move = *(RSTRUCT_PTR(
|
116
|
+
VALUE on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
|
71
117
|
int i;
|
72
118
|
for(i=0; i<RARRAY_LEN(on_move); i++)
|
73
119
|
{
|
@@ -85,9 +131,14 @@ static VALUE layout_move(VALUE self, VALUE dx, VALUE dy)
|
|
85
131
|
return self;
|
86
132
|
}
|
87
133
|
|
134
|
+
VALUE _miyako_layout_move(VALUE self, VALUE dx, VALUE dy)
|
135
|
+
{
|
136
|
+
return layout_move(self, dx, dy);
|
137
|
+
}
|
138
|
+
|
88
139
|
static VALUE layout_move_to(VALUE self, VALUE x, VALUE y)
|
89
140
|
{
|
90
|
-
VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(
|
141
|
+
VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(get_layout(self))));
|
91
142
|
VALUE *pox = pos+0;
|
92
143
|
VALUE *poy = pos+1;
|
93
144
|
VALUE tx = *pox;
|
@@ -97,7 +148,49 @@ static VALUE layout_move_to(VALUE self, VALUE x, VALUE y)
|
|
97
148
|
VALUE dx = INT2NUM((NUM2INT(x))-(NUM2INT(tx)));
|
98
149
|
VALUE dy = INT2NUM((NUM2INT(y))-(NUM2INT(ty)));
|
99
150
|
layout_update_layout(self, dx, dy);
|
100
|
-
VALUE on_move = *(RSTRUCT_PTR(
|
151
|
+
VALUE on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
|
152
|
+
int i;
|
153
|
+
for(i=0; i<RARRAY_LEN(on_move); i++)
|
154
|
+
{
|
155
|
+
rb_funcall(*(RARRAY_PTR(on_move) + i), rb_intern("call"), 5, self, *pox, *poy, dx, dy);
|
156
|
+
}
|
157
|
+
if(rb_block_given_p() == Qtrue){
|
158
|
+
VALUE ret = rb_yield(self);
|
159
|
+
if(ret == Qnil || ret == Qfalse)
|
160
|
+
{
|
161
|
+
*pox = tx;
|
162
|
+
*poy = ty;
|
163
|
+
layout_update_layout(self, INT2NUM(-(NUM2INT(dx))), INT2NUM(-(NUM2INT(dy))));
|
164
|
+
}
|
165
|
+
}
|
166
|
+
return self;
|
167
|
+
}
|
168
|
+
|
169
|
+
VALUE _miyako_layout_move_to(VALUE self, VALUE x, VALUE y)
|
170
|
+
{
|
171
|
+
return layout_move_to(self, x, y);
|
172
|
+
}
|
173
|
+
|
174
|
+
static VALUE layout_relative_move_to(VALUE self, VALUE x, VALUE y)
|
175
|
+
{
|
176
|
+
// bpos = @layout.base.pos
|
177
|
+
// Size.new(bpos.x+x,bpos.y+y)
|
178
|
+
VALUE *pos = RSTRUCT_PTR(*(RSTRUCT_PTR(get_layout(self))));
|
179
|
+
VALUE *pox = pos+0;
|
180
|
+
VALUE *poy = pos+1;
|
181
|
+
VALUE tx = *pox;
|
182
|
+
VALUE ty = *poy;
|
183
|
+
|
184
|
+
VALUE base = *(RSTRUCT_PTR(get_layout(self))+2);
|
185
|
+
VALUE *bpos = RSTRUCT_PTR(rb_funcall(base, rb_intern("pos"), 0));
|
186
|
+
|
187
|
+
*pox = INT2NUM(NUM2INT(x)+NUM2INT(*(bpos+0)));
|
188
|
+
*poy = INT2NUM(NUM2INT(y)+NUM2INT(*(bpos+1)));
|
189
|
+
|
190
|
+
VALUE dx = INT2NUM(NUM2INT(*pox)-NUM2INT(tx));
|
191
|
+
VALUE dy = INT2NUM(NUM2INT(*poy)-NUM2INT(ty));
|
192
|
+
layout_update_layout(self, dx, dy);
|
193
|
+
VALUE on_move = *(RSTRUCT_PTR(get_layout(self)) + 4);
|
101
194
|
int i;
|
102
195
|
for(i=0; i<RARRAY_LEN(on_move); i++)
|
103
196
|
{
|
@@ -117,7 +210,7 @@ static VALUE layout_move_to(VALUE self, VALUE x, VALUE y)
|
|
117
210
|
|
118
211
|
static VALUE layout_add_snap_child(VALUE self, VALUE spr)
|
119
212
|
{
|
120
|
-
VALUE layout =
|
213
|
+
VALUE layout = get_layout(self);
|
121
214
|
VALUE snap = *(RSTRUCT_PTR(layout)+3);
|
122
215
|
VALUE children = *(RSTRUCT_PTR(snap)+1);
|
123
216
|
if(rb_ary_includes(children, spr)==Qfalse){ rb_ary_push(children, spr); }
|
@@ -126,7 +219,7 @@ static VALUE layout_add_snap_child(VALUE self, VALUE spr)
|
|
126
219
|
|
127
220
|
static VALUE layout_delete_snap_child(VALUE self, VALUE spr)
|
128
221
|
{
|
129
|
-
VALUE layout =
|
222
|
+
VALUE layout = get_layout(self);
|
130
223
|
VALUE snap = *(RSTRUCT_PTR(layout)+3);
|
131
224
|
VALUE children = *(RSTRUCT_PTR(snap)+1);
|
132
225
|
if(TYPE(spr) == T_ARRAY)
|
@@ -145,7 +238,7 @@ static VALUE layout_snap(int argc, VALUE *argv, VALUE self)
|
|
145
238
|
{
|
146
239
|
VALUE spr = Qnil;
|
147
240
|
rb_scan_args(argc, argv, "01", &spr);
|
148
|
-
VALUE layout =
|
241
|
+
VALUE layout = get_layout(self);
|
149
242
|
VALUE *sprite = RSTRUCT_PTR(*(RSTRUCT_PTR(layout)+3));
|
150
243
|
VALUE *base = RSTRUCT_PTR(layout)+2;
|
151
244
|
if(spr != Qnil)
|
@@ -182,8 +275,13 @@ void Init_miyako_layout()
|
|
182
275
|
one = 1;
|
183
276
|
nOne = INT2NUM(one);
|
184
277
|
|
278
|
+
rb_define_method(mLayout, "x", layout_x, 0);
|
279
|
+
rb_define_method(mLayout, "y", layout_y, 0);
|
280
|
+
rb_define_method(mLayout, "pos", layout_pos, 0);
|
281
|
+
rb_define_method(mLayout, "size", layout_size, 0);
|
185
282
|
rb_define_method(mLayout, "move!", layout_move, 2);
|
186
283
|
rb_define_method(mLayout, "move_to!", layout_move_to, 2);
|
284
|
+
rb_define_method(mLayout, "relative_move_to!", layout_relative_move_to, 2);
|
187
285
|
rb_define_method(mLayout, "update_layout", layout_update_layout, 2);
|
188
286
|
rb_define_method(mLayout, "snap", layout_snap, -1);
|
189
287
|
rb_define_method(mLayout, "add_snap_child", layout_add_snap_child, 1);
|