################################################################################
##### IB Menu
################################################################################
# Author : Biward
# Date : 21/08/2013 19:50
# Version : VXAce
#
# This script let you have a IBLike Menu. It shows the life of an hero that you
# can define with script calls and it shows the objects that you wanted to show
#
# Three commands :
# - perso_menu(id)
# The menu will show the life of the actor id.
#
# - menu_item(id)
# This command add the item id in the menu
#
# - remove_menu_item(id)
# This command remove the item id of the menu
################################################################################
##### ConfigurationMenu
################################################################################
module BIKO
# Life Bar's position [x, y]
Position_life = [32, 80]
# First Item's position [x, y]
Position_items = [200, 80]
# Indicate here the ID of the actor
Id_hero = 1
end
################################################################################
##### Beginning of the Script
################################################################################
### Scene_Menu
class Scene_Menu
class << self
attr_accessor :perso, :items
end
#----------------------------------START--------------------------------------
def start
super
check_variables
create_back
create_life
create_window_items
end
def check_variables
Scene_Menu.perso ||= BIKO::Id_hero if BIKO::Id_hero > 0
Scene_Menu.items ||= []
end
def create_life
@window_life = Window_Base.new(-16, -16, Graphics.width + 32, Graphics.height + 32)
@window_life.opacity = 0
spritelife_back = Cache.system("HP_BAR_BACK")
spritelife = Cache.system("HP_BAR")
src_rect_back = Rect.new(0, 0, spritelife.width, spritelife.height)
mp = ($game_actors[Scene_Menu.perso].hp.to_f / $game_actors[Scene_Menu.perso].mhp.to_f ).to_f * spritelife.height.to_f
src_rect = Rect.new(0, spritelife.height - mp, spritelife.width, spritelife.height)
x = BIKO::Position_life[0]
y = BIKO::Position_life[1]
pp = spritelife.height - mp
@window_life.contents.blt(x, y, spritelife_back, src_rect_back)
@window_life.contents.blt(x, y + pp, spritelife, src_rect)
end
def create_back
@spriteback = Sprite.new
@spriteback.bitmap = Cache.system("MenuBack")
end
def create_window_items
@img ||= []
@x ||= BIKO::Position_items[0]
@y ||= BIKO::Position_items[1]
@i ||= 0
Scene_Menu.items.each do |i|
@img << Sprite.new
@img[@i].bitmap = Cache.system($data_items[i].name.to_s)
@img[@i].x = @x ; @img[@i].y = @y
@y += @img[@i].height ; @i += 1
end
end
#---------------------------------TERMINATE-----------------------------------
def terminate
super
dispose_life
dispose_back
dispose_window_items
end
def dispose_life
@window_life.dispose
end
def dispose_back
@spriteback.dispose
end
def dispose_window_items
@img.each { |i| i.dispose }
end
#------------------------------------UPDATE-----------------------------------
def update
super
SceneManager.return if Input.trigger?(:B)
end
end
### Game_Interpreter
class Game_Interpreter
def perso_menu(id)
Scene_Menu.perso = id
end
def menu_item(id)
Scene_Menu.items ||= []
Scene_Menu.items << id if ! Scene_Menu.items.include?(id)
end
def remove_menu_item(id)
Scene_Menu.items ||= []
index = Scene_Menu.items.index(id) if Scene_Menu.items.include?(id)
Scene_Menu.items.delete_at(index) if index
end
end
################################################################################
##### End of the Script
################################################################################