mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 06:04:59 +00:00
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:
@@ -780,30 +780,57 @@ module Compiler
|
||||
Graphics.update
|
||||
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
|
||||
text_files = get_all_pbs_files_to_compile
|
||||
modify_pbs_file_contents_before_compiling
|
||||
compile_town_map
|
||||
compile_connections
|
||||
compile_types
|
||||
compile_abilities
|
||||
compile_moves # Depends on Type
|
||||
compile_items # Depends on Move
|
||||
compile_berry_plants # Depends on Item
|
||||
compile_pokemon # Depends on Move, Item, Type, Ability
|
||||
compile_pokemon_forms # Depends on Species, Move, Item, Type, Ability
|
||||
compile_pokemon_metrics # Depends on Species
|
||||
compile_shadow_pokemon # Depends on Species
|
||||
compile_regional_dexes # Depends on Species
|
||||
compile_ribbons
|
||||
compile_encounters # Depends on Species
|
||||
compile_trainer_types
|
||||
compile_trainers # Depends on Species, Item, Move
|
||||
compile_trainer_lists # Depends on TrainerType
|
||||
compile_metadata # Depends on TrainerType
|
||||
compile_map_metadata
|
||||
compile_dungeon_tilesets
|
||||
compile_dungeon_parameters
|
||||
compile_phone # Depends on TrainerType
|
||||
compile_town_map(*text_files[:TownMap][1])
|
||||
compile_connections(*text_files[:Connection][1])
|
||||
compile_types(*text_files[:Type][1])
|
||||
compile_abilities(*text_files[:Ability][1])
|
||||
compile_moves(*text_files[:Move][1]) # Depends on Type
|
||||
compile_items(*text_files[:Item][1]) # Depends on Move
|
||||
compile_berry_plants(*text_files[:BerryPlant][1]) # Depends on Item
|
||||
compile_pokemon(*text_files[:Species][1]) # Depends on Move, Item, Type, Ability
|
||||
compile_pokemon_forms(*text_files[:Species1][1]) # Depends on Species, Move, Item, Type, Ability
|
||||
compile_pokemon_metrics(*text_files[:SpeciesMetrics][1]) # Depends on Species
|
||||
compile_shadow_pokemon(*text_files[:ShadowPokemon][1]) # Depends on Species
|
||||
compile_regional_dexes(*text_files[:RegionalDex][1]) # Depends on Species
|
||||
compile_ribbons(*text_files[:Ribbon][1])
|
||||
compile_encounters(*text_files[:Encounter][1]) # Depends on Species
|
||||
compile_trainer_types(*text_files[:TrainerType][1])
|
||||
compile_trainers(*text_files[:Trainer][1]) # Depends on Species, Item, Move
|
||||
compile_trainer_lists # Depends on TrainerType
|
||||
compile_metadata(*text_files[:Metadata][1]) # Depends on TrainerType
|
||||
compile_map_metadata(*text_files[:MapMetadata][1])
|
||||
compile_dungeon_tilesets(*text_files[:DungeonTileset][1])
|
||||
compile_dungeon_parameters(*text_files[:DungeonParameters][1])
|
||||
compile_phone(*text_files[:PhoneMessage][1]) # Depends on TrainerType
|
||||
end
|
||||
|
||||
def compile_all(mustCompile)
|
||||
@@ -831,54 +858,14 @@ module Compiler
|
||||
def main
|
||||
return if !$DEBUG
|
||||
begin
|
||||
dataFiles = [
|
||||
"abilities.dat",
|
||||
"berry_plants.dat",
|
||||
"dungeon_parameters.dat",
|
||||
"dungeon_tilesets.dat",
|
||||
"encounters.dat",
|
||||
"items.dat",
|
||||
# Get all data files and PBS files to be checked for their last modified times
|
||||
data_files = GameData.get_all_data_filenames
|
||||
data_files += [ # Extra .dat files for data that isn't a GameData class
|
||||
"map_connections.dat",
|
||||
"map_metadata.dat",
|
||||
"metadata.dat",
|
||||
"moves.dat",
|
||||
"phone.dat",
|
||||
"player_metadata.dat",
|
||||
"regional_dexes.dat",
|
||||
"ribbons.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"
|
||||
"trainer_lists.dat"
|
||||
]
|
||||
text_files = get_all_pbs_files_to_compile
|
||||
latestDataTime = 0
|
||||
latestTextTime = 0
|
||||
mustCompile = false
|
||||
@@ -891,9 +878,8 @@ module Compiler
|
||||
write_all
|
||||
mustCompile = true
|
||||
end
|
||||
# Check data files and PBS files, and recompile if any PBS file was edited
|
||||
# more recently than the data files were last created
|
||||
dataFiles.each do |filename|
|
||||
# Check data files for their latest modify time
|
||||
data_files.each do |filename|
|
||||
if safeExists?("Data/" + filename)
|
||||
begin
|
||||
File.open("Data/#{filename}") { |file|
|
||||
@@ -907,24 +893,26 @@ module Compiler
|
||||
break
|
||||
end
|
||||
end
|
||||
textFiles.each do |filename|
|
||||
next if !safeExists?("PBS/" + filename)
|
||||
begin
|
||||
File.open("PBS/#{filename}") { |file|
|
||||
latestTextTime = [latestTextTime, file.mtime.to_i].max
|
||||
}
|
||||
rescue SystemCallError
|
||||
# Check PBS files for their latest modify time
|
||||
text_files.each do |key, value|
|
||||
next if !value || !value[1].is_a?(Array)
|
||||
value[1].each do |filepath|
|
||||
begin
|
||||
File.open(filepath) { |file| latestTextTime = [latestTextTime, file.mtime.to_i].max }
|
||||
rescue SystemCallError
|
||||
end
|
||||
end
|
||||
end
|
||||
# Decide to compile if a PBS file was edited more recently than any .dat files
|
||||
mustCompile |= (latestTextTime >= latestDataTime)
|
||||
# Should recompile if holding Ctrl
|
||||
Input.update
|
||||
mustCompile = true if Input.press?(Input::CTRL)
|
||||
# Delete old data files in preparation for recompiling
|
||||
if mustCompile
|
||||
dataFiles.length.times do |i|
|
||||
data_files.length.times do |i|
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -935,9 +923,9 @@ module Compiler
|
||||
e = $!
|
||||
raise e if e.class.to_s == "Reset" || e.is_a?(Reset) || e.is_a?(SystemExit)
|
||||
pbPrintException(e)
|
||||
dataFiles.length.times do |i|
|
||||
data_files.length.times do |i|
|
||||
begin
|
||||
File.delete("Data/#{dataFiles[i]}")
|
||||
File.delete("Data/#{data_files[i]}")
|
||||
rescue SystemCallError
|
||||
end
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,18 @@
|
||||
module Compiler
|
||||
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)
|
||||
file.write(0xEF.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")
|
||||
end
|
||||
|
||||
def write_PBS_file_generic(game_data, path)
|
||||
write_pbs_file_message_start(path)
|
||||
def write_PBS_file_generic(game_data)
|
||||
paths = get_all_PBS_file_paths(game_data)
|
||||
schema = game_data.schema
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
# Write each element in turn
|
||||
game_data.each do |element|
|
||||
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|
|
||||
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)
|
||||
# Write each element in turn
|
||||
game_data.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")
|
||||
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(sub_val, f, schema[key])
|
||||
pbWriteCsvRecord(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
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save Town Map data to PBS file
|
||||
#=============================================================================
|
||||
def write_town_map(path = "PBS/town_map.txt")
|
||||
write_PBS_file_generic(GameData::TownMap, path)
|
||||
def write_town_map
|
||||
write_PBS_file_generic(GameData::TownMap)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -114,36 +134,36 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Save type data to PBS file
|
||||
#=============================================================================
|
||||
def write_types(path = "PBS/types.txt")
|
||||
write_PBS_file_generic(GameData::Type, path)
|
||||
def write_types
|
||||
write_PBS_file_generic(GameData::Type)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save ability data to PBS file
|
||||
#=============================================================================
|
||||
def write_abilities(path = "PBS/abilities.txt")
|
||||
write_PBS_file_generic(GameData::Ability, path)
|
||||
def write_abilities
|
||||
write_PBS_file_generic(GameData::Ability)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save move data to PBS file
|
||||
#=============================================================================
|
||||
def write_moves(path = "PBS/moves.txt")
|
||||
write_PBS_file_generic(GameData::Move, path)
|
||||
def write_moves
|
||||
write_PBS_file_generic(GameData::Move)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save item data to PBS file
|
||||
#=============================================================================
|
||||
def write_items(path = "PBS/items.txt")
|
||||
write_PBS_file_generic(GameData::Item, path)
|
||||
def write_items
|
||||
write_PBS_file_generic(GameData::Item)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save berry plant data to PBS file
|
||||
#=============================================================================
|
||||
def write_berry_plants(path = "PBS/berry_plants.txt")
|
||||
write_PBS_file_generic(GameData::BerryPlant, path)
|
||||
def write_berry_plants
|
||||
write_PBS_file_generic(GameData::BerryPlant)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -151,40 +171,55 @@ module Compiler
|
||||
# NOTE: Doesn't use write_PBS_file_generic because it needs to ignore defined
|
||||
# species with a form that isn't 0.
|
||||
#=============================================================================
|
||||
def write_pokemon(path = "PBS/pokemon.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
def write_pokemon
|
||||
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
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
# Write each element in turn
|
||||
GameData::Species.each_species do |element|
|
||||
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|
|
||||
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)
|
||||
# Write each element in turn
|
||||
GameData::Species.each_species 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")
|
||||
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(sub_val, f, schema[key])
|
||||
pbWriteCsvRecord(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
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -192,41 +227,59 @@ module Compiler
|
||||
# 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.
|
||||
#=============================================================================
|
||||
def write_pokemon_forms(path = "PBS/pokemon_forms.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
def write_pokemon_forms
|
||||
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)
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
# Write each element in turn
|
||||
GameData::Species.each do |element|
|
||||
next if element.form == 0
|
||||
f.write("\#-------------------------------\r\n")
|
||||
if schema["SectionName"]
|
||||
f.write("[")
|
||||
pbWriteCsvRecord(element.get_property_for_PBS("SectionName", true), 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, true)
|
||||
next if val.nil?
|
||||
if schema[key][1][0] == "^" && val.is_a?(Array)
|
||||
val.each do |sub_val|
|
||||
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)
|
||||
# Write each element in turn
|
||||
GameData::Species.each do |element|
|
||||
next if element.form == 0
|
||||
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")
|
||||
if schema["SectionName"]
|
||||
f.write("[")
|
||||
pbWriteCsvRecord(element.get_property_for_PBS("SectionName", true), 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, 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))
|
||||
pbWriteCsvRecord(sub_val, f, schema[key])
|
||||
pbWriteCsvRecord(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
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -235,55 +288,73 @@ module Compiler
|
||||
# metrics for forms of species where the metrics are the same as for the
|
||||
# base species.
|
||||
#=============================================================================
|
||||
def write_pokemon_metrics(path = "PBS/pokemon_metrics.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
def write_pokemon_metrics
|
||||
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
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
# Write each element in turn
|
||||
GameData::SpeciesMetrics.each do |element|
|
||||
if element.form > 0
|
||||
base_element = GameData::SpeciesMetrics.get(element.species)
|
||||
next if element.back_sprite == base_element.back_sprite &&
|
||||
element.front_sprite == base_element.front_sprite &&
|
||||
element.front_sprite_altitude == base_element.front_sprite_altitude &&
|
||||
element.shadow_x == base_element.shadow_x &&
|
||||
element.shadow_size == base_element.shadow_size
|
||||
end
|
||||
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|
|
||||
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)
|
||||
# Write each element in turn
|
||||
GameData::SpeciesMetrics.each do |element|
|
||||
next if element.pbs_file_suffix != path[1]
|
||||
if element.form > 0
|
||||
base_element = GameData::SpeciesMetrics.get(element.species)
|
||||
next if element.back_sprite == base_element.back_sprite &&
|
||||
element.front_sprite == base_element.front_sprite &&
|
||||
element.front_sprite_altitude == base_element.front_sprite_altitude &&
|
||||
element.shadow_x == base_element.shadow_x &&
|
||||
element.shadow_size == base_element.shadow_size
|
||||
end
|
||||
echo "." if idx % 50 == 0
|
||||
Graphics.update if idx % 250 == 0
|
||||
idx += 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(sub_val, f, schema[key])
|
||||
pbWriteCsvRecord(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
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save Shadow Pokémon data to PBS file
|
||||
#=============================================================================
|
||||
def write_shadow_pokemon(path = "PBS/shadow_pokemon.txt")
|
||||
write_PBS_file_generic(GameData::ShadowPokemon, path)
|
||||
def write_shadow_pokemon
|
||||
write_PBS_file_generic(GameData::ShadowPokemon)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -321,107 +392,115 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Save ability data to PBS file
|
||||
#=============================================================================
|
||||
def write_ribbons(path = "PBS/ribbons.txt")
|
||||
write_PBS_file_generic(GameData::Ribbon, path)
|
||||
def write_ribbons
|
||||
write_PBS_file_generic(GameData::Ribbon)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save wild encounter data to PBS file
|
||||
#=============================================================================
|
||||
def write_encounters(path = "PBS/encounters.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
def write_encounters
|
||||
paths = get_all_PBS_file_paths(GameData::Encounter)
|
||||
map_infos = pbLoadMapInfos
|
||||
File.open(path, "wb") { |f|
|
||||
idx = 0
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::Encounter.each do |encounter_data|
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
f.write("\#-------------------------------\r\n")
|
||||
map_name = (map_infos[encounter_data.map]) ? " # #{map_infos[encounter_data.map].name}" : ""
|
||||
if encounter_data.version > 0
|
||||
f.write(sprintf("[%03d,%d]%s\r\n", encounter_data.map, encounter_data.version, map_name))
|
||||
else
|
||||
f.write(sprintf("[%03d]%s\r\n", encounter_data.map, map_name))
|
||||
end
|
||||
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]))
|
||||
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::Encounter.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[element.map]) ? " # #{map_infos[element.map].name}" : ""
|
||||
if element.version > 0
|
||||
f.write(sprintf("[%03d,%d]%s\r\n", element.map, element.version, map_name))
|
||||
else
|
||||
f.write(sprintf("%s\r\n", type.to_s))
|
||||
f.write(sprintf("[%03d]%s\r\n", element.map, map_name))
|
||||
end
|
||||
slots.each do |slot|
|
||||
if slot[2] == slot[3]
|
||||
f.write(sprintf(" %d,%s,%d\r\n", slot[0], slot[1], slot[2]))
|
||||
element.types.each do |type, slots|
|
||||
next if !slots || slots.length == 0
|
||||
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
|
||||
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
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save trainer type data to PBS file
|
||||
#=============================================================================
|
||||
def write_trainer_types(path = "PBS/trainer_types.txt")
|
||||
write_PBS_file_generic(GameData::TrainerType, path)
|
||||
def write_trainer_types
|
||||
write_PBS_file_generic(GameData::TrainerType)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save individual trainer data to PBS file
|
||||
#=============================================================================
|
||||
def write_trainers(path = "PBS/trainers.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
File.open(path, "wb") { |f|
|
||||
idx = 0
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::Trainer.each do |trainer|
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
f.write("\#-------------------------------\r\n")
|
||||
if trainer.version > 0
|
||||
f.write(sprintf("[%s,%s,%d]\r\n", trainer.trainer_type, trainer.real_name, trainer.version))
|
||||
else
|
||||
f.write(sprintf("[%s,%s]\r\n", trainer.trainer_type, trainer.real_name))
|
||||
end
|
||||
f.write(sprintf("Items = %s\r\n", trainer.items.join(","))) if trainer.items.length > 0
|
||||
if trainer.real_lose_text && !trainer.real_lose_text.empty?
|
||||
f.write(sprintf("LoseText = %s\r\n", trainer.real_lose_text))
|
||||
end
|
||||
trainer.pokemon.each do |pkmn|
|
||||
f.write(sprintf("Pokemon = %s,%d\r\n", pkmn[:species], pkmn[:level]))
|
||||
f.write(sprintf(" Name = %s\r\n", pkmn[:name])) if pkmn[:name] && !pkmn[:name].empty?
|
||||
f.write(sprintf(" Form = %d\r\n", pkmn[:form])) if pkmn[:form] && pkmn[:form] > 0
|
||||
f.write(sprintf(" Gender = %s\r\n", (pkmn[:gender] == 1) ? "female" : "male")) if pkmn[:gender]
|
||||
f.write(" Shiny = yes\r\n") if pkmn[:shininess] && !pkmn[:super_shininess]
|
||||
f.write(" SuperShiny = yes\r\n") if pkmn[:super_shininess]
|
||||
f.write(" Shadow = yes\r\n") if pkmn[:shadowness]
|
||||
f.write(sprintf(" Moves = %s\r\n", pkmn[:moves].join(","))) if pkmn[:moves] && pkmn[:moves].length > 0
|
||||
f.write(sprintf(" Ability = %s\r\n", pkmn[:ability])) if pkmn[:ability]
|
||||
f.write(sprintf(" AbilityIndex = %d\r\n", pkmn[:ability_index])) if pkmn[:ability_index]
|
||||
f.write(sprintf(" Item = %s\r\n", pkmn[:item])) if pkmn[:item]
|
||||
f.write(sprintf(" Nature = %s\r\n", pkmn[:nature])) if pkmn[:nature]
|
||||
ivs_array = []
|
||||
evs_array = []
|
||||
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]
|
||||
def write_trainers
|
||||
paths = get_all_PBS_file_paths(GameData::Trainer)
|
||||
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::Trainer.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")
|
||||
if element.version > 0
|
||||
f.write(sprintf("[%s,%s,%d]\r\n", element.trainer_type, element.real_name, element.version))
|
||||
else
|
||||
f.write(sprintf("[%s,%s]\r\n", element.trainer_type, element.real_name))
|
||||
end
|
||||
f.write(sprintf("Items = %s\r\n", element.items.join(","))) if element.items.length > 0
|
||||
if element.real_lose_text && !element.real_lose_text.empty?
|
||||
f.write(sprintf("LoseText = %s\r\n", element.real_lose_text))
|
||||
end
|
||||
element.pokemon.each do |pkmn|
|
||||
f.write(sprintf("Pokemon = %s,%d\r\n", pkmn[:species], pkmn[:level]))
|
||||
f.write(sprintf(" Name = %s\r\n", pkmn[:name])) if pkmn[:name] && !pkmn[:name].empty?
|
||||
f.write(sprintf(" Form = %d\r\n", pkmn[:form])) if pkmn[:form] && pkmn[:form] > 0
|
||||
f.write(sprintf(" Gender = %s\r\n", (pkmn[:gender] == 1) ? "female" : "male")) if pkmn[:gender]
|
||||
f.write(" Shiny = yes\r\n") if pkmn[:shininess] && !pkmn[:super_shininess]
|
||||
f.write(" SuperShiny = yes\r\n") if pkmn[:super_shininess]
|
||||
f.write(" Shadow = yes\r\n") if pkmn[:shadowness]
|
||||
f.write(sprintf(" Moves = %s\r\n", pkmn[:moves].join(","))) if pkmn[:moves] && pkmn[:moves].length > 0
|
||||
f.write(sprintf(" Ability = %s\r\n", pkmn[:ability])) if pkmn[:ability]
|
||||
f.write(sprintf(" AbilityIndex = %d\r\n", pkmn[:ability_index])) if pkmn[:ability_index]
|
||||
f.write(sprintf(" Item = %s\r\n", pkmn[:item])) if pkmn[:item]
|
||||
f.write(sprintf(" Nature = %s\r\n", pkmn[:nature])) if pkmn[:nature]
|
||||
ivs_array = []
|
||||
evs_array = []
|
||||
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
|
||||
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
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -542,22 +621,132 @@ module Compiler
|
||||
# NOTE: Doesn't use write_PBS_file_generic because it contains data for two
|
||||
# different GameData classes.
|
||||
#=============================================================================
|
||||
def write_metadata(path = "PBS/metadata.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
def write_metadata
|
||||
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
|
||||
player_schema = GameData::PlayerMetadata.schema
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
# Write each element in turn
|
||||
[GameData::Metadata, GameData::PlayerMetadata].each do |game_data|
|
||||
schema = global_schema if game_data == GameData::Metadata
|
||||
schema = player_schema if game_data == GameData::PlayerMetadata
|
||||
game_data.each do |element|
|
||||
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::Metadata, GameData::PlayerMetadata].each do |game_data|
|
||||
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")
|
||||
if schema["SectionName"]
|
||||
f.write("[")
|
||||
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
|
||||
f.write("[#{element.id}]\r\n")
|
||||
end
|
||||
@@ -578,109 +767,23 @@ module Compiler
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_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
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save dungeon parameters to PBS file
|
||||
#=============================================================================
|
||||
def write_dungeon_parameters(path = "PBS/dungeon_parameters.txt")
|
||||
write_PBS_file_generic(GameData::DungeonParameters, path)
|
||||
def write_dungeon_parameters
|
||||
write_PBS_file_generic(GameData::DungeonParameters)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save phone messages to PBS file
|
||||
#=============================================================================
|
||||
def write_phone(path = "PBS/phone.txt")
|
||||
write_PBS_file_generic(GameData::PhoneMessage, path)
|
||||
def write_phone
|
||||
write_PBS_file_generic(GameData::PhoneMessage)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
Reference in New Issue
Block a user