#============================================================================== # □ 選択肢画面 (for VX Ace) #------------------------------------------------------------------------------ # Version : 2_20120223 # by サリサ・タイクーン # http://www.tycoon812.com/rgss/ #============================================================================== #============================================================================== # □ 素材スイッチ #============================================================================== $rgsslab = {} if $rgsslab == nil $rgsslab["選択肢画面"] = true if $rgsslab["選択肢画面"] #============================================================================== # □ カスタマイズポイント #============================================================================== module RGSSLAB end module RGSSLAB::Scene_Choices #-------------------------------------------------------------------------- # ○ 結果内容を受け取る変数 # 受け取る変数を指定します。 # # 注意: # 変数拡張の変数に設定する事はできません。 #-------------------------------------------------------------------------- RESULT_VARIABLE = 3 #-------------------------------------------------------------------------- # ○ 選択肢の番号表示 # 0 : アラビア数字 # 1 : アルファベット # 2 : ローマ数字 # 3 : 漢数字 # # 上記以外は、0として扱われます。 #-------------------------------------------------------------------------- DRAW = 0 #-------------------------------------------------------------------------- # ○ モードの選択(New!) # この素材のモードを選択します。 # # 0 : 通常モード(制御文字は使えません) # 1 : 制御文字モード # # これら以外の数値は0として扱われます。 # # 使えない制御文字もありますので、ご注意下さい。 #-------------------------------------------------------------------------- MODE = 0 end # カスタマイズポイントは、ここまで #============================================================================== # □ RGSSLAB::Scene_Choices [module] #============================================================================== module RGSSLAB::Scene_Choices #-------------------------------------------------------------------------- # ○ 素材設定用の定数定義 #-------------------------------------------------------------------------- MATERIAL_NAME = "選択肢画面" VERSION = 2 RELEASE = 20120223 #-------------------------------------------------------------------------- # ○ 操作エラー # error_number : エラー番号 #-------------------------------------------------------------------------- def self.operate_error(error_number) text = "【RGSS研究所:#{MATERIAL_NAME}】" case error_number when 1 msgbox_p text, "呼び出しの文字列を記述して下さい。" when 2 msgbox_p text, "呼び出しの文字列:#{string}は存在しない為、実行できません。" when 3 msgbox_p text, "選択肢の数が2よりも小さい為、実行できません。" when 4 msgbox_p text, "選択肢の数が7よりも多い為、実行できません。" end end end #============================================================================== # ■ Game_Interpreter [class] #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ○ モジュールの設定 #-------------------------------------------------------------------------- RGSSLAB_052 = RGSSLAB::Scene_Choices #-------------------------------------------------------------------------- # ○ 選択肢画面の呼び出し # index : 選択肢の種類 #-------------------------------------------------------------------------- def call_choices(index) if index == nil RGSSLAB_052.operate_error(1) return end if RGSSLAB_052_2::SETTING[index] == nil RGSSLAB_052.operate_error(2, index) return end if RGSSLAB_052_2::SETTING[index].size < 2 RGSSLAB_052.operate_error(3) return end if RGSSLAB_052_2::SETTING[index].size > 7 RGSSLAB_052.operate_error(4) return end SceneManager.call(Scene_Choices) SceneManager.scene.prepare(index) Fiber.yield end end #============================================================================== # □ Window_Dummy_052 [class] #============================================================================== class Window_Dummy_052 < Window_Base #-------------------------------------------------------------------------- # ○ オブジェクト初期化 [オーバーライド] #-------------------------------------------------------------------------- def initialize if $rgsslab["XP画面サイズ"] super(48, 288, 544, 160) else super(0, 256, 544, 160) end end end #============================================================================== # □ Window_Choices_Display [class] #============================================================================== class Window_Choices_Display < Window_Base #-------------------------------------------------------------------------- # ○ モジュールの設定 #-------------------------------------------------------------------------- RGSSLAB_052 = RGSSLAB::Scene_Choices #-------------------------------------------------------------------------- # ○ オブジェクト初期化 [オーバーライド] # text : 最初に描画させる選択肢の文字列 #-------------------------------------------------------------------------- def initialize(text = "") if $rgsslab["XP画面サイズ"] super(48, 288, 544, 80) else super(0, 256, 544, 80) end self.opacity = 0 refresh(text) end #-------------------------------------------------------------------------- # ○ リフレッシュ # text : 現在選択中の選択肢の文字列 #-------------------------------------------------------------------------- def refresh(text) contents.clear contents.font.color = normal_color case RGSSLAB_052::MODE when 0 ; contents.draw_text(4, 0, self.width - 40, 32, text) when 1 ; draw_text_ex(4, 0, text) else ; contents.draw_text(4, 0, self.width - 40, 32, text) end end end #============================================================================== # □ Window_Label_Display [class] #============================================================================== class Window_Label_Display < Window_Selectable #-------------------------------------------------------------------------- # ○ モジュールの設定 #-------------------------------------------------------------------------- RGSSLAB_052 = RGSSLAB::Scene_Choices #-------------------------------------------------------------------------- # ○ オブジェクト初期化 [オーバーライド] # item_max : 候補数 #-------------------------------------------------------------------------- def initialize(item_max) @item_max = item_max if $rgsslab["XP画面サイズ"] super(48, 368, 544, 80) else super(0, 336, 544, 80) end self.index = -1 self.opacity = 0 case RGSSLAB_052::DRAW when 1 ; @label = ["A", "B", "C", "D", "E", "F", "G"] when 2 ; @label = ["T", "U", "V", "W", "X", "Y", "Z"] when 3 ; @label = ["一", "二", "三", "四", "五", "六", "七"] else ; @label = ["1", "2", "3", "4", "5", "6", "7"] end refresh end #-------------------------------------------------------------------------- # ○ 桁数の取得 [オーバーライド] #-------------------------------------------------------------------------- def col_max return 7 end #-------------------------------------------------------------------------- # ○ 項目数の取得 [オーバーライド] #-------------------------------------------------------------------------- def item_max @item_max end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ○ 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) rect = Rect.new(10 + index * 32, 0, 32, 32) self.contents.draw_text(rect, @label[index]) end #-------------------------------------------------------------------------- # ○ カーソルの矩形更新 [オーバーライド] #-------------------------------------------------------------------------- def update_cursor if @index < 0 self.cursor_rect.empty else self.cursor_rect.set(4 + @index * 32, 0, 32, 32) end end end #============================================================================== # □ Scene_Choices [class] #============================================================================== class Scene_Choices < Scene_Base #-------------------------------------------------------------------------- # ○ モジュールの設定 #-------------------------------------------------------------------------- RGSSLAB_052 = RGSSLAB::Scene_Choices #-------------------------------------------------------------------------- # ○ 準備 # index : 選択肢の種類 #-------------------------------------------------------------------------- def prepare(index) @index = RGSSLAB_052_2::SETTING[index] @item_max = RGSSLAB_052_2::SETTING[index].size end #-------------------------------------------------------------------------- # ○ 開始処理 [オーバーライド] #-------------------------------------------------------------------------- def start super create_spriteset create_all_windows end #-------------------------------------------------------------------------- # ○ スプライトセットの作成 #-------------------------------------------------------------------------- def create_spriteset @spriteset = Spriteset_Map.new end #-------------------------------------------------------------------------- # ○ 全ウィンドウの作成 #-------------------------------------------------------------------------- def create_all_windows @window = Window_Dummy_052.new @choices_window = Window_Choices_Display.new(@index[0]) @label_window = Window_Label_Display.new(@item_max) @label_window.index = 0 @label_window.active = true end #-------------------------------------------------------------------------- # ○ フレーム更新 [オーバーライド] #-------------------------------------------------------------------------- def update super update_choices update_input end #-------------------------------------------------------------------------- # ○ 選択肢の更新 #-------------------------------------------------------------------------- def update_choices @choices_window.refresh(@index[@label_window.index]) end #-------------------------------------------------------------------------- # ○ 入力 #-------------------------------------------------------------------------- def update_input if Input.trigger?(:C) Sound.play_ok $game_variables[RGSSLAB_052::RESULT_VARIABLE] = @label_window.index + 1 return_scene end end #-------------------------------------------------------------------------- # ○ 終了処理 [オーバーライド] #-------------------------------------------------------------------------- def terminate super dispose_spriteset end #-------------------------------------------------------------------------- # ○ スプライトセットの解放 #-------------------------------------------------------------------------- def dispose_spriteset @spriteset.dispose end end end