Код:
#==============================================================================
# MOG VX- Menu Yui 1.5
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com/
#==============================================================================
# Menu animado com layout em pictures.
#==============================================================================
#
# Update
# 2010/12/23 -> v1.5 - Novas animações e melhor codificação.
#
#==============================================================================
# 1 - Crie uma pasta com o nome Graphics/Menus.
# 2 - Nesta pasta devem conter os seguintes arquivos.
#
# Background.png
# Menu_Actor_Parameter.png
# Menu_Command.png
# Menu_HPSP.png
# Menu_Layout.png
# Menu_Layout2.png
# Menu_Select.png
#
# 3 - Será necessário ter a imagem Number_02.png na pasta Graphics/System.
#
#==============================================================================
#==============================================================================
# ■ Cache
#==============================================================================
module Cache
def self.menu(filename)
load_bitmap("Graphics/Menus/", filename)
end
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● draw_picture_number(x,y,value,file_name,align, space, frame_max ,frame_index)
#--------------------------------------------------------------------------
# X - Posição na horizontal
# Y - Posição na vertical
# VALUE - Valor Numérico
# FILE_NAME - Nome do arquivo
# ALIGN - Centralizar 0 - Esquerda 1- Centro 2 - Direita
# SPACE - Espaço entre os números.
# FRAME_MAX - Quantidade de quadros(Linhas) que a imagem vai ter.
# FRAME_INDEX - Definição do quadro a ser utilizado.
#--------------------------------------------------------------------------
def draw_picture_number(x,y,value, file_name,align = 0, space = 0, frame_max = 1,frame_index = 0)
number_image = Cache.system(file_name)
frame_max = 1 if frame_max < 1
frame_index = frame_max -1 if frame_index > frame_max -1
align = 2 if align > 2
cw = number_image.width / 10
ch = number_image.height / frame_max
h = ch * frame_index
number = value.abs.to_s.split(//)
case align
when 0
plus_x = (-cw + space) * number.size
when 1
plus_x = (-cw + space) * number.size
plus_x /= 2
when 2
plus_x = 0
end
for r in 0..number.size - 1
number_abs = number[r].to_i
number_rect = Rect.new(cw * number_abs, h, cw, ch)
self.contents.blt(plus_x + x + ((cw - space) * r), y , number_image, number_rect)
end
number_image.dispose
end
#--------------------------------------------------------------------------
# ● draw_menu_parameter
#--------------------------------------------------------------------------
def draw_menu_parameter( x, y)
image = Cache.menu("Menu_Actor_Parameter")
cw = image.width
ch = image.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - (cw / 2), y - (ch / 2) - 25, image, src_rect)
image.dispose
end
#--------------------------------------------------------------------------
# ● draw_meter
#--------------------------------------------------------------------------
def draw_meter( x, y,name,value1,value2,frames_max,frame_index)
image = Cache.menu(name)
cw = image.width * value1 / value2
ch = image.height / frames_max
h = ch * frame_index
src_rect = Rect.new(0, h, cw, ch)
self.contents.blt(x , y , image, src_rect)
image.dispose
end
#--------------------------------------------------------------------------
# ● draw_actor_state2
#--------------------------------------------------------------------------
def draw_actor_state2(actor, x, y, width = 96)
count = 0
for state in actor.states
plus_x = (24 * actor.states.size / 2)
draw_icon(state.icon_index, x + 24 * count - plus_x, y)
count += 1
break if (24 * count > width - 24)
end
end
end
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● mpname
#--------------------------------------------------------------------------
def mpname
$mpname = load_data("Data/MapInfos.rvdata")
$mpname[@map_id].name
end
end
#==============================================================================
# ■ Window_Selectable_Menu
#==============================================================================
class Window_Selectable_Menu < Window_Base
attr_reader :item_max
attr_reader :column_max
attr_reader :index
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(x, y, width, height, spacing = 32)
@item_max = 1
@column_max = 1
@index = -1
@spacing = spacing
super(x, y, width, height)
end
#--------------------------------------------------------------------------
# ● create_contents
#--------------------------------------------------------------------------
def create_contents
self.contents.dispose
self.contents = Bitmap.new(width - 32, [height - 32, row_max * WLH].max)
end
#--------------------------------------------------------------------------
# ● index
#--------------------------------------------------------------------------
def index=(index)
@index = index
end
#--------------------------------------------------------------------------
# ● row_max
#--------------------------------------------------------------------------
def row_max
return (@item_max + @column_max - 1) / @column_max
end
#--------------------------------------------------------------------------
# ● top_row
#--------------------------------------------------------------------------
def top_row
return self.oy / WLH
end
#--------------------------------------------------------------------------
# ● top_row
#--------------------------------------------------------------------------
def top_row=(row)
row = 0 if row < 0
row = row_max - 1 if row > row_max - 1
self.oy = row * WLH
end
#--------------------------------------------------------------------------
# ● page_row_max
#--------------------------------------------------------------------------
def page_row_max
return (self.height - 32) / WLH
end
#--------------------------------------------------------------------------
# ● page_item_max
#--------------------------------------------------------------------------
def page_item_max
return page_row_max * @column_max
end
#--------------------------------------------------------------------------
# ● bottom_row
#--------------------------------------------------------------------------
def bottom_row
return top_row + page_row_max - 1
end
#--------------------------------------------------------------------------
# ● bottom_row=(row)
#--------------------------------------------------------------------------
def bottom_row=(row)
self.top_row = row - (page_row_max - 1)
end
#--------------------------------------------------------------------------
# ● cursor_movable?
#--------------------------------------------------------------------------
def cursor_movable?
return false if (not visible or not active)
return false if (index < 0 or index > @item_max or @item_max == 0)
return false if (@opening or @closing)
return true
end
#--------------------------------------------------------------------------
# ● cursor_down
#--------------------------------------------------------------------------
def cursor_down(wrap = false)
if (@index < @item_max - @column_max) or (wrap and @column_max == 1)
@index = (@index + @column_max) % @item_max
end
end
#--------------------------------------------------------------------------
# ● cursor_up
#--------------------------------------------------------------------------
def cursor_up(wrap = false)
if (@index >= @column_max) or (wrap and @column_max == 1)
@index = (@index - @column_max + @item_max) % @item_max
end
end
#--------------------------------------------------------------------------
# ● cursor_right
#--------------------------------------------------------------------------
def cursor_right(wrap = false)
if (@column_max >= 2) and
(@index < @item_max - 1 or (wrap and page_row_max == 1))
@index = (@index + 1) % @item_max
end
end
#--------------------------------------------------------------------------
# ● cursor_left
#--------------------------------------------------------------------------
def cursor_left(wrap = false)
if (@column_max >= 2) and
(@index > 0 or (wrap and page_row_max == 1))
@index = (@index - 1 + @item_max) % @item_max
end
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
super
if cursor_movable?
last_index = @index
if Input.repeat?(Input::DOWN)
cursor_down(Input.trigger?(Input::DOWN))
end
if Input.repeat?(Input::UP)
cursor_up(Input.trigger?(Input::UP))
end
if Input.repeat?(Input::RIGHT)
cursor_down(Input.trigger?(Input::DOWN))
end
if Input.repeat?(Input::LEFT)
cursor_up(Input.trigger?(Input::UP))
end
if @index != last_index
Sound.play_cursor
end
end
end
end
#==============================================================================
# ■ Window_MenuStatus_Yui
#==============================================================================
class Window_MenuStatus_Yui < Window_Selectable_Menu
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 480, 300)
refresh
self.opacity = 0
self.contents_opacity = 0
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.members.size
p1 = [85,110]
p2 = [165,210]
p3 = [265,110]
p4 = [365,210]
for actor in $game_party.members
case actor.index
when 0
draw_menu_parameter(p1[0], p1[1])
draw_actor_graphic(actor, p1[0], p1[1])
draw_picture_number(p1[0] + 45 ,p1[1] - 82,actor.hp,"Number_01",0,0,3,0)
draw_picture_number(p1[0] + 83 ,p1[1] - 61,actor.mp,"Number_01",0,0,3,0)
draw_picture_number(p1[0] - 38 ,p1[1] - 55,actor.level,"Number_01",1,0,3,1)
draw_actor_state2(actor,p1[0] ,p1[1])
draw_meter(p1[0] - 27,p1[1] - 63,"Menu_HPSP",actor.hp,actor.maxhp,2,0)
draw_meter(p1[0] + 10,p1[1] - 42,"Menu_HPSP",actor.mp,actor.maxmp,2,1)
draw_actor_name(actor, p1[0] + 30, p1[1] - 25)
when 1
draw_menu_parameter(p2[0], p2[1])
draw_actor_graphic(actor, p2[0], p2[1])
draw_picture_number(p2[0] + 45 ,p2[1] - 82,actor.hp,"Number_01",0,0,3,0)
draw_picture_number(p2[0] + 83 ,p2[1] - 61,actor.mp,"Number_01",0,0,3,0)
draw_picture_number(p2[0] - 38 ,p2[1] - 55,actor.level,"Number_01",1,0,3,1)
draw_actor_state2(actor,p2[0] ,p2[1])
draw_meter(p2[0] - 27,p2[1] - 63,"Menu_HPSP",actor.hp,actor.maxhp,2,0)
draw_meter(p2[0] + 10,p2[1] - 42,"Menu_HPSP",actor.mp,actor.maxmp,2,1)
draw_actor_name(actor, p2[0] - 90, p2[1] - 25)
when 2
draw_menu_parameter(p3[0], p3[1])
draw_actor_graphic(actor, p3[0], p3[1])
draw_picture_number(p3[0] + 45 ,p3[1] - 82,actor.hp,"Number_01",0,0,3,0)
draw_picture_number(p3[0] + 83 ,p3[1] - 61,actor.mp,"Number_01",0,0,3,0)
draw_picture_number(p3[0] - 38 ,p3[1] - 55,actor.level,"Number_01",1,0,3,1)
draw_actor_state2(actor,p3[0] ,p3[1])
draw_meter(p3[0] - 27,p3[1] - 63,"Menu_HPSP",actor.hp,actor.maxhp,2,0)
draw_meter(p3[0] + 10,p3[1] - 42,"Menu_HPSP",actor.mp,actor.maxmp,2,1)
draw_actor_name(actor, p3[0] + 30, p3[1] - 25)
when 3
draw_menu_parameter(p4[0], p4[1])
draw_actor_graphic(actor, p4[0], p4[1])
draw_picture_number(p4[0] + 45 ,p4[1] - 82,actor.hp,"Number_01",0,0,3,0)
draw_picture_number(p4[0] + 83 ,p4[1] - 61,actor.mp,"Number_01",0,0,3,0)
draw_picture_number(p4[0] - 38 ,p4[1] - 55,actor.level,"Number_01",1,0,3,1)
draw_actor_state2(actor,p4[0] ,p4[1])
draw_meter(p4[0] - 27,p4[1] - 63,"Menu_HPSP",actor.hp,actor.maxhp,2,0)
draw_meter(p4[0] + 10,p4[1] - 42,"Menu_HPSP",actor.mp,actor.maxmp,2,1)
draw_actor_name(actor, p4[0] - 90, p4[1] - 25)
end
end
end
#--------------------------------------------------------------------------
# ● update_cursor
#--------------------------------------------------------------------------
def update_cursor
end
end
#==============================================================================
# ■ Window_Mapname
#==============================================================================
class Window_Mapname < Window_Base
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 160, WLH + 32)
self.opacity = 0
self.contents_opacity = 0
self.contents.font.bold = true
self.contents.font.size = 16
refresh
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120, 32, $game_map.mpname.to_s, 1)
end
end
#=======================================
Социальные закладки