HUNTERMiér Ene 30, 2013 2:31 am
Super Usuario
: Ring Menu (Pseudo) 3D [V2.2]
INTRODUCCION:
Bello y simple un Script de menu con efecto 3D
sinceramente espectacular un diseño sencillo
pero con un efecto impresionante.
CARACTERISTICAS
-Uso simple
-Customizable
-Plug 'n Play
-Posibilidad de añadir musica al menu
IMAGENES DE MUESTRA:
-Pegar el Script encima de Main
-Configurar el módulo Gab :: RingMenu3D al inicio de la secuencia de comandos
SCRIPT:
- Código:
#=============================================================================
# Gab Ring Menu 3D
#-----------------------------------------------------------------------------
# Autor: Gab!
# Data: 28/11/12
#-----------------------------------------------------------------------------
# Deixa o menu com perspectiva 3D.
#=============================================================================
module Gab
module RingMenu3D
#=============================================================================
# * CONFIGURAÇÃO
#=============================================================================
# ID dos ícones
ICONS = [
192, # Itens
112, # Habilidades
169, # Equipamentos
14, # Status
12, # Formação
117, # Salvar
121 # Sair
]
# Fonte
FNAME = "Trebuchet MS" # Nome
FSIZE = 19 # Tamanho
FCOLOR = [255, 255, 255, 200] # Cor (R,G,B,A)
# Raios
R1 = 90 # Para que o efeito ocorra,
R2 = 20 # é necessário que R1 > R2.
# Precisão de movimento dos ícones (Quanto maior, mais lento)
# Valores sugeridos:
# 1 = Instantâneo
# 5 = Rápido
# 10 = Mediano
# 20 = Lento
MV = 10
# Frequência do movimento dos characters (Quanto maior, mais lento)
CFREQ = 15
# BGM (Deixar em branco para remover)
BGM = "Battle3"
# BGS (Deixar em branco para remover)
BGS = "Clock"
# Tempo de fade no audio para sair da cena (milissegundos)
AudioFade = 1000
# Janelas adicionais
Windows = {
mapName: [ # Nome do mapa
true, # Mostrar?
0, # Posição X
0, # Posição Y
400, # Largura
231, # Ícone
0, # Opacidade
],
time: [ # Tempo de jogo
true, # Mostrar?
0, # Posição X
34, # Posição Y
160, # Largura
280, # Ícone
0, # Opacidade
],
gold: [ # Dinheiro
true, # Mostrar?
0, # Posição X
68, # Posição Y
160, # Largura
361, # Ícone
0, # Opacidade
]
}
#=============================================================================
# * FIM DA CONFIGURAÇÃO
#=============================================================================
end
end
Object.send(:remove_const, :Scene_Menu)
class Scene_Menu < Scene_Base
#--------------------------------------------------------------------------
# ** Base para as janelas do menu
#--------------------------------------------------------------------------
class MenuWindow < Window_Base
def initialize(x, y, width, icon, opacity)
super(x, y, width, fitting_height(1))
@icon = icon
self.opacity = opacity
self.contents.font.name = Gab::RingMenu3D::FNAME
self.contents.font.size = Gab::RingMenu3D::FSIZE
self.contents.font.color = Color.new(*Gab::RingMenu3D::FCOLOR)
self.contents.font.outline = false
self.contents.font.shadow = true
draw_icon(@icon, 0, 0)
@clear_rect = Rect.new(30, 0, contents.width - 31, contents.height)
refresh
end
def refresh
self.contents.clear_rect(@clear_rect)
text_size = self.contents.width - 32
self.contents.draw_text(30, 0, text_size, self.contents.height, text, align)
end
def align
return 2
end
def update
super
refresh if (Graphics.frame_count % Graphics.frame_rate) == 0
end
def text
return ""
end
end
#--------------------------------------------------------------------------
# ** Nome do mapa
#--------------------------------------------------------------------------
class MenuWindowMapName < MenuWindow
def text
$game_map.display_name
end
def align
return 0
end
end
#--------------------------------------------------------------------------
# ** Tempo de jogo
#--------------------------------------------------------------------------
class MenuWindowTime < MenuWindow
def text
total_sec = Graphics.frame_count / Graphics.frame_rate
hour = total_sec / 60 / 60
min = total_sec / 60 % 60
sec = total_sec % 60
sprintf("%02d:%02d:%02d", hour, min, sec)
end
end
#--------------------------------------------------------------------------
# ** Dinheiro
#--------------------------------------------------------------------------
class MenuWindowGold < MenuWindow
def text
$game_party.gold.to_s
end
end
#--------------------------------------------------------------------------
# * Inicialização do processo
#--------------------------------------------------------------------------
def start
super
@vocabulary = [
Vocab::item,
Vocab::skill,
Vocab::equip,
Vocab::status,
Vocab::formation,
Vocab::save,
Vocab::game_end
]
@actorsNames = $game_party.members.map{|actor| actor.name}
create_background
@sprite = Sprite_Character.new(@main_viewport, $game_player)
@index = 0
@actorIndex = 0
@stage = 0
@pattern = 1
@actor1 = nil
@actor2 = nil
@bgm = RPG::BGM.new(Gab::RingMenu3D::BGM)
@bgs = RPG::BGS.new(Gab::RingMenu3D::BGS)
@bgm.play
@bgs.play
precalculus
create_icons
create_legend
create_actor_selection
create_windows
end
#--------------------------------------------------------------------------
# * Finalização do processo
#--------------------------------------------------------------------------
def terminate
super
RPG::BGM.fade(Gab::RingMenu3D::AudioFade)
RPG::BGS.fade(Gab::RingMenu3D::AudioFade)
dispose_background
@icons.each(&:dispose)
@actors.each(&:dispose)
@windows.each(&:dispose)
@sprite.dispose
@legend.dispose
Input.update
$game_map.autoplay
end
#--------------------------------------------------------------------------
# * Disposição do plano de fundo
#--------------------------------------------------------------------------
def dispose_background
@background_sprite.dispose
end
#--------------------------------------------------------------------------
# * Criação do plano de fundo
#--------------------------------------------------------------------------
def create_background
@background_sprite = Sprite.new
@background_sprite.bitmap = SceneManager.background_bitmap
@background_sprite.color.set(16, 16, 16, 128)
end
#--------------------------------------------------------------------------
# * Pré-calculo
#--------------------------------------------------------------------------
def precalculus
@elIcons = 2 * Math::PI / Gab::RingMenu3D::ICONS.size
@basePointIcons = @sprite.y + Gab::RingMenu3D::R2 * (Math.sin(-@elIcons) - 0.5)
@maxDifIcons = @sprite.y + Gab::RingMenu3D::R2 * Math.sin(Math::PI - @elIcons) - @basePointIcons
@moveTimesIcons = @elIcons / Gab::RingMenu3D::MV
@addIcons = 0
@elActors = 2 * Math::PI / $game_party.members.size
@basePointActors = @sprite.y + (Gab::RingMenu3D::R2 + 24) * Math.sin(-@elIcons)
@maxDifActors = @sprite.y + (Gab::RingMenu3D::R2 + 24) * Math.sin(Math::PI - @elActors) - @basePointActors
@moveTimesActors = @elActors / Gab::RingMenu3D::MV
@addActors = 0
end
#--------------------------------------------------------------------------
# * Criação dos ícones
#--------------------------------------------------------------------------
def create_icons
iconset = Cache.system("Iconset")
@icons = []
Gab::RingMenu3D::ICONS.each_with_index{|icon_index, index|
sprite = Sprite.new
sprite.bitmap = iconset
sprite.src_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
sprite.ox = sprite.width / 2
sprite.oy = sprite.height / 2
@icons << sprite
}
@icons[4].tone = Tone.new(0, 0, 0, 255) if $game_party.members.size <= 1
@icons[5].tone = Tone.new(0, 0, 0, 255) if $game_system.save_disabled
adjust_icons
end
#--------------------------------------------------------------------------
# * Cria a legenda
#--------------------------------------------------------------------------
def create_legend
base, c = Bitmap.new(1, 1), nil
base.font.name = Gab::RingMenu3D::FNAME
base.font.size = Gab::RingMenu3D::FSIZE
base.font.color = Color.new(*Gab::RingMenu3D::FCOLOR)
maxLen = (@vocabulary + @actorsNames).inject(0){|a, b|
c = base.text_size(b)
c.width > a ? c.width : a
}
@legend = Sprite.new
@legend.bitmap = Bitmap.new(maxLen + 5, c.height)
@legend.bitmap.font.name = Gab::RingMenu3D::FNAME
@legend.bitmap.font.size = Gab::RingMenu3D::FSIZE
@legend.bitmap.font.color = Color.new(*Gab::RingMenu3D::FCOLOR)
@legend.ox = @legend.width / 2
@legend.oy = @legend.height / 2
@legend.x = @icons.first.x
@legend.y = @icons.first.y + @icons.first.height
base.dispose
legend_refresh
end
#--------------------------------------------------------------------------
# * Cria seleção de atores
#--------------------------------------------------------------------------
def create_actor_selection
@actors = $game_party.members.map{|char|
actor = Sprite.new
actor.bitmap = Cache.character(char.character_name)
sign = char.character_name[/^[\!\$]./]
if sign && sign.include?('$')
cw = actor.bitmap.width / 3
ch = actor.bitmap.height / 4
else
cw = actor.bitmap.width / 12
ch = actor.bitmap.height / 8
end
actor.ox = cw / 2
actor.oy = ch
actor.x = @sprite.x + 1.5 * Gab::RingMenu3D::R1
actor.instance_variable_set(:@charData, [char, cw, ch])
actor
}
adjust_actors
update_actors_src
end
#--------------------------------------------------------------------------
# * Cria janelas
#--------------------------------------------------------------------------
def create_windows
windows = Gab::RingMenu3D::Windows
@windows = []
@windows << MenuWindowMapName.new(*windows[:mapName][1,5]) if windows[:mapName][0]
@windows << MenuWindowTime.new(*windows[:time][1,5]) if windows[:time][0]
@windows << MenuWindowGold.new(*windows[:gold][1,5]) if windows[:gold][0]
end
#--------------------------------------------------------------------------
# * Posicionamento e ajuste de opacidade dos ícones
#--------------------------------------------------------------------------
def adjust_icons
el = 2 * Math::PI / @icons.size
t = @addIcons - el
@icons.each{|sprite|
t += el
sprite.x = @sprite.x + Math.sin(t) * Gab::RingMenu3D::R1
sprite.y = @sprite.y + Gab::RingMenu3D::R2 * (Math.cos(t) - 0.5)
dif = (sprite.y - @basePointIcons) / @maxDifIcons
sprite.opacity = @stage == 0 ? 127 + 255 * dif : 0
sprite.zoom_x = sprite.zoom_y = [0.5 + dif, 1].min
}
end
#--------------------------------------------------------------------------
# * Posicionamento e ajuste de opacidade dos atores
#--------------------------------------------------------------------------
def adjust_actors
el = 2 * Math::PI / @actors.size
t = @addActors - el
@actors.each{|sprite|
t += el
sprite.x = @sprite.x + Math.sin(t) * (Gab::RingMenu3D::R1 + 24)
sprite.y = @sprite.y + (Gab::RingMenu3D::R2 + 24) * Math.cos(t)
dif = (sprite.y - @basePointActors) / @maxDifActors
sprite.opacity = @stage != 0 ? 127 + 255 * dif : 0
sprite.zoom_x = sprite.zoom_y = [0.5 + dif, 1].min
}
end
#--------------------------------------------------------------------------
# * Movimento dos ícones
#--------------------------------------------------------------------------
def rotateIcons(dir)
@moveTimesIcons *= -1 if dir == :right
Sound.play_cursor
Gab::RingMenu3D::MV.times{|sprite|
@addIcons += @moveTimesIcons
@addIcons %= Math::PI * 2
adjust_icons
Graphics.update
}
if dir == :right
@moveTimesIcons *= -1
@index += 1
else
@index -= 1
end
@index %= @icons.size
legend_refresh
end
#--------------------------------------------------------------------------
# * Movimento dos atores
#--------------------------------------------------------------------------
def rotateActors(dir)
@moveTimesActors *= -1 if dir == :right
Sound.play_cursor
Gab::RingMenu3D::MV.times{|sprite|
@addActors += @moveTimesActors
@addActors %= Math::PI * 2
adjust_actors
Graphics.update
}
if dir == :right
@moveTimesActors *= -1
@actorIndex += 1
else
@actorIndex -= 1
end
@actorIndex %= @actors.size
legend_refresh
end
#--------------------------------------------------------------------------
# * Atualiza legenda
#--------------------------------------------------------------------------
def legend_refresh
@legend.bitmap.clear
text = @stage == 0 ? @vocabulary[@index] : @actorsNames[@actorIndex]
@legend.bitmap.draw_text(@legend.bitmap.rect, text, 1)
@legend.update
end
#--------------------------------------------------------------------------
# * Atualização Base
#--------------------------------------------------------------------------
def update
super
@windows.each(&:update)
case @stage
when 0
update_main_input
when 1, 2
@stage == 1 ? update_actors_input : update_formation_input
if (Graphics.frame_count % Gab::RingMenu3D::CFREQ) == 0
@pattern = (@pattern + 1) % 3
end
update_actors_src
end
end
#--------------------------------------------------------------------------
# * Atualização de input padrão
#--------------------------------------------------------------------------
def update_main_input
if Input.repeat?(:LEFT)
rotateIcons(:left)
elsif Input.repeat?(:RIGHT)
rotateIcons(:right)
elsif Input.trigger?(:B)
Sound.play_cancel
process_return
elsif Input.trigger?(:C)
process_confirm
end
end
#--------------------------------------------------------------------------
# * Atualização de entrada na seleção de ator
#--------------------------------------------------------------------------
def update_actors_input
if Input.repeat?(:LEFT)
rotateActors(:left)
elsif Input.repeat?(:RIGHT)
rotateActors(:right)
elsif Input.trigger?(:B)
Sound.play_cancel
process_return
elsif Input.trigger?(:C)
Sound.play_ok
process_special_confirm
end
end
#--------------------------------------------------------------------------
# * Atualização de entrada na seleção de ator
#--------------------------------------------------------------------------
def update_actors_input
if Input.repeat?(:LEFT)
rotateActors(:left)
elsif Input.repeat?(:RIGHT)
rotateActors(:right)
elsif Input.trigger?(:B)
Sound.play_cancel
process_return
elsif Input.trigger?(:C)
Sound.play_ok
process_special_confirm
end
end
#--------------------------------------------------------------------------
# * Atualização de troca de formação
#--------------------------------------------------------------------------
def update_formation_input
if Input.repeat?(:LEFT)
rotateActors(:left)
elsif Input.repeat?(:RIGHT)
rotateActors(:right)
elsif Input.trigger?(:B)
Sound.play_cancel
process_return
elsif Input.trigger?(:C)
process_formation_confirm
end
end
#--------------------------------------------------------------------------
# * Processa confirmação
#--------------------------------------------------------------------------
def process_confirm
case @index
when 0 # Item
Sound.play_ok
SceneManager.call(Scene_Item)
when 1, 2, 3, 4 # Skill, Equip, Status, Formação
return Sound.play_buzzer if ($game_party.members.size <= 1 && @index == 4)
Sound.play_ok
@stage = @index == 4 ? 2 : 1
adjust_actors
adjust_icons
legend_refresh
@legend.y -= 28
when 5 # Save
if ($game_system.save_disabled)
Sound.play_buzzer
else
SceneManager.call(Scene_Save)
Sound.play_ok
end
when 6 # Sair
Sound.play_ok
SceneManager.call(Scene_End)
end
end
#--------------------------------------------------------------------------
# * Processa confirmação das opções que requerem seleção de ator
#--------------------------------------------------------------------------
def process_special_confirm
$game_party.menu_actor = $game_party.members[@actorIndex]
case @index
when 1 # Skill
SceneManager.call(Scene_Skill)
when 2 # Equip
SceneManager.call(Scene_Equip)
when 3 # Status
SceneManager.call(Scene_Status)
end
end
#--------------------------------------------------------------------------
# * Processa confirmação de troca de formação
#--------------------------------------------------------------------------
def process_formation_confirm
if @actor1.nil?
@actor1 = @actorIndex
@actors[@actor1].tone = Tone.new(150, 150, 150, 0)
Sound.play_ok
else
return Sound.play_buzzer if @actor1 == @actorIndex
Sound.play_ok
$game_party.swap_order(@actor1, @actorIndex)
@actorsNames = $game_party.members.map{|actor| actor.name}
@sprite.dispose
@sprite = Sprite_Character.new(@main_viewport, $game_player)
@actors.each(&:dispose)
create_actor_selection
@actors[@actor1].tone = Tone.new(0, 0, 0, 0)
@stage = 0
@actor1 = nil
adjust_icons
adjust_actors
legend_refresh
@legend.y += 28
end
end
#--------------------------------------------------------------------------
# * Processa retorno
#--------------------------------------------------------------------------
def process_return
case @stage
when 0
return_scene
when 1
case @index
when 1, 2, 3
@stage = 0
adjust_actors
adjust_icons
legend_refresh
@legend.y += 28
when 4
if !@actor1.nil?
@actors[@actor1].tone = Tone.new(0, 0, 0, 0)
return @actor1 = nil
end
@stage = 0
adjust_actors
adjust_icons
legend_refresh
@legend.y += 28
end
end
end
#--------------------------------------------------------------------------
# * Atualiza characters
#--------------------------------------------------------------------------
def update_actors_src
@actors.each{|sprite|
char, cw, ch = sprite.instance_variable_get(:@charData)
index = char.character_index
sx = (index % 4 * 3 + @pattern) * cw
sy = (index / 4 * 4) * ch
sprite.src_rect.set(sx, sy, cw, ch)
}
end
end
Eso es todo un saludo y disfrutenlo.