- =begin 
- #============================================================================== 
- [名前]    選択肢の拡張 
- [作者]    焼きノリ 
- [配布元]  まったりツクール雑貨 [url]http://mata-tuku.ldblog.jp/[/url] 
- #------------------------------------------------------------------------------ 
- [更新履歴] 
- ・2012/08/30 公開 
- #============================================================================== 
-   
- #------------------------------------------------------------------------------ 
- [対応] 
- ・RGSS3のみ 
- #------------------------------------------------------------------------------ 
-   
- #------------------------------------------------------------------------------ 
- [機能] 
- ・以下の機能を追加した選択肢を扱うことができるようになります。 
- ・選択項目数の制限が無くなり、5つ以上の選択肢を表示することが可能です。 
-   ただし上限が無いので、あまりに選択数が多いと画面からはみ出るので注意。 
- ・メッセージウィンドウは事前に自動で閉じます。 
- ・選択肢の表示位置が画面中央になります。引数でデフォルトの位置にすることも可能。 
- #------------------------------------------------------------------------------ 
-   
- #------------------------------------------------------------------------------ 
- [使用方法] 
- ・ExChoice.push(text)    選択項目予約配列の末尾に文字列を追加します。 
- ・ExChoice.insert(text)  選択項目予約配列の先頭に文字列を追加します。 
- ・ExChoice.clear         選択項目予約配列を初期化します。自動でも呼ばれます。 
- ・ExChoice.size          選択項目予約配列のサイズを取得します。 
- ・setup_ex_choices([centering])  選択肢拡張機能を実行します。 
-                                    選択肢が空の場合はキャンセルとみなします。 
- 引数 : centering : ウィンドウを画面中央に表示するか。 
-                           未指定の場合、trueになります。 
- #------------------------------------------------------------------------------ 
- [再定義箇所] 
- ・Window_ChoiceList の make_command_list 
- #------------------------------------------------------------------------------ 
-   [○ : 新規定義,  ◎ : エイリアス定義,  ● : 再定義] 
- #------------------------------------------------------------------------------ 
- =end 
- $YkNr_Scripts ||= {} 
- $YkNr_Scripts[:ExChoice] = true 
- #※このスクリプトを使用しない場合は、↑を false にすること 
-   
- if $YkNr_Scripts[:ExChoice] 
- #============================================================================== 
- # ■ ExChoice 
- #------------------------------------------------------------------------------ 
- #     拡張選択肢を扱うためのモジュールです。 
- #============================================================================== 
- module YakiNori::BaseExModules::ExChoice 
- #============================================================================== 
- # ■ 定数モジュール 
- #============================================================================== 
- module Const 
-   #============================================================================== 
-   # ▼ カスタマイズ 
-   #============================================================================== 
-   # 選択肢拡張機能の結果値を保存する変数番号 
-   #   キャンセル時は CancelExChoiceIndex を返します。 
-   SaveResultVariableNum = 41 
-   # 選択肢ウィンドウの位置を画面中央に表示するスイッチの番号 
-   CenteringWindowSwitchNum = 19 
-   #============================================================================== 
-   # ▲ カスタマイズここまで 
-   #============================================================================== 
-   # キャンセル時に代入される値 
-   CancelExChoiceIndex = -1 
- end 
- YakiNori.freeze_all_constants(self)  # 定数をフリーズ 
- #============================================================================== 
- # ■ 特異メソッド 
- #============================================================================== 
-   #-------------------------------------------------------------------------- 
-   # ○ 値の取得 
-   #-------------------------------------------------------------------------- 
-   def self.list 
-     $game_system.ex_choice_list 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ Ex選択肢項目を末尾に追加 
-   #-------------------------------------------------------------------------- 
-   def self.push(text) 
-     list.push(text.to_s) 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ Ex選択肢項目を先頭に追加 
-   #-------------------------------------------------------------------------- 
-   def self.insert(text) 
-     list.insert(0, text.to_s) 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ Ex選択肢項目のクリア 
-   #-------------------------------------------------------------------------- 
-   def self.clear 
-     list.__send__ :clear 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ Ex選択肢項目の数の取得 
-   #-------------------------------------------------------------------------- 
-   def self.size 
-     list.size 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ Ex選択肢機能を使用するか設定 :内部で使用されます 
-   #-------------------------------------------------------------------------- 
-   def self.using(flag) 
-     @use_this = flag 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ Ex選択肢機能を使用するか取得 :内部で使用されます 
-   #-------------------------------------------------------------------------- 
-   def self.using? 
-     @use_this 
-   end 
- end 
-   
- #============================================================================== 
- # ■ Game_System 
- #============================================================================== 
- class Game_System 
-   #-------------------------------------------------------------------------- 
-   # ○ Ex選択肢項目 
-   #-------------------------------------------------------------------------- 
-   def ex_choice_list 
-     @ex_choice_list ||= [] 
-     @ex_choice_list 
-   end 
- end 
-   
- #============================================================================== 
- # ■ Game_Interpreter 
- #============================================================================== 
- class Game_Interpreter 
-   #-------------------------------------------------------------------------- 
-   # ○ インクルード 
-   #-------------------------------------------------------------------------- 
-   include YakiNori::BaseExModules::ExChoice::Const 
-   #-------------------------------------------------------------------------- 
-   # ◎ 選択肢の表示 
-   #-------------------------------------------------------------------------- 
-   alias yknr_ExChoice_command_102 command_102 
-   def command_102 
-     yknr_ExChoice_command_102 
-     $game_switches[CenteringWindowSwitchNum] = false 
-     ExChoice.using(false) 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ◎ 選択肢のセットアップ 
-   #-------------------------------------------------------------------------- 
-   alias yknr_ExChoice_setup_choices setup_choices 
-   def setup_choices(params) 
-     if ExChoice.using? 
-       ExChoice.list.each {|s| $game_message.choices.push(s) } 
-       ExChoice.clear 
-       $game_message.choice_cancel_type = 5 
-     else 
-       yknr_ExChoice_setup_choices(params) 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ○ Ex選択肢のセットアップ 
-   #-------------------------------------------------------------------------- 
-   def setup_ex_choices(centering = true) 
-     ExChoice.clear if ExChoice.list.nil? 
-     if ExChoice.list.empty? 
-       $game_variables[SaveResultVariableNum] = CancelExChoiceIndex 
-       return 
-     end 
-     $game_switches[CenteringWindowSwitchNum] = centering 
-     ExChoice.using(true) 
-     command_102 
-   end 
- end 
-   
- #============================================================================== 
- # ■ Window_ChoiceList 
- #============================================================================== 
- class Window_ChoiceList < Window_Command 
-   #-------------------------------------------------------------------------- 
-   # ○ インクルード 
-   #-------------------------------------------------------------------------- 
-   include YakiNori::BaseExModules::ExChoice::Const 
-   #-------------------------------------------------------------------------- 
-   # ◎ ウィンドウ位置の更新 
-   #-------------------------------------------------------------------------- 
-   alias yknr_ExChoice_update_placement update_placement 
-   def update_placement 
-     if $game_switches[CenteringWindowSwitchNum] 
-       self.width = [max_choice_width + 12, 96].max + padding * 2 
-       self.width = [width, Graphics.width].min 
-       self.height = fitting_height($game_message.choices.size) 
-       self.x = (Graphics.width / 2) - (width / 2)   # 真ん中へ 
-       self.y = (Graphics.height / 2) - (height / 2) # 真ん中へ 
-     else 
-       yknr_ExChoice_update_placement 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ● コマンドリストの作成 
-   #-------------------------------------------------------------------------- 
-   def make_command_list 
-     $game_message.choices.each do |choice| 
-       add_command(choice, :ok) 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ◎ 決定ハンドラの呼び出し 
-   #-------------------------------------------------------------------------- 
-   alias yknr_ExChoice_call_ok_handler call_ok_handler 
-   def call_ok_handler 
-     if ExChoice.using? 
-       $game_variables[SaveResultVariableNum] = index 
-       close 
-     else 
-       yknr_ExChoice_call_ok_handler 
-     end 
-   end 
-   #-------------------------------------------------------------------------- 
-   # ◎ キャンセルハンドラの呼び出し 
-   #-------------------------------------------------------------------------- 
-   alias yknr_ExChoice_call_cancel_handler call_cancel_handler 
-   def call_cancel_handler 
-     if ExChoice.using? 
-       $game_variables[SaveResultVariableNum] = CancelExChoiceIndex 
-       close 
-     else 
-       yknr_ExChoice_call_cancel_handler 
-     end 
-   end 
- end 
- end #$YkNr_Scripts