mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-01-22 14:26:01 +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
|
||||
|
||||
Reference in New Issue
Block a user