mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 21:54:58 +00:00
Added parent pocket functionality to BagPocket, started implementing Bag UI redesign
This commit is contained in:
@@ -20,7 +20,9 @@ module GameData
|
|||||||
|
|
||||||
def self.all_pockets
|
def self.all_pockets
|
||||||
ret = []
|
ret = []
|
||||||
DATA.each_value { |pocket| ret.push([pocket.id, pocket.order]) }
|
DATA.each_value { |pocket| ret.push([pocket.bag_pocket]) }
|
||||||
|
ret.uniq!
|
||||||
|
ret.each { |data| data.push(self.get(data[0]).order) }
|
||||||
ret.sort_by! { |pckt| pckt[1] }
|
ret.sort_by! { |pckt| pckt[1] }
|
||||||
ret.map! { |pckt| pckt[0] }
|
ret.map! { |pckt| pckt[0] }
|
||||||
return ret
|
return ret
|
||||||
@@ -61,17 +63,27 @@ module GameData
|
|||||||
@order = hash[:order] || 999
|
@order = hash[:order] || 999
|
||||||
@max_slots = hash[:max_slots] || -1
|
@max_slots = hash[:max_slots] || -1
|
||||||
@auto_sort = hash[:auto_sort] || false
|
@auto_sort = hash[:auto_sort] || false
|
||||||
|
@parent_pocket = hash[:parent_pocket]
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [String] the translated name of this nature
|
# @return [String] the translated name of this nature
|
||||||
def name
|
def name
|
||||||
return _INTL(@real_name)
|
return _INTL(@real_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bag_pocket
|
||||||
|
return @parent_pocket || @id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
# NOTE: If :parent_pocket is defined for a BagPocket below, that parent pocket
|
||||||
|
# is assumed to be one that appears in the Bag. They don't chain.
|
||||||
|
# i.e. You can't give "MegaStones" a :parent_pocket of "HeldItems", and
|
||||||
|
# "HeldItems" a :parent_pocket of "Items" (where "Items" is the only one
|
||||||
|
# of these pockets that appears in the Bag). Both "MegaStones" and
|
||||||
|
# "HeldItems" should have a :parent_pocket of "Items".
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
GameData::BagPocket.register({
|
GameData::BagPocket.register({
|
||||||
|
|||||||
@@ -177,6 +177,10 @@ module GameData
|
|||||||
return pbGetMessageFromHash(MessageTypes::ITEM_DESCRIPTIONS, @real_description)
|
return pbGetMessageFromHash(MessageTypes::ITEM_DESCRIPTIONS, @real_description)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bag_pocket
|
||||||
|
return GameData::BagPocket.get(@pocket).bag_pocket
|
||||||
|
end
|
||||||
|
|
||||||
def has_flag?(flag)
|
def has_flag?(flag)
|
||||||
return @flags.any? { |f| f.downcase == flag.downcase }
|
return @flags.any? { |f| f.downcase == flag.downcase }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -684,7 +684,7 @@ def pbItemBall(item, quantity = 1)
|
|||||||
item = GameData::Item.get(item)
|
item = GameData::Item.get(item)
|
||||||
return false if !item || quantity < 1
|
return false if !item || quantity < 1
|
||||||
itemname = (quantity > 1) ? item.portion_name_plural : item.portion_name
|
itemname = (quantity > 1) ? item.portion_name_plural : item.portion_name
|
||||||
pocket = item.pocket
|
pocket = item.bag_pocket
|
||||||
move = item.move
|
move = item.move
|
||||||
if $bag.add(item, quantity) # If item can be picked up
|
if $bag.add(item, quantity) # If item can be picked up
|
||||||
meName = (item.is_key_item?) ? "Key item get" : "Item get"
|
meName = (item.is_key_item?) ? "Key item get" : "Item get"
|
||||||
@@ -734,7 +734,7 @@ def pbReceiveItem(item, quantity = 1)
|
|||||||
item = GameData::Item.get(item)
|
item = GameData::Item.get(item)
|
||||||
return false if !item || quantity < 1
|
return false if !item || quantity < 1
|
||||||
itemname = (quantity > 1) ? item.portion_name_plural : item.portion_name
|
itemname = (quantity > 1) ? item.portion_name_plural : item.portion_name
|
||||||
pocket = item.pocket
|
pocket = item.bag_pocket
|
||||||
move = item.move
|
move = item.move
|
||||||
meName = (item.is_key_item?) ? "Key item get" : "Item get"
|
meName = (item.is_key_item?) ? "Key item get" : "Item get"
|
||||||
if item == :DNASPLICERS
|
if item == :DNASPLICERS
|
||||||
@@ -769,7 +769,7 @@ def pbBuyPrize(item, quantity = 1)
|
|||||||
item = GameData::Item.get(item)
|
item = GameData::Item.get(item)
|
||||||
return false if !item || quantity < 1
|
return false if !item || quantity < 1
|
||||||
item_name = (quantity > 1) ? item.portion_name_plural : item.portion_name
|
item_name = (quantity > 1) ? item.portion_name_plural : item.portion_name
|
||||||
pocket = item.pocket
|
pocket = item.bag_pocket
|
||||||
return false if !$bag.add(item, quantity)
|
return false if !$bag.add(item, quantity)
|
||||||
pbMessage("\\CN" + _INTL("You put the {1} in\nyour Bag's <icon=bagPocket{2}>\\c[1]{3}\\c[0] pocket.",
|
pbMessage("\\CN" + _INTL("You put the {1} in\nyour Bag's <icon=bagPocket{2}>\\c[1]{3}\\c[0] pocket.",
|
||||||
item_name, pocket, GameData::BagPocket.get(pocket).name))
|
item_name, pocket, GameData::BagPocket.get(pocket).name))
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ def pbPickBerry(berry, qty = 1)
|
|||||||
else
|
else
|
||||||
pbMessage("\\me[Berry get]" + _INTL("You picked the \\c[1]{1}\\c[0].", berry_name) + "\\wtnp[30]")
|
pbMessage("\\me[Berry get]" + _INTL("You picked the \\c[1]{1}\\c[0].", berry_name) + "\\wtnp[30]")
|
||||||
end
|
end
|
||||||
pocket = berry.pocket
|
pocket = berry.bag_pocket
|
||||||
pbMessage(_INTL("You put the {1} in\nyour Bag's <icon=bagPocket{2}>\\c[1]{3}\\c[0] pocket.",
|
pbMessage(_INTL("You put the {1} in\nyour Bag's <icon=bagPocket{2}>\\c[1]{3}\\c[0] pocket.",
|
||||||
berry_name, pocket, GameData::BagPocket.get(pocket).name) + "\1")
|
berry_name, pocket, GameData::BagPocket.get(pocket).name) + "\1")
|
||||||
if Settings::NEW_BERRY_PLANTS
|
if Settings::NEW_BERRY_PLANTS
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ module ItemHandlers
|
|||||||
UseFromBag = ItemHandlerHash.new
|
UseFromBag = ItemHandlerHash.new
|
||||||
ConfirmUseInField = ItemHandlerHash.new
|
ConfirmUseInField = ItemHandlerHash.new
|
||||||
UseInField = ItemHandlerHash.new
|
UseInField = ItemHandlerHash.new
|
||||||
|
UsableOnPokemon = ItemHandlerHash.new
|
||||||
UseOnPokemon = ItemHandlerHash.new
|
UseOnPokemon = ItemHandlerHash.new
|
||||||
UseOnPokemonMaximum = ItemHandlerHash.new
|
UseOnPokemonMaximum = ItemHandlerHash.new
|
||||||
CanUseInBattle = ItemHandlerHash.new
|
CanUseInBattle = ItemHandlerHash.new
|
||||||
@@ -29,6 +30,10 @@ module ItemHandlers
|
|||||||
return !UseInField[item].nil?
|
return !UseInField[item].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hasUsableOnPokemon(item)
|
||||||
|
return !UsableOnPokemon[item].nil?
|
||||||
|
end
|
||||||
|
|
||||||
def hasUseOnPokemon(item)
|
def hasUseOnPokemon(item)
|
||||||
return !UseOnPokemon[item].nil?
|
return !UseOnPokemon[item].nil?
|
||||||
end
|
end
|
||||||
@@ -82,6 +87,12 @@ module ItemHandlers
|
|||||||
return (UseInField.trigger(item)) ? 1 : 0
|
return (UseInField.trigger(item)) ? 1 : 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns whether item will have an effect if used on pkmn.
|
||||||
|
def triggerUsableOnPokemon(item, pkmn)
|
||||||
|
return false if !UsableOnPokemon[item]
|
||||||
|
return UsableOnPokemon.trigger(item, pkmn)
|
||||||
|
end
|
||||||
|
|
||||||
# Returns whether item was used.
|
# Returns whether item was used.
|
||||||
def triggerUseOnPokemon(item, qty, pkmn, scene)
|
def triggerUseOnPokemon(item, qty, pkmn, scene)
|
||||||
return false if !UseOnPokemon[item]
|
return false if !UseOnPokemon[item]
|
||||||
@@ -125,7 +136,9 @@ def pbCanRegisterItem?(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbCanUseOnPokemon?(item)
|
def pbCanUseOnPokemon?(item)
|
||||||
return ItemHandlers.hasUseOnPokemon(item) || GameData::Item.get(item).is_machine?
|
return ItemHandlers.hasUseOnPokemon(item) ||
|
||||||
|
ItemHandlers.hasUsableOnPokemon(item) ||
|
||||||
|
GameData::Item.get(item).is_machine?
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@@ -676,7 +689,7 @@ def pbUseItem(bag, item, bag_scene = nil)
|
|||||||
end
|
end
|
||||||
screen.choose_pokemon do |pkmn, party_index|
|
screen.choose_pokemon do |pkmn, party_index|
|
||||||
next true if party_index < 0
|
next true if party_index < 0
|
||||||
next false if !pbCheckUseOnPokemon(item, pkmn, screen)
|
next false if !pbCheckUseOnPokemon(item, pkmn)
|
||||||
qty = 1
|
qty = 1
|
||||||
max_at_once = ItemHandlers.triggerUseOnPokemonMaximum(item, pkmn)
|
max_at_once = ItemHandlers.triggerUseOnPokemonMaximum(item, pkmn)
|
||||||
max_at_once = [max_at_once, bag.quantity(item)].min
|
max_at_once = [max_at_once, bag.quantity(item)].min
|
||||||
@@ -781,10 +794,19 @@ def pbUseItemMessage(item)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbCheckUseOnPokemon(item, pkmn, _screen)
|
# Returns whether pkmn is able to have an item used on it.
|
||||||
|
def pbCheckUseOnPokemon(item, pkmn)
|
||||||
return pkmn && !pkmn.egg? && (!pkmn.hyper_mode || GameData::Item.get(item)&.is_scent?)
|
return pkmn && !pkmn.egg? && (!pkmn.hyper_mode || GameData::Item.get(item)&.is_scent?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This method assumes the item is usable on a Pokémon. It returns whether the
|
||||||
|
# item will have an effect when used on pkmn.
|
||||||
|
def pbItemHasEffectOnPokemon?(item, pkmn)
|
||||||
|
return false if !pbCheckUseOnPokemon(item, pkmn)
|
||||||
|
ret = ItemHandlers.triggerUsableOnPokemon(item, pkmn)
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Give an item to a Pokémon to hold, and take a held item from a Pokémon.
|
# Give an item to a Pokémon to hold, and take a held item from a Pokémon.
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -56,7 +56,7 @@ class PokemonBag
|
|||||||
def quantity(item)
|
def quantity(item)
|
||||||
item_data = GameData::Item.try_get(item)
|
item_data = GameData::Item.try_get(item)
|
||||||
return 0 if !item_data
|
return 0 if !item_data
|
||||||
pocket = item_data.pocket
|
pocket = item_data.bag_pocket
|
||||||
return ItemStorageHelper.quantity(@pockets[pocket], item_data.id)
|
return ItemStorageHelper.quantity(@pockets[pocket], item_data.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class PokemonBag
|
|||||||
def can_add?(item, qty = 1)
|
def can_add?(item, qty = 1)
|
||||||
item_data = GameData::Item.try_get(item)
|
item_data = GameData::Item.try_get(item)
|
||||||
return false if !item_data
|
return false if !item_data
|
||||||
pocket = item_data.pocket
|
pocket = item_data.bag_pocket
|
||||||
max_size = max_pocket_size(pocket)
|
max_size = max_pocket_size(pocket)
|
||||||
max_size = @pockets[pocket].length + 1 if max_size < 0 # Infinite size
|
max_size = @pockets[pocket].length + 1 if max_size < 0 # Infinite size
|
||||||
return ItemStorageHelper.can_add?(
|
return ItemStorageHelper.can_add?(
|
||||||
@@ -79,7 +79,7 @@ class PokemonBag
|
|||||||
def add(item, qty = 1)
|
def add(item, qty = 1)
|
||||||
item_data = GameData::Item.try_get(item)
|
item_data = GameData::Item.try_get(item)
|
||||||
return false if !item_data
|
return false if !item_data
|
||||||
pocket = item_data.pocket
|
pocket = item_data.bag_pocket
|
||||||
max_size = max_pocket_size(pocket)
|
max_size = max_pocket_size(pocket)
|
||||||
max_size = @pockets[pocket].length + 1 if max_size < 0 # Infinite size
|
max_size = @pockets[pocket].length + 1 if max_size < 0 # Infinite size
|
||||||
ret = ItemStorageHelper.add(@pockets[pocket],
|
ret = ItemStorageHelper.add(@pockets[pocket],
|
||||||
@@ -101,7 +101,7 @@ class PokemonBag
|
|||||||
def remove(item, qty = 1)
|
def remove(item, qty = 1)
|
||||||
item_data = GameData::Item.try_get(item)
|
item_data = GameData::Item.try_get(item)
|
||||||
return false if !item_data
|
return false if !item_data
|
||||||
pocket = item_data.pocket
|
pocket = item_data.bag_pocket
|
||||||
return ItemStorageHelper.remove(@pockets[pocket], item_data.id, qty)
|
return ItemStorageHelper.remove(@pockets[pocket], item_data.id, qty)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ class PokemonBag
|
|||||||
old_item_data = GameData::Item.try_get(old_item)
|
old_item_data = GameData::Item.try_get(old_item)
|
||||||
new_item_data = GameData::Item.try_get(new_item)
|
new_item_data = GameData::Item.try_get(new_item)
|
||||||
return false if !old_item_data || !new_item_data
|
return false if !old_item_data || !new_item_data
|
||||||
pocket = old_item_data.pocket
|
pocket = old_item_data.bag_pocket
|
||||||
old_id = old_item_data.id
|
old_id = old_item_data.id
|
||||||
new_id = new_item_data.id
|
new_id = new_item_data.id
|
||||||
ret = false
|
ret = false
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class UI::BagVisualsList < Window_DrawableCommand
|
|||||||
# Draw quantity
|
# Draw quantity
|
||||||
if item_data.show_quantity? && !showing_register_icon
|
if item_data.show_quantity? && !showing_register_icon
|
||||||
qty = @items[index][1]
|
qty = @items[index][1]
|
||||||
qtytext = _ISPRINTF("×{1: 3d}", qty)
|
qtytext = _ISPRINTF("× {1:d}", qty)
|
||||||
xQty = rect.x + rect.width - self.contents.text_size(qtytext).width - 16
|
xQty = rect.x + rect.width - self.contents.text_size(qtytext).width - 16
|
||||||
textpos.push([qtytext, xQty, rect.y + 2, :left, baseColor, shadowColor])
|
textpos.push([qtytext, xQty, rect.y + 2, :left, baseColor, shadowColor])
|
||||||
end
|
end
|
||||||
@@ -154,11 +154,11 @@ class UI::BagVisuals < UI::BaseVisuals
|
|||||||
:default => [Color.new(248, 248, 248), Color.new(104, 104, 104)], # Base and shadow colour
|
:default => [Color.new(248, 248, 248), Color.new(104, 104, 104)], # Base and shadow colour
|
||||||
# :white => [Color.new(248, 248, 248), Color.new(104, 104, 104)], # Summary screen's white
|
# :white => [Color.new(248, 248, 248), Color.new(104, 104, 104)], # Summary screen's white
|
||||||
# :black => [Color.new(64, 64, 64), Color.new(176, 176, 176)] # Summary screen's black
|
# :black => [Color.new(64, 64, 64), Color.new(176, 176, 176)] # Summary screen's black
|
||||||
:white => [Color.new(248, 248, 248), Color.new(0, 0, 0)],
|
:white => [Color.new(248, 248, 248), Color.new(56, 56, 56)],
|
||||||
:black => [Color.new(88, 88, 80), Color.new(168, 184, 184)],
|
:black => [Color.new(88, 88, 80), Color.new(168, 184, 184)],
|
||||||
:switching => [Color.new(224, 0, 0), Color.new(248, 144, 144)]
|
:switching => [Color.new(224, 0, 0), Color.new(248, 144, 144)]
|
||||||
}
|
}
|
||||||
ITEMS_VISIBLE = 7
|
ITEMS_VISIBLE = 6
|
||||||
|
|
||||||
def initialize(bag, mode = :normal)
|
def initialize(bag, mode = :normal)
|
||||||
@bag = bag
|
@bag = bag
|
||||||
@@ -168,44 +168,40 @@ class UI::BagVisuals < UI::BaseVisuals
|
|||||||
end
|
end
|
||||||
|
|
||||||
def initialize_bitmaps
|
def initialize_bitmaps
|
||||||
@bitmaps[:slider] = AnimatedBitmap.new(graphics_folder + "icon_slider")
|
@bitmaps[:slider] = AnimatedBitmap.new(graphics_folder + "icon_slider")
|
||||||
@bitmaps[:pocket_icons] = AnimatedBitmap.new(graphics_folder + "icon_pocket")
|
@bitmaps[:pocket_icons] = AnimatedBitmap.new(graphics_folder + "icon_pocket")
|
||||||
|
@bitmaps[:party_icons] = AnimatedBitmap.new(graphics_folder + "icon_party")
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_overlay
|
def initialize_overlay
|
||||||
super
|
super
|
||||||
add_overlay(:slider_overlay, 36, 470 + 38 + 38)
|
add_overlay(:slider_overlay, 24, 224)
|
||||||
@sprites[:slider_overlay].x = 470
|
@sprites[:slider_overlay].x = 484
|
||||||
@sprites[:slider_overlay].y = 54 - 38
|
@sprites[:slider_overlay].y = 46
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_sprites
|
def initialize_sprites
|
||||||
initialize_pocket_sprites
|
initialize_pocket_sprites
|
||||||
|
initialize_party_sprites
|
||||||
initialize_item_list
|
initialize_item_list
|
||||||
initialize_item_sprites
|
initialize_item_sprites
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_pocket_sprites
|
def initialize_pocket_sprites
|
||||||
@sprites[:bag] = IconSprite.new(30, 20, @viewport)
|
@sprites[:bag] = IconSprite.new(28, 90, @viewport)
|
||||||
@sprites[:pocket_icons] = BitmapSprite.new(186, 32, @viewport)
|
@sprites[:pocket_icons] = BitmapSprite.new(344, 28, @viewport)
|
||||||
@sprites[:pocket_icons].x = 0
|
@sprites[:pocket_icons].x = 160
|
||||||
@sprites[:pocket_icons].y = 224
|
@sprites[:pocket_icons].y = 2
|
||||||
# TODO: I won't need these two animated arrows once new ones are put next to
|
end
|
||||||
# the pocket icons.
|
|
||||||
# Arrow to indicate more ribbons are above the ones visible when navigating ribbons
|
def initialize_party_sprites
|
||||||
add_animated_arrow(:left_arrow, -4, 76, :left)
|
@sprites[:party_icons] = BitmapSprite.new(32 * Settings::MAX_PARTY_SIZE, 32, @viewport)
|
||||||
@sprites[:left_arrow].z = 1700
|
@sprites[:party_icons].x = 6
|
||||||
# TODO: Set visibility.
|
@sprites[:party_icons].y = 42
|
||||||
# @sprites[:left_arrow].visible = (!@choosing || numfilledpockets > 1)
|
|
||||||
# Arrow to indicate more ribbons are below the ones visible when navigating ribbons
|
|
||||||
add_animated_arrow(:right_arrow, 150, 76, :right)
|
|
||||||
@sprites[:right_arrow].z = 1700
|
|
||||||
# TODO: Set visibility.
|
|
||||||
# @sprites[:right_arrow].visible = (!@choosing || numfilledpockets > 1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_item_list
|
def initialize_item_list
|
||||||
@sprites[:item_list] = UI::BagVisualsList.new(@bag, 168, -8, 314, 40 + 32 + (ITEMS_VISIBLE * 32), @viewport)
|
@sprites[:item_list] = UI::BagVisualsList.new(@bag, 166, 28, 332, 40 + 28 + (ITEMS_VISIBLE * 32), @viewport)
|
||||||
@sprites[:item_list].baseColor = TEXT_COLOR_THEMES[:black][0]
|
@sprites[:item_list].baseColor = TEXT_COLOR_THEMES[:black][0]
|
||||||
@sprites[:item_list].shadowColor = TEXT_COLOR_THEMES[:black][1]
|
@sprites[:item_list].shadowColor = TEXT_COLOR_THEMES[:black][1]
|
||||||
@sprites[:item_list].switching_base_color = TEXT_COLOR_THEMES[:switching][0]
|
@sprites[:item_list].switching_base_color = TEXT_COLOR_THEMES[:switching][0]
|
||||||
@@ -220,7 +216,7 @@ class UI::BagVisuals < UI::BaseVisuals
|
|||||||
@sprites[:item_icon] = ItemIconSprite.new(48, Graphics.height - 48, nil, @viewport)
|
@sprites[:item_icon] = ItemIconSprite.new(48, Graphics.height - 48, nil, @viewport)
|
||||||
# Selected item's description text box
|
# Selected item's description text box
|
||||||
@sprites[:item_description] = Window_UnformattedTextPokemon.newWithSize(
|
@sprites[:item_description] = Window_UnformattedTextPokemon.newWithSize(
|
||||||
"", 72, 272, Graphics.width - 96, 128, @viewport
|
"", 76, 272, Graphics.width - 100, 128, @viewport
|
||||||
)
|
)
|
||||||
@sprites[:item_description].baseColor = TEXT_COLOR_THEMES[:white][0]
|
@sprites[:item_description].baseColor = TEXT_COLOR_THEMES[:white][0]
|
||||||
@sprites[:item_description].shadowColor = TEXT_COLOR_THEMES[:white][1]
|
@sprites[:item_description].shadowColor = TEXT_COLOR_THEMES[:white][1]
|
||||||
@@ -381,12 +377,12 @@ class UI::BagVisuals < UI::BaseVisuals
|
|||||||
end
|
end
|
||||||
|
|
||||||
def refresh_pocket_icons
|
def refresh_pocket_icons
|
||||||
icon_size = [28, 28]
|
|
||||||
icon_overlap = 6
|
|
||||||
icon_x = 2
|
|
||||||
icon_y = 2
|
|
||||||
@sprites[:pocket_icons].bitmap.clear
|
|
||||||
all_pockets = GameData::BagPocket.all_pockets
|
all_pockets = GameData::BagPocket.all_pockets
|
||||||
|
icon_size = [28, 28]
|
||||||
|
icon_overlap = 0
|
||||||
|
icon_x = 172 - ((icon_size[0] - icon_overlap) * all_pockets.length / 2)
|
||||||
|
icon_y = 0
|
||||||
|
@sprites[:pocket_icons].bitmap.clear
|
||||||
# Draw regular pocket icons
|
# Draw regular pocket icons
|
||||||
all_pockets.each_with_index do |pckt, i|
|
all_pockets.each_with_index do |pckt, i|
|
||||||
icon_pos = GameData::BagPocket.get(pckt).icon_position
|
icon_pos = GameData::BagPocket.get(pckt).icon_position
|
||||||
@@ -407,13 +403,18 @@ class UI::BagVisuals < UI::BaseVisuals
|
|||||||
icon_pos = GameData::BagPocket.get(@pocket).icon_position
|
icon_pos = GameData::BagPocket.get(@pocket).icon_position
|
||||||
draw_image(@bitmaps[:pocket_icons], icon_x + (pocket_number * (icon_size[0] - icon_overlap)), icon_y,
|
draw_image(@bitmaps[:pocket_icons], icon_x + (pocket_number * (icon_size[0] - icon_overlap)), icon_y,
|
||||||
icon_pos * icon_size[0], 0, *icon_size, overlay: :pocket_icons)
|
icon_pos * icon_size[0], 0, *icon_size, overlay: :pocket_icons)
|
||||||
# TODO: Draw the left and right arrows, if @mode != :choose_item ||
|
# Draw left/right arrows if there are multiple pockets that can be looked at
|
||||||
# @filtered_list has 2+ non-empty pockets.
|
if @mode != :choose_item || !@filtered_list || @filtered_list.count { |pckt, contents| !contents.empty? } > 1
|
||||||
|
draw_image(@bitmaps[:pocket_icons], icon_x - (icon_size[0] - icon_overlap), icon_y,
|
||||||
|
0, icon_size[1] * 3, *icon_size, overlay: :pocket_icons)
|
||||||
|
draw_image(@bitmaps[:pocket_icons], icon_x + (all_pockets.length * (icon_size[0] - icon_overlap)), icon_y,
|
||||||
|
icon_size[0], icon_size[1] * 3, *icon_size, overlay: :pocket_icons)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_pocket
|
def refresh_pocket
|
||||||
# Draw pocket's name
|
# Draw pocket's name
|
||||||
draw_text(GameData::BagPocket.get(@pocket).name, 94, 186, align: :center, theme: :black)
|
draw_text(GameData::BagPocket.get(@pocket).name, 16, 6, theme: :black)
|
||||||
# Set the bag sprite
|
# Set the bag sprite
|
||||||
bag_sprite_filename = graphics_folder + gendered_filename(sprintf("bag_%s", @pocket.to_s))
|
bag_sprite_filename = graphics_folder + gendered_filename(sprintf("bag_%s", @pocket.to_s))
|
||||||
@sprites[:bag].setBitmap(bag_sprite_filename)
|
@sprites[:bag].setBitmap(bag_sprite_filename)
|
||||||
@@ -430,15 +431,15 @@ class UI::BagVisuals < UI::BaseVisuals
|
|||||||
@sprites[:slider_overlay].bitmap.clear
|
@sprites[:slider_overlay].bitmap.clear
|
||||||
# Define useful values
|
# Define useful values
|
||||||
slider_rects = {
|
slider_rects = {
|
||||||
:up_arrow => [0, 0, 36, 38],
|
:up_arrow => [0, 0, 24, 28],
|
||||||
:down_arrow => [0, 38, 36, 38],
|
:down_arrow => [0, 28, 24, 28],
|
||||||
:box_top => [36, 0, 36, 4],
|
:box_top => [24, 0, 24, 4],
|
||||||
:box_middle => [36, 4, 36, 16],
|
:box_middle => [24, 4, 24, 8],
|
||||||
:box_bottom => [36, 20, 36, 18]
|
:box_bottom => [24, 12, 24, 18]
|
||||||
}
|
}
|
||||||
slider_x = 0
|
slider_x = 0
|
||||||
slider_y = slider_rects[:up_arrow][3]
|
slider_y = slider_rects[:up_arrow][3]
|
||||||
slider_height = 174
|
slider_height = 168
|
||||||
min_box_height = slider_rects[:box_top][3] + slider_rects[:box_middle][3] + slider_rects[:box_bottom][3]
|
min_box_height = slider_rects[:box_top][3] + slider_rects[:box_middle][3] + slider_rects[:box_bottom][3]
|
||||||
# Draw things
|
# Draw things
|
||||||
show_slider = false
|
show_slider = false
|
||||||
@@ -492,6 +493,34 @@ class UI::BagVisuals < UI::BaseVisuals
|
|||||||
else
|
else
|
||||||
@sprites[:item_description].text = _INTL("Close bag.")
|
@sprites[:item_description].text = _INTL("Close bag.")
|
||||||
end
|
end
|
||||||
|
refresh_party_display
|
||||||
|
end
|
||||||
|
|
||||||
|
def refresh_party_display
|
||||||
|
@sprites[:party_icons].bitmap.clear
|
||||||
|
return if item.nil? || @mode == :choose_item
|
||||||
|
item_data = GameData::Item.get(item)
|
||||||
|
use_type = item_data.field_use
|
||||||
|
# TODO: If @mode == :choose_item_in_battle, also check for item usage on a
|
||||||
|
# battler.
|
||||||
|
return if !pbCanUseOnPokemon?(item)
|
||||||
|
icon_x = 0
|
||||||
|
icon_y = 0
|
||||||
|
icon_size = [@bitmaps[:party_icons].height, @bitmaps[:party_icons].height]
|
||||||
|
icon_overlap = 4
|
||||||
|
Settings::MAX_PARTY_SIZE.times do |i|
|
||||||
|
pkmn = $player.party[i]
|
||||||
|
this_icon_x = (icon_size[0] - icon_overlap) * i
|
||||||
|
# TODO: If @mode == :choose_item_in_battle, also check for item usage on a
|
||||||
|
# battler.
|
||||||
|
usable = pbItemHasEffectOnPokemon?(item, pkmn)
|
||||||
|
icon_offset = 2
|
||||||
|
if pkmn
|
||||||
|
icon_offset = (usable) ? 0 : 1
|
||||||
|
end
|
||||||
|
draw_image(@bitmaps[:party_icons], this_icon_x, icon_y,
|
||||||
|
icon_offset * icon_size[0], 0, *icon_size, overlay: :party_icons)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_on_index_changed(old_index)
|
def refresh_on_index_changed(old_index)
|
||||||
|
|||||||
@@ -820,11 +820,12 @@ MenuHandlers.add(:debug_menu, :fill_bag, {
|
|||||||
GameData::BagPocket.each { |pckt| pocket_sizes[pckt.id] = pckt.max_slots }
|
GameData::BagPocket.each { |pckt| pocket_sizes[pckt.id] = pckt.max_slots }
|
||||||
bag = $bag.pockets # Called here so that it only rearranges itself once
|
bag = $bag.pockets # Called here so that it only rearranges itself once
|
||||||
GameData::Item.each do |i|
|
GameData::Item.each do |i|
|
||||||
next if GameData::BagPocket.get(i.pocket).max_slots
|
bag_pocket = i.bag_pocket
|
||||||
next if !pocket_sizes[i.pocket] || pocket_sizes[i.pocket] == 0
|
next if GameData::BagPocket.get(bag_pocket).max_slots
|
||||||
next if pocket_sizes[i.pocket] > 0 && bag[i.pocket].length >= pocket_sizes[i.pocket]
|
next if !pocket_sizes[bag_pocket] || pocket_sizes[bag_pocket] == 0
|
||||||
|
next if pocket_sizes[bag_pocket] > 0 && bag[bag_pocket].length >= pocket_sizes[bag_pocket]
|
||||||
item_qty = (i.is_important?) ? 1 : qty
|
item_qty = (i.is_important?) ? 1 : qty
|
||||||
bag[i.pocket].push([i.id, item_qty])
|
bag[bag_pocket].push([i.id, item_qty])
|
||||||
end
|
end
|
||||||
# NOTE: Auto-sorting pockets don't need to be sorted afterwards, because
|
# NOTE: Auto-sorting pockets don't need to be sorted afterwards, because
|
||||||
# items are added in the same order they would be sorted into.
|
# items are added in the same order they would be sorted into.
|
||||||
|
|||||||
Reference in New Issue
Block a user