Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #============================================================================
- # Miraki - Main Menu
- #============================================================================
- # Infomation
- #-----------------------------------
- #Author: Miraki
- #Version: Beta 1.0
- # Script use for RPG Maker XP (RGSS1)
- #-----------------------------------
- #Tutorial:
- #Add into your script editor.
- #-----------------------------------
- # Nothing about this !
- #=============================================================================
- class Game_Actor < Game_Battler
- #----------------------------------------------------
- #Exp
- #----------------------------------------------------
- def now_exp
- return @exp - @exp_list[@level]
- end
- def next_exp
- return @exp_list[@level + 1] > 0 ? @exp_list[@level + 1] - @exp_list[@level] : @exp_list[@level] = 1
- end
- end
- #========================================================
- #--------------------------------------------------------
- #Window_Gold
- #--------------------------------------------------------
- class Window_Gold < Window_Base
- def initialize
- super(0, 0, 160, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.opacity = 0
- refresh
- end
- def refresh
- self.contents.clear
- cx = contents.text_size($data_system.words.gold).width
- self.contents.font.color = system_color
- self.contents.draw_text(-20, 0, cx + 100, 32, "Money: ", 2)
- self.contents.font.color = normal_color
- self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
- self.contents.font.color = system_color
- self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
- end
- end
- #========================================================
- #--------------------------------------------------------
- #Window_Location
- #--------------------------------------------------------
- class Game_Map
- attr_reader :map_id
- def map_name
- $map_name = load_data("Data/MapInfos.rxdata")
- $map_name[@map_id].name
- end
- end
- #========================================================
- #--------------------------------------------------------
- #Window_MapName
- #--------------------------------------------------------
- class Window_Mapname < Window_Base
- def initialize
- super(0, 0, 160, 96)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = "Arial"
- self.contents.font.size = 22
- refresh
- end
- def refresh
- self.contents.clear
- self.contents.font.color = system_color
- lx = contents.text_size("Location").width
- self.contents.draw_text(4, -55, lx, 144, "Location", 1)
- self.contents.font.color = normal_color
- self.contents.font.size = 20
- self.contents.draw_text(0, 0, 110, 106, $game_map.mpname.to_s)
- bitmap = RPG::Cache.icon("038-Item07")
- self.contents.blt(105, 40, bitmap, Rect.new(0, 0, 24, 24))
- end
- end
- #========================================================
- #==============================================================================
- # ** Window_PlayTime
- #------------------------------------------------------------------------------
- # This window displays play time on the menu screen.
- #==============================================================================
- class Window_PlayTime < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 160, 96)
- self.contents = Bitmap.new(width - 32, height - 32)
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.color = system_color
- self.contents.draw_text(4, 0, 120, 32, "Time: ")
- @total_sec = Graphics.frame_count / Graphics.frame_rate
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- text = sprintf("%02d:%02d:%02d", hour, min, sec)
- self.contents.font.color = normal_color
- self.contents.draw_text(4, 32, 120, 32, text, 2)
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- if Graphics.frame_count / Graphics.frame_rate != @total_sec
- refresh
- end
- end
- end
- #========================================================
- class Window_Steps < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 160, 96)
- self.contents = Bitmap.new(width - 32, height - 32)
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.color = system_color
- self.contents.draw_text(4, 0, 120, 32, "Step Count")
- self.contents.font.color = normal_color
- self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2)
- end
- end
- #========================================================
- #--------------------------------------------------------
- #Window_Base
- #--------------------------------------------------------
- class Window_Base < Window
- #----------------------------------------------------
- #Draw_Actor_Pic
- #----------------------------------------------------
- def draw_actors_pic(actor, x, y)
- bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
- draw_ac_pic_cw = bitmap.width / 4
- draw_ac_pic_ch = bitmap.height / 4
- actorpic_rect = Rect.new(0, 0, draw_ac_pic_cw, draw_ac_pic_ch)
- self.contents.blt(x - draw_ac_pic_cw / 2, y - draw_ac_pic_ch, bitmap, actorpic_rect)
- end
- #----------------------------------------------------
- #Draw_Actor_Name
- #----------------------------------------------------
- def draw_actors_name(actor, x, y)
- self.contents.font.color = normal_color
- self.contents.font.size = 20
- self.contents.font.name = "Arial"
- self.contents.draw_text(x, y, 200, 32, actor.name)
- end
- #----------------------------------------------------
- #Draw_Actor_Class
- #----------------------------------------------------
- def draw_actors_class(actor, x, y)
- self.contents.font.color = normal_color
- self.contents.font.size = 16
- self.contents.font.name = "Arial"
- self.contents.draw_text(x, y, 236, 32, "Class: " + actor.class_name)
- end
- #----------------------------------------------------
- #Draw_Level_Number
- #----------------------------------------------------
- def draw_actors_level(actor, x, y)
- self.contents.font.color = system_color
- self.contents.font.size = 16
- self.contents.draw_text(x, y, 32, 32, "Level")
- self.contents.font.color = normal_color
- self.contents.font.size = 16
- self.contents.draw_text(x + 24, y, 24, 32, actor.level.to_s, 2)
- end
- #----------------------------------------------------
- #Draw_Actor_bar_hp
- #----------------------------------------------------
- def draw_actors_hp(actor, x, y, x_pa, y_pa, fontsize, width = 144)
- # Draw "HP" text string
- self.contents.font.color = system_color
- self.contents.font.size = 20
- self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
- # Calculate if there is draw space for MaxHP
- if width - 32 >= 108
- hp_x = x_pa + width - 108
- flag = true
- elsif width - 32 >= 48
- hp_x = x_pa + width - 48
- flag = false
- end
- # Draw HP
- self.contents.font.size = fontsize
- self.contents.font.color = actor.hp == 0 ? knockout_color :
- actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
- self.contents.draw_text(hp_x, y_pa, 48, 32, actor.hp.to_s, 2)
- # Draw MaxHP
- if flag
- self.contents.font.color = normal_color
- self.contents.font.size = fontsize
- self.contents.draw_text(hp_x + 48, y_pa, 12, 32, "/", 1)
- self.contents.draw_text(hp_x + 60, y_pa, 48, 32, actor.maxhp.to_s)
- end
- end
- #----------------------------------------------------
- #Draw_Actor_bar_sp
- #----------------------------------------------------
- def draw_actors_sp(actor, x, y, x_pa, y_pa, fontsize, width = 144)
- # Draw "SP" text string
- self.contents.font.color = system_color
- self.contents.font.size = 20
- self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
- # Calculate if there is draw space for MaxHP
- if width - 32 >= 108
- sp_x = x_pa + width - 108
- flag = true
- elsif width - 32 >= 48
- sp_x = x_pa + width - 48
- flag = false
- end
- # Draw SP
- self.contents.font.size = fontsize
- self.contents.font.color = actor.sp == 0 ? knockout_color :
- actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
- self.contents.draw_text(sp_x, y_pa, 48, 32, actor.sp.to_s, 2)
- # Draw MaxSP
- if flag
- self.contents.font.color = normal_color
- self.contents.font.size = fontsize
- self.contents.draw_text(sp_x + 48, y_pa, 12, 32, "/", 1)
- self.contents.draw_text(sp_x + 60, y_pa, 48, 32, actor.maxsp.to_s)
- end
- end
- #----------------------------------------------------
- #Draw_Actor_bar_exp
- #----------------------------------------------------
- def draw_actors_exp(actor, x, y, x_pa, y_pa, fontsize, width = 144)
- # Draw "EXP" text string
- self.contents.font.color = system_color
- self.contents.font.size = 20
- self.contents.draw_text(x, y, 40, 40, "Exp")
- # Calculate if there is draw space for MaxEXP
- if width - 32 >= 108
- exp_x = x_pa + width - 108
- flag = true
- elsif width - 32 >= 48
- exp_x = x_pa + width - 48
- flag = false
- end
- # Draw EXP
- self.contents.font.color = actor.now_exp == 0 ? knockout_color :
- actor.now_exp <= actor.next_exp / 4 ? crisis_color : normal_color
- self.contents.font.size = fontsize
- self.contents.draw_text(exp_x, y_pa, 48, 32, actor.now_exp.to_s, 2)
- # Draw MaxEXP
- if flag
- self.contents.font.color = normal_color
- self.contents.font.size = fontsize
- self.contents.draw_text(exp_x + 48, y_pa, 12, 32, "/", 1)
- self.contents.draw_text(exp_x + 60, y_pa, 48, 32, actor.next_exp.to_s)
- end
- end
- #----------------------------------------------------
- #Draw_Parameter
- #----------------------------------------------------
- def draw_parameter_menu(x, y, fsize, paraname)
- self.contents.font.size = fsize
- self.contents.font.color = system_color
- self.contents.font.name = "Arial"
- self.contents.draw_text(x, y, 200, 100, paraname, 1)
- end
- #----------------------------------------------------
- #Draw_ATK_parameter
- #----------------------------------------------------
- def draw_atk_parameter(actor, x, y)
- self.contents.font.size = 18
- self.contents.font.color = normal_color
- self.contents.font.name = "Arial"
- self.contents.draw_text(x, y, 200, 100, "ATK: ")
- self.contents.draw_text(x + 45, y, 200, 100, actor.atk.to_s)
- end
- #----------------------------------------------------
- #Draw_DEF_parameter
- #----------------------------------------------------
- def draw_def_parameter(actor, x, y)
- self.contents.font.size = 18
- self.contents.font.color = normal_color
- self.contents.font.name = "Arial"
- self.contents.draw_text(x, y + 32, 200, 100, "DEF: ")
- self.contents.draw_text(x + 45, y + 32, 200, 100, actor.pdef.to_s)
- end
- #----------------------------------------------------
- #Draw_MDEF_parameter
- #----------------------------------------------------
- def draw_mdef_parameter(actor, x, y)
- self.contents.font.size = 18
- self.contents.font.color = normal_color
- self.contents.font.name = "Arial"
- self.contents.draw_text(x, y, 200, 100, "Magic DEF: ")
- self.contents.draw_text(x + 90, y, 200, 100, actor.mdef.to_s)
- end
- #----------------------------------------------------
- #Draw_STR_parameter
- #----------------------------------------------------
- def draw_str_parameter(actor, x, y)
- self.contents.font.size = 18
- self.contents.font.color = normal_color
- self.contents.font.name = "Arial"
- self.contents.draw_text(x, y + 64, 200, 100, "STR: ")
- self.contents.draw_text(x + 45, y + 64, 200, 100, actor.str.to_s)
- end
- #----------------------------------------------------
- #Draw_DEX_parameter
- #----------------------------------------------------
- def draw_dex_parameter(actor, x, y)
- self.contents.font.size = 18
- self.contents.font.color = normal_color
- self.contents.font.name = "Arial"
- self.contents.draw_text(x, y + 32, 200, 100, "DEX: ")
- self.contents.draw_text(x + 45, y + 32, 200, 100, actor.dex.to_s)
- end
- #----------------------------------------------------
- #Draw_AGI_parameter
- #----------------------------------------------------
- def draw_agi_parameter(actor, x, y)
- self.contents.font.size = 18
- self.contents.font.color = normal_color
- self.contents.font.name = "Arial"
- self.contents.draw_text(x, y + 64, 200, 100, "AGI: ")
- self.contents.draw_text(x + 45, y + 64, 200, 100, actor.agi.to_s)
- end
- #----------------------------------------------------
- #Draw_INT_parameter
- #----------------------------------------------------
- def draw_int_parameter(actor, x, y)
- self.contents.font.size = 18
- self.contents.font.color = normal_color
- self.contents.font.name = "Arial"
- self.contents.draw_text(x, y + 96, 200, 100, "INT: ")
- self.contents.draw_text(x + 45, y + 96, 200, 100, actor.int.to_s)
- end
- #----------------------------------------------------
- #Draw_Actor_Picture
- #----------------------------------------------------
- def draw_actors_picture(actor, x, y)
- bitmap = RPG::Cache.picture(actor.character_name + "_pic")
- cw = bitmap.width
- ch = bitmap.height
- sr_rect = Rect.new(0, 0, cw, ch)
- self.contents.blt(x, y, bitmap, sr_rect, 40)
- end
- #--------------------------------------------------------------------------
- # * Draw Icon
- #--------------------------------------------------------------------------
- def draw_icon(actor, x, y, type)
- case type
- when 1
- img_name = "028-Herb04"
- when 2
- img_name = "032-Item01"
- when 3
- img_name = "050-Skill07"
- when 4
- img_name = "001-Weapon01"
- when 5
- img_name = "011-Head02"
- when 6
- img_name = "037-Item06"
- when 7
- img_name = "039-Item08"
- when 8
- img_name = "048-Skill05"
- when 9
- img_name = "040-Item09"
- when 10
- img_name = "046-Skill03"
- end
- bitmap = RPG::Cache.icon(img_name)
- cw = bitmap.width
- ch = bitmap.height
- src_rect = Rect.new(0, 0, cw, ch)
- self.contents.blt(x, y, bitmap, src_rect, 100)
- end
- #--------------------------------------------------------------------------
- # * Draw parameters bar
- #--------------------------------------------------------------------------
- def draw_parameter_bar(actor, x, y, width, type)
- case type
- when 1 #Health
- color = Color.new(255, 0, 0)
- color2 = Color.new(200, 0, 0)
- width = actor.hp.to_f / actor.maxhp.to_f * 100 * 2
- when 2 #SP
- color = Color.new(0, 0, 255)
- color2 = Color.new(0, 0, 200)
- width = actor.sp.to_f / actor.maxsp.to_f * 100 * 2
- when 3 #Exp
- color = Color.new(0, 255, 0)
- color2 = Color.new(0, 200, 0)
- width = actor.now_exp.to_f / actor.next_exp.to_f * 100 * 2
- end
- self.contents.fill_rect(x, y, 202, 4, Color.new(0, 0, 0))
- self.contents.fill_rect(x + 1, y + 1, width, 1, color2)
- self.contents.fill_rect(x + 1, y + 2, width, 1, color)
- end
- #--------------------------------------------------------------------------
- # * Draw icon item
- #--------------------------------------------------------------------------
- def draw_item_icon(item, x, y)
- if item == nil
- return
- end
- bitmap = RPG::Cache.icon(item.icon_name)
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
- self.contents.font.color = normal_color
- self.contents.font.size = 16
- end
- end
- #========================================================
- class Window_MenuStatus < Window_Selectable
- def initialize
- super(0, 0, 640, 500)
- self.contents = Bitmap.new(width - 32, height - 32)
- refresh
- self.active = false
- self.index = -1
- self.opacity = 225
- self.x = 64
- self.y = 0
- end
- def refresh
- self.contents.clear
- self.windowskin = RPG::Cache.windowskin("3")
- @item_max = $game_party.actors.size
- for i in 0...$game_party.actors.size
- x = 64
- y = 0
- actor = $game_party.actors[0]
- draw_actors_picture(actor, x + 100, y + 100)
- draw_actors_pic(actor, x - 40, y + 80)
- draw_actors_exp(actor, x + 100, y + 30, 230, 25, 15)
- draw_actors_hp(actor, x, y + 64, 120, 58, 15)
- draw_actors_sp(actor, x, y + 96, 120, 90, 15)
- draw_actors_name(actor, x - 40, y)
- draw_actors_class(actor, x + 104, y)
- draw_actors_level(actor, x, y + 32)
- #Draw Parameters
- draw_parameter_menu(x - 20, y + 100, 26, "Parameters")
- draw_atk_parameter(actor, x, y + 132)
- draw_def_parameter(actor, x, y + 132)
- draw_mdef_parameter(actor, x + 25, y + 230)
- draw_str_parameter(actor, x, y + 132)
- draw_dex_parameter(actor, x + 100, y + 100)
- draw_agi_parameter(actor, x + 100, y + 100)
- draw_int_parameter(actor, x + 100, y + 100)
- #Draw icon menu
- draw_icon(actor, x + 430, y + 53, 1)
- draw_icon(actor, x + 430, y + 85, 2)
- draw_icon(actor, x + 430, y + 117, 3)
- draw_icon(actor, x + 430, y + 149, 4)
- draw_icon(actor, x + 430, y + 181, 5)
- draw_icon(actor, x + 430, y + 213, 6)
- draw_icon(actor, x + 430, y + 245, 7)
- draw_icon(actor, x + 430, y + 277, 8)
- draw_icon(actor, x + 430, y + 309, 9)
- draw_icon(actor, x + 430, y + 341, 10)
- #Draw parameters bar
- draw_parameter_bar(actor, x + 32, y + 80, width, 1) #HP
- draw_parameter_bar(actor, x + 32, y + 112, width, 2) #SP
- draw_parameter_bar(actor, x + 137, y + 50, width, 3) #EXP
- #Draw Icon Weapon
- draw_parameter_menu(x - 40, y + 280, 22, "Equipments")
- draw_item_icon($data_weapons[actor.weapon_id], x + 10, y + 380) #Weapon
- draw_item_icon($data_armors[actor.armor1_id], x + 85, y + 380) #Shield
- draw_item_icon($data_armors[actor.armor2_id], x + 50, y + 350) #Helmet
- draw_item_icon($data_armors[actor.armor3_id], x + 50, y + 380) #Body Armor
- draw_item_icon($data_armors[actor.armor4_id], x + 50, y + 410) #Accessory
- end
- end
- def update_cursor_rect
- if @index < 0
- self.cursor_rect.empty
- else
- self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
- end
- end
- end
- #=============================================================================
- #==============================================================================
- # ** Scene_Menu
- #------------------------------------------------------------------------------
- # This class performs menu screen processing.
- #==============================================================================
- class Scene_Menu
- #--------------------------------------------------------------------------
- # * Object Initialization
- # menu_index : command cursor's initial position
- #--------------------------------------------------------------------------
- def initialize(menu_index = 0)
- @menu_index = menu_index
- #----------------------------------------------------
- #Draw_menu_title
- #----------------------------------------------------
- def draw_menu_title(x, y)
- #Draw title text string
- title = "Main Menu"
- self.contents.font.name = "Arial"
- self.contents.font.size = 30
- self.contents.draw_text(x, y, 200, 100, title)
- end
- end
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- # Make command window
- s1 = " " + "Resume" + " "
- s2 = " " + $data_system.words.item + " "
- s3 = " " + $data_system.words.skill + " "
- s4 = " " + $data_system.words.equip + " "
- s5 = " " + "Info" + " "
- s6 = " " + "Mission" + " "
- s7 = " " + "Save" + " "
- s8 = " " + "Load" + " "
- s9 = " " + "Setting" + " "
- s10 = " " + "Quit" + " "
- @command_window = Window_Command.new(150, [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10])
- @command_window.index = @menu_index
- @command_window.x = 490
- @command_window.y = 50
- # If number of party members is 0
- if $game_party.actors.size == 0
- # Disable items, skills, equipment, and status
- @command_window.disable_item(0)
- @command_window.disable_item(1)
- @command_window.disable_item(2)
- @command_window.disable_item(3)
- end
- # If save is forbidden
- if $game_system.save_disabled
- # Disable save
- @command_window.disable_item(4)
- end
- # Make play time window
- @playtime_window = Window_PlayTime.new
- @playtime_window.x = 480
- @playtime_window.y = 400
- @playtime_window.opacity = 0
- # Make gold window
- @gold_window = Window_Gold.new
- @gold_window.x = 400
- @gold_window.y = 0
- # Make status window
- @status_window = Window_MenuStatus.new
- @status_window.x = 0
- @status_window.y = 0
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update
- # Abort loop if screen is changed
- if $scene != self
- break
- end
- end
- # Prepare for transition
- Graphics.freeze
- # Dispose of windows
- @command_window.dispose
- @playtime_window.dispose
- @gold_window.dispose
- @status_window.dispose
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Update windows
- @command_window.update
- @playtime_window.update
- @gold_window.update
- @status_window.update
- # If command window is active: call update_command
- if @command_window.active
- update_command
- return
- end
- # If status window is active: call update_status
- if @status_window.active
- update_status
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (when command window is active)
- #--------------------------------------------------------------------------
- def update_command
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Switch to map screen
- $scene = Scene_Map.new
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # If command other than save or end game, and party members = 0
- if $game_party.actors.size == 0 and @command_window.index < 9
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Branch by command window cursor position
- case @command_window.index
- when 0
- $game_system.se_play($data_system.buzzer_se)
- # Switch to item screen
- $scene = Scene_Map.new
- when 1 # item
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Switch to item screen
- $scene = Scene_Item.new
- when 2 # skill
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Make status window active
- @command_window.active = false
- @status_window.active = true
- $scene = Scene_Skill.new
- when 3 # equipment
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Make status window active
- @command_window.active = false
- @status_window.active = true
- $scene = Scene_Equip.new
- when 4
- $game_system.se_play($data_system.decision_se)
- # Switch to item screen
- $scene = Scene_Info.new
- when 5
- $game_system.se_play($data_system.decision_se)
- # Switch to item screen
- $scene = Scene_Mission.new
- when 6 # save
- if $game_system.save_disabled
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Switch to save screen
- $scene = Scene_Save.new
- when 7 # load
- if $game_system.save_disabled
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Switch to load screen
- $scene = Scene_Load.new
- when 8 #Setting
- $game_system.se_play($data_system.decision_se)
- $scene = Scene_Setting.new
- when 9 # end game
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Switch to end game screen
- $scene = Scene_End.new
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (when status window is active)
- #--------------------------------------------------------------------------
- def update_status
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Make command window active
- @command_window.active = true
- @status_window.active = false
- @status_window.index = -1
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Branch by command window cursor position
- case @command_window.index
- when 1 # skill
- # If this actor's action limit is 2 or more
- if $game_party.actors[@status_window.index].restriction >= 2
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Switch to skill screen
- $scene = Scene_Skill.new(@status_window.index)
- when 2 # equipment
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Switch to equipment screen
- $scene = Scene_Equip.new(@status_window.index)
- when 3 # status
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Switch to status screen
- $scene = Scene_Status.new(@status_window.index)
- end
- return
- end
- end
- end
- #==============================================================================
- #==============================================================================
- # ** Scene_Item
- #------------------------------------------------------------------------------
- # This class performs item screen processing.
- #==============================================================================
- class Scene_Item
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- # Make help window, item window
- @help_window = Window_Help.new
- @item_window = Window_Item.new
- # Associate help window
- @item_window.help_window = @help_window
- # Make target window (set to invisible / inactive)
- @target_window = Window_Target.new
- @target_window.visible = false
- @target_window.active = false
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update
- # Abort loop if screen is changed
- if $scene != self
- break
- end
- end
- # Prepare for transition
- Graphics.freeze
- # Dispose of windows
- @help_window.dispose
- @item_window.dispose
- @target_window.dispose
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Update windows
- @help_window.update
- @item_window.update
- @target_window.update
- # If item window is active: call update_item
- if @item_window.active
- update_item
- return
- end
- # If target window is active: call update_target
- if @target_window.active
- update_target
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (when item window is active)
- #--------------------------------------------------------------------------
- def update_item
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Switch to menu screen
- $scene = Scene_Menu.new(1)
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Get currently selected data on the item window
- @item = @item_window.item
- # If not a use item
- unless @item.is_a?(RPG::Item)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # If it can't be used
- unless $game_party.item_can_use?(@item.id)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # If effect scope is an ally
- if @item.scope >= 3
- # Activate target window
- @item_window.active = false
- @target_window.x = (@item_window.index + 1) % 2 * 304
- @target_window.visible = true
- @target_window.active = true
- # Set cursor position to effect scope (single / all)
- if @item.scope == 4 || @item.scope == 6
- @target_window.index = -1
- else
- @target_window.index = 0
- end
- # If effect scope is other than an ally
- else
- # If command event ID is valid
- if @item.common_event_id > 0
- # Command event call reservation
- $game_temp.common_event_id = @item.common_event_id
- # Play item use SE
- $game_system.se_play(@item.menu_se)
- # If consumable
- if @item.consumable
- # Decrease used items by 1
- $game_party.lose_item(@item.id, 1)
- # Draw item window item
- @item_window.draw_item(@item_window.index)
- end
- # Switch to map screen
- $scene = Scene_Map.new
- return
- end
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (when target window is active)
- #--------------------------------------------------------------------------
- def update_target
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # If unable to use because items ran out
- unless $game_party.item_can_use?(@item.id)
- # Remake item window contents
- @item_window.refresh
- end
- # Erase target window
- @item_window.active = true
- @target_window.visible = false
- @target_window.active = false
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # If items are used up
- if $game_party.item_number(@item.id) == 0
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # If target is all
- if @target_window.index == -1
- # Apply item effects to entire party
- used = false
- for i in $game_party.actors
- used |= i.item_effect(@item)
- end
- end
- # If single target
- if @target_window.index >= 0
- # Apply item use effects to target actor
- target = $game_party.actors[@target_window.index]
- used = target.item_effect(@item)
- end
- # If an item was used
- if used
- # Play item use SE
- $game_system.se_play(@item.menu_se)
- # If consumable
- if @item.consumable
- # Decrease used items by 1
- $game_party.lose_item(@item.id, 1)
- # Redraw item window item
- @item_window.draw_item(@item_window.index)
- end
- # Remake target window contents
- @target_window.refresh
- # If all party members are dead
- if $game_party.all_dead?
- # Switch to game over screen
- $scene = Scene_Gameover.new
- return
- end
- # If common event ID is valid
- if @item.common_event_id > 0
- # Common event call reservation
- $game_temp.common_event_id = @item.common_event_id
- # Switch to map screen
- $scene = Scene_Map.new
- return
- end
- end
- # If item wasn't used
- unless used
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- end
- return
- end
- end
- end
- #=======================================================================
- #==============================================================================
- # ** Scene_Skill
- #------------------------------------------------------------------------------
- # This class performs skill screen processing.
- #==============================================================================
- class Scene_Skill
- #--------------------------------------------------------------------------
- # * Object Initialization
- # actor_index : actor index
- #--------------------------------------------------------------------------
- def initialize(actor_index = 0, equip_index = 0)
- @actor_index = actor_index
- end
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- # Get actor
- @actor = $game_party.actors[0]
- # Make help window, status window, and skill window
- @help_window = Window_Help.new
- @status_window = Window_SkillStatus.new(@actor)
- @skill_window = Window_Skill.new(@actor)
- # Associate help window
- @skill_window.help_window = @help_window
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update
- # Abort loop if screen is changed
- if $scene != self
- break
- end
- end
- # Prepare for transition
- Graphics.freeze
- # Dispose of windows
- @help_window.dispose
- @status_window.dispose
- @skill_window.dispose
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Update windows
- @help_window.update
- @status_window.update
- @skill_window.update
- # If skill window is active: call update_skill
- if @skill_window.active
- update_skill
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (if skill window is active)
- #--------------------------------------------------------------------------
- def update_skill
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Switch to menu screen
- $scene = Scene_Menu.new(2)
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Get currently selected data on the skill window
- @skill = @skill_window.skill
- # If unable to use
- if @skill == nil or not @actor.skill_can_use?(@skill.id)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # If effect scope is ally
- if @skill.scope >= 3
- # Activate target window
- @skill_window.active = false
- @target_window.x = (@skill_window.index + 1) % 2 * 304
- @target_window.visible = true
- @target_window.active = true
- # Set cursor position to effect scope (single / all)
- if @skill.scope == 4 || @skill.scope == 6
- @target_window.index = -1
- elsif @skill.scope == 7
- @target_window.index = @actor_index - 10
- else
- @target_window.index = 0
- end
- # If effect scope is other than ally
- else
- # If common event ID is valid
- if @skill.common_event_id > 0
- # Common event call reservation
- $game_temp.common_event_id = @skill.common_event_id
- # Play use skill SE
- $game_system.se_play(@skill.menu_se)
- # Use up SP
- @actor.sp -= @skill.sp_cost
- # Remake each window content
- @status_window.refresh
- @skill_window.refresh
- @target_window.refresh
- # Switch to map screen
- $scene = Scene_Map.new
- return
- end
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (when target window is active)
- #--------------------------------------------------------------------------
- def update_target
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Erase target window
- @skill_window.active = true
- @target_window.visible = false
- @target_window.active = false
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # If unable to use because SP ran out
- unless @actor.skill_can_use?(@skill.id)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # If target is all
- if @target_window.index == -1
- # Apply skill use effects to entire party
- used = false
- for i in $game_party.actors
- used |= i.skill_effect(@actor, @skill)
- end
- end
- # If target is user
- if @target_window.index <= -2
- # Apply skill use effects to target actor
- target = $game_party.actors[@target_window.index + 10]
- used = target.skill_effect(@actor, @skill)
- end
- # If single target
- if @target_window.index >= 0
- # Apply skill use effects to target actor
- target = $game_party.actors[@target_window.index]
- used = target.skill_effect(@actor, @skill)
- end
- # If skill was used
- if used
- # Play skill use SE
- $game_system.se_play(@skill.menu_se)
- # Use up SP
- @actor.sp -= @skill.sp_cost
- # Remake each window content
- @status_window.refresh
- @skill_window.refresh
- @target_window.refresh
- # If entire party is dead
- if $game_party.all_dead?
- # Switch to game over screen
- $scene = Scene_Gameover.new
- return
- end
- # If command event ID is valid
- if @skill.common_event_id > 0
- # Command event call reservation
- $game_temp.common_event_id = @skill.common_event_id
- # Switch to map screen
- $scene = Scene_Map.new
- return
- end
- end
- # If skill wasn't used
- unless used
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- end
- return
- end
- end
- end
- #========================================================================
- #==============================================================================
- # ** Scene_Equip
- #------------------------------------------------------------------------------
- # This class performs equipment screen processing.
- #==============================================================================
- class Scene_Equip
- #--------------------------------------------------------------------------
- # * Object Initialization
- # actor_index : actor index
- # equip_index : equipment index
- #--------------------------------------------------------------------------
- def initialize(actor_index = 0, equip_index = 0)
- @actor_index = actor_index
- @equip_index = equip_index
- end
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- # Get actor
- @actor = $game_party.actors[@actor_index]
- # Make windows
- @help_window = Window_Help.new
- @left_window = Window_EquipLeft.new(@actor)
- @right_window = Window_EquipRight.new(@actor)
- @item_window1 = Window_EquipItem.new(@actor, 0)
- @item_window2 = Window_EquipItem.new(@actor, 1)
- @item_window3 = Window_EquipItem.new(@actor, 2)
- @item_window4 = Window_EquipItem.new(@actor, 3)
- @item_window5 = Window_EquipItem.new(@actor, 4)
- # Associate help window
- @right_window.help_window = @help_window
- @item_window1.help_window = @help_window
- @item_window2.help_window = @help_window
- @item_window3.help_window = @help_window
- @item_window4.help_window = @help_window
- @item_window5.help_window = @help_window
- # Set cursor position
- @right_window.index = @equip_index
- refresh
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update
- # Abort loop if screen is changed
- if $scene != self
- break
- end
- end
- # Prepare for transition
- Graphics.freeze
- # Dispose of windows
- @help_window.dispose
- @left_window.dispose
- @right_window.dispose
- @item_window1.dispose
- @item_window2.dispose
- @item_window3.dispose
- @item_window4.dispose
- @item_window5.dispose
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- # Set item window to visible
- @item_window1.visible = (@right_window.index == 0)
- @item_window2.visible = (@right_window.index == 1)
- @item_window3.visible = (@right_window.index == 2)
- @item_window4.visible = (@right_window.index == 3)
- @item_window5.visible = (@right_window.index == 4)
- # Get currently equipped item
- item1 = @right_window.item
- # Set current item window to @item_window
- case @right_window.index
- when 0
- @item_window = @item_window1
- when 1
- @item_window = @item_window2
- when 2
- @item_window = @item_window3
- when 3
- @item_window = @item_window4
- when 4
- @item_window = @item_window5
- end
- # If right window is active
- if @right_window.active
- # Erase parameters for after equipment change
- @left_window.set_new_parameters(nil, nil, nil)
- end
- # If item window is active
- if @item_window.active
- # Get currently selected item
- item2 = @item_window.item
- # Change equipment
- last_hp = @actor.hp
- last_sp = @actor.sp
- @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
- # Get parameters for after equipment change
- new_atk = @actor.atk
- new_pdef = @actor.pdef
- new_mdef = @actor.mdef
- # Return equipment
- @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
- @actor.hp = last_hp
- @actor.sp = last_sp
- # Draw in left window
- @left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Update windows
- @left_window.update
- @right_window.update
- @item_window.update
- refresh
- # If right window is active: call update_right
- if @right_window.active
- update_right
- return
- end
- # If item window is active: call update_item
- if @item_window.active
- update_item
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (when right window is active)
- #--------------------------------------------------------------------------
- def update_right
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Switch to menu screen
- $scene = Scene_Menu.new(3)
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # If equipment is fixed
- if @actor.equip_fix?(@right_window.index)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Activate item window
- @right_window.active = false
- @item_window.active = true
- @item_window.index = 0
- return
- end
- # If R button was pressed
- if Input.trigger?(Input::R)
- # Play cursor SE
- $game_system.se_play($data_system.cursor_se)
- # To next actor
- @actor_index += 1
- @actor_index %= $game_party.actors.size
- # Switch to different equipment screen
- $scene = Scene_Equip.new(@actor_index, @right_window.index)
- return
- end
- # If L button was pressed
- if Input.trigger?(Input::L)
- # Play cursor SE
- $game_system.se_play($data_system.cursor_se)
- # To previous actor
- @actor_index += $game_party.actors.size - 1
- @actor_index %= $game_party.actors.size
- # Switch to different equipment screen
- $scene = Scene_Equip.new(@actor_index, @right_window.index)
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (when item window is active)
- #--------------------------------------------------------------------------
- def update_item
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Activate right window
- @right_window.active = true
- @item_window.active = false
- @item_window.index = -1
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Play equip SE
- $game_system.se_play($data_system.equip_se)
- # Get currently selected data on the item window
- item = @item_window.item
- # Change equipment
- @actor.equip(@right_window.index, item == nil ? 0 : item.id)
- # Activate right window
- @right_window.active = true
- @item_window.active = false
- @item_window.index = -1
- # Remake right window and item window contents
- @right_window.refresh
- @item_window.refresh
- return
- end
- end
- end
- #=============================================================================
- #==============================================================================
- # ** Scene_Save
- #------------------------------------------------------------------------------
- # This class performs save screen processing.
- #==============================================================================
- class Scene_Save < Scene_File
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super("Which file would you like to save to?")
- end
- #--------------------------------------------------------------------------
- # * Decision Processing
- #--------------------------------------------------------------------------
- def on_decision(filename)
- # Play save SE
- $game_system.se_play($data_system.save_se)
- # Write save data
- file = File.open(filename, "wb")
- write_save_data(file)
- file.close
- # If called from event
- if $game_temp.save_calling
- # Clear save call flag
- $game_temp.save_calling = false
- # Switch to map screen
- $scene = Scene_Map.new
- return
- end
- # Switch to menu screen
- $scene = Scene_Menu.new(4)
- end
- #--------------------------------------------------------------------------
- # * Cancel Processing
- #--------------------------------------------------------------------------
- def on_cancel
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # If called from event
- if $game_temp.save_calling
- # Clear save call flag
- $game_temp.save_calling = false
- # Switch to map screen
- $scene = Scene_Map.new
- return
- end
- # Switch to menu screen
- $scene = Scene_Menu.new(6)
- end
- #--------------------------------------------------------------------------
- # * Write Save Data
- # file : write file object (opened)
- #--------------------------------------------------------------------------
- def write_save_data(file)
- # Make character data for drawing save file
- characters = []
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- characters.push([actor.character_name, actor.character_hue])
- end
- # Write character data for drawing save file
- Marshal.dump(characters, file)
- # Wrire frame count for measuring play time
- Marshal.dump(Graphics.frame_count, file)
- # Increase save count by 1
- $game_system.save_count += 1
- # Save magic number
- # (A random value will be written each time saving with editor)
- $game_system.magic_number = $data_system.magic_number
- # Write each type of game object
- Marshal.dump($game_system, file)
- Marshal.dump($game_switches, file)
- Marshal.dump($game_variables, file)
- Marshal.dump($game_self_switches, file)
- Marshal.dump($game_screen, file)
- Marshal.dump($game_actors, file)
- Marshal.dump($game_party, file)
- Marshal.dump($game_troop, file)
- Marshal.dump($game_map, file)
- Marshal.dump($game_player, file)
- end
- end
- #=======================================================================
- #==============================================================================
- # ** Scene_Load
- #------------------------------------------------------------------------------
- # This class performs load screen processing.
- #==============================================================================
- class Scene_Load < Scene_File
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- # Remake temporary object
- $game_temp = Game_Temp.new
- # Timestamp selects new file
- $game_temp.last_file_index = 0
- latest_time = Time.at(0)
- for i in 0..3
- filename = make_filename(i)
- if FileTest.exist?(filename)
- file = File.open(filename, "r")
- if file.mtime > latest_time
- latest_time = file.mtime
- $game_temp.last_file_index = i
- end
- file.close
- end
- end
- super("Which file would you like to load?")
- end
- #--------------------------------------------------------------------------
- # * Decision Processing
- #--------------------------------------------------------------------------
- def on_decision(filename)
- # If file doesn't exist
- unless FileTest.exist?(filename)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play load SE
- $game_system.se_play($data_system.load_se)
- # Read save data
- file = File.open(filename, "rb")
- read_save_data(file)
- file.close
- # Restore BGM and BGS
- $game_system.bgm_play($game_system.playing_bgm)
- $game_system.bgs_play($game_system.playing_bgs)
- # Update map (run parallel process event)
- $game_map.update
- # Switch to map screen
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # * Cancel Processing
- #--------------------------------------------------------------------------
- def on_cancel
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Switch to title screen
- $scene = Scene_Menu.new(7)
- end
- #--------------------------------------------------------------------------
- # * Read Save Data
- # file : file object for reading (opened)
- #--------------------------------------------------------------------------
- def read_save_data(file)
- # Read character data for drawing save file
- characters = Marshal.load(file)
- # Read frame count for measuring play time
- Graphics.frame_count = Marshal.load(file)
- # Read each type of game object
- $game_system = Marshal.load(file)
- $game_switches = Marshal.load(file)
- $game_variables = Marshal.load(file)
- $game_self_switches = Marshal.load(file)
- $game_screen = Marshal.load(file)
- $game_actors = Marshal.load(file)
- $game_party = Marshal.load(file)
- $game_troop = Marshal.load(file)
- $game_map = Marshal.load(file)
- $game_player = Marshal.load(file)
- # If magic number is different from when saving
- # (if editing was added with editor)
- if $game_system.magic_number != $data_system.magic_number
- # Load map
- $game_map.setup($game_map.map_id)
- $game_player.center($game_player.x, $game_player.y)
- end
- # Refresh party members
- $game_party.refresh
- end
- end
- #==============================================================================
- # ** Scene_End
- #------------------------------------------------------------------------------
- # This class performs game end screen processing.
- #==============================================================================
- class Scene_End
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- # Make command window
- s1 = "To Title"
- s2 = "Shutdown"
- s3 = "Cancel"
- @command_window = Window_Command.new(192, [s1, s2, s3])
- @command_window.x = 320 - @command_window.width / 2
- @command_window.y = 240 - @command_window.height / 2
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame Update
- update
- # Abort loop if screen is changed
- if $scene != self
- break
- end
- end
- # Prepare for transition
- Graphics.freeze
- # Dispose of window
- @command_window.dispose
- # If switching to title screen
- if $scene.is_a?(Scene_Title)
- # Fade out screen
- Graphics.transition
- Graphics.freeze
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Update command window
- @command_window.update
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Switch to menu screen
- $scene = Scene_Menu.new(9)
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Branch by command window cursor position
- case @command_window.index
- when 0 # to title
- command_to_title
- when 1 # shutdown
- command_shutdown
- when 2 # quit
- command_cancel
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Process When Choosing [To Title] Command
- #--------------------------------------------------------------------------
- def command_to_title
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Fade out BGM, BGS, and ME
- Audio.bgm_fade(800)
- Audio.bgs_fade(800)
- Audio.me_fade(800)
- # Switch to title screen
- $scene = Scene_Title.new
- end
- #--------------------------------------------------------------------------
- # * Process When Choosing [Shutdown] Command
- #--------------------------------------------------------------------------
- def command_shutdown
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Fade out BGM, BGS, and ME
- Audio.bgm_fade(800)
- Audio.bgs_fade(800)
- Audio.me_fade(800)
- # Shutdown
- $scene = nil
- end
- #--------------------------------------------------------------------------
- # * Process When Choosing [Cancel] Command
- #--------------------------------------------------------------------------
- def command_cancel
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Switch to menu screen
- $scene = Scene_Menu.new(5)
- end
- end
- #=============================================================================
- #==============================================================================
- # ** Scene_File
- #------------------------------------------------------------------------------
- # This is a superclass for the save screen and load screen.
- #==============================================================================
- class Scene_File
- #--------------------------------------------------------------------------
- # * Object Initialization
- # help_text : text string shown in the help window
- #--------------------------------------------------------------------------
- def initialize(help_text)
- @help_text = help_text
- end
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- # Make help window
- @help_window = Window_Help.new
- @help_window.set_text(@help_text)
- # Make save file window
- @savefile_windows = []
- for i in 0..3
- @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
- end
- # Select last file to be operated
- @file_index = $game_temp.last_file_index
- @savefile_windows[@file_index].selected = true
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update
- # Abort loop if screen is changed
- if $scene != self
- break
- end
- end
- # Prepare for transition
- Graphics.freeze
- # Dispose of windows
- @help_window.dispose
- for i in @savefile_windows
- i.dispose
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Update windows
- @help_window.update
- for i in @savefile_windows
- i.update
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Call method: on_decision (defined by the subclasses)
- on_decision(make_filename(@file_index))
- $game_temp.last_file_index = @file_index
- return
- end
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Call method: on_cancel (defined by the subclasses)
- on_cancel
- return
- end
- # If the down directional button was pressed
- if Input.repeat?(Input::DOWN)
- # If the down directional button pressed down is not a repeat,
- # or cursor position is more in front than 3
- if Input.trigger?(Input::DOWN) or @file_index < 3
- # Play cursor SE
- $game_system.se_play($data_system.cursor_se)
- # Move cursor down
- @savefile_windows[@file_index].selected = false
- @file_index = (@file_index + 1) % 4
- @savefile_windows[@file_index].selected = true
- return
- end
- end
- # If the up directional button was pressed
- if Input.repeat?(Input::UP)
- # If the up directional button pressed down is not a repeat、
- # or cursor position is more in back than 0
- if Input.trigger?(Input::UP) or @file_index > 0
- # Play cursor SE
- $game_system.se_play($data_system.cursor_se)
- # Move cursor up
- @savefile_windows[@file_index].selected = false
- @file_index = (@file_index + 3) % 4
- @savefile_windows[@file_index].selected = true
- return
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Make File Name
- # file_index : save file index (0-3)
- #--------------------------------------------------------------------------
- def make_filename(file_index)
- return "Save#{file_index + 1}.rxdata"
- end
- end
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement