赞 | 12 |
VIP | 0 |
好人卡 | 0 |
积分 | 17 |
经验 | 0 |
最后登录 | 2020-8-22 |
在线时间 | 91 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1680
- 在线时间
- 91 小时
- 注册时间
- 2019-5-16
- 帖子
- 45
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
Q:它能做什么?
A:文章自动换行、排版,支持缩头避尾规则和英文排版规则。可以为选项设置出现条件、合法性检查和帮助文本。还有更多。请仔细阅读脚本说明。
Q:为什么除了最开始的说明,其他注释都是日语?
A:本来抱着练习日语的想法,注释全部以日语书写。既然要发出来,就把说明部分翻译成中文吧。
- #==============================================================================
- # ◆ 事件·脚本扩张 by Aephiex
- #------------------------------------------------------------------------------
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- # http://www.apache.org/licenses/LICENSE-2.0
- #------------------------------------------------------------------------------
- #
- # 主要机能:
- # ◎ 添加控制符
- # ○ \n -> 强制换行(大写无效;"\n[i]" 优先)
- # ○ \f -> 强制换页(大写无效)
- # ○ \NN[i] -> i号主角别名
- # ○ \PN[i] -> i号队员别名
- # ○ #{...} -> 花括弧以内的文字将作为 Ruby 脚本解析,替换成出现的文本
- # 千万不要在脚本中使用 "{" 、 "}"
- # ◎ 文章自动换行、排版
- # ○ 自动避免将特定的标点符号放在行首、行末。
- # ○ 通过将常量 "USE_ENGLISH_COMPOSITION" 设为 "true" 可启用英语排版。
- # 这时,将自动避免换行将单词切断。
- # ○ 通过脚本 "AutoNewline.turnOff" 和 "AutoNewline.turnOn"
- # 可切换自动换行的使用状态。
- # ○ 自动换行作用中,除 "\n" 之外的换行全部被无视。
- # ○ 和文字放大、缩小的控制符一起使用时会出现问题。
- # ◎ 滚动文章指令可作为常规文章使用
- # ○ enable_batch_text(face_name, face_index, background, position)
- # 下一个滚动文章指令变成常规文章指令。
- # 配合 "\n" "\f" 和自动换行使用,比连续配置的多个常规文章指令更为方便。
- # ◎ 事件页可设置脚本为出现条件
- # ○ 事件页的第一个指令若为备注,且备注的第一行是 "Condition:",
- # 则除第一行之外的部分将作为 Ruby 脚本解析,成为事件的出现条件。
- # 如有任何多余文字则设定无效。
- # ◎ 连续设置的多个选项将合并为一个选项
- # ◎ 可以为选项设置出现条件、合法性检查和帮助文本
- # ○ 在备注指令的第一行写上特定关键字来设定。如有任何多余文字则设定无效。
- # ○ 备注的第一行写上 "Potential:",则第二行开始将作为 Ruby
- # 脚本解析,成为该选项的出现条件。
- # ○ 备注的第一行写上 "Valid:",则第二行开始将作为 Ruby
- # 脚本解析,成为该选项的合法性检查。
- # ○ 备注的第一行写上 "Tooltip:",则第二行开始将作为选项的帮助文本。
- # ○ 这些备注块必须在选项效果的最开头连续地配置。中断点以来的设置无效。
- # ◎ 增加操作独立开关的脚本
- # ○ set_self_switch('A', map_id, event_id)
- # ○ get_self_switch('A', map_id, event_id)
- # Key 也可以设定为 'A' 'B' 'C' 'D' 之外的东西。
- # 若不指定地图ID,则会成为本地图的ID。
- # 若不指定事件ID,则会成为本事件的ID。
- # 适合与 "Condition:" 一同使用。
- # ◎ 重置变量、开关和私有开关的指令
- # ○ $game_variables.reset
- # ○ $game_switches.reset
- # ○ $game_self_switches.reset([map_id, [event_id]])
- # 若不指定地图ID,则会消除全部私有开关。
- # 若不指定事件ID,则会消除本地图的全部私有开关。
- # 通过 @map_id 和 @event_id 来限定本地图、本事件。
- # ◎ 像公共事件一般呼出其他事件页
- # ○ call_page(page_id, [event_id])
- # 若不指定事件ID,则会成为本事件的ID。
- # 无法呼出其他地图上的事件的事件页。
- # ◎ 下次的选项指令的位置改变
- # ○ set_choice_position(x, y, num_choices)
- # ◎ 设置下次输入数字时的最小值和最大值
- # ○ set_number_range(min, max)
- # ◎ 事件中任何脚本出错都不会关闭游戏,会弹窗提示事件、地图ID以及脚本内容。
- # ◎ 连续配置的脚本指令会合并为一个脚本指令,一起执行。
- #
- #==============================================================================
- #==============================================================================
- # ■ AutoNewline
- #------------------------------------------------------------------------------
- # 自動改行のモジュール。
- #==============================================================================
- module AutoNewline
- #--------------------------------------------------------------------------
- # ¤ 自動改行
- # デフォルトオフにしたいなら "false" に
- #--------------------------------------------------------------------------
- SWITCH = true
- #--------------------------------------------------------------------------
- # ¤ 英語組版
- #--------------------------------------------------------------------------
- # While Off:
- # > Hello, I'm Eric, a Rakdos Bers<
- # > erker. <
- #
- # While On:
- # > Hello, I'm Eric, a Rakdos <
- # > Berserker. <
- #--------------------------------------------------------------------------
- USE_ENGLISH_COMPOSITION = false
- #--------------------------------------------------------------------------
- # ¤ 自動改行使用中か
- #--------------------------------------------------------------------------
- def self.isTurnedOn
- return SWITCH
- end
- #--------------------------------------------------------------------------
- # ¤ 英語組版使用中か
- #--------------------------------------------------------------------------
- def self.useEnglishComposition
- return USE_ENGLISH_COMPOSITION
- end
- #--------------------------------------------------------------------------
- # ¤ 自動改行停止
- #--------------------------------------------------------------------------
- def self.turnOff
- self.const_set(:SWITCH, false)
- end
- #--------------------------------------------------------------------------
- # ¤ 自動改行再開
- #--------------------------------------------------------------------------
- def self.turnOn
- self.const_set(:SWITCH, true)
- end
- end
- #==============================================================================
- # □ Game_Message
- #==============================================================================
- class Game_Message
- #--------------------------------------------------------------------------
- # ¤ インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :next_choice_x # 次に選択肢ウィンドウを表示する場合のx
- attr_accessor :next_choice_y # 次に選択肢ウィンドウを表示する場合のy
- attr_accessor :choice_row_max # 次に選択肢ウィンドウを表示する場合の表示数
- attr_accessor :choice_validities # 選択肢の合法性
- attr_accessor :choice_tooltips # 選択肢の説明文章
- #--------------------------------------------------------------------------
- # ○ クリア
- #--------------------------------------------------------------------------
- alias clear_enhanced_text clear
- def clear
- clear_enhanced_text
- @next_choice_x = nil
- @next_choice_y = nil
- @choice_row_max = 6
- @choice_validities = []
- @choice_tooltips = {}
- end
- end
- #==============================================================================
- # □ Game_Event
- #==============================================================================
- class Game_Event
- #--------------------------------------------------------------------------
- # ○ イベントの出現条件の検察
- #--------------------------------------------------------------------------
- alias conditions_met_enhanced_text conditions_met?
- def conditions_met?(page)
- return false if !conditions_met_enhanced_text(page)
- if page.list[0].code == 108 && page.list[0].parameters[0] == "Condition:"
- pack = []
- i = 1
- while (page.list[i].code == 408)
- pack.push(@list[i].parameters[0])
- i += 1
- end
- string = pack.join("\n")
- begin
- s, v = $game_switches, $game_variables
- return eval(string)
- rescue
- msgbox "Error in Event Condition\n" +
- "Map: " + $game_map.display_name + " (" + @map_id.to_s + ")\n" +
- "Event: " + @event.name + " ("+ @id.to_s + ")\n\n" +
- "Script:\n" +
- string
- return true
- end
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ¤ イベントページの取得
- #--------------------------------------------------------------------------
- def get_page(index)
- @event.pages[index]
- end
- end
- #==============================================================================
- # □ Game_Interpreter
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ○ 余計なファイバー作成の防止
- #--------------------------------------------------------------------------
- alias create_fiber_enhanced_text create_fiber
- def create_fiber
- create_fiber_enhanced_text if @depth == 0
- end
- #--------------------------------------------------------------------------
- # ○ スクロール文章の表示
- #--------------------------------------------------------------------------
- alias command_105_enhanced_text command_105
- def command_105
- if @ehv_batch_text
- wait_for_message
- $game_message.face_name = @ehv_batch_text[0]
- $game_message.face_index = @ehv_batch_text[1]
- $game_message.background = @ehv_batch_text[2]
- $game_message.position = @ehv_batch_text[3]
- while next_event_code == 405
- @index += 1
- $game_message.add(@list[@index].parameters[0])
- end
- case next_event_code
- when 102
- @index += 1
- setup_choices(@list[@index].parameters)
- when 103
- @index += 1
- setup_num_input(@list[@index].parameters)
- when 104
- @index += 1
- setup_item_choice(@list[@index].parameters)
- end
- wait_for_message
- @ehv_batch_text = nil
- else
- command_105_enhanced_text
- end
- end
- #--------------------------------------------------------------------------
- # ● スクリプト
- #--------------------------------------------------------------------------
- def command_355
- pack = [@list[@index].parameters[0]]
- while next_event_code == 355 || next_event_code == 655
- @index += 1
- pack.push(@list[@index].parameters[0])
- end
- script = pack.join("\n")
- begin
- s, v = $game_switches, $game_variables
- eval(script)
- rescue
- msgbox "Error in Script:\n" +
- "Map: #{@map_id}\nEvent: #{@event_id}\n\nScript: #{script}"
- end
- end
- #--------------------------------------------------------------------------
- # ○ 変数の設定
- #--------------------------------------------------------------------------
- alias command_122_enhanced_text command_122
- def command_122
- if @params[3] == 4
- value = nil
- begin
- s, v = $game_switches, $game_variables
- value = eval(@params[4])
- rescue
- msgbox "Error Setting Variable with Script:\n" +
- "Map: #{@map_id}\nEvent: #{@event_id}\n\nScript: #{@params[4]}"
- return
- end
- (@params[0]..@params[1]).each {|i| operate_variable(i, @params[2], value) }
- else
- command_122_enhanced_text
- end
- end
- #--------------------------------------------------------------------------
- # ○ 条件分岐
- #--------------------------------------------------------------------------
- alias command_111_enhanced_text command_111
- def command_111
- if @params[0] == 12
- result = false
- begin
- s, v = $game_switches, $game_variables
- result = eval(@params[1])
- rescue
- msgbox "Error Checking Condition Branch Script:\n" +
- "Map: #{@map_id}\nEvent: #{@event_id}\n\nScript: #{@params[1]}"
- result = false
- end
- @branch[@indent] = result
- command_skip unless @branch[@indent]
- else
- command_111_enhanced_text
- end
- end
- #--------------------------------------------------------------------------
- # ● 条件分岐終了
- #--------------------------------------------------------------------------
- def command_404
- if next_event_code == 102
- @branch[@indent] -= 5 if @branch.include?(@indent)
- @index += 1
- command_skip
- end
- end
- #--------------------------------------------------------------------------
- # ● 選択肢のセットアップ
- #--------------------------------------------------------------------------
- def setup_choices(params)
- result = []
- iterativelyPushChoices(params, @index, result)
- if !$game_message.choices.empty?
- ci = result.index($game_message.choice_cancel_type - 1)
- $game_message.choice_validities.push(!ci || $game_message.choice_validities[ci])
- result.push($game_message.choice_cancel_type - 1)
- $game_message.choice_proc = Proc.new {|n| @branch[@indent] = result[n] }
- else
- @branch[@indent] = -1
- end
- end
- #--------------------------------------------------------------------------
- # ¤ 選択肢追加の繰り返し
- #--------------------------------------------------------------------------
- def iterativelyPushChoices(params, i, result, d = 0)
- visibilities = []
- num_choice_added = 0
- indent = @list[i].indent
- loop do
- i += 1
- if @list[i].indent == indent
- case @list[i].code
- when 402
- if isChoiceVisible(i + 1)
- visibilities.push(true)
- loadChoiceConditionTooltip(result.size + num_choice_added, i + 1)
- num_choice_added += 1
- else
- visibilities.push(false)
- end
- when 404
- break
- end
- end
- end
- params[0].each_with_index do |s, n|
- if visibilities[n]
- $game_message.choices.push(s)
- result.push(n + d)
- end
- end
- if params[1] == 5 || (params[1] > 0 && result.include?(params[1] - 1 + d))
- $game_message.choice_cancel_type = params[1] + d
- end
- i += 1
- iterativelyPushChoices(@list[i].parameters, i, result, d + 5) if @list[i].code == 102
- end
- #--------------------------------------------------------------------------
- # ¤ 選択肢の表示条件のチェック
- #--------------------------------------------------------------------------
- def isChoiceVisible(i)
- flag = false
- pack = []
- while (@list[i].code == 108 || @list[i].code == 408)
- if @list[i].code == 108
- break if flag
- header = @list[i].parameters[0]
- if header == "Potential:"
- flag = true
- elsif header == "Valid:"
- elsif header == "Tooltip:"
- else
- break
- end
- else
- pack.push(@list[i].parameters[0]) if flag
- end
- i += 1
- end
- return true if pack.empty?
- string = pack.join("\n")
- begin
- s, v = $game_switches, $game_variables
- return eval(string) ? true : false
- rescue
- msgbox "Error in Option Condition:\n#{string}"
- return true
- end
- end
- #--------------------------------------------------------------------------
- # ¤ 選択肢の有効状態のチェック及び説明文章の取得
- #--------------------------------------------------------------------------
- def loadChoiceConditionTooltip(index_of_choice, i)
- loadable = [ true, true ]
- comments = [ [], [] ]
- index = -1
- while (@list[i].code == 108 || @list[i].code == 408)
- if @list[i].code == 108
- loadable[index] = false if index >= 0
- index = -1
- header = @list[i].parameters[0]
- if header == "Potential:"
- elsif header == "Valid:"
- index = 0 if loadable[0]
- elsif header == "Tooltip:"
- index = 1 if loadable[1]
- else
- break
- end
- else
- comments[index].push(@list[i].parameters[0]) if loadable[index]
- end
- i += 1
- end
- comments.each_with_index do |pack, j|
- if j == 0
- if pack.empty?
- $game_message.choice_validities[index_of_choice] = true
- else
- string = pack.join("\n")
- begin
- s, v = $game_switches, $game_variables
- $game_message.choice_validities[index_of_choice] = eval(string) ? true : false
- rescue
- msgbox "Error in Option Condition:\n#{string}"
- $game_message.choice_validities[index_of_choice] = true
- end
- end
- elsif j == 1
- $game_message.choice_tooltips[index_of_choice] = pack.clone if !pack.empty?
- end
- end
- end
- #--------------------------------------------------------------------------
- # ¤ スクリプト:セルフスイッチセッター
- #--------------------------------------------------------------------------
- def set_self_switch(key, status, map_id = @map_id, event_id = @event_id)
- begin
- $game_self_switches[[map_id, event_id, key]] = status ? true : false
- rescue
- msgbox "Error Setting Self Switch:\n" +
- "Map: #{map_id}\nEvent: #{event_id}\nKey: #{key}\nStatus: #{status}"
- end
- end
- #--------------------------------------------------------------------------
- # ¤ スクリプト:セルフスイッチゲッター
- #--------------------------------------------------------------------------
- def get_self_switch(key, map_id = @map_id, event_id = @event_id)
- begin
- return $game_self_switches[[map_id, event_id, key]] ? true : false
- rescue
- msgbox "Error Checking Self Switch:\n" +
- "Map: #{map_id}\nEvent: #{event_id}\nKey: #{key}"
- return false
- end
- end
- #--------------------------------------------------------------------------
- # ¤ スクリプト:選択肢位置を一時的に調整する
- #--------------------------------------------------------------------------
- def set_choice_position(x, y, count = 99)
- $game_message.next_choice_x = x
- $game_message.next_choice_y = y
- $game_message.choice_row_max = count
- end
- #--------------------------------------------------------------------------
- # ¤ スクリプト:別のページを呼び出す
- # param : -1 ならプレイヤー、0 ならこのイベント、それ以外はイベント ID
- #--------------------------------------------------------------------------
- def call_page(index, param = 0)
- event = get_character(param)
- page = event ? event.get_page(index - 1) : nil
- if page
- child = Game_Interpreter.new(@depth + 1)
- child.setup(page.list, same_map? ? @event_id : 0)
- child.run
- end
- end
- #--------------------------------------------------------------------------
- # ¤ スクリプト:次回数字入力時の最小値と最大値の設定
- #--------------------------------------------------------------------------
- def set_number_range(min, max)
- Window_NumberInput.setRange(min, max)
- end
- #--------------------------------------------------------------------------
- # ¤ スクリプト:次のスクロール文章を通常文章とする
- #--------------------------------------------------------------------------
- def enable_batch_text(face_name, face_index, background, position)
- @ehv_batch_text = [ face_name, face_index, background, position ]
- end
- end
- #==============================================================================
- # □ Game_Switches
- #==============================================================================
- class Game_Switches
- #--------------------------------------------------------------------------
- # ¤ リセット
- #--------------------------------------------------------------------------
- def reset
- @data = []
- on_change
- end
- #--------------------------------------------------------------------------
- # ● 設定する
- #--------------------------------------------------------------------------
- def []=(switch_id, value)
- @data[switch_id] = value ? true : nil
- on_change
- end
- end
- #==============================================================================
- # □ Game_Variables
- #==============================================================================
- class Game_Variables
- #--------------------------------------------------------------------------
- # ¤ リセット
- #--------------------------------------------------------------------------
- def reset
- @data = []
- on_change
- end
- #--------------------------------------------------------------------------
- # ● 設定する
- #--------------------------------------------------------------------------
- def []=(variable_id, value)
- @data[variable_id] = value != 0 ? value : nil
- on_change
- end
- end
- #==============================================================================
- # □ Game_SelfSwitches
- #==============================================================================
- class Game_SelfSwitches
- #--------------------------------------------------------------------------
- # ¤ リセット
- #--------------------------------------------------------------------------
- def reset(map_id = nil, event_id = nil)
- if map_id
- @data.keys.each do |key|
- @data.delete(key) if key[1] == map_id &&
- (!event_id || key[2] == event_id)
- end
- else
- @data = {}
- end
- on_change
- end
- #--------------------------------------------------------------------------
- # ● 設定する
- #--------------------------------------------------------------------------
- def []=(key, value)
- if value
- @data[key] = true
- else
- @data.delete(key)
- end
- on_change
- end
- end
- #==============================================================================
- # □ Window_Base
- #==============================================================================
- class Window_Base
- #--------------------------------------------------------------------------
- # ¤ クラス定数
- #--------------------------------------------------------------------------
- # 行頭に置く事ができない文字
- NO_LINE_HEAD = [")", "]", "}", ">", "」", "』", "】", "〉", "》", "〕", "’", "”",
- ",", "、", "。", "?", "!", ";", ":",
- "ぁ", "ぃ", "ぅ", "ぇ", "ぉ", "ゃ", "ゅ", "ょ", "ゎ", "ー",
- "ァ", "ィ", "ゥ", "ェ", "ォ", "ャ", "ュ", "ョ", "ヮ"]
- # 行末に置く事ができない文字
- NO_LINE_END = ["(", "[", "{", "<", "「", "『", "【", "〈", "《", "〔", "‘", "“"]
- # 改行で分断できない両文字組
- NO_BREAKING = ["——", "……"]
- #--------------------------------------------------------------------------
- # ● 制御文字の事前変換
- #--------------------------------------------------------------------------
- def convert_escape_characters(text)
- result = text.to_s.clone
- result.gsub!(/\r\n/) { "\n" }
- result.gsub!(/\\/) { "\e" }
- result.gsub!(/\e\e/) { "\\" }
- result.gsub!(/\#\{([^{}]+)\}/i) { evalScriptedText($1) }
- 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!(/\eNN\[(\d+)\]/i) { actorNickname($1.to_i) }
- result.gsub!(/\ePN\[(\d+)\]/i) { memberNickname($1.to_i) }
- result.gsub!(/\eG/i) { Vocab::currency_unit }
- if AutoNewline.isTurnedOn && AutoNewline.useEnglishComposition
- result.gsub!(/[\n\f]/) { " " }
- result.gsub!(/\en/) { "\n" }
- result.gsub!(/\ef/) { "\f" }
- return applyEnglishComposition(result, contents.width - self.new_line_x)
- else
- result.gsub!(/[\n\f]/) { "" } if AutoNewline.isTurnedOn
- result.gsub!(/\en/) { "\n" }
- result.gsub!(/\ef/) { "\f" }
- return result
- end
- end
- #--------------------------------------------------------------------------
- # ¤ 英語組版を適用
- #--------------------------------------------------------------------------
- def applyEnglishComposition(text, width)
- pages = text.split("\f")
- pages.each_with_index do |page, i_page|
- lines = page.split("\n")
- lines.each_with_index do |line, i_line|
- local_width = width
- line_break_positions = {}
- words = line.split(" ")
- words.each_with_index do |word, i_word|
- word_width = widthOfWord(word)
- if local_width < word_width
- line_break_positions[i_word] = true
- local_width = width
- end
- local_width -= word_width
- local_width -= contents.text_size(" ").width
- end
- lines[i_line] = ""
- words.each_with_index do |word, i_word|
- lines[i_line] += word
- if i_word < words.size - 1
- if line_break_positions[i_word + 1]
- lines[i_line] += "\n"
- else
- lines[i_line] += " "
- end
- end
- end
- end
- pages[i_page] = lines.join("\n")
- end
- return pages.join("\f")
- end
- #--------------------------------------------------------------------------
- # ¤ 制御符を取り除いた文字幅
- #--------------------------------------------------------------------------
- def widthOfWord(word)
- word_width = 0
- word2 = word.dup
- word2.gsub!(/\eI\[\d+\]/) { word_width += 24; next nil }
- word2.gsub!(/\e[^Ii]\[[^\[\]]+\]/)
- word2.gsub!(/\e./)
- word_width += contents.text_size(word2).width
- return word_width
- end
- #--------------------------------------------------------------------------
- # ● 文字の処理
- #--------------------------------------------------------------------------
- def process_character(c, text, pos)
- case c
- when "\n"
- process_new_line(text, pos)
- when "\f"
- process_new_page(text, pos)
- when "\e"
- process_escape_character(obtain_escape_code(text), text, pos)
- else
- if AutoNewline.isTurnedOn && !AutoNewline.useEnglishComposition
- preNormalCharCheckLinebreak(c, pos, text.empty? ? nil : text[0, 1])
- end
- process_normal_character(c, pos)
- end
- end
- #--------------------------------------------------------------------------
- # ¤ 通常文字の処理(自動改行)
- #--------------------------------------------------------------------------
- def preNormalCharCheckLinebreak(c_next, pos, c_future = nil)
- prev_width = pos[:x]
- if prev_width >= contents.width
- process_new_line(c_next, pos)
- else
- next_width = prev_width + contents.text_size(c_next).width
- if next_width >= contents.width ||
- (c_future && next_width + contents.text_size(c_future).width >= contents.width &&
- (NO_LINE_END.include?(c_next) ||
- NO_LINE_HEAD.include?(c_future) ||
- NO_BREAKING.include?(c_next + c_future)))
- process_new_line(c_next, pos)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ¤ 制御文字 #{...} の処理
- #--------------------------------------------------------------------------
- def evalScriptedText(str)
- begin
- s, v = $game_switches, $game_variables
- return eval(str)
- rescue
- msgbox "Error Converting Script to String:\n" +
- "Map: #{@map_id}\nEvent: #{@event_id}\n\nScript: \#\{#{str}\}"
- return "<ERROR>"
- end
- end
- #--------------------------------------------------------------------------
- # ¤ アクターの二つ名
- #--------------------------------------------------------------------------
- def actorNickname(n)
- actor = n >= 1 ? $game_actors[n] : nil
- actor ? actor.nickname : ""
- end
- #--------------------------------------------------------------------------
- # ¤ パティーメンバーの二つ名
- #--------------------------------------------------------------------------
- def memberNickname(n)
- actor = n >= 1 ? $game_party.members[n-1] : nil
- actor ? actor.nickname : ""
- end
- #--------------------------------------------------------------------------
- # ▽ 改行位置の取得 (Window_Message に上書きられ)
- #--------------------------------------------------------------------------
- def new_line_x
- return 0
- end
- end
- #==============================================================================
- # □ Window_Message
- #==============================================================================
- class Window_Message
- #--------------------------------------------------------------------------
- # ● 改行文字の処理
- #--------------------------------------------------------------------------
- def process_new_line(text, pos)
- @line_show_fast = false
- super
- if need_new_page?(text, pos)
- input_pause
- new_page(text, pos, true)
- end
- end
- #--------------------------------------------------------------------------
- # ○ 改ページ処理
- #--------------------------------------------------------------------------
- alias new_page_enhanced_text new_page
- def new_page(text, pos, keep_font_settings = nil)
- @keep_font_settings = keep_font_settings
- new_page_enhanced_text(text, pos)
- @keep_font_settings = nil
- end
- #--------------------------------------------------------------------------
- # ○ フォント設定のリセット
- #--------------------------------------------------------------------------
- alias reset_font_settings_enhanced_text reset_font_settings
- def reset_font_settings
- return if @keep_font_settings
- reset_font_settings_enhanced_text
- end
- #--------------------------------------------------------------------------
- # ¤ 説明文章を強行クリア
- #--------------------------------------------------------------------------
- def forceClear
- @gold_window.close
- @fiber = nil
- close
- end
- #--------------------------------------------------------------------------
- # ¤ 説明文章を早送りにする
- #--------------------------------------------------------------------------
- def forceShowFast
- @show_fast = true
- end
- end
- #==============================================================================
- # □ Window_ChoiceList
- #==============================================================================
- class Window_ChoiceList
- #--------------------------------------------------------------------------
- # ● 入力処理の開始
- #--------------------------------------------------------------------------
- def start
- return unless close?
- update_placement
- refresh
- select(-1)
- open
- activate
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウ位置の更新
- #--------------------------------------------------------------------------
- def update_placement
- self.width = [max_choice_width + 12, 96].max + padding * 2
- self.width = [width, Graphics.width].min
- h1 = fitting_height($game_message.choices.size)
- h2 = fitting_height($game_message.choice_row_max)
- self.height = h1 < h2 ? h1 : h2
- self.x = $game_message.next_choice_x ? $game_message.next_choice_x : Graphics.width - width
- if $game_message.next_choice_y
- self.y = $game_message.next_choice_y
- else
- if @message_window.y >= Graphics.height / 2
- self.y = @message_window.y - height
- else
- self.y = @message_window.y + @message_window.height
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● コマンドリストの作成
- #--------------------------------------------------------------------------
- def make_command_list
- $game_message.choices.each_with_index do |choice, i|
- add_command(choice, :choice, $game_message.choice_validities[i])
- end
- end
- #--------------------------------------------------------------------------
- # ○ 項目の描画
- #--------------------------------------------------------------------------
- alias draw_item_enhanced_text draw_item
- def draw_item(index)
- @choice_enabled = command_enabled?(index)
- draw_item_enhanced_text(index)
- end
- #--------------------------------------------------------------------------
- # ▲ テキスト描画色の変更
- #--------------------------------------------------------------------------
- def change_color(color, enabled = true)
- super(color, enabled && @choice_enabled)
- end
- #--------------------------------------------------------------------------
- # ▲ キャンセルボタンが押されたときの処理
- #--------------------------------------------------------------------------
- def process_cancel
- if $game_message.choice_validities[item_max]
- super
- else
- Sound.play_buzzer
- end
- end
- #--------------------------------------------------------------------------
- # ● キャンセルハンドラの呼び出し
- #--------------------------------------------------------------------------
- def call_cancel_handler
- $game_message.choice_proc.call(item_max)
- close
- end
- #--------------------------------------------------------------------------
- # ▲ 閉じる
- #--------------------------------------------------------------------------
- def close
- @message_window.forceShowFast unless $game_message.choice_tooltips.empty?
- super
- end
- #--------------------------------------------------------------------------
- # ▲ ヘルプウィンドウ更新メソッドの呼び出し
- #--------------------------------------------------------------------------
- def call_update_help
- update_help if active && !$game_message.choice_tooltips.empty?
- end
- #--------------------------------------------------------------------------
- # ▲ ヘルプウィンドウの更新
- #--------------------------------------------------------------------------
- def update_help
- @message_window.forceClear
- if $game_message.choice_tooltips.include?(index)
- $game_message.texts.replace($game_message.choice_tooltips[index])
- else
- $game_message.texts.clear
- end
- end
- #--------------------------------------------------------------------------
- # △ カーソルを上に移動
- #--------------------------------------------------------------------------
- alias cursor_up_enhanced_text cursor_up
- def cursor_up(wrap = false)
- @index = 0 if @index == -1
- cursor_up_enhanced_text(wrap)
- end
- #--------------------------------------------------------------------------
- # △ 決定ボタンが押されたときの処理
- #--------------------------------------------------------------------------
- alias process_ok_enhanced_text process_ok
- def process_ok
- return if self.index == -1
- process_ok_enhanced_text()
- end
- end
- #==============================================================================
- # □ Window_NumberInput
- #==============================================================================
- class Window_NumberInput
- #--------------------------------------------------------------------------
- # ○ リフレッシュ
- #--------------------------------------------------------------------------
- alias refresh_unmodified refresh
- def refresh
- @number = @@min if @@min && @number < @@min
- @number = @@max if @@max && @number > @@max
- refresh_unmodified
- end
- #--------------------------------------------------------------------------
- # ○ 決定ボタンが押されたときの処理
- #--------------------------------------------------------------------------
- alias process_ok_unmodified process_ok
- def process_ok
- @@min = nil
- @@max = nil
- process_ok_unmodified
- end
- #--------------------------------------------------------------------------
- # ¤ 最小値と最大値の設定
- #--------------------------------------------------------------------------
- def self.setRange(min, max)
- min = 0 if min < 0
- max = 0 if max < 0
- max = min if min > max
- @@min = min
- @@max = max
- end
- end
复制代码 |
|