#============================================================================== #制御文字拡張スクリプト。 #どちらかと言うと、新しい事ができるというより、 #作業効率が上がるタイプのスクリプトです。 # Ver1.04 # 選択肢の位置が上から2番目に固定されていたバグを修正 # メッセージを何個か表示すると選択肢カーソルのサイズがおかしくなるバグを修正 # クリプトw # # Ver1.03 # 選択肢が文字のサイズに合わせて変動するように変更。 # # Ver1.02 # 文字表示がおかしかった不具合を修正。 # Ver1.01 # KCG様の装備拡張と競合回避。 # # \T[n] 文字のサイズをnに変更します。値が小さすぎると適応されません。 # \IC[n] n番のアイコンを表示します。 # \ITM[n] n番のアイテムの名前を表示します。 # \WPN[n] n番の武器の名前を表示します。 # \ARM[n] n番の防具の名前を表示します。 # \SKL[n] n番のスキルの名前を表示します。 # \TXT[n] TXT_ARRAYに設定した固定メッセージを表示します。 #     ゲーム中の固有名詞などに使うと、後々名称を変更したくなった時に #     かなり楽ができます。 #     \TXT[0]と書けば、0番と表示されます。 #     TXT_ARRAYの[]の中に、 ,"" と書き加えれば、いくらでも固定メッセージを増やせます。 # # \GIN gain。直前に手に入れたアイテムの名前を表示します。 #     後々、やっぱアイテムの名前を変えたいなーと思った時などに #     変更が容易であるのと、イベントの簡単作成に一々処理を加えるよりは楽な事が利点です。 # # \FCN フェイスグラフィックに対応した名前を表示 #     VOCAB_PHASE_NAMEに名前を登録しておく事で効果を表します。 #     画像の名前、インデックスの順に指定してください。 #     複数の表情があるキャラクターはそれぞれ別個で登録する必要があります。 # # \SPC 24ドット分のスペースです。 #     選択肢表示時の文字サイズによる位置のばらつきを抑えるために使いました。 # #============================================================================== class Window_Message < Window_Selectable TXT_ARRAY = ["0番","1番","2番","3番","4番"] VOCAB_PHASE_NAME = { ["Actor1",0] => "アクター1", ["Actor1",1] => "アクター2", } def er_gain_phase_name name = $game_message.face_name index = $game_message.face_index text = VOCAB_PHASE_NAME[[name,index]] return (text == nil ? "" : text) end alias b_init initialize def initialize b_init @max_height = 0 @text_line_y = [] end alias nl new_line def new_line nl #改行時にWLHではなく、その行で一番大きい文字のサイズに合わせてy座標をずらす #大きい文字→小さい文字にした時に、改行して文字がかぶってしまう不具合を #回避するための処置です。 @contents_y += @max_height - WLH @contents_y += 4 @text_line_y.push(@max_height + 4) @max_height = 0 end alias base_new_page new_page def new_page base_new_page @text_line_y = [] end #-------------------------------------------------------------------------- # ● カーソルの更新 #-------------------------------------------------------------------------- def update_cursor if @index >= 0 x = $game_message.face_name.empty? ? 0 : 112 n = @text_line_y[@index+$game_message.choice_start] height = (n == nil ? WLH : n) #y = ($game_message.choice_start + @index) * WLH y = 0 for i in 0..@index + $game_message.choice_start - 1 y += @text_line_y[i] if @text_line_y[i] != nil end self.cursor_rect.set(x, y, contents.width - x, height) else self.cursor_rect.empty end end #-------------------------------------------------------------------------- # ● 特殊文字の変換 #-------------------------------------------------------------------------- alias base_csc convert_special_characters def convert_special_characters #処理の順番の関係から、{ $data_items[$1.to_i].name } を #{ "\\C[1]" + $data_items[$1.to_i].name + "\\C[0]" } と変更すれば #メッセージ中のアイテム文字の色を変える事ができます。 #他の武器や防具、スキルなども同様の手順で色をつける事ができます。 # #かなり長くなりますが、 #{"\\IC[#{$data_items[$1.to_i].icon_name}]" + "\\C[1]" + $data_items[$1.to_i].name + "\\C[0]" } #と変更すれば、\\ITM[n] と記述するだけで #アイコン+文字色の変わったn番のアイテム名を表示する事ができます。 @text.gsub!(/\\GIN/) { $game_temp.er_gain_item_text } @text.gsub!(/\\FCN/) { er_gain_phase_name } @text.gsub!(/\\ITM\[([0-9]+)\]/i) { $data_items[$1.to_i].name } @text.gsub!(/\\WPN\[([0-9]+)\]/i) { $data_weapons[$1.to_i].name } @text.gsub!(/\\ARM\[([0-9]+)\]/i) { $data_armors[$1.to_i].name } @text.gsub!(/\\SKL\[([0-9]+)\]/i) { $data_skills[$1.to_i].name } @text.gsub!(/\\TXT\[([0-9]+)\]/i) { TXT_ARRAY[$1.to_i] } base_csc #\T[数値]を便宜上変換。 @text.gsub!(/\\T\[([0-9]+)\]/i) { "\x11[#{$1}]" } @text.gsub!(/\\IC\[([0-9]+)\]/i) { "\x99[#{$1}]" } @text.gsub!(/\SPC/) { "\x98" } end #-------------------------------------------------------------------------- # ● メッセージの更新 ※再定義 #-------------------------------------------------------------------------- def update_message loop do c = @text.slice!(/./m) # 次の文字を取得 case c when nil # 描画すべき文字がない finish_message # 更新終了 break when "\x00" # 改行 new_line if @line_count >= MAX_LINE # 行数が最大のとき unless @text.empty? # さらに続きがあるなら self.pause = true # 入力待ちを入れる break end end when "\x01" # \C[n] (文字色変更) @text.sub!(/\[([0-9]+)\]/, "") contents.font.color = text_color($1.to_i) next #-------------------追加ここから---------------------------------- when "\x11" # \T[n] (文字サイズ変更) @text.sub!(/\[([0-9]+)\]/, "") contents.font.size = [($1.to_i),6].max next when "\x99" # \IC[n] (アイコン表示) @text.sub!(/\[([0-9]+)\]/, "") draw_icon($1.to_i,@contents_x,@contents_y,true) @contents_x += 24 when "\x98" # \IC[n] (アイコン表示) @contents_x += 24 next #-------------------追加ここまで---------------------------------- when "\x02" # \G (所持金表示) @gold_window.refresh @gold_window.open when "\x03" # \. (ウェイト 1/4 秒) @wait_count = 15 break when "\x04" # \| (ウェイト 1 秒) @wait_count = 60 break when "\x05" # \! (入力待ち) self.pause = true break when "\x06" # \> (瞬間表示 ON) @line_show_fast = true when "\x07" # \< (瞬間表示 OFF) @line_show_fast = false when "\x08" # \^ (入力待ちなし) @pause_skip = true else # 普通の文字 #-------------------▼このあたり改変ポイント▼---------------------------------- c_height = contents.text_size(c).height contents.draw_text(@contents_x, @contents_y+2, 40, c_height, c) c_width = contents.text_size(c).width @contents_x += c_width @max_height = c_height if c_height > @max_height #-------------------▲このあたり改変ポイント▲---------------------------------- end break unless @show_fast or @line_show_fast end end #-------------------------------------------------------------------------- # ● メッセージの開始 #-------------------------------------------------------------------------- def start_message @text = "" for i in 0...$game_message.texts.size @text += "\SPC" if i >= $game_message.choice_start @text += $game_message.texts[i].clone + "\x00" end @item_max = $game_message.choice_max convert_special_characters reset_window new_page end end #====================================================================== #以下、最後に手に入れたアイテム、ゴールドを格納する処理。 #$game_temp.er_gain_item_text = item.nameをいろいろいじれば、 #アイコン表示+文字色変え+アイテム名表示などを\GINのみで行うことも可能です # class Game_Temp attr_accessor :er_gain_item_text alias base_ini initialize def initialize base_ini @er_gain_item_text = "" end end class Game_Party alias base_gain_item gain_item def gain_item(item, n, include_equip = false) base_gain_item(item, n, include_equip) $game_temp.er_gain_item_text = (item != nil ? item.name : "") #↑をコメントアウト(小文字の♯)して、下の♯を外せば、アイコン表示+文字色変えアイテム名 #$game_temp.er_gain_item_text = "\\IC[#{item.icon_index}]" + "\\C[1]" + item.name + "\\C[0]" end alias base_gain_gold gain_gold def gain_gold(n) base_gain_gold(n) $game_temp.er_gain_item_text = n.to_s + Vocab::gold end end