Scene_Menu

Publié le par chindan

#============================================
# ■ Scene_Menu
#----------------------------------------------
#  メニュー画面の処理を行うクラスです。
#============================================

class Scene_Menu
#------------------------------------------
# ● オブジェクト初期化
# menu_index : コマンドのカーソル初期位置
#------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#------------------------------------------
# ● メイン処理
#------------------------------------------
def main
# コマンドウィンドウを作成
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "État"
s5 = "Sauvegarder"
s6 = "Quitter"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
@command_window.index = @menu_index
# パーティ人数が 0 人の場合
if $game_party.actors.size == 0
# アイテム、スキル、装備、ステータスを無効化
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# セーブ禁止の場合
if $game_system.save_disabled
# セーブを無効にする
@command_window.disable_item(4)
end
# プレイ時間ウィンドウを作成
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 224
# 歩数ウィンドウを作成
@steps_window = Window_Steps.new
@steps_window.x = 0
@steps_window.y = 320
# ゴールドウィンドウを作成
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
# ステータスウィンドウを作成
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
end
#------------------------------------------
# ● フレーム更新
#------------------------------------------
def update
# ウィンドウを更新
@command_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
@status_window.update
# コマンドウィンドウがアクティブの場合: update_command を呼ぶ
if @command_window.active
update_command
return
end
# ステータスウィンドウがアクティブの場合: update_status を呼ぶ
if @status_window.active
update_status
return
end
end
#------------------------------------------
# ● フレーム更新 (コマンドウィンドウがアクティブの場合)
#------------------------------------------
def update_command
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# パーティ人数が 0 人で、セーブ、ゲーム終了以外のコマンドの場合
if $game_party.actors.size == 0 and @command_window.index < 4
# &#12502;&#12470;&#12540; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.buzzer_se)
return
end
# &#12467;&#12510;&#12531;&#12489;&#12454;&#12451;&#12531;&#12489;&#12454;&#12398;&#12459;&#12540;&#12477;&#12523;&#20301;&#32622;&#12391;&#20998;&#23696;
case @command_window.index
when 0 # &#12450;&#12452;&#12486;&#12512;
# &#27770;&#23450; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.decision_se)
# &#12450;&#12452;&#12486;&#12512;&#30011;&#38754;&#12395;&#20999;&#12426;&#26367;&#12360;
$scene = Scene_Item.new
when 1 # &#12473;&#12461;&#12523;
# &#27770;&#23450; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.decision_se)
# &#12473;&#12486;&#12540;&#12479;&#12473;&#12454;&#12451;&#12531;&#12489;&#12454;&#12434;&#12450;&#12463;&#12486;&#12451;&#12502;&#12395;&#12377;&#12427;
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # &#35013;&#20633;
# &#27770;&#23450; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.decision_se)
# &#12473;&#12486;&#12540;&#12479;&#12473;&#12454;&#12451;&#12531;&#12489;&#12454;&#12434;&#12450;&#12463;&#12486;&#12451;&#12502;&#12395;&#12377;&#12427;
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # &#12473;&#12486;&#12540;&#12479;&#12473;
# &#27770;&#23450; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.decision_se)
# &#12473;&#12486;&#12540;&#12479;&#12473;&#12454;&#12451;&#12531;&#12489;&#12454;&#12434;&#12450;&#12463;&#12486;&#12451;&#12502;&#12395;&#12377;&#12427;
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # &#12475;&#12540;&#12502;
# &#12475;&#12540;&#12502;&#31105;&#27490;&#12398;&#22580;&#21512;
if $game_system.save_disabled
# &#12502;&#12470;&#12540; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.buzzer_se)
return
end
# &#27770;&#23450; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.decision_se)
# &#12475;&#12540;&#12502;&#30011;&#38754;&#12395;&#20999;&#12426;&#26367;&#12360;
$scene = Scene_Save.new
when 5 # &#12466;&#12540;&#12512;&#32066;&#20102;
# &#27770;&#23450; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.decision_se)
# &#12466;&#12540;&#12512;&#32066;&#20102;&#30011;&#38754;&#12395;&#20999;&#12426;&#26367;&#12360;
$scene = Scene_End.new
end
return
end
end
#------------------------------------------
# &#9679; &#12501;&#12524;&#12540;&#12512;&#26356;&#26032; (&#12473;&#12486;&#12540;&#12479;&#12473;&#12454;&#12451;&#12531;&#12489;&#12454;&#12364;&#12450;&#12463;&#12486;&#12451;&#12502;&#12398;&#22580;&#21512;)
#------------------------------------------
def update_status
# B &#12508;&#12479;&#12531;&#12364;&#25276;&#12373;&#12428;&#12383;&#22580;&#21512;
if Input.trigger?(Input::B)
# &#12461;&#12515;&#12531;&#12475;&#12523; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.cancel_se)
# &#12467;&#12510;&#12531;&#12489;&#12454;&#12451;&#12531;&#12489;&#12454;&#12434;&#12450;&#12463;&#12486;&#12451;&#12502;&#12395;&#12377;&#12427;
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# C &#12508;&#12479;&#12531;&#12364;&#25276;&#12373;&#12428;&#12383;&#22580;&#21512;
if Input.trigger?(Input::C)
# &#12467;&#12510;&#12531;&#12489;&#12454;&#12451;&#12531;&#12489;&#12454;&#12398;&#12459;&#12540;&#12477;&#12523;&#20301;&#32622;&#12391;&#20998;&#23696;
case @command_window.index
when 1 # &#12473;&#12461;&#12523;
# &#12371;&#12398;&#12450;&#12463;&#12479;&#12540;&#12398;&#34892;&#21205;&#21046;&#38480;&#12364; 2 &#20197;&#19978;&#12398;&#22580;&#21512;
if $game_party.actors[@status_window.index].restriction >= 2
# &#12502;&#12470;&#12540; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.buzzer_se)
return
end
# &#27770;&#23450; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.decision_se)
# &#12473;&#12461;&#12523;&#30011;&#38754;&#12395;&#20999;&#12426;&#26367;&#12360;
$scene = Scene_Skill.new(@status_window.index)
when 2 # &#35013;&#20633;
# &#27770;&#23450; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.decision_se)
# &#35013;&#20633;&#30011;&#38754;&#12395;&#20999;&#12426;&#26367;&#12360;
$scene = Scene_Equip.new(@status_window.index)
when 3 # &#12473;&#12486;&#12540;&#12479;&#12473;
# &#27770;&#23450; SE &#12434;&#28436;&#22863;
$game_system.se_play($data_system.decision_se)
# &#12473;&#12486;&#12540;&#12479;&#12473;&#30011;&#38754;&#12395;&#20999;&#12426;&#26367;&#12360;
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
Publicité

Publié dans poubelle

Pour être informé des derniers articles, inscrivez vous :
Commenter cet article