Added class GameData::BodyColor

This commit is contained in:
Maruno17
2021-02-06 22:40:41 +00:00
parent a5af35beb1
commit 2e125019a9
7 changed files with 119 additions and 56 deletions

View File

@@ -96,7 +96,7 @@ module GameData
"StepsToHatch" => [0, "v"],
"Height" => [0, "f"],
"Weight" => [0, "f"],
"Color" => [0, "e", :PBColors],
"Color" => [0, "e", :BodyColor],
"Shape" => [0, "u"],
"Habitat" => [0, "e", :Habitat],
"Generation" => [0, "i"],
@@ -159,7 +159,7 @@ module GameData
@evolutions = hash[:evolutions] || []
@height = hash[:height] || 1
@weight = hash[:weight] || 1
@color = hash[:color] || PBColors::Red
@color = hash[:color] || :Red
@shape = hash[:shape] || 1
@habitat = hash[:habitat] || :None
@generation = hash[:generation] || 0

View File

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

View File

@@ -1,32 +0,0 @@
# Colors must begin at 0 and have no missing numbers
module PBColors
Red = 0
Blue = 1
Yellow = 2
Green = 3
Black = 4
Brown = 5
Purple = 6
Gray = 7
White = 8
Pink = 9
def self.maxValue; 9; end
def self.getName(id)
id = getID(PBColors,id)
names = [
_INTL("Red"),
_INTL("Blue"),
_INTL("Yellow"),
_INTL("Green"),
_INTL("Black"),
_INTL("Brown"),
_INTL("Purple"),
_INTL("Gray"),
_INTL("White"),
_INTL("Pink")
]
return names[id]
end
end

View File

@@ -16,7 +16,7 @@ module GameData
@real_name = hash[:name] || "Unnamed"
end
# @return [String] the translated name of this egg group
# @return [String] the translated name of this habitat
def name
return _INTL(@real_name)
end

View File

@@ -460,7 +460,7 @@ class PokemonPokedex_Scene
# Write order, name and color parameters
textpos.push([@orderCommands[params[0]],344,60,2,base,shadow,1])
textpos.push([(params[1]<0) ? "----" : @nameCommands[params[1]],176,118,2,base,shadow,1])
textpos.push([(params[8]<0) ? "----" : @colorCommands[params[8]],444,118,2,base,shadow,1])
textpos.push([(params[8]<0) ? "----" : @colorCommands[params[8]].name,444,118,2,base,shadow,1])
# Draw type icons
if params[2]>=0
type_number = @typeCommands[params[2]].id_number
@@ -600,6 +600,12 @@ class PokemonPokedex_Scene
textpos.push([txt1,286,58,2,base,shadow,1])
textpos.push([txt2,414,58,2,base,shadow,1])
overlay.blt(462,52,@hwbitmap.bitmap,Rect.new(32,(hwoffset) ? 44 : 0,32,44))
when 5 # Color
if sel[0]<0
textpos.push(["----",362,58,2,base,shadow,1])
else
textpos.push([cmds[sel[0]].name,362,58,2,base,shadow,1])
end
when 6 # Shape icon
if sel[0]>=0
shaperect = Rect.new(0,@shapeCommands[sel[0]]*60,60,60)
@@ -614,7 +620,7 @@ class PokemonPokedex_Scene
end
end
# Draw selected option(s) button graphic
if mode==3 || mode==4 # Height, weight
if mode==3 || mode==4 # Height, weight
xpos1 = xstart+(sel[0]+1)*xgap
xpos1 = xstart if sel[0]<-1
xpos2 = xstart+(sel[1]+1)*xgap
@@ -645,7 +651,7 @@ class PokemonPokedex_Scene
end
# Draw options
case mode
when 0,1,5 # Order, name, color
when 0,1 # Order, name
for i in 0...cmds.length
x = xstart+halfwidth+(i%cols)*xgap
y = ystart+6+(i/cols).floor*ygap
@@ -655,7 +661,7 @@ class PokemonPokedex_Scene
textpos.push([(mode==1) ? "-" : "----",
xstart+halfwidth+(cols-1)*xgap,ystart+6+(cmds.length/cols).floor*ygap,2,base,shadow,1])
end
when 2 # Type
when 2 # Type
typerect = Rect.new(0,0,96,32)
for i in 0...cmds.length
typerect.y = @typeCommands[i].id_number*32
@@ -663,7 +669,15 @@ class PokemonPokedex_Scene
end
textpos.push(["----",
xstart+halfwidth+(cols-1)*xgap,ystart+6+(cmds.length/cols).floor*ygap,2,base,shadow,1])
when 6 # Shape
when 5 # Color
for i in 0...cmds.length
x = xstart+halfwidth+(i%cols)*xgap
y = ystart+6+(i/cols).floor*ygap
textpos.push([cmds[i].name,x,y,2,base,shadow,1])
end
textpos.push(["----",
xstart+halfwidth+(cols-1)*xgap,ystart+6+(cmds.length/cols).floor*ygap,2,base,shadow,1])
when 6 # Shape
shaperect = Rect.new(0,0,60,60)
for i in 0...cmds.length
shaperect.y = i*60
@@ -738,16 +752,10 @@ class PokemonPokedex_Scene
end
# Filter by color
if params[8]>=0
colorCommands = []
for i in 0..PBColors.maxValue
j = PBColors.getName(i)
colorCommands.push(i) if j
end
scolor = colorCommands[params[8]]
scolor = @colorCommands[params[8]].id
dexlist = dexlist.find_all { |item|
next false if !$Trainer.seen?(item[0])
color = item[8]
next color==scolor
next item[8] == scolor
}
end
# Filter by shape
@@ -841,7 +849,9 @@ class PokemonPokedex_Scene
oldindex = index
minmax = 1
oldminmax = minmax
if mode==3 || mode==4; index = oldindex = selindex[minmax]; end
if mode==3 || mode==4
index = oldindex = selindex[minmax]
end
@sprites["searchcursor"].mode = mode
@sprites["searchcursor"].cmds = cmds.length
@sprites["searchcursor"].minmax = minmax
@@ -1013,10 +1023,7 @@ class PokemonPokedex_Scene
180,200,250,300,350,400,500,600,700,800,
900,1000,1250,1500,2000,3000,5000]
@colorCommands = []
for i in 0..PBColors.maxValue
j = PBColors.getName(i)
@colorCommands.push(j) if j
end
GameData::BodyColor.each { |c| @colorCommands.push(c) }
@shapeCommands = []
for i in 0...14; @shapeCommands.push(i); end
@sprites["searchbg"].visible = true

View File

@@ -981,7 +981,7 @@ def pbPokemonEditor
[_INTL("Evolutions"), EvolutionsProperty.new, _INTL("Evolution paths of this species.")],
[_INTL("Height"), NonzeroLimitProperty.new(999), _INTL("Height of the Pokémon in 0.1 metres (e.g. 42 = 4.2m).")],
[_INTL("Weight"), NonzeroLimitProperty.new(9999), _INTL("Weight of the Pokémon in 0.1 kilograms (e.g. 42 = 4.2kg).")],
[_INTL("Color"), EnumProperty2.new(PBColors), _INTL("Pokémon's body color.")],
[_INTL("Color"), GameDataProperty.new(:BodyColor), _INTL("Pokémon's body color.")],
[_INTL("Shape"), LimitProperty.new(14), _INTL("Body shape of this species (0-14).")],
[_INTL("Habitat"), GameDataProperty.new(:Habitat), _INTL("The habitat of this species.")],
[_INTL("Generation"), LimitProperty.new(99999), _INTL("The number of the generation the Pokémon debuted in.")],

View File

@@ -300,7 +300,7 @@ module Compiler
f.write(sprintf("StepsToHatch = %d\r\n", species.hatch_steps))
f.write(sprintf("Height = %.1f\r\n", species.height / 10.0))
f.write(sprintf("Weight = %.1f\r\n", species.weight / 10.0))
f.write(sprintf("Color = %s\r\n", getConstantName(PBColors, species.color)))
f.write(sprintf("Color = %s\r\n", species.color))
f.write(sprintf("Shape = %d\r\n", species.shape))
f.write(sprintf("Habitat = %s\r\n", species.habitat)) if species.habitat != :None
f.write(sprintf("Kind = %s\r\n", species.real_category))
@@ -395,7 +395,7 @@ module Compiler
f.write(sprintf("StepsToHatch = %d\r\n", species.hatch_steps)) if species.hatch_steps != base_species.hatch_steps
f.write(sprintf("Height = %.1f\r\n", species.height / 10.0)) if species.height != base_species.height
f.write(sprintf("Weight = %.1f\r\n", species.weight / 10.0)) if species.weight != base_species.weight
f.write(sprintf("Color = %s\r\n", getConstantName(PBColors, species.color))) if species.color != base_species.color
f.write(sprintf("Color = %s\r\n", species.color)) if species.color != base_species.color
f.write(sprintf("Shape = %d\r\n", species.shape)) if species.shape != base_species.shape
if species.habitat != :None && species.habitat != base_species.habitat
f.write(sprintf("Habitat = %s\r\n", species.habitat))