ruby-miyako 2.1.17 → 2.1.18

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/ChangeLog.txt CHANGED
@@ -1635,7 +1635,7 @@ v2.1.16(2010.08.30)
1635
1635
  ・リファレンスマニュアルの反映
1636
1636
  <その他>
1637
1637
 
1638
- v2.1.16(2010.10.08)
1638
+ v2.1.17(2010.10.08)
1639
1639
  <バグ修正>
1640
1640
  ・SpriteAnimation#renderで、visibleの値に関わらず画像が描画されるバグを修正
1641
1641
  <機能改善>
@@ -1659,3 +1659,33 @@ v2.1.16(2010.10.08)
1659
1659
  <ドキュメント>
1660
1660
  ・更新履歴をChangeLog.txtに移動
1661
1661
  <その他>
1662
+
1663
+ v2.1.18(2010.10.08)
1664
+ <バグ修正>
1665
+ ・(Initiatie)ScenarioEngine#textで、nilなどを渡すとエラーを出す問題を修正(現在は無視)
1666
+ <機能改善>
1667
+ ・(Initiatie)ScenarioEngine#text_by_char,text_by_strの高速化
1668
+ <仕様変更>
1669
+ ・(Initiatie)ScenarioEngine#text_methodの引数に:char_rapid,:string_rapidを追加
1670
+ <ファイル追加>
1671
+ <ファイル削除>
1672
+ <グローバル変数追加>
1673
+ <定数追加>
1674
+ <定数削除>
1675
+ <構造体追加>
1676
+ <クラス追加>
1677
+ <モジュール追加>
1678
+ <mixin>
1679
+ <クラス・モジュールメソッド追加>
1680
+ <クラス・モジュールメソッド廃止>
1681
+ <モジュール関数追加>
1682
+ <モジュール関数廃止>
1683
+ <インスタンスメソッド追加>
1684
+ ・InitiativeScenarioEngine#text_by_char_rapid
1685
+ ・InitiativeScenarioEngine#text_by_str_rapid
1686
+ ・ScenarioEngine#text_by_char_rapid
1687
+ ・ScenarioEngine#text_by_str_rapid
1688
+ <インスタンスメソッド廃止>
1689
+ <ドキュメント>
1690
+ ・更新履歴をChangeLog.txtに移動
1691
+ <その他>
data/README CHANGED
@@ -1,8 +1,8 @@
1
1
  *******************************************************************************
2
2
  【 作者名 】 サイロス誠
3
3
  【 ソフト名 】 Interactive Media Authoring System "Miyako"
4
- 【 バージョン 】 2.1.17
5
- 【 作成日 】 2010/10/08
4
+ 【 バージョン 】 2.1.18
5
+ 【 作成日 】 2010/10/16
6
6
  【 種別 】 フリーウェア
7
7
  【 開発言語 】 Ruby 1.9.1
8
8
  【 ランタイム 】 Ruby 1.9.1~,Ruby/SDL 2.1~,SDL
@@ -15,7 +15,7 @@
15
15
 
16
16
  【 注意事項 】
17
17
 
18
- 本バージョンは、2.1.17公式リリース版です。
18
+ 本バージョンは、2.1.18公式リリース版です。
19
19
  本バージョンでは、ドキュメント・リファレンスは不十分ですが、「サイログ。」内や、サンプルプログラムの紹介等で随時ドキュメントを公開して行きます。
20
20
  (RDOC化を進めていますので、我こそはと思う方は是非・・・)
21
21
 
@@ -284,7 +284,9 @@ module Miyako
284
284
  @vars = {}
285
285
 
286
286
  @text_methods = {:char => self.method(:text_by_char),
287
- :string => self.method(:text_by_str) }
287
+ :char_rapid => self.method(:text_by_char_rapid),
288
+ :string => self.method(:text_by_str),
289
+ :string_rapid => self.method(:text_by_str_rapid) }
288
290
  @text_method_name = :char
289
291
 
290
292
  @valign = :middle
@@ -1249,7 +1251,7 @@ module Miyako
1249
1251
  #_mode_:: テキストの表示方法。:charのときは文字ごと、:stringのときは文字列ごとに表示される。それ以外を指定したときは例外が発生
1250
1252
  #返却値:: 自分自身を返す
1251
1253
  def text_method(mode)
1252
- raise MiyakoValueError, "undefined text_mode! #{mode}" unless [:char,:string].include?(mode)
1254
+ raise MiyakoValueError, "undefined text_mode! #{mode}" unless @text_methods.keys.include?(mode)
1253
1255
  backup = @text_method_name
1254
1256
  @text_method_name = mode
1255
1257
  if block_given?
@@ -1273,8 +1275,6 @@ module Miyako
1273
1275
  #_txt_:: 表示させるテキスト
1274
1276
  #返却値:: 自分自身を返す
1275
1277
  def text(txt)
1276
- return self if txt.eql?(self)
1277
- return self if txt.empty?
1278
1278
  return @text_methods[@text_method_name].call(txt)
1279
1279
  end
1280
1280
 
@@ -1286,14 +1286,14 @@ module Miyako
1286
1286
  #_txt_:: 表示させるテキスト
1287
1287
  #返却値:: 自分自身を返す
1288
1288
  def text_by_char(txt)
1289
- return self if txt.eql?(self)
1289
+ return self unless txt.class.method_defined?("chars")
1290
1290
  txt.chars{|ch|
1291
1291
  pre_process
1292
- if /[\n\r]/.match(ch)
1292
+ if ch == "\n" || ch == "\r"
1293
1293
  next wait_by_cond(@is_outer_height)
1294
1294
  elsif @text_box.locate.x + @text_box.font.text_size(ch)[0] >= @text_box.textarea.w
1295
1295
  wait_by_cond(@is_outer_height)
1296
- elsif /[\t\f]/.match(ch)
1296
+ elsif ch == "\t" || ch == "\f"
1297
1297
  next nil
1298
1298
  end
1299
1299
  @text_box.draw_text(ch)
@@ -1303,6 +1303,31 @@ module Miyako
1303
1303
  return self
1304
1304
  end
1305
1305
 
1306
+ #===テキストボックスに文字を1文字ずつ表示する
1307
+ #[[Yukiスクリプトとして利用可能]]
1308
+ #引数txtの値は、内部で1文字ずつ分割され、1文字描画されるごとに、
1309
+ #update_textメソッドが呼び出され、続けてYuki#start_plotもしくはYuki#updateメソッド呼び出し直後に戻る
1310
+ #注意として、改行が文字列中にあれば改行、タブやフィードが文字列中にあれば、nilを返す。
1311
+ #_txt_:: 表示させるテキスト
1312
+ #返却値:: 自分自身を返す
1313
+ def text_by_char_rapid(txt)
1314
+ return self unless txt.class.method_defined?("chars")
1315
+ pre_process
1316
+ txt.chars{|ch|
1317
+ if ch == "\n" || ch == "\r"
1318
+ next wait_by_cond(@is_outer_height)
1319
+ elsif @text_box.locate.x + @text_box.font.text_size(ch)[0] >= @text_box.textarea.w
1320
+ wait_by_cond(@is_outer_height)
1321
+ elsif ch == "\t" || ch == "\f"
1322
+ next nil
1323
+ end
1324
+ @text_box.draw_text(ch)
1325
+ @base.text_inner(self, ch) if @base
1326
+ }
1327
+ post_process
1328
+ return self
1329
+ end
1330
+
1306
1331
  #===テキストボックスに文字を表示する
1307
1332
  #[[Yukiスクリプトとして利用可能]]
1308
1333
  #文字列が描画されるごとに、update_textメソッドが呼び出され、
@@ -1311,17 +1336,17 @@ module Miyako
1311
1336
  #_txt_:: 表示させるテキスト
1312
1337
  #返却値:: 自分自身を返す
1313
1338
  def text_by_str(txt)
1314
- return self if txt.eql?(self)
1339
+ return self unless txt.class.method_defined?("chars")
1315
1340
  use_cr = false
1341
+ tw = @text_box.textarea.w
1316
1342
  until txt.empty? do
1317
1343
  pre_process
1318
1344
  if /[\n\r]/.match(txt)
1319
1345
  tmp = Regexp.last_match.pre_match
1320
1346
  txt = Regexp.last_match.post_match
1321
1347
  use_cr = true
1322
- elsif @text_box.locate.x + @text_box.font.text_size(txt)[0] >= @text_box.textarea.w
1323
- w = (@text_box.textarea.w - @text_box.locate.x) / @text_box.font.size
1324
- tmp = txt.slice!(0,w)
1348
+ elsif @text_box.locate.x + @text_box.font.text_size(txt)[0] >= tw
1349
+ tmp = txt.slice!(0,(tw - @text_box.locate.x) / @text_box.font.size)
1325
1350
  use_cr = true
1326
1351
  elsif /[\t\f]/.match(txt)
1327
1352
  post_process
@@ -1331,13 +1356,51 @@ module Miyako
1331
1356
  txt = ""
1332
1357
  end
1333
1358
  @text_box.draw_text(tmp)
1334
- self.cr if use_cr
1359
+ if use_cr
1360
+ self.cr
1361
+ use_cr = false
1362
+ end
1335
1363
  @base.text_inner(self, tmp) if @base
1336
- use_cr = false
1337
1364
  post_process
1338
1365
  end
1339
1366
  return self
1340
1367
  end
1368
+ #===テキストボックスに文字を表示する
1369
+ #[[Yukiスクリプトとして利用可能]]
1370
+ #文字列が描画されるごとに、update_textメソッドが呼び出され、
1371
+ #続けてYuki#start_plotもしくはYuki#updateメソッド呼び出し直後に戻る
1372
+ #注意として、改行が文字列中にあれば改行、タブやフィードが文字列中にあれば、nilを返す。
1373
+ #_txt_:: 表示させるテキスト
1374
+ #返却値:: 自分自身を返す
1375
+ def text_by_str_rapid(txt)
1376
+ return self unless txt.class.method_defined?("chars")
1377
+ use_cr = false
1378
+ tw = @text_box.textarea.w
1379
+ pre_process
1380
+ until txt.empty? do
1381
+ if /[\n\r]/.match(txt)
1382
+ tmp = Regexp.last_match.pre_match
1383
+ txt = Regexp.last_match.post_match
1384
+ use_cr = true
1385
+ elsif @text_box.locate.x + @text_box.font.text_size(txt)[0] >= tw
1386
+ tmp = txt.slice!(0,(tw - @text_box.locate.x) / @text_box.font.size)
1387
+ use_cr = true
1388
+ elsif /[\t\f]/.match(txt)
1389
+ next nil
1390
+ else
1391
+ tmp = txt
1392
+ txt = ""
1393
+ end
1394
+ @text_box.draw_text(tmp)
1395
+ if use_cr
1396
+ self.cr
1397
+ use_cr = false
1398
+ end
1399
+ end
1400
+ @base.text_inner(self, tmp) if @base
1401
+ post_process
1402
+ return self
1403
+ end
1341
1404
 
1342
1405
  def is_outer_height #:nodoc:
1343
1406
  return @text_box.locate.y + @text_box.max_height >= @text_box.textarea.h
@@ -280,7 +280,9 @@ module Miyako
280
280
  @executing_fiber = nil
281
281
 
282
282
  @text_methods = {:char => self.method(:text_by_char),
283
- :string => self.method(:text_by_str) }
283
+ :char_rapid => self.method(:text_by_char_rapid),
284
+ :string => self.method(:text_by_str),
285
+ :string_rapid => self.method(:text_by_str_rapid) }
284
286
  @text_method_name = :char
285
287
 
286
288
  @valign = :middle
@@ -1268,7 +1270,7 @@ module Miyako
1268
1270
  #_mode_:: テキストの表示方法。:charのときは文字ごと、:stringのときは文字列ごとに表示される。それ以外を指定したときは例外が発生
1269
1271
  #返却値:: 自分自身を返す
1270
1272
  def text_method(mode)
1271
- raise MiyakoValueError, "undefined text_mode! #{mode}" unless [:char,:string].include?(mode)
1273
+ raise MiyakoValueError, "undefined text_mode! #{mode}" unless @text_methods.keys.include?(mode)
1272
1274
  backup = @text_method_name
1273
1275
  @text_method_name = mode
1274
1276
  if block_given?
@@ -1292,8 +1294,6 @@ module Miyako
1292
1294
  #_txt_:: 表示させるテキスト
1293
1295
  #返却値:: 自分自身を返す
1294
1296
  def text(txt)
1295
- return self if txt.eql?(self)
1296
- return self if txt.empty?
1297
1297
  return @text_methods[@text_method_name].call(txt)
1298
1298
  end
1299
1299
 
@@ -1305,13 +1305,13 @@ module Miyako
1305
1305
  #_txt_:: 表示させるテキスト
1306
1306
  #返却値:: 自分自身を返す
1307
1307
  def text_by_char(txt)
1308
- return self if txt.eql?(self)
1308
+ return self unless txt.class.method_defined?("chars")
1309
1309
  txt.chars{|ch|
1310
- if /[\n\r]/.match(ch)
1310
+ if ch == "\n" || ch == "\r"
1311
1311
  next wait_by_cond(@is_outer_height)
1312
1312
  elsif @text_box.locate.x + @text_box.font.text_size(ch)[0] >= @text_box.textarea.w
1313
1313
  wait_by_cond(@is_outer_height)
1314
- elsif /[\t\f]/.match(ch)
1314
+ elsif ch == "\t" || ch == "\f"
1315
1315
  next nil
1316
1316
  end
1317
1317
  @text_box.draw_text(ch)
@@ -1321,6 +1321,30 @@ module Miyako
1321
1321
  return self
1322
1322
  end
1323
1323
 
1324
+ #===テキストボックスに文字を1文字ずつ表示する
1325
+ #[[Yukiスクリプトとして利用可能]]
1326
+ #引数txtの値は、内部で1文字ずつ分割され、1文字描画されるごとに、
1327
+ #update_textメソッドが呼び出され、続けてYuki#start_plotもしくはYuki#updateメソッド呼び出し直後に戻る
1328
+ #注意として、改行が文字列中にあれば改行、タブやフィードが文字列中にあれば、nilを返す。
1329
+ #_txt_:: 表示させるテキスト
1330
+ #返却値:: 自分自身を返す
1331
+ def text_by_char_rapid(txt)
1332
+ return self unless txt.class.method_defined?("chars")
1333
+ txt.chars{|ch|
1334
+ if ch == "\n" || ch == "\r"
1335
+ next wait_by_cond(@is_outer_height)
1336
+ elsif @text_box.locate.x + @text_box.font.text_size(ch)[0] >= @text_box.textarea.w
1337
+ wait_by_cond(@is_outer_height)
1338
+ elsif ch == "\t" || ch == "\f"
1339
+ next nil
1340
+ end
1341
+ @text_box.draw_text(ch)
1342
+ @update_text.call(self, ch)
1343
+ }
1344
+ Fiber.yield
1345
+ return self
1346
+ end
1347
+
1324
1348
  #===テキストボックスに文字を表示する
1325
1349
  #[[Yukiスクリプトとして利用可能]]
1326
1350
  #文字列が描画されるごとに、update_textメソッドが呼び出され、
@@ -1329,16 +1353,16 @@ module Miyako
1329
1353
  #_txt_:: 表示させるテキスト
1330
1354
  #返却値:: 自分自身を返す
1331
1355
  def text_by_str(txt)
1332
- return self if txt.eql?(self)
1356
+ return self unless txt.class.method_defined?("chars")
1333
1357
  use_cr = false
1358
+ tw = @text_box.textarea.w
1334
1359
  until txt.empty? do
1335
1360
  if /[\n\r]/.match(txt)
1336
1361
  tmp = Regexp.last_match.pre_match
1337
1362
  txt = Regexp.last_match.post_match
1338
1363
  use_cr = true
1339
- elsif @text_box.locate.x + @text_box.font.text_size(txt)[0] >= @text_box.textarea.w
1340
- w = (@text_box.textarea.w - @text_box.locate.x) / @text_box.font.size
1341
- tmp = txt.slice!(0,w)
1364
+ elsif @text_box.locate.x + @text_box.font.text_size(txt)[0] >= tw
1365
+ tmp = txt.slice!(0,(tw - @text_box.locate.x) / @text_box.font.size)
1342
1366
  use_cr = true
1343
1367
  elsif /[\t\f]/.match(txt)
1344
1368
  next nil
@@ -1347,14 +1371,52 @@ module Miyako
1347
1371
  txt = ""
1348
1372
  end
1349
1373
  @text_box.draw_text(tmp)
1350
- self.cr if use_cr
1374
+ if use_cr
1375
+ self.cr
1376
+ use_cr = false
1377
+ end
1351
1378
  @update_text.call(self, tmp)
1352
1379
  Fiber.yield
1353
- use_cr = false
1354
1380
  end
1355
1381
  return self
1356
1382
  end
1357
1383
 
1384
+ #===テキストボックスに文字を表示する
1385
+ #[[Yukiスクリプトとして利用可能]]
1386
+ #文字列が描画されるごとに、update_textメソッドが呼び出され、
1387
+ #続けてYuki#start_plotもしくはYuki#updateメソッド呼び出し直後に戻る
1388
+ #注意として、改行が文字列中にあれば改行、タブやフィードが文字列中にあれば、nilを返す。
1389
+ #_txt_:: 表示させるテキスト
1390
+ #返却値:: 自分自身を返す
1391
+ def text_by_str_rapid(txt)
1392
+ return self unless txt.class.method_defined?("chars")
1393
+ use_cr = false
1394
+ tw = @text_box.textarea.w
1395
+ until txt.empty? do
1396
+ if /[\n\r]/.match(txt)
1397
+ tmp = Regexp.last_match.pre_match
1398
+ txt = Regexp.last_match.post_match
1399
+ use_cr = true
1400
+ elsif @text_box.locate.x + @text_box.font.text_size(txt)[0] >= tw
1401
+ tmp = txt.slice!(0,(tw - @text_box.locate.x) / @text_box.font.size)
1402
+ use_cr = true
1403
+ elsif /[\t\f]/.match(txt)
1404
+ next nil
1405
+ else
1406
+ tmp = txt
1407
+ txt = ""
1408
+ end
1409
+ @text_box.draw_text(tmp)
1410
+ if use_cr
1411
+ self.cr
1412
+ use_cr = false
1413
+ end
1414
+ end
1415
+ @update_text.call(self, tmp)
1416
+ Fiber.yield
1417
+ return self
1418
+ end
1419
+
1358
1420
  def is_outer_height #:nodoc:
1359
1421
  return @text_box.locate.y + @text_box.max_height >= @text_box.textarea.h
1360
1422
  end
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-miyako
3
3
  version: !ruby/object:Gem::Version
4
- hash: 41
4
+ hash: 47
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 17
10
- version: 2.1.17
9
+ - 18
10
+ version: 2.1.18
11
11
  platform: ruby
12
12
  authors:
13
13
  - Cyross Makoto
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-06 00:00:00 +09:00
18
+ date: 2010-10-15 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies: []
21
21