Removed all uses of ID numbers for GameDatas BodyColor, BodyShape and Target, removed support for trainer type graphics using ID numbers in their names

This commit is contained in:
Maruno17
2021-06-17 22:45:16 +01:00
parent eaa915878a
commit 6e188666a4
8 changed files with 83 additions and 118 deletions

View File

@@ -1,26 +1,25 @@
# NOTE: The id_number is only used to determine the order that body shapes are # NOTE: The order these shapes are registered are the order they are listed in
# listed in the Pokédex search screen. Number 0 (:None) is ignored; they # the Pokédex search screen.
# start with shape 1.
# "Graphics/Pictures/Pokedex/icon_shapes.png" contains icons for these # "Graphics/Pictures/Pokedex/icon_shapes.png" contains icons for these
# shapes. # shapes.
module GameData module GameData
class BodyShape class BodyShape
attr_reader :id attr_reader :id
attr_reader :id_number
attr_reader :real_name attr_reader :real_name
attr_reader :icon_position # Where this shape's icon is within icon_shapes.png
DATA = {} DATA = {}
extend ClassMethods extend ClassMethodsSymbols
include InstanceMethods include InstanceMethods
def self.load; end def self.load; end
def self.save; end def self.save; end
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@id_number = hash[:id_number] || -1 @real_name = hash[:name] || "Unnamed"
@real_name = hash[:name] || "Unnamed" @icon_position = hash[:icon_position] || -1 # -1 means "no icon"
end end
# @return [String] the translated name of this body shape # @return [String] the translated name of this body shape
@@ -33,85 +32,85 @@ end
#=============================================================================== #===============================================================================
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :Head, :id => :Head,
:id_number => 1, :name => _INTL("Head"),
:name => _INTL("Head") :icon_position => 0
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :Serpentine, :id => :Serpentine,
:id_number => 2, :name => _INTL("Serpentine"),
:name => _INTL("Serpentine") :icon_position => 1
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :Finned, :id => :Finned,
:id_number => 3, :name => _INTL("Finned"),
:name => _INTL("Finned") :icon_position => 2
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :HeadArms, :id => :HeadArms,
:id_number => 4, :name => _INTL("Head and arms"),
:name => _INTL("Head and arms") :icon_position => 3
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :HeadBase, :id => :HeadBase,
:id_number => 5, :name => _INTL("Head and base"),
:name => _INTL("Head and base") :icon_position => 4
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :BipedalTail, :id => :BipedalTail,
:id_number => 6, :name => _INTL("Bipedal with tail"),
:name => _INTL("Bipedal with tail") :icon_position => 5
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :HeadLegs, :id => :HeadLegs,
:id_number => 7, :name => _INTL("Head and legs"),
:name => _INTL("Head and legs") :icon_position => 6
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :Quadruped, :id => :Quadruped,
:id_number => 8, :name => _INTL("Quadruped"),
:name => _INTL("Quadruped") :icon_position => 7
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :Winged, :id => :Winged,
:id_number => 9, :name => _INTL("Winged"),
:name => _INTL("Winged") :icon_position => 8
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :Multiped, :id => :Multiped,
:id_number => 10, :name => _INTL("Multiped"),
:name => _INTL("Multiped") :icon_position => 9
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :MultiBody, :id => :MultiBody,
:id_number => 11, :name => _INTL("Multi Body"),
:name => _INTL("Multi Body") :icon_position => 10
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :Bipedal, :id => :Bipedal,
:id_number => 12, :name => _INTL("Bipedal"),
:name => _INTL("Bipedal") :icon_position => 11
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :MultiWinged, :id => :MultiWinged,
:id_number => 13, :name => _INTL("Multi Winged"),
:name => _INTL("Multi Winged") :icon_position => 12
}) })
GameData::BodyShape.register({ GameData::BodyShape.register({
:id => :Insectoid, :id => :Insectoid,
:id_number => 14, :name => _INTL("Insectoid"),
:name => _INTL("Insectoid") :icon_position => 13
}) })

View File

@@ -1,14 +1,13 @@
# NOTE: The id_number is only used to determine the order that body colors are # NOTE: The order these colors are registered are the order they are listed in
# listed in the Pokédex search screen. # the Pokédex search screen.
module GameData module GameData
class BodyColor class BodyColor
attr_reader :id attr_reader :id
attr_reader :id_number
attr_reader :real_name attr_reader :real_name
DATA = {} DATA = {}
extend ClassMethods extend ClassMethodsSymbols
include InstanceMethods include InstanceMethods
def self.load; end def self.load; end
@@ -16,8 +15,7 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@id_number = hash[:id_number] || -1 @real_name = hash[:name] || "Unnamed"
@real_name = hash[:name] || "Unnamed"
end end
# @return [String] the translated name of this body color # @return [String] the translated name of this body color
@@ -30,61 +28,51 @@ end
#=============================================================================== #===============================================================================
GameData::BodyColor.register({ GameData::BodyColor.register({
:id => :Red, :id => :Red,
:id_number => 0, :name => _INTL("Red")
:name => _INTL("Red")
}) })
GameData::BodyColor.register({ GameData::BodyColor.register({
:id => :Blue, :id => :Blue,
:id_number => 1, :name => _INTL("Blue")
:name => _INTL("Blue")
}) })
GameData::BodyColor.register({ GameData::BodyColor.register({
:id => :Yellow, :id => :Yellow,
:id_number => 2, :name => _INTL("Yellow")
:name => _INTL("Yellow")
}) })
GameData::BodyColor.register({ GameData::BodyColor.register({
:id => :Green, :id => :Green,
:id_number => 3, :name => _INTL("Green")
:name => _INTL("Green")
}) })
GameData::BodyColor.register({ GameData::BodyColor.register({
:id => :Black, :id => :Black,
:id_number => 4, :name => _INTL("Black")
:name => _INTL("Black")
}) })
GameData::BodyColor.register({ GameData::BodyColor.register({
:id => :Brown, :id => :Brown,
:id_number => 5, :name => _INTL("Brown")
:name => _INTL("Brown")
}) })
GameData::BodyColor.register({ GameData::BodyColor.register({
:id => :Purple, :id => :Purple,
:id_number => 6, :name => _INTL("Purple")
:name => _INTL("Purple")
}) })
GameData::BodyColor.register({ GameData::BodyColor.register({
:id => :Gray, :id => :Gray,
:id_number => 7, :name => _INTL("Gray")
:name => _INTL("Gray")
}) })
GameData::BodyColor.register({ GameData::BodyColor.register({
:id => :White, :id => :White,
:id_number => 8, :name => _INTL("White")
:name => _INTL("White")
}) })
GameData::BodyColor.register({ GameData::BodyColor.register({
:id => :Pink, :id => :Pink,
:id_number => 9, :name => _INTL("Pink")
:name => _INTL("Pink")
}) })

View File

@@ -21,7 +21,7 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@animation = hash[:animation] @animation = hash[:animation]
@icon_position = hash[:icon_position] || -1 # -1 means "no icon" @icon_position = hash[:icon_position] || -1 # -1 means "no icon"
end end

View File

@@ -8,7 +8,6 @@
module GameData module GameData
class Target class Target
attr_reader :id attr_reader :id
attr_reader :id_number
attr_reader :real_name attr_reader :real_name
attr_reader :num_targets # 0, 1 or 2 (meaning 2+) attr_reader :num_targets # 0, 1 or 2 (meaning 2+)
attr_reader :targets_foe # Is able to target one or more foes attr_reader :targets_foe # Is able to target one or more foes
@@ -18,7 +17,7 @@ module GameData
DATA = {} DATA = {}
extend ClassMethods extend ClassMethodsSymbols
include InstanceMethods include InstanceMethods
def self.load; end def self.load; end
@@ -54,20 +53,17 @@ end
# Bide, Counter, Metal Burst, Mirror Coat (calculate a target) # Bide, Counter, Metal Burst, Mirror Coat (calculate a target)
GameData::Target.register({ GameData::Target.register({
:id => :None, :id => :None,
:id_number => 1,
:name => _INTL("None") :name => _INTL("None")
}) })
GameData::Target.register({ GameData::Target.register({
:id => :User, :id => :User,
:id_number => 10,
:name => _INTL("User") :name => _INTL("User")
}) })
# Aromatic Mist, Helping Hand, Hold Hands # Aromatic Mist, Helping Hand, Hold Hands
GameData::Target.register({ GameData::Target.register({
:id => :NearAlly, :id => :NearAlly,
:id_number => 100,
:name => _INTL("Near Ally"), :name => _INTL("Near Ally"),
:num_targets => 1 :num_targets => 1
}) })
@@ -75,7 +71,6 @@ GameData::Target.register({
# Acupressure # Acupressure
GameData::Target.register({ GameData::Target.register({
:id => :UserOrNearAlly, :id => :UserOrNearAlly,
:id_number => 200,
:name => _INTL("User or Near Ally"), :name => _INTL("User or Near Ally"),
:num_targets => 1 :num_targets => 1
}) })
@@ -83,7 +78,6 @@ GameData::Target.register({
# Aromatherapy, Gear Up, Heal Bell, Life Dew, Magnetic Flux, Howl (in Gen 8+) # Aromatherapy, Gear Up, Heal Bell, Life Dew, Magnetic Flux, Howl (in Gen 8+)
GameData::Target.register({ GameData::Target.register({
:id => :UserAndAllies, :id => :UserAndAllies,
:id_number => 5,
:name => _INTL("User and Allies"), :name => _INTL("User and Allies"),
:num_targets => 2, :num_targets => 2,
:long_range => true :long_range => true
@@ -92,7 +86,6 @@ GameData::Target.register({
# Me First # Me First
GameData::Target.register({ GameData::Target.register({
:id => :NearFoe, :id => :NearFoe,
:id_number => 400,
:name => _INTL("Near Foe"), :name => _INTL("Near Foe"),
:num_targets => 1, :num_targets => 1,
:targets_foe => true :targets_foe => true
@@ -101,7 +94,6 @@ GameData::Target.register({
# Petal Dance, Outrage, Struggle, Thrash, Uproar # Petal Dance, Outrage, Struggle, Thrash, Uproar
GameData::Target.register({ GameData::Target.register({
:id => :RandomNearFoe, :id => :RandomNearFoe,
:id_number => 2,
:name => _INTL("Random Near Foe"), :name => _INTL("Random Near Foe"),
:num_targets => 1, :num_targets => 1,
:targets_foe => true :targets_foe => true
@@ -109,7 +101,6 @@ GameData::Target.register({
GameData::Target.register({ GameData::Target.register({
:id => :AllNearFoes, :id => :AllNearFoes,
:id_number => 4,
:name => _INTL("All Near Foes"), :name => _INTL("All Near Foes"),
:num_targets => 2, :num_targets => 2,
:targets_foe => true :targets_foe => true
@@ -118,7 +109,6 @@ GameData::Target.register({
# For throwing a Poké Ball # For throwing a Poké Ball
GameData::Target.register({ GameData::Target.register({
:id => :Foe, :id => :Foe,
:id_number => 9,
:name => _INTL("Foe"), :name => _INTL("Foe"),
:num_targets => 1, :num_targets => 1,
:targets_foe => true, :targets_foe => true,
@@ -128,7 +118,6 @@ GameData::Target.register({
# Unused # Unused
GameData::Target.register({ GameData::Target.register({
:id => :AllFoes, :id => :AllFoes,
:id_number => 6,
:name => _INTL("All Foes"), :name => _INTL("All Foes"),
:num_targets => 2, :num_targets => 2,
:targets_foe => true, :targets_foe => true,
@@ -137,7 +126,6 @@ GameData::Target.register({
GameData::Target.register({ GameData::Target.register({
:id => :NearOther, :id => :NearOther,
:id_number => 0,
:name => _INTL("Near Other"), :name => _INTL("Near Other"),
:num_targets => 1, :num_targets => 1,
:targets_foe => true :targets_foe => true
@@ -145,7 +133,6 @@ GameData::Target.register({
GameData::Target.register({ GameData::Target.register({
:id => :AllNearOthers, :id => :AllNearOthers,
:id_number => 8,
:name => _INTL("All Near Others"), :name => _INTL("All Near Others"),
:num_targets => 2, :num_targets => 2,
:targets_foe => true :targets_foe => true
@@ -154,7 +141,6 @@ GameData::Target.register({
# Most Flying-type moves, pulse moves (hits non-near targets) # Most Flying-type moves, pulse moves (hits non-near targets)
GameData::Target.register({ GameData::Target.register({
:id => :Other, :id => :Other,
:id_number => 3,
:name => _INTL("Other"), :name => _INTL("Other"),
:num_targets => 1, :num_targets => 1,
:targets_foe => true, :targets_foe => true,
@@ -164,7 +150,6 @@ GameData::Target.register({
# Flower Shield, Perish Song, Rototiller, Teatime # Flower Shield, Perish Song, Rototiller, Teatime
GameData::Target.register({ GameData::Target.register({
:id => :AllBattlers, :id => :AllBattlers,
:id_number => 7,
:name => _INTL("All Battlers"), :name => _INTL("All Battlers"),
:num_targets => 2, :num_targets => 2,
:targets_foe => true, :targets_foe => true,
@@ -174,21 +159,18 @@ GameData::Target.register({
GameData::Target.register({ GameData::Target.register({
:id => :UserSide, :id => :UserSide,
:id_number => 40,
:name => _INTL("User Side") :name => _INTL("User Side")
}) })
# Entry hazards # Entry hazards
GameData::Target.register({ GameData::Target.register({
:id => :FoeSide, :id => :FoeSide,
:id_number => 80,
:name => _INTL("Foe Side"), :name => _INTL("Foe Side"),
:affects_foe_side => true :affects_foe_side => true
}) })
GameData::Target.register({ GameData::Target.register({
:id => :BothSides, :id => :BothSides,
:id_number => 20,
:name => _INTL("Both Sides"), :name => _INTL("Both Sides"),
:affects_foe_side => true :affects_foe_side => true
}) })

View File

@@ -24,12 +24,8 @@ module GameData
if optional_suffix && !optional_suffix.empty? if optional_suffix && !optional_suffix.empty?
ret = path + tr_type_data.id.to_s + optional_suffix + suffix ret = path + tr_type_data.id.to_s + optional_suffix + suffix
return ret if pbResolveBitmap(ret) return ret if pbResolveBitmap(ret)
ret = path + sprintf("%03d", tr_type_data.id_number) + optional_suffix + suffix
return ret if pbResolveBitmap(ret)
end end
ret = path + tr_type_data.id.to_s + suffix ret = path + tr_type_data.id.to_s + suffix
return ret if pbResolveBitmap(ret)
ret = path + sprintf("%03d", tr_type_data.id_number) + suffix
return (pbResolveBitmap(ret)) ? ret : nil return (pbResolveBitmap(ret)) ? ret : nil
end end

View File

@@ -310,7 +310,7 @@ module ItemStorageHelper
items[i] = [item, [qty, maxPerSlot].min] items[i] = [item, [qty, maxPerSlot].min]
qty -= items[i][1] qty -= items[i][1]
if itemPocket > 0 && sorting && Settings::BAG_POCKET_AUTO_SORT[itemPocket] if itemPocket > 0 && sorting && Settings::BAG_POCKET_AUTO_SORT[itemPocket]
items.sort! { |a, b| GameData::Item.get(a[0]).id_number <=> GameData::Item.get(b[0]).id_number } items.sort! { |a, b| GameData::Item.keys.index(a[0]) <=> GameData::Item.keys.index(b[0]) }
end end
return true if qty == 0 return true if qty == 0
elsif itemslot[0] == item && itemslot[1] < maxPerSlot elsif itemslot[0] == item && itemslot[1] < maxPerSlot

View File

@@ -502,8 +502,8 @@ class PokemonPokedex_Scene
overlay.blt(344,266,@hwbitmap.bitmap,Rect.new(32,(hwoffset) ? 44 : 0,32,44)) overlay.blt(344,266,@hwbitmap.bitmap,Rect.new(32,(hwoffset) ? 44 : 0,32,44))
# Draw shape icon # Draw shape icon
if params[9] >= 0 if params[9] >= 0
shape_number = @shapeCommands[params[9]].id_number shape_number = @shapeCommands[params[9]].icon_position
shaperect = Rect.new(0, (shape_number - 1) * 60, 60, 60) shaperect = Rect.new(0, shape_number * 60, 60, 60)
overlay.blt(424, 218, @shapebitmap.bitmap, shaperect) overlay.blt(424, 218, @shapebitmap.bitmap, shaperect)
end end
# Draw all text # Draw all text
@@ -609,7 +609,7 @@ class PokemonPokedex_Scene
end end
when 6 # Shape icon when 6 # Shape icon
if sel[0] >= 0 if sel[0] >= 0
shaperect = Rect.new(0, (@shapeCommands[sel[0]].id_number - 1) * 60, 60, 60) shaperect = Rect.new(0, @shapeCommands[sel[0]].icon_position * 60, 60, 60)
overlay.blt(332, 50, @shapebitmap.bitmap, shaperect) overlay.blt(332, 50, @shapebitmap.bitmap, shaperect)
end end
else else
@@ -681,7 +681,7 @@ class PokemonPokedex_Scene
when 6 # Shape when 6 # Shape
shaperect = Rect.new(0, 0, 60, 60) shaperect = Rect.new(0, 0, 60, 60)
for i in 0...cmds.length for i in 0...cmds.length
shaperect.y = (@shapeCommands[i].id_number - 1) * 60 shaperect.y = @shapeCommands[i].icon_position * 60
overlay.blt(xstart + 4 + (i % cols) * xgap, ystart + 4 + (i / cols).floor * ygap, @shapebitmap.bitmap, shaperect) overlay.blt(xstart + 4 + (i % cols) * xgap, ystart + 4 + (i / cols).floor * ygap, @shapebitmap.bitmap, shaperect)
end end
end end
@@ -1021,9 +1021,9 @@ class PokemonPokedex_Scene
180,200,250,300,350,400,500,600,700,800, 180,200,250,300,350,400,500,600,700,800,
900,1000,1250,1500,2000,3000,5000] 900,1000,1250,1500,2000,3000,5000]
@colorCommands = [] @colorCommands = []
GameData::BodyColor.each { |c| @colorCommands.push(c) } GameData::BodyColor.each { |c| @colorCommands.push(c) if c.id != :None }
@shapeCommands = [] @shapeCommands = []
GameData::BodyShape.each { |c| @shapeCommands.push(c) if c.id != :None } GameData::BodyShape.each { |s| @shapeCommands.push(s) if s.id != :None }
@sprites["searchbg"].visible = true @sprites["searchbg"].visible = true
@sprites["overlay"].visible = true @sprites["overlay"].visible = true
@sprites["searchcursor"].visible = true @sprites["searchcursor"].visible = true

View File

@@ -278,7 +278,7 @@ module Compiler
:accuracy => line[7], :accuracy => line[7],
:total_pp => line[8], :total_pp => line[8],
:effect_chance => line[9], :effect_chance => line[9],
:target => GameData::Target.get(line[10]).id, :target => line[10],
:priority => line[11], :priority => line[11],
:flags => line[12], :flags => line[12],
:description => line[13] :description => line[13]