Allowed multiple PBS files per data type, removed hardcoded lists of PBS files/.dat files/GameData classes that need data loading

This commit is contained in:
Maruno17
2022-11-22 22:24:30 +00:00
parent 4d147a7bf7
commit bd04112122
24 changed files with 1134 additions and 937 deletions

View File

@@ -246,24 +246,34 @@ module GameData
# A bulk loader method for all data stored in .dat files in the Data folder.
#=============================================================================
def self.load_all
TownMap.load
Type.load
Ability.load
Move.load
Item.load
BerryPlant.load
Species.load
SpeciesMetrics.load
ShadowPokemon.load
Ribbon.load
Encounter.load
TrainerType.load
Trainer.load
Metadata.load
PlayerMetadata.load
MapMetadata.load
DungeonTileset.load
DungeonParameters.load
PhoneMessage.load
self.constants.each do |c|
next if !self.const_get(c).is_a?(Class)
self.const_get(c).load if self.const_get(c).const_defined?(:DATA_FILENAME)
end
end
def self.get_all_data_filenames
ret = []
self.constants.each do |c|
next if !self.const_get(c).is_a?(Class)
ret.push(self.const_get(c)::DATA_FILENAME) if self.const_get(c).const_defined?(:DATA_FILENAME)
end
return ret
end
def self.get_all_pbs_base_filenames
ret = {}
self.constants.each do |c|
next if !self.const_get(c).is_a?(Class)
ret[c] = self.const_get(c)::PBS_BASE_FILENAME if self.const_get(c).const_defined?(:PBS_BASE_FILENAME)
if ret[c].is_a?(Array)
ret[c].length.times do |i|
next if i == 0
ret[(c.to_s + i.to_s).to_sym] = ret[c][i] # :Species1 => "pokemon_forms"
end
ret[c] = ret[c][0] # :Species => "pokemon"
end
end
return ret
end
end

View File

@@ -5,9 +5,11 @@ module GameData
attr_reader :filename
attr_reader :point
attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "town_map.dat"
PBS_BASE_FILENAME = "town_map"
SCHEMA = {
"SectionName" => [:id, "u"],
@@ -21,11 +23,12 @@ module GameData
include InstanceMethods
def initialize(hash)
@id = hash[:id]
@real_name = hash[:real_name] || "???"
@filename = hash[:filename]
@point = hash[:point] || []
@flags = hash[:flags] || []
@id = hash[:id]
@real_name = hash[:real_name] || "???"
@filename = hash[:filename]
@point = hash[:point] || []
@flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of this region

View File

@@ -9,9 +9,11 @@ module GameData
attr_reader :resistances
attr_reader :immunities
attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "types.dat"
PBS_BASE_FILENAME = "types"
SCHEMA = {
"SectionName" => [:id, "m"],
@@ -29,18 +31,19 @@ module GameData
include InstanceMethods
def initialize(hash)
@id = hash[:id]
@real_name = hash[:real_name] || "Unnamed"
@icon_position = hash[:icon_position] || 0
@special_type = hash[:special_type] || false
@pseudo_type = hash[:pseudo_type] || false
@weaknesses = hash[:weaknesses] || []
@weaknesses = [@weaknesses] if !@weaknesses.is_a?(Array)
@resistances = hash[:resistances] || []
@resistances = [@resistances] if !@resistances.is_a?(Array)
@immunities = hash[:immunities] || []
@immunities = [@immunities] if !@immunities.is_a?(Array)
@flags = hash[:flags] || []
@id = hash[:id]
@real_name = hash[:real_name] || "Unnamed"
@icon_position = hash[:icon_position] || 0
@special_type = hash[:special_type] || false
@pseudo_type = hash[:pseudo_type] || false
@weaknesses = hash[:weaknesses] || []
@weaknesses = [@weaknesses] if !@weaknesses.is_a?(Array)
@resistances = hash[:resistances] || []
@resistances = [@resistances] if !@resistances.is_a?(Array)
@immunities = hash[:immunities] || []
@immunities = [@immunities] if !@immunities.is_a?(Array)
@flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of this item

View File

@@ -4,9 +4,11 @@ module GameData
attr_reader :real_name
attr_reader :real_description
attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "abilities.dat"
PBS_BASE_FILENAME = "abilities"
extend ClassMethodsSymbols
include InstanceMethods
@@ -23,6 +25,7 @@ module GameData
@real_name = hash[:real_name] || "Unnamed"
@real_description = hash[:real_description] || "???"
@flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of this ability

View File

@@ -14,9 +14,11 @@ module GameData
attr_reader :flags
attr_reader :effect_chance
attr_reader :real_description
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "moves.dat"
PBS_BASE_FILENAME = "moves"
SCHEMA = {
"SectionName" => [:id, "m"],
@@ -53,6 +55,7 @@ module GameData
@flags = [@flags] if !@flags.is_a?(Array)
@effect_chance = hash[:effect_chance] || 0
@real_description = hash[:real_description] || "???"
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of this move

View File

@@ -12,9 +12,11 @@ module GameData
attr_reader :consumable
attr_reader :move
attr_reader :real_description
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "items.dat"
PBS_BASE_FILENAME = "items"
SCHEMA = {
"SectionName" => [:id, "m"],
@@ -95,6 +97,7 @@ module GameData
@consumable = !is_important? if @consumable.nil?
@move = hash[:move]
@real_description = hash[:real_description] || "???"
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of this item

View File

@@ -4,9 +4,11 @@ module GameData
attr_reader :hours_per_stage
attr_reader :drying_per_hour
attr_reader :yield
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "berry_plants.dat"
PBS_BASE_FILENAME = "berry_plants"
SCHEMA = {
"SectionName" => [:id, "m"],
@@ -29,6 +31,7 @@ module GameData
@drying_per_hour = hash[:drying_per_hour] || 15
@yield = hash[:yield] || [2, 5]
@yield.reverse! if @yield[1] < @yield[0]
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
def minimum_yield

View File

@@ -40,9 +40,11 @@ module GameData
attr_reader :mega_move
attr_reader :unmega_form
attr_reader :mega_message
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "species.dat"
PBS_BASE_FILENAME = ["pokemon", "pokemon_forms"]
extend ClassMethodsSymbols
include InstanceMethods
@@ -175,6 +177,7 @@ module GameData
@mega_move = hash[:mega_move]
@unmega_form = hash[:unmega_form] || 0
@mega_message = hash[:mega_message] || 0
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of this species

View File

@@ -8,9 +8,11 @@ module GameData
attr_accessor :front_sprite_altitude
attr_accessor :shadow_x
attr_accessor :shadow_size
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "species_metrics.dat"
PBS_BASE_FILENAME = "pokemon_metrics"
SCHEMA = {
"SectionName" => [:id, "eV", :Species],
@@ -63,6 +65,7 @@ module GameData
@front_sprite_altitude = hash[:front_sprite_altitude] || 0
@shadow_x = hash[:shadow_x] || 0
@shadow_size = hash[:shadow_size] || 2
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
def apply_metrics_to_sprite(sprite, index, shadow = false)

View File

@@ -4,9 +4,11 @@ module GameData
attr_reader :moves
attr_reader :gauge_size
attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "shadow_pokemon.dat"
PBS_BASE_FILENAME = "shadow_pokemon"
SCHEMA = {
"SectionName" => [:id, "e", :Species],
@@ -20,10 +22,11 @@ module GameData
include InstanceMethods
def initialize(hash)
@id = hash[:id]
@gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE
@moves = hash[:moves] || []
@flags = hash[:flags] || []
@id = hash[:id]
@gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE
@moves = hash[:moves] || []
@flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
def has_flag?(flag)

View File

@@ -5,9 +5,11 @@ module GameData
attr_reader :icon_position # Where this ribbon's graphic is within ribbons.png
attr_reader :real_description
attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "ribbons.dat"
PBS_BASE_FILENAME = "ribbons"
SCHEMA = {
"SectionName" => [:id, "m"],
@@ -26,6 +28,7 @@ module GameData
@icon_position = hash[:icon_position] || 0
@real_description = hash[:real_description] || "???"
@flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of this ribbon

View File

@@ -3,11 +3,13 @@ module GameData
attr_accessor :id
attr_accessor :map
attr_accessor :version
attr_reader :step_chances
attr_reader :types
attr_reader :step_chances
attr_reader :types
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "encounters.dat"
PBS_BASE_FILENAME = "encounters"
extend ClassMethodsSymbols
include InstanceMethods
@@ -58,11 +60,12 @@ module GameData
end
def initialize(hash)
@id = hash[:id]
@map = hash[:map]
@version = hash[:version] || 0
@step_chances = hash[:step_chances]
@types = hash[:types] || {}
@id = hash[:id]
@map = hash[:map]
@version = hash[:version] || 0
@step_chances = hash[:step_chances]
@types = hash[:types] || {}
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
end
end

View File

@@ -9,9 +9,11 @@ module GameData
attr_reader :intro_BGM
attr_reader :battle_BGM
attr_reader :victory_BGM
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "trainer_types.dat"
PBS_BASE_FILENAME = "trainer_types"
SCHEMA = {
"SectionName" => [:id, "m"],
@@ -81,15 +83,16 @@ module GameData
end
def initialize(hash)
@id = hash[:id]
@real_name = hash[:real_name] || "Unnamed"
@gender = hash[:gender] || 2
@base_money = hash[:base_money] || 30
@skill_level = hash[:skill_level] || @base_money
@flags = hash[:flags] || []
@intro_BGM = hash[:intro_BGM]
@battle_BGM = hash[:battle_BGM]
@victory_BGM = hash[:victory_BGM]
@id = hash[:id]
@real_name = hash[:real_name] || "Unnamed"
@gender = hash[:gender] || 2
@base_money = hash[:base_money] || 30
@skill_level = hash[:skill_level] || @base_money
@flags = hash[:flags] || []
@intro_BGM = hash[:intro_BGM]
@battle_BGM = hash[:battle_BGM]
@victory_BGM = hash[:victory_BGM]
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of this trainer type

View File

@@ -7,9 +7,11 @@ module GameData
attr_reader :items
attr_reader :real_lose_text
attr_reader :pokemon
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "trainers.dat"
PBS_BASE_FILENAME = "trainers"
SCHEMA = {
"Items" => [:items, "*e", :Item],
@@ -71,19 +73,20 @@ module GameData
end
def initialize(hash)
@id = hash[:id]
@trainer_type = hash[:trainer_type]
@real_name = hash[:name] || "Unnamed"
@version = hash[:version] || 0
@items = hash[:items] || []
@real_lose_text = hash[:lose_text] || "..."
@pokemon = hash[:pokemon] || []
@id = hash[:id]
@trainer_type = hash[:trainer_type]
@real_name = hash[:name] || "Unnamed"
@version = hash[:version] || 0
@items = hash[:items] || []
@real_lose_text = hash[:lose_text] || "..."
@pokemon = hash[:pokemon] || []
@pokemon.each do |pkmn|
GameData::Stat.each_main do |s|
pkmn[:iv][s.id] ||= 0 if pkmn[:iv]
pkmn[:ev][s.id] ||= 0 if pkmn[:ev]
end
end
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of this trainer

View File

@@ -12,9 +12,11 @@ module GameData
attr_reader :wild_capture_ME
attr_reader :surf_BGM
attr_reader :bicycle_BGM
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "metadata.dat"
PBS_BASE_FILENAME = "metadata"
SCHEMA = {
"SectionName" => [:id, "u"],
@@ -67,11 +69,12 @@ module GameData
@wild_capture_ME = hash[:wild_capture_ME]
@surf_BGM = hash[:surf_BGM]
@bicycle_BGM = hash[:bicycle_BGM]
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of the Pokémon Storage creator
def storage_creator
ret = pbGetMessage(MessageTypes::StorageCreator, 0)
ret = pbGetMessageFromHash(MessageTypes::StorageCreator, @real_storage_creator)
return nil_or_empty?(ret) ? _INTL("Bill") : ret
end
end

View File

@@ -4,6 +4,7 @@ module GameData
attr_reader :trainer_type
attr_reader :walk_charset
attr_reader :home
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "player_metadata.dat"
@@ -57,6 +58,7 @@ module GameData
@fish_charset = hash[:fish_charset]
@surf_fish_charset = hash[:surf_fish_charset]
@home = hash[:home]
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
def run_charset

View File

@@ -23,9 +23,11 @@ module GameData
attr_reader :town_map_size
attr_reader :battle_environment
attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "map_metadata.dat"
PBS_BASE_FILENAME = "map_metadata"
SCHEMA = {
"SectionName" => [:id, "u"],
@@ -106,7 +108,8 @@ module GameData
@wild_capture_ME = hash[:wild_capture_ME]
@town_map_size = hash[:town_map_size]
@battle_environment = hash[:battle_environment]
@flags = hash[:flags] || []
@flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
# @return [String] the translated name of this map

View File

@@ -10,9 +10,11 @@ module GameData
attr_reader :floor_patch_under_walls
attr_reader :thin_north_wall_offset
attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "dungeon_tilesets.dat"
PBS_BASE_FILENAME = "dungeon_tilesets"
SCHEMA = {
"SectionName" => [:id, "u"],
@@ -51,6 +53,7 @@ module GameData
@flags = hash[:flags] || []
@tile_type_ids = {}
set_tile_type_ids(hash)
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
def set_tile_type_ids(hash)

View File

@@ -25,9 +25,11 @@ module GameData
attr_reader :void_decoration_density, :void_decoration_large_density
attr_reader :rng_seed
attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "dungeon_parameters.dat"
PBS_BASE_FILENAME = "dungeon_parameters"
SCHEMA = {
"SectionName" => [:id, "mV"],
@@ -67,7 +69,7 @@ module GameData
def initialize(hash)
@id = hash[:id]
@area = hash[:area]
@version = hash[:version] || 0
@version = hash[:version] || 0
@cell_count_x = (hash[:dungeon_size]) ? hash[:dungeon_size][0] : 5
@cell_count_y = (hash[:dungeon_size]) ? hash[:dungeon_size][1] : 5
@cell_width = (hash[:cell_size]) ? hash[:cell_size][0] : 10
@@ -76,11 +78,11 @@ module GameData
@room_min_height = (hash[:min_room_size]) ? hash[:min_room_size][1] : 5
@room_max_width = (hash[:max_room_size]) ? hash[:max_room_size][0] : @cell_width - 1
@room_max_height = (hash[:max_room_size]) ? hash[:max_room_size][1] : @cell_height - 1
@corridor_width = hash[:corridor_width] || 2
@corridor_width = hash[:corridor_width] || 2
@random_corridor_shift = hash[:random_corridor_shift]
@node_layout = hash[:node_layout] || :full
@room_layout = hash[:room_layout] || :full
@room_chance = hash[:room_chance] || 70
@node_layout = hash[:node_layout] || :full
@room_layout = hash[:room_layout] || :full
@room_chance = hash[:room_chance] || 70
@extra_connections_count = hash[:extra_connections_count] || 2
@floor_patch_radius = (hash[:floor_patches]) ? hash[:floor_patches][0] : 3
@floor_patch_chance = (hash[:floor_patches]) ? hash[:floor_patches][1] : 75
@@ -90,7 +92,8 @@ module GameData
@void_decoration_density = (hash[:void_decorations]) ? hash[:void_decorations][0] : 50
@void_decoration_large_density = (hash[:void_decorations]) ? hash[:void_decorations][1] : 200
@rng_seed = hash[:rng_seed]
@flags = hash[:flags] || []
@flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
def has_flag?(flag)

View File

@@ -6,9 +6,11 @@ module GameData
attr_reader :body, :body1, :body2
attr_reader :battle_request, :battle_remind
attr_reader :end
attr_reader :pbs_file_suffix
DATA = {}
DATA_FILENAME = "phone.dat"
PBS_BASE_FILENAME = "phone"
SCHEMA = {
"SectionName" => [:id, "q"],
@@ -16,9 +18,9 @@ module GameData
"IntroMorning" => [:intro_morning, "^q"],
"IntroAfternoon" => [:intro_afternoon, "^q"],
"IntroEvening" => [:intro_evening, "^q"],
"Body" => [:body, "^q"],
"Body1" => [:body1, "^q"],
"Body2" => [:body2, "^q"],
"Body" => [:body, "^q"],
"BattleRequest" => [:battle_request, "^q"],
"BattleRemind" => [:battle_remind, "^q"],
"End" => [:end, "^q"]
@@ -71,7 +73,7 @@ module GameData
@id = hash[:id]
@trainer_type = hash[:trainer_type]
@real_name = hash[:real_name]
@version = hash[:version] || 0
@version = hash[:version] || 0
@intro = hash[:intro]
@intro_morning = hash[:intro_morning]
@intro_afternoon = hash[:intro_afternoon]
@@ -82,6 +84,7 @@ module GameData
@battle_request = hash[:battle_request]
@battle_remind = hash[:battle_remind]
@end = hash[:end]
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)