#===============================================================================
# ** Game Menu Script
#-------------------------------------------------------------------------------
# Created by: Mr Wiggles
# V 0.6
#===============================================================================
# CONFIG
#===============================================================================
STATUS_WIN_FONT = 'Times New Roman' # Font for status window
#===============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
#---------------------------
# Make commands
s1 = $data_system.words.item
s2 = $data_system.words.equip
s3 = "Status"
s4 = "Map"
s5 = "Save"
@commands = Window_Command.new(160, [s1, s2, s3, s4, s5])
@commands.index = @menu_index
@commands.visible = false
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, and status
@commands.disable_item(0)
@commands.disable_item(1)
@commands.disable_item(2)
@commands.disable_item(3)
end
# If save is forbidden
if $game_system.save_disabled
# Disable save
@commands.disable_item(4)
end
#---------------------------
# Make Windows
# Status Window
@status_window = Window_Menu_Status.new
# Make Map back
@spriteset = Spriteset_Map.new
# Make Command Window
@command_window = Window_Commands.new
#---------------------------
# 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
@commands.dispose
@status_window.dispose
@spriteset.dispose
@command_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@commands.update
@status_window.update
@command_window.update(@commands.index)
update_command
end
#--------------------------------------------------------------------------
# * Command window location update
#--------------------------------------------------------------------------
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 @commands.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @commands.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(0)
when 2 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(0)
when 3 # map
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
when 4 # save
# If saving is forbidden
if $game_system.save_disabled
# 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 save screen
$scene = Scene_Save.new
end
return
end
end
end #class
#==============================================================================
# ** Window_MenuStatus
#==============================================================================
class Window_Menu_Status < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(-20, -20, 700, 600)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
@actor = $game_party.actors[0]
@x = 165
@y = 56
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# Draw window back
status_window = RPG::Cache.picture('Status')
self.contents.blt(@x, @y, status_window, Rect.new(0, 0, 640, 480))
# Draw battler
battler = RPG::Cache.battler(@actor.battler_name, @actor.battler_hue)
self.contents.blt(@x + 270, @y + 40, battler, Rect.new(0, 0, 640, 480))
#-------------------------
# Draw HP Bar
percent = @actor.hp / @actor.maxhp.to_f
hp_bar = RPG::Cache.picture('HP Bar2')
offset = 207 - 103 * percent
self.contents.blt(@x + 54, @y + offset, hp_bar, Rect.new(0, 0, 16, 103 * percent))
#-------------------------
# Draw SP Bar
percent = @actor.sp / @actor.maxsp.to_f
sp_bar = RPG::Cache.picture('SP Bar2')
offset = 207 - 103 * percent
self.contents.blt(@x + 26, @y + offset, sp_bar, Rect.new(0, 0, 16, 103 * percent))
#-------------------------
# Draw actor info
# set up text
self.contents.font.name = STATUS_WIN_FONT
self.contents.font.color = Color.new(255, 255, 255, 255)
# draw name
self.contents.font.size = 50
self.contents.draw_text(@x + 10, @y - 20, 200, 100, @actor.name, 0)
self.contents.font.size = 15
# draw level
self.contents.draw_text(@x + 178, @y + 77, 120, 32, @actor.level.to_s, 0)
# draw state
state = make_battler_state_text(@actor, 160, true)
self.contents.draw_text(@x + 174, @y + 89, 120, 32, state, 0)
# draw INT
self.contents.draw_text(@x + 155, @y + 100, 120, 32, @actor.int.to_s, 0)
# draw DEX
self.contents.draw_text(@x + 155, @y + 111, 120, 32, @actor.dex.to_s, 0)
# draw AGI
self.contents.draw_text(@x + 155, @y + 122, 120, 32, @actor.agi.to_s, 0)
# draw STR
self.contents.draw_text(@x + 160, @y + 133, 120, 32, @actor.str.to_s, 0)
# draw ATK
self.contents.draw_text(@x + 160, @y + 144, 120, 32, @actor.atk.to_s, 0)
# draw PDEF
self.contents.draw_text(@x + 165, @y + 155, 120, 32, @actor.pdef.to_s, 0)
# draw MDEF
self.contents.draw_text(@x + 165, @y + 166, 120, 32, @actor.mdef.to_s, 0)
#-------------------------
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
refresh
end
end
#==============================================================================
# ** Window_Commands
#==============================================================================
class Window_Commands < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
@curser_pos = 0
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# Draw Menu Back
command_window = RPG::Cache.picture('Commando')
self.contents.blt(26, 26,command_window, Rect.new(0, 0, 640, 480))
# Create Gold
self.contents.draw_text(54, 295, 200, 32, $game_party.gold.to_s, 0)
# Create Arrow
arrow = RPG::Cache.picture('Arrow')
x = @curser_pos * 16 + 54
self.contents.blt(34, x, arrow, Rect.new(0, 0, 640, 480))
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update(menu_index)
@curser_pos = menu_index
refresh
end
end
#==============================================================================
# ** Scene_Save
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * 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(4)
end
end
#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
# This class performs load screen processing.
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# * 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_Title.new
end
end
#==============================================================================
# ** Scene_Equip
#==============================================================================
class Scene_Equip
#--------------------------------------------------------------------------
# * 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(1)
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
end
#==============================================================================
# ** Scene_Status
#==============================================================================
class Scene_Status
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def 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(2)
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 status screen
$scene = Scene_Status.new(@actor_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 status screen
$scene = Scene_Status.new(@actor_index)
return
end
end
end