Hello guys =)
I'm using this script of Window Command:
#==============================================================================
# ** Window_ActorCommand
#------------------------------------------------------------------------------
# This window is used to select actor commands, such as "Attack" or "Skill".
#==============================================================================
class Window_ActorCommand
COMMAND_ICONS = [
# ID Icone
22, # Attacco
160, # Skill
40, # Guardia
144, # Oggetti
48 # Fuggi
]
SKILL_ICONS = {}
USE_EQUIPMENT_ICON_ATTACK = true
USE_EQUIPMENT_ICON_GUARD = true
VERT_PIXEL_SPACING = 0
SELECTION_ZOOM = 2.0
UNSELECT_ZOOM = 1.0
SELECTION_RECT = false
ICON_Y_OFFSET = 56
FONT_COLOR = Color.new(255, 255, 255)
FONT_BOLD = false
USE_FRONT_WINDOW = false
USE_DUMMY_WINDOW = true
DUMMY_WINDOW_WIDTH_OFFSET = 40
def initialize
cmd_count = $game_troop.can_escape ? 5 : 4
create_icon_graphics(cmd_count)
super(cmd_count * (24 + VERT_PIXEL_SPACING) + 32, [], cmd_count, 1)
@dummy_window = Window_Base.new(self.x - DUMMY_WINDOW_WIDTH_OFFSET / 2, self.y, self.width - DUMMY_WINDOW_WIDTH_OFFSET, self.height)
self.z += 1
self.opacity = 0 unless USE_FRONT_WINDOW
self.active = false
@spacing = VERT_PIXEL_SPACING
self.x = x
self.y = y
self.height += ICON_Y_OFFSET
self.contents.font.color = FONT_COLOR
self.contents.font.bold = FONT_BOLD
end
def get_commands(actor)
[
Vocab::attack,
(actor.class.skill_name_valid ? actor.class.skill_name : Vocab::skill),
Vocab::guard,
Vocab::item,
$game_troop.can_escape ? Vocab::escape : nil
].compact
end
def setup(actor)
@actor = actor
@commands = get_commands(actor)
@item_max = @commands.size
refresh
self.index = 0
end
def update_cursor
self.oy = ICON_Y_OFFSET
if @index < 0 or !SELECTION_RECT
self.cursor_rect.empty
else
rect = item_rect(@index)
self.cursor_rect = rect
end
if self.index != @last_index
@last_index = index
if index >= 0
self.contents.clear
self.contents.draw_text(self.contents.rect, @commands[index], 1)
else
self.contents.clear
end
end
end
def refresh
self.contents.clear
@last_index = nil
return if @actor.nil?
@icon_sprites.each_with_index { |s, i|
if i == 0 and USE_EQUIPMENT_ICON_ATTACK
weapon = @actor.weapons.compact[0]
if weapon != nil
s.icon_index = weapon.icon_index
else
s.icon_index = COMMAND_ICONS[i]
end
elsif i == 1
id = @actor.nil? ? 0 : @actor.class.id
s.icon_index = SKILL_ICONS[id] || COMMAND_ICONS[i]
elsif i == 2 and USE_EQUIPMENT_ICON_GUARD
shield = @actor.equips[0]
if shield.is_a?(RPG::Armor) and shield.kind == 0
s.icon_index = shield.icon_index
else
s.icon_index = COMMAND_ICONS[i]
end
else
s.icon_index = COMMAND_ICONS[i]
end
}
end
def update
last_index = index
@icon_sprites.each { |s| s.update }
super
self.index = index
end
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = 24 + @spacing
rect.height = 24 + @spacing
rect.x = index * (24 + @spacing) - @spacing / 2
rect.y = 0 - @spacing / 2
return rect
end
def dispose
super
dispose_icon_graphics
end
def dispose_icon_graphics
@icon_sprites.each { |s| s.dispose }
@dummy_window.dispose
end
def create_icon_graphics(cmd_count)
@icon_sprites = []
cmd_count.times { |t|
sprite = SpriteIcon.new
@icon_sprites[t] = sprite
}
end
def x=(new_x)
super
@icon_sprites.each_with_index { |s, i|
# Modifica per spostare l'asse orizzontale
s.x = self.x + 16 + 12 + item_rect(i).x + @spacing / 2
}
@dummy_window.x = self.x + (self.width - @dummy_window.width) / 2 if @dummy_window
end
def index=(new_index)
super
@icon_sprites.each { |s|
s.active = s == @icon_sprites[new_index]
}
end
def y=(new_y)
super
@icon_sprites.each_with_index { |s, i| s.y = self.y + 16 + item_rect(i).y + 12 + @spacing / 2}
@dummy_window.y = self.y - self.oy if @dummy_window
end
def viewport=(new_vw)
super
@icon_sprites.each { |s| s.viewport = new_vw}
@dummy_window.viewport = new_vw
end
def visible=(new_vis)
super
@icon_sprites.each { |s| s.visible = new_vis }
@dummy_window.visible = new_vis if USE_DUMMY_WINDOW
end
end
class SpriteIcon < Sprite
def initialize(viewport = nil, icon_index = -1)
super(viewport)
self.bitmap = Cache.system("IconSet")
self.icon_index = icon_index
self.active = false
self.ox = self.oy = 12
end
def icon_index=(new_index)
if @icon_index != new_index
@icon_index = new_index
if new_index >= 0
rect = Rect.new(@icon_index % 16 * 24, @icon_index / 16 * 24, 24, 24)
self.src_rect = rect
else
self.src_rect = Rect.new(0, 0, 0, 0)
end
end
end
def active=(new_active)
if @active != new_active
@active = new_active
if @active
self.zoom_x = self.zoom_y = Window_ActorCommand::SELECTION_ZOOM
self.color.set(0, 0, 0, 0)
self.z = 101
else
self.z = 100
self.zoom_x = self.zoom_y = Window_ActorCommand::UNSELECT_ZOOM
self.color.set(0, 0, 0, 128)
end
end
end
end
For now, the icons are horizontally, and I would put them vertically.
Besides this, I wish I could make a change.
I would like the selection of choice, remained at the center, while the icons flow.
Exsample:
Function:
If I click down, the icon of choice must come to the center, while others remain small.