| 赞 | 2 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2020-7-27 |
| 在线时间 | 1379 小时 |
- 梦石
- 0
- 星屑
- 76
- 在线时间
- 1379 小时
- 注册时间
- 2012-7-5
- 回帖
- 1643

|
发表于 2014-8-16 14:16:14
|
显示全部楼层
食用姿势 :
- 事件-注释> 選択肢[3]:选项1|选项2 (3代表将窗口放中间)
- 事件-条件分歧> 变量0001 == 1 (选了选项1的情况)
我才不会说这个脚本是魔女之家里面的呢
以及这个脚本有很多强大的功能, 希望有人有空汉化一下
脚本在这里- #==============================================================================
- #
- # ■選択肢機能拡張 □Ver.3.21 □製作者:月紳士
- #
- # ・RPGツクールVX用 RGSS2スクリプト
- #
- # ●…書き換えメソッド(競合注意) ◎…メソッドのエイリアス ○…新規メソッド
- #
- # ※二次配布禁止!配布元には利用規約があります。必ずそちらを見てください。
- #------------------------------------------------------------------------------
- # 更新履歴
- # Ver3.21 ○選択肢準備直下の追加選択肢使用時の挙動修正。
- # ○場所移動とフェードアウト使用時に関する動作の修正。
- #==============================================================================
- =begin
- このスクリプトでは主に以下の事が出来る様になります。
- ○ 5項目以上の選択肢を表示することが出来るようになります。
- ※5項目以上の選択肢はアイテム欄などのように
- ウインドウ内のスクロールにて表示されます。
- ○ メッセージウインドウとは別枠で表示される
- 特別な選択肢を表示することが出来ます。
- ○ 現在のパーティーを対象とするような動的な選択肢を作ることができます。
-
- ※ Ver.3.00よりダミーアクター機能が別スクリプトとなりました。
- Ver.3.00以前の物と同様の使い方をするには別途
- ダミーアクター・スクリプトの導入が必要です。
- 詳しい設定の仕方はマニュアルをご覧ください。
- =end
- #==============================================================================
- # □ 選択肢機能拡張・モジュール(カスタマイズ項目)
- #==============================================================================
- module Expansion_Choices
- CHOICE_RESUIT_VARIABLES = 1
- # 選択肢を選んだ結果を納める変数を指定します。
- # プレイヤーが選んだ選択肢の項目番号が、この番号の変数へ納められます。
-
- TARGET_ACTOR_ID_VARIABLES = 2
- # アクターを対象にした選択肢の結果を納める変数を指定します。
- # 選んだアクターのID番号が、この番号の変数へ納められます。
- # (ダミーアクター・スクリプト併用時は
- # ダミーアクター・スクリプトのACTOR_ID_VARIABLESと
- # 揃えることを推奨します。)
-
-
- EX_CHOICES_DELAY = 25
- # 別枠選択肢が表示されてから、決定・キャンセル入力を受け付けるまでの
- # 延滞時間をフレーム数で設定します。
-
- end
- #==============================================================================
- # □ Game_Choices
- #------------------------------------------------------------------------------
- # 特殊選択肢の情報を管理するクラスです。
- #==============================================================================
- class Game_Choices
- #--------------------------------------------------------------------------
- # ○ 定数
- #--------------------------------------------------------------------------
- CHOICE_V = Expansion_Choices::CHOICE_RESUIT_VARIABLES
- TARGET_V = Expansion_Choices::TARGET_ACTOR_ID_VARIABLES
- #--------------------------------------------------------------------------
- # ○ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :choices # 選択肢
- attr_accessor :actor_id # アクターID
- attr_accessor :help_text # 選択肢ヘルプテキスト
- attr_accessor :window_type # 表示ウインドウタイプ
- attr_accessor :column # 選択肢の横ならび表示
- attr_accessor :cancel_type # キャンセル時項目
- attr_accessor :choice_cancel # 選択肢が一つの際の自動選択
- attr_accessor :choice_show_fast # 選択肢を一度に線画
- attr_accessor :choices_check # 選択肢チェック
- attr_accessor :choices_ready # 選択肢準備
- attr_accessor :can_not_select # 選択不能の選択肢
- attr_accessor :choice_hide # 隠す選択肢
- attr_accessor :icon # 選択肢アイコン
- attr_accessor :price # 選択肢価格
- attr_accessor :pick_up # ピックアップする選択肢
- attr_accessor :pick_up_result # ピックアップ結果を残すグループ(ID)
- attr_accessor :pick_up_limit # ピックアップ数
- attr_accessor :pick_up_canstop # ピックアップの中断許可
- attr_accessor :face_name # フェイス画像ファイル名
- attr_accessor :face_index # フェイス画像インデックス
- attr_accessor :re_face # フェイス画像の逆位置表示
- #--------------------------------------------------------------------------
- # ○ オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- clear
- end
- #--------------------------------------------------------------------------
- # ○ クリア
- #--------------------------------------------------------------------------
- def clear
- @cancel_type = -1
- @choices = []
- @actor_id = []
- @help_text = []
- @window_type = -1
- @column = false
- @choice_cancel = false
- @choice_show_fast = false
- @choices_check = false
- @choices_ready = false
- @can_not_select = []
- @choice_hide = []
- @icon = []
- @price = []
- @pick_up = nil
- @pick_up_result = 0
- @pick_up_limit = 0
- @pick_up_canstop = false
- @face_name = ""
- @face_index = 0
- @re_face = false
- @item_name_memory = false
- end
- #--------------------------------------------------------------------------
- # ○ アクター選択肢か?
- #--------------------------------------------------------------------------
- def actor_choice?
- return false if @actor_id.empty?
- return true
- end
- #--------------------------------------------------------------------------
- # ○ 表示すべき選択肢項目のインデックス取得
- #--------------------------------------------------------------------------
- def display_item_index
- array = []
- @choices.size.times do |i|
- next if @choice_hide.include?(i)
- next if @pick_up and @pick_up.include?(i)
- array.push(i)
- end
- return array
- end
- #--------------------------------------------------------------------------
- # ○ 表示すべき選択肢項目の取得
- #--------------------------------------------------------------------------
- def item
- array = []
- display_item_index.each{|i|array.push(@choices[i])}
- return array
- end
- #--------------------------------------------------------------------------
- # ○ 表示すべき選択肢の項目数
- #--------------------------------------------------------------------------
- def size
- return display_item_index.size
- end
- #--------------------------------------------------------------------------
- # ○ 選択可能な選択肢項目のインデックス取得
- #--------------------------------------------------------------------------
- def active_item_index
- array = []
- @choices.size.times do |i|
- next if @choice_hide.include?(i)
- next if @pick_up and @pick_up.include?(i)
- next if @can_not_select.include?(i)
- array.push(i)
- end
- return array
- end
- #--------------------------------------------------------------------------
- # ○ 選択不可項目のインデックス取得(非表示項目を除外して再編)
- #--------------------------------------------------------------------------
- def can_not_select_active
- array = []
- n = 0
- @choices.size.times do |i|
- next if @choice_hide.include?(i)
- next if @pick_up and @pick_up.include?(i)
- array.push(n) if @can_not_select.include?(i)
- n += 1
- end
- return array
- end
- #--------------------------------------------------------------------------
- # ○ 選択時コールバックの設定
- #--------------------------------------------------------------------------
- def proc
- choice_proc = Proc.new{|n|
- if n < 0 # 拡張選択肢キャンセル時(の特殊な返り値)の場合
- if @cancel_type == -1 # キャンセル項目未設定
- $game_variables[CHOICE_V] = 0
- else # キャンセル項目指定あり
- $game_variables[CHOICE_V] = @cancel_type
- $game_variables[TARGET_V] = @actor_id[@cancel_type-1] if actor_choice?
- end
- else
- index = display_item_index[n]
- $game_variables[CHOICE_V] = index + 1
- $game_variables[TARGET_V] = @actor_id[index] if actor_choice?
- $game_temp.last_select_choice = @choices[index] if @item_name_memory
- end
- }
- return choice_proc
- end
- #--------------------------------------------------------------------------
- # ○ テキストからのオプション取得
- #--------------------------------------------------------------------------
- def get_option(text)
- @column = true if /[\##]/i =~ text # 選択肢の横ならび表示の取得
- @item_name_memory = true if /[\@@]/i =~ text # 選択項目名の記憶
- @choice_cancel = true if /[\'’]/ =~ text # 選択肢が一つの際の自動選択
- @choice_show_fast = true if /[\>>]/ =~ text # 選択肢を一度に線画
- if /\[(\d+)\]/ =~ text # ウインドウタイプの取得
- @window_type = $1.to_i
- else
- @window_type = -1
- end
- if /[\((](\d+)[\))]/ =~ text # キャンセル時項目の取得
- @cancel_type = $1.to_i
- elsif /[\((][\**][\))]/ =~ text # キャンセル不能の取得
- @cancel_type = 0
- else
- @cancel_type = -1
- end
- if /face\{(\w+)\/([0-7])\}/i =~ text
- @face_name = $1
- @face_index = $2.to_i
- if /re_face\{/i =~ text
- @re_face = true
- end
- elsif /face\{top_actor\}/i =~ text
- actor = $game_party.members[0]
- @face_name = actor.face_name
- @face_index = actor.face_index
- if /re_face\{/i =~ text
- @re_face = true
- end
- end
- end
- #--------------------------------------------------------------------------
- # ○ テキストから自由選択肢を生成
- #--------------------------------------------------------------------------
- def create_free_choices(text)
- choices = text.split(/[\|\s]/)
- choices.delete("")
- for i in choices
- i.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
- i.gsub!(/\<cns\>/i, "")
- if $&
- @can_not_select.push(@choices.size)
- end
- i.gsub!(/\<ch\>/i, "")
- if $&
- @choice_hide.push(@choices.size)
- end
- i.gsub!(/\\i\[([0-9]+)\]/i, "")
- if $&
- @icon[@choices.size] = $1.to_i
- end
- i.gsub!(/\\g\[([0-9]+)\]/i, "")
- if $&
- @price[@choices.size] = $1.to_i
- end
- @choices.push(i)
- end
- end
- #--------------------------------------------------------------------------
- # ○ テキストからヘルプを生成
- #--------------------------------------------------------------------------
- def set_help(text, index = nil)
- if index
- @help_text[index] = text
- else
- @help_text.push(text)
- end
- end
- #--------------------------------------------------------------------------
- # ○ アクター選択肢の調整
- #--------------------------------------------------------------------------
- def actor_choice_addition(addition_type, addition_id, icon_index = nil)
- return unless actor_choice?
- if addition_type == 1 or addition_type == 3
- addition_id = @actor_id - addition_id
- end
- for i in addition_id.compact
- ind = @actor_id.index(i)
- next if ind.nil?
- case addition_type
- when 0, 1
- @can_not_select.push(ind)
- when 2, 3
- @choice_hide.push(ind)
- when 4
- @icon[ind] = icon_index
- end
- end
- end
- end
- #==============================================================================
- # ■ Game_Temp
- #------------------------------------------------------------------------------
- # セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン
- # スタンスは $game_temp で参照されます。
- #==============================================================================
- class Game_Temp
- #--------------------------------------------------------------------------
- # ○ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :choices
- attr_accessor :last_select_choice
- #--------------------------------------------------------------------------
- # ◎ オブジェクト初期化
- #--------------------------------------------------------------------------
- alias tig_ec_initialize initialize
- def initialize
- tig_ec_initialize
- @choices = Game_Choices.new
- @last_select_choice = ""
- end
- end
- #==============================================================================
- # ■ Game_Message
- #------------------------------------------------------------------------------
- # 文章や選択肢などを表示するメッセージウィンドウの状態を扱うクラスです。この
- # クラスのインスタンスは $game_message で参照されます。
- #==============================================================================
- class Game_Message
- #--------------------------------------------------------------------------
- # ○ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :can_not_select # 選択禁止するindex
- attr_accessor :last_face_name # face_name 履歴
- attr_accessor :last_face_index # face_index 履歴
- attr_accessor :last_background # background 履歴
- attr_accessor :last_position # position 履歴
- attr_accessor :cancel_input # 文章送り時 キャンセル取得するか?
- attr_accessor :show_ex_choices
- #--------------------------------------------------------------------------
- # ◎ クリア
- #--------------------------------------------------------------------------
- alias tig_ec_clear clear
- def clear
- tig_ec_clear
- @cancel_input = false
- @can_not_select = []
- @show_ex_choices = nil
- end
- end
- #==============================================================================
- # ■ Game_Party
- #------------------------------------------------------------------------------
- # パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク
- # ラスのインスタンスは $game_party で参照されます。
- #==========================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # ○ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :group # アクターIDグループ
- attr_accessor :reserve_choice_id # 選択アクターの予備
- #--------------------------------------------------------------------------
- # ○ パーティーが最大人数に達しているか?
- #--------------------------------------------------------------------------
- def max?
- return @actors.size >= MAX_MEMBERS
- end
- end
- #==============================================================================
- # ■ Game_Event
- #------------------------------------------------------------------------------
- # イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
- # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
- #==============================================================================
- class Game_Event < Game_Character
- #--------------------------------------------------------------------------
- # ◎ イベントページの条件合致判定
- #--------------------------------------------------------------------------
- alias tig_ec_conditions_met? conditions_met?
- def conditions_met?(page)
- c = page.condition
- if c.actor_valid and c.variable_valid and
- c.variable_id == Expansion_Choices::CHOICE_RESUIT_VARIABLES
- return $game_party.group[c.variable_value].include?(c.actor_id)
- end
- return tig_ec_conditions_met?(page)
- end
- end
- #==============================================================================
- # ■ Game_Interpreter
- #------------------------------------------------------------------------------
- # イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
- # Game_Troop クラス、Game_Event クラスの内部で使用されます。
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ○ 定数
- #--------------------------------------------------------------------------
- MAX_LINE = 4 # メッセージウインドウの最大行数
-
- CHOICE_V = Expansion_Choices::CHOICE_RESUIT_VARIABLES
- TARGET_V = Expansion_Choices::TARGET_ACTOR_ID_VARIABLES
- #--------------------------------------------------------------------------
- # ◎ クリア
- #--------------------------------------------------------------------------
- alias tig_ec_clear clear
- def clear
- tig_ec_clear
- $game_message.last_face_name = ""
- $game_message.last_face_index = 0
- $game_message.last_background = 0
- $game_message.last_position = 2
- if $game_party.group.nil?
- $game_party.group = [[], [], [], [], [], []] # index0~5をあらかじめ初期化
- end
- $game_party.reserve_choice_id = 1
- end
- #--------------------------------------------------------------------------
- # ◎ 選択肢のセットアップ
- #--------------------------------------------------------------------------
- alias tig_ec_setup_choices setup_choices
- def setup_choices(params)
- $game_temp.choices.clear
- tig_ec_setup_choices(params)
- end
- #--------------------------------------------------------------------------
- # ○ 特殊選択肢か?
- #--------------------------------------------------------------------------
- def expansion_choice?(index = nil)
- index = @index unless index
- return false if @list[index].code != 108
- return /\A選択肢/ =~ @list[index].parameters[0]
- end
- #--------------------------------------------------------------------------
- # ◎ イベントコマンドの実行
- # ※ 拡張選択肢の実行と特殊コマンドの実行処理の割り込み
- #--------------------------------------------------------------------------
- alias tig_ec_execute_command execute_command
- def execute_command
- if @index >= @list.size-1
- command_end
- return true
- else
- if expansion_choice?
- return setup_expansion_choice
- elsif choices_command
- return true
- end
- end
- return tig_ec_execute_command
- end
- #--------------------------------------------------------------------------
- # ◎ メッセージ待機中フラグおよびコールバックの設定
- # ※ 文章に続けて選択肢を表示する時の為に拡張選択肢の処理を割り込ませる
- #--------------------------------------------------------------------------
- alias tig_ec_set_message_waiting set_message_waiting
- def set_message_waiting
- unless $game_message.texts.size == 0
- unless @list[(@index - 1)].code == 102 or @list[(@index - 1)].code == 103
- setup_expansion_choice if expansion_choice?
- end
- end
-
- tig_ec_set_message_waiting
- end
- #--------------------------------------------------------------------------
- # ○ 特殊選択肢のセットアップへの処理振り分け
- #--------------------------------------------------------------------------
- def setup_expansion_choice
- text = @list[@index].parameters[0]
- if /\A選択肢開始/ =~ text
- @index += 1 if start_display_choices
- return false
- elsif /\A選択肢ピックアップ/ =~ text
- $game_temp.choices.pick_up = []
- $game_temp.choices.pick_up_result = -1
- $game_temp.choices.pick_up_limit = 3
- if /\[(\d+)\]/ =~ text
- $game_temp.choices.pick_up_result = $1.to_i
- end
- if /\((\d+)\)/ =~ text
- $game_temp.choices.pick_up_limit = [[$1.to_i, $game_temp.choices.choices.size].min, 1].max
- else
- $game_temp.choices.pick_up_limit = $game_temp.choices.choices.size
- end
- if /[\'’]/ =~ text
- $game_temp.choices.pick_up_canstop = true
- end
- $game_temp.choices.window_type = -1
- @index += 1 if start_display_choices
- return false
- elsif /\A選択肢の?初期化/ =~ text
- $game_temp.choices.clear
- return true
- elsif /[::]パーティー/ =~ text
- return command_setup_actor_choice
- elsif /[::]グループ\[(\d+)\]/ =~ text
- return command_setup_actor_choice($1.to_i)
- else
- return command_setup_free_choice
- end
- end
- #--------------------------------------------------------------------------
- # ○ アクター選択肢(コマンド)
- # ※ このメソッドはイベントコマンドの実行に類するメソッドです。
- # 実行しながら@indexを進ませています。
- # ただし、test_indexが与えられている場合は選択肢を生成し、
- # 結果として返えすのみで、@indexは進めません。
- #--------------------------------------------------------------------------
- def command_setup_actor_choice(group_id = nil, test_index = nil)
- index = test_index ? test_index : @index
- if group_id
- choices = setup_group_choice(group_id)
- else
- choices = setup_party_choice
- end
-
- unless /[::]/ =~ @list[index].parameters[0]
- if test_index
- return choices
- else
- return
- end
- end
-
- option_text = $`
- choices.get_option(option_text)
-
- index += 1
- while @list[index].code == 408
- index += 1
- texts = @list[index-1].parameters[0].split(/[\|\s]/)
- for text in texts
- if /[::]/ =~ text
- addition_type_text = $`
- addition_id_text = $'
- # 調整する方法の取得
- if /\A選択不能/ =~ addition_type_text
- addition_type = 0
- elsif /\A選択限定/ =~ addition_type_text
- addition_type = 1
- elsif /\A除外/ =~ addition_type_text
- addition_type = 2
- elsif /\A共通/ =~ addition_type_text
- addition_type = 3
- elsif /\Aアイコン付加\[(\d+)\]/ =~ addition_type_text
- addition_type = 4
- icon_index = $1.to_i
- else
- next
- end
- # 調整するID郡の取得
- if /\Aパーティー/ =~ addition_id_text
- addition_id = actor_choice_addition_party
- elsif /\Aグループ\[(\d+)\]/ =~ addition_id_text
- addition_id = actor_choice_addition_group($1.to_i)
- elsif /\Aステート\[(\d+)\]/ =~ addition_id_text
- addition_id = actor_choice_addition_state($1.to_i)
- elsif /\Aレベル\[(\d+)\]/ =~ addition_id_text
- addition_id = actor_choice_addition_level($1.to_i)
- elsif /\A負傷者/ =~ addition_id_text
- addition_id = actor_choice_addition_injure
- else
- next
- end
- end
- choices.actor_choice_addition(addition_type, addition_id, icon_index)
- end
- end
-
- if test_index
- return choices
- else
- $game_temp.choices = choices
- if choices_check?(option_text) # 選択肢チェックの場合
- $game_variables[Expansion_Choices::CHOICE_RESUIT_VARIABLES] = $game_temp.choices.active_item_index.size
- return true
- elsif $game_temp.choices.active_item_index.size == 0 # 選択肢が無効の場合
- $game_variables[Expansion_Choices::CHOICE_RESUIT_VARIABLES] = -1
- return true
- elsif $game_temp.choices.size == 1 and choices_one?(option_text)
- # 択一自動選択の場合
- $game_temp.choices.proc.call($game_temp.choices.active_item_index[0])
- return true
- elsif choices_start?(option_text) # 選択肢開始
- if start_display_choices
- @index = index
- return false
- else
- return true
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ○ 自由選択肢(コマンド)
- # ※ このメソッドはイベントコマンドの実行に類するメソッドです。
- # 実行しながら@indexを進ませています。
- # ただし、test_indexが与えられている場合は選択肢を生成し、
- # 結果として返えすのみで、@indexは進めません。
- #--------------------------------------------------------------------------
- def command_setup_free_choice(test_index = nil)
- index = test_index ? test_index : @index
- choices = Game_Choices.new
-
- unless /[::]/ =~ @list[index].parameters[0]
- if test_index
- return choices
- else
- return
- end
- end
-
- option_text = $`
- choices.get_option(option_text)
- text = conversion_choices_switch_data($')
- choices.create_free_choices(text)
-
- index += 1
- while @list[index].code == 408 # 注釈データから追加
- text = conversion_choices_switch_data(@list[index].parameters[0])
- choices.create_free_choices(text)
- index += 1
- end
- unless option_text.include?("準備")
- while @list[index].code == 108 and # 追加選択肢を追加
- (/\A追加選択肢\s?[::]/ =~ @list[index].parameters[0])
- text = conversion_choices_switch_data($')
- choices.create_free_choices(text)
- index += 1
- while @list[index].code == 408 # さらに注釈データから追加
- text = conversion_choices_switch_data(@list[index].parameters[0])
- choices.create_free_choices(text)
- index += 1
- end
- end
- end
-
- if test_index
- return choices
- else
- $game_temp.choices = choices
- if choices_check?(option_text) # 選択肢チェックの場合
- $game_variables[Expansion_Choices::CHOICE_RESUIT_VARIABLES] = $game_temp.choices.active_item_index.size
- return true
- elsif $game_temp.choices.active_item_index.size == 0 # 選択肢が無効の場合
- $game_variables[Expansion_Choices::CHOICE_RESUIT_VARIABLES] = -1
- return true
- elsif $game_temp.choices.size == 1 and choices_one?(option_text)
- # 択一自動選択の場合
- $game_temp.choices.proc.call($game_temp.choices.active_item_index[0])
- return true
- elsif choices_start?(option_text) # 選択肢開始
- if start_display_choices
- @index = index
- return false
- else
- return true
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ○ 自由選択肢内のスイッチデータをコードに変換
- #--------------------------------------------------------------------------
- def conversion_choices_switch_data(text)
-
- # スイッチから非表示を取得
- while text =~ /\\S\[([0-9]+)\]/i
- if $game_switches[$1.to_i] # スイッチonなら表示
- text = text.sub(/\\S\[#{$1.to_i}\]/i, "")
- else # スイッチoffなら非表示
- text = text.sub(/\\S\[#{$1.to_i}\]/i, "<ch>")
- end
- end
-
- # セルフスイッチから非表示を取得
- while text =~ /\\S\[([A-D])\]/i
- if @original_event_id > 0 # マップイベントでない?
- key = [@map_id, @original_event_id, $1.upcase]
- unless $game_self_switches[key] # セルフスイッチoffなら非表示
- text = text.sub(/\\S\[#{$1}\]/i, "<ch>")
- end
- end
- text = text.sub(/\\S\[#{$1}\]/i, "") # 該当しなければ表示
- end
-
- # スイッチから選択不可を取得
- while text =~ /\\S\'\[([0-9]+)\]/i
- if $game_switches[$1.to_i] # スイッチonなら選択可
- text = text.sub(/\\S\'\[#{$1.to_i}\]/i, "")
- else # スイッチoffなら選択不可
- text = text.sub(/\\S\'\[#{$1.to_i}\]/i, "<cns>")
- end
- end
-
- # セルフスイッチから選択不可を取得
- while text =~ /\\S\'\[([A-D])\]/i
- if @original_event_id > 0 # マップイベントでない?
- key = [@map_id, @original_event_id, $1.upcase]
- unless $game_self_switches[key] # セルフスイッチoffなら選択不可
- text = text.sub(/\\S\'\[#{$1}\]/i, "<cns>")
- end
- end
- text = text.sub(/\\S\'\[#{$1}\]/i, "") # 該当しなければ選択可
- end
- return text
- end
- #--------------------------------------------------------------------------
- # ○ パーティー選択肢の生成
- #--------------------------------------------------------------------------
- def setup_party_choice
- choices = Game_Choices.new
- for i in 0...$game_party.members.size
- actor = $game_party.members[i]
- choices.choices.push(actor.name)
- choices.actor_id.push(actor.id)
- end
- return choices
- end
- #--------------------------------------------------------------------------
- # ○ グループ選択肢の生成
- #--------------------------------------------------------------------------
- def setup_group_choice(group_id)
- choices = Game_Choices.new
- unless $game_party.group[group_id].nil?
- for i in 0...$game_party.group[group_id].size
- actor = $game_actors[$game_party.group[group_id][i]]
- choices.choices.push(actor.name)
- choices.actor_id.push(actor.id)
- end
- end
- return choices
- end
- #--------------------------------------------------------------------------
- # ○ パーティーIDの取得
- #--------------------------------------------------------------------------
- def actor_choice_addition_party
- array = []
- for actor in $game_party.members
- array.push(actor.id)
- end
- return array
- end
- #--------------------------------------------------------------------------
- # ○ グループIDの取得
- #--------------------------------------------------------------------------
- def actor_choice_addition_group(group_id)
- return [] if $game_party.group[group_id].nil?
- array = $game_party.group[group_id]
- return array
- end
- #--------------------------------------------------------------------------
- # ○ ステート付加者IDの取得
- #--------------------------------------------------------------------------
- def actor_choice_addition_state(state_id)
- array = []
- for i in 1...$data_actors.size
- actor = $game_actors[i]
- array.push(i) if actor.state?(state_id)
- end
- return array
- end
- #--------------------------------------------------------------------------
- # ○ レベル到達者の取得
- #--------------------------------------------------------------------------
- def actor_choice_addition_level(level)
- array = []
- for i in 1...$data_actors.size
- actor = $game_actors[i]
- array.push(i) if actor.level >= level
- end
- return array
- end
- #--------------------------------------------------------------------------
- # ○ 負傷者IDの取得
- #--------------------------------------------------------------------------
- def actor_choice_addition_injure
- array = []
- for i in 1...$data_actors.size
- actor = $game_actors[i]
- array.push(i) if actor.hp < actor.maxhp
- end
- return array
- end
- #--------------------------------------------------------------------------
- # ○ 選択肢の表示
- #--------------------------------------------------------------------------
- def start_display_choices
- return true if $game_temp.choices.size == 0
- if $game_temp.choices.window_type != -1 or
- $game_temp.choices.pick_up or
- $game_message.texts.size == 0 or
- $game_message.texts.size + $game_temp.choices.size <= MAX_LINE
- $game_message.face_name = $game_message.last_face_name
- $game_message.face_index = $game_message.last_face_index
- $game_message.background = $game_message.last_background
- $game_message.position = $game_message.last_position
- $game_message.choice_start = $game_message.texts.size
- $game_message.can_not_select = $game_temp.choices.can_not_select_active
-
- if $game_temp.choices.window_type != -1 or $game_temp.choices.pick_up
- $game_message.choice_max = 4
- $game_message.show_ex_choices = $game_temp.choices
- else
- $game_message.choice_max = $game_temp.choices.size
- for i in 0...$game_temp.choices.size
- text = $game_temp.choices.item[i]
- text = "\x06" + text if $game_temp.choices.choice_show_fast
- if $game_message.can_not_select.include?(i)
- text = "\x01[#{8}]" + text + "\x01[#{0}]"
- end
- $game_message.texts.push(text)
- end
- end
- if $game_temp.choices.cancel_type == 0
- $game_message.choice_cancel_type = 0
- else
- $game_message.choice_cancel_type = -1
- end
-
- $game_message.choice_proc = $game_temp.choices.proc
- tig_ec_set_message_waiting
- return true
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ○ オプション用テキストから即実行すべき選択肢か判別
- #--------------------------------------------------------------------------
- def choices_start?(option_text)
- return false if option_text.include?("準備") # 選択肢準備のみの取得
- return false if choices_check?(option_text) # 選択肢チェックの場合
- return true
- end
- #--------------------------------------------------------------------------
- # ○ オプション用テキストから選択肢チェックか判別
- #--------------------------------------------------------------------------
- def choices_check?(option_text)
- return true if option_text.include?("チェック") # 選択肢チェックの取得
- return false
- end
- #--------------------------------------------------------------------------
- # ○ オプション用テキストから選択肢が一つの際の自動選択か判別
- #--------------------------------------------------------------------------
- def choices_one?(option_text)
- return true if /[\'’]/ =~ option_text # 選択肢が一つの際の自動選択
- return false
- end
- #--------------------------------------------------------------------------
- # ○ 注釈を使用したその他の選択肢コマンドへの振り分け
- #--------------------------------------------------------------------------
- def choices_command
- return false if @list[@index].code != 108
- text = @list[@index].parameters[0]
- if /\A追加選択肢\s?[::]/ =~ text
- additional_choices
- return true
- elsif /\Aオプションを?取得[::]/ =~ text
- $game_temp.choices.get_option($')
- return true
- elsif /\Aヘルプ/ =~ text
- if /[::]/ =~ text
- text = $'
- if /\[(\d+)\]/ =~ $`
- index = $1.to_i - 1
- else
- index = nil
- end
- $game_temp.choices.set_help(text, index)
- end
- return true
- elsif /\A有効な?選択肢数を?取得/ =~ text
- $game_variables[Expansion_Choices::CHOICE_RESUIT_VARIABLES] = $game_temp.choices.active_item_index.size
- return true
- elsif /\Aグループ\[/ =~ text or /\AG\[/i =~ text
- if /\[(\d+)\]を?初期化/ =~ text
- $game_party.group[$1.to_i] = []
- $game_map.need_refresh = true
- return true
- elsif /\[(\d+)\]を?作成[::]/ =~ text
- group_number = $1.to_i
- crowd = $'
- $game_party.group[group_number] = []
- if /\Aパーティー/ =~ crowd
- for actor in $game_party.members
- $game_party.group[group_number].push(actor.id)
- end
- else
- before_group = crowd.split(/[\|\s]/)
- before_group.delete("")
- for i in before_group
- $game_party.group[group_number].push(i.to_i)
- end
- end
- $game_map.need_refresh = true
- return true
- elsif /\[(\d+)\]に?[\((](\d+)[\))]を?追加/ =~ text
- $game_party.group[$1.to_i] = [] if $game_party.group[$1.to_i].nil?
- unless $game_party.group[$1.to_i].include?($2.to_i)
- $game_party.group[$1.to_i].push($2.to_i)
- end
- $game_map.need_refresh = true
- return true
- elsif /\[(\d+)\]に?選択アクターを?追加/ =~ text
- $game_party.group[$1.to_i] = [] if $game_party.group[$1.to_i].nil?
- unless $game_party.group[$1.to_i].include?($game_variables[TARGET_V])
- $game_party.group[$1.to_i].push($game_variables[TARGET_V])
- end
- $game_map.need_refresh = true
- return true
- elsif /\[(\d+)\]か?ら?[\((](\d+)[\))]を?削除/ =~ text
- $game_party.group[$1.to_i] = [] if $game_party.group[$1.to_i].nil?
- $game_party.group[$1.to_i].delete($2.to_i)
- $game_map.need_refresh = true
- return true
- elsif /\[(\d+)\]か?ら?選択アクターを?削除/ =~ text
- $game_party.group[$1.to_i] = [] if $game_party.group[$1.to_i].nil?
- $game_party.group[$1.to_i].delete($game_variables[TARGET_V])
- $game_map.need_refresh = true
- return true
- elsif /\[(\d+)\]へ?に?パーティーを?変更/ =~ text
- $game_party.group[$1.to_i] = [] if $game_party.group[$1.to_i].nil?
- return true if $game_party.group[$1.to_i].empty?
- for m in $game_party.members
- $game_party.remove_actor(m.id)
- end
- for i in $game_party.group[$1.to_i]
- $game_party.add_actor(i)
- end
- $game_map.need_refresh = true
- return true
- end
- elsif /\A選択アクターを?予備に?へ?格納/ =~ text
- $game_party.reserve_choice_id = $game_variables[TARGET_V]
- elsif /\A選択アクターを?予備か?ら?[習取]得/ =~ text
- $game_variables[TARGET_V] = $game_party.reserve_choice_id
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ○ 追加選択肢の登録
- # ※ このメソッドはイベントコマンドの実行に類するメソッドではなく、
- # あくまで注釈として扱われます。
- # このメソッド自体には@indexを進ませる処理はありません。
- #--------------------------------------------------------------------------
- def additional_choices
- return unless /[::]/ =~ @list[@index].parameters[0]
- text = conversion_choices_switch_data($')
- $game_temp.choices.create_free_choices(text)
- temp_index = 1
- while @list[@index+temp_index].code == 408 # さらに注釈データから追加
- text = conversion_choices_switch_data(@list[@index+temp_index].parameters[0])
- $game_temp.choices.create_free_choices(text)
- temp_index += 1
- end
- end
- #--------------------------------------------------------------------------
- # ○ 次の選択肢の取得
- #--------------------------------------------------------------------------
- def next_choices_search
- index = @index + 1
- while @list[index].code == 401 or
- @list[index].code == 355 or @list[index].code == 655
- index += 1
- end
- return nil if index >= @list.size - 1
- return nil unless @list[index].code == 108
- return nil if /\A選択肢開始/ =~ @list[index].parameters[0]
- return index if /\A選択肢/ =~ @list[index].parameters[0]
- return nil
- end
- #--------------------------------------------------------------------------
- # ◎ 文章の表示
- #--------------------------------------------------------------------------
- alias tig_ec_command_101 command_101
- def command_101
-
- # 無効な選択肢&択一選択肢の、前置き文章を非表示にする処理
- if /\\\*/ =~ @list[@index + 1].parameters[0]
- next_choices_index = next_choices_search
- unless next_choices_index.nil?
- text = @list[next_choices_index].parameters[0]
- if /[::]パーティー/ =~ text
- choices = command_setup_actor_choice(nil, next_choices_index)
- elsif /[::]グループ\[(\d+)\]/ =~ text
- choices = command_setup_actor_choice($1.to_i, next_choices_index)
- else
- choices = command_setup_free_choice(next_choices_index)
- end
- return true if choices.size == 1 or choices.active_item_index.size == 0
- end
- end
-
- $game_message.last_face_name = @params[0]
- $game_message.last_face_index = @params[1]
- $game_message.last_background = @params[2]
- $game_message.last_position = @params[3]
- return tig_ec_command_101
- end
- #--------------------------------------------------------------------------
- # ◎ 選択肢の表示
- #--------------------------------------------------------------------------
- alias tig_ec_command_102 command_102
- def command_102 # バックグラウンドと表示位置を取得させる
- $game_message.face_name = $game_message.last_face_name
- $game_message.face_index = $game_message.last_face_index
- $game_message.background = $game_message.last_background
- $game_message.position = $game_message.last_position
- return tig_ec_command_102
- end
- #--------------------------------------------------------------------------
- # ○ 文章表示のパラメーター履歴初期化
- # ※ 選択肢へパラメーターを継続させたくない場合に
- # イベントコマンド・スクリプトで実行。
- #--------------------------------------------------------------------------
- def last_parameters_clear
- $game_message.last_face_name = ""
- $game_message.last_face_index = 0
- $game_message.last_background = 0
- $game_message.last_position = 2
- end
- end
- #==============================================================================
- # ■ Window_Message
- #------------------------------------------------------------------------------
- # 文章表示に使うメッセージウィンドウです。
- #==============================================================================
- class Window_Message < Window_Selectable
- #--------------------------------------------------------------------------
- # ◎ オブジェクト初期化
- #--------------------------------------------------------------------------
- alias tig_ec_initialize initialize
- def initialize
- tig_ec_initialize
- create_frame_choices_window
- end
- #--------------------------------------------------------------------------
- # ◎ 解放
- #--------------------------------------------------------------------------
- alias tig_ec_dispose dispose
- def dispose
- tig_ec_dispose
- dispose_frame_choices_window
- end
- #--------------------------------------------------------------------------
- # ○ 別枠選択肢ウインドウの作成
- #--------------------------------------------------------------------------
- def create_frame_choices_window
- @frame_choices_window = Window_Choice.new
- @frame_choices_window.z = self.z
- @frame_choices_window.openness = 0
- @frame_choices_pickup_window = Window_Pickup.new(@frame_choices_window)
- @frame_choices_pickup_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ○ 別枠選択肢ウインドウの解放
- #--------------------------------------------------------------------------
- def dispose_frame_choices_window
- @frame_choices_window.dispose
- @frame_choices_pickup_window.dispose
- end
- #--------------------------------------------------------------------------
- # ◎ フレーム更新
- #--------------------------------------------------------------------------
- alias tig_ec_update update
- def update
- update_frame_choices_window
- tig_ec_update
- unless @opening or @closing
- if self.openness == 0
- if $game_message.show_ex_choices and @frame_choices_window.openness == 0
- start_ex_choice
- end
- end
- end
- unless @face_sprite.nil?
- @face_sprite.visible = self.openness == 255 unless @face_sprite.disposed?
- end
- end
- #--------------------------------------------------------------------------
- # ○ 別枠選択肢ウインドウの更新
- #--------------------------------------------------------------------------
- def update_frame_choices_window
- @frame_choices_window.update
- @frame_choices_pickup_window.update
- end
- #--------------------------------------------------------------------------
- # ◎ 選択肢の開始
- #--------------------------------------------------------------------------
- alias tig_ec_start_choice start_choice
- def start_choice
- return start_ex_choice if $game_message.show_ex_choices
- tig_ec_start_choice
- end
- #--------------------------------------------------------------------------
- # ○ 別枠ウインドウ選択肢の開始
- #--------------------------------------------------------------------------
- def start_ex_choice
- self.active = true
- self.index = -1
- @frame_choices_window.setting($game_message.show_ex_choices)
- @frame_choices_window.open
- @frame_choices_window.index = 0
- @frame_choices_pickup_window.refresh
- end
- #--------------------------------------------------------------------------
- # ◎ メッセージの終了
- #--------------------------------------------------------------------------
- alias tig_ec_terminate_message terminate_message
- def terminate_message
- tig_ec_terminate_message
- $game_message.show_ex_choices = nil
- @frame_choices_window.close
- @frame_choices_window.index = -1
- @frame_choices_pickup_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ● 選択肢の入力処理
- #--------------------------------------------------------------------------
- def input_choice
- return input_pick_up if $game_temp.choices.pick_up ###
- if $game_message.show_ex_choices ###
- return if @frame_choices_window.delay != 0
- index = @frame_choices_window.index ### 追加部分
- else ###
- index = self.index ###
- end ###
-
- if Input.trigger?(Input::B)
- Sound.play_cancel ### 追加部分
- if $game_message.choice_cancel_type != 0 ### 変更部分 > → !=
- #Sound.play_cancel ### コメントアウト
- scroll_contents_clear ### 追加部分
- $game_message.choice_proc.call($game_message.choice_cancel_type - 1)
- terminate_message
- end
- elsif Input.trigger?(Input::C)
- return if can_not_select?(index) ### 追加・変更部分
- Sound.play_decision
- scroll_contents_clear ### 追加部分
- $game_message.choice_proc.call(index) ### 変更部分
- terminate_message
- end
- end
- #--------------------------------------------------------------------------
- # ○ 選択肢ピックアップの処理
- #--------------------------------------------------------------------------
- def input_pick_up
- if Input.trigger?(Input::B)
- Sound.play_cancel
- if $game_message.show_ex_choices.pick_up.empty?
- $game_variables[Expansion_Choices::CHOICE_RESUIT_VARIABLES] = 0
- scroll_contents_clear
- $game_message.show_ex_choices.pick_up = nil
- $game_message.show_ex_choices.pick_up_result = -1
- terminate_message
- else
- $game_message.show_ex_choices.pick_up.pop
- @frame_choices_window.index = [@frame_choices_window.index, 0].max
- @frame_choices_window.refresh
- @frame_choices_pickup_window.refresh
- end
- elsif $game_message.show_ex_choices.pick_up_canstop and Input.trigger?(Input::A)
- if $game_message.show_ex_choices.pick_up.size == 0
- Sound.play_buzzer
- else
- Sound.play_decision unless @frame_choices_window.index == -1
- @frame_choices_window.index = -1
- end
- elsif Input.trigger?(Input::C)
- if @frame_choices_window.index == -1
- Sound.play_decision
- if $game_message.show_ex_choices.actor_choice?
- array = []
- for i in $game_message.show_ex_choices.pick_up
- array.push($game_message.show_ex_choices.actor_id[i])
- end
- if $game_message.show_ex_choices.pick_up_result >= 0
- $game_party.group[$game_message.show_ex_choices.pick_up_result] = array
- end
- else
- array = []
- for i in $game_message.show_ex_choices.pick_up
- array.push(i + 1)
- end
- if $game_message.show_ex_choices.pick_up_result >= 0
- $game_party.group[$game_message.show_ex_choices.pick_up_result] = $game_message.show_ex_choices.pick_up
- end
- end
- $game_variables[Expansion_Choices::CHOICE_RESUIT_VARIABLES] = $game_party.group[$game_message.show_ex_choices.pick_up_result][0]
- scroll_contents_clear
- $game_message.show_ex_choices.pick_up = nil
- $game_message.show_ex_choices.pick_up_result = 0
- terminate_message
- else
- return if can_not_select?(@frame_choices_window.index)
- Sound.play_decision
- $game_message.show_ex_choices.pick_up.push($game_message.show_ex_choices.display_item_index[@frame_choices_window.index])
- @frame_choices_window.refresh
- @frame_choices_pickup_window.refresh
- if $game_message.show_ex_choices.pick_up_limit == $game_message.show_ex_choices.pick_up.size
- @frame_choices_window.index = -1
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ○ 選択不能項目を選択した場合の処理
- # ※ 選択肢が選択不能だった場合、真(true)の結果を返すと共にブザー音を鳴らす。
- #--------------------------------------------------------------------------
- def can_not_select?(index)
- return false if $game_temp.choices.display_item_index.empty?
- if $game_temp.choices.can_not_select_active.include?(index)
- Sound.play_buzzer
- return true
- elsif $game_temp.choices.price[$game_temp.choices.display_item_index[index]]
- if $game_temp.choices.price[$game_temp.choices.display_item_index[index]] > $game_party.gold
- Sound.play_buzzer
- return true
- end
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ○ 4項目を超える選択肢後のウインドウ内項目の初期化
- #--------------------------------------------------------------------------
- def scroll_contents_clear
- if $game_message.choice_max > MAX_LINE
- @item_max = 0
- self.oy = 0
- create_contents
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 特殊文字の変換
- #--------------------------------------------------------------------------
- alias tig_ec_convert_special_characters convert_special_characters
- def convert_special_characters
- @text.gsub!(/\\N\[選択アクター\]/i) { $game_actors[$game_variables[Expansion_Choices::TARGET_ACTOR_ID_VARIABLES]].name }
- @text.gsub!(/\\N\[選択\]/i) { $game_actors[$game_variables[Expansion_Choices::TARGET_ACTOR_ID_VARIABLES]].name }
- @text.gsub!(/\\N\[choice\]/i) { $game_actors[$game_variables[Expansion_Choices::TARGET_ACTOR_ID_VARIABLES]].name }
- @text.gsub!(/\\N\[予備アクター\]/i) { $game_actors[$game_party.reserve_choice_id].name }
- @text.gsub!(/\\N\[予備\]/i) { $game_actors[$game_party.reserve_choice_id].name }
- @text.gsub!(/\\N\[reserve\]/i) { $game_actors[$game_party.reserve_choice_id].name }
- @text.gsub!(/\\N\[選択項目\]/i) { $game_temp.last_select_choice }
- @text.gsub!(/\\\*/){ "" }
- tig_ec_convert_special_characters
- end
- #--------------------------------------------------------------------------
- # ◎ メッセージの開始
- #--------------------------------------------------------------------------
- alias tig_ec_start_message start_message
- def start_message
- face_sprite_dispose
- tig_ec_start_message
- if @item_max > MAX_LINE
- create_contents # 最大項目以上の選択肢の際に項目をすべて線画させる
- unless $game_message.face_name.empty?
- draw_face_sprite($game_message.face_name, $game_message.face_index)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 改ページ処理
- #--------------------------------------------------------------------------
- alias tig_ec_new_page new_page
- def new_page
- tig_ec_new_page
- if @item_max > 4
- @line_count = 4 - @item_max
- end
- end
- #--------------------------------------------------------------------------
- # ○ 顔グラフィック(スプライト)の描画
- # face_name : 顔グラフィック ファイル名
- # face_index : 顔グラフィック インデックス
- # size : 表示サイズ
- #--------------------------------------------------------------------------
- def draw_face_sprite(face_name, face_index, size = 96)
- rect = Rect.new(0, 0, 0, 0)
- rect.x = face_index % 4 * 96 + (96 - size) / 2
- rect.y = face_index / 4 * 96 + (96 - size) / 2
- rect.width = size
- rect.height = size
- @face_sprite = Sprite.new
- @face_sprite.bitmap = Cache.face(face_name)
- @face_sprite.src_rect = rect
- @face_sprite.z = 200
- @face_sprite.x = self.x + 16
- @face_sprite.y = self.y + 16
- end
- #--------------------------------------------------------------------------
- # ○ 顔グラフィック(スプライト)の開放
- #--------------------------------------------------------------------------
- def face_sprite_dispose
- unless @face_sprite.nil?
- @face_sprite.dispose unless @face_sprite.disposed?
- end
- end
- #--------------------------------------------------------------------------
- # ○ 開放
- #--------------------------------------------------------------------------
- def dispose
- super
- face_sprite_dispose
- end
- #--------------------------------------------------------------------------
- # ○ ウィンドウを閉じる
- #--------------------------------------------------------------------------
- def close
- super
- face_sprite_dispose
- end
- #--------------------------------------------------------------------------
- # ● カーソルの更新
- #--------------------------------------------------------------------------
- def update_cursor
- if @index < 0 # カーソル位置が 0 未満の場合
- self.cursor_rect.empty # カーソルを無効とする
- else # カーソル位置が 0 以上の場合
- row = @index / @column_max # 現在の行を取得
- if row < top_row # 表示されている先頭の行より前の場合
- self.top_row = row # 現在の行が先頭になるようにスクロール
- end
- if row > bottom_row # 表示されている末尾の行より後ろの場合
- self.bottom_row = row # 現在の行が末尾になるようにスクロール
- end
- x = $game_message.face_name.empty? ? 0 : 112
- y = ($game_message.choice_start + @index) * WLH
- y -= self.oy
- self.cursor_rect.set(x, y, contents.width - x, WLH)
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 文章送りの入力処理
- #--------------------------------------------------------------------------
- alias tig_ec_input_pause input_pause
- def input_pause
- if $game_message.cancel_input
- if Input.trigger?(Input::B)
- Sound.play_cancel
- $game_variables[Expansion_Choices::CHOICE_RESUIT_VARIABLES] = 0
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- $game_variables[Expansion_Choices::CHOICE_RESUIT_VARIABLES] = -1
- end
- end
- tig_ec_input_pause
- end
- end
- #==============================================================================
- # □ Window_Choice
- #------------------------------------------------------------------------------
- # 別枠選択肢の表示用のウインドウです。
- #==============================================================================
- class Window_Choice < Window_Selectable
- #--------------------------------------------------------------------------
- # ○ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_reader :choice
- attr_reader :window_row_max
- attr_accessor :delay
- #--------------------------------------------------------------------------
- # ○ オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 64, 64)
- @column_max = 1
- @spacing = 16
- @delay = 0
- create_help_window
- create_gold_window
- end
- #--------------------------------------------------------------------------
- # ○ ウインドウタイプの取得
- #--------------------------------------------------------------------------
- def window_type
- return -1 if @choice == nil
- return @choice.window_type
- end
- #--------------------------------------------------------------------------
- # ○ ウインドウセッティング
- #--------------------------------------------------------------------------
- def setting(choice)
- @choice = choice
- @item_max = @choice.size
- case @choice.window_type
- when -1 # 選択肢ピックアップで使用される位置設定
- @window_row_max = 9
- set_column_max
- self.width = choise_width
- self.height = choise_height
- self.x = 288
- self.y = center_y(144)
- when 0 # レス用メッセージウインドウ位置
- @window_row_max = 4
- set_column_max
- self.width = 544
- self.height = 128
- self.x = 0
- case $game_message.position
- when 0 ; self.y = 288 # 上
- when 1 ; self.y = 288 # 真ん中
- when 2 ; self.y = 0 # 下
- end
- when 1 # メッセージウインドウが上or下位置の際に適した位置
- @window_row_max = 4
- set_column_max
- self.width = choise_width
- self.height = choise_height
- self.x = align_right_x(480)
- self.y = center_y(208)
- when 2 # ヘルプウインドウ&下位置の組み合わせに適したやや上への位置
- @window_row_max = 7
- set_column_max
- self.width = choise_width
- self.height = choise_height
- self.x = align_right_x(480)
- self.y = center_y(172)
- when 3 # ENDウインドウのような中央揃えの位置
- @window_row_max = 4
- set_column_max
- self.width = choise_width
- self.height = choise_height
- self.x = center_x(272)
- self.y = center_y(208)
- when 4 # ショップ風選択肢用(メッセウインドウ下位置、ヘルプ・ゴールド使用)
- @window_row_max = 7
- set_column_max
- self.width = choise_width
- self.height = choise_height
- self.x = 50
- self.y = center_y(172)
- end
- self.index = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # ○ 桁数のセット
- #--------------------------------------------------------------------------
- def set_column_max
- if @choice.column
- @column_max = @choice.size / @window_row_max
- @column_max += 1 if @choice.size % @window_row_max != 0
- else
- @column_max = 1
- end
- end
- #--------------------------------------------------------------------------
- # ○ 選択肢幅に合わせたウインドウ幅の取得
- #--------------------------------------------------------------------------
- def choise_width
- size = 32
- for i in @choice.choices
- size = [size, self.contents.text_size(i).width].max + 1
- end
- unless @choice.icon.empty? # アイコン付きならばその表示の為に幅を拡張
- size += 24
- end
- unless @choice.price.empty? # 値段が付いていればその表示の為に幅を拡張
- size += 80
- cx = contents.text_size(Vocab::gold).width
- size += cx if contents.text_size(Vocab::gold).width <= 36
- end
- size *= @column_max
- unless @choice.face_name == "" # フェイス付きならばその表示の為に幅を拡張
- size += 112
- end
- return size + (@spacing * (@column_max - 1)) + 32 + 1
- end
- #--------------------------------------------------------------------------
- # ○ 選択項目数に合わせたウインドウ高さの取得
- #--------------------------------------------------------------------------
- def choise_height
- row = row_max
- row += @choice.pick_up.size if @choice.pick_up
- height = row * WLH
- unless @choice.face_name == ""
- height = [96, height].max
- end
- max_height = @window_row_max * WLH
- return [height, max_height].min + 32
- end
- #--------------------------------------------------------------------------
- # ○ 引数を中心とした場合のウインドウX座標の取得(中央揃え)
- #--------------------------------------------------------------------------
- def center_x(x)
- return x - self.width / 2
- end
- #--------------------------------------------------------------------------
- # ○ 引数をウインドウ終点とした場合のウインドウX座標の取得(右詰め)
- #--------------------------------------------------------------------------
- def align_right_x(x)
- return x - self.width
- end
- #--------------------------------------------------------------------------
- # ○ 引数を中心とした場合のウインドウY座標の取得(中央揃え)
- #--------------------------------------------------------------------------
- def center_y(y)
- return y - self.height / 2
- end
- #--------------------------------------------------------------------------
- # ○ 引数をウインドウ終点とした場合のウインドウY座標の取得(下詰め)
- #--------------------------------------------------------------------------
- def align_bottom_y(y)
- return y - self.height
- end
- #--------------------------------------------------------------------------
- # ○ ヘルプウインドウの作成
- #--------------------------------------------------------------------------
- def create_help_window
- @help_window = Window_Help.new
- @help_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ○ 所持金ウィンドウの作成
- #--------------------------------------------------------------------------
- def create_gold_window
- @gold_window = Window_Gold.new(384, 0)
- @gold_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ○ 開放
- #--------------------------------------------------------------------------
- def dispose
- super
- face_sprite_dispose
- dispose_gold_window
- dispose_gold_window
- end
- #--------------------------------------------------------------------------
- # ○ ヘルプウインドウの解放
- #--------------------------------------------------------------------------
- def dispose_help_window
- @help_window.dispose
- end
- #--------------------------------------------------------------------------
- # ○ 所持金ウィンドウの解放
- #--------------------------------------------------------------------------
- def dispose_gold_window
- @gold_window.dispose
- end
- #--------------------------------------------------------------------------
- # ○ リフレッシュ
- #--------------------------------------------------------------------------
- def refresh
- @item_max = @choice.size
- create_contents
- return if @choice.nil?
- unless @choice.face_name == "" # フェイスあり
- draw_face_sprite(@choice.face_name, @choice.face_index, @choice.re_face)
- end
- for i in 0...@item_max
- draw_item(i)
- end
- @index = [@index, @item_max - 1].min
- unless @index < 0
- self.bottom_row = [@index / @column_max, self.bottom_row].min
- end
- end
- #--------------------------------------------------------------------------
- # ○ 項目を描画する矩形の取得
- # index : 項目番号
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- width = contents.width
- width -= 112 if @choice.face_name != ""
- rect.width = (width + @spacing) / @column_max - @spacing
- rect.height = WLH
- rect.x = index % @column_max * (rect.width + @spacing)
- rect.x += 112 if @choice.face_name != "" and not @choice.re_face
- rect.y = index / @column_max * WLH
- return rect
- end
- #--------------------------------------------------------------------------
- # ○ 項目の描画
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- if @choice.icon[@choice.display_item_index[index]] # アイコンあり
- draw_icon(@choice.icon[@choice.display_item_index[index]], rect.x, rect.y, enabled(index))
- end
- unless @choice.icon.empty?
- rect.x += 24
- rect.width -= 24
- end
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled(index) ? 255 : 128
- self.contents.draw_text(rect, @choice.item[index])
- if @choice.price[@choice.display_item_index[index]] # 値段表示あり
- value = @choice.price[@choice.display_item_index[index]]
- rect.width -= 4
- cx = contents.text_size(Vocab::gold).width
- if cx <= 36 # 通貨単位が短ければあわせて表示、長い場合は非表示
- self.contents.font.color = system_color
- self.contents.font.color.alpha = enabled(index) ? 255 : 128
- self.contents.draw_text(rect, Vocab::gold, 2)
- rect.width -= ( cx + 2 )
- end
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled(index) ? 255 : 128
- self.contents.draw_text(rect, value, 2)
- end
- end
- #--------------------------------------------------------------------------
- # ○ 顔グラフィック(スプライト)の描画
- # face_name : 顔グラフィック ファイル名
- # face_index : 顔グラフィック インデックス
- # size : 表示サイズ
- #--------------------------------------------------------------------------
- def draw_face_sprite(face_name, face_index, re_fase, size = 96)
-
- rect = Rect.new(0, 0, 0, 0)
- rect.x = face_index % 4 * 96 + (96 - size) / 2
- rect.y = face_index / 4 * 96 + (96 - size) / 2
- rect.width = size
- rect.height = size
- @face_sprite = Sprite.new
- @face_sprite.bitmap = Cache.face(face_name)
- @face_sprite.src_rect = rect
- @face_sprite.z = 200
- if re_fase
- @face_sprite.x = self.x + self.width - size - 16
- @face_sprite.mirror = true
- else
- @face_sprite.x = self.x + 16
- end
- @face_sprite.y = self.y + 16
- end
- #--------------------------------------------------------------------------
- # ○ 顔グラフィック(スプライト)の開放
- #--------------------------------------------------------------------------
- def face_sprite_dispose
- unless @face_sprite.nil?
- @face_sprite.dispose unless @face_sprite.disposed?
- end
- end
- #--------------------------------------------------------------------------
- # ○ 項目の有効フラグ
- #--------------------------------------------------------------------------
- def enabled(index)
- return false if @choice.can_not_select_active.include?(index)
- if @choice.price[@choice.display_item_index[index]]
- if @choice.price[@choice.display_item_index[index]] > $game_party.gold
- return false
- end
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ○ フレーム更新
- #--------------------------------------------------------------------------
- def update
- super
- @delay -= 1 unless @delay == 0
- @help_window.update
- @gold_window.update
- unless @face_sprite.nil?
- @face_sprite.visible = self.openness == 255 unless @face_sprite.disposed?
- end
- end
- #--------------------------------------------------------------------------
- # ○ ウィンドウを開く
- #--------------------------------------------------------------------------
- def open
- super
- return unless @opening
- if $game_message.show_ex_choices.help_text != []
- @help_window.visible = true
- end
- unless @choice.price.empty?
- @gold_window.y = $game_message.show_ex_choices.help_text.empty? ? 0 : 56
- @gold_window.refresh
- @gold_window.visible = true
- end
- @delay = Expansion_Choices::EX_CHOICES_DELAY # 延滞フレーム数
- end
- #--------------------------------------------------------------------------
- # ○ ウィンドウを閉じる
- #--------------------------------------------------------------------------
- def close
- super
- return unless @closing
- face_sprite_dispose
- @help_window.visible = false
- @gold_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ○ ヘルプテキスト更新
- #--------------------------------------------------------------------------
- def update_help
- return if @choice.nil?
- if @choice.display_item_index[@index].nil?
- @help_window.set_text("")
- else
- text = @choice.help_text[@choice.display_item_index[@index]]
- @help_window.set_text(text.nil? ? "" : text)
- end
- end
- end
- #==============================================================================
- # □ Window_Pickup
- #------------------------------------------------------------------------------
- # 選択肢のピックアップ処理用のウインドウです。
- #==============================================================================
- class Window_Pickup < Window_Selectable
- #--------------------------------------------------------------------------
- # ○ オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize(choice_window)
- @choice_window = choice_window
- super(0, 0, 64, 64)
- end
- #--------------------------------------------------------------------------
- # ○ リフレッシュ
- #--------------------------------------------------------------------------
- def refresh
- self.x = @choice_window.x - @choice_window.width - 32
- self.y = @choice_window.y
- self.width = @choice_window.width
- self.height = [@choice_window.height, @choice_window.choice.pick_up_limit * WLH + 32].min
- create_contents
- return if @choice_window.choice.nil?
- return if @choice_window.choice.pick_up.nil?
- self.visible = true
- @item_max = [@choice_window.choice.pick_up.size, @choice_window.window_row_max].min
- y = 0
- ([@choice_window.choice.pick_up.size - @item_max, 0].max).upto(@choice_window.choice.pick_up.size) do |i|
- draw_item(i, y)
- y += 1
- end
- end
- #--------------------------------------------------------------------------
- # ○ 項目の描画
- #--------------------------------------------------------------------------
- def draw_item(index, y)
- return if @choice_window.choice.pick_up[index].nil?
- rect = item_rect(y)
- self.contents.clear_rect(rect)
- self.contents.font.color = normal_color
- self.contents.draw_text(rect, @choice_window.choice.choices[@choice_window.choice.pick_up[index]])
- end
- end
复制代码 |
评分
-
查看全部评分
|