Isto é uma pré-visualização de um tema em Hitskin.com
Instalar o tema • Voltar para a ficha do tema
Nova janela de descrição de itens e habilidades
Aldeia RPG :: VXA-OS Engine :: Recursos :: Scripts
Página 1 de 1
Nova janela de descrição de itens e habilidades
Substitua TODO o script [VS] Sprite_Desc do CLIENTE por:
Imagens:
Créditos:
Paulo Soreto
- Código:
#==============================================================================
# ** Sprite_Desc
#------------------------------------------------------------------------------
# Esta classe lida com a exibição das informações de itens
# e habilidades.
#------------------------------------------------------------------------------
# Autor: Paulo Soreto
#==============================================================================
class Sprite_Desc
attr_writer :z
def visible=(visible)
dispose
end
def bitmap
self
end
def dispose
@bitmap.dispose if @bitmap
end
def refresh(item)
x = Mouse.x + 12 + 200 > Graphics.width ? Graphics.width - 200 : Mouse.x + 12
y = Mouse.y + 12 + 170 > Graphics.height ? Graphics.height - 170 : Mouse.y + 12
position = Display::Position.new x, y
if item.is_a?(RPG::Item)
i = Display::Consumable::Data.new
i.name = item.name
i.description = item.description
i.level = item.level
i.consumable = item.consumable
i.key_item = item.key_item?
@bitmap = Display::Consumable::Renderer.new(position, i)
elsif item.is_a?(RPG::EquipItem)
i = Display::Equippable::Data.new
i.name = item.name
i.description = item.description
i.level = item.level
i.equippable = $game_actors[1].equippable?(item)
i.attributes = {
'atk' => item.params[0],
'def' => item.params[1],
'matk' => item.params[2],
'mdef' => item.params[3],
'agi' => item.params[4],
'luck' => item.params[5],
'mhp' => item.params[6],
'mmp' => item.params[7]
}
i.price = item.price
x = Mouse.x + 12 + 200 > Graphics.width ? Graphics.width - 200 : Mouse.x + 12
y = Mouse.y + 12 + 255 > Graphics.height ? Graphics.height - 255 : Mouse.y + 12
position = Display::Position.new x, y
@bitmap = Display::Equippable::Renderer.new(position, i)
else
i = Display::Skill::Data.new
i.name = item.name
i.description = item.description
i.base_damage = item.damage.eval($game_actors[1], Game_Battler.new, $game_variables).abs
i.mp_cost = item.mp_cost
i.precision = item.success_rate
@bitmap = Display::Skill::Renderer.new(position, i)
end
@bitmap.using_shop = ($windows[:shop].visible && ($windows[:shop].in_area? || $windows[:item].in_area? || $windows[:equip].in_area?))
@bitmap.render
end
end
#=============================================================================
# * Display
#=============================================================================
module Display
#=============================================================================
# * Position
#=============================================================================
class Position
attr_reader :x
attr_reader :y
def initialize(x, y)
@x = x
@y = y
end
end
#=============================================================================
# * Size
#=============================================================================
class Size
attr_reader :width
attr_reader :height
def initialize(width, height)
@width = width
@height = height
end
end
#-----------------------------------------------------------------------------
# * word_wrap copied from vxa-os, made by Valentine
#-----------------------------------------------------------------------------
def self.word_wrap(text, width)
width -= 20
bitmap = Bitmap.new(1, 1)
return [text] if bitmap.text_size(text).width <= width
lines = []
line = ''
line_size = 0
text.each_line(' ') do |word|
word_size = bitmap.text_size(word).width
if word_size > width
line, lines = character_wrap(word, width, bitmap, line, lines)
elsif line_size + word_size <= width
line << word
line_size += word_size
else
lines << line
line = word
line_size = word_size
end
end
bitmap.dispose
lines << line
end
#=============================================================================
# * Renderer
#=============================================================================
class Renderer
attr_accessor :using_shop
def initialize window, position, data
@window = window
@data = data
@sprite = create_sprite position
end
def window
@window
end
def bitmap
@sprite.bitmap
end
def width
bitmap.width
end
def height
bitmap.height
end
def data
@data
end
def background_color
@window::BackgroundColor
end
def dispose
@sprite.dispose
end
def create_sprite(position)
size = @window::Size
sprite = Sprite.new
sprite.x = position.x
sprite.y = position.y
sprite.z = 1000
sprite.bitmap = Bitmap.new size.width, size.height
return sprite
end
def apply_style style, validation = nil
bitmap.font.size = style::Size
bitmap.font.outline = style::Outline
bitmap.font.bold = style::Bold
bitmap.font.shadow = style::Shadow
if style::ForegroundColor.is_a? Color
bitmap.font.color.set style::ForegroundColor
elsif style::ForegroundColor.is_a? Proc
bitmap.font.color.set style::ForegroundColor.call(validation)
end
end
def draw_text settings, text
x = settings::Position.x
y = settings::Position.y
width = settings::Size.width
height = settings::Size.height
align = settings::Align
bitmap.draw_text x, y, width, height, text, align
end
end
#=============================================================================
# * Consumable Items
#=============================================================================
module Consumable
#---------------------------------------------------------------------------
# ** Settings
#---------------------------------------------------------------------------
module Settings
#-------------------------------------------------------------------------
# * Window
#-------------------------------------------------------------------------
module Window
BackgroundColor = Color.new(0, 0, 0, 180).freeze
Size = Size.new 200, 170
end
#-------------------------------------------------------------------------
# * Name
#-------------------------------------------------------------------------
module Name
Position = Position.new 0, 10
Size = Size.new 200, 20
Align = 1
module Style
Size = 22
ForegroundColor = Color.new(70, 171, 242).freeze
Outline = false
Shadow = false
Bold = true
end
end
#-------------------------------------------------------------------------
# * Level
#-------------------------------------------------------------------------
module Level
module Label
Position = Position.new 65, 30
Size = Size.new 100, 20
Align = 0
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Bold = true
Shadow = false
end
end
module Value
Position = Position.new 115, 30
Size = Size.new 60, 20
Align = 0
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Bold = true
Shadow = false
end
end
end
#-------------------------------------------------------------------------
# * Description
#-------------------------------------------------------------------------
module Description
Position = Position.new 0, 60
Size = Size.new 60, 20
Align = 1
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Shadow = false
Bold = false
end
end
#-------------------------------------------------------------------------
# * Price
#-------------------------------------------------------------------------
module Price
Position = Position.new 150, Window::Size.height - 20
Size = Size.new 50, 20
Align = 1
module Style
Size = 20
ForegroundColor = Color.new(209, 54, 54).freeze
Outline = false
Shadow = true
Bold = true
BackgroundColor = Color.new(0, 0, 0, 110).freeze
end
end
#-------------------------------------------------------------------------
# * Consumable
#-------------------------------------------------------------------------
module Consumable
module Label
Position = Position.new 10, 110
Size = Size.new 100, 20
Align = 0
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Bold = true
Shadow = false
end
end
module Value
Position = Position.new 110, 110
Size = Size.new 60, 20
Align = 0
Text = ->(bool) do
bool ? 'Yes' : 'No'
end
module Style
Size = 18
ForegroundColor = ->(bool) do
bool ? Color.new(100, 219, 100) : Color.new(219, 100, 100)
end
Outline = false
Bold = true
Shadow = false
end
end
end
#-------------------------------------------------------------------------
# * KeyItem
#-------------------------------------------------------------------------
module KeyItem
module Label
Position = Position.new 10, 130
Size = Size.new 100, 20
Align = 0
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Bold = true
Shadow = false
end
end
module Value
Position = Position.new 60, 130
Size = Size.new 100, 20
Align = 0
Text = ->(bool) do
bool ? 'Importante' : 'Normal'
end
module Style
Size = 18
ForegroundColor = ->(bool) do
bool ? Color.new(100, 100, 219) : Color.new(219, 219, 219)
end
Outline = false
Bold = true
Shadow = false
end
end
end
end
#---------------------------------------------------------------------------
# * Data Structure
#---------------------------------------------------------------------------
class Data
attr_accessor :name
attr_accessor :level
attr_accessor :description
attr_accessor :consumable
attr_accessor :key_item
attr_accessor :price
end
#---------------------------------------------------------------------------
# * Renderer
#---------------------------------------------------------------------------
class Renderer < Display::Renderer
def initialize position, data
super Settings::Window, position, data
end
def render
render_background
render_name
render_level
render_description
render_consumable
render_key_item
end
def render_background
bitmap.fill_rect 0, 0, width, height, background_color
end
def render_name
settings = Settings::Name
style = settings::Style
apply_style style
draw_text settings, data.name
end
def render_level
settings = Settings::Level
label = settings::Label
value = settings::Value
apply_style label::Style
draw_text label, 'Level:'
apply_style value::Style, true
draw_text value, data.level.to_s
end
def render_description
settings = Settings::Description
apply_style settings::Style
pos = settings::Position
line_height = settings::Size.height
Display.word_wrap(data.description, bitmap.width).each_with_index do |line, i|
bitmap.draw_text(
pos.x, pos.y + i * line_height,
bitmap.width, line_height, line, settings::Align
)
end
end
def render_consumable
settings = Settings::Consumable
label = settings::Label
value = settings::Value
apply_style label::Style
draw_text label, 'Consumível:'
apply_style value::Style, data.consumable
draw_text value, value::Text.call(data.consumable)
end
def render_key_item
settings = Settings::KeyItem
label = settings::Label
value = settings::Value
apply_style label::Style
draw_text label, 'Tipo:'
apply_style value::Style, data.key_item
draw_text value, value::Text.call(data.key_item)
end
end
end
#=============================================================================
# * Equippable Items
#=============================================================================
module Equippable
#---------------------------------------------------------------------------
# ** Settings
#---------------------------------------------------------------------------
module Settings
#-------------------------------------------------------------------------
# * Window
#-------------------------------------------------------------------------
module Window
BackgroundColor = Color.new(0, 0, 0, 180).freeze
Size = Size.new 200, 255
end
#-------------------------------------------------------------------------
# * Name
#-------------------------------------------------------------------------
module Name
Position = Position.new 0, 10
Size = Size.new 200, 20
Align = 1
module Style
Size = 22
ForegroundColor = Color.new(70, 171, 242).freeze
Outline = false
Shadow = false
Bold = true
end
end
#-------------------------------------------------------------------------
# * Level
#-------------------------------------------------------------------------
module Level
module Label
Position = Position.new 65, 30
Size = Size.new 100, 20
Align = 0
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Bold = true
Shadow = false
end
end
module Value
Position = Position.new 115, 30
Size = Size.new 60, 20
Align = 0
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Bold = true
Shadow = false
end
end
end
#-------------------------------------------------------------------------
# * Description
#-------------------------------------------------------------------------
module Description
Position = Position.new 0, 60
Size = Size.new 60, 20
Align = 1
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Shadow = false
Bold = false
end
end
#-------------------------------------------------------------------------
# * Price
#-------------------------------------------------------------------------
module Price
Position = Position.new 150, Window::Size.height - 20
Size = Size.new 50, 20
Align = 1
module Style
Size = 20
ForegroundColor = Color.new(209, 54, 54).freeze
Outline = false
Shadow = true
Bold = true
BackgroundColor = Color.new(0, 0, 0, 110).freeze
end
end
#-------------------------------------------------------------------------
# * Attributes
#-------------------------------------------------------------------------
module Attributes
HideZero = true
Columns = 2
Lines = 4
Offset = Position.new 20, 130
LabelColor = Color.new(245, 174, 93).freeze
ValueColor = Color.new(230, 230, 230).freeze
CellSize = Size.new 80, 20
ValueMargin = 60
end
#-------------------------------------------------------------------------
# * Equippable
#-------------------------------------------------------------------------
module Equippable
module Label
Position = Position.new 10, 220
Size = Size.new 100, 20
Align = 0
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Shadow = false
Bold = true
end
end
module Value
Position = Position.new 100, 220
Size = Size.new 60, 20
Align = 0
Text = ->(bool) do
bool ? 'Yes' : 'No'
end
module Style
Size = 18
ForegroundColor = ->(bool) do
bool ? Color.new(100, 219, 100) : Color.new(219, 100, 100)
end
Outline = false
Shadow = false
Bold = true
end
end
end
end
#---------------------------------------------------------------------------
# * Data Structure
#---------------------------------------------------------------------------
class Data
attr_accessor :name
attr_accessor :level
attr_accessor :description
attr_accessor :equippable
attr_accessor :attributes
attr_accessor :price
end
#---------------------------------------------------------------------------
# * Renderer
#---------------------------------------------------------------------------
class Renderer < Display::Renderer
def initialize position, data
super Settings::Window, position, data
end
def render
render_background
render_name
render_level
render_description
render_equippable
render_attributes
render_price if @using_shop
end
def render_background
bitmap.fill_rect 0, 0, width, height, background_color
end
def render_name
apply_style Settings::Name::Style
draw_text Settings::Name, data.name
end
def render_level
apply_style Settings::Level::Label::Style
draw_text Settings::Level::Label, 'Level:'
apply_style Settings::Level::Value::Style
draw_text Settings::Level::Value, data.level.to_s
end
def render_description
settings = Settings::Description
apply_style settings::Style
pos = settings::Position
line_height = settings::Size.height
Display.word_wrap(data.description, bitmap.width).each_with_index do |line, i|
bitmap.draw_text(
pos.x, pos.y + i * line_height,
bitmap.width, line_height, line, settings::Align
)
end
end
def render_equippable
settings = Settings::Equippable
label = settings::Label
value = settings::Value
apply_style label::Style
draw_text label, 'Equipável:'
apply_style value::Style, data.equippable
draw_text value, value::Text.call(data.equippable)
end
def render_attributes
columns = Settings::Attributes::Columns
offset = Settings::Attributes::Offset
lines = Settings::Attributes::Lines
hide_zero = Settings::Attributes::HideZero
label_color = Settings::Attributes::LabelColor
value_color = Settings::Attributes::ValueColor
cell_size = Settings::Attributes::CellSize
value_margin = Settings::Attributes::ValueMargin
column_index = 0
line_index = 0
data.attributes.each do |attr|
next if hide_zero && attr[1] == 0
if line_index >= lines
column_index += 1
line_index = 0
end
x = offset.x + column_index * cell_size.width
y = offset.y + line_index * cell_size.height
w = cell_size.width
h = cell_size.height
bitmap.font.color.set(label_color)
bitmap.draw_text x, y, w, h, attr[0]
bitmap.font.color.set(value_color)
bitmap.draw_text x + value_margin, y, w, h, attr[1]
line_index += 1
end
end
def render_price
x = Settings::Price::Position.x
y = Settings::Price::Position.y
w = Settings::Price::Size.width
h = Settings::Price::Size.height
align = Settings::Price::Align
bg_color = Settings::Price::Style::BackgroundColor
bitmap.fill_rect x, y, w, h, bg_color
apply_style Settings::Price::Style
bitmap.draw_text x, y, w, h, "$#{data.price}", align
end
end
end
#=============================================================================
# * Skill
#=============================================================================
module Skill
#---------------------------------------------------------------------------
# ** Settings
#---------------------------------------------------------------------------
module Settings
#-------------------------------------------------------------------------
# * Window
#-------------------------------------------------------------------------
module Window
BackgroundColor = Color.new(0, 0, 0, 180).freeze
Size = Size.new 200, 170
end
#-------------------------------------------------------------------------
# * Name
#-------------------------------------------------------------------------
module Name
Position = Position.new 0, 10
Size = Size.new 200, 20
Align = 1
module Style
Size = 22
ForegroundColor = Color.new(70, 171, 242).freeze
Outline = false
Shadow = false
Bold = true
end
end
#-------------------------------------------------------------------------
# * Description
#-------------------------------------------------------------------------
module Description
Position = Position.new 0, 35
Size = Size.new 60, 20
Align = 1
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Shadow = false
Bold = false
end
end
#-------------------------------------------------------------------------
# * Base Damage
#-------------------------------------------------------------------------
module BaseDamage
module Label
Position = Position.new 25, 90
Size = Size.new 100, 20
Align = 1
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Shadow = false
Bold = false
end
end
module Value
Position = Position.new 90, 90
Size = Size.new 100, 20
Align = 1
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Shadow = false
Bold = false
end
end
end
#-------------------------------------------------------------------------
# * MP Cost
#-------------------------------------------------------------------------
module MpCost
module Label
Position = Position.new 25, 110
Size = Size.new 100, 20
Align = 1
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Shadow = false
Bold = false
end
end
module Value
Position = Position.new 90, 110
Size = Size.new 100, 20
Align = 1
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Shadow = false
Bold = false
end
end
end
#-------------------------------------------------------------------------
# * Precision
#-------------------------------------------------------------------------
module Precision
module Label
Position = Position.new 25, 130
Size = Size.new 100, 20
Align = 1
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Shadow = false
Bold = false
end
end
module Value
Position = Position.new 90, 130
Size = Size.new 100, 20
Align = 1
module Style
Size = 18
ForegroundColor = Color.new(219, 219, 219).freeze
Outline = false
Shadow = false
Bold = false
end
end
end
end
#---------------------------------------------------------------------------
# * Data Structure
#---------------------------------------------------------------------------
class Data
attr_accessor :name
attr_accessor :description
attr_accessor :base_damage
attr_accessor :mp_cost
attr_accessor :precision
end
#---------------------------------------------------------------------------
# * Renderer
#---------------------------------------------------------------------------
class Renderer < Display::Renderer
def initialize position, data
super Settings::Window, position, data
end
def render
render_background
render_name
render_description
render_base_damage
render_mp_cost
render_precision
end
def render_background
bitmap.fill_rect 0, 0, width, height, background_color
end
def render_name
apply_style Settings::Name::Style
draw_text Settings::Name, data.name
end
def render_description
settings = Settings::Description
apply_style settings::Style
pos = settings::Position
line_height = settings::Size.height
Display.word_wrap(data.description, bitmap.width).each_with_index do |line, i|
bitmap.draw_text(
pos.x, pos.y + i * line_height,
bitmap.width, line_height, line, settings::Align
)
end
end
def render_base_damage
apply_style Settings::BaseDamage::Label::Style
draw_text Settings::BaseDamage::Label, 'Base Damage:'
apply_style Settings::BaseDamage::Value::Style
draw_text Settings::BaseDamage::Value, data.base_damage.to_s
end
def render_mp_cost
apply_style Settings::MpCost::Label::Style
draw_text Settings::MpCost::Label, 'MP cost:'
apply_style Settings::MpCost::Value::Style
draw_text Settings::MpCost::Value, data.mp_cost.to_s
end
def render_precision
apply_style Settings::Precision::Label::Style
draw_text Settings::Precision::Label, 'Precision:'
apply_style Settings::Precision::Value::Style
draw_text Settings::Precision::Value, data.precision.to_s
end
end
end
end
Imagens:
Créditos:
Paulo Soreto
-JohnLennon- gosta desta mensagem
Tópicos semelhantes
» Descrição para habilidades
» [Resolvido]Comando de Descrição de itens - RGSS
» Dano minimo e máximo janela de habilidades
» Ajuda nova janela com botão
» [PEDIDO] Sistema de descrição de classe / Habilidades por Classe
» [Resolvido]Comando de Descrição de itens - RGSS
» Dano minimo e máximo janela de habilidades
» Ajuda nova janela com botão
» [PEDIDO] Sistema de descrição de classe / Habilidades por Classe
Aldeia RPG :: VXA-OS Engine :: Recursos :: Scripts
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos