#◆◇◆◇◆ センターヘルプコメントVX ver 1.02 ◇◆◇◆◇ # サポート掲示板 http://www2.ezbbs.net/21/minto-aaa/ # by みんと =begin ■ 更新履歴 ○ ver 1.02(2009/06/29) 仕様が機能していなかったミスを修正。 ○ ver 1.01(2009/04/16) 制御文字と基本機能を改良。 説明 RPGによくある、マップ画面中央に出てくるコメントを表示させます。 制御文字対応です。 なるべく下の方にセクションを作成して、 本スクリプトを導入してください。 使用例 イベントコマンドの『スクリプト』で text = "○○を手に入れた!" $scene.centerhelp_window.set_text(text) で表示されます。 文字とウィンドウの位置は自動的にセンタリングされます。 ウィンドウの大きさも、文字の長さに合わせて調節されますが、 極端に長い文字の場合は、画面からはみ出してしまいます。 (16文字程度を目安にしてください) また、改行は半角のスペースで可能です。 (何行でも可能) また、$scene.centerhelp_window.set_text(text, true) とすることで、ヘルプを表示する際、 ウィンドウが下からフェードインするようになります。 対応制御文字 \\C[n] 文字の色を n に該当するカラーに変更します。 内容は Window_Base の text_color に依存します。 \\V[n] 変数 n に収納されている数値に変換します。 \\N[n] n に該当するアクター名に変換します。 \\W[n] n に該当する武器名に変換します。 アイコンも同時に描写します。 \\A[n] n に該当する防具名に変換します。 アイコンも同時に描写します。 \\I[n] n に該当するアイテム名に変換します。 アイコンも同時に描写します。 text = "\\c[3]\\i[1]\\c[0]を手に入れた!" ↑の様に、連続で使用することも可能です。 ※注意点 文章の表示と連続して使う場合(前後に文章の表示がある場合) デフォルトのスクリプトの都合上、 最低でも3フレームのウェイトを置かないと、 空のメッセージウィンドウが表示されてしまいます。 =end #============================================================================== # ☆ MINTO #------------------------------------------------------------------------------ # 様々なフラグを扱うメインモジュールです。 #============================================================================== module MINTO # センターヘルプコメントを有効化 ( true で有効 / false で無効 ) RGSS["center_help"] = true end if MINTO::RGSS["center_help"] #============================================================================== # ☆ カスタマイズ #------------------------------------------------------------------------------ # 機能のカスタマイズを行います。 #============================================================================== module MINTO # ボタン入力を無効にするウェイトフレーム数 Help_Wait = 60 end #============================================================================== # ■ Window_Center_Help #------------------------------------------------------------------------------ #  マップ画面で任意の文章を表示するウィンドウです。 #============================================================================== class Window_Center_Help < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 64, WLH + 32) self.z = 10000 self.visible = false @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 = 2 end #-------------------------------------------------------------------------- # ● フェード(変更) #-------------------------------------------------------------------------- def fade=(type) @fade = type self.x = (Graphics.width - self.width) / 2 self.y = ((Graphics.height - self.height) / 2) # フェードインの場合 if type == 2 self.y = ((Graphics.height - self.height) / 2) + 96 self.opacity = 0 self.contents_opacity = 0 end update_fade end #-------------------------------------------------------------------------- # ● フェード(参照) #-------------------------------------------------------------------------- def fade return @fade end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update_fade # ウィンドウがセンタリングされるまで更新する if self.y != (Graphics.height - self.height) / 2 self.y -= 16 self.y = [self.y, (Graphics.height - self.height) / 2].max end # フェード処理の場合 case @fade when 0 # 初期化 self.y = (Graphics.height - self.height) / 2 self.opacity = 192 self.contents_opacity = 255 when 1 # フェードアウト self.opacity -= 16 if self.opacity > 0 self.contents_opacity -= 16 when 2 # フェードイン self.opacity += 16 if self.opacity < 192 self.contents_opacity += 32 end end #-------------------------------------------------------------------------- # ● テキスト設定 # text : スプライトに表示する文字列 # fade : フェードインフラグ #-------------------------------------------------------------------------- def set_text(text, fade = false) @spell = false $scene.helpwait = MINTO::Help_Wait # ポーズサインを非表示にする self.pause = false # 求められたテキストが無効な場合 if text.to_s == "" then # 表示カウントを設定 @message_duration = 8 # メソッドを終了 return end # 終了記号を追加 text += "\\bw" # スプライトを可視状態にする self.visible = true # 各データを初期化 @scroll = [] @scroll_count = 0 @scroll_duration = 0 @save_text = "" @text = [] @text_width = [] @text_index = 0 @text_type = 0 @align = [] @wx = 0 @wy = 0 @speed = 1 @foring_end = false self.oy = 0 self.opacity = 192 self.contents_opacity = 255 # 表示カウントを設定 @message_duration = 16 # 設定用のデータを定義 height_p = 1 normal_height = 1 text_width = 0 max_width = 0 # テキストを再描画 self.contents.clear # 文字を複製 data = text.dup # 各制御文字を仮変換 data.gsub!(/\\\\/) { "\000" } data.gsub!(/\\[Cc]\[([0-9]+)\]/) { "" } data.gsub!(/\\[Ww][Ee]\[([0-9]+)\]/) { "" } data.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] } data.gsub!(/\\[Nn]\[([0-9]+)\]/) { $game_actors[$1.to_i].name } data.gsub!(/\\[Nn]/) { "" } data.gsub!(/ /) { "\002" } data.gsub!(/\\[Bb][Oo]\[([0-9]+)\]/) { "\10[#{$1}]" } data.gsub!(/\\[Ii][Tt]\[([0-9]+)\]/) { "" } data.gsub!(/\\[Ss][Pp]\[([0-9]+)\]/) { "" } data.gsub!(/\\[Bb][Ww]/) { "" } data.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\021[#{$1}]" } data.gsub!(/\\[Aa]\[([0-9]+)\]/) { "\022[#{$1}]" } data.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\023[#{$1}]" } # c に 1 文字を取得 (文字が取得できなくなるまでループ) while ((c = data.slice!(/./m)) != nil) do # 改行 の場合 if c == "\002" then # 文字幅が最高値以上の場合 if text_width > max_width then # 文字幅を更新 max_width = text_width end # 文字幅を記憶 @text_width.push(text_width) # 文字幅を初期化 text_width = 0 # 描写の高さを増やす height_p += 1 # 通常のを増やす normal_height += 1 # 次の文字へ next # \BO[n] の場合 elsif c == "\010" then # 制御文字を処理 data.sub!(/\[([0-9]+)\]/, "") # 太文字に変更 self.contents.font.bold = ($1.to_i == 1) # 次の文字へ next # \W[n] の場合 elsif c == "\021" then # 制御文字を処理 data.sub!(/\[([0-9]+)\]/, "") # 武器を取得 weapon = $data_weapons[$1.to_i] # 有効な武器の場合 unless weapon.nil? # text_width に武器名の幅を加算 text_width += self.contents.text_size(weapon.name).width # アイコンが設定されている場合 unless weapon.icon_index.zero? # text_width にアイコンの幅を加算 text_width += 24 end end # 次の文字へ next # \A[n] の場合 elsif c == "\022" then # 制御文字を処理 data.sub!(/\[([0-9]+)\]/, "") # 防具を取得 armor = $data_armors[$1.to_i] # 有効な防具の場合 unless armor.nil? # text_width に防具名の幅を加算 text_width += self.contents.text_size(armor.name).width # アイコンが設定されている場合 unless armor.icon_index.zero? # text_width にアイコンの幅を加算 text_width += 24 end end # 次の文字へ next # \I[n] の場合 elsif c == "\023" then # 制御文字を処理 data.sub!(/\[([0-9]+)\]/, "") # アイテムを取得 item = $data_items[$1.to_i] # 有効なアイテムの場合 unless item.nil? # text_width にアイテム名の幅を加算 text_width += self.contents.text_size(item.name).width # アイコンが設定されている場合 unless item.icon_index.zero? # text_width にアイコンの幅を加算 text_width += 24 end end # 次の文字へ next end # text_width に描画した文字の幅を加算 text_width += self.contents.text_size(c).width end # 文字幅を記憶 @text_width.push(text_width) # 文字幅が最高値以上の場合 if text_width > max_width # 文字幅を更新 max_width = text_width end # ウィンドウのサイズを調節 self.width = max_width + 32 self.height = 32 + (WLH * normal_height) # ビットマップを再作成 create_contents refresh(text.dup) if fade self.fade = 2 else self.fade = 0 end end #-------------------------------------------------------------------------- # ● リフレッシュ # text : スプライトに表示する文字列 #-------------------------------------------------------------------------- def refresh(text) # 基本情報を初期化 self.contents.clear self.contents.font.color = normal_color self.contents.font.bold = false self.contents.font.italic = false @text_x = ((self.width - 32) - @text_width[0]) / 2 @text_y = 0 # 文章のインデックスを初期化 @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].name != nil ? $game_actors[$1.to_i].name : "" end # 便宜上、"\\\\" を "\000" に変換 text.gsub!(/\\\\/) { "\000" } # 各制御文字を実際のものに変換 text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" } text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] } text.gsub!(/ /) { "\002" } text.gsub!(/\\[Ww][Ee]\[([0-9]+)\]/) { "\003[#{$1}]" } text.gsub!(/\\[Bb][Oo]\[([0-9]+)\]/) { "\010[#{$1}]" } text.gsub!(/\\[Ii][Tt]\[([0-9]+)\]/) { "\016[#{$1}]" } text.gsub!(/\\[Bb][Ww]/) { "\017" } text.gsub!(/\\[Ss][Pp]\[([0-9]+)\]/) { "\020[#{$1}]" } text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\021[#{$1}]#{$data_weapons[$1.to_i].name}" } text.gsub!(/\\[Aa]\[([0-9]+)\]/) { "\022[#{$1}]#{$data_armors[$1.to_i].name}" } text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\023[#{$1}]#{$data_items[$1.to_i].name}" } @save_text = text.dup end end #-------------------------------------------------------------------------- # ● テキストの更新 #-------------------------------------------------------------------------- def text_update @text = @save_text.split(//) # 無効な文字列の場合 if @text[@text_index] == nil then # メソッドを返す return false end # スプライトを可視状態にする self.visible = true # テキストを取得 c = @text[@text_index] # \\ の場合 if c == "\000" then # 本来の文字に戻す c = "\\" # \C[n] の場合 elsif c == "\001" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 文字色のIDを取得 color = $1.to_i # 文字色のIDが有効な場合 if color >= 0 then # 文字色を変更 self.contents.font.color = text_color(color) end # インデックスを進める @text_index += 1 # メソッドを返す return true # 改行 の場合 elsif c == "\002" then # インデックスを進める @text_index += 1 # @text_y に 1 を加算 @text_y += 1 @text_x = ((self.width - 32) - @text_width[@text_y]) / 2 # メソッドを返す return true # \WE[n] の場合 elsif c == "\003" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # ウェイトカウントを設定 @wait_count = $1.to_i # インデックスを進める @text_index += 1 # メソッドを返す return true # \BO[n] の場合 elsif c == "\010" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 太文字に変更 self.contents.font.bold = ($1.to_i == 1) # インデックスを進める @text_index += 1 # メソッドを返す return true # \IT[n] の場合 elsif c == "\016" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 斜体文字に変更 self.contents.font.italic = ($1.to_i == 1) # インデックスを進める @text_index += 1 # メソッドを返す return true # \BW の場合 elsif c == "\017" then # 文章の表示速度を初期化 @speed = 0 # ポーズサインを表示する self.pause = true # ボタン待ちフラグをオン @press = true # インデックスを進める @text_index += 1 # メソッドを返す return true # \SP[n] の場合 elsif c == "\020" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 表示速度を変更 @speed = [$1.to_i, 0].max # インデックスを進める @text_index += 1 # メソッドを返す return true # \W[n] の場合 elsif c == "\021" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 有効なデータの場合 unless $1.to_i.zero? then # アイコンのインデックスを取得 icon_index = $data_weapons[$1.to_i].icon_index # アイコンを描写 draw_icon(icon_index, @text_x, WLH * @text_y) # @text_x にアイコンの幅を加算 @text_x += 24 end # インデックスを進める @text_index += 1 # メソッドを返す return true # \A[n] の場合 elsif c == "\022" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 有効なデータの場合 unless $1.to_i.zero? then # アイコンのインデックスを取得 icon_index = $data_armors[$1.to_i].icon_index # アイコンを描写 draw_icon(icon_index, @text_x, WLH * @text_y) # @text_x にアイコンの幅を加算 @text_x += 24 end # インデックスを進める @text_index += 1 # メソッドを返す return true # \I[n] の場合 elsif c == "\023" then # 制御文字を処理 @save_text.sub!(/\[([0-9]+)\]/, "") # 有効なデータの場合 unless $1.to_i.zero? then # アイコンのインデックスを取得 icon_index = $data_items[$1.to_i].icon_index # アイコンを描写 draw_icon(icon_index, @text_x, WLH * @text_y) # @text_x にアイコンの幅を加算 @text_x += 24 end # インデックスを進める @text_index += 1 # メソッドを返す return true end # 文字を描画 self.contents.draw_text(@text_x, WLH * @text_y, 40, WLH, c) # @text_x に描画した文字の幅を加算 @text_x += self.contents.text_size(c).width # インデックスを進める @text_index += 1 return true end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ボタン入力待ちフラグがオンの場合 if @press == true and @foring_end == false then super # ウェイト終了待ちの場合 if $scene.helpwait >= 1 then # メソッドを返す return end # C ボタンが押された場合 if Input.trigger?(Input::C) == true then # ボタン入力待ちフラグをオフ @press = false # ポーズサインを非表示にする self.pause = false end # メソッドを返す return end # ウェイトカウントが 1 以上の場合 if @wait_count >= 1 then # ウェイトカウントを減らす @wait_count -= 1 # メソッドを返す 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 = 1 end # 更新カウントが設定してある場合 if @message_duration >= 1 then # 更新カウントを減らす @message_duration -= 1 # 透明度を調節する self.contents_opacity -= 32 self.opacity -= 32 # 更新カウントが丁度 0 になった場合 if @message_duration == 0 then # 文章の表示速度を初期化 @speed = 0 # ボタン入力待ちフラグをオフ @press = false # テロップを不可視にする self.visible = false end end end end #============================================================================== # ☆ MINTO_Scene_Map_01 #------------------------------------------------------------------------------ # Scene_Mapクラスの強化システムモジュールです。 #============================================================================== module MINTO_Scene_Map_01 #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start # センターヘルプウィンドウを作成 @centerhelp_window = Window_Center_Help.new @helpwait = 0 # スーパークラスを実行 (継承先の処理に移行する) super end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate # センターヘルプウィンドウを解放 @centerhelp_window.dispose # スーパークラスを実行 (継承先の処理に移行する) super end end #============================================================================== # ■ Scene_Map #------------------------------------------------------------------------------ #  マップ画面の処理を行うクラスです。 #============================================================================== class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ● システムインクルード宣言 #-------------------------------------------------------------------------- include MINTO_Scene_Map_01 # みんとシーンマップ #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :centerhelp_window # ヘルプウィンドウ attr_accessor :helpwait # ウェイトカウント #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias :update_Center_Help :update def update # フェード処理を更新 @centerhelp_window.update @centerhelp_window.update_fade # すでにヘルプウィンドウが表示されており、 # ヘルプ終了判定が有効の場合はウィンドウを不可視にする if @centerhelp_window.visible and Input.trigger?(Input::C) # ウェイトカウントが0の場合はウィンドウを閉じる if @helpwait == 0 @centerhelp_window.visible = false # メソッドを終了 return end end # ヘルプウィンドウ表示中の場合は更新を一時停止 if @centerhelp_window.visible # ウェイトカウントを減らす if @helpwait >= 1 @helpwait -= 1 end # メソッドを終了 return end # 元の処理を実行 update_Center_Help end end end