查看: 2087|回复: 2

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

[复制链接]
梦石
0
星屑
5476
在线时间
761 小时
注册时间
2009-1-21
回帖
236
发表于 2012-8-10 01:24:27 | 显示全部楼层 |阅读模式

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

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

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

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

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


A1共通


  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. class A1_System::CommonModule
  78.   #--------------------------------------------------------------------------
  79.   # ○ 定数
  80.   #--------------------------------------------------------------------------
  81.   TWOBYTE_LIST = {
  82.                   " " => " ",
  83.                   "=" => "=",
  84.                   ":" => ":"
  85.                   }
  86.   #--------------------------------------------------------------------------
  87.   # ○ オブジェクト初期化
  88.   #--------------------------------------------------------------------------
  89.   def initialize
  90.     define_command
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ○ 変換対象の全角文字を半角に置換
  94.   #--------------------------------------------------------------------------
  95.   def replace_twobyte(str)
  96.     for key in TWOBYTE_LIST.keys
  97.       str.gsub!(key) {TWOBYTE_LIST[key]}
  98.     end
  99.     return str
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ○ マイナスが含まれている文字列を数値にする
  103.   #--------------------------------------------------------------------------
  104.   def minus_to_i(s)
  105.     if s[0,0] == "-"
  106.       s.gsub!("-","")
  107.       return s.to_i * -1
  108.     else
  109.       return s.to_i
  110.     end
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ○ ミリ秒単位の現在時間
  114.   #--------------------------------------------------------------------------
  115.   def now_usec
  116.     now = Time.now
  117.     hour = now.hour * 60 * 60
  118.     min  = now.min * 60
  119.     sec  = now.sec
  120.     msec = (now.usec / 1000.0).round
  121.     return (hour + min + sec) * 1000 + msec
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # ○ イベントリストの作成
  125.   #--------------------------------------------------------------------------
  126.   def create_event_list(code, indent, parameters)
  127.     list = RPG::EventCommand.new
  128.     list.code       = code
  129.     list.indent     = indent
  130.     list.parameters = parameters
  131.     return list
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ○ メソッド呼び出し
  135.   #--------------------------------------------------------------------------
  136.   def send_method(method_name)
  137.     return send(method_name) if respond_to?(method_name)
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # ○ オブジェクトの型を判断してStringならエンコード
  141.   #--------------------------------------------------------------------------
  142.   def encoding_string(obj)
  143.     obj.force_encoding("UTF-8") if obj.is_a?(String)
  144.     return obj
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ○ メモの内容から必要な情報を取得
  148.   #--------------------------------------------------------------------------
  149.   def note_data(note, key)
  150.     result = []
  151.     note.each_line {|line|
  152.       next unless line =~ /<#{key}[ ]?(.*)>/
  153.       return true if $1.empty?
  154.       data = $a1_common.replace_twobyte($1).split(" ")
  155.       for st in data
  156.         result.push(st)
  157.       end
  158.     }
  159.     return false if result.empty?
  160.     return result
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ○ メモの内容からハッシュを作成
  164.   #--------------------------------------------------------------------------
  165.   def note_data_hash(note, key, data_default = nil, default = {}, ret = {})
  166.     list = note_data_split(note, key)
  167.     return default if list.empty?
  168.     list.each {|data| ret[data[0]] = data[1] ? data[1] : data_default }
  169.     return ret
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ○ メモの内容からカンマ区切りの多元配列を取得
  173.   #--------------------------------------------------------------------------
  174.   def note_data_split(note, key, default = [], ret = [])
  175.     data = note_data(note, key)
  176.     return default unless data.is_a?(Array)
  177.     data.each {|str| ret.push(convert_integer_from_array(split_array(str)))}
  178.     return ret
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ○ 配列の内容から数値があれば変換
  182.   #--------------------------------------------------------------------------
  183.   def convert_integer_from_array(data, ret = [])
  184.     data.each {|str| ret.push(convert_integer(str))}
  185.     return ret
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ○ 数値があれば変換
  189.   #--------------------------------------------------------------------------
  190.   def convert_integer(str)
  191.     return $1.to_i if str =~ /(^[-]?[0-9]+$)/
  192.     str.is_a?(Array) ? convert_integer_from_array(str) : str
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ○ メモの内容から単項目の数値を取得
  196.   #--------------------------------------------------------------------------
  197.   def note_data_one_value(note, key, default)
  198.     data = note_data(note, key)
  199.     return data[0].to_i if data.is_a?(Array)
  200.     return default
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ○ メモの内容から単項目を取得
  204.   #--------------------------------------------------------------------------
  205.   def note_data_one(note, key, default)
  206.     data = note_data(note, key)
  207.     return data[0] if data.is_a?(Array)
  208.     return default
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # ○ メモの内容からカンマ区切りの文字列を取得
  212.   #--------------------------------------------------------------------------
  213.   def note_data_array_str(note, key, default)
  214.     data = note_data(note, key)
  215.     return data[0].split(",") if data.is_a?(Array)
  216.     return default
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ○ メモの内容からカンマ区切りの数値を取得
  220.   #--------------------------------------------------------------------------
  221.   def note_data_array_value(note, key, default)
  222.     data = note_data(note, key)
  223.     return default unless data.is_a?(Array)
  224.     return convert_integer_from_array(split_array(data[0]))
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ○ カンマ区切りの文字列メモを変換
  228.   #--------------------------------------------------------------------------
  229.   def note_data_array(note, key, type, default = nil, through = true)
  230.     ret = []
  231.     default.each {|dat| ret.push(dat)} if default != nil
  232.    
  233.     data = note_data(note, key)
  234.     return ret unless data.is_a?(Array)
  235.    
  236.     data = data[0].split(",")
  237.     for d in data
  238.       next if ret.include?(d) if through
  239.       ret.push(d.to_i) if type.is_a?(Integer)
  240.       ret.push(d)      if type.is_a?(String)
  241.     end
  242.     return ret
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ○ ディレクトリの作成
  246.   #--------------------------------------------------------------------------
  247.   def make_directory(dir_name)
  248.     Dir::mkdir(dir_name) unless FileTest.exist?(dir_name)
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ○ コマンドリスト
  252.   #--------------------------------------------------------------------------
  253.   def make_command(command, src = "", dect = "")
  254.     src.gsub!("/","\")
  255.     dect.gsub!("/","\")
  256.     cmd = "#{command} "#{src}" "#{dect}""
  257.     return cmd
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ○ 素材の拡張子を取得
  261.   #--------------------------------------------------------------------------
  262.   def material_ext(directory, file, direct = false)
  263.     exts = []
  264.     exts = [".png",".bmp",".jpg"]               if directory =~ /(.*)Graphics\/(.*)/
  265.     exts = [".mid",".ogg",".wav",".mp3",".wma"] if directory =~ /(.*)Audio(.*)/
  266.    
  267.     find_file = sprintf("%s%s", directory, file) unless direct
  268.     find_file = file if direct
  269.    
  270.     for ext in exts
  271.       return ext if File.exist?(sprintf("%s%s", find_file, ext))
  272.     end
  273.     return nil
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ○ 素材が存在するかチェック
  277.   #--------------------------------------------------------------------------
  278.   def material_exist?(directory, file, direct = false)
  279.     return false if material_ext(directory, file, direct) == nil
  280.     return true
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   # ○ ファイルコピー
  284.   #--------------------------------------------------------------------------
  285.   def copy_file(src, dest)
  286.     srcFile = File.open( src, "rb" )
  287.     dstFile = File.open( dest, "wb" )
  288.     dstFile.write( srcFile.read )
  289.     srcFile.close
  290.     dstFile.close
  291.   end
  292.   #--------------------------------------------------------------------------
  293.   # ○ ファイルの存在を確認してファイルコピー
  294.   #--------------------------------------------------------------------------
  295.   def material_copy(src, dest, directory)
  296.     ext = material_ext(directory, src, true)
  297.     copy_file( src + ext, dest + ext ) if ext != nil
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ○ 配列からAudioを作成
  301.   #--------------------------------------------------------------------------
  302.   def set_audio(sound, kind)
  303.     case kind
  304.     when "BGM"; audio = RPG::BGM.new
  305.     when "BGS"; audio = RPG::BGS.new
  306.     when "ME";  audio = RPG::ME.new
  307.     when "SE";  audio = RPG::SE.new
  308.     end
  309.     audio.name   = sound[0]
  310.     audio.volume = sound[1]
  311.     audio.pitch  = sound[2]
  312.     return audio
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ○ 既に準拠識別子を持っているかチェック
  316.   #--------------------------------------------------------------------------
  317.   def chk_rtp(file_name, default)
  318.     return "" if file_name =~ /^VX_.*/
  319.     return "" if file_name =~ /^XP_.*/
  320.     return "" if file_name =~ /^2000_.*/
  321.     return "" if file_name =~ /^2003_.*/
  322.     return default
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # ○ 先頭の $ を切り出す
  326.   #--------------------------------------------------------------------------
  327.   def one_character(file_name)
  328.     return file_name unless file_name[0] == "$"
  329.     tmp = file_name.clone
  330.     tmp[0] = ""
  331.     return tmp
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ○ 配列を入れ替える
  335.   #--------------------------------------------------------------------------
  336.   def change_array(array, index1, index2)
  337.     tmp = array[index1]
  338.     array[index1] = array[index2]
  339.     array[index2] = tmp
  340.     return array
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ○ 移動ルートの作成
  344.   #--------------------------------------------------------------------------
  345.   def create_move_route(repeat, skippable, wait, list)
  346.     move_route = RPG::MoveRoute.new
  347.     move_route.repeat    = repeat
  348.     move_route.skippable = skippable
  349.     move_route.wait      = wait
  350.     move_route.list      = list
  351.     return move_route
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # ○ 移動ルートコマンドの作成
  355.   #--------------------------------------------------------------------------
  356.   def create_move_command(code, parameters)
  357.     list = RPG::MoveCommand.new
  358.     list.code       = code
  359.     list.parameters = parameters
  360.     return list
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ○ インタプリタ起動用リストの作成
  364.   #--------------------------------------------------------------------------
  365.   def create_list(code, indent, parameters)
  366.     list            = RPG::EventCommand.new
  367.     list.code       = code
  368.     list.indent     = indent
  369.     list.parameters = parameters
  370.     return list
  371.   end
  372.   #--------------------------------------------------------------------------
  373.   # ○ クラス名の取得
  374.   #--------------------------------------------------------------------------
  375.   def class_name(class_instance)
  376.     return class_instance.to_s.split(":")[0].gsub("#<","")
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ○ 配列を考慮したsplit
  380.   #--------------------------------------------------------------------------
  381.   def split_array(str)
  382.     str = convert_escape_characters(str)
  383.    
  384.     ret       = []
  385.     tmp_array = str.split(",")
  386.    
  387.     return strip_array_str(tmp_array) unless str.include?("[")
  388.     tmp_str   = ""
  389.     tmp_array.each {|s|
  390.       if char_in_str(s, "[", "]") && tmp_str.empty?
  391.         ret.push(s) unless s =~ /^\[/
  392.         ret.push([s[1...s.size-1]]) if s =~ /^\[/
  393.       else
  394.         tmp_str = "#{tmp_str}#{s},"
  395.         if char_in_str(tmp_str, "[", "]")
  396.           unless tmp_str =~ /^\[/
  397.             ret.push(tmp_str[0...tmp_str.size-1])
  398.             tmp_str = ""
  399.           else
  400.             tmp_str = tmp_str[1...tmp_str.size-2]
  401.             tmp_str = split_array(tmp_str) if tmp_str.include?("[")
  402.             tmp_str = tmp_str.split(",") if tmp_str.include?(",")
  403.             ret.push(tmp_str)   if tmp_str.is_a?(Array)
  404.             ret.push([tmp_str]) if !tmp_str.is_a?(Array)
  405.             tmp_str = ""
  406.           end
  407.         end
  408.       end
  409.     }
  410.     return strip_array_str(ret)
  411.   end
  412.   #--------------------------------------------------------------------------
  413.   # ○ 配列の中の文字列の先頭と末尾の空白を除去
  414.   #--------------------------------------------------------------------------
  415.   def strip_array_str(array, ret = [])
  416.     array.each {|str| ret.push(strip_array_str(str)) if str.is_a?(Array); next if str.is_a?(Array); ret.push(str.strip) }
  417.     return ret
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ○ 文字列の中に文字が何文字含まれているか調べて同数ならtrueを返す
  421.   #--------------------------------------------------------------------------
  422.   def char_in_str(str, c1, c2)
  423.     num1 = 0
  424.     num2 = 0
  425.     (0...str.size).each {|i| num1 += 1 if str[i] == c1; num2 += 1 if str[i] == c2 }
  426.     return num1 == num2
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # ○ 制御文字の変換
  430.   #--------------------------------------------------------------------------
  431.   def convert_escape_characters(text)
  432.     result = text.to_s.clone
  433.     result.gsub!(/\\/)                           { "\e" }
  434.     result.gsub!(/\e\e/)                         { "\" }
  435.     result.gsub!(/\eV\[(\d+)\]/i)                { $game_variables[$1.to_i] }
  436.     result.gsub!(/\eV\[(\d+)\]/i)                { $game_variables[$1.to_i] }
  437.     result.gsub!(/\eN\[(\d+)\]/i)                { actor_name($1.to_i) }
  438.     result.gsub!(/\eP\[(\d+)\]/i)                { party_member_name($1.to_i) }
  439.     result.gsub!(/\eG/i)                         { Vocab::currency_unit }
  440.     loop { result = result.sub(/<s>(.+?)<\/s>/i) { eval($1) }; break unless $1 }
  441.     result
  442.   end
  443.   #--------------------------------------------------------------------------
  444.   # ○ アクター n 番の名前を取得
  445.   #--------------------------------------------------------------------------
  446.   def actor_name(n)
  447.     actor = n >= 1 ? $game_actors[n] : nil
  448.     actor ? actor.name : ""
  449.   end
  450.   #--------------------------------------------------------------------------
  451.   # ○ パーティメンバー n 番の名前を取得
  452.   #--------------------------------------------------------------------------
  453.   def party_member_name(n)
  454.     actor = n >= 1 ? $game_party.members[n - 1] : nil
  455.     actor ? actor.name : ""
  456.   end
  457.   #--------------------------------------------------------------------------
  458.   # ○ 配列を全て整数にする
  459.   #--------------------------------------------------------------------------
  460.   def params_to_i(params)
  461.     ret = []
  462.     params.each {|param| ret.push(param.to_i)}
  463.     return ret
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # ○ 注釈コマンド定義
  467.   #--------------------------------------------------------------------------
  468.   def define_command
  469.     @cmd_108 = {}
  470.   end
  471.   #--------------------------------------------------------------------------
  472.   # ○ 注釈コマンド定義取得
  473.   #--------------------------------------------------------------------------
  474.   def cmd_108
  475.     @cmd_108
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # ○ フレーム更新
  479.   #--------------------------------------------------------------------------
  480.   def update
  481.   end
  482.   #--------------------------------------------------------------------------
  483.   # ○ 文字の幅と高さを取得
  484.   #--------------------------------------------------------------------------
  485.   def text_size(font, size, text)
  486.     bitmap = Cache.system("")
  487.     bitmap.font.name = font
  488.     bitmap.font.size = size
  489.     tw = bitmap.text_size(text).width
  490.     th = bitmap.text_size(text).height
  491.     bitmap.dispose
  492.     return [tw, th]
  493.   end
  494.   #--------------------------------------------------------------------------
  495.   # ○ 文字の幅を取得
  496.   #--------------------------------------------------------------------------
  497.   def text_width(font, text)
  498.     texts = text.split("\n")
  499.     @max_width = 0
  500.     texts.each {|text|
  501.       width = text_size(font.name, font.size, text)[0]
  502.       @max_width = @max_width < width ? width : @max_width
  503.     }
  504.     return @max_width
  505.   end
  506. end
  507. #==============================================================================
  508. # ◆ RGSS3用処理
  509. #==============================================================================
  510. if rgss_version == 3
  511. #==============================================================================
  512. # ■ RPG::Tileset
  513. #==============================================================================

  514. class RPG::Tileset
  515.   #--------------------------------------------------------------------------
  516.   # ○ 拡張通行判定
  517.   #--------------------------------------------------------------------------
  518.   def ex_flags
  519.     @ex_flags ||= Table.new(8192)
  520.     return @ex_flags
  521.   end
  522.   #--------------------------------------------------------------------------
  523.   # ○ 拡張通行判定初期化
  524.   #--------------------------------------------------------------------------
  525.   def init_ex_flags
  526.     @ex_flags = Table.new(8192)
  527.   end
  528. end
  529. #==============================================================================
  530. # ■ Game_Interpreter
  531. #------------------------------------------------------------------------------
  532. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  533. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  534. #==============================================================================

  535. class Game_Interpreter
  536.   #--------------------------------------------------------------------------
  537.   # ☆ オブジェクト初期化
  538.   #     depth : ネストの深さ
  539.   #--------------------------------------------------------------------------
  540.   alias a1_common_gi_rgss3_initialize initialize
  541.   def initialize(depth = 0, sub_interpreter = false)
  542.     @sub_interpreter = sub_interpreter
  543.     a1_common_gi_rgss3_initialize(depth)
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # ☆ メッセージ表示がビジー状態の間ウェイト
  547.   #--------------------------------------------------------------------------
  548.   alias a1_common_gi_wait_for_message wait_for_message
  549.   def wait_for_message
  550.     return if @sub_interpreter
  551.     a1_common_gi_wait_for_message
  552.   end
  553. end
  554. #==============================================================================
  555. # ■ Window_Message
  556. #------------------------------------------------------------------------------
  557. #  文章表示に使うメッセージウィンドウです。
  558. #==============================================================================

  559. class Window_Message < Window_Base
  560.   #--------------------------------------------------------------------------
  561.   # ☆ 通常文字の処理
  562.   #--------------------------------------------------------------------------
  563.   alias a1_common_wm_process_normal_character process_normal_character
  564.   def process_normal_character(c, pos)
  565.     wait_for_one_character_before
  566.     a1_common_wm_process_normal_character(c, pos)
  567.   end
  568.   #--------------------------------------------------------------------------
  569.   # ○ 一文字出力前のウェイト
  570.   #--------------------------------------------------------------------------
  571.   def wait_for_one_character_before
  572.   end
  573. end
  574. #==============================================================================
  575. # ■ RPG::Map
  576. #==============================================================================

  577. class RPG::Map
  578.   #--------------------------------------------------------------------------
  579.   # ○ マップチップを調べるか判定する
  580.   #--------------------------------------------------------------------------
  581.   def search_map_chip?
  582.     return true if $a1_common.note_data(self.note, "マップチップサーチ")
  583.     return false
  584.   end
  585. end
  586. #==============================================================================
  587. # ■ Game_Map
  588. #------------------------------------------------------------------------------
  589. #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
  590. # このクラスのインスタンスは $game_map で参照されます。
  591. #==============================================================================

  592. class Game_Map
  593.   #--------------------------------------------------------------------------
  594.   # ☆ セットアップ
  595.   #--------------------------------------------------------------------------
  596.   alias a1_common_gm_setup setup
  597.   def setup(map_id)
  598.     a1_common_gm_setup(map_id)
  599.     setup_tileset
  600.     map_chip_search if search_map_chip?
  601.   end
  602.   #--------------------------------------------------------------------------
  603.   # ★ タイルセットの取得
  604.   #--------------------------------------------------------------------------
  605.   def tileset
  606.     setup_tileset unless @tileset && @now_tileset_id == @tileset_id
  607.     return @tileset
  608.   end
  609.   #--------------------------------------------------------------------------
  610.   # ○ タイルセットのセットアップ
  611.   #--------------------------------------------------------------------------
  612.   def setup_tileset
  613.     @tileset        = $data_tilesets[@tileset_id].clone
  614.     @tileset.flags  = $data_tilesets[@tileset_id].flags.clone
  615.     @now_tileset_id = @tileset_id
  616.   end
  617.   #--------------------------------------------------------------------------
  618.   # ○ マップチップを調べるか判定する
  619.   #--------------------------------------------------------------------------
  620.   def search_map_chip?
  621.     return @map.search_map_chip?
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # ○ 指定座標の全レイヤーのフラグ判定(イベント含む)
  625.   #--------------------------------------------------------------------------
  626.   def all_tiles_flag?(x, y, bit)
  627.     all_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 }
  628.   end
  629.   #--------------------------------------------------------------------------
  630.   # ○ 指定座標の全レイヤーの拡張フラグ判定(イベント含む)
  631.   #--------------------------------------------------------------------------
  632.   def all_tiles_flag_ex?(x, y, bit)
  633.     all_tiles(x, y).any? {|tile_id| tileset.ex_flags[tile_id] & bit != 0 }
  634.   end
  635.   #--------------------------------------------------------------------------
  636.   # ○ 指定座標の全レイヤーの拡張フラグ判定
  637.   #--------------------------------------------------------------------------
  638.   def layered_tiles_flag_ex?(x, y, bit)
  639.     layered_tiles(x, y).any? {|tile_id| tileset.ex_flags[tile_id] & bit != 0 }
  640.   end
  641.   #--------------------------------------------------------------------------
  642.   # ○ 地形タグの取得(イベント含む)
  643.   #--------------------------------------------------------------------------
  644.   def terrain_tag_all_tailes(x, y)
  645.     return 0 unless valid?(x, y)
  646.     all_tiles(x, y).each do |tile_id|
  647.       tag = tileset.flags[tile_id] >> 12
  648.       return tag if tag > 0
  649.     end
  650.     return 0
  651.   end
  652. end
  653. #==============================================================================
  654. # ■ DataManager
  655. #------------------------------------------------------------------------------
  656. #  データベースとゲームオブジェクトを管理するモジュールです。ゲームで使用する
  657. # ほぼ全てのグローバル変数はこのモジュールで初期化されます。
  658. #==============================================================================

  659. module DataManager
  660.   #--------------------------------------------------------------------------
  661.   # ○ エイリアス用特異メソッド
  662.   #--------------------------------------------------------------------------
  663.   class << self
  664.     alias :a1_common_create_game_objects :create_game_objects
  665.   end
  666.   #--------------------------------------------------------------------------
  667.   # ☆ 各種ゲームオブジェクトの作成
  668.   #--------------------------------------------------------------------------
  669.   def self.create_game_objects
  670.     $a1_common ||= A1_System::CommonModule.new
  671.     a1_common_create_game_objects
  672.   end
  673. end
  674. #==============================================================================
  675. # ■ Scene_Base
  676. #------------------------------------------------------------------------------
  677. #  ゲーム中の全てのシーンのスーパークラスです。
  678. #==============================================================================

  679. class Scene_Base
  680.   #--------------------------------------------------------------------------
  681.   # ☆ フレーム更新(基本)
  682.   #--------------------------------------------------------------------------
  683.   alias a1_common_sb_update_basic update_basic
  684.   def update_basic
  685.     a1_common_sb_update_basic
  686.     $a1_common.update
  687.   end
  688.   #--------------------------------------------------------------------------
  689.   # ○ 指定のウィンドウが開いている間ウェイト
  690.   #--------------------------------------------------------------------------
  691.   def wait_for_window_open(window)
  692.     update_basic until window.openness == 0
  693.   end
  694. end
  695. #==============================================================================
  696. # ■ Window_Base
  697. #------------------------------------------------------------------------------
  698. #  ゲーム中の全てのウィンドウのスーパークラスです。
  699. #==============================================================================

  700. class Window_Base < Window
  701.   #--------------------------------------------------------------------------
  702.   # ★ 制御文字の事前変換
  703.   #    実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
  704.   #    文字「\」はエスケープ文字(\e)に変換。
  705.   #--------------------------------------------------------------------------
  706.   def convert_escape_characters(text)
  707.     return $a1_common.convert_escape_characters(text)
  708.   end
  709. end
  710. #==============================================================================
  711. # ◆ RGSS2用処理
  712. #==============================================================================
  713. elsif rgss_version == 2
  714. #==============================================================================
  715. # ■ Window
  716. #==============================================================================

  717. class Window
  718.   #--------------------------------------------------------------------------
  719.   # ○ ウィンドウが開いている?
  720.   #--------------------------------------------------------------------------
  721.   def open?
  722.     return self.openness == 255
  723.   end
  724.   #--------------------------------------------------------------------------
  725.   # ○ ウィンドウが閉じている?
  726.   #--------------------------------------------------------------------------
  727.   def close?
  728.     return self.openness == 0
  729.   end
  730. end
  731. #==============================================================================
  732. # ■ Cache
  733. #------------------------------------------------------------------------------
  734. #  各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
  735. # です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
  736. # のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
  737. # を返すようになっています。
  738. #==============================================================================

  739. module Cache
  740.   #--------------------------------------------------------------------------
  741.   # ○ キャッシュ存在チェック
  742.   #--------------------------------------------------------------------------
  743.   def self.include?(key)
  744.     @cache[key] && !@cache[key].disposed?
  745.   end
  746. end
  747. #==============================================================================
  748. # ■ Game_Interpreter
  749. #------------------------------------------------------------------------------
  750. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  751. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  752. #==============================================================================

  753. class Game_Interpreter
  754.   #--------------------------------------------------------------------------
  755.   # ○ 注釈
  756.   #--------------------------------------------------------------------------
  757.   def command_108
  758.     @comments = [@params[0]]
  759.     while next_event_code == 408
  760.       @index += 1
  761.       @comments.push(@list[@index].parameters[0])
  762.     end
  763.   end
  764.   #--------------------------------------------------------------------------
  765.   # ★ イベントコマンドの実行
  766.   #--------------------------------------------------------------------------
  767.   def execute_command
  768.     return rgss3_execute_command unless @index >= @list.size-1
  769.     command_end
  770.     return true
  771.   end
  772.   #--------------------------------------------------------------------------
  773.   # ○ RGSS3風「イベントコマンドの実行」
  774.   #--------------------------------------------------------------------------
  775.   def rgss3_execute_command
  776.     command = @list[@index]
  777.     @params = command.parameters
  778.     @indent = command.indent
  779.     method_name = "command_#{command.code}"
  780.     send(method_name) if respond_to?(method_name)
  781.   end
  782.   #--------------------------------------------------------------------------
  783.   # ○ 次のイベントコマンドのコードを取得
  784.   #--------------------------------------------------------------------------
  785.   def next_event_code
  786.     @list[@index + 1].code
  787.   end
  788. end
  789. #==============================================================================
  790. # ■ Game_Map
  791. #------------------------------------------------------------------------------
  792. #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
  793. # このクラスのインスタンスは $game_map で参照されます。
  794. #==============================================================================

  795. class Game_Map
  796.   #--------------------------------------------------------------------------
  797.   # ○ マップチップを調べるか判定する
  798.   #--------------------------------------------------------------------------
  799.   def search_map_chip?
  800.     return $data_map_infos[@map_id].name =~ /\[サーチ\]/
  801.   end
  802.   #--------------------------------------------------------------------------
  803.   # ○ 指定座標に存在するタイル扱いイベント(すり抜け以外)の配列取得
  804.   #--------------------------------------------------------------------------
  805.   def tile_events_xy(x, y)
  806.     @tile_events.select {|event| event.pos_nt?(x, y) }
  807.   end
  808.   #--------------------------------------------------------------------------
  809.   # ○ タイル扱いイベントの配列をリフレッシュ
  810.   #--------------------------------------------------------------------------
  811.   def refresh_tile_events
  812.     @tile_events = @events.values.select {|event| event.tile? }
  813.   end
  814. end
  815. #==============================================================================
  816. # ■ Game_Character
  817. #------------------------------------------------------------------------------
  818. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  819. # クラスのスーパークラスとして使用されます。
  820. #==============================================================================

  821. class Game_Character
  822.   #--------------------------------------------------------------------------
  823.   # ○ タイル判定
  824.   #--------------------------------------------------------------------------
  825.   def tile?
  826.     @tile_id > 0 && @priority_type == 0
  827.   end
  828. end
  829. #==============================================================================
  830. # ■ Scene_Title
  831. #------------------------------------------------------------------------------
  832. #  タイトル画面の処理を行うクラスです。
  833. #==============================================================================

  834. class Scene_Title < Scene_Base
  835.   #--------------------------------------------------------------------------
  836.   # ☆ データベースのロード
  837.   #--------------------------------------------------------------------------
  838.   alias a1_common_st_load_database load_database
  839.   def load_database
  840.     a1_common_st_load_database
  841.     $data_map_infos = load_data("Data/MapInfos.rvdata")
  842.   end
  843.   #--------------------------------------------------------------------------
  844.   # ☆ 各種ゲームオブジェクトの作成
  845.   #--------------------------------------------------------------------------
  846.   alias a1_common_st_create_game_objects create_game_objects
  847.   def create_game_objects
  848.     $a1_common ||= A1_System::CommonModule.new
  849.     a1_common_st_create_game_objects
  850.   end
  851. end
  852. #==============================================================================
  853. # ◆ RGSS用処理
  854. #==============================================================================
  855. elsif rgss_version == 1
  856. end
  857. #==============================================================================
  858. # ■ Cache
  859. #------------------------------------------------------------------------------
  860. #  各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
  861. # です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
  862. # のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
  863. # を返すようになっています。
  864. #==============================================================================

  865. module Cache
  866.   #--------------------------------------------------------------------------
  867.   # ○ 拡大縮小したビットマップのロード
  868.   #--------------------------------------------------------------------------
  869.   def self.load_resize_bitmap(load_path, key, resize = nil)
  870.     @cache ||= {}
  871.     key = load_path if key == nil
  872.     return @cache[key] if include?(key)
  873.    
  874.     @cache[key] = Bitmap.new(load_path)
  875.     return @cache[key] if resize == nil
  876.     return @cache[key] if @cache[key].width == resize[0] and @cache[key].height == resize[1]
  877.    
  878.     info = calc_size(resize, key)
  879.     return resize_bitmap(@cache[key], info[0], info[1], key)
  880.   end
  881.   #--------------------------------------------------------------------------
  882.   # ○ 拡大縮小した色相変化済みビットマップを作成/取得
  883.   #--------------------------------------------------------------------------
  884.   def self.load_resize_hue_changed_bitmap(load_path, path, hue, resize)
  885.     key = [path, hue]
  886.     return @cache[key] if include?(key)
  887.    
  888.     @cache[key] = load_resize_bitmap(load_path, path, resize).clone
  889.     @cache[key].hue_change(hue)
  890.     return @cache[key]
  891.   end
  892.   #--------------------------------------------------------------------------
  893.   # ○ リサイズするサイズを取得
  894.   #--------------------------------------------------------------------------
  895.   def self.calc_size(resize, key)
  896.     width  = resize[0]
  897.     width  = @cache[key].width * width.abs if width < 0
  898.     height = resize[1]
  899.     height = @cache[key].height * height.abs if height < 0
  900.     height = Integer(@cache[key].height * (width.to_f / @cache[key].width.to_f)) if height == 0
  901.     return [width, height]
  902.   end
  903.   #--------------------------------------------------------------------------
  904.   # ○ ビットマップの拡大縮小
  905.   #--------------------------------------------------------------------------
  906.   def self.resize_bitmap(bitmap, width, height, key)
  907.     resize = Bitmap.new(width, height)
  908.     resize.stretch_blt(resize.rect, bitmap, bitmap.rect)
  909.     @cache[key] = resize
  910.     return resize
  911.   end
  912.   #--------------------------------------------------------------------------
  913.   # ○ テキストビットマップの取得
  914.   #--------------------------------------------------------------------------
  915.   def self.text_picture(text, font)
  916.     load_text_bitmap(text, font)
  917.   end
  918.   #--------------------------------------------------------------------------
  919.   # ○ フォントのキーを作成
  920.   #--------------------------------------------------------------------------
  921.   def self.make_font_key(text, font)
  922.     [text, font.name, font.size, font.bold, font.italic, font.outline, font.shadow, font.color.to_s, font.out_color.to_s]
  923.   end
  924.   #--------------------------------------------------------------------------
  925.   # ○ テキストビットマップの作成
  926.   #--------------------------------------------------------------------------
  927.   def self.load_text_bitmap(text, font)
  928.     @cache ||= {}
  929.     key = make_font_key(text, font)
  930.     return @cache[key] if include?(key)
  931.    
  932.     # 計算用ダミービットマップ
  933.     bitmap = Cache.system("")
  934.     bitmap.font = font
  935.     tw = bitmap.text_size(text).width + 8
  936.    
  937.     # ビットマップ作成
  938.     bitmap = Bitmap.new(tw, bitmap.font.size + 4)
  939.     bitmap.font = font
  940.     bitmap.draw_text(0, 0, bitmap.width, bitmap.height, text, 1)
  941.    
  942.     @cache[key] = bitmap
  943.     return @cache[key]
  944.   end
  945. end
  946. #==============================================================================
  947. # ■ Game_Interpreter
  948. #------------------------------------------------------------------------------
  949. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  950. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  951. #==============================================================================

  952. class Game_Interpreter
  953.   #--------------------------------------------------------------------------
  954.   # ○ 注釈
  955.   #--------------------------------------------------------------------------
  956.   alias a1_common_command_108 command_108
  957.   def command_108
  958.     a1_common_command_108
  959.     proc_comment(@comments)
  960.   end
  961.   #--------------------------------------------------------------------------
  962.   # ○ 注釈の処理
  963.   #--------------------------------------------------------------------------
  964.   def proc_comment(comments)
  965.     param = ""
  966.     comments.each {|comment| param += comment }
  967.     params = param.sub(/^(\S+)/, "")
  968.     command = $1
  969.     comment_parameters = $a1_common.split_array(params) if params
  970.     proc_comment_command(command, comment_parameters)
  971.   end
  972.   #--------------------------------------------------------------------------
  973.   # ○ 注釈の実行
  974.   #--------------------------------------------------------------------------
  975.   def proc_comment_command(command, params)
  976.     cmd_108 = $a1_common.cmd_108[command]
  977.     method(cmd_108).call(params) if cmd_108 != nil
  978.   end
  979.   #--------------------------------------------------------------------------
  980.   # ○ 前のイベントコマンドを取得
  981.   #--------------------------------------------------------------------------
  982.   def prev_event
  983.     @list[@index - 1]
  984.   end
  985. end
  986. #==============================================================================
  987. # ■ Game_Map
  988. #------------------------------------------------------------------------------
  989. #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
  990. # このクラスのインスタンスは $game_map で参照されます。
  991. #==============================================================================

  992. class Game_Map
  993.   #--------------------------------------------------------------------------
  994.   # ○ 全マップチップを調べる
  995.   #--------------------------------------------------------------------------
  996.   def map_chip_search
  997.     tileset.init_ex_flags
  998.     ([email]0...@map.data.xsize[/email]).each {|x| map_chip_search_y(x) }
  999.   end
  1000.   #--------------------------------------------------------------------------
  1001.   # ○ x座標にあるy座標のマップチップを調べる
  1002.   #--------------------------------------------------------------------------
  1003.   def map_chip_search_y(x)
  1004.     ([email]0...@map.data.ysize[/email]).each {|y| map_pos_proc(x, y); map_chip_search_z(x, y) }
  1005.   end
  1006.   #--------------------------------------------------------------------------
  1007.   # ○ x,y座標にあるz座標のマップチップを調べる
  1008.   #--------------------------------------------------------------------------
  1009.   def map_chip_search_z(x, y)
  1010.     ([email]0...@map.data.zsize[/email]).each {|z| map_chip_proc(x, y, z) }
  1011.     tile_events_xy(x, y).collect {|ev| tile_event_proc(ev.tile_id) }
  1012.   end
  1013.   #--------------------------------------------------------------------------
  1014.   # ○ 座標に対して処理を行う
  1015.   #--------------------------------------------------------------------------
  1016.   def map_pos_proc(x, y)
  1017.   end
  1018.   #--------------------------------------------------------------------------
  1019.   # ○ マップチップに対して処理を行う
  1020.   #--------------------------------------------------------------------------
  1021.   def map_chip_proc(x, y, z)
  1022.   end
  1023.   #--------------------------------------------------------------------------
  1024.   # ○ タイルのイベントに対して処理を行う
  1025.   #--------------------------------------------------------------------------
  1026.   def tile_event_proc(tile_id)
  1027.   end
  1028. end
  1029. #==============================================================================
  1030. # ■ Window_Base
  1031. #------------------------------------------------------------------------------
  1032. #  ゲーム中の全てのウィンドウのスーパークラスです。
  1033. #==============================================================================

  1034. class Window_Base < Window
  1035.   #--------------------------------------------------------------------------
  1036.   # ○ 入力を受け付けるか?
  1037.   #--------------------------------------------------------------------------
  1038.   def can_input?
  1039.     @can_input
  1040.   end
  1041.   #--------------------------------------------------------------------------
  1042.   # ○ 入力受け付け設定
  1043.   #--------------------------------------------------------------------------
  1044.   def can_input=(flag)
  1045.     @can_input = flag
  1046.   end
  1047. end
  1048. #==============================================================================
  1049. # ■ Bitmap
  1050. #==============================================================================

  1051. class Bitmap
  1052.   #--------------------------------------------------------------------------
  1053.   # ○ 文字縁取り描画
  1054.   #--------------------------------------------------------------------------
  1055.   def draw_text_f(x, y, width, height, str, align = 0, color = Color.new(64,32,128))
  1056.     shadow = self.font.shadow
  1057.     b_color = self.font.color.dup
  1058.     font.shadow = false
  1059.     font.color = color
  1060.     draw_text(x + 1, y, width, height, str, align)
  1061.     draw_text(x - 1, y, width, height, str, align)
  1062.     draw_text(x, y + 1, width, height, str, align)
  1063.     draw_text(x, y - 1, width, height, str, align)
  1064.     font.color = b_color
  1065.     draw_text(x, y, width, height, str, align)
  1066.     font.shadow = shadow
  1067.   end
  1068.   #--------------------------------------------------------------------------
  1069.   # ○ 文字縁取り描画の矩形を取得
  1070.   #--------------------------------------------------------------------------
  1071.   def draw_text_f_rect(r, str, align = 0, color = Color.new(64,32,128))
  1072.     draw_text_f(r.x, r.y, r.width, r.height, str, align = 0, color)
  1073.   end
  1074. end
复制代码




本體


  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. module Cache
  118.   #--------------------------------------------------------------------------
  119.   # ○ 顔グラフィックの取得
  120.   #--------------------------------------------------------------------------
  121.   def self.half_face(filename)
  122.     load_file_name = "Graphics/Faces/#{filename}"
  123.     key            = "#{load_file_name}_halfface"
  124.     load_resize_bitmap(load_file_name, key, [-0.5, -0.5])
  125.   end
  126. end
  127. #==============================================================================
  128. # ■ Window_Message
  129. #------------------------------------------------------------------------------
  130. #  文章表示に使うメッセージウィンドウです。
  131. #==============================================================================

  132. class Window_Message < Window_Base
  133.   #--------------------------------------------------------------------------
  134.   # ○ 定数
  135.   #--------------------------------------------------------------------------
  136.   LINK_FACE = A1_System::CnildMassageWindowConfig::LINK_FACE
  137.   #--------------------------------------------------------------------------
  138.   # ○ 子メッセージウィンドウのキーを取得
  139.   #--------------------------------------------------------------------------
  140.   def child_key
  141.     return event_id_key if $game_temp.event_popup_id
  142.     key = LINK_FACE["#{$game_message.face_name}_#{$game_message.face_index}"]
  143.     key = LINK_FACE["#{$game_message.face_name}"] unless key
  144.     return key
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ○ イベントIDからキーを設定
  148.   #--------------------------------------------------------------------------
  149.   def event_id_key
  150.     key = "event_id_key_#{$game_temp.event_popup_id}"
  151.     $game_temp.event_popup_id = nil
  152.     return key
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ☆ 全ウィンドウの作成
  156.   #--------------------------------------------------------------------------
  157.   alias a1_child_message_window_wm_create_all_windows create_all_windows
  158.   def create_all_windows
  159.     a1_child_message_window_wm_create_all_windows
  160.     @child_message_window = {}
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ☆ 全ウィンドウの解放
  164.   #--------------------------------------------------------------------------
  165.   alias a1_child_message_window_wm_dispose_all_windows dispose_all_windows
  166.   def dispose_all_windows
  167.     a1_child_message_window_wm_dispose_all_windows
  168.     @child_message_window.values.each {|window| window.dispose }
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ☆ 全ウィンドウの更新
  172.   #--------------------------------------------------------------------------
  173.   alias a1_child_message_window_wm_update_all_windows update_all_windows
  174.   def update_all_windows
  175.     a1_child_message_window_wm_update_all_windows
  176.     @child_message_window.values.each {|window| window.update }
  177.     close_window = $game_message.close_message
  178.     @child_message_window[close_window].close if close_window && @child_message_window[close_window]
  179.     $game_message.close_message = nil
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ☆ 全テキストの処理
  183.   #--------------------------------------------------------------------------
  184.   alias a1_child_message_window_wm_process_all_text process_all_text
  185.   def process_all_text
  186.     @use_child = false
  187.     return a1_child_message_window_wm_process_all_text unless need_setup?
  188.     @child_key = child_key
  189.     return if setup_child_message if @child_key && !@child_key.empty?
  190.     a1_child_message_window_wm_process_all_text
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ○ 子メッセージウィンドウのセットアップが必要?
  194.   #--------------------------------------------------------------------------
  195.   def need_setup?
  196.     return false if $game_party.in_battle
  197.     return false if @my_child_window
  198.     return $game_system.enable_child_msg
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ○ 子メッセージウィンドウのセットアップ
  202.   #--------------------------------------------------------------------------
  203.   def setup_child_message
  204.     @child_message_window[@child_key] ||= create_child_message
  205.     return false unless @child_message_window[@child_key].link_event
  206.     close
  207.     process_child_message_window(@child_message_window[@child_key])
  208.     return true
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # ○ 子メッセージウィンドウの作成
  212.   #--------------------------------------------------------------------------
  213.   def create_child_message
  214.     window = Window_ChildMessage.new
  215.     return set_link_event_id(window, $1.to_i) if @child_key =~ /event_id_key_(\d+)/
  216.     return window if link_player(window)
  217.     $game_map.events.values.each {|event| break if link_event(event, window) }
  218.     return window
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ○ リンクするプレイヤーの取得
  222.   #--------------------------------------------------------------------------
  223.   def link_player(window)
  224.     return true if link_event($game_player, window)
  225.     $game_player.followers.each {|follower| return true if link_event(follower, window) }
  226.     return false
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # ○ リンクするイベントの取得
  230.   #--------------------------------------------------------------------------
  231.   def link_event(event, window)
  232.     return false unless search_link_event(event.character_name, event.character_index)
  233.     set_link_event(window, event)
  234.     return true
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # ○ リンクするイベントの検索
  238.   #--------------------------------------------------------------------------
  239.   def search_link_event(name, index)
  240.     return "#{name}_#{index}" == @child_key unless @child_key.is_a?(Array)
  241.     @child_key.each {|key| return true if "#{name}_#{index}" == key }
  242.     return false
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ○ リンクするイベントの設定(ID)
  246.   #--------------------------------------------------------------------------
  247.   def set_link_event_id(window, event_id)
  248.     window.link_event = $game_map.events[event_id]
  249.     return window
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ○ リンクするイベントの設定
  253.   #--------------------------------------------------------------------------
  254.   def set_link_event(window, event)
  255.     window.link_event = event
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ○ 子メッセージウィンドウの処理
  259.   #--------------------------------------------------------------------------
  260.   def process_child_message_window(window)
  261.     @child_window = window
  262.     window.position     = $game_message.position
  263.     text                = convert_escape_characters($game_message.all_text)
  264.     text_width          = $a1_common.text_width(window.contents.font, text)
  265.     $game_message.texts = text.split("\n")
  266.     window.set_face_info($game_message.face_name, $game_message.face_index)
  267.     window.set_width(window.new_line_x + text_width + standard_padding * 2)
  268.     window.background   = $game_message.background
  269.     window.create_contents
  270.     setup_priority(window)
  271.     window.process_all_text
  272.     @use_child = true
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # ○ 子メッセージウィンドウの表示優先度の設定
  276.   #--------------------------------------------------------------------------
  277.   def setup_priority(now_window)
  278.     @priority_order ||= []
  279.     @priority_order.delete(@child_key)
  280.     @priority_order.insert(0, @child_key)
  281.     @priority_order.each_with_index {|key, i | @child_message_window[key].priority = @priority_order.size - i }
  282.   end
  283.   #--------------------------------------------------------------------------
  284.   # ○ クローズカウントのセット
  285.   #--------------------------------------------------------------------------
  286.   def set_close_count(value)
  287.     @child_window.close_count = value
  288.     return ""
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ○ ポップアップ種別のセット
  292.   #--------------------------------------------------------------------------
  293.   def set_popup_kind
  294.     @child_window.popup_kind = 1
  295.     return ""
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # ☆ 入力待ち処理
  299.   #--------------------------------------------------------------------------
  300.   alias a1_child_message_window_wm_input_pause input_pause
  301.   def input_pause
  302.     return if @use_child
  303.     a1_child_message_window_wm_input_pause
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ☆ ウィンドウを閉じ、完全に閉じるまで待つ
  307.   #--------------------------------------------------------------------------
  308.   alias a1_child_message_window_wm_close_and_wait close_and_wait
  309.   def close_and_wait
  310.     @child_message_window.values.each {|window| window.close if window.input_wait }
  311.     a1_child_message_window_wm_close_and_wait
  312.     @priority_order = []
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ☆ 全ウィンドウが完全に閉じているか判定
  316.   #--------------------------------------------------------------------------
  317.   alias a1_child_message_window_wm_all_close? all_close?
  318.   def all_close?
  319.     return false unless a1_child_message_window_wm_all_close?
  320.     @child_message_window.values.each {|window| return false unless window.close? if window.input_wait }
  321.     return true
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # ☆ 背景と位置の変更判定
  325.   #--------------------------------------------------------------------------
  326.   alias a1_child_message_window_wm_settings_changed? settings_changed?
  327.   def settings_changed?
  328.     return false if $game_system.enable_child_msg
  329.     a1_child_message_window_wm_settings_changed?
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ○ 吹き出しの初期化
  333.   #--------------------------------------------------------------------------
  334.   def init_popup_message
  335.     @child_message_window.values.each {|window| window.dispose }
  336.     @child_message_window = {}
  337.   end
  338. end
  339. #==============================================================================
  340. # ■ Window_ChildMessage
  341. #==============================================================================

  342. class Window_ChildMessage < Window_Message
  343.   #--------------------------------------------------------------------------
  344.   # ○ 定数
  345.   #--------------------------------------------------------------------------
  346.   CLOSE_COUNT      = A1_System::CnildMassageWindowConfig::DEFAULT_CLOSE_COUNT
  347.   POS_UP           = 0
  348.   POS_MIDDLE       = 1
  349.   POS_DOWN         = 2
  350.   POPUP_RECT       = { POS_UP     => [Rect.new( 0,  0, 32, 64), Rect.new( 0, 64, 32, 64)],
  351.                        POS_MIDDLE => [Rect.new( 0,  0, 32, 64), Rect.new( 0, 64, 32, 64)],
  352.                        POS_DOWN   => [Rect.new(32,  0, 32, 64), Rect.new(32, 64, 32, 64)],
  353.                      }
  354.   #--------------------------------------------------------------------------
  355.   # ○ オブジェクト初期化
  356.   #--------------------------------------------------------------------------
  357.   def initialize
  358.     @my_child_window = true
  359.     @screen_width = Graphics.width
  360.     super
  361.     create_popup
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # ○ 表示優先度の設定
  365.   #--------------------------------------------------------------------------
  366.   def priority=(value)
  367.     self.z = 200 + value
  368.     @popup_sprite.z = 200 + value
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ○ 吹き出しスプライトの作成
  372.   #--------------------------------------------------------------------------
  373.   def create_popup
  374.     @popup_sprite = Sprite.new
  375.     @popup_sprite.visible = false
  376.     @popup_bitmap = Cache.system("Window_Popup")
  377.     bitmap = Bitmap.new(32, 64)
  378.     @popup_sprite.bitmap = bitmap
  379.     @input_wait = true
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ○ 顔グラフィックの情報を設定
  383.   #--------------------------------------------------------------------------
  384.   def set_face_info(name, index)
  385.     @face_name  = name
  386.     @face_index = index
  387.     @name_window_key = show_name(@face_name, @face_index) if $imported["A1_Name_Window"]
  388.   end
  389.   #--------------------------------------------------------------------------
  390.   # ○ リンクするイベントの取得
  391.   #--------------------------------------------------------------------------
  392.   def link_event
  393.     @event
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # ○ リンクするイベントの設定
  397.   #--------------------------------------------------------------------------
  398.   def link_event=(event)
  399.     @event = event
  400.   end
  401.   #--------------------------------------------------------------------------
  402.   # ○ 表示位置の設定
  403.   #--------------------------------------------------------------------------
  404.   def position=(pos)
  405.     @position = pos
  406.     @position = 0 if @position == 1
  407.     set_popup_bitmap(0)
  408.   end
  409.   #--------------------------------------------------------------------------
  410.   # ○ 背景の設定
  411.   #--------------------------------------------------------------------------
  412.   def background=(type)
  413.     @background = type
  414.     self.opacity = @background == 0 ? 255 : 0
  415.     setup_back_ground if @background == 1
  416.     @back_sprite.visible = false if @back_sprite && @background != 1
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # ○ 背景のセットアップ
  420.   #--------------------------------------------------------------------------
  421.   def setup_back_ground
  422.     @back_bitmap.dispose if @back_bitmap
  423.     create_back_bitmap_ex
  424.     @back_sprite = Sprite.new unless @back_sprite
  425.     setup_back_sprite
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # ○ 背景のビットマップ作成
  429.   #--------------------------------------------------------------------------
  430.   def create_back_bitmap_ex
  431.     @back_bitmap = Bitmap.new(width, height)
  432.     rect1 = Rect.new(0, 0, width, 12)
  433.     rect2 = Rect.new(0, 12, width, height - 24)
  434.     rect3 = Rect.new(0, height - 12, width, 12)
  435.     @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
  436.     @back_bitmap.fill_rect(rect2, back_color1)
  437.     @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
  438.   end
  439.   #--------------------------------------------------------------------------
  440.   # ○ 背景のスプライトの作成
  441.   #--------------------------------------------------------------------------
  442.   def setup_back_sprite
  443.     @back_sprite.bitmap = @back_bitmap
  444.     @back_sprite.z = z - 1
  445.     @back_sprite.visible = false
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # ○ 背景ビットマップの解放
  449.   #--------------------------------------------------------------------------
  450.   def dispose_back_bitmap
  451.     super if @back_bitmap
  452.   end
  453.   #--------------------------------------------------------------------------
  454.   # ○ 背景スプライトの解放
  455.   #--------------------------------------------------------------------------
  456.   def dispose_back_sprite
  457.     super if @back_sprite
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # ○ 背景スプライトの更新
  461.   #--------------------------------------------------------------------------
  462.   def update_back_sprite
  463.     return unless @back_sprite && @background == 1
  464.     @back_sprite.x = self.x
  465.     @back_sprite.y = self.y
  466.     @back_sprite.visible = true
  467.     @back_sprite.opacity = openness
  468.     @back_sprite.update
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # ○ ウィンドウ背景の更新
  472.   #--------------------------------------------------------------------------
  473.   def update_background
  474.     self.opacity = @background == 0 ? 255 : 0
  475.   end
  476.   #--------------------------------------------------------------------------
  477.   # ○ フレーム更新
  478.   #--------------------------------------------------------------------------
  479.   def update
  480.     return unless @event
  481.     update_pos
  482.     super
  483.     update_close_count
  484.     update_background
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # ○ クローズカウントの更新
  488.   #--------------------------------------------------------------------------
  489.   def update_close_count
  490.     return unless @close_count
  491.     return if @close_count < 0
  492.     @close_count -= 1
  493.     auto_close if @close_count == 0
  494.   end
  495.   #--------------------------------------------------------------------------
  496.   # ○ ポップアップスプライト位置の設定
  497.   #--------------------------------------------------------------------------
  498.   def set_popup_pos
  499.     @popup_sprite.x = @event.screen_x
  500.     @popup_sprite.y = self.y + popup_pos_y
  501.     @popup_sprite.visible = open? && @background == 0
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # ○ ポップアップビットマップの設定
  505.   #--------------------------------------------------------------------------
  506.   def set_popup_bitmap(kind)
  507.     @popup_sprite.bitmap.clear
  508.     @popup_sprite.bitmap.blt(0, 0, @popup_bitmap, POPUP_RECT[@position][kind])
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # ○ ポップアップ種別の設定
  512.   #--------------------------------------------------------------------------
  513.   def popup_kind=(kind)
  514.     set_popup_bitmap(1)
  515.   end
  516.   #--------------------------------------------------------------------------
  517.   # ○ ウィンドウ位置の更新
  518.   #--------------------------------------------------------------------------
  519.   def update_pos
  520.     self.x = @event.screen_x + @pos_x
  521.     self.y = @event.screen_y + pos_y
  522.     set_popup_pos
  523.     set_name_window_pos if $imported["A1_Name_Window"]
  524.   end
  525.   #--------------------------------------------------------------------------
  526.   # ○ ネームウィンドウの位置設定
  527.   #--------------------------------------------------------------------------
  528.   def set_name_window_pos
  529.     return unless @name_windows[@name_window_key]
  530.     @name_windows[@name_window_key].x = self.x + 24
  531.     @name_windows[@name_window_key].y = name_window_y
  532.     @name_windows[@name_window_key].z = self.z
  533.     @name_windows[@name_window_key].set_name_sprite_pos
  534.   end
  535.   #--------------------------------------------------------------------------
  536.   # ○ ネームウィンドウのy座標設定
  537.   #--------------------------------------------------------------------------
  538.   def name_window_y
  539.     return self.y + self.height - 12 if @position == 2
  540.     self.y - 16
  541.   end
  542.   #--------------------------------------------------------------------------
  543.   # ○ ウィンドウx座標の取得
  544.   #--------------------------------------------------------------------------
  545.   def set_pos_x
  546.     base = @event.screen_x - 64
  547.     return @pos_x = (@screen_width - self.width) - (base + 64) if base + self.width > @screen_width
  548.     @pos_x = -64
  549.   end
  550.   #--------------------------------------------------------------------------
  551.   # ○ ウィンドウy座標の取得
  552.   #--------------------------------------------------------------------------
  553.   def pos_y
  554.     return -116 if @position == 0
  555.     return  16 if @position == 2
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # ○ ポップアップy座標の取得
  559.   #--------------------------------------------------------------------------
  560.   def popup_pos_y
  561.     return self.height - 32 if @position == 0
  562.     return -32 if @position == 2
  563.   end
  564.   #--------------------------------------------------------------------------
  565.   # ○ 自動で閉じる
  566.   #--------------------------------------------------------------------------
  567.   def auto_close
  568.     close
  569.     @close_count = nil
  570.   end
  571.   #--------------------------------------------------------------------------
  572.   # ○ 解放
  573.   #--------------------------------------------------------------------------
  574.   def dispose
  575.     @popup_sprite.bitmap.dispose
  576.     @popup_sprite.dispose
  577.     super
  578.   end
  579.   #--------------------------------------------------------------------------
  580.   # ○ 制御文字の事前変換
  581.   #--------------------------------------------------------------------------
  582.   def convert_escape_characters(text)
  583.     text
  584.   end
  585.   #--------------------------------------------------------------------------
  586.   # ○ 背景ビットマップの作成
  587.   #--------------------------------------------------------------------------
  588.   def create_back_bitmap
  589.   end
  590.   #--------------------------------------------------------------------------
  591.   # ○ 背景スプライトの作成
  592.   #--------------------------------------------------------------------------
  593.   def create_back_sprite
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ○ 全ウィンドウの作成
  597.   #--------------------------------------------------------------------------
  598.   def create_all_windows
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # ○ 全ウィンドウの解放
  602.   #--------------------------------------------------------------------------
  603.   def dispose_all_windows
  604.   end
  605.   #--------------------------------------------------------------------------
  606.   # ○ 全ウィンドウの更新
  607.   #--------------------------------------------------------------------------
  608.   def update_all_windows
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ○ 全ウィンドウが完全に閉じているか判定
  612.   #--------------------------------------------------------------------------
  613.   def all_close?
  614.     close?
  615.   end
  616.   #--------------------------------------------------------------------------
  617.   # ○ ファイバーの更新
  618.   #--------------------------------------------------------------------------
  619.   def update_fiber
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   # ○ 入力処理
  623.   #--------------------------------------------------------------------------
  624.   def process_input
  625.     input_pause unless @pause_skip
  626.   end
  627.   #--------------------------------------------------------------------------
  628.   # ○ ウィンドウ幅の取得
  629.   #--------------------------------------------------------------------------
  630.   def window_width
  631.     return self.width unless self.disposed?
  632.     Graphics.width
  633.   end
  634.   #--------------------------------------------------------------------------
  635.   # ○ ウィンドウ高さの取得
  636.   #--------------------------------------------------------------------------
  637.   def window_height
  638.     fitting_height(visible_line_number)
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # ○ 表示行数の取得
  642.   #--------------------------------------------------------------------------
  643.   def visible_line_number
  644.     return 2
  645.   end
  646.   #--------------------------------------------------------------------------
  647.   # ○ ウィンドウ幅の設定
  648.   #--------------------------------------------------------------------------
  649.   def set_width(width)
  650.     self.width         = width
  651.   end
  652.   #--------------------------------------------------------------------------
  653.   # ○ テキストの設定
  654.   #--------------------------------------------------------------------------
  655.   def text=(text)
  656.     @text = text
  657.   end
  658.   #--------------------------------------------------------------------------
  659.   # ○ 全テキストの処理
  660.   #--------------------------------------------------------------------------
  661.   def process_all_text
  662.     @input_wait = $game_temp.input_wait
  663.     $game_temp.input_wait = true
  664.     set_pos_x
  665.     super
  666.     @init_close_count = CLOSE_COUNT unless @init_close_count
  667.     input_pause
  668.   end
  669.   #--------------------------------------------------------------------------
  670.   # ○ ウィンドウを開き、完全に開くまで待つ
  671.   #--------------------------------------------------------------------------
  672.   def open_and_wait
  673.     open
  674.     Fiber.yield until open? if @input_wait
  675.   end
  676.   #--------------------------------------------------------------------------
  677.   # ○ 入力待ち取得
  678.   #--------------------------------------------------------------------------
  679.   def input_wait
  680.     @input_wait
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # ○ 入力待ち取得
  684.   #--------------------------------------------------------------------------
  685.   def input_wait
  686.     @input_wait
  687.   end
  688.   #--------------------------------------------------------------------------
  689.   # ○ 入力待ち処理
  690.   #--------------------------------------------------------------------------
  691.   def input_pause
  692.     reset_close_count
  693.     super if @input_wait
  694.     @input_wait = true if @parallel_release
  695.     @parallel_release = false
  696.     start_close_count
  697.   end
  698.   #--------------------------------------------------------------------------
  699.   # ○ クローズカウントの開始
  700.   #--------------------------------------------------------------------------
  701.   def start_close_count
  702.     @close_count = @init_close_count
  703.     @init_close_count = nil
  704.   end
  705.   #--------------------------------------------------------------------------
  706.   # ○ クローズカウントの設定
  707.   #--------------------------------------------------------------------------
  708.   def close_count=(count)
  709.     @init_close_count = count
  710.   end
  711.   #--------------------------------------------------------------------------
  712.   # ○ クローズカウントのリセット
  713.   #--------------------------------------------------------------------------
  714.   def reset_close_count
  715.     @close_count      = nil
  716.   end
  717.   #--------------------------------------------------------------------------
  718.   # ○ ウィンドウを閉じる
  719.   #--------------------------------------------------------------------------
  720.   def close
  721.     reset_close_count
  722.     super
  723.   end
  724.   #--------------------------------------------------------------------------
  725.   # ○ 改行位置の取得
  726.   #--------------------------------------------------------------------------
  727.   def new_line_x
  728.     $game_message.face_name.empty? ? 0 : 56
  729.   end
  730.   #--------------------------------------------------------------------------
  731.   # ○ 制御文字の処理
  732.   #     code : 制御文字の本体部分(「\C[1]」なら「C」)
  733.   #     text : 描画処理中の文字列バッファ(必要なら破壊的に変更)
  734.   #     pos  : 描画位置 {:x, :y, :new_x, :height}
  735.   #--------------------------------------------------------------------------
  736.   def process_escape_character(code, text, pos)
  737.     case code.upcase
  738.     when 'PR'
  739.       @parallel_release = true
  740.     else
  741.       super
  742.     end
  743.   end
  744.   #--------------------------------------------------------------------------
  745.   # ○ ネームウィンドウの表示
  746.   #--------------------------------------------------------------------------
  747.   def show_name_window(face_name, face_index, x, size = 96)
  748.     super
  749.     set_name_window_pos
  750.   end
  751. end
  752. #==============================================================================
  753. # ■ Window_Base
  754. #------------------------------------------------------------------------------
  755. #  ゲーム中の全てのウィンドウのスーパークラスです。
  756. #==============================================================================

  757. class Window_Base < Window
  758.   #--------------------------------------------------------------------------
  759.   # ☆ 顔グラフィックの描画
  760.   #     enabled : 有効フラグ。false のとき半透明で描画
  761.   #--------------------------------------------------------------------------
  762.   alias a1_child_message_window_wb_draw_face draw_face
  763.   def draw_face(face_name, face_index, x, y, size = 96)
  764.     return draw_face_half(face_name, face_index, x, y, size) if @my_child_window
  765.     a1_child_message_window_wb_draw_face(face_name, face_index, x, y, size)
  766.   end
  767.   #--------------------------------------------------------------------------
  768.   # ○ 顔グラフィックの描画(ハーフサイズ)
  769.   #     enabled : 有効フラグ。false のとき半透明で描画
  770.   #--------------------------------------------------------------------------
  771.   def draw_face_half(face_name, face_index, x, y, enabled = true)
  772.     draw_half_face(face_name, face_index, x, y, enabled) unless face_name.empty?
  773.     show_name_window(face_name, face_index, x, 48) if $imported["A1_Name_Window"]
  774.   end
  775.   #--------------------------------------------------------------------------
  776.   # ○ 顔グラフィックの描画(ハーフサイズ)
  777.   #--------------------------------------------------------------------------
  778.   def draw_half_face(face_name, face_index, x, y, enabled)
  779.     bitmap = Cache.half_face(face_name)
  780.     rect = Rect.new(face_index % 4 * 48, face_index / 4 * 48, 48, 48)
  781.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  782.   end
  783.   #--------------------------------------------------------------------------
  784.   # ☆ 制御文字の事前変換
  785.   #    実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
  786.   #    文字「\」はエスケープ文字(\e)に変換。
  787.   #--------------------------------------------------------------------------
  788.   alias a1_child_message_window_wb_convert_escape_characters convert_escape_characters
  789.   def convert_escape_characters(text)
  790.     result = a1_child_message_window_wb_convert_escape_characters(text)
  791.     result.gsub!(/\eCC\[(\d+)\]/i)          { set_close_count($1.to_i) }
  792.     result.gsub!(/\eKP/i)                   { set_popup_kind }
  793.     result
  794.   end
  795. end
  796. #==============================================================================
  797. # ■ Game_Message
  798. #------------------------------------------------------------------------------
  799. #  文章や選択肢などを表示するメッセージウィンドウの状態を扱うクラスです。この
  800. # クラスのインスタンスは $game_message で参照されます。
  801. #==============================================================================

  802. class Game_Message
  803.   #--------------------------------------------------------------------------
  804.   # ○ 公開インスタンス変数
  805.   #--------------------------------------------------------------------------
  806.   attr_accessor :close_message
  807.   #--------------------------------------------------------------------------
  808.   # ☆ オブジェクト初期化
  809.   #--------------------------------------------------------------------------
  810.   alias a1_child_message_window_gm_initialize initialize
  811.   def initialize
  812.     a1_child_message_window_gm_initialize
  813.     @input_wait    = true
  814.     @close_message = nil
  815.   end
  816.   #--------------------------------------------------------------------------
  817.   # ○ 表示するテキストの設定
  818.   #--------------------------------------------------------------------------
  819.   def texts=(text)
  820.     @texts = text
  821.   end
  822. end
  823. #==============================================================================
  824. # ■ Game_Temp
  825. #------------------------------------------------------------------------------
  826. #  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン
  827. # スタンスは $game_temp で参照されます。
  828. #==============================================================================

  829. class Game_Temp
  830.   #--------------------------------------------------------------------------
  831.   # ○ 公開インスタンス変数
  832.   #--------------------------------------------------------------------------
  833.   attr_accessor :input_wait
  834.   attr_accessor :event_popup_id
  835.   #--------------------------------------------------------------------------
  836.   # ☆ オブジェクト初期化
  837.   #--------------------------------------------------------------------------
  838.   alias a1_child_message_gt_initialize initialize
  839.   def initialize
  840.     a1_child_message_gt_initialize
  841.     @input_wait     = true
  842.     @event_popup_id = nil
  843.   end
  844. end
  845. #==============================================================================
  846. # ■ Game_System
  847. #------------------------------------------------------------------------------
  848. #  システム周りのデータを扱うクラスです。セーブやメニューの禁止状態などを保存
  849. # します。このクラスのインスタンスは $game_system で参照されます。
  850. #==============================================================================

  851. class Game_System
  852.   #--------------------------------------------------------------------------
  853.   # ○ 公開インスタンス変数
  854.   #--------------------------------------------------------------------------
  855.   attr_accessor :enable_child_msg
  856.   #--------------------------------------------------------------------------
  857.   # ☆ オブジェクト初期化
  858.   #--------------------------------------------------------------------------
  859.   alias a1_child_message_gs_initialize initialize
  860.   def initialize
  861.     a1_child_message_gs_initialize
  862.     @enable_child_msg = A1_System::CnildMassageWindowConfig::DEFAULT_ENABLE_POPUP
  863.   end
  864. end
  865. #==============================================================================
  866. # ■ A1_System::CommonModule
  867. #==============================================================================

  868. class A1_System::CommonModule
  869.   #--------------------------------------------------------------------------
  870.   # ☆ 注釈コマンド定義
  871.   #--------------------------------------------------------------------------
  872.   alias a1_child_message_define_command define_command
  873.   def define_command
  874.     a1_child_message_define_command
  875.     @cmd_108["並列吹き出し"]     = :sub_message
  876.     @cmd_108["吹き出しクローズ"] = :close_popup
  877.     @cmd_108["吹き出し使用"]     = :use_popup_message
  878.     @cmd_108["イベント吹き出し"] = :event_popup_message
  879.   end
  880. end
  881. #==============================================================================
  882. # ■ Game_Interpreter
  883. #------------------------------------------------------------------------------
  884. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  885. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  886. #==============================================================================

  887. class Game_Interpreter
  888.   #--------------------------------------------------------------------------
  889.   # ○ 並列吹き出し
  890.   #--------------------------------------------------------------------------
  891.   def sub_message(params)
  892.     $game_temp.input_wait = false
  893.   end
  894.   #--------------------------------------------------------------------------
  895.   # ○ 吹き出しクローズ
  896.   #--------------------------------------------------------------------------
  897.   def close_popup(params)
  898.     return close_popup_id(params[0]) if params[0].is_a?(Array)
  899.     $game_message.close_message = params[0]
  900.   end
  901.   #--------------------------------------------------------------------------
  902.   # ○ 吹き出しクローズ(ID)
  903.   #--------------------------------------------------------------------------
  904.   def close_popup_id(params)
  905.     $game_message.close_message = "event_id_key_#{params[1].to_i}" if params[0] == "イベント"
  906.   end
  907.   #--------------------------------------------------------------------------
  908.   # ○ 吹き出し使用
  909.   #--------------------------------------------------------------------------
  910.   def use_popup_message(params)
  911.     $game_system.enable_child_msg = params[0] == "on" ? true : false
  912.   end
  913.   #--------------------------------------------------------------------------
  914.   # ○ イベント吹き出し
  915.   #--------------------------------------------------------------------------
  916.   def event_popup_message(params)
  917.     $game_temp.event_popup_id = params[0].to_i
  918.   end
  919. end
  920. #==============================================================================
  921. # ■ Scene_Map
  922. #------------------------------------------------------------------------------
  923. #  マップ画面の処理を行うクラスです。
  924. #==============================================================================

  925. class Scene_Map < Scene_Base
  926.   #--------------------------------------------------------------------------
  927.   # ☆ 場所移動の処理
  928.   #--------------------------------------------------------------------------
  929.   alias a1_child_message_sm_perform_transfer perform_transfer
  930.   def perform_transfer
  931.     prev_map = $game_map.map_id
  932.     a1_child_message_sm_perform_transfer
  933.     @message_window.init_popup_message if prev_map != $game_map.map_id
  934.   end
  935. end
  936. #==============================================================================
  937. # ■ ネームウィンドウインポート時処理
  938. #==============================================================================
  939. if $imported["A1_Name_Window"]
  940. #==============================================================================
  941. # ■ Window_FaceName
  942. #==============================================================================

  943. class Window_FaceName < Window_Base
  944.   #--------------------------------------------------------------------------
  945.   # ○ ネームスプライトの位置設定
  946.   #--------------------------------------------------------------------------
  947.   def set_name_sprite_pos
  948.     @name_sprite.x = self.x + self.width / 2
  949.     @name_sprite.y = self.y + self.height / 2
  950.   end
  951. end;end
  952. end
复制代码



Window_Popup.png


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

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

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


我想問的是
要怎樣 讓 主角 也能 呼出 這樣的視窗
還有就是 怎麼 向他 官網一依樣 跑出 人物名字
梦石
0
星屑
5476
在线时间
761 小时
注册时间
2009-1-21
回帖
236
 楼主| 发表于 2012-8-11 09:40:41 | 显示全部楼层
上提一下

麻煩 會的幫幫忙囉
回复

使用道具 举报

梦石
0
星屑
5476
在线时间
761 小时
注册时间
2009-1-21
回帖
236
 楼主| 发表于 2012-8-12 16:27:38 | 显示全部楼层
上提一下

麻煩 會的幫幫忙囉
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部