ruby-miyako-mswin32 2.1.10 → 2.1.11
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.
- data/README +89 -16
- data/lib/Miyako/API/choices.rb +17 -3
- data/lib/Miyako/API/i_yuki.rb +136 -21
- data/lib/Miyako/API/layout.rb +110 -107
- data/lib/Miyako/API/modules.rb +60 -13
- data/lib/Miyako/API/sprite_animation.rb +32 -37
- data/lib/Miyako/API/sprite_list.rb +34 -0
- data/lib/Miyako/API/textbox.rb +1 -1
- data/lib/Miyako/API/yuki.rb +136 -22
- data/lib/Miyako/EXT/drawer.rb +117 -0
- data/lib/Miyako/miyako.rb +2 -2
- data/lib/Miyako/miyako_no_katana.so +0 -0
- data/sample/drawer_sample.rb +67 -0
- metadata +4 -2
@@ -53,7 +53,7 @@ module Miyako
|
|
53
53
|
#
|
54
54
|
#利用できるパラメータは以下の通り
|
55
55
|
#
|
56
|
-
#:sprite => sprite|spriteの配列 アニメーションさせるスプライト(インスタンス単体もしくはインスタンスの配列)。必須パラメータ
|
56
|
+
#:sprite/:sprites => sprite|spriteの配列 アニメーションさせるスプライト(インスタンス単体もしくはインスタンスの配列)。必須パラメータ
|
57
57
|
#
|
58
58
|
#:dir => :h|:v 単体アニメーションのとき、縦方向に位置をずらして表示させる(:h指定時)か、横方向か(:v指定時)を決定する。デフォルトは:h
|
59
59
|
#
|
@@ -65,12 +65,11 @@ module Miyako
|
|
65
65
|
#返却値:: 生成されたインスタンス
|
66
66
|
def initialize(hash)
|
67
67
|
init_layout
|
68
|
-
@units = Array.new
|
69
68
|
@slist = nil
|
70
69
|
|
71
70
|
hash[:dir] ||= :h
|
72
71
|
@dir = hash[:dir]
|
73
|
-
s = hash[:sprite]
|
72
|
+
s = hash[:sprite] || hash[:sprites]
|
74
73
|
hash[:pattern_list] ||= nil
|
75
74
|
@plist = hash[:pattern_list]
|
76
75
|
hash[:wait] ||= 0
|
@@ -91,25 +90,13 @@ module Miyako
|
|
91
90
|
|
92
91
|
@slist = Array.new
|
93
92
|
if s.kind_of?(Sprite)
|
94
|
-
@now = s.to_unit unless @now
|
95
|
-
set_layout_size(s.ow, s.oh)
|
96
|
-
move_to!(s.x, s.y)
|
97
|
-
s.snap(self)
|
98
|
-
s.left!.top!
|
99
93
|
@pat_len = @dir == :h ? s.h : s.w
|
100
94
|
@pat_olen = @dir == :h ? s.oh : s.ow
|
101
95
|
@chr_len = @dir == :h ? s.w : s.h
|
102
96
|
@chr_olen = @dir == :h ? s.ow : s.oh
|
103
97
|
@pats = @pat_len / @pat_olen
|
104
98
|
elsif s.kind_of?(Array)
|
105
|
-
|
106
|
-
@now = first.to_unit unless @now
|
107
|
-
set_layout_size(first.ow, first.oh)
|
108
|
-
move_to!(first.x, first.y)
|
109
|
-
@slist = s.map{|ss|
|
110
|
-
ss.snap(self)
|
111
|
-
ss.left!.top!
|
112
|
-
}
|
99
|
+
@slist = s.dup
|
113
100
|
@pat_len = @slist.length
|
114
101
|
@pats = @slist.length
|
115
102
|
else
|
@@ -164,23 +151,18 @@ module Miyako
|
|
164
151
|
end
|
165
152
|
|
166
153
|
if @slist.length == 0
|
167
|
-
@slist = Array.new(@pats){|pat|
|
168
|
-
|
169
|
-
u = @slist[pat].to_unit.dup
|
154
|
+
@slist = Array.new(@pats){|pat|
|
155
|
+
u = s.dup
|
170
156
|
px = pat % (@pat_len / @pat_olen)
|
171
157
|
if @dir == :h
|
172
|
-
u.oy =
|
158
|
+
u.oy = u.oh * @plist[px]
|
173
159
|
else
|
174
|
-
u.ox =
|
160
|
+
u.ox = u.ow * @plist[px]
|
175
161
|
end
|
176
162
|
u
|
177
163
|
}
|
178
164
|
elsif @slist.length < @pats
|
179
|
-
tmp = @slist
|
180
165
|
@slist = @slist.cycle.take(@pats)
|
181
|
-
@units = Array.new(@pats){|pat| @slist[pat].to_unit.dup }
|
182
|
-
else
|
183
|
-
@units = Array.new(@pats){|pat| @slist[pat].to_unit.dup }
|
184
166
|
end
|
185
167
|
|
186
168
|
if @move_offset.length == 0
|
@@ -215,7 +197,16 @@ module Miyako
|
|
215
197
|
@exec = false
|
216
198
|
@visible = true
|
217
199
|
|
218
|
-
@now = @
|
200
|
+
@now = @slist[@plist[@pnum]]
|
201
|
+
|
202
|
+
first = @slist[0]
|
203
|
+
set_layout_size(first.ow, first.oh)
|
204
|
+
move_to!(first.x, first.y)
|
205
|
+
@slist.each{|ss|
|
206
|
+
ss.snap(self)
|
207
|
+
ss.left!.top!
|
208
|
+
}
|
209
|
+
|
219
210
|
@now.move_to!(@slist[@plist[@pnum]].x + @move_offset[@pnum][0],
|
220
211
|
@slist[@plist[@pnum]].y + @move_offset[@pnum][1])
|
221
212
|
end
|
@@ -224,12 +215,11 @@ module Miyako
|
|
224
215
|
#複写と同時に、本インスタンスに対するスナップの関係を解消するが、
|
225
216
|
#新しいパターンスプライトとスナップをやり直す
|
226
217
|
def initialize_copy(obj)
|
227
|
-
@units = @units.deep_dup
|
228
218
|
@slist = @slist.deep_dup
|
229
219
|
@plist = @plist.dup
|
230
220
|
@move_offset = @move_offset.dup
|
231
221
|
@pos_offset = @pos_offset.dup
|
232
|
-
@now = @
|
222
|
+
@now = @slist[@plist[@pnum]]
|
233
223
|
copy_layout
|
234
224
|
@slist.each{|s| s.snap(self)}
|
235
225
|
end
|
@@ -261,7 +251,7 @@ module Miyako
|
|
261
251
|
end
|
262
252
|
|
263
253
|
def update_layout_position #:nodoc:
|
264
|
-
@
|
254
|
+
@slist.each{|u| u.move_to!(*@layout.pos)}
|
265
255
|
end
|
266
256
|
|
267
257
|
#===現在表示しているスプライトのowを取得する
|
@@ -298,8 +288,8 @@ module Miyako
|
|
298
288
|
end
|
299
289
|
|
300
290
|
#===キャラクター番号を設定する
|
301
|
-
|
302
|
-
|
291
|
+
#キャラクター番号(アニメーションさせるときに表示させるパターン群インデックス)
|
292
|
+
#を設定する。範囲外のキャラクター番号が設定された時は何も行わない
|
303
293
|
#_cnum_:: キャラクター番号
|
304
294
|
def character=(cnum)
|
305
295
|
return self if (cnum < 0 || cnum >= @chrs)
|
@@ -317,8 +307,8 @@ module Miyako
|
|
317
307
|
return self
|
318
308
|
end
|
319
309
|
|
320
|
-
|
321
|
-
|
310
|
+
#===現在のキャラクター番号を取得する
|
311
|
+
#返却値:: キャラクター番号(0以上の整数)
|
322
312
|
def character
|
323
313
|
return @cnum
|
324
314
|
end
|
@@ -409,11 +399,11 @@ module Miyako
|
|
409
399
|
end
|
410
400
|
|
411
401
|
def set_pat #:nodoc:
|
412
|
-
@now = @
|
402
|
+
@now = @slist[@plist[@pnum]]
|
413
403
|
end
|
414
404
|
|
415
405
|
def set_chr #:nodoc:
|
416
|
-
@
|
406
|
+
@slist.each{|u|
|
417
407
|
if @dir == :h
|
418
408
|
u.ox = @chr_olen * @cnum
|
419
409
|
else
|
@@ -460,6 +450,7 @@ module Miyako
|
|
460
450
|
#===現在表示しているスプライトの大きさを矩形で取得する
|
461
451
|
#返却値:: 生成された矩形(Rect構造体のインスタンス)
|
462
452
|
def rect
|
453
|
+
v = @slist[@plist[@pnum]]
|
463
454
|
return Rect.new(@now.x, @now.y, @now.ow, @now.oh)
|
464
455
|
end
|
465
456
|
|
@@ -473,8 +464,6 @@ module Miyako
|
|
473
464
|
#===インスタンスに束縛されているオブジェクトを解放する
|
474
465
|
def dispose
|
475
466
|
@slist.clear
|
476
|
-
@units.each{|u| u.bitmap = nil}
|
477
|
-
@units.clear
|
478
467
|
@waits.clear
|
479
468
|
@plist.clear
|
480
469
|
@move_offset.clear
|
@@ -489,6 +478,9 @@ module Miyako
|
|
489
478
|
#ブロックの引数は、|インスタンスのSpriteUnit|となる。
|
490
479
|
#visibleメソッドの値がfalseのときは描画されない。
|
491
480
|
def render
|
481
|
+
return self unless @now
|
482
|
+
pos = @now.move(*@move_offset[@pnum])
|
483
|
+
@now.render_xy(*pos)
|
492
484
|
end
|
493
485
|
|
494
486
|
#===アニメーションの現在の画像を画像に描画する
|
@@ -500,6 +492,9 @@ module Miyako
|
|
500
492
|
#visibleメソッドの値がfalseのときは描画されない。
|
501
493
|
#_dst_:: 転送先ビットマップ(to_unitメソッドを呼び出すことが出来る/値がnilではないインスタンス)
|
502
494
|
def render_to(dst)
|
495
|
+
return self unless @now
|
496
|
+
pos = @now.move(*@move_offset[@pnum])
|
497
|
+
@now.render_xy_to(dst, *pos)
|
503
498
|
end
|
504
499
|
end
|
505
500
|
end
|
@@ -1349,6 +1349,40 @@ module Miyako
|
|
1349
1349
|
return self
|
1350
1350
|
end
|
1351
1351
|
|
1352
|
+
|
1353
|
+
#===位置を指定して画面への描画を指示するメソッドのテンプレート
|
1354
|
+
#オブジェクトで保持している位置情報ではなく、引数で渡された位置に描画する
|
1355
|
+
#基本的に、メソッドのオーバーライドにより機能するが、pos,move_to!メソッドを持っているときは、
|
1356
|
+
#これらのメソッドを呼び出して同じ動作を行うが処理速度的に課題あり
|
1357
|
+
#ただし、上記のメソッドを持っていない場合は、単純にrenderメソッドを呼び出す
|
1358
|
+
#_x_:: 描画位置のx座標
|
1359
|
+
#_y_:: 描画位置のy座標
|
1360
|
+
#返却値:: 自分自身を返す
|
1361
|
+
def render_xy(x, y)
|
1362
|
+
return self.each{|pair|
|
1363
|
+
obj = pair[1]
|
1364
|
+
cl = e.class
|
1365
|
+
obj.render_xy(x, y) if cl.include?(SpriteBase) || cl.include?(SpriteArray)
|
1366
|
+
}
|
1367
|
+
end
|
1368
|
+
|
1369
|
+
#===位置を指定して画像への描画を指示するメソッドのテンプレート
|
1370
|
+
#オブジェクトで保持している位置情報ではなく、引数で渡された位置に描画する
|
1371
|
+
#基本的に、メソッドのオーバーライドにより機能するが、pos,move_to!メソッドを持っているときは、
|
1372
|
+
#これらのメソッドを呼び出して同じ動作を行うが、処理速度的に課題あり
|
1373
|
+
#ただし、上記のメソッドを持っていない場合は、単純にrender_toメソッドを呼び出す
|
1374
|
+
#_dst_:: 対象の画像
|
1375
|
+
#_x_:: 描画位置のx座標
|
1376
|
+
#_y_:: 描画位置のy座標
|
1377
|
+
#返却値:: 自分自身を返す
|
1378
|
+
def render_xy_to(dst, x, y)
|
1379
|
+
return self.each{|pair|
|
1380
|
+
obj = pair[1]
|
1381
|
+
cl = e.class
|
1382
|
+
obj.render_xy_to(dst, x, y) if cl.include?(SpriteBase) || cl.include?(SpriteArray)
|
1383
|
+
}
|
1384
|
+
end
|
1385
|
+
|
1352
1386
|
#===オブジェクトを文字列に変換する
|
1353
1387
|
#いったん、名前とスプライトとの対の配列に変換し、to_sメソッドで文字列化する。
|
1354
1388
|
#例:[[name1, sprite1], [name2, sprite2],...]
|
data/lib/Miyako/API/textbox.rb
CHANGED
data/lib/Miyako/API/yuki.rb
CHANGED
@@ -36,6 +36,8 @@ module Miyako
|
|
36
36
|
include SpriteBase
|
37
37
|
include Animation
|
38
38
|
|
39
|
+
ALL_TRUE = lambda{ true }
|
40
|
+
|
39
41
|
#==キャンセルを示す構造体
|
40
42
|
#コマンド選択がキャンセルされたときに生成される構造体
|
41
43
|
Canceled = Struct.new(:dummy)
|
@@ -49,6 +51,43 @@ module Miyako
|
|
49
51
|
#_result_:: 選択結果(移動先シーンクラス名、シナリオ(メソッド)名他のオブジェクト)
|
50
52
|
Command = Struct.new(:body, :body_selected, :body_disable, :enable, :condition, :result)
|
51
53
|
|
54
|
+
class Command
|
55
|
+
# Command構造体をChoice構造体に変換する
|
56
|
+
def to_choice(font=Font.sans_serif, size=16, color=Color[:white])
|
57
|
+
org_font_color = font.color
|
58
|
+
org_font_size = font.size
|
59
|
+
|
60
|
+
font.color = color
|
61
|
+
tmp = self[:body]
|
62
|
+
body = tmp.method(:to_sprite).arity == 0 ? tmp.to_sprite : tmp.to_sprite(font)
|
63
|
+
|
64
|
+
font.color = Color[:red]
|
65
|
+
tmp = self[:body_selected]
|
66
|
+
body_selected = tmp ? (tmp.method(:to_sprite).arity == 0 ? tmp.to_sprite : tmp.to_sprite(font)) : body
|
67
|
+
|
68
|
+
font.color = Color[:dark_gray]
|
69
|
+
tmp = self[:body_disable]
|
70
|
+
body_disable= tmp ? (tmp.method(:to_sprite).arity == 0 ? tmp.to_sprite : tmp.to_sprite(font)) : body
|
71
|
+
|
72
|
+
cond = self[:condition] || ALL_TRUE
|
73
|
+
|
74
|
+
choice = Choice.new(body, body_selected, body_disable,
|
75
|
+
cond, self[:enable], false, self[:result],
|
76
|
+
nil, nil, nil, nil,
|
77
|
+
nil, {}, lambda{}, nil)
|
78
|
+
choice.left = choice
|
79
|
+
choice.right = choice
|
80
|
+
choice.up = choice
|
81
|
+
choice.down = choice
|
82
|
+
choice.name = choice.__id__.to_s
|
83
|
+
|
84
|
+
font.color = org_font_color
|
85
|
+
font.size = org_font_size
|
86
|
+
|
87
|
+
choice
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
52
91
|
#==コマンド構造体
|
53
92
|
#_body_:: コマンドの名称(移動する、調べるなど、アイコンなどの画像も可)
|
54
93
|
#_body_selected_:: 選択時コマンドの名称(移動する、調べるなど、アイコンなどの画像も可)(省略時は、bodyと同一)
|
@@ -60,6 +99,43 @@ module Miyako
|
|
60
99
|
#ブロックは1つの引数を取る(コマンド選択テキストボックス))。デフォルトはnil
|
61
100
|
CommandEX = Struct.new(:body, :body_selected, :condition, :body_disable, :enable, :result, :end_select_proc)
|
62
101
|
|
102
|
+
class CommandEx
|
103
|
+
# Command構造体をChoice構造体に変換する
|
104
|
+
def to_choice(font=Font.sans_serif, size=16, color=Color[:white])
|
105
|
+
org_font_color = font.color
|
106
|
+
org_font_size = font.size
|
107
|
+
|
108
|
+
font.color = color
|
109
|
+
tmp = self[:body]
|
110
|
+
body = tmp.method(:to_sprite).arity == 0 ? tmp.to_sprite : tmp.to_sprite(font)
|
111
|
+
|
112
|
+
font.color = Color[:red]
|
113
|
+
tmp = self[:body_selected]
|
114
|
+
body_selected = tmp ? (tmp.method(:to_sprite).arity == 0 ? tmp.to_sprite : tmp.to_sprite(font)) : body
|
115
|
+
|
116
|
+
font.color = Color[:dark_gray]
|
117
|
+
tmp = self[:body_disable]
|
118
|
+
body_disable= tmp ? (tmp.method(:to_sprite).arity == 0 ? tmp.to_sprite : tmp.to_sprite(font)) : body
|
119
|
+
|
120
|
+
cond = self[:condition] || ALL_TRUE
|
121
|
+
|
122
|
+
choice = Choice.new(body, body_selected, body_disable,
|
123
|
+
cond, self[:enable], false, self[:result],
|
124
|
+
nil, nil, nil, nil,
|
125
|
+
nil, {}, self[:end_select_proc], nil)
|
126
|
+
choice.left = choice
|
127
|
+
choice.right = choice
|
128
|
+
choice.up = choice
|
129
|
+
choice.down = choice
|
130
|
+
choice.name = choice.__id__.to_s
|
131
|
+
|
132
|
+
font.color = org_font_color
|
133
|
+
font.size = org_font_size
|
134
|
+
|
135
|
+
choice
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
63
139
|
#===Yuki#update実行中に行わせる処理を実装するテンプレートメソッド
|
64
140
|
#但し、メソッド本体は、update_inner=メソッドで設定する必要がある
|
65
141
|
#_yuki_:: 実行中のYukiクラスインスタンス
|
@@ -228,7 +304,7 @@ module Miyako
|
|
228
304
|
@now_page = nil
|
229
305
|
@first_page = nil
|
230
306
|
|
231
|
-
raise MiyakoProcError, "
|
307
|
+
raise MiyakoProcError, "Argument count is not same block parameter count!" if proc && proc.arity.abs != params.length
|
232
308
|
instance_exec(*params, &proc) if block_given?
|
233
309
|
end
|
234
310
|
|
@@ -314,6 +390,38 @@ module Miyako
|
|
314
390
|
self.pre_visibles.render_to(dst)
|
315
391
|
end
|
316
392
|
|
393
|
+
def start_all
|
394
|
+
self.bgs.start
|
395
|
+
self.visibles.start
|
396
|
+
self.textbox_all.start
|
397
|
+
self.commandbox_all.start unless self.box_shared?
|
398
|
+
self.pre_visibles.start
|
399
|
+
end
|
400
|
+
|
401
|
+
def stop_all
|
402
|
+
self.bgs.stop
|
403
|
+
self.visibles.stop
|
404
|
+
self.textbox_all.stop
|
405
|
+
self.commandbox_all.stop unless self.box_shared?
|
406
|
+
self.pre_visibles.stop
|
407
|
+
end
|
408
|
+
|
409
|
+
def reset_all
|
410
|
+
self.bgs.reset
|
411
|
+
self.visibles.reset
|
412
|
+
self.textbox_all.reset
|
413
|
+
self.commandbox_all.reset unless self.box_shared?
|
414
|
+
self.pre_visibles.reset
|
415
|
+
end
|
416
|
+
|
417
|
+
def animation_all
|
418
|
+
self.bgs.update_animation
|
419
|
+
self.visibles.update_animation
|
420
|
+
self.textbox_all.update_animation
|
421
|
+
self.commandbox_all.update_animation unless self.box_shared?
|
422
|
+
self.pre_visibles.update_animation
|
423
|
+
end
|
424
|
+
|
317
425
|
#===Yuki#showで表示指定した画像のアニメーションを更新する
|
318
426
|
#showメソッドで指定した画像のupdate_animationメソッドを呼び出す
|
319
427
|
#返却値:: 描く画像のupdate_spriteメソッドを呼び出した結果を配列で返す
|
@@ -803,7 +911,7 @@ module Miyako
|
|
803
911
|
@now_page = nil
|
804
912
|
@first_page = nil
|
805
913
|
|
806
|
-
raise MiyakoProcError, "
|
914
|
+
raise MiyakoProcError, "Argument count is not same block parameter count!" if proc && proc.arity.abs != params.length
|
807
915
|
instance_exec(*params, &proc) if proc
|
808
916
|
|
809
917
|
return self
|
@@ -833,9 +941,9 @@ module Miyako
|
|
833
941
|
#返却値:: 自分自身を返す
|
834
942
|
def start_plot(plot_proc = nil, *params, &plot_block)
|
835
943
|
raise MiyakoValueError, "Yuki Error! Textbox is not selected!" unless @text_box
|
836
|
-
raise MiyakoProcError, "
|
837
|
-
raise MiyakoProcError, "
|
838
|
-
raise MiyakoProcError, "
|
944
|
+
raise MiyakoProcError, "Argument count is not same block parameter count!" if plot_proc && plot_proc.arity.abs != params.length
|
945
|
+
raise MiyakoProcError, "Argument count is not same block parameter count!" if plot_block && plot_block.arity.abs != params.length
|
946
|
+
raise MiyakoProcError, "Argument count is not same block parameter count!" if @exec_plot && @exec_plot.arity.abs != params.length
|
839
947
|
@executing_fiber = Fiber.new{ plot_facade(plot_proc, *params, &plot_block) }
|
840
948
|
@executing_fiber.resume
|
841
949
|
return self
|
@@ -1337,7 +1445,7 @@ module Miyako
|
|
1337
1445
|
#引数無しのブロックを渡せば、コマンド選択開始前に、決定判別・キャンセル判別に必要な前処理を施すことが出来る
|
1338
1446
|
#選択中、update_innerメソッドを呼び出し、続けて、処理をYuki#startもしくはYuki#update呼び出し直後に戻す
|
1339
1447
|
#Yuki#updateが呼び出されても選択中の場合は、再び上記の処理を繰り返す
|
1340
|
-
#_command_list_:: 表示するコマンド群。各要素はCommand
|
1448
|
+
#_command_list_:: 表示するコマンド群。各要素はCommand構造体/CommandEx構造体の配列
|
1341
1449
|
#_cancel_to_:: キャンセルボタンを押したときの結果。デフォルトはnil(キャンセル無効)
|
1342
1450
|
#_chain_block_:: コマンドの表示方法。TextBox#create_choices_chainメソッド参照
|
1343
1451
|
#返却値:: 自分自身を返す
|
@@ -1345,22 +1453,28 @@ module Miyako
|
|
1345
1453
|
raise MiyakoValueError, "Yuki Error! Commandbox is not selected!" unless @command_box
|
1346
1454
|
@cancel = cancel_to
|
1347
1455
|
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1456
|
+
if command_list.kind_of?(Choices)
|
1457
|
+
@pre_command.each{|proc| proc.call}
|
1458
|
+
@pre_cancel.each{|proc| proc.call}
|
1459
|
+
@command_box_all.show if @command_box_all.object_id != @text_box_all.object_id
|
1460
|
+
@command_box.command(command_list)
|
1461
|
+
else
|
1462
|
+
choices = []
|
1463
|
+
command_list.each{|cm|
|
1464
|
+
if (cm[:condition] == nil || cm[:condition].call)
|
1465
|
+
cm_array = [cm[:body], cm[:body_selected], cm[:body_disable], cm[:enable], cm[:result]]
|
1466
|
+
methods = cm.methods
|
1467
|
+
cm_array << (methods.include?(:end_select_proc) ? cm[:end_select_proc] : nil)
|
1468
|
+
choices.push(cm_array)
|
1469
|
+
end
|
1470
|
+
}
|
1471
|
+
return self if choices.length == 0
|
1472
|
+
|
1473
|
+
@pre_command.each{|proc| proc.call}
|
1474
|
+
@pre_cancel.each{|proc| proc.call}
|
1475
|
+
@command_box_all.show if @command_box_all.object_id != @text_box_all.object_id
|
1476
|
+
@command_box.command(@command_box.create_choices_chain(choices, &chain_block))
|
1477
|
+
end
|
1364
1478
|
@result = nil
|
1365
1479
|
@selecting = true
|
1366
1480
|
while @selecting
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
# Drawerクラス
|
3
|
+
# 図形描画をスプライトとして扱うクラス
|
4
|
+
# 2010.05.01 Cyross Makoto
|
5
|
+
|
6
|
+
module Miyako
|
7
|
+
# SpriteBase, Animation, Layoutモジュールのメソッドが利用可能
|
8
|
+
class Drawer
|
9
|
+
include SpriteBase
|
10
|
+
include Animation
|
11
|
+
include Layout
|
12
|
+
|
13
|
+
attr_accessor :method, :color
|
14
|
+
attr_accessor :r, :rx, :ry, :aa, :fill
|
15
|
+
attr_accessor :visible
|
16
|
+
attr_accessor :base, :point, :rect, :points
|
17
|
+
|
18
|
+
# 図形描画オブジェクトを作る
|
19
|
+
# 引数はハッシュ引数
|
20
|
+
# それぞれのキーは、Drawerクラスオブジェクトのメソッドとしてアクセス可能
|
21
|
+
# :method => メソッドを指定(:fill,:pset,:line,:rect,:circle,:ellipse,:polygon) 省略不可
|
22
|
+
# :base => 描画先スプライト 全メソッドで有効 省略時はScreen(画面)
|
23
|
+
# :color => 描画色 全メソッドで有効 省略時は白色([255,255,255,255])
|
24
|
+
# :point => 描画開始座標/円の中心座標(Point構造体) :pset, :circle, :ellipseのみ有効 省略時はPoint(0,0)
|
25
|
+
# :rect => 描画矩形(Rect構造体) :line,:rectのみ有効 省略時はRect(0,0,1,1)
|
26
|
+
# :points => 座標の配列([Point構造体,Point構造体,...]) :polygonのみ有効 省略時は空の配列
|
27
|
+
# :r => 円の半径(数値) :circleのみ有効 省略時は1
|
28
|
+
# :rx => 楕円の横方向半径 :ellipseのみ有効 省略時は1
|
29
|
+
# :ry => 楕円の縦方向半径 :ellipseのみ有効 省略時は1
|
30
|
+
# :aa => アンチエイリアスを付けるかどうか(true/false) :line, :cirle, :ellipse, :polygonのみ有効 省略時はfalse
|
31
|
+
# :fill => 描画色で図形の中を塗りつぶすかどうか(true/false) :rect, :circle, :ellipse, :polygonのみ有効 省略時はfalse
|
32
|
+
def initialize(hash)
|
33
|
+
init_layout
|
34
|
+
set_layout_size(1,1)
|
35
|
+
@method = hash[:method]
|
36
|
+
@base = hash[:base] || Screen
|
37
|
+
@color = hash[:color] || [255,255,255]
|
38
|
+
@point = hash[:point] ? Point.new(*(hash[:point].to_a)) : Point.new(0,0)
|
39
|
+
@rect = hash[:rect] ? Rect.new(*(hash[:rect].to_a)) : Rect.new(0,0,1,1)
|
40
|
+
@points = hash[:points] ? hash[:points].map{|pos| Point.new(*pos.to_a)} : []
|
41
|
+
@r = hash[:r] || 1
|
42
|
+
@rx = hash[:rx] || 1
|
43
|
+
@ry = hash[:ry] || 1
|
44
|
+
@aa = hash[:aa] || false
|
45
|
+
@fill = hash[:fill] || false
|
46
|
+
@visible = true
|
47
|
+
@off = Point.new(0,0)
|
48
|
+
raise MiyakoError, "set correct method name by symbol!" unless @method
|
49
|
+
end
|
50
|
+
|
51
|
+
def render
|
52
|
+
return self unless @visible
|
53
|
+
@off.move_to!(0,0)
|
54
|
+
__send__(@method)
|
55
|
+
end
|
56
|
+
|
57
|
+
def render_xy(x, y)
|
58
|
+
return self unless @visible
|
59
|
+
@off.move_to!(x,y)
|
60
|
+
__send__(@method)
|
61
|
+
end
|
62
|
+
|
63
|
+
def fill
|
64
|
+
Drawing.fill(@base,
|
65
|
+
@color)
|
66
|
+
end
|
67
|
+
|
68
|
+
def pset
|
69
|
+
Drawing.pser(@base,
|
70
|
+
@point.move(*@layout.pos).move!(*@off),
|
71
|
+
@color)
|
72
|
+
end
|
73
|
+
|
74
|
+
def line
|
75
|
+
Drawing.line(@base,
|
76
|
+
@rect.move(*@layout.pos).move!(*@off),
|
77
|
+
@color,
|
78
|
+
@aa)
|
79
|
+
end
|
80
|
+
|
81
|
+
def rect
|
82
|
+
Drawing.rect(@base,
|
83
|
+
@rect.move(*@layout.pos).move!(*@off),
|
84
|
+
@color,
|
85
|
+
@fill)
|
86
|
+
end
|
87
|
+
|
88
|
+
def circle
|
89
|
+
Drawing.circle(@base,
|
90
|
+
@point.move(*@layout.pos).move!(*@off),
|
91
|
+
@r,
|
92
|
+
@color,
|
93
|
+
@fill,
|
94
|
+
@aa)
|
95
|
+
end
|
96
|
+
|
97
|
+
def ellipse
|
98
|
+
Drawing.ellipse(@base,
|
99
|
+
@point.move(*@layout.pos).move!(*@off),
|
100
|
+
@rx,
|
101
|
+
@ry,
|
102
|
+
@color,
|
103
|
+
@fill,
|
104
|
+
@aa)
|
105
|
+
end
|
106
|
+
|
107
|
+
def polygon
|
108
|
+
Drawing.polygon(@base,
|
109
|
+
@points.map{|pos| pos.move(*@layout.pos).move!(*@off)},
|
110
|
+
@color,
|
111
|
+
@fill,
|
112
|
+
@aa)
|
113
|
+
end
|
114
|
+
|
115
|
+
private :fill, :pset, :line, :rect, :circle, :ellipse, :polygon
|
116
|
+
end
|
117
|
+
end
|
data/lib/Miyako/miyako.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#=コンテンツ作成ライブラリMiyako2.1
|
4
4
|
#
|
5
5
|
#Authors:: サイロス誠
|
6
|
-
#Version:: 2.1.
|
6
|
+
#Version:: 2.1.11
|
7
7
|
#Copyright:: 2007-2010 Cyross Makoto
|
8
8
|
#License:: LGPL2.1
|
9
9
|
#
|
@@ -63,7 +63,7 @@ Thread.abort_on_exception = true
|
|
63
63
|
|
64
64
|
#==Miyako基幹モジュール
|
65
65
|
module Miyako
|
66
|
-
VERSION = "2.1.
|
66
|
+
VERSION = "2.1.11"
|
67
67
|
|
68
68
|
#===アプリケーション実行中に演奏する音楽のサンプリングレートを指定する
|
69
69
|
#単位はHz(周波数)
|
Binary file
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
#Drawerクラスサンプル
|
3
|
+
#画面に星を表示させる
|
4
|
+
#2010.05.01 Cyross Makoto
|
5
|
+
|
6
|
+
require 'miyako'
|
7
|
+
require 'Miyako/EXT/drawer'
|
8
|
+
|
9
|
+
include Miyako
|
10
|
+
|
11
|
+
RadianBase = 0.4 * Math::PI # inner point (radian of 72deg)
|
12
|
+
RadianOffset = 0.2 * Math::PI # inner point (radian of 36deg)
|
13
|
+
W = 7
|
14
|
+
H = 5
|
15
|
+
R = 32
|
16
|
+
|
17
|
+
def base_line(sprite)
|
18
|
+
end
|
19
|
+
|
20
|
+
def star_points(r, r2=r*0.4, dx=0, dy=0, rad=0.0, scale=1.0)
|
21
|
+
(0...5).to_a.inject([]){|ary, n|
|
22
|
+
rad1 = RadianBase * n + Math::PI + rad
|
23
|
+
rad2 = rad1 + RadianOffset
|
24
|
+
ary.push(Point.new(dx+(Math.sin(rad1)*r*scale).to_i, dy+(Math.cos(rad1)*r*scale).to_i),
|
25
|
+
Point.new(dx+(Math.sin(rad2)*r2*scale).to_i, dy+(Math.cos(rad2)*r2*scale).to_i))
|
26
|
+
ary
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def point_to_s(point)
|
31
|
+
sprintf("[%4d,%4d]", point[0], point[1])
|
32
|
+
end
|
33
|
+
|
34
|
+
def points_to_s(points)
|
35
|
+
points.map{|pt| point_to_s(pt)}.join("")
|
36
|
+
end
|
37
|
+
|
38
|
+
def multi_star_points(num, r, r2=r*0.4, dx=0, dy=0, rad=0.0, scale=1.0)
|
39
|
+
num.times.to_a.map{|n| star_points(r, r2, dx, dy, rad + (n.to_f/num.to_f * 2 * Math::PI), scale) }
|
40
|
+
end
|
41
|
+
|
42
|
+
# axis line
|
43
|
+
axis = [Drawer.new(:method=>:line, :rect=>[320,0,1,480], :color=>:white), # y-axis
|
44
|
+
Drawer.new(:method=>:line, :rect=>[0,240,640,1], :color=>:white)] # x-axis
|
45
|
+
|
46
|
+
# stars
|
47
|
+
stars = H.times.to_a.map{|y|
|
48
|
+
W.times.to_a.map{|x|
|
49
|
+
tmp = multi_star_points(8, R, R*0.4, x*R*3+R, y*R*3+R+16).map{|points|
|
50
|
+
Drawer.new(:method=>:polygon,
|
51
|
+
:points=>points,
|
52
|
+
:color=>[255,255,255,128],
|
53
|
+
:fill=>true)
|
54
|
+
}
|
55
|
+
SpriteAnimation.new(:sprites=>tmp, :wait=>0.1)
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
Sprite[:axis] = axis
|
60
|
+
Sprite[:stars] = stars
|
61
|
+
|
62
|
+
Animation[:stars] = stars
|
63
|
+
stars.start
|
64
|
+
|
65
|
+
Miyako.main_loop do
|
66
|
+
break if Input.quit_or_escape?
|
67
|
+
end
|