Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Window_Item
- #------------------------------------------------------------------------------
- # By Marlos Gama
- #==============================================================================
- class Window_Item2 < Window_IconSelectable
- def initialize
- super(100, 85, 192, 192)#(100, 85, 180, 196)
- self.windowskin = RPG::Cache.windowskin("windteste2")
- self.back_opacity = 220
- @column_max = 5
- refresh
- #@dragable = true
- #@scalable = false
- #@clickable = true
- #@closable = true
- self.index = 0
- self.z = 99998
- #-----
- @scrollbar = Scroll_Bar33.new(self)
- end
- def item
- return @data[self.index]
- end
- def refresh
- # Mostra a imagem de fundo
- #fundo3 = RPG::Cache.picture("inv1")
- #fundo1 = fundo3.width
- #fundo2 = fundo3.height
- #fundo4 = Rect.new(0,0,fundo1,fundo2)
- #self.contents.blt(0,0,fundo3,fundo4)
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0
- @data.push($data_items[i])
- end
- end
- unless $game_temp.in_battle
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0
- @data.push($data_weapons[i])
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0
- @data.push($data_armors[i])
- end
- end
- end
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- #return if i > 20
- draw_item(i)
- end
- end
- end
- def selecao
- #-----
- return if $pegando_item_trade == true
- return if $pegando_item == true
- return if $pegando_item_loja == true
- return if $desequipar_arma == true
- return if $desequipar_armadura == true
- return if $desequipar_escudo == true
- return if $desequipar_helmet == true
- return if $desequipar_acessorio == true
- return if $desequipar_capa == true
- return if $desequipar_bota == true
- return if $desequipar_amuleto == true
- return if $desequipar_luva == true
- #-----
- if not $pegando_item and $Mouse.x > self.x + 16 and $Mouse.x < (self.x + self.width) - 16 and
- $Mouse.y > self.y + 16 and $Mouse.y < (self.y + self.height) - 16
- #-----
- mx = (($Mouse.x + self.ox) - (self.x + 16)) / 32
- my = (($Mouse.y + self.oy) - (self.y + 16)) / 32
- #-----
- self.index = mx + (my * @column_max)
- self.index = -1 if self.index > @data.size
- else
- self.index = -1
- end
- #-----
- end
- def click
- if Input.pressed?(Input::Mouse_Left) and in_area?
- return if $pegando_item_trade == true
- return if $pegando_item_loja == true
- return if $mouse_active == true
- return if $desequipar_arma == true
- return if $desequipar_armadura== true
- return if $desequipar_escudo == true
- return if $desequipar_helmet== true
- return if $desequipar_acessorio == true
- return if $desequipar_capa == true
- return if $desequipar_bota == true
- return if $desequipar_amuleto == true
- return if $desequipar_luva == true
- #-----
- if not $pegando_item and $Mouse.x > self.x + 16 and $Mouse.x < (self.x + self.width) - 16 and
- $Mouse.y > self.y + 16 and $Mouse.y < (self.y + self.height) - 16
- #-----
- mx = (($Mouse.x + self.ox) - (self.x + 16)) / 32
- my = (($Mouse.y + self.oy) - (self.y + 16)) / 32
- #-----
- self.index = mx + (my * @column_max)
- self.index = -1 if self.index > @data.size
- else
- self.index = -1
- end
- return if self.index == -1
- #-----
- $pegando_item = true
- item = @data[index]
- return if item == nil
- $mouse_iconfor = item.icon_name
- $game_temp.atualizar_mouse = true
- end
- if Input.pressed?(Input::Mouse_Right)
- if in_area?
- return if $mouse_active == true
- $mouse_active = true
- item = @data[index]
- if item.is_a?(RPG::Item)
- if $game_party.item_can_use?(item.id)
- target = $game_party.actors[0]
- used = target.item_effect(item)
- $game_system.se_play(item.menu_se)
- $game_player.animation_id = item.animation1_id
- if item.consumable
- $game_party.lose_item(item.id, 1)
- if item.common_event_id > 0
- $game_temp.common_event_id = item.common_event_id
- end
- refresh
- end
- end
- end
- else
- $help_w.visible = false
- $help_w.active = false
- end
- end
- end
- def use_item_1(item_carregado)
- item = item_carregado#$data_items[1]
- if item.is_a?(RPG::Item)
- if $game_party.item_can_use?(item.id)
- target = $game_party.actors[0]
- used = target.item_effect(item)
- $game_system.se_play(item.menu_se)
- $game_player.animation_id = item.animation1_id
- if item.consumable
- $game_party.lose_item(item.id, 1)
- refresh
- end
- end
- end
- end
- def use_item_2(item_carregado2)
- item = item_carregado2#$data_items[1]
- if item.is_a?(RPG::Item)
- if $game_party.item_can_use?(item.id)
- target = $game_party.actors[0]
- used = target.item_effect(item)
- $game_system.se_play(item.menu_se)
- $game_player.animation_id = item.animation1_id
- if item.consumable
- $game_party.lose_item(item.id, 1)
- refresh
- end
- end
- end
- end
- def use_item_3(item_carregado3)
- item = item_carregado3#$data_items[1]
- if item.is_a?(RPG::Item)
- if $game_party.item_can_use?(item.id)
- target = $game_party.actors[0]
- used = target.item_effect(item)
- $game_system.se_play(item.menu_se)
- $game_player.animation_id = item.animation1_id
- if item.consumable
- $game_party.lose_item(item.id, 1)
- refresh
- end
- end
- end
- end
- def use_item_4(item_carregado4)
- item = item_carregado4#$data_items[1]
- if item.is_a?(RPG::Item)
- if $game_party.item_can_use?(item.id)
- target = $game_party.actors[0]
- used = target.item_effect(item)
- $game_system.se_play(item.menu_se)
- $game_player.animation_id = item.animation1_id
- if item.consumable
- $game_party.lose_item(item.id, 1)
- refresh
- end
- end
- end
- end
- def comprar_loja
- if $loja == true
- if $pegando_item == true
- if !Input.pressed?(Input::Mouse_Left) and $loja_w.in_area?
- $mouse_iconfor = "arrow"
- $game_temp.atualizar_mouse = true
- @item = $item_w.item
- if @item.is_a?(RPG::Item)
- return if @item.id == Item_Ouro::Item_Id.to_i
- end
- if @item == nil
- return
- end
- case @item
- when RPG::Item
- @number = $game_party.item_number(@item.id)
- when RPG::Weapon
- @number = $game_party.weapon_number(@item.id)
- when RPG::Armor
- @number = $game_party.armor_number(@item.id)
- end
- return if @number < $amount
- $game_party.gain_item(Item_Ouro::Item_Id.to_i,$amount * (@item.price/2))
- $game_party.lose_item(Item_Ouro::Item_Id.to_i,$amount * @item.price/2)
- $game_party.gain_gold($amount * (@item.price / 2))
- #$game_system.se_play($data_system.shop_se)
- case @item
- when RPG::Item
- $game_party.lose_item(@item.id, $amount)
- when RPG::Weapon
- $game_party.lose_weapon(@item.id, $amount)
- when RPG::Armor
- $game_party.lose_armor(@item.id, $amount)
- end
- $item_w.refresh
- $loja_w.refresh
- $janela_gold_w.refresh
- $item_w.active = false
- $pegando_item = false
- end
- end
- end
- end
- def voltar_mouse
- if !Input.pressed?(Input::Mouse_Left)
- $mouse_iconfor = "arrow"
- $game_temp.atualizar_mouse = true
- $pegando_item = false
- $pegando_item_loja = false
- $pegando_item_trade = false
- $desequipar_arma = false
- $desequipar_armadura = false
- $desequipar_escudo = false
- $desequipar_helmet = false
- $desequipar_acessorio = false
- $desequipar_capa = false
- $desequipar_bota = false
- $desequipar_amuleto = false
- $desequipar_luva = false
- end
- end
- def draw_item(index)
- item = @data[index]
- #return if index > 19
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- #-----
- x = index % @column_max * (width/@column_max - 6)
- y = index / @column_max * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- if item.is_a?(RPG::Item)
- if item.id != Item_Ouro::Item_Id.to_i
- opacity = 255
- self.contents.font.color = normal_color
- else
- opacity = 128
- self.contents.font.color = Color.new(128,128,128)
- end
- else
- opacity = 255
- self.contents.font.color = normal_color
- end
- #opacity = self.contents.font.color == normal_color ? 255 : 128#255
- self.contents.blt(x, y + 2, bitmap, Rect.new(0, 0, 24, 24), opacity)
- if item.id == 33
- if number < 1000
- self.contents.draw_text(x - 6, y + 9, 34, 32, number.to_s, 2)
- elsif number > 10000
- self.contents.draw_text(x - 7, y + 9, 34, 32, number.to_s, 2)
- elsif number == 10000
- self.contents.draw_text(x - 7, y + 9, 34, 32, number.to_s, 2)
- elsif number > 100000
- self.contents.draw_text(x + 2, y + 9, 32, 32, number.to_s, 2)
- elsif number == 100000
- self.contents.draw_text(x + 2, y + 9, 32, 32, number.to_s, 2)
- else
- self.contents.draw_text(x - 4, y + 9, 34, 32, number.to_s, 2)
- end
- else
- self.contents.draw_text(x + 2, y + 9, 24, 32, number.to_s, 2)
- end
- end
- def visible=(v)
- super(v) rescue nil
- self.update
- end
- def x=(v)
- super(v)
- @scrollbar.update if @scrollbar
- end
- def y=(v)
- super(v)
- @scrollbar.update if @scrollbar
- end
- def update
- super
- if not $pegando_item and $Mouse.x > self.x + 16 and $Mouse.x < (self.x + self.width) - 16 and
- $Mouse.y > self.y + 16 and $Mouse.y < (self.y + self.height) - 16
- #-----
- mx = (($Mouse.x + self.ox) - (self.x + 16)) / 32
- my = (($Mouse.y + self.oy) - (self.y + 16)) / 32
- #-----
- self.index = mx + (my * @column_max)
- self.index = -1 if self.index > @data.size
- else
- self.index = -1
- end
- end
- end
Add Comment
Please, Sign In to add comment