Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Sprite_Hotbar
- #------------------------------------------------------------------------------
- # Esta classe lida com a exibição dos atalhos.
- #------------------------------------------------------------------------------
- # Autor: Valentine
- #==============================================================================
- class Sprite_Hotbar < Sprite2
- def initialize
- super
- self.bitmap = Bitmap.new(355, 40)
- self.x = adjust_x
- self.y = adjust_y
- self.z = 50
- @back = Cache.system('Hotbar')
- @iconset = Cache.system('Iconset')
- @dragable = true
- @old_item = nil
- create_desc
- refresh
- end
- def adjust_x
- Graphics.width / 2 - 127
- end
- def adjust_y
- Graphics.height - 70
- end
- def slot_width
- 28
- end
- def slot_height
- 28
- end
- def create_desc
- @desc_sprite = Sprite_Desc.new
- # Deixa a janela de informações sobre o inventário
- @desc_sprite.z = self.z + 100
- end
- def refresh
- draw_background
- draw_items
- end
- def draw_background
- self.bitmap.clear
- self.bitmap.blt(0, 0, @back, self.bitmap.rect)
- end
- def draw_items
- $game_actors[1].hotbar.each_with_index do |item, i|
- draw_icon(item, i) if item
- end
- end
- def x_slots
- [9, 43, 77, 111, 194, 228, 264, 296]
- end
- def draw_icon(item, index)
- rect = Rect.new(item.icon_index % 16 * 24, item.icon_index / 16 * 24, 24, 24)
- opacity = item.is_a?(RPG::Item) & !$game_party.has_item?(item) ? 160 : 255
- self.bitmap.blt(x_slots[index], 7, @iconset, rect, opacity)
- self.bitmap.draw_text(x_slots[index] - 8, 19, slot_width, 18, $game_party.item_number(item), 2) if item.is_a?(RPG::Item)
- end
- def show_desc(item)
- return if @old_item == item
- @desc_sprite.refresh(item)
- @old_item = item
- end
- def hide_desc
- @desc_sprite.visible = false
- @old_item = nil
- end
- def update
- super
- update_drop
- remove_item
- update_desc
- end
- def update_drop
- return if Mouse.press?(:L)
- return unless $cursor.object.is_a?(RPG::Item) || $cursor.object.is_a?(RPG::Skill)
- $game_actors[1].hotbar.each_index do |i|
- next unless in_area?(x_slots[i], 0, slot_width, slot_height)
- $network.send_change_hotbar(i, $cursor.type, $cursor.object.id)
- break
- end
- end
- def remove_item
- return unless Mouse.click?(:R)
- $game_actors[1].hotbar.each_with_index do |item, i|
- next unless in_area?(x_slots[i], 0, slot_width, slot_height) && item
- $network.send_change_hotbar(i, Constants::HOTBAR_NONE, 0)
- break
- end
- end
- def update_desc
- return if $dragging_window
- index = -1
- $game_actors[1].hotbar.each_with_index do |item, i|
- next unless in_area?(x_slots[i], 0, slot_width, slot_height) && item
- index = i
- break
- end
- if index >= 0 && !$cursor.object
- show_desc($game_actors[1].hotbar[index])
- else
- hide_desc
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement