设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1555|回复: 2
打印 上一主题 下一主题

[已经过期] 這種 呼出式的對話視窗 要怎麼使用 [ 附帶腳本 ]

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2296
在线时间
611 小时
注册时间
2009-1-21
帖子
273
跳转到指定楼层
1
发表于 2012-8-10 01:24:27 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 御之嵐 于 2012-8-10 01:26 编辑

腳本網站
http://a1tktk.web.fc2.com/scripts_page/popup_message.html

腳本 本體  要放在 A1共通下面


A1共通


RUBY 代码复制
  1. # ===========================================================================
  2. # ◆ A1 Scripts ◆
  3. #    A1共通処理(RGSS2/RGSS3共用)
  4. #
  5. # バージョン   : 4.50 (2012/01/26)
  6. # 作者         : A1
  7. # URL     : [url]http://a1tktk.web.fc2.com/[/url]
  8. # ---------------------------------------------------------------------------
  9. # 更新履歴   :2011/11/11 Ver1.00 新規作成
  10. #        :2011/12/22 Ver2.00 RGSS3用と同様の処理に変更
  11. #        :2011/12/30 Ver2.10 RGSS3用メソッドを追加
  12. #        :2011/12/30 Ver3.00 RGSS3用共通処理と統合
  13. #        :2011/12/31 Ver3.10 マップチップサーチの仕様を変更
  14. #        :2011/12/31 Ver3.10 拡張通行判定を追加
  15. #        :2012/01/01 Ver3.11 クラス名の取得処理を追加
  16. #              :2012/01/02 Ver3.20 配列を考慮したsplit処理を追加
  17. #              :2012/01/02 Ver3.20 配列の全ての要素を整数にする処理を追加
  18. #              :2012/01/02 Ver3.30 注釈の処理の仕様を変更
  19. #              :2012/01/02 Ver3.40 「前のイベントコマンドの取得」を追加
  20. #              :2012/01/03 Ver3.50 「フレーム更新」を追加
  21. #              :2012/01/04 Ver3.60 「指定のウィンドウが開いている間ウェイト」追加
  22. #              :2012/01/04 Ver3.70 RGSS2用処理見直し
  23. #              :2012/01/05 Ver3.80 注釈文字列にエスケープコマンド対応
  24. #              :2012/01/05 Ver3.80 多次元配列を考慮したsplit処理を追加
  25. #              :2012/01/05 Ver3.80 注釈にスクリプト処理機能を追加
  26. #              :2012/01/10 Ver3.90 文字縁取り描画を追加
  27. #              :2012/01/11 Ver4.00 テキストビットマップのキャッシュを追加
  28. #              :2012/01/13 Ver4.01 「タイルセットの変更」ができなくなる不具合を修正
  29. #              :2012/01/14 Ver4.10 split処理を強化
  30. #              :2012/01/14 Ver4.20 空白を含む注釈コマンドに対応
  31. #              :2012/01/14 Ver4.21 split処理の不具合を修正
  32. #              :2012/01/21 Ver4.30 メモの内容を取得する関数を追加
  33. #              :2012/01/24 Ver4.40 メモの内容を取得する関数を追加
  34. #              :2012/01/24 Ver4.50 メモの内容を取得する関数を追加
  35. # ---------------------------------------------------------------------------
  36. # 設置場所      
  37. #  なるべく上の方
  38. #
  39. # 必要スクリプト
  40. #    なし
  41. #==============================================================================
  42. $imported = {} if $imported == nil
  43. $imported["A1_Common_Script"] = 4.50
  44. #==============================================================================
  45. # ■ Kernel
  46. #==============================================================================
  47. module Kernel
  48.   #--------------------------------------------------------------------------
  49.   # ○ RGSSのバージョン取得
  50.   #--------------------------------------------------------------------------
  51.   def rgss_version
  52.     return 3 if defined? Graphics.play_movie
  53.     return 2 if defined? Graphics.resize_screen
  54.     return 1
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ○ コモンスクリプトのバージョン取得
  58.   #--------------------------------------------------------------------------
  59.   def common_version
  60.     $imported["A1_Common_Script"]
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ○ コモンスクリプトのバージョンが古い
  64.   #--------------------------------------------------------------------------
  65.   def old_common_script(script_name, version)
  66.     msgbox("#{script_name}にはA1共通スクリプトVer#{version}以上が必要です")
  67.   end
  68. end
  69. #==============================================================================
  70. # ■ A1_System
  71. #==============================================================================
  72. module A1_System
  73. end
  74. #==============================================================================
  75. # ■ A1_System::CommonModule
  76. #==============================================================================
  77.  
  78. class A1_System::CommonModule
  79.   #--------------------------------------------------------------------------
  80.   # ○ 定数
  81.   #--------------------------------------------------------------------------
  82.   TWOBYTE_LIST = {
  83.                   " " => " ",
  84.                   "=" => "=",
  85.                   ":" => ":"
  86.                   }
  87.   #--------------------------------------------------------------------------
  88.   # ○ オブジェクト初期化
  89.   #--------------------------------------------------------------------------
  90.   def initialize
  91.     define_command
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ○ 変換対象の全角文字を半角に置換
  95.   #--------------------------------------------------------------------------
  96.   def replace_twobyte(str)
  97.     for key in TWOBYTE_LIST.keys
  98.       str.gsub!(key) {TWOBYTE_LIST[key]}
  99.     end
  100.     return str
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ○ マイナスが含まれている文字列を数値にする
  104.   #--------------------------------------------------------------------------
  105.   def minus_to_i(s)
  106.     if s[0,0] == "-"
  107.       s.gsub!("-","")
  108.       return s.to_i * -1
  109.     else
  110.       return s.to_i
  111.     end
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ○ ミリ秒単位の現在時間
  115.   #--------------------------------------------------------------------------
  116.   def now_usec
  117.     now = Time.now
  118.     hour = now.hour * 60 * 60
  119.     min  = now.min * 60
  120.     sec  = now.sec
  121.     msec = (now.usec / 1000.0).round
  122.     return (hour + min + sec) * 1000 + msec
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ○ イベントリストの作成
  126.   #--------------------------------------------------------------------------
  127.   def create_event_list(code, indent, parameters)
  128.     list = RPG::EventCommand.new
  129.     list.code       = code
  130.     list.indent     = indent
  131.     list.parameters = parameters
  132.     return list
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ○ メソッド呼び出し
  136.   #--------------------------------------------------------------------------
  137.   def send_method(method_name)
  138.     return send(method_name) if respond_to?(method_name)
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ○ オブジェクトの型を判断してStringならエンコード
  142.   #--------------------------------------------------------------------------
  143.   def encoding_string(obj)
  144.     obj.force_encoding("UTF-8") if obj.is_a?(String)
  145.     return obj
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ○ メモの内容から必要な情報を取得
  149.   #--------------------------------------------------------------------------
  150.   def note_data(note, key)
  151.     result = []
  152.     note.each_line {|line|
  153.       next unless line =~ /<#{key}[ ]?(.*)>/
  154.       return true if $1.empty?
  155.       data = $a1_common.replace_twobyte($1).split(" ")
  156.       for st in data
  157.         result.push(st)
  158.       end
  159.     }
  160.     return false if result.empty?
  161.     return result
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ○ メモの内容からハッシュを作成
  165.   #--------------------------------------------------------------------------
  166.   def note_data_hash(note, key, data_default = nil, default = {}, ret = {})
  167.     list = note_data_split(note, key)
  168.     return default if list.empty?
  169.     list.each {|data| ret[data[0]] = data[1] ? data[1] : data_default }
  170.     return ret
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ○ メモの内容からカンマ区切りの多元配列を取得
  174.   #--------------------------------------------------------------------------
  175.   def note_data_split(note, key, default = [], ret = [])
  176.     data = note_data(note, key)
  177.     return default unless data.is_a?(Array)
  178.     data.each {|str| ret.push(convert_integer_from_array(split_array(str)))}
  179.     return ret
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ○ 配列の内容から数値があれば変換
  183.   #--------------------------------------------------------------------------
  184.   def convert_integer_from_array(data, ret = [])
  185.     data.each {|str| ret.push(convert_integer(str))}
  186.     return ret
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ○ 数値があれば変換
  190.   #--------------------------------------------------------------------------
  191.   def convert_integer(str)
  192.     return $1.to_i if str =~ /(^[-]?[0-9]+$)/
  193.     str.is_a?(Array) ? convert_integer_from_array(str) : str
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   # ○ メモの内容から単項目の数値を取得
  197.   #--------------------------------------------------------------------------
  198.   def note_data_one_value(note, key, default)
  199.     data = note_data(note, key)
  200.     return data[0].to_i if data.is_a?(Array)
  201.     return default
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ○ メモの内容から単項目を取得
  205.   #--------------------------------------------------------------------------
  206.   def note_data_one(note, key, default)
  207.     data = note_data(note, key)
  208.     return data[0] if data.is_a?(Array)
  209.     return default
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ○ メモの内容からカンマ区切りの文字列を取得
  213.   #--------------------------------------------------------------------------
  214.   def note_data_array_str(note, key, default)
  215.     data = note_data(note, key)
  216.     return data[0].split(",") if data.is_a?(Array)
  217.     return default
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ○ メモの内容からカンマ区切りの数値を取得
  221.   #--------------------------------------------------------------------------
  222.   def note_data_array_value(note, key, default)
  223.     data = note_data(note, key)
  224.     return default unless data.is_a?(Array)
  225.     return convert_integer_from_array(split_array(data[0]))
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # ○ カンマ区切りの文字列メモを変換
  229.   #--------------------------------------------------------------------------
  230.   def note_data_array(note, key, type, default = nil, through = true)
  231.     ret = []
  232.     default.each {|dat| ret.push(dat)} if default != nil
  233.  
  234.     data = note_data(note, key)
  235.     return ret unless data.is_a?(Array)
  236.  
  237.     data = data[0].split(",")
  238.     for d in data
  239.       next if ret.include?(d) if through
  240.       ret.push(d.to_i) if type.is_a?(Integer)
  241.       ret.push(d)      if type.is_a?(String)
  242.     end
  243.     return ret
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # ○ ディレクトリの作成
  247.   #--------------------------------------------------------------------------
  248.   def make_directory(dir_name)
  249.     Dir::mkdir(dir_name) unless FileTest.exist?(dir_name)
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ○ コマンドリスト
  253.   #--------------------------------------------------------------------------
  254.   def make_command(command, src = "", dect = "")
  255.     src.gsub!("/","\\")
  256.     dect.gsub!("/","\\")
  257.     cmd = "#{command} \"#{src}\" \"#{dect}\""
  258.     return cmd
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # ○ 素材の拡張子を取得
  262.   #--------------------------------------------------------------------------
  263.   def material_ext(directory, file, direct = false)
  264.     exts = []
  265.     exts = [".png",".bmp",".jpg"]               if directory =~ /(.*)Graphics\/(.*)/
  266.     exts = [".mid",".ogg",".wav",".mp3",".wma"] if directory =~ /(.*)Audio(.*)/
  267.  
  268.     find_file = sprintf("%s%s", directory, file) unless direct
  269.     find_file = file if direct
  270.  
  271.     for ext in exts
  272.       return ext if File.exist?(sprintf("%s%s", find_file, ext))
  273.     end
  274.     return nil
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # ○ 素材が存在するかチェック
  278.   #--------------------------------------------------------------------------
  279.   def material_exist?(directory, file, direct = false)
  280.     return false if material_ext(directory, file, direct) == nil
  281.     return true
  282.   end
  283.   #--------------------------------------------------------------------------
  284.   # ○ ファイルコピー
  285.   #--------------------------------------------------------------------------
  286.   def copy_file(src, dest)
  287.     srcFile = File.open( src, "rb" )
  288.     dstFile = File.open( dest, "wb" )
  289.     dstFile.write( srcFile.read )
  290.     srcFile.close
  291.     dstFile.close
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ○ ファイルの存在を確認してファイルコピー
  295.   #--------------------------------------------------------------------------
  296.   def material_copy(src, dest, directory)
  297.     ext = material_ext(directory, src, true)
  298.     copy_file( src + ext, dest + ext ) if ext != nil
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # ○ 配列からAudioを作成
  302.   #--------------------------------------------------------------------------
  303.   def set_audio(sound, kind)
  304.     case kind
  305.     when "BGM"; audio = RPG::BGM.new
  306.     when "BGS"; audio = RPG::BGS.new
  307.     when "ME";  audio = RPG::ME.new
  308.     when "SE";  audio = RPG::SE.new
  309.     end
  310.     audio.name   = sound[0]
  311.     audio.volume = sound[1]
  312.     audio.pitch  = sound[2]
  313.     return audio
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ○ 既に準拠識別子を持っているかチェック
  317.   #--------------------------------------------------------------------------
  318.   def chk_rtp(file_name, default)
  319.     return "" if file_name =~ /^VX_.*/
  320.     return "" if file_name =~ /^XP_.*/
  321.     return "" if file_name =~ /^2000_.*/
  322.     return "" if file_name =~ /^2003_.*/
  323.     return default
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ○ 先頭の $ を切り出す
  327.   #--------------------------------------------------------------------------
  328.   def one_character(file_name)
  329.     return file_name unless file_name[0] == "$"
  330.     tmp = file_name.clone
  331.     tmp[0] = ""
  332.     return tmp
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ○ 配列を入れ替える
  336.   #--------------------------------------------------------------------------
  337.   def change_array(array, index1, index2)
  338.     tmp = array[index1]
  339.     array[index1] = array[index2]
  340.     array[index2] = tmp
  341.     return array
  342.   end
  343.   #--------------------------------------------------------------------------
  344.   # ○ 移動ルートの作成
  345.   #--------------------------------------------------------------------------
  346.   def create_move_route(repeat, skippable, wait, list)
  347.     move_route = RPG::MoveRoute.new
  348.     move_route.repeat    = repeat
  349.     move_route.skippable = skippable
  350.     move_route.wait      = wait
  351.     move_route.list      = list
  352.     return move_route
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ○ 移動ルートコマンドの作成
  356.   #--------------------------------------------------------------------------
  357.   def create_move_command(code, parameters)
  358.     list = RPG::MoveCommand.new
  359.     list.code       = code
  360.     list.parameters = parameters
  361.     return list
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # ○ インタプリタ起動用リストの作成
  365.   #--------------------------------------------------------------------------
  366.   def create_list(code, indent, parameters)
  367.     list            = RPG::EventCommand.new
  368.     list.code       = code
  369.     list.indent     = indent
  370.     list.parameters = parameters
  371.     return list
  372.   end
  373.   #--------------------------------------------------------------------------
  374.   # ○ クラス名の取得
  375.   #--------------------------------------------------------------------------
  376.   def class_name(class_instance)
  377.     return class_instance.to_s.split(":")[0].gsub("#<","")
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # ○ 配列を考慮したsplit
  381.   #--------------------------------------------------------------------------
  382.   def split_array(str)
  383.     str = convert_escape_characters(str)
  384.  
  385.     ret       = []
  386.     tmp_array = str.split(",")
  387.  
  388.     return strip_array_str(tmp_array) unless str.include?("[")
  389.     tmp_str   = ""
  390.     tmp_array.each {|s|
  391.       if char_in_str(s, "[", "]") && tmp_str.empty?
  392.         ret.push(s) unless s =~ /^\[/
  393.         ret.push([s[1...s.size-1]]) if s =~ /^\[/
  394.       else
  395.         tmp_str = "#{tmp_str}#{s},"
  396.         if char_in_str(tmp_str, "[", "]")
  397.           unless tmp_str =~ /^\[/
  398.             ret.push(tmp_str[0...tmp_str.size-1])
  399.             tmp_str = ""
  400.           else
  401.             tmp_str = tmp_str[1...tmp_str.size-2]
  402.             tmp_str = split_array(tmp_str) if tmp_str.include?("[")
  403.             tmp_str = tmp_str.split(",") if tmp_str.include?(",")
  404.             ret.push(tmp_str)   if tmp_str.is_a?(Array)
  405.             ret.push([tmp_str]) if !tmp_str.is_a?(Array)
  406.             tmp_str = ""
  407.           end
  408.         end
  409.       end
  410.     }
  411.     return strip_array_str(ret)
  412.   end
  413.   #--------------------------------------------------------------------------
  414.   # ○ 配列の中の文字列の先頭と末尾の空白を除去
  415.   #--------------------------------------------------------------------------
  416.   def strip_array_str(array, ret = [])
  417.     array.each {|str| ret.push(strip_array_str(str)) if str.is_a?(Array); next if str.is_a?(Array); ret.push(str.strip) }
  418.     return ret
  419.   end
  420.   #--------------------------------------------------------------------------
  421.   # ○ 文字列の中に文字が何文字含まれているか調べて同数ならtrueを返す
  422.   #--------------------------------------------------------------------------
  423.   def char_in_str(str, c1, c2)
  424.     num1 = 0
  425.     num2 = 0
  426.     (0...str.size).each {|i| num1 += 1 if str[i] == c1; num2 += 1 if str[i] == c2 }
  427.     return num1 == num2
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # ○ 制御文字の変換
  431.   #--------------------------------------------------------------------------
  432.   def convert_escape_characters(text)
  433.     result = text.to_s.clone
  434.     result.gsub!(/\\/)                           { "\e" }
  435.     result.gsub!(/\e\e/)                         { "\\" }
  436.     result.gsub!(/\eV\[(\d+)\]/i)                { $game_variables[$1.to_i] }
  437.     result.gsub!(/\eV\[(\d+)\]/i)                { $game_variables[$1.to_i] }
  438.     result.gsub!(/\eN\[(\d+)\]/i)                { actor_name($1.to_i) }
  439.     result.gsub!(/\eP\[(\d+)\]/i)                { party_member_name($1.to_i) }
  440.     result.gsub!(/\eG/i)                         { Vocab::currency_unit }
  441.     loop { result = result.sub(/<s>(.+?)<\/s>/i) { eval($1) }; break unless $1 }
  442.     result
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # ○ アクター n 番の名前を取得
  446.   #--------------------------------------------------------------------------
  447.   def actor_name(n)
  448.     actor = n >= 1 ? $game_actors[n] : nil
  449.     actor ? actor.name : ""
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ○ パーティメンバー n 番の名前を取得
  453.   #--------------------------------------------------------------------------
  454.   def party_member_name(n)
  455.     actor = n >= 1 ? $game_party.members[n - 1] : nil
  456.     actor ? actor.name : ""
  457.   end
  458.   #--------------------------------------------------------------------------
  459.   # ○ 配列を全て整数にする
  460.   #--------------------------------------------------------------------------
  461.   def params_to_i(params)
  462.     ret = []
  463.     params.each {|param| ret.push(param.to_i)}
  464.     return ret
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # ○ 注釈コマンド定義
  468.   #--------------------------------------------------------------------------
  469.   def define_command
  470.     @cmd_108 = {}
  471.   end
  472.   #--------------------------------------------------------------------------
  473.   # ○ 注釈コマンド定義取得
  474.   #--------------------------------------------------------------------------
  475.   def cmd_108
  476.     @cmd_108
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # ○ フレーム更新
  480.   #--------------------------------------------------------------------------
  481.   def update
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # ○ 文字の幅と高さを取得
  485.   #--------------------------------------------------------------------------
  486.   def text_size(font, size, text)
  487.     bitmap = Cache.system("")
  488.     bitmap.font.name = font
  489.     bitmap.font.size = size
  490.     tw = bitmap.text_size(text).width
  491.     th = bitmap.text_size(text).height
  492.     bitmap.dispose
  493.     return [tw, th]
  494.   end
  495.   #--------------------------------------------------------------------------
  496.   # ○ 文字の幅を取得
  497.   #--------------------------------------------------------------------------
  498.   def text_width(font, text)
  499.     texts = text.split("\n")
  500.     @max_width = 0
  501.     texts.each {|text|
  502.       width = text_size(font.name, font.size, text)[0]
  503.       @max_width = @max_width < width ? width : @max_width
  504.     }
  505.     return @max_width
  506.   end
  507. end
  508. #==============================================================================
  509. # ◆ RGSS3用処理
  510. #==============================================================================
  511. if rgss_version == 3
  512. #==============================================================================
  513. # ■ RPG::Tileset
  514. #==============================================================================
  515.  
  516. class RPG::Tileset
  517.   #--------------------------------------------------------------------------
  518.   # ○ 拡張通行判定
  519.   #--------------------------------------------------------------------------
  520.   def ex_flags
  521.     @ex_flags ||= Table.new(8192)
  522.     return @ex_flags
  523.   end
  524.   #--------------------------------------------------------------------------
  525.   # ○ 拡張通行判定初期化
  526.   #--------------------------------------------------------------------------
  527.   def init_ex_flags
  528.     @ex_flags = Table.new(8192)
  529.   end
  530. end
  531. #==============================================================================
  532. # ■ Game_Interpreter
  533. #------------------------------------------------------------------------------
  534. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  535. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  536. #==============================================================================
  537.  
  538. class Game_Interpreter
  539.   #--------------------------------------------------------------------------
  540.   # ☆ オブジェクト初期化
  541.   #     depth : ネストの深さ
  542.   #--------------------------------------------------------------------------
  543.   alias a1_common_gi_rgss3_initialize initialize
  544.   def initialize(depth = 0, sub_interpreter = false)
  545.     @sub_interpreter = sub_interpreter
  546.     a1_common_gi_rgss3_initialize(depth)
  547.   end
  548.   #--------------------------------------------------------------------------
  549.   # ☆ メッセージ表示がビジー状態の間ウェイト
  550.   #--------------------------------------------------------------------------
  551.   alias a1_common_gi_wait_for_message wait_for_message
  552.   def wait_for_message
  553.     return if @sub_interpreter
  554.     a1_common_gi_wait_for_message
  555.   end
  556. end
  557. #==============================================================================
  558. # ■ Window_Message
  559. #------------------------------------------------------------------------------
  560. #  文章表示に使うメッセージウィンドウです。
  561. #==============================================================================
  562.  
  563. class Window_Message < Window_Base
  564.   #--------------------------------------------------------------------------
  565.   # ☆ 通常文字の処理
  566.   #--------------------------------------------------------------------------
  567.   alias a1_common_wm_process_normal_character process_normal_character
  568.   def process_normal_character(c, pos)
  569.     wait_for_one_character_before
  570.     a1_common_wm_process_normal_character(c, pos)
  571.   end
  572.   #--------------------------------------------------------------------------
  573.   # ○ 一文字出力前のウェイト
  574.   #--------------------------------------------------------------------------
  575.   def wait_for_one_character_before
  576.   end
  577. end
  578. #==============================================================================
  579. # ■ RPG::Map
  580. #==============================================================================
  581.  
  582. class RPG::Map
  583.   #--------------------------------------------------------------------------
  584.   # ○ マップチップを調べるか判定する
  585.   #--------------------------------------------------------------------------
  586.   def search_map_chip?
  587.     return true if $a1_common.note_data(self.note, "マップチップサーチ")
  588.     return false
  589.   end
  590. end
  591. #==============================================================================
  592. # ■ Game_Map
  593. #------------------------------------------------------------------------------
  594. #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
  595. # このクラスのインスタンスは $game_map で参照されます。
  596. #==============================================================================
  597.  
  598. class Game_Map
  599.   #--------------------------------------------------------------------------
  600.   # ☆ セットアップ
  601.   #--------------------------------------------------------------------------
  602.   alias a1_common_gm_setup setup
  603.   def setup(map_id)
  604.     a1_common_gm_setup(map_id)
  605.     setup_tileset
  606.     map_chip_search if search_map_chip?
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # ★ タイルセットの取得
  610.   #--------------------------------------------------------------------------
  611.   def tileset
  612.     setup_tileset unless @tileset && @now_tileset_id == @tileset_id
  613.     return @tileset
  614.   end
  615.   #--------------------------------------------------------------------------
  616.   # ○ タイルセットのセットアップ
  617.   #--------------------------------------------------------------------------
  618.   def setup_tileset
  619.     @tileset        = $data_tilesets[@tileset_id].clone
  620.     @tileset.flags  = $data_tilesets[@tileset_id].flags.clone
  621.     @now_tileset_id = @tileset_id
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # ○ マップチップを調べるか判定する
  625.   #--------------------------------------------------------------------------
  626.   def search_map_chip?
  627.     return @map.search_map_chip?
  628.   end
  629.   #--------------------------------------------------------------------------
  630.   # ○ 指定座標の全レイヤーのフラグ判定(イベント含む)
  631.   #--------------------------------------------------------------------------
  632.   def all_tiles_flag?(x, y, bit)
  633.     all_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 }
  634.   end
  635.   #--------------------------------------------------------------------------
  636.   # ○ 指定座標の全レイヤーの拡張フラグ判定(イベント含む)
  637.   #--------------------------------------------------------------------------
  638.   def all_tiles_flag_ex?(x, y, bit)
  639.     all_tiles(x, y).any? {|tile_id| tileset.ex_flags[tile_id] & bit != 0 }
  640.   end
  641.   #--------------------------------------------------------------------------
  642.   # ○ 指定座標の全レイヤーの拡張フラグ判定
  643.   #--------------------------------------------------------------------------
  644.   def layered_tiles_flag_ex?(x, y, bit)
  645.     layered_tiles(x, y).any? {|tile_id| tileset.ex_flags[tile_id] & bit != 0 }
  646.   end
  647.   #--------------------------------------------------------------------------
  648.   # ○ 地形タグの取得(イベント含む)
  649.   #--------------------------------------------------------------------------
  650.   def terrain_tag_all_tailes(x, y)
  651.     return 0 unless valid?(x, y)
  652.     all_tiles(x, y).each do |tile_id|
  653.       tag = tileset.flags[tile_id] >> 12
  654.       return tag if tag > 0
  655.     end
  656.     return 0
  657.   end
  658. end
  659. #==============================================================================
  660. # ■ DataManager
  661. #------------------------------------------------------------------------------
  662. #  データベースとゲームオブジェクトを管理するモジュールです。ゲームで使用する
  663. # ほぼ全てのグローバル変数はこのモジュールで初期化されます。
  664. #==============================================================================
  665.  
  666. module DataManager
  667.   #--------------------------------------------------------------------------
  668.   # ○ エイリアス用特異メソッド
  669.   #--------------------------------------------------------------------------
  670.   class << self
  671.     alias :a1_common_create_game_objects :create_game_objects
  672.   end
  673.   #--------------------------------------------------------------------------
  674.   # ☆ 各種ゲームオブジェクトの作成
  675.   #--------------------------------------------------------------------------
  676.   def self.create_game_objects
  677.     $a1_common ||= A1_System::CommonModule.new
  678.     a1_common_create_game_objects
  679.   end
  680. end
  681. #==============================================================================
  682. # ■ Scene_Base
  683. #------------------------------------------------------------------------------
  684. #  ゲーム中の全てのシーンのスーパークラスです。
  685. #==============================================================================
  686.  
  687. class Scene_Base
  688.   #--------------------------------------------------------------------------
  689.   # ☆ フレーム更新(基本)
  690.   #--------------------------------------------------------------------------
  691.   alias a1_common_sb_update_basic update_basic
  692.   def update_basic
  693.     a1_common_sb_update_basic
  694.     $a1_common.update
  695.   end
  696.   #--------------------------------------------------------------------------
  697.   # ○ 指定のウィンドウが開いている間ウェイト
  698.   #--------------------------------------------------------------------------
  699.   def wait_for_window_open(window)
  700.     update_basic until window.openness == 0
  701.   end
  702. end
  703. #==============================================================================
  704. # ■ Window_Base
  705. #------------------------------------------------------------------------------
  706. #  ゲーム中の全てのウィンドウのスーパークラスです。
  707. #==============================================================================
  708.  
  709. class Window_Base < Window
  710.   #--------------------------------------------------------------------------
  711.   # ★ 制御文字の事前変換
  712.   #    実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
  713.   #    文字「\」はエスケープ文字(\e)に変換。
  714.   #--------------------------------------------------------------------------
  715.   def convert_escape_characters(text)
  716.     return $a1_common.convert_escape_characters(text)
  717.   end
  718. end
  719. #==============================================================================
  720. # ◆ RGSS2用処理
  721. #==============================================================================
  722. elsif rgss_version == 2
  723. #==============================================================================
  724. # ■ Window
  725. #==============================================================================
  726.  
  727. class Window
  728.   #--------------------------------------------------------------------------
  729.   # ○ ウィンドウが開いている?
  730.   #--------------------------------------------------------------------------
  731.   def open?
  732.     return self.openness == 255
  733.   end
  734.   #--------------------------------------------------------------------------
  735.   # ○ ウィンドウが閉じている?
  736.   #--------------------------------------------------------------------------
  737.   def close?
  738.     return self.openness == 0
  739.   end
  740. end
  741. #==============================================================================
  742. # ■ Cache
  743. #------------------------------------------------------------------------------
  744. #  各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
  745. # です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
  746. # のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
  747. # を返すようになっています。
  748. #==============================================================================
  749.  
  750. module Cache
  751.   #--------------------------------------------------------------------------
  752.   # ○ キャッシュ存在チェック
  753.   #--------------------------------------------------------------------------
  754.   def self.include?(key)
  755.     @cache[key] && !@cache[key].disposed?
  756.   end
  757. end
  758. #==============================================================================
  759. # ■ Game_Interpreter
  760. #------------------------------------------------------------------------------
  761. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  762. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  763. #==============================================================================
  764.  
  765. class Game_Interpreter
  766.   #--------------------------------------------------------------------------
  767.   # ○ 注釈
  768.   #--------------------------------------------------------------------------
  769.   def command_108
  770.     @comments = [@params[0]]
  771.     while next_event_code == 408
  772.       @index += 1
  773.       @comments.push(@list[@index].parameters[0])
  774.     end
  775.   end
  776.   #--------------------------------------------------------------------------
  777.   # ★ イベントコマンドの実行
  778.   #--------------------------------------------------------------------------
  779.   def execute_command
  780.     return rgss3_execute_command unless @index >= @list.size-1
  781.     command_end
  782.     return true
  783.   end
  784.   #--------------------------------------------------------------------------
  785.   # ○ RGSS3風「イベントコマンドの実行」
  786.   #--------------------------------------------------------------------------
  787.   def rgss3_execute_command
  788.     command = @list[@index]
  789.     @params = command.parameters
  790.     @indent = command.indent
  791.     method_name = "command_#{command.code}"
  792.     send(method_name) if respond_to?(method_name)
  793.   end
  794.   #--------------------------------------------------------------------------
  795.   # ○ 次のイベントコマンドのコードを取得
  796.   #--------------------------------------------------------------------------
  797.   def next_event_code
  798.     @list[@index + 1].code
  799.   end
  800. end
  801. #==============================================================================
  802. # ■ Game_Map
  803. #------------------------------------------------------------------------------
  804. #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
  805. # このクラスのインスタンスは $game_map で参照されます。
  806. #==============================================================================
  807.  
  808. class Game_Map
  809.   #--------------------------------------------------------------------------
  810.   # ○ マップチップを調べるか判定する
  811.   #--------------------------------------------------------------------------
  812.   def search_map_chip?
  813.     return $data_map_infos[@map_id].name =~ /\[サーチ\]/
  814.   end
  815.   #--------------------------------------------------------------------------
  816.   # ○ 指定座標に存在するタイル扱いイベント(すり抜け以外)の配列取得
  817.   #--------------------------------------------------------------------------
  818.   def tile_events_xy(x, y)
  819.     @tile_events.select {|event| event.pos_nt?(x, y) }
  820.   end
  821.   #--------------------------------------------------------------------------
  822.   # ○ タイル扱いイベントの配列をリフレッシュ
  823.   #--------------------------------------------------------------------------
  824.   def refresh_tile_events
  825.     @tile_events = @events.values.select {|event| event.tile? }
  826.   end
  827. end
  828. #==============================================================================
  829. # ■ Game_Character
  830. #------------------------------------------------------------------------------
  831. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  832. # クラスのスーパークラスとして使用されます。
  833. #==============================================================================
  834.  
  835. class Game_Character
  836.   #--------------------------------------------------------------------------
  837.   # ○ タイル判定
  838.   #--------------------------------------------------------------------------
  839.   def tile?
  840.     @tile_id > 0 && @priority_type == 0
  841.   end
  842. end
  843. #==============================================================================
  844. # ■ Scene_Title
  845. #------------------------------------------------------------------------------
  846. #  タイトル画面の処理を行うクラスです。
  847. #==============================================================================
  848.  
  849. class Scene_Title < Scene_Base
  850.   #--------------------------------------------------------------------------
  851.   # ☆ データベースのロード
  852.   #--------------------------------------------------------------------------
  853.   alias a1_common_st_load_database load_database
  854.   def load_database
  855.     a1_common_st_load_database
  856.     $data_map_infos = load_data("Data/MapInfos.rvdata")
  857.   end
  858.   #--------------------------------------------------------------------------
  859.   # ☆ 各種ゲームオブジェクトの作成
  860.   #--------------------------------------------------------------------------
  861.   alias a1_common_st_create_game_objects create_game_objects
  862.   def create_game_objects
  863.     $a1_common ||= A1_System::CommonModule.new
  864.     a1_common_st_create_game_objects
  865.   end
  866. end
  867. #==============================================================================
  868. # ◆ RGSS用処理
  869. #==============================================================================
  870. elsif rgss_version == 1
  871. end
  872. #==============================================================================
  873. # ■ Cache
  874. #------------------------------------------------------------------------------
  875. #  各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
  876. # です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
  877. # のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
  878. # を返すようになっています。
  879. #==============================================================================
  880.  
  881. module Cache
  882.   #--------------------------------------------------------------------------
  883.   # ○ 拡大縮小したビットマップのロード
  884.   #--------------------------------------------------------------------------
  885.   def self.load_resize_bitmap(load_path, key, resize = nil)
  886.     @cache ||= {}
  887.     key = load_path if key == nil
  888.     return @cache[key] if include?(key)
  889.  
  890.     @cache[key] = Bitmap.new(load_path)
  891.     return @cache[key] if resize == nil
  892.     return @cache[key] if @cache[key].width == resize[0] and @cache[key].height == resize[1]
  893.  
  894.     info = calc_size(resize, key)
  895.     return resize_bitmap(@cache[key], info[0], info[1], key)
  896.   end
  897.   #--------------------------------------------------------------------------
  898.   # ○ 拡大縮小した色相変化済みビットマップを作成/取得
  899.   #--------------------------------------------------------------------------
  900.   def self.load_resize_hue_changed_bitmap(load_path, path, hue, resize)
  901.     key = [path, hue]
  902.     return @cache[key] if include?(key)
  903.  
  904.     @cache[key] = load_resize_bitmap(load_path, path, resize).clone
  905.     @cache[key].hue_change(hue)
  906.     return @cache[key]
  907.   end
  908.   #--------------------------------------------------------------------------
  909.   # ○ リサイズするサイズを取得
  910.   #--------------------------------------------------------------------------
  911.   def self.calc_size(resize, key)
  912.     width  = resize[0]
  913.     width  = @cache[key].width * width.abs if width < 0
  914.     height = resize[1]
  915.     height = @cache[key].height * height.abs if height < 0
  916.     height = Integer(@cache[key].height * (width.to_f / @cache[key].width.to_f)) if height == 0
  917.     return [width, height]
  918.   end
  919.   #--------------------------------------------------------------------------
  920.   # ○ ビットマップの拡大縮小
  921.   #--------------------------------------------------------------------------
  922.   def self.resize_bitmap(bitmap, width, height, key)
  923.     resize = Bitmap.new(width, height)
  924.     resize.stretch_blt(resize.rect, bitmap, bitmap.rect)
  925.     @cache[key] = resize
  926.     return resize
  927.   end
  928.   #--------------------------------------------------------------------------
  929.   # ○ テキストビットマップの取得
  930.   #--------------------------------------------------------------------------
  931.   def self.text_picture(text, font)
  932.     load_text_bitmap(text, font)
  933.   end
  934.   #--------------------------------------------------------------------------
  935.   # ○ フォントのキーを作成
  936.   #--------------------------------------------------------------------------
  937.   def self.make_font_key(text, font)
  938.     [text, font.name, font.size, font.bold, font.italic, font.outline, font.shadow, font.color.to_s, font.out_color.to_s]
  939.   end
  940.   #--------------------------------------------------------------------------
  941.   # ○ テキストビットマップの作成
  942.   #--------------------------------------------------------------------------
  943.   def self.load_text_bitmap(text, font)
  944.     @cache ||= {}
  945.     key = make_font_key(text, font)
  946.     return @cache[key] if include?(key)
  947.  
  948.     # 計算用ダミービットマップ
  949.     bitmap = Cache.system("")
  950.     bitmap.font = font
  951.     tw = bitmap.text_size(text).width + 8
  952.  
  953.     # ビットマップ作成
  954.     bitmap = Bitmap.new(tw, bitmap.font.size + 4)
  955.     bitmap.font = font
  956.     bitmap.draw_text(0, 0, bitmap.width, bitmap.height, text, 1)
  957.  
  958.     @cache[key] = bitmap
  959.     return @cache[key]
  960.   end
  961. end
  962. #==============================================================================
  963. # ■ Game_Interpreter
  964. #------------------------------------------------------------------------------
  965. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  966. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  967. #==============================================================================
  968.  
  969. class Game_Interpreter
  970.   #--------------------------------------------------------------------------
  971.   # ○ 注釈
  972.   #--------------------------------------------------------------------------
  973.   alias a1_common_command_108 command_108
  974.   def command_108
  975.     a1_common_command_108
  976.     proc_comment(@comments)
  977.   end
  978.   #--------------------------------------------------------------------------
  979.   # ○ 注釈の処理
  980.   #--------------------------------------------------------------------------
  981.   def proc_comment(comments)
  982.     param = ""
  983.     comments.each {|comment| param += comment }
  984.     params = param.sub(/^(\S+)/, "")
  985.     command = $1
  986.     comment_parameters = $a1_common.split_array(params) if params
  987.     proc_comment_command(command, comment_parameters)
  988.   end
  989.   #--------------------------------------------------------------------------
  990.   # ○ 注釈の実行
  991.   #--------------------------------------------------------------------------
  992.   def proc_comment_command(command, params)
  993.     cmd_108 = $a1_common.cmd_108[command]
  994.     method(cmd_108).call(params) if cmd_108 != nil
  995.   end
  996.   #--------------------------------------------------------------------------
  997.   # ○ 前のイベントコマンドを取得
  998.   #--------------------------------------------------------------------------
  999.   def prev_event
  1000.     @list[@index - 1]
  1001.   end
  1002. end
  1003. #==============================================================================
  1004. # ■ Game_Map
  1005. #------------------------------------------------------------------------------
  1006. #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
  1007. # このクラスのインスタンスは $game_map で参照されます。
  1008. #==============================================================================
  1009.  
  1010. class Game_Map
  1011.   #--------------------------------------------------------------------------
  1012.   # ○ 全マップチップを調べる
  1013.   #--------------------------------------------------------------------------
  1014.   def map_chip_search
  1015.     tileset.init_ex_flags
  1016.     ([email]0...@map.data.xsize[/email]).each {|x| map_chip_search_y(x) }
  1017.   end
  1018.   #--------------------------------------------------------------------------
  1019.   # ○ x座標にあるy座標のマップチップを調べる
  1020.   #--------------------------------------------------------------------------
  1021.   def map_chip_search_y(x)
  1022.     ([email]0...@map.data.ysize[/email]).each {|y| map_pos_proc(x, y); map_chip_search_z(x, y) }
  1023.   end
  1024.   #--------------------------------------------------------------------------
  1025.   # ○ x,y座標にあるz座標のマップチップを調べる
  1026.   #--------------------------------------------------------------------------
  1027.   def map_chip_search_z(x, y)
  1028.     ([email]0...@map.data.zsize[/email]).each {|z| map_chip_proc(x, y, z) }
  1029.     tile_events_xy(x, y).collect {|ev| tile_event_proc(ev.tile_id) }
  1030.   end
  1031.   #--------------------------------------------------------------------------
  1032.   # ○ 座標に対して処理を行う
  1033.   #--------------------------------------------------------------------------
  1034.   def map_pos_proc(x, y)
  1035.   end
  1036.   #--------------------------------------------------------------------------
  1037.   # ○ マップチップに対して処理を行う
  1038.   #--------------------------------------------------------------------------
  1039.   def map_chip_proc(x, y, z)
  1040.   end
  1041.   #--------------------------------------------------------------------------
  1042.   # ○ タイルのイベントに対して処理を行う
  1043.   #--------------------------------------------------------------------------
  1044.   def tile_event_proc(tile_id)
  1045.   end
  1046. end
  1047. #==============================================================================
  1048. # ■ Window_Base
  1049. #------------------------------------------------------------------------------
  1050. #  ゲーム中の全てのウィンドウのスーパークラスです。
  1051. #==============================================================================
  1052.  
  1053. class Window_Base < Window
  1054.   #--------------------------------------------------------------------------
  1055.   # ○ 入力を受け付けるか?
  1056.   #--------------------------------------------------------------------------
  1057.   def can_input?
  1058.     @can_input
  1059.   end
  1060.   #--------------------------------------------------------------------------
  1061.   # ○ 入力受け付け設定
  1062.   #--------------------------------------------------------------------------
  1063.   def can_input=(flag)
  1064.     @can_input = flag
  1065.   end
  1066. end
  1067. #==============================================================================
  1068. # ■ Bitmap
  1069. #==============================================================================
  1070.  
  1071. class Bitmap
  1072.   #--------------------------------------------------------------------------
  1073.   # ○ 文字縁取り描画
  1074.   #--------------------------------------------------------------------------
  1075.   def draw_text_f(x, y, width, height, str, align = 0, color = Color.new(64,32,128))
  1076.     shadow = self.font.shadow
  1077.     b_color = self.font.color.dup
  1078.     font.shadow = false
  1079.     font.color = color
  1080.     draw_text(x + 1, y, width, height, str, align)
  1081.     draw_text(x - 1, y, width, height, str, align)
  1082.     draw_text(x, y + 1, width, height, str, align)
  1083.     draw_text(x, y - 1, width, height, str, align)
  1084.     font.color = b_color
  1085.     draw_text(x, y, width, height, str, align)
  1086.     font.shadow = shadow
  1087.   end
  1088.   #--------------------------------------------------------------------------
  1089.   # ○ 文字縁取り描画の矩形を取得
  1090.   #--------------------------------------------------------------------------
  1091.   def draw_text_f_rect(r, str, align = 0, color = Color.new(64,32,128))
  1092.     draw_text_f(r.x, r.y, r.width, r.height, str, align = 0, color)
  1093.   end
  1094. end




本體


RUBY 代码复制
  1. #===========================================================================
  2. # ◆ A1 Scripts ◆
  3. #    吹き出しメッセージ(RGSS3)
  4. #
  5. # バージョン   : 1.00 (2012/01/12)
  6. # 作者         : A1
  7. # URL     : [url]http://a1tktk.web.fc2.com/[/url]
  8. #---------------------------------------------------------------------------
  9. # 機能:
  10. # ・吹き出しメッセージを表示します
  11. #---------------------------------------------------------------------------
  12. # 更新履歴   :2012/01/12 Ver1.00 リリース
  13. #---------------------------------------------------------------------------
  14. # 設置場所      
  15. #    A1共通スクリプト以下
  16. #    (ネームウィンドウ以下)
  17. #
  18. # 必要スクリプト
  19. #    A1共通スクリプトVer4.00以上
  20. #
  21. # 必要ファイル
  22. #    Window_Popup.png  ※ Graphics/System にインポート
  23. #---------------------------------------------------------------------------
  24. # 使い方
  25. #   ■ 設定項目 に設定
  26. #
  27. #   イベントコマンド「注釈」に記述
  28. #
  29. #     並列吹き出し
  30. #
  31. #       指定後1回のの文章を並列吹き出しとして表示します
  32. #       並列吹き出しは、吹き出し表示中でもプレイヤーの移動や
  33. #       イベントコマンドの実行・続行が可能です
  34. #
  35. #       また、他の吹き出しと同時に閉じることがなくなります
  36. #
  37. #     イベント吹き出し event_id
  38. #
  39. #       イベントを直接指定して吹き出しを表示します
  40. #
  41. #     吹き出しクローズ key
  42. #
  43. #       指定した吹き出しを閉じます
  44. #       設定項目で設定した [歩行グラフィック名]_[歩行グラフィックIndex] を
  45. #       key に指定します
  46. #
  47. #       例:吹き出しクローズ Actor4_0
  48. #
  49. #     吹き出しクローズ [イベント,event_id]
  50. #
  51. #       イベント吹き出しで表示した吹き出しを閉じます
  52. #
  53. #       例:吹き出しクローズ [イベント,5]
  54. #
  55. #           ※先に「イベント吹き出し」でevent_id 5 のイベントに
  56. #             吹き出しを表示させているものとします
  57. #
  58. #     吹き出し使用 on|off
  59. #
  60. #       吹き出しの使用を切り替えます
  61. #       on で吹き出し使用、off で吹き出し使用しなくなります
  62. #
  63. #
  64. #   メッセージウィンドウコマンド
  65. #
  66. #     \CC[count] :クローズカウントを設定します(フレーム数)
  67. #                  設定項目のデフォルト値より優先されます
  68. #
  69. #     \KP        :吹き出しのヒレが「考え中」になります
  70. #
  71. #     \PR        :並列吹き出し状態として表示した吹き出しの
  72. #                  並列吹き出し状態をメッセージ終了後に解除します
  73. #
  74. #                  解除された場合、他の吹き出しと同時に閉じるようになります
  75. #==============================================================================
  76. $imported ||= {}
  77. $imported["A1_PopupMassage"] = true
  78. if $imported["A1_Common_Script"]
  79. old_common_script("吹き出しメッセージ", "4.00") if common_version < 4.00
  80. #==============================================================================
  81. # ■ 設定項目
  82. #==============================================================================
  83. module A1_System::CnildMassageWindowConfig
  84.   #--------------------------------------------------------------------------
  85.   # 顔グラフィックと歩行グラフィックの対応
  86.   #
  87.   #  "[顔グラフィック名]_[Index]" => "[歩行グラフィック名]_[Index]" ※Index毎に設定
  88.   #  "[顔グラフィック名]"         => "[歩行グラフィック名]_[Index]" ※該当顔グラフィック全てに適用
  89.   #
  90.   #  歩行グラフィックは配列で複数指定することが可能です
  91.   #--------------------------------------------------------------------------
  92.   LINK_FACE       = {
  93.    # 顔グラフィック => 歩行グラフィック
  94.     "Actor4_0"      => "Actor4_0",
  95.     "Actor4_4"      => "Actor4_4",
  96.     "Actor4_5"      => "Actor4_5",
  97.   }
  98.   #--------------------------------------------------------------------------
  99.   # 文字入力待ちでないウィンドウが閉じるまでの時間(フレーム)のデフォルト値
  100.   #   -1 にすると手動で閉じるかイベント終了まで閉じません
  101.   #   -1 にすると「並列吹き出し」にしたウィンドウは手動で閉じるまでずっと閉じません
  102.   #--------------------------------------------------------------------------
  103.   DEFAULT_CLOSE_COUNT = -1
  104.   #--------------------------------------------------------------------------
  105.   # 吹き出しメッセージ使用のデフォルト値
  106.   #--------------------------------------------------------------------------
  107.   DEFAULT_ENABLE_POPUP = true
  108. end
  109. #==============================================================================
  110. # ■ Cache
  111. #------------------------------------------------------------------------------
  112. #  各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
  113. # です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
  114. # のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
  115. # を返すようになっています。
  116. #==============================================================================
  117.  
  118. module Cache
  119.   #--------------------------------------------------------------------------
  120.   # ○ 顔グラフィックの取得
  121.   #--------------------------------------------------------------------------
  122.   def self.half_face(filename)
  123.     load_file_name = "Graphics/Faces/#{filename}"
  124.     key            = "#{load_file_name}_halfface"
  125.     load_resize_bitmap(load_file_name, key, [-0.5, -0.5])
  126.   end
  127. end
  128. #==============================================================================
  129. # ■ Window_Message
  130. #------------------------------------------------------------------------------
  131. #  文章表示に使うメッセージウィンドウです。
  132. #==============================================================================
  133.  
  134. class Window_Message < Window_Base
  135.   #--------------------------------------------------------------------------
  136.   # ○ 定数
  137.   #--------------------------------------------------------------------------
  138.   LINK_FACE = A1_System::CnildMassageWindowConfig::LINK_FACE
  139.   #--------------------------------------------------------------------------
  140.   # ○ 子メッセージウィンドウのキーを取得
  141.   #--------------------------------------------------------------------------
  142.   def child_key
  143.     return event_id_key if $game_temp.event_popup_id
  144.     key = LINK_FACE["#{$game_message.face_name}_#{$game_message.face_index}"]
  145.     key = LINK_FACE["#{$game_message.face_name}"] unless key
  146.     return key
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ○ イベントIDからキーを設定
  150.   #--------------------------------------------------------------------------
  151.   def event_id_key
  152.     key = "event_id_key_#{$game_temp.event_popup_id}"
  153.     $game_temp.event_popup_id = nil
  154.     return key
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ☆ 全ウィンドウの作成
  158.   #--------------------------------------------------------------------------
  159.   alias a1_child_message_window_wm_create_all_windows create_all_windows
  160.   def create_all_windows
  161.     a1_child_message_window_wm_create_all_windows
  162.     @child_message_window = {}
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ☆ 全ウィンドウの解放
  166.   #--------------------------------------------------------------------------
  167.   alias a1_child_message_window_wm_dispose_all_windows dispose_all_windows
  168.   def dispose_all_windows
  169.     a1_child_message_window_wm_dispose_all_windows
  170.     @child_message_window.values.each {|window| window.dispose }
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ☆ 全ウィンドウの更新
  174.   #--------------------------------------------------------------------------
  175.   alias a1_child_message_window_wm_update_all_windows update_all_windows
  176.   def update_all_windows
  177.     a1_child_message_window_wm_update_all_windows
  178.     @child_message_window.values.each {|window| window.update }
  179.     close_window = $game_message.close_message
  180.     @child_message_window[close_window].close if close_window && @child_message_window[close_window]
  181.     $game_message.close_message = nil
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ☆ 全テキストの処理
  185.   #--------------------------------------------------------------------------
  186.   alias a1_child_message_window_wm_process_all_text process_all_text
  187.   def process_all_text
  188.     @use_child = false
  189.     return a1_child_message_window_wm_process_all_text unless need_setup?
  190.     @child_key = child_key
  191.     return if setup_child_message if @child_key && !@child_key.empty?
  192.     a1_child_message_window_wm_process_all_text
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ○ 子メッセージウィンドウのセットアップが必要?
  196.   #--------------------------------------------------------------------------
  197.   def need_setup?
  198.     return false if $game_party.in_battle
  199.     return false if @my_child_window
  200.     return $game_system.enable_child_msg
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ○ 子メッセージウィンドウのセットアップ
  204.   #--------------------------------------------------------------------------
  205.   def setup_child_message
  206.     @child_message_window[@child_key] ||= create_child_message
  207.     return false unless @child_message_window[@child_key].link_event
  208.     close
  209.     process_child_message_window(@child_message_window[@child_key])
  210.     return true
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ○ 子メッセージウィンドウの作成
  214.   #--------------------------------------------------------------------------
  215.   def create_child_message
  216.     window = Window_ChildMessage.new
  217.     return set_link_event_id(window, $1.to_i) if @child_key =~ /event_id_key_(\d+)/
  218.     return window if link_player(window)
  219.     $game_map.events.values.each {|event| break if link_event(event, window) }
  220.     return window
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # ○ リンクするプレイヤーの取得
  224.   #--------------------------------------------------------------------------
  225.   def link_player(window)
  226.     return true if link_event($game_player, window)
  227.     $game_player.followers.each {|follower| return true if link_event(follower, window) }
  228.     return false
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # ○ リンクするイベントの取得
  232.   #--------------------------------------------------------------------------
  233.   def link_event(event, window)
  234.     return false unless search_link_event(event.character_name, event.character_index)
  235.     set_link_event(window, event)
  236.     return true
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ○ リンクするイベントの検索
  240.   #--------------------------------------------------------------------------
  241.   def search_link_event(name, index)
  242.     return "#{name}_#{index}" == @child_key unless @child_key.is_a?(Array)
  243.     @child_key.each {|key| return true if "#{name}_#{index}" == key }
  244.     return false
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ○ リンクするイベントの設定(ID)
  248.   #--------------------------------------------------------------------------
  249.   def set_link_event_id(window, event_id)
  250.     window.link_event = $game_map.events[event_id]
  251.     return window
  252.   end
  253.   #--------------------------------------------------------------------------
  254.   # ○ リンクするイベントの設定
  255.   #--------------------------------------------------------------------------
  256.   def set_link_event(window, event)
  257.     window.link_event = event
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ○ 子メッセージウィンドウの処理
  261.   #--------------------------------------------------------------------------
  262.   def process_child_message_window(window)
  263.     @child_window = window
  264.     window.position     = $game_message.position
  265.     text                = convert_escape_characters($game_message.all_text)
  266.     text_width          = $a1_common.text_width(window.contents.font, text)
  267.     $game_message.texts = text.split("\n")
  268.     window.set_face_info($game_message.face_name, $game_message.face_index)
  269.     window.set_width(window.new_line_x + text_width + standard_padding * 2)
  270.     window.background   = $game_message.background
  271.     window.create_contents
  272.     setup_priority(window)
  273.     window.process_all_text
  274.     @use_child = true
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # ○ 子メッセージウィンドウの表示優先度の設定
  278.   #--------------------------------------------------------------------------
  279.   def setup_priority(now_window)
  280.     @priority_order ||= []
  281.     @priority_order.delete(@child_key)
  282.     @priority_order.insert(0, @child_key)
  283.     @priority_order.each_with_index {|key, i | @child_message_window[key].priority = @priority_order.size - i }
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ○ クローズカウントのセット
  287.   #--------------------------------------------------------------------------
  288.   def set_close_count(value)
  289.     @child_window.close_count = value
  290.     return ""
  291.   end
  292.   #--------------------------------------------------------------------------
  293.   # ○ ポップアップ種別のセット
  294.   #--------------------------------------------------------------------------
  295.   def set_popup_kind
  296.     @child_window.popup_kind = 1
  297.     return ""
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ☆ 入力待ち処理
  301.   #--------------------------------------------------------------------------
  302.   alias a1_child_message_window_wm_input_pause input_pause
  303.   def input_pause
  304.     return if @use_child
  305.     a1_child_message_window_wm_input_pause
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # ☆ ウィンドウを閉じ、完全に閉じるまで待つ
  309.   #--------------------------------------------------------------------------
  310.   alias a1_child_message_window_wm_close_and_wait close_and_wait
  311.   def close_and_wait
  312.     @child_message_window.values.each {|window| window.close if window.input_wait }
  313.     a1_child_message_window_wm_close_and_wait
  314.     @priority_order = []
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ☆ 全ウィンドウが完全に閉じているか判定
  318.   #--------------------------------------------------------------------------
  319.   alias a1_child_message_window_wm_all_close? all_close?
  320.   def all_close?
  321.     return false unless a1_child_message_window_wm_all_close?
  322.     @child_message_window.values.each {|window| return false unless window.close? if window.input_wait }
  323.     return true
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ☆ 背景と位置の変更判定
  327.   #--------------------------------------------------------------------------
  328.   alias a1_child_message_window_wm_settings_changed? settings_changed?
  329.   def settings_changed?
  330.     return false if $game_system.enable_child_msg
  331.     a1_child_message_window_wm_settings_changed?
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ○ 吹き出しの初期化
  335.   #--------------------------------------------------------------------------
  336.   def init_popup_message
  337.     @child_message_window.values.each {|window| window.dispose }
  338.     @child_message_window = {}
  339.   end
  340. end
  341. #==============================================================================
  342. # ■ Window_ChildMessage
  343. #==============================================================================
  344.  
  345. class Window_ChildMessage < Window_Message
  346.   #--------------------------------------------------------------------------
  347.   # ○ 定数
  348.   #--------------------------------------------------------------------------
  349.   CLOSE_COUNT      = A1_System::CnildMassageWindowConfig::DEFAULT_CLOSE_COUNT
  350.   POS_UP           = 0
  351.   POS_MIDDLE       = 1
  352.   POS_DOWN         = 2
  353.   POPUP_RECT       = { POS_UP     => [Rect.new( 0,  0, 32, 64), Rect.new( 0, 64, 32, 64)],
  354.                        POS_MIDDLE => [Rect.new( 0,  0, 32, 64), Rect.new( 0, 64, 32, 64)],
  355.                        POS_DOWN   => [Rect.new(32,  0, 32, 64), Rect.new(32, 64, 32, 64)],
  356.                      }
  357.   #--------------------------------------------------------------------------
  358.   # ○ オブジェクト初期化
  359.   #--------------------------------------------------------------------------
  360.   def initialize
  361.     @my_child_window = true
  362.     @screen_width = Graphics.width
  363.     super
  364.     create_popup
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # ○ 表示優先度の設定
  368.   #--------------------------------------------------------------------------
  369.   def priority=(value)
  370.     self.z = 200 + value
  371.     @popup_sprite.z = 200 + value
  372.   end
  373.   #--------------------------------------------------------------------------
  374.   # ○ 吹き出しスプライトの作成
  375.   #--------------------------------------------------------------------------
  376.   def create_popup
  377.     @popup_sprite = Sprite.new
  378.     @popup_sprite.visible = false
  379.     @popup_bitmap = Cache.system("Window_Popup")
  380.     bitmap = Bitmap.new(32, 64)
  381.     @popup_sprite.bitmap = bitmap
  382.     @input_wait = true
  383.   end
  384.   #--------------------------------------------------------------------------
  385.   # ○ 顔グラフィックの情報を設定
  386.   #--------------------------------------------------------------------------
  387.   def set_face_info(name, index)
  388.     @face_name  = name
  389.     @face_index = index
  390.     @name_window_key = show_name(@face_name, @face_index) if $imported["A1_Name_Window"]
  391.   end
  392.   #--------------------------------------------------------------------------
  393.   # ○ リンクするイベントの取得
  394.   #--------------------------------------------------------------------------
  395.   def link_event
  396.     @event
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ○ リンクするイベントの設定
  400.   #--------------------------------------------------------------------------
  401.   def link_event=(event)
  402.     @event = event
  403.   end
  404.   #--------------------------------------------------------------------------
  405.   # ○ 表示位置の設定
  406.   #--------------------------------------------------------------------------
  407.   def position=(pos)
  408.     @position = pos
  409.     @position = 0 if @position == 1
  410.     set_popup_bitmap(0)
  411.   end
  412.   #--------------------------------------------------------------------------
  413.   # ○ 背景の設定
  414.   #--------------------------------------------------------------------------
  415.   def background=(type)
  416.     @background = type
  417.     self.opacity = @background == 0 ? 255 : 0
  418.     setup_back_ground if @background == 1
  419.     @back_sprite.visible = false if @back_sprite && @background != 1
  420.   end
  421.   #--------------------------------------------------------------------------
  422.   # ○ 背景のセットアップ
  423.   #--------------------------------------------------------------------------
  424.   def setup_back_ground
  425.     @back_bitmap.dispose if @back_bitmap
  426.     create_back_bitmap_ex
  427.     @back_sprite = Sprite.new unless @back_sprite
  428.     setup_back_sprite
  429.   end
  430.   #--------------------------------------------------------------------------
  431.   # ○ 背景のビットマップ作成
  432.   #--------------------------------------------------------------------------
  433.   def create_back_bitmap_ex
  434.     @back_bitmap = Bitmap.new(width, height)
  435.     rect1 = Rect.new(0, 0, width, 12)
  436.     rect2 = Rect.new(0, 12, width, height - 24)
  437.     rect3 = Rect.new(0, height - 12, width, 12)
  438.     @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
  439.     @back_bitmap.fill_rect(rect2, back_color1)
  440.     @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # ○ 背景のスプライトの作成
  444.   #--------------------------------------------------------------------------
  445.   def setup_back_sprite
  446.     @back_sprite.bitmap = @back_bitmap
  447.     @back_sprite.z = z - 1
  448.     @back_sprite.visible = false
  449.   end
  450.   #--------------------------------------------------------------------------
  451.   # ○ 背景ビットマップの解放
  452.   #--------------------------------------------------------------------------
  453.   def dispose_back_bitmap
  454.     super if @back_bitmap
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # ○ 背景スプライトの解放
  458.   #--------------------------------------------------------------------------
  459.   def dispose_back_sprite
  460.     super if @back_sprite
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ○ 背景スプライトの更新
  464.   #--------------------------------------------------------------------------
  465.   def update_back_sprite
  466.     return unless @back_sprite && @background == 1
  467.     @back_sprite.x = self.x
  468.     @back_sprite.y = self.y
  469.     @back_sprite.visible = true
  470.     @back_sprite.opacity = openness
  471.     @back_sprite.update
  472.   end
  473.   #--------------------------------------------------------------------------
  474.   # ○ ウィンドウ背景の更新
  475.   #--------------------------------------------------------------------------
  476.   def update_background
  477.     self.opacity = @background == 0 ? 255 : 0
  478.   end
  479.   #--------------------------------------------------------------------------
  480.   # ○ フレーム更新
  481.   #--------------------------------------------------------------------------
  482.   def update
  483.     return unless @event
  484.     update_pos
  485.     super
  486.     update_close_count
  487.     update_background
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # ○ クローズカウントの更新
  491.   #--------------------------------------------------------------------------
  492.   def update_close_count
  493.     return unless @close_count
  494.     return if @close_count < 0
  495.     @close_count -= 1
  496.     auto_close if @close_count == 0
  497.   end
  498.   #--------------------------------------------------------------------------
  499.   # ○ ポップアップスプライト位置の設定
  500.   #--------------------------------------------------------------------------
  501.   def set_popup_pos
  502.     @popup_sprite.x = @event.screen_x
  503.     @popup_sprite.y = self.y + popup_pos_y
  504.     @popup_sprite.visible = open? && @background == 0
  505.   end
  506.   #--------------------------------------------------------------------------
  507.   # ○ ポップアップビットマップの設定
  508.   #--------------------------------------------------------------------------
  509.   def set_popup_bitmap(kind)
  510.     @popup_sprite.bitmap.clear
  511.     @popup_sprite.bitmap.blt(0, 0, @popup_bitmap, POPUP_RECT[@position][kind])
  512.   end
  513.   #--------------------------------------------------------------------------
  514.   # ○ ポップアップ種別の設定
  515.   #--------------------------------------------------------------------------
  516.   def popup_kind=(kind)
  517.     set_popup_bitmap(1)
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # ○ ウィンドウ位置の更新
  521.   #--------------------------------------------------------------------------
  522.   def update_pos
  523.     self.x = @event.screen_x + @pos_x
  524.     self.y = @event.screen_y + pos_y
  525.     set_popup_pos
  526.     set_name_window_pos if $imported["A1_Name_Window"]
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # ○ ネームウィンドウの位置設定
  530.   #--------------------------------------------------------------------------
  531.   def set_name_window_pos
  532.     return unless @name_windows[@name_window_key]
  533.     @name_windows[@name_window_key].x = self.x + 24
  534.     @name_windows[@name_window_key].y = name_window_y
  535.     @name_windows[@name_window_key].z = self.z
  536.     @name_windows[@name_window_key].set_name_sprite_pos
  537.   end
  538.   #--------------------------------------------------------------------------
  539.   # ○ ネームウィンドウのy座標設定
  540.   #--------------------------------------------------------------------------
  541.   def name_window_y
  542.     return self.y + self.height - 12 if @position == 2
  543.     self.y - 16
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # ○ ウィンドウx座標の取得
  547.   #--------------------------------------------------------------------------
  548.   def set_pos_x
  549.     base = @event.screen_x - 64
  550.     return @pos_x = (@screen_width - self.width) - (base + 64) if base + self.width > @screen_width
  551.     @pos_x = -64
  552.   end
  553.   #--------------------------------------------------------------------------
  554.   # ○ ウィンドウy座標の取得
  555.   #--------------------------------------------------------------------------
  556.   def pos_y
  557.     return -116 if @position == 0
  558.     return  16 if @position == 2
  559.   end
  560.   #--------------------------------------------------------------------------
  561.   # ○ ポップアップy座標の取得
  562.   #--------------------------------------------------------------------------
  563.   def popup_pos_y
  564.     return self.height - 32 if @position == 0
  565.     return -32 if @position == 2
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # ○ 自動で閉じる
  569.   #--------------------------------------------------------------------------
  570.   def auto_close
  571.     close
  572.     @close_count = nil
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # ○ 解放
  576.   #--------------------------------------------------------------------------
  577.   def dispose
  578.     @popup_sprite.bitmap.dispose
  579.     @popup_sprite.dispose
  580.     super
  581.   end
  582.   #--------------------------------------------------------------------------
  583.   # ○ 制御文字の事前変換
  584.   #--------------------------------------------------------------------------
  585.   def convert_escape_characters(text)
  586.     text
  587.   end
  588.   #--------------------------------------------------------------------------
  589.   # ○ 背景ビットマップの作成
  590.   #--------------------------------------------------------------------------
  591.   def create_back_bitmap
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # ○ 背景スプライトの作成
  595.   #--------------------------------------------------------------------------
  596.   def create_back_sprite
  597.   end
  598.   #--------------------------------------------------------------------------
  599.   # ○ 全ウィンドウの作成
  600.   #--------------------------------------------------------------------------
  601.   def create_all_windows
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # ○ 全ウィンドウの解放
  605.   #--------------------------------------------------------------------------
  606.   def dispose_all_windows
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # ○ 全ウィンドウの更新
  610.   #--------------------------------------------------------------------------
  611.   def update_all_windows
  612.   end
  613.   #--------------------------------------------------------------------------
  614.   # ○ 全ウィンドウが完全に閉じているか判定
  615.   #--------------------------------------------------------------------------
  616.   def all_close?
  617.     close?
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ○ ファイバーの更新
  621.   #--------------------------------------------------------------------------
  622.   def update_fiber
  623.   end
  624.   #--------------------------------------------------------------------------
  625.   # ○ 入力処理
  626.   #--------------------------------------------------------------------------
  627.   def process_input
  628.     input_pause unless @pause_skip
  629.   end
  630.   #--------------------------------------------------------------------------
  631.   # ○ ウィンドウ幅の取得
  632.   #--------------------------------------------------------------------------
  633.   def window_width
  634.     return self.width unless self.disposed?
  635.     Graphics.width
  636.   end
  637.   #--------------------------------------------------------------------------
  638.   # ○ ウィンドウ高さの取得
  639.   #--------------------------------------------------------------------------
  640.   def window_height
  641.     fitting_height(visible_line_number)
  642.   end
  643.   #--------------------------------------------------------------------------
  644.   # ○ 表示行数の取得
  645.   #--------------------------------------------------------------------------
  646.   def visible_line_number
  647.     return 2
  648.   end
  649.   #--------------------------------------------------------------------------
  650.   # ○ ウィンドウ幅の設定
  651.   #--------------------------------------------------------------------------
  652.   def set_width(width)
  653.     self.width         = width
  654.   end
  655.   #--------------------------------------------------------------------------
  656.   # ○ テキストの設定
  657.   #--------------------------------------------------------------------------
  658.   def text=(text)
  659.     @text = text
  660.   end
  661.   #--------------------------------------------------------------------------
  662.   # ○ 全テキストの処理
  663.   #--------------------------------------------------------------------------
  664.   def process_all_text
  665.     @input_wait = $game_temp.input_wait
  666.     $game_temp.input_wait = true
  667.     set_pos_x
  668.     super
  669.     @init_close_count = CLOSE_COUNT unless @init_close_count
  670.     input_pause
  671.   end
  672.   #--------------------------------------------------------------------------
  673.   # ○ ウィンドウを開き、完全に開くまで待つ
  674.   #--------------------------------------------------------------------------
  675.   def open_and_wait
  676.     open
  677.     Fiber.yield until open? if @input_wait
  678.   end
  679.   #--------------------------------------------------------------------------
  680.   # ○ 入力待ち取得
  681.   #--------------------------------------------------------------------------
  682.   def input_wait
  683.     @input_wait
  684.   end
  685.   #--------------------------------------------------------------------------
  686.   # ○ 入力待ち取得
  687.   #--------------------------------------------------------------------------
  688.   def input_wait
  689.     @input_wait
  690.   end
  691.   #--------------------------------------------------------------------------
  692.   # ○ 入力待ち処理
  693.   #--------------------------------------------------------------------------
  694.   def input_pause
  695.     reset_close_count
  696.     super if @input_wait
  697.     @input_wait = true if @parallel_release
  698.     @parallel_release = false
  699.     start_close_count
  700.   end
  701.   #--------------------------------------------------------------------------
  702.   # ○ クローズカウントの開始
  703.   #--------------------------------------------------------------------------
  704.   def start_close_count
  705.     @close_count = @init_close_count
  706.     @init_close_count = nil
  707.   end
  708.   #--------------------------------------------------------------------------
  709.   # ○ クローズカウントの設定
  710.   #--------------------------------------------------------------------------
  711.   def close_count=(count)
  712.     @init_close_count = count
  713.   end
  714.   #--------------------------------------------------------------------------
  715.   # ○ クローズカウントのリセット
  716.   #--------------------------------------------------------------------------
  717.   def reset_close_count
  718.     @close_count      = nil
  719.   end
  720.   #--------------------------------------------------------------------------
  721.   # ○ ウィンドウを閉じる
  722.   #--------------------------------------------------------------------------
  723.   def close
  724.     reset_close_count
  725.     super
  726.   end
  727.   #--------------------------------------------------------------------------
  728.   # ○ 改行位置の取得
  729.   #--------------------------------------------------------------------------
  730.   def new_line_x
  731.     $game_message.face_name.empty? ? 0 : 56
  732.   end
  733.   #--------------------------------------------------------------------------
  734.   # ○ 制御文字の処理
  735.   #     code : 制御文字の本体部分(「\C[1]」なら「C」)
  736.   #     text : 描画処理中の文字列バッファ(必要なら破壊的に変更)
  737.   #     pos  : 描画位置 {:x, :y, :new_x, :height}
  738.   #--------------------------------------------------------------------------
  739.   def process_escape_character(code, text, pos)
  740.     case code.upcase
  741.     when 'PR'
  742.       @parallel_release = true
  743.     else
  744.       super
  745.     end
  746.   end
  747.   #--------------------------------------------------------------------------
  748.   # ○ ネームウィンドウの表示
  749.   #--------------------------------------------------------------------------
  750.   def show_name_window(face_name, face_index, x, size = 96)
  751.     super
  752.     set_name_window_pos
  753.   end
  754. end
  755. #==============================================================================
  756. # ■ Window_Base
  757. #------------------------------------------------------------------------------
  758. #  ゲーム中の全てのウィンドウのスーパークラスです。
  759. #==============================================================================
  760.  
  761. class Window_Base < Window
  762.   #--------------------------------------------------------------------------
  763.   # ☆ 顔グラフィックの描画
  764.   #     enabled : 有効フラグ。false のとき半透明で描画
  765.   #--------------------------------------------------------------------------
  766.   alias a1_child_message_window_wb_draw_face draw_face
  767.   def draw_face(face_name, face_index, x, y, size = 96)
  768.     return draw_face_half(face_name, face_index, x, y, size) if @my_child_window
  769.     a1_child_message_window_wb_draw_face(face_name, face_index, x, y, size)
  770.   end
  771.   #--------------------------------------------------------------------------
  772.   # ○ 顔グラフィックの描画(ハーフサイズ)
  773.   #     enabled : 有効フラグ。false のとき半透明で描画
  774.   #--------------------------------------------------------------------------
  775.   def draw_face_half(face_name, face_index, x, y, enabled = true)
  776.     draw_half_face(face_name, face_index, x, y, enabled) unless face_name.empty?
  777.     show_name_window(face_name, face_index, x, 48) if $imported["A1_Name_Window"]
  778.   end
  779.   #--------------------------------------------------------------------------
  780.   # ○ 顔グラフィックの描画(ハーフサイズ)
  781.   #--------------------------------------------------------------------------
  782.   def draw_half_face(face_name, face_index, x, y, enabled)
  783.     bitmap = Cache.half_face(face_name)
  784.     rect = Rect.new(face_index % 4 * 48, face_index / 4 * 48, 48, 48)
  785.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  786.   end
  787.   #--------------------------------------------------------------------------
  788.   # ☆ 制御文字の事前変換
  789.   #    実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
  790.   #    文字「\」はエスケープ文字(\e)に変換。
  791.   #--------------------------------------------------------------------------
  792.   alias a1_child_message_window_wb_convert_escape_characters convert_escape_characters
  793.   def convert_escape_characters(text)
  794.     result = a1_child_message_window_wb_convert_escape_characters(text)
  795.     result.gsub!(/\eCC\[(\d+)\]/i)          { set_close_count($1.to_i) }
  796.     result.gsub!(/\eKP/i)                   { set_popup_kind }
  797.     result
  798.   end
  799. end
  800. #==============================================================================
  801. # ■ Game_Message
  802. #------------------------------------------------------------------------------
  803. #  文章や選択肢などを表示するメッセージウィンドウの状態を扱うクラスです。この
  804. # クラスのインスタンスは $game_message で参照されます。
  805. #==============================================================================
  806.  
  807. class Game_Message
  808.   #--------------------------------------------------------------------------
  809.   # ○ 公開インスタンス変数
  810.   #--------------------------------------------------------------------------
  811.   attr_accessor :close_message
  812.   #--------------------------------------------------------------------------
  813.   # ☆ オブジェクト初期化
  814.   #--------------------------------------------------------------------------
  815.   alias a1_child_message_window_gm_initialize initialize
  816.   def initialize
  817.     a1_child_message_window_gm_initialize
  818.     @input_wait    = true
  819.     @close_message = nil
  820.   end
  821.   #--------------------------------------------------------------------------
  822.   # ○ 表示するテキストの設定
  823.   #--------------------------------------------------------------------------
  824.   def texts=(text)
  825.     @texts = text
  826.   end
  827. end
  828. #==============================================================================
  829. # ■ Game_Temp
  830. #------------------------------------------------------------------------------
  831. #  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン
  832. # スタンスは $game_temp で参照されます。
  833. #==============================================================================
  834.  
  835. class Game_Temp
  836.   #--------------------------------------------------------------------------
  837.   # ○ 公開インスタンス変数
  838.   #--------------------------------------------------------------------------
  839.   attr_accessor :input_wait
  840.   attr_accessor :event_popup_id
  841.   #--------------------------------------------------------------------------
  842.   # ☆ オブジェクト初期化
  843.   #--------------------------------------------------------------------------
  844.   alias a1_child_message_gt_initialize initialize
  845.   def initialize
  846.     a1_child_message_gt_initialize
  847.     @input_wait     = true
  848.     @event_popup_id = nil
  849.   end
  850. end
  851. #==============================================================================
  852. # ■ Game_System
  853. #------------------------------------------------------------------------------
  854. #  システム周りのデータを扱うクラスです。セーブやメニューの禁止状態などを保存
  855. # します。このクラスのインスタンスは $game_system で参照されます。
  856. #==============================================================================
  857.  
  858. class Game_System
  859.   #--------------------------------------------------------------------------
  860.   # ○ 公開インスタンス変数
  861.   #--------------------------------------------------------------------------
  862.   attr_accessor :enable_child_msg
  863.   #--------------------------------------------------------------------------
  864.   # ☆ オブジェクト初期化
  865.   #--------------------------------------------------------------------------
  866.   alias a1_child_message_gs_initialize initialize
  867.   def initialize
  868.     a1_child_message_gs_initialize
  869.     @enable_child_msg = A1_System::CnildMassageWindowConfig::DEFAULT_ENABLE_POPUP
  870.   end
  871. end
  872. #==============================================================================
  873. # ■ A1_System::CommonModule
  874. #==============================================================================
  875.  
  876. class A1_System::CommonModule
  877.   #--------------------------------------------------------------------------
  878.   # ☆ 注釈コマンド定義
  879.   #--------------------------------------------------------------------------
  880.   alias a1_child_message_define_command define_command
  881.   def define_command
  882.     a1_child_message_define_command
  883.     @cmd_108["並列吹き出し"]     = :sub_message
  884.     @cmd_108["吹き出しクローズ"] = :close_popup
  885.     @cmd_108["吹き出し使用"]     = :use_popup_message
  886.     @cmd_108["イベント吹き出し"] = :event_popup_message
  887.   end
  888. end
  889. #==============================================================================
  890. # ■ Game_Interpreter
  891. #------------------------------------------------------------------------------
  892. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  893. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  894. #==============================================================================
  895.  
  896. class Game_Interpreter
  897.   #--------------------------------------------------------------------------
  898.   # ○ 並列吹き出し
  899.   #--------------------------------------------------------------------------
  900.   def sub_message(params)
  901.     $game_temp.input_wait = false
  902.   end
  903.   #--------------------------------------------------------------------------
  904.   # ○ 吹き出しクローズ
  905.   #--------------------------------------------------------------------------
  906.   def close_popup(params)
  907.     return close_popup_id(params[0]) if params[0].is_a?(Array)
  908.     $game_message.close_message = params[0]
  909.   end
  910.   #--------------------------------------------------------------------------
  911.   # ○ 吹き出しクローズ(ID)
  912.   #--------------------------------------------------------------------------
  913.   def close_popup_id(params)
  914.     $game_message.close_message = "event_id_key_#{params[1].to_i}" if params[0] == "イベント"
  915.   end
  916.   #--------------------------------------------------------------------------
  917.   # ○ 吹き出し使用
  918.   #--------------------------------------------------------------------------
  919.   def use_popup_message(params)
  920.     $game_system.enable_child_msg = params[0] == "on" ? true : false
  921.   end
  922.   #--------------------------------------------------------------------------
  923.   # ○ イベント吹き出し
  924.   #--------------------------------------------------------------------------
  925.   def event_popup_message(params)
  926.     $game_temp.event_popup_id = params[0].to_i
  927.   end
  928. end
  929. #==============================================================================
  930. # ■ Scene_Map
  931. #------------------------------------------------------------------------------
  932. #  マップ画面の処理を行うクラスです。
  933. #==============================================================================
  934.  
  935. class Scene_Map < Scene_Base
  936.   #--------------------------------------------------------------------------
  937.   # ☆ 場所移動の処理
  938.   #--------------------------------------------------------------------------
  939.   alias a1_child_message_sm_perform_transfer perform_transfer
  940.   def perform_transfer
  941.     prev_map = $game_map.map_id
  942.     a1_child_message_sm_perform_transfer
  943.     @message_window.init_popup_message if prev_map != $game_map.map_id
  944.   end
  945. end
  946. #==============================================================================
  947. # ■ ネームウィンドウインポート時処理
  948. #==============================================================================
  949. if $imported["A1_Name_Window"]
  950. #==============================================================================
  951. # ■ Window_FaceName
  952. #==============================================================================
  953.  
  954. class Window_FaceName < Window_Base
  955.   #--------------------------------------------------------------------------
  956.   # ○ ネームスプライトの位置設定
  957.   #--------------------------------------------------------------------------
  958.   def set_name_sprite_pos
  959.     @name_sprite.x = self.x + self.width / 2
  960.     @name_sprite.y = self.y + self.height / 2
  961.   end
  962. end;end
  963. end






主要的用法 是用 註解 去使用
我目前只知道
イベント吹き出し + 事件 ID
就可以 指定事件 呼出對話視窗

\KP 可以 呼出 思考的 泡泡對話視窗

對話框的上下 可以決定 上下位置


我想問的是
要怎樣 讓 主角 也能 呼出 這樣的視窗
還有就是 怎麼 向他 官網一依樣 跑出 人物名字

Lv3.寻梦者

梦石
0
星屑
2296
在线时间
611 小时
注册时间
2009-1-21
帖子
273
2
 楼主| 发表于 2012-8-11 09:40:41 | 只看该作者
上提一下

麻煩 會的幫幫忙囉
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2296
在线时间
611 小时
注册时间
2009-1-21
帖子
273
3
 楼主| 发表于 2012-8-12 16:27:38 | 只看该作者
上提一下

麻煩 會的幫幫忙囉
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-3 03:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表