查看: 2048|回复: 2

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

[复制链接]
梦石
0
星屑
5241
在线时间
760 小时
注册时间
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共通


[pre lang="ruby" line="1"]# ===========================================================================
# ◆ A1 Scripts ◆
#    A1共通処理(RGSS2/RGSS3共用)
#
# バージョン   : 4.50 (2012/01/26)
# 作者         : A1
# URL     : http://a1tktk.web.fc2.com/
# ---------------------------------------------------------------------------
# 更新履歴   :2011/11/11 Ver1.00 新規作成
#        :2011/12/22 Ver2.00 RGSS3用と同様の処理に変更
#        :2011/12/30 Ver2.10 RGSS3用メソッドを追加
#        :2011/12/30 Ver3.00 RGSS3用共通処理と統合
#        :2011/12/31 Ver3.10 マップチップサーチの仕様を変更
#        :2011/12/31 Ver3.10 拡張通行判定を追加
#        :2012/01/01 Ver3.11 クラス名の取得処理を追加
#              :2012/01/02 Ver3.20 配列を考慮したsplit処理を追加
#              :2012/01/02 Ver3.20 配列の全ての要素を整数にする処理を追加
#              :2012/01/02 Ver3.30 注釈の処理の仕様を変更
#              :2012/01/02 Ver3.40 「前のイベントコマンドの取得」を追加
#              :2012/01/03 Ver3.50 「フレーム更新」を追加
#              :2012/01/04 Ver3.60 「指定のウィンドウが開いている間ウェイト」追加
#              :2012/01/04 Ver3.70 RGSS2用処理見直し
#              :2012/01/05 Ver3.80 注釈文字列にエスケープコマンド対応
#              :2012/01/05 Ver3.80 多次元配列を考慮したsplit処理を追加
#              :2012/01/05 Ver3.80 注釈にスクリプト処理機能を追加
#              :2012/01/10 Ver3.90 文字縁取り描画を追加
#              :2012/01/11 Ver4.00 テキストビットマップのキャッシュを追加
#              :2012/01/13 Ver4.01 「タイルセットの変更」ができなくなる不具合を修正
#              :2012/01/14 Ver4.10 split処理を強化
#              :2012/01/14 Ver4.20 空白を含む注釈コマンドに対応
#              :2012/01/14 Ver4.21 split処理の不具合を修正
#              :2012/01/21 Ver4.30 メモの内容を取得する関数を追加
#              :2012/01/24 Ver4.40 メモの内容を取得する関数を追加
#              :2012/01/24 Ver4.50 メモの内容を取得する関数を追加
# ---------------------------------------------------------------------------
# 設置場所      
#  なるべく上の方
#
# 必要スクリプト
#    なし
#==============================================================================
$imported = {} if $imported == nil
$imported["A1_Common_Script"] = 4.50
#==============================================================================
# ■ Kernel
#==============================================================================
module Kernel
  #--------------------------------------------------------------------------
  # ○ RGSSのバージョン取得
  #--------------------------------------------------------------------------
  def rgss_version
    return 3 if defined? Graphics.play_movie
    return 2 if defined? Graphics.resize_screen
    return 1
  end
  #--------------------------------------------------------------------------
  # ○ コモンスクリプトのバージョン取得
  #--------------------------------------------------------------------------
  def common_version
    $imported["A1_Common_Script"]
  end
  #--------------------------------------------------------------------------
  # ○ コモンスクリプトのバージョンが古い
  #--------------------------------------------------------------------------
  def old_common_script(script_name, version)
    msgbox("#{script_name}にはA1共通スクリプトVer#{version}以上が必要です")
  end
end
#==============================================================================
# ■ A1_System
#==============================================================================
module A1_System
end
#==============================================================================
# ■ A1_System::CommonModule
#==============================================================================

class A1_System::CommonModule
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  TWOBYTE_LIST = {
                  " " => " ",
                  "=" => "=",
                  ":" => ":"
                  }
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    define_command
  end
  #--------------------------------------------------------------------------
  # ○ 変換対象の全角文字を半角に置換
  #--------------------------------------------------------------------------
  def replace_twobyte(str)
    for key in TWOBYTE_LIST.keys
      str.gsub!(key) {TWOBYTE_LIST[key]}
    end
    return str
  end
  #--------------------------------------------------------------------------
  # ○ マイナスが含まれている文字列を数値にする
  #--------------------------------------------------------------------------
  def minus_to_i(s)
    if s[0,0] == "-"
      s.gsub!("-","")
      return s.to_i * -1
    else
      return s.to_i
    end
  end
  #--------------------------------------------------------------------------
  # ○ ミリ秒単位の現在時間
  #--------------------------------------------------------------------------
  def now_usec
    now = Time.now
    hour = now.hour * 60 * 60
    min  = now.min * 60
    sec  = now.sec
    msec = (now.usec / 1000.0).round
    return (hour + min + sec) * 1000 + msec
  end
  #--------------------------------------------------------------------------
  # ○ イベントリストの作成
  #--------------------------------------------------------------------------
  def create_event_list(code, indent, parameters)
    list = RPG::EventCommand.new
    list.code       = code
    list.indent     = indent
    list.parameters = parameters
    return list
  end
  #--------------------------------------------------------------------------
  # ○ メソッド呼び出し
  #--------------------------------------------------------------------------
  def send_method(method_name)
    return send(method_name) if respond_to?(method_name)
  end
  #--------------------------------------------------------------------------
  # ○ オブジェクトの型を判断してStringならエンコード
  #--------------------------------------------------------------------------
  def encoding_string(obj)
    obj.force_encoding("UTF-8") if obj.is_a?(String)
    return obj
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容から必要な情報を取得
  #--------------------------------------------------------------------------
  def note_data(note, key)
    result = []
    note.each_line {|line|
      next unless line =~ /<#{key}[ ]?(.*)>/
      return true if $1.empty?
      data = $a1_common.replace_twobyte($1).split(" ")
      for st in data
        result.push(st)
      end
    }
    return false if result.empty?
    return result
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容からハッシュを作成
  #--------------------------------------------------------------------------
  def note_data_hash(note, key, data_default = nil, default = {}, ret = {})
    list = note_data_split(note, key)
    return default if list.empty?
    list.each {|data| ret[data[0]] = data[1] ? data[1] : data_default }
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容からカンマ区切りの多元配列を取得
  #--------------------------------------------------------------------------
  def note_data_split(note, key, default = [], ret = [])
    data = note_data(note, key)
    return default unless data.is_a?(Array)
    data.each {|str| ret.push(convert_integer_from_array(split_array(str)))}
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ 配列の内容から数値があれば変換
  #--------------------------------------------------------------------------
  def convert_integer_from_array(data, ret = [])
    data.each {|str| ret.push(convert_integer(str))}
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ 数値があれば変換
  #--------------------------------------------------------------------------
  def convert_integer(str)
    return $1.to_i if str =~ /(^[-]?[0-9]+$)/
    str.is_a?(Array) ? convert_integer_from_array(str) : str
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容から単項目の数値を取得
  #--------------------------------------------------------------------------
  def note_data_one_value(note, key, default)
    data = note_data(note, key)
    return data[0].to_i if data.is_a?(Array)
    return default
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容から単項目を取得
  #--------------------------------------------------------------------------
  def note_data_one(note, key, default)
    data = note_data(note, key)
    return data[0] if data.is_a?(Array)
    return default
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容からカンマ区切りの文字列を取得
  #--------------------------------------------------------------------------
  def note_data_array_str(note, key, default)
    data = note_data(note, key)
    return data[0].split(",") if data.is_a?(Array)
    return default
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容からカンマ区切りの数値を取得
  #--------------------------------------------------------------------------
  def note_data_array_value(note, key, default)
    data = note_data(note, key)
    return default unless data.is_a?(Array)
    return convert_integer_from_array(split_array(data[0]))
  end
  #--------------------------------------------------------------------------
  # ○ カンマ区切りの文字列メモを変換
  #--------------------------------------------------------------------------
  def note_data_array(note, key, type, default = nil, through = true)
    ret = []
    default.each {|dat| ret.push(dat)} if default != nil
   
    data = note_data(note, key)
    return ret unless data.is_a?(Array)
   
    data = data[0].split(",")
    for d in data
      next if ret.include?(d) if through
      ret.push(d.to_i) if type.is_a?(Integer)
      ret.push(d)      if type.is_a?(String)
    end
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ ディレクトリの作成
  #--------------------------------------------------------------------------
  def make_directory(dir_name)
    Dir::mkdir(dir_name) unless FileTest.exist?(dir_name)
  end
  #--------------------------------------------------------------------------
  # ○ コマンドリスト
  #--------------------------------------------------------------------------
  def make_command(command, src = "", dect = "")
    src.gsub!("/","\\")
    dect.gsub!("/","\\")
    cmd = "#{command} \"#{src}\" \"#{dect}\""
    return cmd
  end
  #--------------------------------------------------------------------------
  # ○ 素材の拡張子を取得
  #--------------------------------------------------------------------------
  def material_ext(directory, file, direct = false)
    exts = []
    exts = [".png",".bmp",".jpg"]               if directory =~ /(.*)Graphics\/(.*)/
    exts = [".mid",".ogg",".wav",".mp3",".wma"] if directory =~ /(.*)Audio(.*)/
   
    find_file = sprintf("%s%s", directory, file) unless direct
    find_file = file if direct
   
    for ext in exts
      return ext if File.exist?(sprintf("%s%s", find_file, ext))
    end
    return nil
  end
  #--------------------------------------------------------------------------
  # ○ 素材が存在するかチェック
  #--------------------------------------------------------------------------
  def material_exist?(directory, file, direct = false)
    return false if material_ext(directory, file, direct) == nil
    return true
  end
  #--------------------------------------------------------------------------
  # ○ ファイルコピー
  #--------------------------------------------------------------------------
  def copy_file(src, dest)
    srcFile = File.open( src, "rb" )
    dstFile = File.open( dest, "wb" )
    dstFile.write( srcFile.read )
    srcFile.close
    dstFile.close
  end
  #--------------------------------------------------------------------------
  # ○ ファイルの存在を確認してファイルコピー
  #--------------------------------------------------------------------------
  def material_copy(src, dest, directory)
    ext = material_ext(directory, src, true)
    copy_file( src + ext, dest + ext ) if ext != nil
  end
  #--------------------------------------------------------------------------
  # ○ 配列からAudioを作成
  #--------------------------------------------------------------------------
  def set_audio(sound, kind)
    case kind
    when "BGM"; audio = RPG::BGM.new
    when "BGS"; audio = RPG::BGS.new
    when "ME";  audio = RPG::ME.new
    when "SE";  audio = RPG::SE.new
    end
    audio.name   = sound[0]
    audio.volume = sound[1]
    audio.pitch  = sound[2]
    return audio
  end
  #--------------------------------------------------------------------------
  # ○ 既に準拠識別子を持っているかチェック
  #--------------------------------------------------------------------------
  def chk_rtp(file_name, default)
    return "" if file_name =~ /^VX_.*/
    return "" if file_name =~ /^XP_.*/
    return "" if file_name =~ /^2000_.*/
    return "" if file_name =~ /^2003_.*/
    return default
  end
  #--------------------------------------------------------------------------
  # ○ 先頭の $ を切り出す
  #--------------------------------------------------------------------------
  def one_character(file_name)
    return file_name unless file_name[0] == "$"
    tmp = file_name.clone
    tmp[0] = ""
    return tmp
  end
  #--------------------------------------------------------------------------
  # ○ 配列を入れ替える
  #--------------------------------------------------------------------------
  def change_array(array, index1, index2)
    tmp = array[index1]
    array[index1] = array[index2]
    array[index2] = tmp
    return array
  end
  #--------------------------------------------------------------------------
  # ○ 移動ルートの作成
  #--------------------------------------------------------------------------
  def create_move_route(repeat, skippable, wait, list)
    move_route = RPG::MoveRoute.new
    move_route.repeat    = repeat
    move_route.skippable = skippable
    move_route.wait      = wait
    move_route.list      = list
    return move_route
  end
  #--------------------------------------------------------------------------
  # ○ 移動ルートコマンドの作成
  #--------------------------------------------------------------------------
  def create_move_command(code, parameters)
    list = RPG::MoveCommand.new
    list.code       = code
    list.parameters = parameters
    return list
  end
  #--------------------------------------------------------------------------
  # ○ インタプリタ起動用リストの作成
  #--------------------------------------------------------------------------
  def create_list(code, indent, parameters)
    list            = RPG::EventCommand.new
    list.code       = code
    list.indent     = indent
    list.parameters = parameters
    return list
  end
  #--------------------------------------------------------------------------
  # ○ クラス名の取得
  #--------------------------------------------------------------------------
  def class_name(class_instance)
    return class_instance.to_s.split(":")[0].gsub("#<","")
  end
  #--------------------------------------------------------------------------
  # ○ 配列を考慮したsplit
  #--------------------------------------------------------------------------
  def split_array(str)
    str = convert_escape_characters(str)
   
    ret       = []
    tmp_array = str.split(",")
   
    return strip_array_str(tmp_array) unless str.include?("[")
    tmp_str   = ""
    tmp_array.each {|s|
      if char_in_str(s, "[", "]") && tmp_str.empty?
        ret.push(s) unless s =~ /^\[/
        ret.push([s[1...s.size-1]]) if s =~ /^\[/
      else
        tmp_str = "#{tmp_str}#{s},"
        if char_in_str(tmp_str, "[", "]")
          unless tmp_str =~ /^\[/
            ret.push(tmp_str[0...tmp_str.size-1])
            tmp_str = ""
          else
            tmp_str = tmp_str[1...tmp_str.size-2]
            tmp_str = split_array(tmp_str) if tmp_str.include?("[")
            tmp_str = tmp_str.split(",") if tmp_str.include?(",")
            ret.push(tmp_str)   if tmp_str.is_a?(Array)
            ret.push([tmp_str]) if !tmp_str.is_a?(Array)
            tmp_str = ""
          end
        end
      end
    }
    return strip_array_str(ret)
  end
  #--------------------------------------------------------------------------
  # ○ 配列の中の文字列の先頭と末尾の空白を除去
  #--------------------------------------------------------------------------
  def strip_array_str(array, ret = [])
    array.each {|str| ret.push(strip_array_str(str)) if str.is_a?(Array); next if str.is_a?(Array); ret.push(str.strip) }
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ 文字列の中に文字が何文字含まれているか調べて同数ならtrueを返す
  #--------------------------------------------------------------------------
  def char_in_str(str, c1, c2)
    num1 = 0
    num2 = 0
    (0...str.size).each {|i| num1 += 1 if str == c1; num2 += 1 if str == c2 }
    return num1 == num2
  end
  #--------------------------------------------------------------------------
  # ○ 制御文字の変換
  #--------------------------------------------------------------------------
  def convert_escape_characters(text)
    result = text.to_s.clone
    result.gsub!(/\\/)                           { "\e" }
    result.gsub!(/\e\e/)                         { "\\" }
    result.gsub!(/\eV\[(\d+)\]/i)                { $game_variables[$1.to_i] }
    result.gsub!(/\eV\[(\d+)\]/i)                { $game_variables[$1.to_i] }
    result.gsub!(/\eN\[(\d+)\]/i)                { actor_name($1.to_i) }
    result.gsub!(/\eP\[(\d+)\]/i)                { party_member_name($1.to_i) }
    result.gsub!(/\eG/i)                         { Vocab::currency_unit }
    loop { result = result.sub(/<s>(.+?)<\/s>/i) { eval($1) }; break unless $1 }
    result
  end
  #--------------------------------------------------------------------------
  # ○ アクター n 番の名前を取得
  #--------------------------------------------------------------------------
  def actor_name(n)
    actor = n >= 1 ? $game_actors[n] : nil
    actor ? actor.name : ""
  end
  #--------------------------------------------------------------------------
  # ○ パーティメンバー n 番の名前を取得
  #--------------------------------------------------------------------------
  def party_member_name(n)
    actor = n >= 1 ? $game_party.members[n - 1] : nil
    actor ? actor.name : ""
  end
  #--------------------------------------------------------------------------
  # ○ 配列を全て整数にする
  #--------------------------------------------------------------------------
  def params_to_i(params)
    ret = []
    params.each {|param| ret.push(param.to_i)}
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ 注釈コマンド定義
  #--------------------------------------------------------------------------
  def define_command
    @cmd_108 = {}
  end
  #--------------------------------------------------------------------------
  # ○ 注釈コマンド定義取得
  #--------------------------------------------------------------------------
  def cmd_108
    @cmd_108
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
  end
  #--------------------------------------------------------------------------
  # ○ 文字の幅と高さを取得
  #--------------------------------------------------------------------------
  def text_size(font, size, text)
    bitmap = Cache.system("")
    bitmap.font.name = font
    bitmap.font.size = size
    tw = bitmap.text_size(text).width
    th = bitmap.text_size(text).height
    bitmap.dispose
    return [tw, th]
  end
  #--------------------------------------------------------------------------
  # ○ 文字の幅を取得
  #--------------------------------------------------------------------------
  def text_width(font, text)
    texts = text.split("\n")
    @max_width = 0
    texts.each {|text|
      width = text_size(font.name, font.size, text)[0]
      @max_width = @max_width < width ? width : @max_width
    }
    return @max_width
  end
end
#==============================================================================
# ◆ RGSS3用処理
#==============================================================================
if rgss_version == 3
#==============================================================================
# ■ RPG::Tileset
#==============================================================================

class RPG::Tileset
  #--------------------------------------------------------------------------
  # ○ 拡張通行判定
  #--------------------------------------------------------------------------
  def ex_flags
    @ex_flags ||= Table.new(8192)
    return @ex_flags
  end
  #--------------------------------------------------------------------------
  # ○ 拡張通行判定初期化
  #--------------------------------------------------------------------------
  def init_ex_flags
    @ex_flags = Table.new(8192)
  end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #     depth : ネストの深さ
  #--------------------------------------------------------------------------
  alias a1_common_gi_rgss3_initialize initialize
  def initialize(depth = 0, sub_interpreter = false)
    @sub_interpreter = sub_interpreter
    a1_common_gi_rgss3_initialize(depth)
  end
  #--------------------------------------------------------------------------
  # ☆ メッセージ表示がビジー状態の間ウェイト
  #--------------------------------------------------------------------------
  alias a1_common_gi_wait_for_message wait_for_message
  def wait_for_message
    return if @sub_interpreter
    a1_common_gi_wait_for_message
  end
end
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
#  文章表示に使うメッセージウィンドウです。
#==============================================================================

class Window_Message < Window_Base
  #--------------------------------------------------------------------------
  # ☆ 通常文字の処理
  #--------------------------------------------------------------------------
  alias a1_common_wm_process_normal_character process_normal_character
  def process_normal_character(c, pos)
    wait_for_one_character_before
    a1_common_wm_process_normal_character(c, pos)
  end
  #--------------------------------------------------------------------------
  # ○ 一文字出力前のウェイト
  #--------------------------------------------------------------------------
  def wait_for_one_character_before
  end
end
#==============================================================================
# ■ RPG::Map
#==============================================================================

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

class Game_Map
  #--------------------------------------------------------------------------
  # ☆ セットアップ
  #--------------------------------------------------------------------------
  alias a1_common_gm_setup setup
  def setup(map_id)
    a1_common_gm_setup(map_id)
    setup_tileset
    map_chip_search if search_map_chip?
  end
  #--------------------------------------------------------------------------
  # ★ タイルセットの取得
  #--------------------------------------------------------------------------
  def tileset
    setup_tileset unless @tileset && @now_tileset_id == @tileset_id
    return @tileset
  end
  #--------------------------------------------------------------------------
  # ○ タイルセットのセットアップ
  #--------------------------------------------------------------------------
  def setup_tileset
    @tileset        = $data_tilesets[@tileset_id].clone
    @tileset.flags  = $data_tilesets[@tileset_id].flags.clone
    @now_tileset_id = @tileset_id
  end
  #--------------------------------------------------------------------------
  # ○ マップチップを調べるか判定する
  #--------------------------------------------------------------------------
  def search_map_chip?
    return @map.search_map_chip?
  end
  #--------------------------------------------------------------------------
  # ○ 指定座標の全レイヤーのフラグ判定(イベント含む)
  #--------------------------------------------------------------------------
  def all_tiles_flag?(x, y, bit)
    all_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 }
  end
  #--------------------------------------------------------------------------
  # ○ 指定座標の全レイヤーの拡張フラグ判定(イベント含む)
  #--------------------------------------------------------------------------
  def all_tiles_flag_ex?(x, y, bit)
    all_tiles(x, y).any? {|tile_id| tileset.ex_flags[tile_id] & bit != 0 }
  end
  #--------------------------------------------------------------------------
  # ○ 指定座標の全レイヤーの拡張フラグ判定
  #--------------------------------------------------------------------------
  def layered_tiles_flag_ex?(x, y, bit)
    layered_tiles(x, y).any? {|tile_id| tileset.ex_flags[tile_id] & bit != 0 }
  end
  #--------------------------------------------------------------------------
  # ○ 地形タグの取得(イベント含む)
  #--------------------------------------------------------------------------
  def terrain_tag_all_tailes(x, y)
    return 0 unless valid?(x, y)
    all_tiles(x, y).each do |tile_id|
      tag = tileset.flags[tile_id] >> 12
      return tag if tag > 0
    end
    return 0
  end
end
#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
#  データベースとゲームオブジェクトを管理するモジュールです。ゲームで使用する
# ほぼ全てのグローバル変数はこのモジュールで初期化されます。
#==============================================================================

module DataManager
  #--------------------------------------------------------------------------
  # ○ エイリアス用特異メソッド
  #--------------------------------------------------------------------------
  class << self
    alias :a1_common_create_game_objects :create_game_objects
  end
  #--------------------------------------------------------------------------
  # ☆ 各種ゲームオブジェクトの作成
  #--------------------------------------------------------------------------
  def self.create_game_objects
    $a1_common ||= A1_System::CommonModule.new
    a1_common_create_game_objects
  end
end
#==============================================================================
# ■ Scene_Base
#------------------------------------------------------------------------------
#  ゲーム中の全てのシーンのスーパークラスです。
#==============================================================================

class Scene_Base
  #--------------------------------------------------------------------------
  # ☆ フレーム更新(基本)
  #--------------------------------------------------------------------------
  alias a1_common_sb_update_basic update_basic
  def update_basic
    a1_common_sb_update_basic
    $a1_common.update
  end
  #--------------------------------------------------------------------------
  # ○ 指定のウィンドウが開いている間ウェイト
  #--------------------------------------------------------------------------
  def wait_for_window_open(window)
    update_basic until window.openness == 0
  end
end
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  ゲーム中の全てのウィンドウのスーパークラスです。
#==============================================================================

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

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

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

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ○ 注釈
  #--------------------------------------------------------------------------
  def command_108
    @comments = [@params[0]]
    while next_event_code == 408
      @index += 1
      @comments.push(@list[@index].parameters[0])
    end
  end
  #--------------------------------------------------------------------------
  # ★ イベントコマンドの実行
  #--------------------------------------------------------------------------
  def execute_command
    return rgss3_execute_command unless @index >= @list.size-1
    command_end
    return true
  end
  #--------------------------------------------------------------------------
  # ○ RGSS3風「イベントコマンドの実行」
  #--------------------------------------------------------------------------
  def rgss3_execute_command
    command = @list[@index]
    @params = command.parameters
    @indent = command.indent
    method_name = "command_#{command.code}"
    send(method_name) if respond_to?(method_name)
  end
  #--------------------------------------------------------------------------
  # ○ 次のイベントコマンドのコードを取得
  #--------------------------------------------------------------------------
  def next_event_code
    @list[@index + 1].code
  end
end
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
#  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
# このクラスのインスタンスは $game_map で参照されます。
#==============================================================================

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

class Game_Character
  #--------------------------------------------------------------------------
  # ○ タイル判定
  #--------------------------------------------------------------------------
  def tile?
    @tile_id > 0 && @priority_type == 0
  end
end
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
#  タイトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # ☆ データベースのロード
  #--------------------------------------------------------------------------
  alias a1_common_st_load_database load_database
  def load_database
    a1_common_st_load_database
    $data_map_infos = load_data("Data/MapInfos.rvdata")
  end
  #--------------------------------------------------------------------------
  # ☆ 各種ゲームオブジェクトの作成
  #--------------------------------------------------------------------------
  alias a1_common_st_create_game_objects create_game_objects
  def create_game_objects
    $a1_common ||= A1_System::CommonModule.new
    a1_common_st_create_game_objects
  end
end
#==============================================================================
# ◆ RGSS用処理
#==============================================================================
elsif rgss_version == 1
end
#==============================================================================
# ■ Cache
#------------------------------------------------------------------------------
#  各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
# です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
# のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
# を返すようになっています。
#==============================================================================

module Cache
  #--------------------------------------------------------------------------
  # ○ 拡大縮小したビットマップのロード
  #--------------------------------------------------------------------------
  def self.load_resize_bitmap(load_path, key, resize = nil)
    @cache ||= {}
    key = load_path if key == nil
    return @cache[key] if include?(key)
   
    @cache[key] = Bitmap.new(load_path)
    return @cache[key] if resize == nil
    return @cache[key] if @cache[key].width == resize[0] and @cache[key].height == resize[1]
   
    info = calc_size(resize, key)
    return resize_bitmap(@cache[key], info[0], info[1], key)
  end
  #--------------------------------------------------------------------------
  # ○ 拡大縮小した色相変化済みビットマップを作成/取得
  #--------------------------------------------------------------------------
  def self.load_resize_hue_changed_bitmap(load_path, path, hue, resize)
    key = [path, hue]
    return @cache[key] if include?(key)
   
    @cache[key] = load_resize_bitmap(load_path, path, resize).clone
    @cache[key].hue_change(hue)
    return @cache[key]
  end
  #--------------------------------------------------------------------------
  # ○ リサイズするサイズを取得
  #--------------------------------------------------------------------------
  def self.calc_size(resize, key)
    width  = resize[0]
    width  = @cache[key].width * width.abs if width < 0
    height = resize[1]
    height = @cache[key].height * height.abs if height < 0
    height = Integer(@cache[key].height * (width.to_f / @cache[key].width.to_f)) if height == 0
    return [width, height]
  end
  #--------------------------------------------------------------------------
  # ○ ビットマップの拡大縮小
  #--------------------------------------------------------------------------
  def self.resize_bitmap(bitmap, width, height, key)
    resize = Bitmap.new(width, height)
    resize.stretch_blt(resize.rect, bitmap, bitmap.rect)
    @cache[key] = resize
    return resize
  end
  #--------------------------------------------------------------------------
  # ○ テキストビットマップの取得
  #--------------------------------------------------------------------------
  def self.text_picture(text, font)
    load_text_bitmap(text, font)
  end
  #--------------------------------------------------------------------------
  # ○ フォントのキーを作成
  #--------------------------------------------------------------------------
  def self.make_font_key(text, font)
    [text, font.name, font.size, font.bold, font.italic, font.outline, font.shadow, font.color.to_s, font.out_color.to_s]
  end
  #--------------------------------------------------------------------------
  # ○ テキストビットマップの作成
  #--------------------------------------------------------------------------
  def self.load_text_bitmap(text, font)
    @cache ||= {}
    key = make_font_key(text, font)
    return @cache[key] if include?(key)
   
    # 計算用ダミービットマップ
    bitmap = Cache.system("")
    bitmap.font = font
    tw = bitmap.text_size(text).width + 8
   
    # ビットマップ作成
    bitmap = Bitmap.new(tw, bitmap.font.size + 4)
    bitmap.font = font
    bitmap.draw_text(0, 0, bitmap.width, bitmap.height, text, 1)
   
    @cache[key] = bitmap
    return @cache[key]
  end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ○ 注釈
  #--------------------------------------------------------------------------
  alias a1_common_command_108 command_108
  def command_108
    a1_common_command_108
    proc_comment(@comments)
  end
  #--------------------------------------------------------------------------
  # ○ 注釈の処理
  #--------------------------------------------------------------------------
  def proc_comment(comments)
    param = ""
    comments.each {|comment| param += comment }
    params = param.sub(/^(\S+)/, "")
    command = $1
    comment_parameters = $a1_common.split_array(params) if params
    proc_comment_command(command, comment_parameters)
  end
  #--------------------------------------------------------------------------
  # ○ 注釈の実行
  #--------------------------------------------------------------------------
  def proc_comment_command(command, params)
    cmd_108 = $a1_common.cmd_108[command]
    method(cmd_108).call(params) if cmd_108 != nil
  end
  #--------------------------------------------------------------------------
  # ○ 前のイベントコマンドを取得
  #--------------------------------------------------------------------------
  def prev_event
    @list[@index - 1]
  end
end
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
#  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
# このクラスのインスタンスは $game_map で参照されます。
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # ○ 全マップチップを調べる
  #--------------------------------------------------------------------------
  def map_chip_search
    tileset.init_ex_flags
    (0...@map.data.xsize).each {|x| map_chip_search_y(x) }
  end
  #--------------------------------------------------------------------------
  # ○ x座標にあるy座標のマップチップを調べる
  #--------------------------------------------------------------------------
  def map_chip_search_y(x)
    (0...@map.data.ysize).each {|y| map_pos_proc(x, y); map_chip_search_z(x, y) }
  end
  #--------------------------------------------------------------------------
  # ○ x,y座標にあるz座標のマップチップを調べる
  #--------------------------------------------------------------------------
  def map_chip_search_z(x, y)
    (0...@map.data.zsize).each {|z| map_chip_proc(x, y, z) }
    tile_events_xy(x, y).collect {|ev| tile_event_proc(ev.tile_id) }
  end
  #--------------------------------------------------------------------------
  # ○ 座標に対して処理を行う
  #--------------------------------------------------------------------------
  def map_pos_proc(x, y)
  end
  #--------------------------------------------------------------------------
  # ○ マップチップに対して処理を行う
  #--------------------------------------------------------------------------
  def map_chip_proc(x, y, z)
  end
  #--------------------------------------------------------------------------
  # ○ タイルのイベントに対して処理を行う
  #--------------------------------------------------------------------------
  def tile_event_proc(tile_id)
  end
end
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  ゲーム中の全てのウィンドウのスーパークラスです。
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ○ 入力を受け付けるか?
  #--------------------------------------------------------------------------
  def can_input?
    @can_input
  end
  #--------------------------------------------------------------------------
  # ○ 入力受け付け設定
  #--------------------------------------------------------------------------
  def can_input=(flag)
    @can_input = flag
  end
end
#==============================================================================
# ■ Bitmap
#==============================================================================

class Bitmap
  #--------------------------------------------------------------------------
  # ○ 文字縁取り描画
  #--------------------------------------------------------------------------
  def draw_text_f(x, y, width, height, str, align = 0, color = Color.new(64,32,128))
    shadow = self.font.shadow
    b_color = self.font.color.dup
    font.shadow = false
    font.color = color
    draw_text(x + 1, y, width, height, str, align)
    draw_text(x - 1, y, width, height, str, align)
    draw_text(x, y + 1, width, height, str, align)
    draw_text(x, y - 1, width, height, str, align)
    font.color = b_color
    draw_text(x, y, width, height, str, align)
    font.shadow = shadow
  end
  #--------------------------------------------------------------------------
  # ○ 文字縁取り描画の矩形を取得
  #--------------------------------------------------------------------------
  def draw_text_f_rect(r, str, align = 0, color = Color.new(64,32,128))
    draw_text_f(r.x, r.y, r.width, r.height, str, align = 0, color)
  end
end[/pre]



本體


[pre lang="ruby" line="1"]#===========================================================================
# ◆ A1 Scripts ◆
#    吹き出しメッセージ(RGSS3)
#
# バージョン   : 1.00 (2012/01/12)
# 作者         : A1
# URL     : http://a1tktk.web.fc2.com/
#---------------------------------------------------------------------------
# 機能:
# ・吹き出しメッセージを表示します
#---------------------------------------------------------------------------
# 更新履歴   :2012/01/12 Ver1.00 リリース
#---------------------------------------------------------------------------
# 設置場所      
#    A1共通スクリプト以下
#    (ネームウィンドウ以下)
#
# 必要スクリプト
#    A1共通スクリプトVer4.00以上
#
# 必要ファイル
#    Window_Popup.png  ※ Graphics/System にインポート
#---------------------------------------------------------------------------
# 使い方
#   ■ 設定項目 に設定
#
#   イベントコマンド「注釈」に記述
#
#     並列吹き出し
#
#       指定後1回のの文章を並列吹き出しとして表示します
#       並列吹き出しは、吹き出し表示中でもプレイヤーの移動や
#       イベントコマンドの実行・続行が可能です
#
#       また、他の吹き出しと同時に閉じることがなくなります
#
#     イベント吹き出し event_id
#
#       イベントを直接指定して吹き出しを表示します
#
#     吹き出しクローズ key
#
#       指定した吹き出しを閉じます
#       設定項目で設定した [歩行グラフィック名]_[歩行グラフィックIndex] を
#       key に指定します
#
#       例:吹き出しクローズ Actor4_0
#
#     吹き出しクローズ [イベント,event_id]
#
#       イベント吹き出しで表示した吹き出しを閉じます
#
#       例:吹き出しクローズ [イベント,5]
#
#           ※先に「イベント吹き出し」でevent_id 5 のイベントに
#             吹き出しを表示させているものとします
#
#     吹き出し使用 on|off
#
#       吹き出しの使用を切り替えます
#       on で吹き出し使用、off で吹き出し使用しなくなります
#
#
#   メッセージウィンドウコマンド
#
#     \CC[count] :クローズカウントを設定します(フレーム数)
#                  設定項目のデフォルト値より優先されます
#
#     \KP        :吹き出しのヒレが「考え中」になります
#
#     \PR        :並列吹き出し状態として表示した吹き出しの
#                  並列吹き出し状態をメッセージ終了後に解除します
#
#                  解除された場合、他の吹き出しと同時に閉じるようになります
#==============================================================================
$imported ||= {}
$imported["A1_PopupMassage"] = true
if $imported["A1_Common_Script"]
old_common_script("吹き出しメッセージ", "4.00") if common_version < 4.00
#==============================================================================
# ■ 設定項目
#==============================================================================
module A1_System::CnildMassageWindowConfig
  #--------------------------------------------------------------------------
  # 顔グラフィックと歩行グラフィックの対応
  #
  #  "[顔グラフィック名]_[Index]" => "[歩行グラフィック名]_[Index]" ※Index毎に設定
  #  "[顔グラフィック名]"         => "[歩行グラフィック名]_[Index]" ※該当顔グラフィック全てに適用
  #
  #  歩行グラフィックは配列で複数指定することが可能です
  #--------------------------------------------------------------------------
  LINK_FACE       = {
   # 顔グラフィック => 歩行グラフィック
    "Actor4_0"      => "Actor4_0",
    "Actor4_4"      => "Actor4_4",
    "Actor4_5"      => "Actor4_5",
  }
  #--------------------------------------------------------------------------
  # 文字入力待ちでないウィンドウが閉じるまでの時間(フレーム)のデフォルト値
  #   -1 にすると手動で閉じるかイベント終了まで閉じません
  #   -1 にすると「並列吹き出し」にしたウィンドウは手動で閉じるまでずっと閉じません
  #--------------------------------------------------------------------------
  DEFAULT_CLOSE_COUNT = -1
  #--------------------------------------------------------------------------
  # 吹き出しメッセージ使用のデフォルト値
  #--------------------------------------------------------------------------
  DEFAULT_ENABLE_POPUP = true
end
#==============================================================================
# ■ Cache
#------------------------------------------------------------------------------
#  各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
# です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
# のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
# を返すようになっています。
#==============================================================================

module Cache
  #--------------------------------------------------------------------------
  # ○ 顔グラフィックの取得
  #--------------------------------------------------------------------------
  def self.half_face(filename)
    load_file_name = "Graphics/Faces/#{filename}"
    key            = "#{load_file_name}_halfface"
    load_resize_bitmap(load_file_name, key, [-0.5, -0.5])
  end
end
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
#  文章表示に使うメッセージウィンドウです。
#==============================================================================

class Window_Message < Window_Base
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  LINK_FACE = A1_System::CnildMassageWindowConfig::LINK_FACE
  #--------------------------------------------------------------------------
  # ○ 子メッセージウィンドウのキーを取得
  #--------------------------------------------------------------------------
  def child_key
    return event_id_key if $game_temp.event_popup_id
    key = LINK_FACE["#{$game_message.face_name}_#{$game_message.face_index}"]
    key = LINK_FACE["#{$game_message.face_name}"] unless key
    return key
  end
  #--------------------------------------------------------------------------
  # ○ イベントIDからキーを設定
  #--------------------------------------------------------------------------
  def event_id_key
    key = "event_id_key_#{$game_temp.event_popup_id}"
    $game_temp.event_popup_id = nil
    return key
  end
  #--------------------------------------------------------------------------
  # ☆ 全ウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_child_message_window_wm_create_all_windows create_all_windows
  def create_all_windows
    a1_child_message_window_wm_create_all_windows
    @child_message_window = {}
  end
  #--------------------------------------------------------------------------
  # ☆ 全ウィンドウの解放
  #--------------------------------------------------------------------------
  alias a1_child_message_window_wm_dispose_all_windows dispose_all_windows
  def dispose_all_windows
    a1_child_message_window_wm_dispose_all_windows
    @child_message_window.values.each {|window| window.dispose }
  end
  #--------------------------------------------------------------------------
  # ☆ 全ウィンドウの更新
  #--------------------------------------------------------------------------
  alias a1_child_message_window_wm_update_all_windows update_all_windows
  def update_all_windows
    a1_child_message_window_wm_update_all_windows
    @child_message_window.values.each {|window| window.update }
    close_window = $game_message.close_message
    @child_message_window[close_window].close if close_window && @child_message_window[close_window]
    $game_message.close_message = nil
  end
  #--------------------------------------------------------------------------
  # ☆ 全テキストの処理
  #--------------------------------------------------------------------------
  alias a1_child_message_window_wm_process_all_text process_all_text
  def process_all_text
    @use_child = false
    return a1_child_message_window_wm_process_all_text unless need_setup?
    @child_key = child_key
    return if setup_child_message if @child_key && !@child_key.empty?
    a1_child_message_window_wm_process_all_text
  end
  #--------------------------------------------------------------------------
  # ○ 子メッセージウィンドウのセットアップが必要?
  #--------------------------------------------------------------------------
  def need_setup?
    return false if $game_party.in_battle
    return false if @my_child_window
    return $game_system.enable_child_msg
  end
  #--------------------------------------------------------------------------
  # ○ 子メッセージウィンドウのセットアップ
  #--------------------------------------------------------------------------
  def setup_child_message
    @child_message_window[@child_key] ||= create_child_message
    return false unless @child_message_window[@child_key].link_event
    close
    process_child_message_window(@child_message_window[@child_key])
    return true
  end
  #--------------------------------------------------------------------------
  # ○ 子メッセージウィンドウの作成
  #--------------------------------------------------------------------------
  def create_child_message
    window = Window_ChildMessage.new
    return set_link_event_id(window, $1.to_i) if @child_key =~ /event_id_key_(\d+)/
    return window if link_player(window)
    $game_map.events.values.each {|event| break if link_event(event, window) }
    return window
  end
  #--------------------------------------------------------------------------
  # ○ リンクするプレイヤーの取得
  #--------------------------------------------------------------------------
  def link_player(window)
    return true if link_event($game_player, window)
    $game_player.followers.each {|follower| return true if link_event(follower, window) }
    return false
  end
  #--------------------------------------------------------------------------
  # ○ リンクするイベントの取得
  #--------------------------------------------------------------------------
  def link_event(event, window)
    return false unless search_link_event(event.character_name, event.character_index)
    set_link_event(window, event)
    return true
  end
  #--------------------------------------------------------------------------
  # ○ リンクするイベントの検索
  #--------------------------------------------------------------------------
  def search_link_event(name, index)
    return "#{name}_#{index}" == @child_key unless @child_key.is_a?(Array)
    @child_key.each {|key| return true if "#{name}_#{index}" == key }
    return false
  end
  #--------------------------------------------------------------------------
  # ○ リンクするイベントの設定(ID)
  #--------------------------------------------------------------------------
  def set_link_event_id(window, event_id)
    window.link_event = $game_map.events[event_id]
    return window
  end
  #--------------------------------------------------------------------------
  # ○ リンクするイベントの設定
  #--------------------------------------------------------------------------
  def set_link_event(window, event)
    window.link_event = event
  end
  #--------------------------------------------------------------------------
  # ○ 子メッセージウィンドウの処理
  #--------------------------------------------------------------------------
  def process_child_message_window(window)
    @child_window = window
    window.position     = $game_message.position
    text                = convert_escape_characters($game_message.all_text)
    text_width          = $a1_common.text_width(window.contents.font, text)
    $game_message.texts = text.split("\n")
    window.set_face_info($game_message.face_name, $game_message.face_index)
    window.set_width(window.new_line_x + text_width + standard_padding * 2)
    window.background   = $game_message.background
    window.create_contents
    setup_priority(window)
    window.process_all_text
    @use_child = true
  end
  #--------------------------------------------------------------------------
  # ○ 子メッセージウィンドウの表示優先度の設定
  #--------------------------------------------------------------------------
  def setup_priority(now_window)
    @priority_order ||= []
    @priority_order.delete(@child_key)
    @priority_order.insert(0, @child_key)
    @priority_order.each_with_index {|key, i | @child_message_window[key].priority = @priority_order.size - i }
  end
  #--------------------------------------------------------------------------
  # ○ クローズカウントのセット
  #--------------------------------------------------------------------------
  def set_close_count(value)
    @child_window.close_count = value
    return ""
  end
  #--------------------------------------------------------------------------
  # ○ ポップアップ種別のセット
  #--------------------------------------------------------------------------
  def set_popup_kind
    @child_window.popup_kind = 1
    return ""
  end
  #--------------------------------------------------------------------------
  # ☆ 入力待ち処理
  #--------------------------------------------------------------------------
  alias a1_child_message_window_wm_input_pause input_pause
  def input_pause
    return if @use_child
    a1_child_message_window_wm_input_pause
  end
  #--------------------------------------------------------------------------
  # ☆ ウィンドウを閉じ、完全に閉じるまで待つ
  #--------------------------------------------------------------------------
  alias a1_child_message_window_wm_close_and_wait close_and_wait
  def close_and_wait
    @child_message_window.values.each {|window| window.close if window.input_wait }
    a1_child_message_window_wm_close_and_wait
    @priority_order = []
  end
  #--------------------------------------------------------------------------
  # ☆ 全ウィンドウが完全に閉じているか判定
  #--------------------------------------------------------------------------
  alias a1_child_message_window_wm_all_close? all_close?
  def all_close?
    return false unless a1_child_message_window_wm_all_close?
    @child_message_window.values.each {|window| return false unless window.close? if window.input_wait }
    return true
  end
  #--------------------------------------------------------------------------
  # ☆ 背景と位置の変更判定
  #--------------------------------------------------------------------------
  alias a1_child_message_window_wm_settings_changed? settings_changed?
  def settings_changed?
    return false if $game_system.enable_child_msg
    a1_child_message_window_wm_settings_changed?
  end
  #--------------------------------------------------------------------------
  # ○ 吹き出しの初期化
  #--------------------------------------------------------------------------
  def init_popup_message
    @child_message_window.values.each {|window| window.dispose }
    @child_message_window = {}
  end
end
#==============================================================================
# ■ Window_ChildMessage
#==============================================================================

class Window_ChildMessage < Window_Message
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  CLOSE_COUNT      = A1_System::CnildMassageWindowConfig::DEFAULT_CLOSE_COUNT
  POS_UP           = 0
  POS_MIDDLE       = 1
  POS_DOWN         = 2
  POPUP_RECT       = { POS_UP     => [Rect.new( 0,  0, 32, 64), Rect.new( 0, 64, 32, 64)],
                       POS_MIDDLE => [Rect.new( 0,  0, 32, 64), Rect.new( 0, 64, 32, 64)],
                       POS_DOWN   => [Rect.new(32,  0, 32, 64), Rect.new(32, 64, 32, 64)],
                     }
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @my_child_window = true
    @screen_width = Graphics.width
    super
    create_popup
  end
  #--------------------------------------------------------------------------
  # ○ 表示優先度の設定
  #--------------------------------------------------------------------------
  def priority=(value)
    self.z = 200 + value
    @popup_sprite.z = 200 + value
  end
  #--------------------------------------------------------------------------
  # ○ 吹き出しスプライトの作成
  #--------------------------------------------------------------------------
  def create_popup
    @popup_sprite = Sprite.new
    @popup_sprite.visible = false
    @popup_bitmap = Cache.system("Window_Popup")
    bitmap = Bitmap.new(32, 64)
    @popup_sprite.bitmap = bitmap
    @input_wait = true
  end
  #--------------------------------------------------------------------------
  # ○ 顔グラフィックの情報を設定
  #--------------------------------------------------------------------------
  def set_face_info(name, index)
    @face_name  = name
    @face_index = index
    @name_window_key = show_name(@face_name, @face_index) if $imported["A1_Name_Window"]
  end
  #--------------------------------------------------------------------------
  # ○ リンクするイベントの取得
  #--------------------------------------------------------------------------
  def link_event
    @event
  end
  #--------------------------------------------------------------------------
  # ○ リンクするイベントの設定
  #--------------------------------------------------------------------------
  def link_event=(event)
    @event = event
  end
  #--------------------------------------------------------------------------
  # ○ 表示位置の設定
  #--------------------------------------------------------------------------
  def position=(pos)
    @position = pos
    @position = 0 if @position == 1
    set_popup_bitmap(0)
  end
  #--------------------------------------------------------------------------
  # ○ 背景の設定
  #--------------------------------------------------------------------------
  def background=(type)
    @background = type
    self.opacity = @background == 0 ? 255 : 0
    setup_back_ground if @background == 1
    @back_sprite.visible = false if @back_sprite && @background != 1
  end
  #--------------------------------------------------------------------------
  # ○ 背景のセットアップ
  #--------------------------------------------------------------------------
  def setup_back_ground
    @back_bitmap.dispose if @back_bitmap
    create_back_bitmap_ex
    @back_sprite = Sprite.new unless @back_sprite
    setup_back_sprite
  end
  #--------------------------------------------------------------------------
  # ○ 背景のビットマップ作成
  #--------------------------------------------------------------------------
  def create_back_bitmap_ex
    @back_bitmap = Bitmap.new(width, height)
    rect1 = Rect.new(0, 0, width, 12)
    rect2 = Rect.new(0, 12, width, height - 24)
    rect3 = Rect.new(0, height - 12, width, 12)
    @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
    @back_bitmap.fill_rect(rect2, back_color1)
    @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
  end
  #--------------------------------------------------------------------------
  # ○ 背景のスプライトの作成
  #--------------------------------------------------------------------------
  def setup_back_sprite
    @back_sprite.bitmap = @back_bitmap
    @back_sprite.z = z - 1
    @back_sprite.visible = false
  end
  #--------------------------------------------------------------------------
  # ○ 背景ビットマップの解放
  #--------------------------------------------------------------------------
  def dispose_back_bitmap
    super if @back_bitmap
  end
  #--------------------------------------------------------------------------
  # ○ 背景スプライトの解放
  #--------------------------------------------------------------------------
  def dispose_back_sprite
    super if @back_sprite
  end
  #--------------------------------------------------------------------------
  # ○ 背景スプライトの更新
  #--------------------------------------------------------------------------
  def update_back_sprite
    return unless @back_sprite && @background == 1
    @back_sprite.x = self.x
    @back_sprite.y = self.y
    @back_sprite.visible = true
    @back_sprite.opacity = openness
    @back_sprite.update
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ背景の更新
  #--------------------------------------------------------------------------
  def update_background
    self.opacity = @background == 0 ? 255 : 0
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    return unless @event
    update_pos
    super
    update_close_count
    update_background
  end
  #--------------------------------------------------------------------------
  # ○ クローズカウントの更新
  #--------------------------------------------------------------------------
  def update_close_count
    return unless @close_count
    return if @close_count < 0
    @close_count -= 1
    auto_close if @close_count == 0
  end
  #--------------------------------------------------------------------------
  # ○ ポップアップスプライト位置の設定
  #--------------------------------------------------------------------------
  def set_popup_pos
    @popup_sprite.x = @event.screen_x
    @popup_sprite.y = self.y + popup_pos_y
    @popup_sprite.visible = open? && @background == 0
  end
  #--------------------------------------------------------------------------
  # ○ ポップアップビットマップの設定
  #--------------------------------------------------------------------------
  def set_popup_bitmap(kind)
    @popup_sprite.bitmap.clear
    @popup_sprite.bitmap.blt(0, 0, @popup_bitmap, POPUP_RECT[@position][kind])
  end
  #--------------------------------------------------------------------------
  # ○ ポップアップ種別の設定
  #--------------------------------------------------------------------------
  def popup_kind=(kind)
    set_popup_bitmap(1)
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ位置の更新
  #--------------------------------------------------------------------------
  def update_pos
    self.x = @event.screen_x + @pos_x
    self.y = @event.screen_y + pos_y
    set_popup_pos
    set_name_window_pos if $imported["A1_Name_Window"]
  end
  #--------------------------------------------------------------------------
  # ○ ネームウィンドウの位置設定
  #--------------------------------------------------------------------------
  def set_name_window_pos
    return unless @name_windows[@name_window_key]
    @name_windows[@name_window_key].x = self.x + 24
    @name_windows[@name_window_key].y = name_window_y
    @name_windows[@name_window_key].z = self.z
    @name_windows[@name_window_key].set_name_sprite_pos
  end
  #--------------------------------------------------------------------------
  # ○ ネームウィンドウのy座標設定
  #--------------------------------------------------------------------------
  def name_window_y
    return self.y + self.height - 12 if @position == 2
    self.y - 16
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウx座標の取得
  #--------------------------------------------------------------------------
  def set_pos_x
    base = @event.screen_x - 64
    return @pos_x = (@screen_width - self.width) - (base + 64) if base + self.width > @screen_width
    @pos_x = -64
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウy座標の取得
  #--------------------------------------------------------------------------
  def pos_y
    return -116 if @position == 0
    return  16 if @position == 2
  end
  #--------------------------------------------------------------------------
  # ○ ポップアップy座標の取得
  #--------------------------------------------------------------------------
  def popup_pos_y
    return self.height - 32 if @position == 0
    return -32 if @position == 2
  end
  #--------------------------------------------------------------------------
  # ○ 自動で閉じる
  #--------------------------------------------------------------------------
  def auto_close
    close
    @close_count = nil
  end
  #--------------------------------------------------------------------------
  # ○ 解放
  #--------------------------------------------------------------------------
  def dispose
    @popup_sprite.bitmap.dispose
    @popup_sprite.dispose
    super
  end
  #--------------------------------------------------------------------------
  # ○ 制御文字の事前変換
  #--------------------------------------------------------------------------
  def convert_escape_characters(text)
    text
  end
  #--------------------------------------------------------------------------
  # ○ 背景ビットマップの作成
  #--------------------------------------------------------------------------
  def create_back_bitmap
  end
  #--------------------------------------------------------------------------
  # ○ 背景スプライトの作成
  #--------------------------------------------------------------------------
  def create_back_sprite
  end
  #--------------------------------------------------------------------------
  # ○ 全ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_all_windows
  end
  #--------------------------------------------------------------------------
  # ○ 全ウィンドウの解放
  #--------------------------------------------------------------------------
  def dispose_all_windows
  end
  #--------------------------------------------------------------------------
  # ○ 全ウィンドウの更新
  #--------------------------------------------------------------------------
  def update_all_windows
  end
  #--------------------------------------------------------------------------
  # ○ 全ウィンドウが完全に閉じているか判定
  #--------------------------------------------------------------------------
  def all_close?
    close?
  end
  #--------------------------------------------------------------------------
  # ○ ファイバーの更新
  #--------------------------------------------------------------------------
  def update_fiber
  end
  #--------------------------------------------------------------------------
  # ○ 入力処理
  #--------------------------------------------------------------------------
  def process_input
    input_pause unless @pause_skip
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width
    return self.width unless self.disposed?
    Graphics.width
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ高さの取得
  #--------------------------------------------------------------------------
  def window_height
    fitting_height(visible_line_number)
  end
  #--------------------------------------------------------------------------
  # ○ 表示行数の取得
  #--------------------------------------------------------------------------
  def visible_line_number
    return 2
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ幅の設定
  #--------------------------------------------------------------------------
  def set_width(width)
    self.width         = width
  end
  #--------------------------------------------------------------------------
  # ○ テキストの設定
  #--------------------------------------------------------------------------
  def text=(text)
    @text = text
  end
  #--------------------------------------------------------------------------
  # ○ 全テキストの処理
  #--------------------------------------------------------------------------
  def process_all_text
    @input_wait = $game_temp.input_wait
    $game_temp.input_wait = true
    set_pos_x
    super
    @init_close_count = CLOSE_COUNT unless @init_close_count
    input_pause
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウを開き、完全に開くまで待つ
  #--------------------------------------------------------------------------
  def open_and_wait
    open
    Fiber.yield until open? if @input_wait
  end
  #--------------------------------------------------------------------------
  # ○ 入力待ち取得
  #--------------------------------------------------------------------------
  def input_wait
    @input_wait
  end
  #--------------------------------------------------------------------------
  # ○ 入力待ち取得
  #--------------------------------------------------------------------------
  def input_wait
    @input_wait
  end
  #--------------------------------------------------------------------------
  # ○ 入力待ち処理
  #--------------------------------------------------------------------------
  def input_pause
    reset_close_count
    super if @input_wait
    @input_wait = true if @parallel_release
    @parallel_release = false
    start_close_count
  end
  #--------------------------------------------------------------------------
  # ○ クローズカウントの開始
  #--------------------------------------------------------------------------
  def start_close_count
    @close_count = @init_close_count
    @init_close_count = nil
  end
  #--------------------------------------------------------------------------
  # ○ クローズカウントの設定
  #--------------------------------------------------------------------------
  def close_count=(count)
    @init_close_count = count
  end
  #--------------------------------------------------------------------------
  # ○ クローズカウントのリセット
  #--------------------------------------------------------------------------
  def reset_close_count
    @close_count      = nil
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウを閉じる
  #--------------------------------------------------------------------------
  def close
    reset_close_count
    super
  end
  #--------------------------------------------------------------------------
  # ○ 改行位置の取得
  #--------------------------------------------------------------------------
  def new_line_x
    $game_message.face_name.empty? ? 0 : 56
  end
  #--------------------------------------------------------------------------
  # ○ 制御文字の処理
  #     code : 制御文字の本体部分(「\C[1]」なら「C」)
  #     text : 描画処理中の文字列バッファ(必要なら破壊的に変更)
  #     pos  : 描画位置 {:x, :y, :new_x, :height}
  #--------------------------------------------------------------------------
  def process_escape_character(code, text, pos)
    case code.upcase
    when 'PR'
      @parallel_release = true
    else
      super
    end
  end
  #--------------------------------------------------------------------------
  # ○ ネームウィンドウの表示
  #--------------------------------------------------------------------------
  def show_name_window(face_name, face_index, x, size = 96)
    super
    set_name_window_pos
  end
end
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  ゲーム中の全てのウィンドウのスーパークラスです。
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ☆ 顔グラフィックの描画
  #     enabled : 有効フラグ。false のとき半透明で描画
  #--------------------------------------------------------------------------
  alias a1_child_message_window_wb_draw_face draw_face
  def draw_face(face_name, face_index, x, y, size = 96)
    return draw_face_half(face_name, face_index, x, y, size) if @my_child_window
    a1_child_message_window_wb_draw_face(face_name, face_index, x, y, size)
  end
  #--------------------------------------------------------------------------
  # ○ 顔グラフィックの描画(ハーフサイズ)
  #     enabled : 有効フラグ。false のとき半透明で描画
  #--------------------------------------------------------------------------
  def draw_face_half(face_name, face_index, x, y, enabled = true)
    draw_half_face(face_name, face_index, x, y, enabled) unless face_name.empty?
    show_name_window(face_name, face_index, x, 48) if $imported["A1_Name_Window"]
  end
  #--------------------------------------------------------------------------
  # ○ 顔グラフィックの描画(ハーフサイズ)
  #--------------------------------------------------------------------------
  def draw_half_face(face_name, face_index, x, y, enabled)
    bitmap = Cache.half_face(face_name)
    rect = Rect.new(face_index % 4 * 48, face_index / 4 * 48, 48, 48)
    contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  end
  #--------------------------------------------------------------------------
  # ☆ 制御文字の事前変換
  #    実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
  #    文字「\」はエスケープ文字(\e)に変換。
  #--------------------------------------------------------------------------
  alias a1_child_message_window_wb_convert_escape_characters convert_escape_characters
  def convert_escape_characters(text)
    result = a1_child_message_window_wb_convert_escape_characters(text)
    result.gsub!(/\eCC\[(\d+)\]/i)          { set_close_count($1.to_i) }
    result.gsub!(/\eKP/i)                   { set_popup_kind }
    result
  end
end
#==============================================================================
# ■ Game_Message
#------------------------------------------------------------------------------
#  文章や選択肢などを表示するメッセージウィンドウの状態を扱うクラスです。この
# クラスのインスタンスは $game_message で参照されます。
#==============================================================================

class Game_Message
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :close_message
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_child_message_window_gm_initialize initialize
  def initialize
    a1_child_message_window_gm_initialize
    @input_wait    = true
    @close_message = nil
  end
  #--------------------------------------------------------------------------
  # ○ 表示するテキストの設定
  #--------------------------------------------------------------------------
  def texts=(text)
    @texts = text
  end
end
#==============================================================================
# ■ Game_Temp
#------------------------------------------------------------------------------
#  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン
# スタンスは $game_temp で参照されます。
#==============================================================================

class Game_Temp
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :input_wait
  attr_accessor :event_popup_id
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_child_message_gt_initialize initialize
  def initialize
    a1_child_message_gt_initialize
    @input_wait     = true
    @event_popup_id = nil
  end
end
#==============================================================================
# ■ Game_System
#------------------------------------------------------------------------------
#  システム周りのデータを扱うクラスです。セーブやメニューの禁止状態などを保存
# します。このクラスのインスタンスは $game_system で参照されます。
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :enable_child_msg
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_child_message_gs_initialize initialize
  def initialize
    a1_child_message_gs_initialize
    @enable_child_msg = A1_System::CnildMassageWindowConfig::DEFAULT_ENABLE_POPUP
  end
end
#==============================================================================
# ■ A1_System::CommonModule
#==============================================================================

class A1_System::CommonModule
  #--------------------------------------------------------------------------
  # ☆ 注釈コマンド定義
  #--------------------------------------------------------------------------
  alias a1_child_message_define_command define_command
  def define_command
    a1_child_message_define_command
    @cmd_108["並列吹き出し"]     = :sub_message
    @cmd_108["吹き出しクローズ"] = :close_popup
    @cmd_108["吹き出し使用"]     = :use_popup_message
    @cmd_108["イベント吹き出し"] = :event_popup_message
  end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ○ 並列吹き出し
  #--------------------------------------------------------------------------
  def sub_message(params)
    $game_temp.input_wait = false
  end
  #--------------------------------------------------------------------------
  # ○ 吹き出しクローズ
  #--------------------------------------------------------------------------
  def close_popup(params)
    return close_popup_id(params[0]) if params[0].is_a?(Array)
    $game_message.close_message = params[0]
  end
  #--------------------------------------------------------------------------
  # ○ 吹き出しクローズ(ID)
  #--------------------------------------------------------------------------
  def close_popup_id(params)
    $game_message.close_message = "event_id_key_#{params[1].to_i}" if params[0] == "イベント"
  end
  #--------------------------------------------------------------------------
  # ○ 吹き出し使用
  #--------------------------------------------------------------------------
  def use_popup_message(params)
    $game_system.enable_child_msg = params[0] == "on" ? true : false
  end
  #--------------------------------------------------------------------------
  # ○ イベント吹き出し
  #--------------------------------------------------------------------------
  def event_popup_message(params)
    $game_temp.event_popup_id = params[0].to_i
  end
end
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  マップ画面の処理を行うクラスです。
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # ☆ 場所移動の処理
  #--------------------------------------------------------------------------
  alias a1_child_message_sm_perform_transfer perform_transfer
  def perform_transfer
    prev_map = $game_map.map_id
    a1_child_message_sm_perform_transfer
    @message_window.init_popup_message if prev_map != $game_map.map_id
  end
end
#==============================================================================
# ■ ネームウィンドウインポート時処理
#==============================================================================
if $imported["A1_Name_Window"]
#==============================================================================
# ■ Window_FaceName
#==============================================================================

class Window_FaceName < Window_Base
  #--------------------------------------------------------------------------
  # ○ ネームスプライトの位置設定
  #--------------------------------------------------------------------------
  def set_name_sprite_pos
    @name_sprite.x = self.x + self.width / 2
    @name_sprite.y = self.y + self.height / 2
  end
end;end
end[/pre]


Window_Popup.png


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

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

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


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

麻煩 會的幫幫忙囉
回复

使用道具 举报

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

麻煩 會的幫幫忙囉
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部