#==============================================================================
# ** Window_ChaStat
#------------------------------------------------------------------------------
# This class is to show character stat in Scene_Menu. We discard the old one.
#==============================================================================
class Window_ChaStat < Window_Base
def initialize
super(6, 138, 217, 142)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
refresh
end
def refresh
self.contents.clear
actor = $game_party.actors[0]
x = 0
y = 0
draw_actor_graphic(actor, x+16, y+80)
draw_actor_name(actor, x, y-10)
draw_energy(actor,x+40,y+40)
draw_battery($game_variables[1],x+40,y+80) #<== change $game_variables[1] into the variable that you hold the battery value.
#Forexample, if the battery is hero's sp, then just replace it by "actor.sp" with no ""
end
#--------------------------------------------------------------------------
# * Draw battery
# battery : variable that you hold the battery in.
#--------------------------------------------------------------------------
def draw_battery(battery,x,y)
# Drawing battery bg
bitmap = RPG::Cache.picture("battery_bg")
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x+16, y, bitmap, src_rect)
# Drawing battery according to the battery you have
bitmap = RPG::Cache.picture("battery")
cw = 25*battery
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x+16, y, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# * Draw energy
# actor : The hero that you wanna show his/her energy. It will draw the
# health bar in percentage though :)
#--------------------------------------------------------------------------
def draw_energy(actor,x,y)
# Drawing energy bg
bitmap = RPG::Cache.picture("energy_bg")
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x+16, y, bitmap, src_rect)
# Drawing energy
bitmap = RPG::Cache.picture("energy")
max = actor.maxhp
hp = actor.hp
percent = (hp.to_f/max.to_f) * 100.0
cw = percent
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x+16, y, bitmap, src_rect)
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
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
# Make command window
s1 = $data_system.words.item
s2 = "End Game"
@command_window = Window_Command.new(640, [s1, s2])
@command_window.index = @menu_index
# Make status window
@status_window = Window_ChaStat.new
@status_window.back_opacity = 250
# 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
@status_window.dispose
@spriteset.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
$game_screen.update
@command_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
tone = Tone.new(0,0,0,0)
$game_screen.start_tone_change(tone,5 * 2)
for i in 1..50
$game_screen.pictures[i].move(5*2, $game_screen.pictures[i].origin, $game_screen.pictures[i].x, $game_screen.pictures[i].y, $game_screen.pictures[i].zoom_x, $game_screen.pictures[i].zoom_y, $opacity[i], $game_screen.pictures[i].blend_type)
end
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 < 4
# 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 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # 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
end