=begin ■自己完結型コマンドウインドウ RGSS2 DAIpage■ v1.0 ●機能● ・解放とかindex参照とかactiveやvisibleの状態管理とか面倒くさいのでw  newすると何の命令もせずともコマンド選択に遷移し、   プレイヤーがコマンドを決定(キャンセル)などをすると  変数に結果を代入してそのまま解放されます。 ・このスクリプトはマップ画面で使えるようにカスタムしてあります。  4つ以上のコマンドウインドウを好きなタイミングで呼び出せます。 ●機能と使い方● イベントコマンド:スクリプトで以下の例のように実行。 ☆例1 --------------------------------------------------- # コマンド com = ["はい", "いいえ", "いいや","だが断る","ぷ"] # キャンセル時に代入する数値(-1で無効) can = 0 # 結果を入れる変数番号 var = 1 DAI_Command_Win_Ex.new(com, can, var) --------------------------------------------------- ☆例2 座標や幅、高さを指定する場合 --------------------------------------------------- com = ["ボブ!、いかないで!", "あなたにはマーガレットがいるわ", "いつか必ず呪い殺すわよ", "あの時の言葉はすべて嘘だったのね!", "ぷ"] # キャンセル時に代入する数値(-1で無効) can = -1 # 結果を入れる変数番号 var = 1 # x座標, y座標, 幅, 高さ x, y, w, h = 240, 160, 300, 70 DAI_Command_Win_Ex.new(com,can,var,x,y,w,h) --------------------------------------------------- =end #============================================================================== # ■ DAI_Command_Win_Ex #============================================================================== class DAI_Command_Win_Ex < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 # com : コマンド文字列の配列 # can : キャンセルタイプ(-1:無効、0〜:その数値を代入) # var : 結果を代入する変数番号 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 # width : ウィンドウの幅 # height : ウィンドウの高さ #-------------------------------------------------------------------------- def initialize(com, can, var, x = 0, y = 0, w = 180, h = com.size * WLH + 32) super(x, y, w, h) @commands = com @cancel_type = can @item_max = com.size @column_max = 1 @var = var refresh self.index = 0 self.openness = 0 self.active = true update end #-------------------------------------------------------------------------- # ● ウィンドウ内容の作成 #-------------------------------------------------------------------------- def create_contents self.contents.dispose self.contents = Bitmap.new(width - 32, @item_max * WLH) end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose Graphics.update Input.update super end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update loop do self.openness += 48 super Graphics.update break if self.openness == 255 end self.active = true loop do super Graphics.update Input.update if Input.trigger?(Input::C) Sound.play_decision $game_variables[@var] = self.index + 1 break elsif Input.trigger?(Input::B) if @cancel_type == -1 Sound.play_buzzer else Sound.play_cancel $game_variables[@var] = @cancel_type break end end end self.active = false loop do self.openness -= 48 super Graphics.update break if self.openness == 0 end dispose end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh create_contents for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index, enabled = true) rect = item_rect(index) rect.x += 4 rect.width -= 8 self.contents.clear_rect(rect) self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(rect, @commands[index]) end end