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. # A bulk loader method for all data stored in .dat files in the Data folder.
#============================================================================= #=============================================================================
def self.load_all def self.load_all
TownMap.load self.constants.each do |c|
Type.load next if !self.const_get(c).is_a?(Class)
Ability.load self.const_get(c).load if self.const_get(c).const_defined?(:DATA_FILENAME)
Move.load end
Item.load end
BerryPlant.load
Species.load def self.get_all_data_filenames
SpeciesMetrics.load ret = []
ShadowPokemon.load self.constants.each do |c|
Ribbon.load next if !self.const_get(c).is_a?(Class)
Encounter.load ret.push(self.const_get(c)::DATA_FILENAME) if self.const_get(c).const_defined?(:DATA_FILENAME)
TrainerType.load end
Trainer.load return ret
Metadata.load end
PlayerMetadata.load
MapMetadata.load def self.get_all_pbs_base_filenames
DungeonTileset.load ret = {}
DungeonParameters.load self.constants.each do |c|
PhoneMessage.load 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
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,9 +4,11 @@ module GameData
attr_reader :moves attr_reader :moves
attr_reader :gauge_size attr_reader :gauge_size
attr_reader :flags attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {} DATA = {}
DATA_FILENAME = "shadow_pokemon.dat" DATA_FILENAME = "shadow_pokemon.dat"
PBS_BASE_FILENAME = "shadow_pokemon"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "e", :Species], "SectionName" => [:id, "e", :Species],
@@ -20,10 +22,11 @@ module GameData
include InstanceMethods include InstanceMethods
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE @gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE
@moves = hash[:moves] || [] @moves = hash[:moves] || []
@flags = hash[:flags] || [] @flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end end
def has_flag?(flag) 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 :icon_position # Where this ribbon's graphic is within ribbons.png
attr_reader :real_description attr_reader :real_description
attr_reader :flags attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {} DATA = {}
DATA_FILENAME = "ribbons.dat" DATA_FILENAME = "ribbons.dat"
PBS_BASE_FILENAME = "ribbons"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"], "SectionName" => [:id, "m"],
@@ -26,6 +28,7 @@ module GameData
@icon_position = hash[:icon_position] || 0 @icon_position = hash[:icon_position] || 0
@real_description = hash[:real_description] || "???" @real_description = hash[:real_description] || "???"
@flags = hash[:flags] || [] @flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end end
# @return [String] the translated name of this ribbon # @return [String] the translated name of this ribbon

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -10,9 +10,11 @@ module GameData
attr_reader :floor_patch_under_walls attr_reader :floor_patch_under_walls
attr_reader :thin_north_wall_offset attr_reader :thin_north_wall_offset
attr_reader :flags attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {} DATA = {}
DATA_FILENAME = "dungeon_tilesets.dat" DATA_FILENAME = "dungeon_tilesets.dat"
PBS_BASE_FILENAME = "dungeon_tilesets"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "u"], "SectionName" => [:id, "u"],
@@ -51,6 +53,7 @@ module GameData
@flags = hash[:flags] || [] @flags = hash[:flags] || []
@tile_type_ids = {} @tile_type_ids = {}
set_tile_type_ids(hash) set_tile_type_ids(hash)
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end end
def set_tile_type_ids(hash) 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 :void_decoration_density, :void_decoration_large_density
attr_reader :rng_seed attr_reader :rng_seed
attr_reader :flags attr_reader :flags
attr_reader :pbs_file_suffix
DATA = {} DATA = {}
DATA_FILENAME = "dungeon_parameters.dat" DATA_FILENAME = "dungeon_parameters.dat"
PBS_BASE_FILENAME = "dungeon_parameters"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "mV"], "SectionName" => [:id, "mV"],
@@ -67,7 +69,7 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@area = hash[:area] @area = hash[:area]
@version = hash[:version] || 0 @version = hash[:version] || 0
@cell_count_x = (hash[:dungeon_size]) ? hash[:dungeon_size][0] : 5 @cell_count_x = (hash[:dungeon_size]) ? hash[:dungeon_size][0] : 5
@cell_count_y = (hash[:dungeon_size]) ? hash[:dungeon_size][1] : 5 @cell_count_y = (hash[:dungeon_size]) ? hash[:dungeon_size][1] : 5
@cell_width = (hash[:cell_size]) ? hash[:cell_size][0] : 10 @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_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_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 @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] @random_corridor_shift = hash[:random_corridor_shift]
@node_layout = hash[:node_layout] || :full @node_layout = hash[:node_layout] || :full
@room_layout = hash[:room_layout] || :full @room_layout = hash[:room_layout] || :full
@room_chance = hash[:room_chance] || 70 @room_chance = hash[:room_chance] || 70
@extra_connections_count = hash[:extra_connections_count] || 2 @extra_connections_count = hash[:extra_connections_count] || 2
@floor_patch_radius = (hash[:floor_patches]) ? hash[:floor_patches][0] : 3 @floor_patch_radius = (hash[:floor_patches]) ? hash[:floor_patches][0] : 3
@floor_patch_chance = (hash[:floor_patches]) ? hash[:floor_patches][1] : 75 @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_density = (hash[:void_decorations]) ? hash[:void_decorations][0] : 50
@void_decoration_large_density = (hash[:void_decorations]) ? hash[:void_decorations][1] : 200 @void_decoration_large_density = (hash[:void_decorations]) ? hash[:void_decorations][1] : 200
@rng_seed = hash[:rng_seed] @rng_seed = hash[:rng_seed]
@flags = hash[:flags] || [] @flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end end
def has_flag?(flag) def has_flag?(flag)

View File

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

View File

@@ -77,11 +77,12 @@ def pbEncountersEditor
# Construct encounter hash # Construct encounter hash
key = sprintf("%s_%d", new_map_ID, new_version).to_sym key = sprintf("%s_%d", new_map_ID, new_version).to_sym
encounter_hash = { encounter_hash = {
:id => key, :id => key,
:map => new_map_ID, :map => new_map_ID,
:version => new_version, :version => new_version,
:step_chances => {}, :step_chances => {},
:types => {} :types => {},
:pbs_file_suffix => GameData::Encounter.get(this_set[0], this_set[1]).pbs_file_suffix
} }
GameData::Encounter.get(this_set[0], this_set[1]).step_chances.each do |type, value| GameData::Encounter.get(this_set[0], this_set[1]).step_chances.each do |type, value|
encounter_hash[:step_chances][type] = value encounter_hash[:step_chances][type] = value
@@ -384,15 +385,16 @@ def pbTrainerTypeEditor
if pbPropertyList(t_data.id.to_s, data, trainer_type_properties, true) if pbPropertyList(t_data.id.to_s, data, trainer_type_properties, true)
# Construct trainer type hash # Construct trainer type hash
type_hash = { type_hash = {
:id => t_data.id, :id => t_data.id,
:name => data[1], :name => data[1],
:gender => data[2], :gender => data[2],
:base_money => data[3], :base_money => data[3],
:skill_level => data[4], :skill_level => data[4],
:flags => data[5], :flags => data[5],
:intro_BGM => data[6], :intro_BGM => data[6],
:battle_BGM => data[7], :battle_BGM => data[7],
:victory_BGM => data[8] :victory_BGM => data[8],
:pbs_file_suffix => t_data.pbs_file_suffix
} }
# Add trainer type's data to records # Add trainer type's data to records
GameData::TrainerType.register(type_hash) GameData::TrainerType.register(type_hash)
@@ -543,12 +545,13 @@ def pbTrainerBattleEditor
pbMessage(_INTL("Can't save. The Pokémon list is empty.")) pbMessage(_INTL("Can't save. The Pokémon list is empty."))
else else
trainer_hash = { trainer_hash = {
:trainer_type => data[0], :trainer_type => data[0],
:name => data[1], :name => data[1],
:version => data[2], :version => data[2],
:lose_text => data[3], :lose_text => data[3],
:pokemon => party, :pokemon => party,
:items => items :items => items,
:pbs_file_suffix => tr_data.pbs_file_suffix
} }
# Add trainer type's data to records # Add trainer type's data to records
trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]] trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]]
@@ -750,7 +753,8 @@ def pbEditMetadata
:trainer_victory_BGM => data[7], :trainer_victory_BGM => data[7],
:wild_capture_ME => data[8], :wild_capture_ME => data[8],
:surf_BGM => data[9], :surf_BGM => data[9],
:bicycle_BGM => data[10] :bicycle_BGM => data[10],
:pbs_file_suffix => metadata.pbs_file_suffix
} }
# Add metadata's data to records # Add metadata's data to records
GameData::Metadata.register(metadata_hash) GameData::Metadata.register(metadata_hash)
@@ -794,7 +798,8 @@ def pbEditPlayerMetadata(player_id = 1)
:dive_charset => data[5], :dive_charset => data[5],
:fish_charset => data[6], :fish_charset => data[6],
:surf_fish_charset => data[7], :surf_fish_charset => data[7],
:home => data[8] :home => data[8],
:pbs_file_suffix => metadata.pbs_file_suffix
} }
# Add player metadata's data to records # Add player metadata's data to records
GameData::PlayerMetadata.register(metadata_hash) GameData::PlayerMetadata.register(metadata_hash)
@@ -853,7 +858,8 @@ def pbEditMapMetadata(map_id)
:wild_capture_ME => data[18], :wild_capture_ME => data[18],
:town_map_size => data[19], :town_map_size => data[19],
:battle_environment => data[20], :battle_environment => data[20],
:flags => data[21] :flags => data[21],
:pbs_file_suffix => metadata.pbs_file_suffix
} }
# Add map metadata's data to records # Add map metadata's data to records
GameData::MapMetadata.register(metadata_hash) GameData::MapMetadata.register(metadata_hash)
@@ -916,18 +922,19 @@ def pbItemEditor
if pbPropertyList(itm.id.to_s, data, item_properties, true) if pbPropertyList(itm.id.to_s, data, item_properties, true)
# Construct item hash # Construct item hash
item_hash = { item_hash = {
:id => itm.id, :id => itm.id,
:name => data[1], :name => data[1],
:name_plural => data[2], :name_plural => data[2],
:pocket => data[3], :pocket => data[3],
:price => data[4], :price => data[4],
:sell_price => data[5], :sell_price => data[5],
:description => data[6], :description => data[6],
:field_use => data[7], :field_use => data[7],
:battle_use => data[8], :battle_use => data[8],
:consumable => data[9], :consumable => data[9],
:flags => data[10], :flags => data[10],
:move => data[11] :move => data[11],
:pbs_file_suffix => itm.pbs_file_suffix
} }
# Add item's data to records # Add item's data to records
GameData::Item.register(item_hash) GameData::Item.register(item_hash)
@@ -1146,7 +1153,8 @@ def pbPokemonEditor
:shape => data[35], :shape => data[35],
:habitat => data[36], :habitat => data[36],
:generation => data[37], :generation => data[37],
:flags => data[38] :flags => data[38],
:pbs_file_suffix => spec.pbs_file_suffix
} }
# Add species' data to records # Add species' data to records
GameData::Species.register(species_hash) GameData::Species.register(species_hash)

View File

@@ -780,30 +780,57 @@ module Compiler
Graphics.update Graphics.update
end end
def get_all_pbs_files_to_compile
# Get the GameData classes and their respective base PBS filenames
ret = GameData.get_all_pbs_base_filenames
ret.merge!({
:BattleFacility => "battle_facility_lists",
:Connection => "map_connections",
:RegionalDex => "regional_dexes"
})
ret.each { |key, val| ret[key] = [val] } # [base_filename, ["PBS/file.txt", etc.]]
# Look through all PBS files and match them to a GameData class based on
# their base filenames
text_files_keys = ret.keys.sort! { |a, b| ret[b][0].length <=> ret[a][0].length }
Dir.chdir("PBS/") do
Dir.glob("*.txt") do |f|
base_name = File.basename(f, ".txt")
text_files_keys.each do |key|
next if base_name != ret[key][0] && !f.start_with?(ret[key][0] + "_")
ret[key][1] ||= []
ret[key][1].push("PBS/" + f)
break
end
end
end
return ret
end
def compile_pbs_files def compile_pbs_files
text_files = get_all_pbs_files_to_compile
modify_pbs_file_contents_before_compiling modify_pbs_file_contents_before_compiling
compile_town_map compile_town_map(*text_files[:TownMap][1])
compile_connections compile_connections(*text_files[:Connection][1])
compile_types compile_types(*text_files[:Type][1])
compile_abilities compile_abilities(*text_files[:Ability][1])
compile_moves # Depends on Type compile_moves(*text_files[:Move][1]) # Depends on Type
compile_items # Depends on Move compile_items(*text_files[:Item][1]) # Depends on Move
compile_berry_plants # Depends on Item compile_berry_plants(*text_files[:BerryPlant][1]) # Depends on Item
compile_pokemon # Depends on Move, Item, Type, Ability compile_pokemon(*text_files[:Species][1]) # Depends on Move, Item, Type, Ability
compile_pokemon_forms # Depends on Species, Move, Item, Type, Ability compile_pokemon_forms(*text_files[:Species1][1]) # Depends on Species, Move, Item, Type, Ability
compile_pokemon_metrics # Depends on Species compile_pokemon_metrics(*text_files[:SpeciesMetrics][1]) # Depends on Species
compile_shadow_pokemon # Depends on Species compile_shadow_pokemon(*text_files[:ShadowPokemon][1]) # Depends on Species
compile_regional_dexes # Depends on Species compile_regional_dexes(*text_files[:RegionalDex][1]) # Depends on Species
compile_ribbons compile_ribbons(*text_files[:Ribbon][1])
compile_encounters # Depends on Species compile_encounters(*text_files[:Encounter][1]) # Depends on Species
compile_trainer_types compile_trainer_types(*text_files[:TrainerType][1])
compile_trainers # Depends on Species, Item, Move compile_trainers(*text_files[:Trainer][1]) # Depends on Species, Item, Move
compile_trainer_lists # Depends on TrainerType compile_trainer_lists # Depends on TrainerType
compile_metadata # Depends on TrainerType compile_metadata(*text_files[:Metadata][1]) # Depends on TrainerType
compile_map_metadata compile_map_metadata(*text_files[:MapMetadata][1])
compile_dungeon_tilesets compile_dungeon_tilesets(*text_files[:DungeonTileset][1])
compile_dungeon_parameters compile_dungeon_parameters(*text_files[:DungeonParameters][1])
compile_phone # Depends on TrainerType compile_phone(*text_files[:PhoneMessage][1]) # Depends on TrainerType
end end
def compile_all(mustCompile) def compile_all(mustCompile)
@@ -831,54 +858,14 @@ module Compiler
def main def main
return if !$DEBUG return if !$DEBUG
begin begin
dataFiles = [ # Get all data files and PBS files to be checked for their last modified times
"abilities.dat", data_files = GameData.get_all_data_filenames
"berry_plants.dat", data_files += [ # Extra .dat files for data that isn't a GameData class
"dungeon_parameters.dat",
"dungeon_tilesets.dat",
"encounters.dat",
"items.dat",
"map_connections.dat", "map_connections.dat",
"map_metadata.dat",
"metadata.dat",
"moves.dat",
"phone.dat",
"player_metadata.dat",
"regional_dexes.dat", "regional_dexes.dat",
"ribbons.dat", "trainer_lists.dat"
"shadow_pokemon.dat",
"species.dat",
"species_metrics.dat",
"town_map.dat",
"trainer_lists.dat",
"trainer_types.dat",
"trainers.dat",
"types.dat"
]
textFiles = [
"abilities.txt",
"battle_facility_lists.txt",
"berry_plants.txt",
"dungeon_parameters.txt",
"dungeon_tilesets.txt",
"encounters.txt",
"items.txt",
"map_connections.txt",
"map_metadata.txt",
"metadata.txt",
"moves.txt",
"phone.txt",
"pokemon.txt",
"pokemon_forms.txt",
"pokemon_metrics.txt",
"regional_dexes.txt",
"ribbons.txt",
"shadow_pokemon.txt",
"town_map.txt",
"trainer_types.txt",
"trainers.txt",
"types.txt"
] ]
text_files = get_all_pbs_files_to_compile
latestDataTime = 0 latestDataTime = 0
latestTextTime = 0 latestTextTime = 0
mustCompile = false mustCompile = false
@@ -891,9 +878,8 @@ module Compiler
write_all write_all
mustCompile = true mustCompile = true
end end
# Check data files and PBS files, and recompile if any PBS file was edited # Check data files for their latest modify time
# more recently than the data files were last created data_files.each do |filename|
dataFiles.each do |filename|
if safeExists?("Data/" + filename) if safeExists?("Data/" + filename)
begin begin
File.open("Data/#{filename}") { |file| File.open("Data/#{filename}") { |file|
@@ -907,24 +893,26 @@ module Compiler
break break
end end
end end
textFiles.each do |filename| # Check PBS files for their latest modify time
next if !safeExists?("PBS/" + filename) text_files.each do |key, value|
begin next if !value || !value[1].is_a?(Array)
File.open("PBS/#{filename}") { |file| value[1].each do |filepath|
latestTextTime = [latestTextTime, file.mtime.to_i].max begin
} File.open(filepath) { |file| latestTextTime = [latestTextTime, file.mtime.to_i].max }
rescue SystemCallError rescue SystemCallError
end
end end
end end
# Decide to compile if a PBS file was edited more recently than any .dat files
mustCompile |= (latestTextTime >= latestDataTime) mustCompile |= (latestTextTime >= latestDataTime)
# Should recompile if holding Ctrl # Should recompile if holding Ctrl
Input.update Input.update
mustCompile = true if Input.press?(Input::CTRL) mustCompile = true if Input.press?(Input::CTRL)
# Delete old data files in preparation for recompiling # Delete old data files in preparation for recompiling
if mustCompile if mustCompile
dataFiles.length.times do |i| data_files.length.times do |i|
begin begin
File.delete("Data/#{dataFiles[i]}") if safeExists?("Data/#{dataFiles[i]}") File.delete("Data/#{data_files[i]}") if safeExists?("Data/#{data_files[i]}")
rescue SystemCallError rescue SystemCallError
end end
end end
@@ -935,9 +923,9 @@ module Compiler
e = $! e = $!
raise e if e.class.to_s == "Reset" || e.is_a?(Reset) || e.is_a?(SystemExit) raise e if e.class.to_s == "Reset" || e.is_a?(Reset) || e.is_a?(SystemExit)
pbPrintException(e) pbPrintException(e)
dataFiles.length.times do |i| data_files.length.times do |i|
begin begin
File.delete("Data/#{dataFiles[i]}") File.delete("Data/#{data_files[i]}")
rescue SystemCallError rescue SystemCallError
end end
end end

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,18 @@
module Compiler module Compiler
module_function module_function
def get_all_PBS_file_paths(game_data)
ret = []
game_data.each { |element| ret.push(element.pbs_file_suffix) if !ret.include?(element.pbs_file_suffix) }
ret.each_with_index do |element, i|
ret[i] = [sprintf("PBS/%s.txt", game_data::PBS_BASE_FILENAME), element]
if !nil_or_empty?(element)
ret[i][0] = sprintf("PBS/%s_%s.txt", game_data::PBS_BASE_FILENAME, element)
end
end
return ret
end
def add_PBS_header_to_file(file) def add_PBS_header_to_file(file)
file.write(0xEF.chr) file.write(0xEF.chr)
file.write(0xBB.chr) file.write(0xBB.chr)
@@ -8,47 +20,55 @@ module Compiler
file.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n") file.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
end end
def write_PBS_file_generic(game_data, path) def write_PBS_file_generic(game_data)
write_pbs_file_message_start(path) paths = get_all_PBS_file_paths(game_data)
schema = game_data.schema schema = game_data.schema
File.open(path, "wb") { |f| idx = 0
add_PBS_header_to_file(f) paths.each do |path|
# Write each element in turn write_pbs_file_message_start(path[0])
game_data.each do |element| File.open(path[0], "wb") { |f|
f.write("\#-------------------------------\r\n") add_PBS_header_to_file(f)
if schema["SectionName"] # Write each element in turn
f.write("[") game_data.each do |element|
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"]) next if element.pbs_file_suffix != path[1]
f.write("]\r\n") echo "." if idx % 50 == 0
else Graphics.update if idx % 250 == 0
f.write("[#{element.id}]\r\n") idx += 1
end f.write("\#-------------------------------\r\n")
schema.each_key do |key| if schema["SectionName"]
next if key == "SectionName" f.write("[")
val = element.get_property_for_PBS(key) pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
next if val.nil? f.write("]\r\n")
if schema[key][1][0] == "^" && val.is_a?(Array) else
val.each do |sub_val| f.write("[#{element.id}]\r\n")
end
schema.each_key do |key|
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key)) f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key]) pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n") f.write("\r\n")
end end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end end
end end
end }
} process_pbs_file_message_end
process_pbs_file_message_end end
end end
#============================================================================= #=============================================================================
# Save Town Map data to PBS file # Save Town Map data to PBS file
#============================================================================= #=============================================================================
def write_town_map(path = "PBS/town_map.txt") def write_town_map
write_PBS_file_generic(GameData::TownMap, path) write_PBS_file_generic(GameData::TownMap)
end end
#============================================================================= #=============================================================================
@@ -114,36 +134,36 @@ module Compiler
#============================================================================= #=============================================================================
# Save type data to PBS file # Save type data to PBS file
#============================================================================= #=============================================================================
def write_types(path = "PBS/types.txt") def write_types
write_PBS_file_generic(GameData::Type, path) write_PBS_file_generic(GameData::Type)
end end
#============================================================================= #=============================================================================
# Save ability data to PBS file # Save ability data to PBS file
#============================================================================= #=============================================================================
def write_abilities(path = "PBS/abilities.txt") def write_abilities
write_PBS_file_generic(GameData::Ability, path) write_PBS_file_generic(GameData::Ability)
end end
#============================================================================= #=============================================================================
# Save move data to PBS file # Save move data to PBS file
#============================================================================= #=============================================================================
def write_moves(path = "PBS/moves.txt") def write_moves
write_PBS_file_generic(GameData::Move, path) write_PBS_file_generic(GameData::Move)
end end
#============================================================================= #=============================================================================
# Save item data to PBS file # Save item data to PBS file
#============================================================================= #=============================================================================
def write_items(path = "PBS/items.txt") def write_items
write_PBS_file_generic(GameData::Item, path) write_PBS_file_generic(GameData::Item)
end end
#============================================================================= #=============================================================================
# Save berry plant data to PBS file # Save berry plant data to PBS file
#============================================================================= #=============================================================================
def write_berry_plants(path = "PBS/berry_plants.txt") def write_berry_plants
write_PBS_file_generic(GameData::BerryPlant, path) write_PBS_file_generic(GameData::BerryPlant)
end end
#============================================================================= #=============================================================================
@@ -151,40 +171,55 @@ module Compiler
# NOTE: Doesn't use write_PBS_file_generic because it needs to ignore defined # NOTE: Doesn't use write_PBS_file_generic because it needs to ignore defined
# species with a form that isn't 0. # species with a form that isn't 0.
#============================================================================= #=============================================================================
def write_pokemon(path = "PBS/pokemon.txt") def write_pokemon
write_pbs_file_message_start(path) paths = []
GameData::Species.each_species { |element| paths.push(element.pbs_file_suffix) if !paths.include?(element.pbs_file_suffix) }
paths.each_with_index do |element, i|
paths[i] = [sprintf("PBS/%s.txt", GameData::Species::PBS_BASE_FILENAME[0]), element]
if !nil_or_empty?(element)
paths[i][0] = sprintf("PBS/%s_%s.txt", GameData::Species::PBS_BASE_FILENAME[0], element)
end
end
schema = GameData::Species.schema schema = GameData::Species.schema
File.open(path, "wb") { |f| idx = 0
add_PBS_header_to_file(f) paths.each do |path|
# Write each element in turn write_pbs_file_message_start(path[0])
GameData::Species.each_species do |element| File.open(path[0], "wb") { |f|
f.write("\#-------------------------------\r\n") add_PBS_header_to_file(f)
if schema["SectionName"] # Write each element in turn
f.write("[") GameData::Species.each_species do |element|
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"]) next if element.pbs_file_suffix != path[1]
f.write("]\r\n") echo "." if idx % 50 == 0
else Graphics.update if idx % 250 == 0
f.write("[#{element.id}]\r\n") idx += 1
end f.write("\#-------------------------------\r\n")
schema.each_key do |key| if schema["SectionName"]
next if key == "SectionName" f.write("[")
val = element.get_property_for_PBS(key) pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
next if val.nil? f.write("]\r\n")
if schema[key][1][0] == "^" && val.is_a?(Array) else
val.each do |sub_val| f.write("[#{element.id}]\r\n")
end
schema.each_key do |key|
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key)) f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key]) pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n") f.write("\r\n")
end end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end end
end end
end }
} process_pbs_file_message_end
process_pbs_file_message_end end
end end
#============================================================================= #=============================================================================
@@ -192,41 +227,59 @@ module Compiler
# NOTE: Doesn't use write_PBS_file_generic because it needs to ignore defined # NOTE: Doesn't use write_PBS_file_generic because it needs to ignore defined
# species with a form of 0, and needs its own schema. # species with a form of 0, and needs its own schema.
#============================================================================= #=============================================================================
def write_pokemon_forms(path = "PBS/pokemon_forms.txt") def write_pokemon_forms
write_pbs_file_message_start(path) paths = []
GameData::Species.each do |element|
next if element.form == 0
paths.push(element.pbs_file_suffix) if !paths.include?(element.pbs_file_suffix)
end
paths.each_with_index do |element, i|
paths[i] = [sprintf("PBS/%s.txt", GameData::Species::PBS_BASE_FILENAME[1]), element]
if !nil_or_empty?(element)
paths[i][0] = sprintf("PBS/%s_%s.txt", GameData::Species::PBS_BASE_FILENAME[1], element)
end
end
schema = GameData::Species.schema(true) schema = GameData::Species.schema(true)
File.open(path, "wb") { |f| idx = 0
add_PBS_header_to_file(f) paths.each do |path|
# Write each element in turn write_pbs_file_message_start(path[0])
GameData::Species.each do |element| File.open(path[0], "wb") { |f|
next if element.form == 0 add_PBS_header_to_file(f)
f.write("\#-------------------------------\r\n") # Write each element in turn
if schema["SectionName"] GameData::Species.each do |element|
f.write("[") next if element.form == 0
pbWriteCsvRecord(element.get_property_for_PBS("SectionName", true), f, schema["SectionName"]) next if element.pbs_file_suffix != path[1]
f.write("]\r\n") echo "." if idx % 50 == 0
else Graphics.update if idx % 250 == 0
f.write("[#{element.id}]\r\n") idx += 1
end f.write("\#-------------------------------\r\n")
schema.each_key do |key| if schema["SectionName"]
next if key == "SectionName" f.write("[")
val = element.get_property_for_PBS(key, true) pbWriteCsvRecord(element.get_property_for_PBS("SectionName", true), f, schema["SectionName"])
next if val.nil? f.write("]\r\n")
if schema[key][1][0] == "^" && val.is_a?(Array) else
val.each do |sub_val| f.write("[#{element.id}]\r\n")
end
schema.each_key do |key|
next if key == "SectionName"
val = element.get_property_for_PBS(key, true)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key)) f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key]) pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n") f.write("\r\n")
end end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end end
end end
end }
} process_pbs_file_message_end
process_pbs_file_message_end end
end end
#============================================================================= #=============================================================================
@@ -235,55 +288,73 @@ module Compiler
# metrics for forms of species where the metrics are the same as for the # metrics for forms of species where the metrics are the same as for the
# base species. # base species.
#============================================================================= #=============================================================================
def write_pokemon_metrics(path = "PBS/pokemon_metrics.txt") def write_pokemon_metrics
write_pbs_file_message_start(path) paths = []
GameData::SpeciesMetrics.each do |element|
next if element.form == 0
paths.push(element.pbs_file_suffix) if !paths.include?(element.pbs_file_suffix)
end
paths.each_with_index do |element, i|
paths[i] = [sprintf("PBS/%s.txt", GameData::SpeciesMetrics::PBS_BASE_FILENAME), element]
if !nil_or_empty?(element)
paths[i][0] = sprintf("PBS/%s_%s.txt", GameData::SpeciesMetrics::PBS_BASE_FILENAME, element)
end
end
schema = GameData::SpeciesMetrics.schema schema = GameData::SpeciesMetrics.schema
File.open(path, "wb") { |f| idx = 0
add_PBS_header_to_file(f) paths.each do |path|
# Write each element in turn write_pbs_file_message_start(path[0])
GameData::SpeciesMetrics.each do |element| File.open(path[0], "wb") { |f|
if element.form > 0 add_PBS_header_to_file(f)
base_element = GameData::SpeciesMetrics.get(element.species) # Write each element in turn
next if element.back_sprite == base_element.back_sprite && GameData::SpeciesMetrics.each do |element|
element.front_sprite == base_element.front_sprite && next if element.pbs_file_suffix != path[1]
element.front_sprite_altitude == base_element.front_sprite_altitude && if element.form > 0
element.shadow_x == base_element.shadow_x && base_element = GameData::SpeciesMetrics.get(element.species)
element.shadow_size == base_element.shadow_size next if element.back_sprite == base_element.back_sprite &&
end element.front_sprite == base_element.front_sprite &&
f.write("\#-------------------------------\r\n") element.front_sprite_altitude == base_element.front_sprite_altitude &&
if schema["SectionName"] element.shadow_x == base_element.shadow_x &&
f.write("[") element.shadow_size == base_element.shadow_size
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"]) end
f.write("]\r\n") echo "." if idx % 50 == 0
else Graphics.update if idx % 250 == 0
f.write("[#{element.id}]\r\n") idx += 1
end f.write("\#-------------------------------\r\n")
schema.each_key do |key| if schema["SectionName"]
next if key == "SectionName" f.write("[")
val = element.get_property_for_PBS(key) pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
next if val.nil? f.write("]\r\n")
if schema[key][1][0] == "^" && val.is_a?(Array) else
val.each do |sub_val| f.write("[#{element.id}]\r\n")
end
schema.each_key do |key|
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key)) f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key]) pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n") f.write("\r\n")
end end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end end
end end
end }
} process_pbs_file_message_end
process_pbs_file_message_end end
end end
#============================================================================= #=============================================================================
# Save Shadow Pokémon data to PBS file # Save Shadow Pokémon data to PBS file
#============================================================================= #=============================================================================
def write_shadow_pokemon(path = "PBS/shadow_pokemon.txt") def write_shadow_pokemon
write_PBS_file_generic(GameData::ShadowPokemon, path) write_PBS_file_generic(GameData::ShadowPokemon)
end end
#============================================================================= #=============================================================================
@@ -321,107 +392,115 @@ module Compiler
#============================================================================= #=============================================================================
# Save ability data to PBS file # Save ability data to PBS file
#============================================================================= #=============================================================================
def write_ribbons(path = "PBS/ribbons.txt") def write_ribbons
write_PBS_file_generic(GameData::Ribbon, path) write_PBS_file_generic(GameData::Ribbon)
end end
#============================================================================= #=============================================================================
# Save wild encounter data to PBS file # Save wild encounter data to PBS file
#============================================================================= #=============================================================================
def write_encounters(path = "PBS/encounters.txt") def write_encounters
write_pbs_file_message_start(path) paths = get_all_PBS_file_paths(GameData::Encounter)
map_infos = pbLoadMapInfos map_infos = pbLoadMapInfos
File.open(path, "wb") { |f| idx = 0
idx = 0 paths.each do |path|
add_PBS_header_to_file(f) write_pbs_file_message_start(path[0])
GameData::Encounter.each do |encounter_data| File.open(path[0], "wb") { |f|
echo "." if idx % 50 == 0 add_PBS_header_to_file(f)
idx += 1 GameData::Encounter.each do |element|
Graphics.update if idx % 250 == 0 next if element.pbs_file_suffix != path[1]
f.write("\#-------------------------------\r\n") echo "." if idx % 50 == 0
map_name = (map_infos[encounter_data.map]) ? " # #{map_infos[encounter_data.map].name}" : "" Graphics.update if idx % 250 == 0
if encounter_data.version > 0 idx += 1
f.write(sprintf("[%03d,%d]%s\r\n", encounter_data.map, encounter_data.version, map_name)) f.write("\#-------------------------------\r\n")
else map_name = (map_infos[element.map]) ? " # #{map_infos[element.map].name}" : ""
f.write(sprintf("[%03d]%s\r\n", encounter_data.map, map_name)) if element.version > 0
end f.write(sprintf("[%03d,%d]%s\r\n", element.map, element.version, map_name))
encounter_data.types.each do |type, slots|
next if !slots || slots.length == 0
if encounter_data.step_chances[type] && encounter_data.step_chances[type] > 0
f.write(sprintf("%s,%d\r\n", type.to_s, encounter_data.step_chances[type]))
else else
f.write(sprintf("%s\r\n", type.to_s)) f.write(sprintf("[%03d]%s\r\n", element.map, map_name))
end end
slots.each do |slot| element.types.each do |type, slots|
if slot[2] == slot[3] next if !slots || slots.length == 0
f.write(sprintf(" %d,%s,%d\r\n", slot[0], slot[1], slot[2])) if element.step_chances[type] && element.step_chances[type] > 0
f.write(sprintf("%s,%d\r\n", type.to_s, element.step_chances[type]))
else else
f.write(sprintf(" %d,%s,%d,%d\r\n", slot[0], slot[1], slot[2], slot[3])) f.write(sprintf("%s\r\n", type.to_s))
end
slots.each do |slot|
if slot[2] == slot[3]
f.write(sprintf(" %d,%s,%d\r\n", slot[0], slot[1], slot[2]))
else
f.write(sprintf(" %d,%s,%d,%d\r\n", slot[0], slot[1], slot[2], slot[3]))
end
end end
end end
end end
end }
} process_pbs_file_message_end
process_pbs_file_message_end end
end end
#============================================================================= #=============================================================================
# Save trainer type data to PBS file # Save trainer type data to PBS file
#============================================================================= #=============================================================================
def write_trainer_types(path = "PBS/trainer_types.txt") def write_trainer_types
write_PBS_file_generic(GameData::TrainerType, path) write_PBS_file_generic(GameData::TrainerType)
end end
#============================================================================= #=============================================================================
# Save individual trainer data to PBS file # Save individual trainer data to PBS file
#============================================================================= #=============================================================================
def write_trainers(path = "PBS/trainers.txt") def write_trainers
write_pbs_file_message_start(path) paths = get_all_PBS_file_paths(GameData::Trainer)
File.open(path, "wb") { |f| idx = 0
idx = 0 paths.each do |path|
add_PBS_header_to_file(f) write_pbs_file_message_start(path[0])
GameData::Trainer.each do |trainer| File.open(path[0], "wb") { |f|
echo "." if idx % 50 == 0 add_PBS_header_to_file(f)
idx += 1 GameData::Trainer.each do |element|
Graphics.update if idx % 250 == 0 next if element.pbs_file_suffix != path[1]
f.write("\#-------------------------------\r\n") echo "." if idx % 50 == 0
if trainer.version > 0 Graphics.update if idx % 250 == 0
f.write(sprintf("[%s,%s,%d]\r\n", trainer.trainer_type, trainer.real_name, trainer.version)) idx += 1
else f.write("\#-------------------------------\r\n")
f.write(sprintf("[%s,%s]\r\n", trainer.trainer_type, trainer.real_name)) if element.version > 0
end f.write(sprintf("[%s,%s,%d]\r\n", element.trainer_type, element.real_name, element.version))
f.write(sprintf("Items = %s\r\n", trainer.items.join(","))) if trainer.items.length > 0 else
if trainer.real_lose_text && !trainer.real_lose_text.empty? f.write(sprintf("[%s,%s]\r\n", element.trainer_type, element.real_name))
f.write(sprintf("LoseText = %s\r\n", trainer.real_lose_text)) end
end f.write(sprintf("Items = %s\r\n", element.items.join(","))) if element.items.length > 0
trainer.pokemon.each do |pkmn| if element.real_lose_text && !element.real_lose_text.empty?
f.write(sprintf("Pokemon = %s,%d\r\n", pkmn[:species], pkmn[:level])) f.write(sprintf("LoseText = %s\r\n", element.real_lose_text))
f.write(sprintf(" Name = %s\r\n", pkmn[:name])) if pkmn[:name] && !pkmn[:name].empty? end
f.write(sprintf(" Form = %d\r\n", pkmn[:form])) if pkmn[:form] && pkmn[:form] > 0 element.pokemon.each do |pkmn|
f.write(sprintf(" Gender = %s\r\n", (pkmn[:gender] == 1) ? "female" : "male")) if pkmn[:gender] f.write(sprintf("Pokemon = %s,%d\r\n", pkmn[:species], pkmn[:level]))
f.write(" Shiny = yes\r\n") if pkmn[:shininess] && !pkmn[:super_shininess] f.write(sprintf(" Name = %s\r\n", pkmn[:name])) if pkmn[:name] && !pkmn[:name].empty?
f.write(" SuperShiny = yes\r\n") if pkmn[:super_shininess] f.write(sprintf(" Form = %d\r\n", pkmn[:form])) if pkmn[:form] && pkmn[:form] > 0
f.write(" Shadow = yes\r\n") if pkmn[:shadowness] f.write(sprintf(" Gender = %s\r\n", (pkmn[:gender] == 1) ? "female" : "male")) if pkmn[:gender]
f.write(sprintf(" Moves = %s\r\n", pkmn[:moves].join(","))) if pkmn[:moves] && pkmn[:moves].length > 0 f.write(" Shiny = yes\r\n") if pkmn[:shininess] && !pkmn[:super_shininess]
f.write(sprintf(" Ability = %s\r\n", pkmn[:ability])) if pkmn[:ability] f.write(" SuperShiny = yes\r\n") if pkmn[:super_shininess]
f.write(sprintf(" AbilityIndex = %d\r\n", pkmn[:ability_index])) if pkmn[:ability_index] f.write(" Shadow = yes\r\n") if pkmn[:shadowness]
f.write(sprintf(" Item = %s\r\n", pkmn[:item])) if pkmn[:item] f.write(sprintf(" Moves = %s\r\n", pkmn[:moves].join(","))) if pkmn[:moves] && pkmn[:moves].length > 0
f.write(sprintf(" Nature = %s\r\n", pkmn[:nature])) if pkmn[:nature] f.write(sprintf(" Ability = %s\r\n", pkmn[:ability])) if pkmn[:ability]
ivs_array = [] f.write(sprintf(" AbilityIndex = %d\r\n", pkmn[:ability_index])) if pkmn[:ability_index]
evs_array = [] f.write(sprintf(" Item = %s\r\n", pkmn[:item])) if pkmn[:item]
GameData::Stat.each_main do |s| f.write(sprintf(" Nature = %s\r\n", pkmn[:nature])) if pkmn[:nature]
next if s.pbs_order < 0 ivs_array = []
ivs_array[s.pbs_order] = pkmn[:iv][s.id] if pkmn[:iv] evs_array = []
evs_array[s.pbs_order] = pkmn[:ev][s.id] if pkmn[:ev] GameData::Stat.each_main do |s|
next if s.pbs_order < 0
ivs_array[s.pbs_order] = pkmn[:iv][s.id] if pkmn[:iv]
evs_array[s.pbs_order] = pkmn[:ev][s.id] if pkmn[:ev]
end
f.write(sprintf(" IV = %s\r\n", ivs_array.join(","))) if pkmn[:iv]
f.write(sprintf(" EV = %s\r\n", evs_array.join(","))) if pkmn[:ev]
f.write(sprintf(" Happiness = %d\r\n", pkmn[:happiness])) if pkmn[:happiness]
f.write(sprintf(" Ball = %s\r\n", pkmn[:poke_ball])) if pkmn[:poke_ball]
end end
f.write(sprintf(" IV = %s\r\n", ivs_array.join(","))) if pkmn[:iv]
f.write(sprintf(" EV = %s\r\n", evs_array.join(","))) if pkmn[:ev]
f.write(sprintf(" Happiness = %d\r\n", pkmn[:happiness])) if pkmn[:happiness]
f.write(sprintf(" Ball = %s\r\n", pkmn[:poke_ball])) if pkmn[:poke_ball]
end end
end }
} process_pbs_file_message_end
process_pbs_file_message_end end
end end
#============================================================================= #=============================================================================
@@ -542,22 +621,132 @@ module Compiler
# NOTE: Doesn't use write_PBS_file_generic because it contains data for two # NOTE: Doesn't use write_PBS_file_generic because it contains data for two
# different GameData classes. # different GameData classes.
#============================================================================= #=============================================================================
def write_metadata(path = "PBS/metadata.txt") def write_metadata
write_pbs_file_message_start(path) paths = []
GameData::Metadata.each do |element|
paths.push(element.pbs_file_suffix) if !paths.include?(element.pbs_file_suffix)
end
GameData::PlayerMetadata.each do |element|
paths.push(element.pbs_file_suffix) if !paths.include?(element.pbs_file_suffix)
end
paths.each_with_index do |element, i|
paths[i] = [sprintf("PBS/%s.txt", GameData::Metadata::PBS_BASE_FILENAME), element]
if !nil_or_empty?(element)
paths[i][0] = sprintf("PBS/%s_%s.txt", GameData::Metadata::PBS_BASE_FILENAME, element)
end
end
global_schema = GameData::Metadata.schema global_schema = GameData::Metadata.schema
player_schema = GameData::PlayerMetadata.schema player_schema = GameData::PlayerMetadata.schema
File.open(path, "wb") { |f| paths.each do |path|
add_PBS_header_to_file(f) write_pbs_file_message_start(path[0])
# Write each element in turn File.open(path[0], "wb") { |f|
[GameData::Metadata, GameData::PlayerMetadata].each do |game_data| add_PBS_header_to_file(f)
schema = global_schema if game_data == GameData::Metadata # Write each element in turn
schema = player_schema if game_data == GameData::PlayerMetadata [GameData::Metadata, GameData::PlayerMetadata].each do |game_data|
game_data.each do |element| schema = global_schema if game_data == GameData::Metadata
schema = player_schema if game_data == GameData::PlayerMetadata
game_data.each do |element|
next if element.pbs_file_suffix != path[1]
f.write("\#-------------------------------\r\n")
if schema["SectionName"]
f.write("[")
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
f.write("]\r\n")
else
f.write("[#{element.id}]\r\n")
end
schema.each_key do |key|
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
end
}
process_pbs_file_message_end
end
end
#=============================================================================
# Save map metadata data to PBS file
# NOTE: Doesn't use write_PBS_file_generic because it writes the RMXP map name
# next to the section header for each map.
#=============================================================================
def write_map_metadata
paths = get_all_PBS_file_paths(GameData::MapMetadata)
map_infos = pbLoadMapInfos
schema = GameData::MapMetadata.schema
idx = 0
paths.each do |path|
write_pbs_file_message_start(path[0])
File.open(path[0], "wb") { |f|
add_PBS_header_to_file(f)
GameData::MapMetadata.each do |element|
next if element.pbs_file_suffix != path[1]
echo "." if idx % 50 == 0
Graphics.update if idx % 250 == 0
idx += 1
f.write("\#-------------------------------\r\n")
map_name = (map_infos && map_infos[element.id]) ? map_infos[element.id].name : nil
f.write(sprintf("[%03d]", element.id))
f.write(sprintf(" # %s", map_name)) if map_name
f.write("\r\n")
schema.each_key do |key|
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
}
process_pbs_file_message_end
end
end
#=============================================================================
# Save dungeon tileset contents data to PBS file
# NOTE: Doesn't use write_PBS_file_generic because it writes the tileset name
# next to the section header for each tileset.
#=============================================================================
def write_dungeon_tilesets
paths = get_all_PBS_file_paths(GameData::DungeonTileset)
schema = GameData::DungeonTileset.schema
tilesets = load_data("Data/Tilesets.rxdata")
paths.each do |path|
write_pbs_file_message_start(path[0])
File.open(path[0], "wb") { |f|
add_PBS_header_to_file(f)
# Write each element in turn
GameData::DungeonTileset.each do |element|
next if element.pbs_file_suffix != path[1]
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
if schema["SectionName"] if schema["SectionName"]
f.write("[") f.write("[")
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"]) pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
f.write("]\r\n") f.write("]")
f.write(" # #{tilesets[element.id].name}") if tilesets && tilesets[element.id]
f.write("\r\n")
else else
f.write("[#{element.id}]\r\n") f.write("[#{element.id}]\r\n")
end end
@@ -578,109 +767,23 @@ module Compiler
end end
end end
end end
end }
} process_pbs_file_message_end
process_pbs_file_message_end end
end
#=============================================================================
# Save map metadata data to PBS file
# NOTE: Doesn't use write_PBS_file_generic because it writes the RMXP map name
# next to the section header for each map.
#=============================================================================
def write_map_metadata(path = "PBS/map_metadata.txt")
write_pbs_file_message_start(path)
map_infos = pbLoadMapInfos
schema = GameData::MapMetadata.schema
File.open(path, "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
GameData::MapMetadata.each do |element|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
f.write("\#-------------------------------\r\n")
map_name = (map_infos && map_infos[element.id]) ? map_infos[element.id].name : nil
f.write(sprintf("[%03d]", element.id))
f.write(sprintf(" # %s", map_name)) if map_name
f.write("\r\n")
schema.each_key do |key|
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
}
process_pbs_file_message_end
end
#=============================================================================
# Save dungeon tileset contents data to PBS file
# NOTE: Doesn't use write_PBS_file_generic because it writes the tileset name
# next to the section header for each tileset.
#=============================================================================
def write_dungeon_tilesets(path = "PBS/dungeon_tilesets.txt")
write_pbs_file_message_start(path)
tilesets = load_data("Data/Tilesets.rxdata")
schema = GameData::DungeonTileset.schema
File.open(path, "wb") { |f|
add_PBS_header_to_file(f)
# Write each element in turn
GameData::DungeonTileset.each do |element|
f.write("\#-------------------------------\r\n")
if schema["SectionName"]
f.write("[")
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
f.write("]")
f.write(" # #{tilesets[element.id].name}") if tilesets && tilesets[element.id]
f.write("\r\n")
else
f.write("[#{element.id}]\r\n")
end
schema.each_key do |key|
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
}
process_pbs_file_message_end
end end
#============================================================================= #=============================================================================
# Save dungeon parameters to PBS file # Save dungeon parameters to PBS file
#============================================================================= #=============================================================================
def write_dungeon_parameters(path = "PBS/dungeon_parameters.txt") def write_dungeon_parameters
write_PBS_file_generic(GameData::DungeonParameters, path) write_PBS_file_generic(GameData::DungeonParameters)
end end
#============================================================================= #=============================================================================
# Save phone messages to PBS file # Save phone messages to PBS file
#============================================================================= #=============================================================================
def write_phone(path = "PBS/phone.txt") def write_phone
write_PBS_file_generic(GameData::PhoneMessage, path) write_PBS_file_generic(GameData::PhoneMessage)
end end
#============================================================================= #=============================================================================