king-exit/Scripts/_.58.rb
2024-08-31 14:17:23 -05:00

114 lines
No EOL
3.9 KiB
Ruby
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#==============================================================================
# ■ RGSS3 誤選択防止処理 Ver1.01 by 星潟
#------------------------------------------------------------------------------
# イベントで選択肢を選ぶ際に
# 選択肢ウィンドウインデックスを-1にし
# そのままでは選択できない状態にします。
# 上下の方向キーを押す事で、はじめて選択可能となります。
# これにより、決定キー連打による誤選択を防止することが出来ます。
#------------------------------------------------------------------------------
# Ver1.01 非選択状態で上キーを押した際に、下から二番目になる問題を修正。
#==============================================================================
module OUT_CURSOR
#誤選択防止用のスイッチIDを指定します。
#ここで指定したIDのスイッチがONの時、誤選択防止処理が有効になります。
#0にした場合は常時防止処理が行われ、TYPE2の設定が無意味になります。
S_ID = 0
#誤選択防止の非選択状態で決定キーを押した際どうするかを指定します。
#true:何もしない/false:ブザーを鳴らす)
TYPE1 = false
#誤選択防止用のスイッチが誤選択防止処理後どうするかを決定します。
#true:何もしない/false:falseに戻す
TYPE2 = false
end
class Window_ChoiceList < Window_Command
#--------------------------------------------------------------------------
# 入力処理の開始
#--------------------------------------------------------------------------
alias start_out_cursor start
def start
#誤選択防止処理のフラグを取得。
flag = out_cursor_flag
#フラグに応じて処理内容を決定。
@out_cursor = flag
#本来の処理を実行。
start_out_cursor
#処理内容を初期化。
@out_cursor = false
end
#--------------------------------------------------------------------------
# 誤選択防止フラグ
#--------------------------------------------------------------------------
def out_cursor_flag
#指定スイッチIDが0の場合はtrueを返す。
return true if OUT_CURSOR::S_ID == 0
#指定スイッチがONの時、設定に応じて該当スイッチをtrueにしつつ
#trueを返す。
if $game_switches[OUT_CURSOR::S_ID]
$game_switches[OUT_CURSOR::S_ID] = false unless OUT_CURSOR::TYPE2
return true
end
#falseを返す。
false
end
#--------------------------------------------------------------------------
# 項目の選択
#--------------------------------------------------------------------------
alias select_out_cursor select unless $!
def select(index)
#処理内容を分岐。
@out_cursor ? select_out_cursor(-1) : select_out_cursor(index)
end
#--------------------------------------------------------------------------
# カーソルを上に移動
#--------------------------------------------------------------------------
alias cursor_up_out_cursor cursor_up unless $!
def cursor_up(wrap = false)
#非選択状態の場合は一旦0にしておく。
@index = 0 if @index == -1
#本来の処理を実行。
cursor_up_out_cursor(wrap)
end
#--------------------------------------------------------------------------
# 決定ボタンが押されたときの処理
#--------------------------------------------------------------------------
alias process_ok_out_cursor process_ok unless $!
def process_ok
#インデックスが-1の場合、設定内容次第では何もしない。
return if self.index == -1 && OUT_CURSOR::TYPE1
#本来の処理を実行。
process_ok_out_cursor
end
end