#=========================================================================== # ◆ A1 Scripts ◆ # 吹き出しメッセージ(RGSS3) # # バージョン : 2.00 (2020/06/16) # 作者 : A1 # URL     : http://a1tktk.web.fc2.com/ #--------------------------------------------------------------------------- # 機能: # ・吹き出しメッセージを表示します #--------------------------------------------------------------------------- # 更新履歴   :2012/01/12 Ver1.00 リリース #    :2020/06/20 Ver2.00 リリース #--------------------------------------------------------------------------- # 設置場所 # A1共通スクリプト以下 # (ネームウィンドウ以下) # # 必要スクリプト # A1共通スクリプトVer5.30以上 # # 必要ファイル # Window_Popup.png ※ Graphics/System にインポート #--------------------------------------------------------------------------- # 使い方 # ■ 設定項目 に設定 # # イベントコマンド「注釈」に記述 # # 吹き出し使用 on|off # # 吹き出しの使用を切り替えます # on で吹き出し使用、off で吹き出し使用しなくなります # # 吹き出しクローズ key # # 指定した吹き出しを閉じます # 設定項目で設定した [歩行グラフィック名]_[歩行グラフィックIndex] を # key に指定します # # 例:吹き出しクローズ Actor4_0 # # 並列吹き出し # # 指定後1回のの文章を並列吹き出しとして表示します # 並列吹き出しは、吹き出し表示中でもプレイヤーの移動や # イベントコマンドの実行・続行が可能です # # また、他の吹き出しと同時に閉じることがなくなります # # イベント吹き出し event_id # # イベントを直接指定して吹き出しを表示します # # イベント吹き出し event_id,固定 # # イベントを直接指定して吹き出しを表示した際 # 解除するまで指定したイベントから吹き出しメッセージを表示します # # イベント吹き出し固定解除 # # イベント吹き出しを固定で使用した際に固定吹き出しを解除します # # 吹き出しクローズ イベント,event_id # # イベント吹き出しで表示した吹き出しを閉じます # # 例:吹き出しクローズ イベント,5 # # ※先に「イベント吹き出し」でevent_id 5 のイベントに # 吹き出しを表示させているものとします # # スクリーンFIX on|off # # 吹き出しが画面外に出る場合の制御を行います。 # on で画面内に収まるようにします。 # off にすると画面外に出ても位置補正をしません。 # # 吹き出し固定長 key,width # # 指定した吹き出しの幅を固定長にします。 # 設定項目で設定した [歩行グラフィック名]_[歩行グラフィックIndex] を # key に指定します # # 吹き出し固定長解除 key # # 設定した吹き出し固定長を解除します。 # 設定項目で設定した [歩行グラフィック名]_[歩行グラフィックIndex] を # key に指定します # # 吹き出し位置補正 key,x,y # # 指定した吹き出しの位置を指定したx座標・y座標分補正します。 # 設定項目で設定した [歩行グラフィック名]_[歩行グラフィックIndex] を # key に指定します # # 吹き出し位置補正解除 key # # 設定した吹き出し位置補正を解除します。 # 設定項目で設定した [歩行グラフィック名]_[歩行グラフィックIndex] を # key に指定します # # ネームウィンドウ上下固定 上|下|off # # ※A1製ネームウィンドウ併用時 # ネームウィンドウの表示位置を、吹き出しの上下どちらかに固定します。 # offにすると固定解除します。 # # メッセージウィンドウコマンド # # \CC[count] :クローズカウントを設定します(フレーム数) # 設定項目のデフォルト値より優先されます # # \KP :吹き出しのヒレが「考え中」になります # # \PR :並列吹き出し状態として表示した吹き出しの # 並列吹き出し状態をメッセージ終了後に解除します # # 解除された場合、他の吹き出しと同時に閉じるようになります #============================================================================== $imported ||= {} $imported["A1_PopupMassage"] = true if $imported["A1_Common_Script"] old_common_script("吹き出しメッセージ", "5.30") if common_version < 5.30 #============================================================================== # ■ 設定項目 #============================================================================== module A1_System::CnildMassageWindowConfig #-------------------------------------------------------------------------- # 〇 ウィンドウが閉じられた際に、閉じられるまでの最大幅をコンソールに表示する(固定長計測用) #-------------------------------------------------------------------------- SHOW_WIDTH_TO_CONSOLE = false #-------------------------------------------------------------------------- # 〇 表示する行数 #-------------------------------------------------------------------------- LINE_NUM = 4 #-------------------------------------------------------------------------- # 〇 顔グラフィックのサイズ #-------------------------------------------------------------------------- FACE_SIZE = LINE_NUM * 24 #-------------------------------------------------------------------------- # 〇 顔グラフィックと歩行グラフィックの対応 # # "[顔グラフィック名]_[Index]" => "[歩行グラフィック名]_[Index]" ※Index毎に設定 # "[顔グラフィック名]" => "[歩行グラフィック名]_[Index]" ※該当顔グラフィック全てに適用 # # 歩行グラフィックは配列で複数指定することが可能です #-------------------------------------------------------------------------- LINK_FACE = { # 顔グラフィック => 歩行グラフィック "Actor4_0" => "Actor4_0", "Actor4_5" => "Actor4_5", "2000_アレックス" => "2000_主人公1_0", "2000_ブライアン" => "2000_主人公1_2", } #-------------------------------------------------------------------------- # 文字入力待ちでないウィンドウが閉じるまでの時間(フレーム)のデフォルト値 # -1 にすると手動で閉じるかイベント終了まで閉じません # -1 にすると「並列吹き出し」にしたウィンドウは手動で閉じるまでずっと閉じません #-------------------------------------------------------------------------- DEFAULT_CLOSE_COUNT = -1 #-------------------------------------------------------------------------- # 吹き出しメッセージ使用のデフォルト値 #-------------------------------------------------------------------------- DEFAULT_ENABLE_POPUP = true end #============================================================================== # ■ Cache #------------------------------------------------------------------------------ #  各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール # です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部 # のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト # を返すようになっています。 #============================================================================== module Cache #-------------------------------------------------------------------------- # ○ 定数 #-------------------------------------------------------------------------- FACE_SIZE = A1_System::CnildMassageWindowConfig::FACE_SIZE #-------------------------------------------------------------------------- # ○ 顔グラフィックの取得 #-------------------------------------------------------------------------- def self.half_face(filename) load_file_name = "Graphics/Faces/#{filename}" key = "#{load_file_name}_halfface" size_2000 = (FACE_SIZE / 48.0) * -1 size_vxa = (FACE_SIZE / 96.0) * -1 return load_resize_bitmap(load_file_name, key, [size_2000, size_2000]) if filename =~ /^2000_.*/ load_resize_bitmap(load_file_name, key, [size_vxa, size_vxa]) end end #============================================================================== # ■ Window_Message #------------------------------------------------------------------------------ #  文章表示に使うメッセージウィンドウです。 #============================================================================== class Window_Message < Window_Base #-------------------------------------------------------------------------- # ○ 定数 #-------------------------------------------------------------------------- SHOW_WIDTH_TO_CONSOLE = A1_System::CnildMassageWindowConfig::SHOW_WIDTH_TO_CONSOLE 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 unless $game_temp.event_popup_fix 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 } $game_message.close_message ||= [] return if $game_message.close_message.empty? $game_message.close_message.each {|close_window| close_popup(close_window) } $game_message.close_message = [] end #-------------------------------------------------------------------------- # ○ ポップアップのクローズ #-------------------------------------------------------------------------- def close_popup(close_window) target_key = find_target_key(close_window) @child_message_window[target_key].close if close_window && @child_message_window[target_key] end #-------------------------------------------------------------------------- # ○ 対象ウィンドウキーの検索 #-------------------------------------------------------------------------- def find_target_key(close_window) @child_message_window.each_key {|key| return key if key.is_a?(Array) && key.include?(close_window) } return close_window 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 fix_width = nil message_locate = [0, 0] $game_message.message_window_width.each_pair {|key, value| fix_width = value if @child_key.include?(key) } $game_message.message_window_locate.each_pair {|key, value| message_locate = value if @child_key.include?(key) } @child_message_window[@child_key].my_child_key = @child_key process_child_message_window(@child_message_window[@child_key], fix_width, message_locate) 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] window.link_event = $game_player if event_id == -1 return window end #-------------------------------------------------------------------------- # ○ リンクするイベントの設定 #-------------------------------------------------------------------------- def set_link_event(window, event) window.link_event = event end #-------------------------------------------------------------------------- # ○ 子メッセージウィンドウの処理 #-------------------------------------------------------------------------- def process_child_message_window(window, fix_width = nil, message_locate = [0, 0]) @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, replace_text_command(text)) $game_message.texts = text.split("\n") window.set_face_info($game_message.face_name, $game_message.face_index) child_width = fix_width ? fix_width : window.new_line_x + text_width + standard_padding * 2 window.set_width(child_width) window.background = $game_message.background window.message_locate = message_locate window.create_contents setup_priority(window) window.process_all_text @choice_window.set_active_window(window) @use_child = true end #-------------------------------------------------------------------------- # ○ テキストコマンドを空白に変換 #-------------------------------------------------------------------------- def replace_text_command(text) ret = text ret = ret.gsub(/\eCC\[\d+\]/, "") ret = ret.gsub(/\e[\S]/, "") return ret 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(kind) @child_window.popup_kind = kind 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_ChoiceList #------------------------------------------------------------------------------ #  イベントコマンド[選択肢の表示]に使用するウィンドウです。 #============================================================================== class Window_ChoiceList < Window_Command #-------------------------------------------------------------------------- # ○ 吹き出しの初期化 #-------------------------------------------------------------------------- def set_active_window(window) @active_window_x = window.x @active_window_y = window.y @active_window_h = window.height end #-------------------------------------------------------------------------- # ☆ ウィンドウ位置の更新 #-------------------------------------------------------------------------- alias a1_child_message_window_wc_update_placement update_placement def update_placement a1_child_message_window_wc_update_placement if @active_window_y self.y = @active_window_y + @active_window_h self.y = @active_window_y - self.height if self.y + self.height > Graphics.height end @active_window_y = nil @active_window_x = nil @active_window_h = nil end end #============================================================================== # ■ Window_ChildMessage #============================================================================== class Window_ChildMessage < Window_Message #-------------------------------------------------------------------------- # ○ 定数 #-------------------------------------------------------------------------- LINE_NUM = A1_System::CnildMassageWindowConfig::LINE_NUM FACE_SIZE = A1_System::CnildMassageWindowConfig::FACE_SIZE 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_key = nil @max_width = 0 @my_child_window = true @screen_width = Graphics.width @message_locate = [0, 0] super create_popup end #-------------------------------------------------------------------------- # ○ 自身のキーを設定 #-------------------------------------------------------------------------- def my_child_key=(value) @my_child_key = value end #-------------------------------------------------------------------------- # ○ 表示位置補正 #-------------------------------------------------------------------------- def message_locate @message_locate ||= [0, 0] @message_locate end #-------------------------------------------------------------------------- # ○ 表示位置補正 #-------------------------------------------------------------------------- def message_locate=(value) @message_locate = value end #-------------------------------------------------------------------------- # ○ 表示優先度の設定 #-------------------------------------------------------------------------- def set_z(value) @name_windows[@name_window_key].set_z(value + 1) if @name_windows[@name_window_key] self.z = value 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 ? @event.opacity : 0 self.contents_opacity = @event.opacity @popup_sprite.opacity = @event.opacity @popup_sprite.opacity /= 2 if @event.opacity < 255 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 return if kind == 2 @popup_sprite.bitmap.blt(0, 0, @popup_bitmap, POPUP_RECT[@position][kind]) end #-------------------------------------------------------------------------- # ○ ポップアップ種別の設定 #-------------------------------------------------------------------------- def popup_kind=(kind) set_popup_bitmap(kind) end #-------------------------------------------------------------------------- # ○ ウィンドウ位置の更新 #-------------------------------------------------------------------------- def update_pos self.x = set_pos_x self.y = @event.screen_y + pos_y + @message_locate[1] self.width = self.width + @popup_sprite. width + 32 if self.x + self.width < @popup_sprite.x + @popup_sprite. width window_screen_fix if $game_message.message_window_fix set_popup_pos set_name_window_pos if $imported["A1_Name_Window"] end #-------------------------------------------------------------------------- # ○ ウィンドウ位置の画面サイズFIX #-------------------------------------------------------------------------- def window_screen_fix self.y = 0 if self.y < 0 self.y = Graphics.height - self.height if self.y + self.height > Graphics.height self.x = 0 if self.x < 0 self.x = Graphics.width - self.width if self.x + self.width > Graphics.width end #-------------------------------------------------------------------------- # ○ ネームウィンドウの位置設定 #-------------------------------------------------------------------------- def set_name_window_pos return unless @name_windows[@name_window_key] @name_windows[@name_window_key].x = self.x + 24 #+ @message_locate[0] @name_windows[@name_window_key].y = name_window_y + @message_locate[1] @name_windows[@name_window_key].z = self.z @name_windows[@name_window_key].set_name_sprite_pos @name_windows[@name_window_key].set_opacity(self.opacity) end #-------------------------------------------------------------------------- # ○ ネームウィンドウのy座標設定 #-------------------------------------------------------------------------- def name_window_y down_y = self.y + self.height - 12 up_y = self.y - 16 return up_y if $game_temp.name_window_fix_updown == "上" return down_y if $game_temp.name_window_fix_updown == "下" return down_y if self.y - @name_windows[@name_window_key].height < 0 return up_y if self.y - self.height + @name_windows[@name_window_key].height > Graphics.height return down_y if @position == 2 return up_y if @position == 0 return self.y - 16 end #-------------------------------------------------------------------------- # ○ ウィンドウx座標の取得 #-------------------------------------------------------------------------- def set_pos_x base = @event.screen_x - 64 + @message_locate[0] return 0 if base < 0 return Graphics.width - self.width if base + self.width > Graphics.width return base end #-------------------------------------------------------------------------- # ○ ウィンドウy座標の取得 #-------------------------------------------------------------------------- def pos_y return ((LINE_NUM * 36) * -1) - 40 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 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 A1_System::CnildMassageWindowConfig::LINE_NUM end #-------------------------------------------------------------------------- # ○ ウィンドウ幅の設定 #-------------------------------------------------------------------------- def set_width(width) self.width = width @max_width = width if @max_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 unless @pause_skip 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 p "MaxWidth:#{@max_width} key:#{@my_child_key}" if SHOW_WIDTH_TO_CONSOLE @max_width = 0 reset_close_count super end #-------------------------------------------------------------------------- # ○ 改行位置の取得 #-------------------------------------------------------------------------- def new_line_x $game_message.face_name.empty? ? 0 : FACE_SIZE + 8 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 #-------------------------------------------------------------------------- # ○ 定数 #-------------------------------------------------------------------------- FACE_SIZE = A1_System::CnildMassageWindowConfig::FACE_SIZE #-------------------------------------------------------------------------- # ☆ 顔グラフィックの描画 # 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 FACE_SIZE == 48 && @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, FACE_SIZE) 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 * FACE_SIZE, face_index / 4 * FACE_SIZE, FACE_SIZE, FACE_SIZE) contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha) end #-------------------------------------------------------------------------- # ○ 制御文字の事前変換 #-------------------------------------------------------------------------- alias a1_child_message_window_wm_convert_escape_characters convert_escape_characters def convert_escape_characters(text) result = a1_child_message_window_wm_convert_escape_characters(text) result.gsub!(/\eCC\[(\d+)\]/i) { set_close_count($1.to_i) } result.gsub!(/\eKP/i) { set_popup_kind(1) } result.gsub!(/\eNP/i) { set_popup_kind(2) } result end end #============================================================================== # ■ Game_Message #------------------------------------------------------------------------------ #  文章や選択肢などを表示するメッセージウィンドウの状態を扱うクラスです。この # クラスのインスタンスは $game_message で参照されます。 #============================================================================== class Game_Message #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :close_message attr_accessor :message_window_fix #-------------------------------------------------------------------------- # ☆ オブジェクト初期化 #-------------------------------------------------------------------------- alias a1_child_message_window_gm_initialize initialize def initialize a1_child_message_window_gm_initialize @input_wait = true @close_message = [] @message_window_fix = false @message_window_width = {} @message_window_locate = {} end #-------------------------------------------------------------------------- # ○ 表示するテキストの設定 #-------------------------------------------------------------------------- def texts=(text) @texts = text end #-------------------------------------------------------------------------- # ○ 吹き出し固定長 #-------------------------------------------------------------------------- def message_window_width @message_window_width ||= {} @message_window_width end #-------------------------------------------------------------------------- # ○ 吹き出し位置補正 #-------------------------------------------------------------------------- def message_window_locate @message_window_locate ||= {} @message_window_locate end end #============================================================================== # ■ Game_Temp #------------------------------------------------------------------------------ #  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン # スタンスは $game_temp で参照されます。 #============================================================================== class Game_Temp #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :input_wait attr_accessor :event_popup_id attr_accessor :event_popup_fix attr_accessor :name_window_fix_updown #-------------------------------------------------------------------------- # ☆ オブジェクト初期化 #-------------------------------------------------------------------------- alias a1_child_message_gt_initialize initialize def initialize a1_child_message_gt_initialize @input_wait = true @event_popup_id = nil @name_window_fix_updown = nil @event_popup_fix = false 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 @cmd_108["イベント吹き出し固定解除"] = :release_event_popup_fix @cmd_108["スクリーンFIX"] = :message_window_fix @cmd_108["吹き出し固定長"] = :set_window_width @cmd_108["吹き出し固定長解除"] = :delete_window_width @cmd_108["吹き出し位置補正"] = :set_window_locate @cmd_108["吹き出し位置補正解除"] = :delete_window_locate @cmd_108["ネームウィンドウ上下固定"] = :updown_fix_name_window end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ○ ネームウィンドウ上下固定 #-------------------------------------------------------------------------- def updown_fix_name_window(params) $game_temp.name_window_fix_updown = params[0] end #-------------------------------------------------------------------------- # ○ 吹き出し位置補正 #-------------------------------------------------------------------------- def set_window_locate(params) $game_message.message_window_locate[params[0]] = [params[1].to_i, params[2].to_i] end #-------------------------------------------------------------------------- # ○ 吹き出し位置解除 #-------------------------------------------------------------------------- def delete_window_locate(params) $game_message.message_window_locate.delete(params[0]) end #-------------------------------------------------------------------------- # ○ スクリーンFIX #-------------------------------------------------------------------------- def message_window_fix(params) $game_message.message_window_fix = params[0] == "on" ? true : false end #-------------------------------------------------------------------------- # ○ 吹き出し固定長 #-------------------------------------------------------------------------- def set_window_width(params) $game_message.message_window_width[params[0]] = params[1].to_i end #-------------------------------------------------------------------------- # ○ 吹き出し固定長解除 #-------------------------------------------------------------------------- def delete_window_width(params) $game_message.message_window_width.delete(params[0]) end #-------------------------------------------------------------------------- # ○ 並列吹き出し #-------------------------------------------------------------------------- def sub_message(params) $game_temp.input_wait = false end #-------------------------------------------------------------------------- # ○ 吹き出しクローズ #-------------------------------------------------------------------------- def close_popup(params) return close_popup_id(params[1]) if params[0] == "イベント" $game_message.close_message.push(params[0]) end #-------------------------------------------------------------------------- # ○ 吹き出しクローズ(ID) #-------------------------------------------------------------------------- def close_popup_id(params) $game_message.close_message.push("event_id_key_#{params.to_i}") 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 $game_temp.event_popup_fix = params[1] == "固定" end #-------------------------------------------------------------------------- # ○ イベント吹き出し固定解除 #-------------------------------------------------------------------------- def release_event_popup_fix(params) $game_temp.event_popup_fix = false $game_temp.event_popup_id = nil 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_opacity(value) self.opacity = value @name_sprite.opacity = value end #-------------------------------------------------------------------------- # ○ ネームスプライトの位置設定 #-------------------------------------------------------------------------- def set_name_sprite_pos @name_sprite.x = self.x + self.width / 2 @name_sprite.y = self.y + self.height / 2 @name_sprite.z = self.z + 1 end #-------------------------------------------------------------------------- # ○ zの設定 #-------------------------------------------------------------------------- def set_z(value) self.z = value @name_sprite.z = self.z + 1 end end;end end