#◆◇◆◇◆ テロップスクリプトVX ver 1・02 ◇◆◇◆◇ # サポート掲示板 http://www2.ezbbs.net/21/minto-aaa/ # by みんと =begin 更新履歴 ver 1.02(2008/06/29) 制御文字を増設。 \\pa 文字の瞬間表示に対応。 ver 1.01(2008/06/29) 制御文字を増設。 \\en 説明 マップ画面、戦闘画面にて、 一文字ずつ表示されるテロップを描写します。 各制御文字にも対応しています。 また、テロップが終了するまで以降のイベントを待たせますので、 その都度ウェイトタイムを設定する必要はありません。 対応制御文字 ※ n は 1 や 2 などの任意の「半角数値」です。 \\S[n] 改行を実行します。 数値を設定した場合、その数値フレーム分改行を待ち、 24ピクセル文章全体を上にスクロールさせます。 0 なら即改行でスクロールも実行しません。 \\C[n] n に該当するIDの文字色に変更します。 文字色は、ソース内部で設定してください。 \\N[n] 指定したIDのアクターの名前に変換します。 \\V[n] 指定したIDの変数の値に変換します。 \\AL[n] その行のアライメント(文章の整列)を変更します。 1で中央寄せ、2で右寄せ、未記入で左寄せです。 \\FO["フォント名"] 以降の文章のフォントを指定したフォントに変更します。 \\TY[n] 以降の文字の描写タイプを変更します。 0 で通常通り、1 で影文字に、2 で縁文字に変更します。 \\B[0 か 1] 以降の文字をボールド(太文字)に変更します。 \\B[0] でオフ \\B[1] でオンになります。 \\I[0 か 1] 以降の文字をイタリック(斜体文字)に変更します。 \\I[0] でオフ \\I[1] でオンになります。 \\SI[n] 以降の文字のサイズを指定したサイズに変更します。 基本値は20で上限は22です。 \\W[n] 指定した数値フレーム分、以降の処理を待ちます。 \\SP[n] 文字の速度を変更します。 基準は 4 で最速値は 0 です。 なお、小数点は無効です。 高い値ほど遅くなります。 0なら瞬間表示です。 \\BW Cボタンを入力するまで文章の終了を待ちます。 原則として「文章の最後」に設定してください。 \\EN 制御文字を置いた位置でテロップ表示中フラグを解除し、 ほかのイベントなどを実行します。 テロップの処理自体は引き続き行われます。 \\PA 制御文字を置いたタイミングでテロップの更新を一時中断します。 この間、イベントの硬直は解除されます。 異なるテロップを表示するか、 イベントのスクリプトで $scene.map_telop_pause = false と記入すれば、ポーズは解除され、テロップが再開されます。 \\enを実行していない場合はイベントの硬直も再開されます。 =end #============================================================================== # ☆ MINTO #------------------------------------------------------------------------------ # 様々なフラグを扱うメインモジュールです。 #============================================================================== module MINTO # テロップスクリプトを有効化 ( true で有効 / false で無効 ) RGSS["Telop_Script"] = true end if MINTO::RGSS["Telop_Script"] == true then #============================================================================== # ☆ カスタマイズ #------------------------------------------------------------------------------ # 機能のカスタマイズをここで行います。 #============================================================================== class Map_Telop #-------------------------------------------------------------------------- # ● テロップメッセージの取得 # title : テロップのタイトル名 # ex : イベントのスクリプトで # $scene.map_telop.set_telop("フィクションです") # などと入力した場合、タイトルに合ったテロップが実行されます。 # 戦闘中でも、便利上 $scene.map_telop.set_telop です。 #-------------------------------------------------------------------------- def set_telop(title) # タイトルから \n を除外 title.gsub!(/\n/) { "" } # テロップタイトルに応じて分岐 case title when "フィクションです" then text = "\\fo[MS P明朝]\\sp[2]\\ty[1]\\si[28]" + "\\al[1]このゲームは\\c[1]フィクション\\c[0]です\\s[0]" + "\\al[1]このゲームに登場する\\s[0]" + "\\al[1]あらゆるものは、\\s[0]" + "\\al[1]架空のものであり、\\s[0]" + "\\al[1]実在の物とは関係ありません\\s[0]" + "\\s[0]" + "\\al[1]万一、同名のものが実在し、\\s[0]" + "\\al[1]それらと混用し、\\s[0]" + "\\al[1]気分を催した場合においても、\\s[0]" + "\\al[1]当方ではその一切の責任を負いかねます\\bw" when "テスト" then text = "変数1(\\v[1])左寄せです\\fo[MS P明朝]MS P明朝です\\s[0]" + "\\sp[0]\\al[1]\\fo[MS ゴシック]中央寄せです\\s[0]" + "\\al[2]\\fo[MS ゴシック]右寄せです\\s[0]" + "\\c[1]色を変えます\\c[0]\\s[0]\\pa" + "\\ty[1]影文字です\\ty[2]縁文字です\\ty[0]\\i[1]\\s[0]" + "イタリックです\\i[0]\\b[1]ボールドです\\i[1]\\s[0]" + "イタリック&ボールドです\\i[0]\\b[0]\\s[0]" + "\\si[22]文字サイズを変更します\\n[1]\\bw" end # 実際にテロップを描写 set_text(text) end #-------------------------------------------------------------------------- # ● 文字色取得 # n : 文字色番号 (0〜7) #-------------------------------------------------------------------------- def text_color(n) case n when 0 then return normal_color when 1 then return system_color when 2 then return disabled_color when 3 then return Color.new(100, 200, 255) when 4 then return Color.new(255, 150, 0) when 5 then return Color.new(255, 0, 0) when 6 then return Color.new(150, 150, 255) when 7 then return Color.new(155, 155, 155) when 8 then return Color.new(255, 200, 0) end end #-------------------------------------------------------------------------- # ● 通常文字色の取得 #-------------------------------------------------------------------------- def normal_color return Color.new(255, 255, 255) end #-------------------------------------------------------------------------- # ● システム文字色の取得 #-------------------------------------------------------------------------- def system_color return Color.new(100, 255, 255) end #-------------------------------------------------------------------------- # ● 無効文字色の取得 #-------------------------------------------------------------------------- def disabled_color return Color.new(200, 200, 200) end end #============================================================================== # ☆ MINTO_Scene #------------------------------------------------------------------------------ # 各シーンクラスを強化するモジュールです。 #============================================================================== module MINTO_Scene #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :telop_wait # テロップ表示中フラグ attr_accessor :map_telop_pause # テロップポーズ中フラグ attr_accessor :map_telop # テロップスプライト #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start # 継承先の処理に移行 super # テロップスプライトを作成 @map_telop = Map_Telop.new end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate # 継承先の処理に移行 super # テロップスプライトを解放 @map_telop.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # 継承先の処理に移行 super # テロップスプライトを更新 @map_telop.update end end #============================================================================== # ■ Map_Telop #------------------------------------------------------------------------------ # マップ上でのテロップを管理するスプライトです。 #============================================================================== class Map_Telop #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize # 画面の横幅を取得 width = Graphics.width # 画面の縦幅を取得 height = Graphics.height # ビューポートを作成 @view_port = Viewport.new(12, 12, width - 12, height - 24) @view_port.z = 65535 # スプライトを作成 @sprite = Sprite.new(@view_port) @sprite.visible = false @sprite.bitmap = Bitmap.new(24, 24) @sprite.bitmap.font.size = 20 # 基本的なデータを初期化 @message_duration = 0 @wait_count = 0 @scroll = [] @scroll_count = 0 @scroll_duration = 0 @save_text = "" @text = [] @text_y = 0 @text_x = 0 @text_type = 0 @text_index = 0 @text_width = [] @align = [] @speed = 4 end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose # スプライトを解放 @sprite.bitmap.dispose @sprite.dispose # ビューポートを解放 @view_port.dispose end #-------------------------------------------------------------------------- # ● 影文字描写 #-------------------------------------------------------------------------- def draw_shadow_text(x, y, width, height, text, ag = 0) # 元の色を保存 ori_color = @sprite.bitmap.font.color.clone # 影の色を定義 @sprite.bitmap.font.color.set(0, 0, 0) # 影文字を描写 @sprite.bitmap.draw_text(x+2, y+2, width, height, text, ag) # 元の色に戻す @sprite.bitmap.font.color = ori_color # 本体の文字を描写 @sprite.bitmap.draw_text(x, y, width, height, text, ag) end #-------------------------------------------------------------------------- # ● 縁文字描写 #-------------------------------------------------------------------------- def draw_frame_text(x, y, width, height, text, ag = 0) # 元の色を保存 ori_color = @sprite.bitmap.font.color.clone # 縁の色を定義 @sprite.bitmap.font.color.set(0, 0, 0) # 縁文字を描写 @sprite.bitmap.draw_text(x-1, y, width, height, text, ag) @sprite.bitmap.draw_text(x+1, y, width, height, text, ag) @sprite.bitmap.draw_text(x, y-1, width, height, text, ag) @sprite.bitmap.draw_text(x, y+1, width, height, text, ag) # 元の色に戻す @sprite.bitmap.font.color = ori_color # 本体の文字を描写 @sprite.bitmap.draw_text(x, y, width, height, text, ag) end #-------------------------------------------------------------------------- # ● テキスト設定 # text : スプライトに表示する文字列 #-------------------------------------------------------------------------- def set_text(text = "") # 求められたテキストが無効な場合 if text.to_s == "" then # メソッドを終了 return end # テロップ表示中フラグをオン $scene.telop_wait = true # ポーズをクリア $scene.map_telop_pause = false # スプライトを可視状態にする @sprite.visible = true # 各データを初期化 @scroll = [] @scroll_count = 0 @scroll_duration = 0 @save_text = "" @text = [] @text_width = [] @text_index = 0 @text_type = 0 @align = [] @view_port.rect.y = 0 @view_port.oy = 0 @sprite.opacity = 255 # 表示カウントを設定 @message_duration = 32 # 設定用のデータを定義 height_p = 1 max_height = 1 text_width = 0 max_width = 0 # テキストを再描画 @sprite.bitmap.clear @sprite.bitmap.font.size = 20 # 文字を複製 data = text.dup # 各制御文字を仮変換 data.gsub!(/\\\\/) { "\000" } data.gsub!(/\\[Cc]\[([0-9]+)\]/) { "" } data.gsub!(/\\[Ww]\[([0-9]+)\]/) { "" } data.gsub!(/\\[Ff][Oo]\[(.+?)\]/) { "" } data.gsub!(/\\[Nn]\[([0-9]+)\]/) { $game_actors[$1.to_i].name } data.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] } data.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\002[#{$1}]" } data.gsub!(/\\[Aa][Ll]\[([0-9]+)\]/) { "\004[#{$1}]" } data.gsub!(/\\[Ss][Ii]\[([0-9]+)\]/) { "\006[#{$1}]" } data.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\10[#{$1}]" } data.gsub!(/\\[Ii]\[([0-9]+)\]/) { "" } data.gsub!(/\\[Ss][Pp]\[([0-9]+)\]/) { "" } data.gsub!(/\\[Tt][Yy]\[([0-9]+)\]/) { "" } data.gsub!(/\\[Bb][Ww]/) { "" } data.gsub!(/\\[Ee][Nn]/) { "" } data.gsub!(/\\[Pp][Aa]/) { "" } # c に 1 文字を取得 (文字が取得できなくなるまでループ) while ((c = data.slice!(/./m)) != nil) do # \SI[n] の場合 if c == "\006" then # 制御文字を処理 data.sub!(/\[([0-9]+)\]/, "") # 文字サイズを変更 @sprite.bitmap.font.size = [[$1.to_i, 22].min, 1].max # 次の文字へ next end # \S[n] の場合 if c == "\002" then # 文字幅が最高値以上の場合 if text_width > max_width then # 文字幅を更新 max_width = text_width end # 文字幅を記憶 @text_width.push(text_width) # 文字幅を初期化 text_width = 0 data.sub!(/\[([0-9]+)\]/, "") # 描写の高さを増やす height_p += 1 # スクロールが設定されていない場合 if $1.to_i == 0 then # 高さの上限を増やす max_height += 1 end # 次の文字へ next end # \AL[n] の場合 if c == "\004" then # 制御文字を処理 data.sub!(/\[([0-9]+)\]/, "") # アライメントを設定 @align[height_p-1] = $1.to_i # 次の文字へ next end # \B[n] の場合 if c == "\010" then # 制御文字を処理 data.sub!(/\[([0-9]+)\]/, "") # 太文字に変更 @sprite.bitmap.font.bold = ($1.to_i == 1) # 次の文字へ next end # text_width に描画した文字の幅を加算 text_width += @sprite.bitmap.text_size(c).width end # 文字幅を記憶 @text_width.push(text_width) # 文字幅が最高値以上の場合 if text_width > max_width # 文字幅を更新 max_width = text_width end # ビットマップを再作成 @sprite.bitmap = Bitmap.new(Graphics.width, 24 * height_p) @sprite.y = -12 + (Graphics.height - @sprite.bitmap.height) / 2 refresh(text.dup) end #-------------------------------------------------------------------------- # ● リフレッシュ # text : スプライトに表示する文字列 #-------------------------------------------------------------------------- def refresh(text) # 基本情報を初期化 @sprite.bitmap.clear @sprite.bitmap.font.color = normal_color @sprite.bitmap.font.size = 20 @sprite.bitmap.font.bold = false @sprite.bitmap.font.italic = false @text_y = 0 # 初期アライメントに応じて分岐 case @align[0].to_i # 左寄せ(デフォルト) when 0 then @text_x = 0 # 中央寄せ when 1 then @text_x = ((Graphics.width - 12) - @text_width[0]) / 2 # 右寄せ when 2 then @text_x = (Graphics.width - 12) - @text_width[0] end # 文章のインデックスを初期化 @text_index = 0 # 表示待ちのメッセージがある場合 if text != "" then # 制御文字処理 begin last_text = text.clone end until text == last_text text.gsub!(/\\[Nn]\[([0-9]+)\]/) do $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : "" end # 便宜上、"\\\\" を "\000" に変換 text.gsub!(/\\\\/) { "\000" } # 各制御文字を実際のものに変換 text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" } text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\002[#{$1}]" } text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\003[#{$1}]" } text.gsub!(/\\[Aa][Ll]\[([0-9]+)\]/) { "" } text.gsub!(/\\[Ff][Oo]\[(.+?)\]/) { "\005[#{$1}]" } text.gsub!(/\\[Ss][Ii]\[([0-9]+)\]/) { "\006[#{$1}]" } text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\010[#{$1}]" } text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\016[#{$1}]" } text.gsub!(/\\[Bb][Ww]/) { "\017" } text.gsub!(/\\[Ss][Pp]\[([0-9]+)\]/) { "\020[#{$1}]" } text.gsub!(/\\[Tt][Yy]\[([0-9]+)\]/) { "\021[#{$1}]" } text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] } text.gsub!(/\\[Ee][Nn]/) { "\022" } text.gsub!(/\\[Pp][Aa]/) { "\023" } @save_text = text.dup end end #-------------------------------------------------------------------------- # ● テキストの更新 #-------------------------------------------------------------------------- def text_update @text = @save_text.split(//) # 無効な文字列の場合 if @text[@text_index] == nil then # メソッドを返す return false end # スプライトを可視状態にする @sprite.visible = true # テキストを取得 c = @text[@text_index] # \\ の場合 if c == "\000" then # 本来の文字に戻す c = "\\" end # \C[n] の場合 if c == "\001" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 文字色のIDを取得 color = $1.to_i # 文字色のIDが有効な場合 if color >= 0 then # 文字色を変更 @sprite.bitmap.font.color = text_color(color) end # インデックスを進める @text_index += 1 # メソッドを返す return true end # \S[n] の場合 if c == "\002" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # スクロールを予約 @scroll.push($1.to_i+1) # インデックスを進める @text_index += 1 # @text_y に 1 を加算 @text_y += 1 # 現在の行のアライメントに応じて分岐 case @align[@text_y].to_i # 左寄せ(デフォルト) when 0 then @text_x = 0 # 中央寄せ when 1 then @text_x = ((Graphics.width - 24) - @text_width[@text_y]) / 2 # 右寄せ when 2 then @text_x = (Graphics.width - 24) - @text_width[@text_y] end # メソッドを返す return true end # \W[n] の場合 if c == "\003" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # ウェイトカウントを設定 @wait_count = $1.to_i # インデックスを進める @text_index += 1 # メソッドを返す return true end # \FO[n] の場合 if c == "\005" then # 制御文字を処理 @save_text.sub!(/\[(.+?)\]/, "") # フォントを変更 @sprite.bitmap.font.name = $1.to_s # インデックスを進める @text_index += 1 # メソッドを返す return true end # \SI[n] の場合 if c == "\006" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 文字サイズを変更 @sprite.bitmap.font.size = [[$1.to_i, 22].min, 1].max # インデックスを進める @text_index += 1 # メソッドを返す return true end # \B[n] の場合 if c == "\010" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 太文字に変更 @sprite.bitmap.font.bold = ($1.to_i == 1) # インデックスを進める @text_index += 1 # メソッドを返す return true end # \I[n] の場合 if c == "\016" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 斜体文字に変更 @sprite.bitmap.font.italic = ($1.to_i == 1) # インデックスを進める @text_index += 1 # メソッドを返す return true end # \BW[n] の場合 if c == "\017" then # 制御文字を処理 # トランジション実行 Graphics.transition # ボタン待ちフラグをオン @press = true # インデックスを進める @text_index += 1 # メソッドを返す return true end # \SP[n] の場合 if c == "\020" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 表示速度を変更 @speed = $1.to_i # インデックスを進める @text_index += 1 # メソッドを返す return true end # \TY[n] の場合 if c == "\021" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 文字の描写タイプを変更 @text_type = $1.to_i # インデックスを進める @text_index += 1 # メソッドを返す return true end # \EN の場合 if c == "\022" then # テロップ表示中フラグをオフ $scene.telop_wait = false # インデックスを進める @text_index += 1 # メソッドを返す return true end # \PA の場合 if c == "\023" then # テロップポーズフラグをオン $scene.map_telop_pause = true # インデックスを進める @text_index += 1 # メソッドを返す return true end # 文字の描写タイプに応じて分岐 case @text_type # デフォルト when 0 then # 文字を描画 @sprite.bitmap.draw_text(@text_x, 24 * @text_y, 40, 24, c) # 影文字 when 1 then # 影文字を描画 draw_shadow_text(@text_x, 24 * @text_y, 40, 24, c) # 縁文字 when 2 then # 縁文字を描画 draw_frame_text(@text_x, 24 * @text_y, 40, 24, c) end # @text_x に描画した文字の幅を加算 @text_x += @sprite.bitmap.text_size(c).width # インデックスを進める @text_index += 1 return true end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ポーズ中の場合 if $scene.map_telop_pause == true then # メソッドを返す return end # ボタン入力待ちフラグがオンの場合 if @press == true then # C ボタンが押された場合 if Input.trigger?(Input::C) == true then # スピードを元に戻す @speed = 4 # 更新カウントを減らす @message_duration = 1 # ボタン入力待ちをオフ @press = false # 32フレーム繰り返す 32.times do # テロップの透明度を下げる @sprite.opacity -= 8 # 画面の情報を更新 Graphics.update end # テロップ表示中フラグをオフ $scene.telop_wait = false else # メソッドを返す return end end # ウェイトカウントが 1 以上の場合 if @wait_count >= 1 then # ウェイトカウントを減らす @wait_count -= 1 # メソッドを返す return end # スクロール中の場合 if @scroll_duration >= 1 then # 実際にスプライトをスクロールさせる @view_port.rect.y -= 2 # カウントを減らす @scroll_duration -= 1 # メソッドを返す return end # スクロールが有効な場合 if @scroll[0] != nil and @scroll_count == 0 then # スクロールカウントを有効にする @scroll_count = @scroll[0] # スクロールカウントを詰める @scroll[0] = nil @scroll.compact! end # スクロールの待ち時間がある場合 if @scroll_count >= 1 then # カウントを減らす @scroll_count -= 1 # 残りカウントが 1 の場合 if @scroll_count == 1 then # スクロールをはじめる @scroll_duration = 12 end # メソッドを返す return end # 更新が可能なフレームでない場合 if @speed != 0 and (Graphics.frame_count % @speed != 0) then # メソッドを返す return end # 文章を更新中の場合 if text_update == true then # スピードが 0 の場合 if @speed == 0 then # 文章を更新(ループ) update end # メソッドを返す return # 文章の更新が終了した場合 else # 文章の表示速度を初期化 @speed = 4 end # 更新カウントが設定してある場合 if @message_duration >= 1 then # 更新カウントを減らす @message_duration -= 1 # 透明度を調節する @sprite.opacity -= 32 # 更新カウントが丁度 0 になった場合 if @message_duration == 0 then # 文章の表示速度を初期化 @speed = 4 # ボタン入力待ちフラグをオフ @press = false # テロップ表示中フラグをオフ $scene.telop_wait = false # テロップを不可視にする @sprite.visible = false end end end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● フレーム更新 # alias : update_MINTO_Telop #-------------------------------------------------------------------------- alias :update_MINTO_Telop :update def update # テロップ表示中フラグがオンの場合 if $scene.map_telop_pause == false and $scene.telop_wait == true then # メソッドを返す return else # 元の処理を実行 update_MINTO_Telop end end #-------------------------------------------------------------------------- # ● スクリプト # alias : command_355_MINTO_Telop #-------------------------------------------------------------------------- alias :command_355_MINTO_Telop :command_355 def command_355 # スクリプトがテロップ表示の場合 if @list[@index].parameters[0].include?("map_telop") == true then # ウェイトカウントに1を加算 @wait_count += 1 end # 元の処理を実行 command_355_MINTO_Telop end end #============================================================================== # ■ Scene_Map #------------------------------------------------------------------------------ #  マップ画面の処理を行うクラスです。 #============================================================================== class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ● システムインクルード #-------------------------------------------------------------------------- include(MINTO_Scene) end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● システムインクルード #-------------------------------------------------------------------------- include(MINTO_Scene) end end