ruby-miyako-mswin32 2.1.0 → 2.1.1
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 +275 -20
- 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/miyako_no_katana.so +0 -0
- data/lib/miyako.rb +28 -0
- data/lib/miyako_require_only.rb +35 -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 +8 -5
- data/sample/transform.rb +2 -1
- data/uninstall_miyako.rb +4 -1
- metadata +13 -4
- data/lib/Miyako/EXT/miyako_cairo.rb +0 -62
- data/sample/cairo_sample.rb +0 -25
@@ -0,0 +1,158 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
--
|
4
|
+
Miyako v2.1
|
5
|
+
Copyright (C) 2007-2009 Cyross Makoto
|
6
|
+
|
7
|
+
This library is free software; you can redistribute it and/or
|
8
|
+
modify it under the terms of the GNU Lesser General Public
|
9
|
+
License as published by the Free Software Foundation; either
|
10
|
+
version 2.1 of the License, or (at your option) any later version.
|
11
|
+
|
12
|
+
This library is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
Lesser General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU Lesser General Public
|
18
|
+
License along with this library; if not, write to the Free Software
|
19
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20
|
+
++
|
21
|
+
=end
|
22
|
+
|
23
|
+
module Miyako
|
24
|
+
#==サイズ情報のための構造体クラス
|
25
|
+
#サイズ変更メソッドを追加
|
26
|
+
class SizeStruct < Struct
|
27
|
+
#===サイズを変更する(変化量を指定)
|
28
|
+
# ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
|
29
|
+
#_dw_:: 幅変更。単位はピクセル
|
30
|
+
#_dh_:: 高さ変更。単位はピクセル
|
31
|
+
#返却値:: 自分自身を返す
|
32
|
+
def resize!(dw, dh)
|
33
|
+
end
|
34
|
+
|
35
|
+
#===サイズを変更する
|
36
|
+
# ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
|
37
|
+
#_w_:: 幅変更。単位はピクセル
|
38
|
+
#_h_:: 高さ変更。単位はピクセル
|
39
|
+
#返却値:: 自分自身を返す
|
40
|
+
def resize_to!(w, h)
|
41
|
+
end
|
42
|
+
|
43
|
+
#===サイズを変更したインスタンスを返す(変化量を指定)
|
44
|
+
#引数で指定したぶん変えたときの大きさを新しくインスタンスを生成して返す
|
45
|
+
#自分自身の値は変わらない
|
46
|
+
#_dw_:: 幅変更。単位はピクセル
|
47
|
+
#_dh_:: 高さ変更。単位はピクセル
|
48
|
+
#返却値:: 自分自身の複製を更新したインスタンス
|
49
|
+
def resize(dw, dh)
|
50
|
+
self.dup.resize!(dw,dh)
|
51
|
+
end
|
52
|
+
|
53
|
+
#===サイズを変更したインスタンスを返す
|
54
|
+
#引数で指定したぶん変えたときの大きさを新しくインスタンスを生成して返す
|
55
|
+
#自分自身の値は変わらない
|
56
|
+
#_w_:: 幅変更。単位はピクセル
|
57
|
+
#_h_:: 高さ変更。単位はピクセル
|
58
|
+
#返却値:: 自分自身の複製を更新したインスタンス
|
59
|
+
def resize_to(w, h)
|
60
|
+
self.dup.resize_to!(w,h)
|
61
|
+
end
|
62
|
+
|
63
|
+
#===インスタンスの足し算
|
64
|
+
#もう一方が整数のとき、w,hにotherを足したものを返す
|
65
|
+
#Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を足したものを返す
|
66
|
+
#それ以外の時は例外が発生する
|
67
|
+
#自分自身の値は変わらない
|
68
|
+
#_other_:: 整数もしくはPoint構造体
|
69
|
+
#返却値:: Point構造体
|
70
|
+
def +(other)
|
71
|
+
ret = self.dup
|
72
|
+
if other.kind_of?(Numeric)
|
73
|
+
ret[0] += other
|
74
|
+
ret[1] += other
|
75
|
+
elsif other.methods.include?(:[])
|
76
|
+
ret[0] += other[0]
|
77
|
+
ret[1] += other[1]
|
78
|
+
else
|
79
|
+
raise MiyakoError, "this parameter cannot access!"
|
80
|
+
end
|
81
|
+
ret
|
82
|
+
end
|
83
|
+
|
84
|
+
#===インスタンスの引き算
|
85
|
+
#もう一方が整数のとき、w,hからotherを引いたものを返す
|
86
|
+
#Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を引いたものを返す
|
87
|
+
#それ以外の時は例外が発生する
|
88
|
+
#自分自身の値は変わらない
|
89
|
+
#_other_:: 整数もしくはPoint構造体
|
90
|
+
#返却値:: Point構造体
|
91
|
+
def -(other)
|
92
|
+
ret = self.dup
|
93
|
+
if other.kind_of?(Numeric)
|
94
|
+
ret[0] -= other
|
95
|
+
ret[1] -= other
|
96
|
+
elsif other.methods.include?(:[])
|
97
|
+
ret[0] -= other[0]
|
98
|
+
ret[1] -= other[1]
|
99
|
+
else
|
100
|
+
raise MiyakoError, "this parameter cannot access!"
|
101
|
+
end
|
102
|
+
ret
|
103
|
+
end
|
104
|
+
|
105
|
+
#===インスタンスのかけ算
|
106
|
+
#もう一方が整数のとき、w,hにotherを掛けたものを返す
|
107
|
+
#Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を掛けたものを返す
|
108
|
+
#それ以外の時は例外が発生する
|
109
|
+
#自分自身の値は変わらない
|
110
|
+
#_other_:: 整数もしくはPoint構造体
|
111
|
+
#返却値:: Point構造体
|
112
|
+
def *(other)
|
113
|
+
ret = self.dup
|
114
|
+
if other.kind_of?(Numeric)
|
115
|
+
ret[0] *= other
|
116
|
+
ret[1] *= other
|
117
|
+
elsif other.methods.include?(:[])
|
118
|
+
ret[0] *= other[0]
|
119
|
+
ret[1] *= other[1]
|
120
|
+
else
|
121
|
+
raise MiyakoError, "this parameter cannot access!"
|
122
|
+
end
|
123
|
+
ret
|
124
|
+
end
|
125
|
+
|
126
|
+
#===インスタンスの割り算
|
127
|
+
#もう一方が整数のとき、w,hからotherを割ったものを返す
|
128
|
+
#Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を割ったものを返す
|
129
|
+
#それ以外の時は例外が発生する
|
130
|
+
#自分自身の値は変わらない
|
131
|
+
#_other_:: 整数もしくはPoint構造体
|
132
|
+
#返却値:: Point構造体
|
133
|
+
def /(other)
|
134
|
+
ret = self.dup
|
135
|
+
if other.kind_of?(Numeric)
|
136
|
+
raise MiyakoValueError, "0 div!" if other == 0
|
137
|
+
ret[0] /= other
|
138
|
+
ret[1] /= other
|
139
|
+
elsif other.methods.include?(:[])
|
140
|
+
raise MiyakoValueError, "0 div!" if (other[0] == 0 || other[1] == 0)
|
141
|
+
ret[0] /= other[0]
|
142
|
+
ret[1] /= other[1]
|
143
|
+
else
|
144
|
+
raise MiyakoError, "this parameter cannot access!"
|
145
|
+
end
|
146
|
+
ret
|
147
|
+
end
|
148
|
+
|
149
|
+
def to_ary #:nodoc:
|
150
|
+
[self[0], self[1]]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
#==サイズなどを構成するために使用する構造体
|
155
|
+
#_w_:: 横幅
|
156
|
+
#_h_:: 高さ
|
157
|
+
Size = SizeStruct.new(:w, :h)
|
158
|
+
end
|
@@ -0,0 +1,253 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
--
|
4
|
+
Miyako v2.1
|
5
|
+
Copyright (C) 2007-2009 Cyross Makoto
|
6
|
+
|
7
|
+
This library is free software; you can redistribute it and/or
|
8
|
+
modify it under the terms of the GNU Lesser General Public
|
9
|
+
License as published by the Free Software Foundation; either
|
10
|
+
version 2.1 of the License, or (at your option) any later version.
|
11
|
+
|
12
|
+
This library is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
Lesser General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU Lesser General Public
|
18
|
+
License along with this library; if not, write to the Free Software
|
19
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20
|
+
++
|
21
|
+
=end
|
22
|
+
|
23
|
+
module Miyako
|
24
|
+
#==Square構造体用クラス
|
25
|
+
#位置変更メソッドを追加
|
26
|
+
class SquareStruct < Struct
|
27
|
+
#===位置を変更する(変化量を指定)
|
28
|
+
# ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
|
29
|
+
#_dx_:: 移動量(x方向)。単位はピクセル
|
30
|
+
#_dy_:: 移動量(y方向)。単位はピクセル
|
31
|
+
#返却値:: 自分自身を返す
|
32
|
+
def move!(dx, dy)
|
33
|
+
end
|
34
|
+
|
35
|
+
#===位置を変更する(位置指定)
|
36
|
+
# ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
|
37
|
+
#_x_:: 移動先位置(x方向)。単位はピクセル
|
38
|
+
#_y_:: 移動先位置(y方向)。単位はピクセル
|
39
|
+
#返却値:: 自分自身を返す
|
40
|
+
def move_to!(x, y)
|
41
|
+
end
|
42
|
+
|
43
|
+
#===位置を変更したインスタンスを返す(変化量を指定)
|
44
|
+
#引数で指定したぶん移動させたときの位置を新しくインスタンスを生成して返す
|
45
|
+
#自分自身の値は変わらない
|
46
|
+
#_dx_:: 移動量(x方向)。単位はピクセル
|
47
|
+
#_dy_:: 移動量(y方向)。単位はピクセル
|
48
|
+
#返却値:: 自分自身の複製を更新したインスタンス
|
49
|
+
def move(dx, dy)
|
50
|
+
self.dup.move!(dx, dy)
|
51
|
+
end
|
52
|
+
|
53
|
+
#===位置を変更したインスタンスを返す(位置指定)
|
54
|
+
#引数で指定したぶん移動させたときの位置を新しくインスタンスを生成して返す
|
55
|
+
#自分自身の値は変わらない
|
56
|
+
#_x_:: 移動先位置(x方向)。単位はピクセル
|
57
|
+
#_y_:: 移動先位置(y方向)。単位はピクセル
|
58
|
+
#返却値:: 自分自身の複製を更新したインスタンス
|
59
|
+
def move_to(x, y)
|
60
|
+
self.dup.move_to!(x, y)
|
61
|
+
end
|
62
|
+
|
63
|
+
#===サイズを変更する(変化量を指定)
|
64
|
+
# ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
|
65
|
+
#_dw_:: 幅変更。単位はピクセル
|
66
|
+
#_dh_:: 高さ変更。単位はピクセル
|
67
|
+
#返却値:: 自分自身を返す
|
68
|
+
def resize!(dw, dh)
|
69
|
+
end
|
70
|
+
|
71
|
+
#===サイズを変更する
|
72
|
+
# ブロックを渡したとき、ブロックの評価した結果、偽になったときは移動させた値を元に戻す
|
73
|
+
#_w_:: 幅変更。単位はピクセル
|
74
|
+
#_h_:: 高さ変更。単位はピクセル
|
75
|
+
#返却値:: 自分自身を返す
|
76
|
+
def resize_to!(w, h)
|
77
|
+
end
|
78
|
+
|
79
|
+
#===サイズを変更したインスタンスを返す(変化量を指定)
|
80
|
+
#引数で指定したぶん変えたときの大きさを新しくインスタンスを生成して返す
|
81
|
+
#自分自身の値は変わらない
|
82
|
+
#_dw_:: 幅変更。単位はピクセル
|
83
|
+
#_dh_:: 高さ変更。単位はピクセル
|
84
|
+
#返却値:: 自分自身の複製を更新したインスタンス
|
85
|
+
def resize(dw, dh)
|
86
|
+
self.dup.resize!(dw,dh)
|
87
|
+
end
|
88
|
+
|
89
|
+
#===サイズを変更したインスタンスを返す
|
90
|
+
#引数で指定したぶん変えたときの大きさを新しくインスタンスを生成して返す
|
91
|
+
#自分自身の値は変わらない
|
92
|
+
#_w_:: 幅変更。単位はピクセル
|
93
|
+
#_h_:: 高さ変更。単位はピクセル
|
94
|
+
#返却値:: 自分自身の複製を更新したインスタンス
|
95
|
+
def resize_to(w, h)
|
96
|
+
self.dup.resize_to!(w,h)
|
97
|
+
end
|
98
|
+
|
99
|
+
#===インスタンスの足し算
|
100
|
+
#もう一方が整数のとき、x,yにotherを足したものを返す
|
101
|
+
#Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を足したものを返す
|
102
|
+
#それ以外の時は例外が発生する
|
103
|
+
#自分自身の値は変わらない
|
104
|
+
#_other_:: 整数もしくはPoint構造体
|
105
|
+
#返却値:: Point構造体
|
106
|
+
def +(other)
|
107
|
+
ret = self.dup
|
108
|
+
if other.kind_of?(Numeric)
|
109
|
+
ret[0] += other
|
110
|
+
ret[1] += other
|
111
|
+
ret[2] += other
|
112
|
+
ret[3] += other
|
113
|
+
elsif other.methods.include?(:[])
|
114
|
+
ret[0] += other[0]
|
115
|
+
ret[1] += other[1]
|
116
|
+
ret[2] += other[0]
|
117
|
+
ret[3] += other[1]
|
118
|
+
else
|
119
|
+
raise MiyakoError, "this parameter cannot access!"
|
120
|
+
end
|
121
|
+
ret
|
122
|
+
end
|
123
|
+
|
124
|
+
#===インスタンスの引き算
|
125
|
+
#もう一方が整数のとき、x,yからotherを引いたものを返す
|
126
|
+
#Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を引いたものを返す
|
127
|
+
#それ以外の時は例外が発生する
|
128
|
+
#自分自身の値は変わらない
|
129
|
+
#_other_:: 整数もしくはPoint構造体
|
130
|
+
#返却値:: Point構造体
|
131
|
+
def -(other)
|
132
|
+
ret = self.dup
|
133
|
+
if other.kind_of?(Numeric)
|
134
|
+
ret[0] -= other
|
135
|
+
ret[1] -= other
|
136
|
+
ret[2] -= other
|
137
|
+
ret[3] -= other
|
138
|
+
elsif other.methods.include?(:[])
|
139
|
+
ret[0] -= other[0]
|
140
|
+
ret[1] -= other[1]
|
141
|
+
ret[2] -= other[0]
|
142
|
+
ret[3] -= other[1]
|
143
|
+
else
|
144
|
+
raise MiyakoError, "this parameter cannot access!"
|
145
|
+
end
|
146
|
+
ret
|
147
|
+
end
|
148
|
+
|
149
|
+
#===インスタンスのかけ算
|
150
|
+
#もう一方が整数のとき、x,yにotherを掛けたものを返す
|
151
|
+
#Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を掛けたものを返す
|
152
|
+
#それ以外の時は例外が発生する
|
153
|
+
#自分自身の値は変わらない
|
154
|
+
#_other_:: 整数もしくはPoint構造体
|
155
|
+
#返却値:: Point構造体
|
156
|
+
def *(other)
|
157
|
+
ret = self.dup
|
158
|
+
w = ret[2] - ret[0]
|
159
|
+
h = ret[3] - ret[1]
|
160
|
+
if other.kind_of?(Numeric)
|
161
|
+
ret[0] *= other
|
162
|
+
ret[1] *= other
|
163
|
+
ret[2] = ret[0] + w
|
164
|
+
ret[3] = ret[1] + h
|
165
|
+
elsif other.methods.include?(:[])
|
166
|
+
ret[0] *= other[0]
|
167
|
+
ret[1] *= other[1]
|
168
|
+
ret[2] = ret[0] + w
|
169
|
+
ret[3] = ret[1] + h
|
170
|
+
else
|
171
|
+
raise MiyakoError, "this parameter cannot access!"
|
172
|
+
end
|
173
|
+
ret
|
174
|
+
end
|
175
|
+
|
176
|
+
#===インスタンスの割り算
|
177
|
+
#もう一方が整数のとき、x,yからotherを割ったものを返す
|
178
|
+
#Point構造体や配列など、[]メソッドがつかえるもののとき、x,y同士を割ったものを返す
|
179
|
+
#それ以外の時は例外が発生する
|
180
|
+
#自分自身の値は変わらない
|
181
|
+
#_other_:: 整数もしくはPoint構造体
|
182
|
+
#返却値:: Point構造体
|
183
|
+
def /(other)
|
184
|
+
ret = self.dup
|
185
|
+
w = ret[2] - ret[0]
|
186
|
+
h = ret[3] - ret[1]
|
187
|
+
if other.kind_of?(Numeric)
|
188
|
+
raise MiyakoValueError, "0 div!" if other == 0
|
189
|
+
ret[0] /= other
|
190
|
+
ret[1] /= other
|
191
|
+
ret[2] = ret[0] + w
|
192
|
+
ret[3] = ret[1] + h
|
193
|
+
elsif other.methods.include?(:[])
|
194
|
+
raise MiyakoValueError, "0 div!" if (other[0] == 0 || other[1] == 0)
|
195
|
+
ret[0] /= other[0]
|
196
|
+
ret[1] /= other[1]
|
197
|
+
ret[2] = ret[0] + w
|
198
|
+
ret[3] = ret[1] + h
|
199
|
+
else
|
200
|
+
raise MiyakoError, "this parameter cannot access!"
|
201
|
+
end
|
202
|
+
ret
|
203
|
+
end
|
204
|
+
|
205
|
+
#===指定の座標が矩形の範囲内かを問い合わせる
|
206
|
+
#_x_:: 指定のx座標
|
207
|
+
#_y_:: 指定のy座標
|
208
|
+
#返却値:: 座標が矩形の範囲内ならtrueを返す
|
209
|
+
def in_range?(x, y)
|
210
|
+
return (x >= self[0] && y >= self[1] && x <= self[2] && y <= self[3])
|
211
|
+
end
|
212
|
+
|
213
|
+
#===指定の座標が矩形の範囲内かを問い合わせる
|
214
|
+
#_x_:: 指定のx座標
|
215
|
+
#_y_:: 指定のy座標
|
216
|
+
#返却値:: 座標が矩形の範囲内ならtrueを返す
|
217
|
+
def between?(x, y)
|
218
|
+
return in_range?(x, y)
|
219
|
+
end
|
220
|
+
|
221
|
+
#===矩形の左上位置部分のみ返す
|
222
|
+
#返却値:: Position構造体のインスタンス
|
223
|
+
def pos
|
224
|
+
return Point.new(self[0], self[1])
|
225
|
+
end
|
226
|
+
|
227
|
+
#===矩形の大きさのみ返す
|
228
|
+
#返却値:: Size構造体のインスタンス
|
229
|
+
def size
|
230
|
+
return Size.new(self[2]-self[0]+1, self[3]-self[1]+1)
|
231
|
+
end
|
232
|
+
|
233
|
+
#===矩形情報を配列に変換する
|
234
|
+
#[left, top, right, bottom]の配列を生成して返す。
|
235
|
+
#返却値:: 生成した配列
|
236
|
+
def to_ary
|
237
|
+
[self[0], self[1], self[2], self[3]]
|
238
|
+
end
|
239
|
+
|
240
|
+
#===矩形情報をRect構造体に変換する
|
241
|
+
#返却値:: 生成したRect構造体
|
242
|
+
def to_rect
|
243
|
+
Rect.new(self[0], self[1], self[2]-self[0]+1, self[3]-self[1]+1)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
#==矩形などを構成するために使用する構造体
|
248
|
+
#_left_:: 左上X座標の値
|
249
|
+
#_top_:: 左上Y座標の値
|
250
|
+
#_right_:: 右下X座標の値
|
251
|
+
#_bottom_:: 右下Y座標の値
|
252
|
+
Square = SquareStruct.new(:left, :top, :right, :bottom)
|
253
|
+
end
|
data/lib/Miyako/API/textbox.rb
CHANGED
@@ -76,9 +76,9 @@ module Miyako
|
|
76
76
|
@on_pause = lambda{}
|
77
77
|
|
78
78
|
@on_release = lambda{}
|
79
|
-
|
79
|
+
|
80
80
|
@on_draw = lambda{}
|
81
|
-
|
81
|
+
|
82
82
|
@command_page_size = params[:page_size] || @base[1]
|
83
83
|
|
84
84
|
@choices = Choices.new
|
@@ -87,7 +87,7 @@ module Miyako
|
|
87
87
|
|
88
88
|
@now_choice = nil
|
89
89
|
@pre_attach = false
|
90
|
-
|
90
|
+
|
91
91
|
@waiting = false
|
92
92
|
@select_type = :left
|
93
93
|
@selecting = false
|
@@ -114,9 +114,9 @@ module Miyako
|
|
114
114
|
lambda{ },
|
115
115
|
lambda{ }]
|
116
116
|
]
|
117
|
-
|
117
|
+
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
#===複写時に呼び出されるメソッド
|
121
121
|
#複写と同時に、本インスタンスに対するスナップの関係を解消するが、
|
122
122
|
#内部で使用するスプライトとはスナップをやり直す
|
@@ -140,9 +140,9 @@ module Miyako
|
|
140
140
|
@on_pause = @on_pause.dup
|
141
141
|
|
142
142
|
@on_release = @on_release.dup
|
143
|
-
|
143
|
+
|
144
144
|
@on_draw = @on_draw.dup
|
145
|
-
|
145
|
+
|
146
146
|
@choices = @choices.dup
|
147
147
|
@choices.snap(self)
|
148
148
|
@choices.left!.top!
|
@@ -211,14 +211,14 @@ module Miyako
|
|
211
211
|
# 内部でFiberが評価中ならば、Fiberに処理を移す
|
212
212
|
#返却値:: 自分自身を返す
|
213
213
|
def update
|
214
|
-
begin
|
214
|
+
begin
|
215
215
|
@fiber.resume if @fiber
|
216
216
|
rescue FiberError
|
217
217
|
@fiber = nil
|
218
218
|
end
|
219
219
|
return self
|
220
220
|
end
|
221
|
-
|
221
|
+
|
222
222
|
#===テキストボックスのアニメーションを開始する
|
223
223
|
#返却値:: 自分自身を返す
|
224
224
|
def start
|
@@ -256,7 +256,7 @@ module Miyako
|
|
256
256
|
f = false
|
257
257
|
f |= @textarea.update_animation
|
258
258
|
f |= @wait_cursor.update_animation if (@wait_cursor && @waiting)
|
259
|
-
if @selecting
|
259
|
+
if @selecting
|
260
260
|
f |= @choices.update_animation.any?
|
261
261
|
f |= @select_cursor.update_animation if @select_cursor
|
262
262
|
end
|
@@ -291,7 +291,7 @@ module Miyako
|
|
291
291
|
rect = self.rect.to_a
|
292
292
|
rect_list = []
|
293
293
|
rect_list << @wait_cursor.broad_rect if (@wait_cursor && @waiting)
|
294
|
-
if @selecting
|
294
|
+
if @selecting
|
295
295
|
rect_list << @choices.broad_rect
|
296
296
|
rect_list << @select_cursor.broad_rect if @select_cursor
|
297
297
|
end
|
@@ -307,34 +307,30 @@ module Miyako
|
|
307
307
|
|
308
308
|
#===画面に描画する
|
309
309
|
#現在のテキストエリア・カーソルを、現在の状態で描画する
|
310
|
-
#ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
|
311
|
-
#ブロックの引数は、|インスタンスのSpriteUnit, 画面のSpriteUnit|となる。
|
312
310
|
#visibleメソッドの値がfalseのときは描画されない。
|
313
311
|
#返却値:: 自分自身を返す
|
314
|
-
def render
|
312
|
+
def render
|
315
313
|
return unless @visible
|
316
|
-
@textarea.render
|
317
|
-
@wait_cursor.render
|
318
|
-
if @selecting
|
319
|
-
@choices.render
|
320
|
-
@select_cursor.render
|
314
|
+
@textarea.render
|
315
|
+
@wait_cursor.render if (@wait_cursor && @waiting)
|
316
|
+
if @selecting
|
317
|
+
@choices.render
|
318
|
+
@select_cursor.render if @select_cursor
|
321
319
|
end
|
322
320
|
return self
|
323
321
|
end
|
324
322
|
|
325
323
|
#===画面に描画する
|
326
324
|
#現在のテキストエリア・カーソルを、現在の状態で描画する
|
327
|
-
#ブロック付きで呼び出し可能(レシーバに対応したSpriteUnit構造体が引数として得られるので、補正をかけることが出来る。
|
328
|
-
#ブロックの引数は、|インスタンスのSpriteUnit, 転送先のSpriteUnit|となる。
|
329
325
|
#visibleメソッドの値がfalseのときは描画されない。
|
330
326
|
#返却値:: 自分自身を返す
|
331
|
-
def render_to(dst
|
327
|
+
def render_to(dst)
|
332
328
|
return unless @visible
|
333
|
-
@textarea.render_to(dst
|
334
|
-
@wait_cursor.render(dst
|
335
|
-
if @selecting
|
336
|
-
@choices.render(dst
|
337
|
-
@select_cursor.render(dst
|
329
|
+
@textarea.render_to(dst)
|
330
|
+
@wait_cursor.render(dst) if (@wait_cursor && @waiting)
|
331
|
+
if @selecting
|
332
|
+
@choices.render(dst)
|
333
|
+
@select_cursor.render(dst) if @select_cursor
|
338
334
|
end
|
339
335
|
return self
|
340
336
|
end
|
@@ -452,12 +448,17 @@ module Miyako
|
|
452
448
|
#===選択肢の集合をTextBoxインスタンスに見合う形のChoicesクラスインスタンスの配列に変換する
|
453
449
|
#ブロック(引数一つのブロックのみ有効)を渡したときは、ブロックを評価して変換したChoicesクラスの配列を作成する。
|
454
450
|
#引数は、以下の構成を持つ配列のリスト。
|
455
|
-
#[非選択時スプライト(文字列可),選択時スプライト(文字列・nil可)
|
451
|
+
#[非選択時スプライト(文字列可),選択時スプライト(文字列・nil可),選択不可時スプライト(文字列・nil可),
|
452
|
+
# 使用可・不可フラグ,選択結果インスタンス]
|
456
453
|
# 非選択時スプライト:自身が選択されていない時に表示するスプライト。文字列の時は、Shapeクラスなどでスプライトに変更する
|
457
454
|
# 選択時スプライト:自身が選択されている時に表示するスプライト。文字列の時は、Shapeクラスなどでスプライトに変更する
|
458
455
|
# (そのとき、文字色が赤色になる)。
|
459
456
|
# nilを渡すと、非選択時スプライトが使われる
|
457
|
+
# 選択不可時スプライト:自身が選択不可の時に表示するスプライト。文字列の時は、Shapeクラスなどでスプライトに変更する
|
458
|
+
# (そのとき、文字色が灰色になる)。
|
459
|
+
# nilを渡すと、非選択時スプライトが使われる
|
460
460
|
# 注:スプライトは、画面にスナップしておくこと
|
461
|
+
# 使用可・使用不可フラグ:自身が使用可のときはtrue、使用不可の時はfalseを返す
|
461
462
|
# 選択結果インスタンス:コマンドが決定したときに、resultメソッドの値として渡すインスタンス。
|
462
463
|
# デフォルト処理の選択肢の位置は、画面左上から下へ順番に設定される
|
463
464
|
# 注:ブロックを渡すとき、選択肢の位置計算が、全選択肢の左上位置が[0,0]とする相対座標になっていること
|
@@ -473,10 +474,12 @@ module Miyako
|
|
473
474
|
body = v[0].method(:to_sprite).arity == 0 ? v[0].to_sprite : v[0].to_sprite(@font)
|
474
475
|
@font.color = Color[:red]
|
475
476
|
body_selected = v[1] ? (v[1].method(:to_sprite).arity == 0 ? v[1].to_sprite : v[1].to_sprite(@font)) : body
|
477
|
+
@font.color = Color[:dark_gray]
|
478
|
+
body_disable = v[2] ? (v[2].method(:to_sprite).arity == 0 ? v[2].to_sprite : v[2].to_sprite(@font)) : body
|
476
479
|
@font.color = org_font_color
|
477
|
-
choice = Choices.create_choice(body, body_selected)
|
478
|
-
choice.result = v[
|
479
|
-
choice.end_select_proc = v[
|
480
|
+
choice = Choices.create_choice(body, body_selected, false, body_disable, v[3])
|
481
|
+
choice.result = v[4]
|
482
|
+
choice.end_select_proc = v[5]
|
480
483
|
next choice
|
481
484
|
}
|
482
485
|
choices2 = choices.each_slice(@command_page_size).to_a
|
@@ -490,17 +493,19 @@ module Miyako
|
|
490
493
|
v.up = cc[y - 1]
|
491
494
|
v.right = right[y] || right.last
|
492
495
|
v.left = left[y] || left.last
|
493
|
-
v.
|
494
|
-
v.
|
496
|
+
v.move_to!(0, yp)
|
497
|
+
# v.body.move_to!(0, yp)
|
498
|
+
# v.body_selected.move_to!(0, yp)
|
499
|
+
# v.body_disable.move_to!(0, yp)
|
495
500
|
yp += [v.body.broad_rect.h, v.body_selected.broad_rect.h].max
|
496
501
|
}
|
497
502
|
}
|
498
503
|
return choices2
|
499
504
|
end
|
500
|
-
|
505
|
+
|
501
506
|
#===コマンド選択を設定する
|
502
507
|
#コマンド選択処理に移る(self#selecting?メソッドがtrueになる)
|
503
|
-
#
|
508
|
+
#
|
504
509
|
# 引数choicesに配列を渡すとき、各要素の構成は以下のようになる
|
505
510
|
# [コマンド文字列・画像,選択時コマンド文字列・画像,選択した結果(オブジェクト)]
|
506
511
|
#
|
@@ -534,6 +539,7 @@ module Miyako
|
|
534
539
|
#返却値:: 自分自身を返す
|
535
540
|
def start_command
|
536
541
|
raise MiyakoValueError, "don't set Choice!" if @choices.length == 0
|
542
|
+
@choices.start
|
537
543
|
@choices.start_choice
|
538
544
|
if @select_cursor
|
539
545
|
@select_cursor.snap(@choices.body)
|
@@ -549,6 +555,7 @@ module Miyako
|
|
549
555
|
def finish_command
|
550
556
|
@choices.end_choice(self)
|
551
557
|
@choices.left!.top!
|
558
|
+
@choices.stop
|
552
559
|
@selecting = false
|
553
560
|
return self
|
554
561
|
end
|
@@ -601,6 +608,13 @@ module Miyako
|
|
601
608
|
return @choices.attach(x, y)
|
602
609
|
end
|
603
610
|
|
611
|
+
#===選択した選択肢が利用可能か問い合わせる
|
612
|
+
# 選択した選択肢(Choice構造体)が選択可能(Chices#enable?の値)のときはtrue、選択不可の時はfalseを返す
|
613
|
+
#返却値:: true/false
|
614
|
+
def enable_choice?
|
615
|
+
@choices.enable?
|
616
|
+
end
|
617
|
+
|
604
618
|
def update_layout_position #:nodoc:
|
605
619
|
@pos.move_to!(*@layout.pos)
|
606
620
|
end
|
data/lib/Miyako/API/viewport.rb
CHANGED
@@ -28,7 +28,7 @@ module Miyako
|
|
28
28
|
class Viewport
|
29
29
|
include SpriteBase
|
30
30
|
include Animation
|
31
|
-
|
31
|
+
|
32
32
|
attr_accessor :visible #レンダリングの可否(true->描画 false->非描画)
|
33
33
|
|
34
34
|
#===ビューポートのインスタンスを生成する
|
@@ -42,7 +42,7 @@ module Miyako
|
|
42
42
|
@sq = Rect.new(x, y, x+w-1, y+h-1)
|
43
43
|
@visible = true
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def initialize_copy(obj) #:nodoc:
|
47
47
|
@rect = @rect.dup
|
48
48
|
@sq = @sq.dup
|
@@ -168,19 +168,19 @@ module Miyako
|
|
168
168
|
raise MiyakoValueError, "Illegal size! w:#{w} h:#{h}" if (w <= 0 || h <= 0)
|
169
169
|
@rect.dup.resize_to!(w,h)
|
170
170
|
end
|
171
|
-
|
171
|
+
|
172
172
|
#===インスタンスを解放する
|
173
173
|
def dispose
|
174
174
|
@rect = nil
|
175
175
|
@sq = nil
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
178
|
#===ビューポートのインスタンスを複製する
|
179
179
|
#返却値:: 自分自身の複製
|
180
180
|
def viewport
|
181
181
|
return self.dup
|
182
182
|
end
|
183
|
-
|
183
|
+
|
184
184
|
#===ビューポートのインスタンスを「左、右、上、下」の形式で取得する
|
185
185
|
#返却値:: ビューポートの矩形(Square構造体インスタンス)の複製
|
186
186
|
def square
|