Tidied and coloured console messages

This commit is contained in:
Maruno17
2021-10-23 21:55:42 +01:00
parent 10a1fc4430
commit e417e4c659
7 changed files with 210 additions and 50 deletions

View File

@@ -44,6 +44,27 @@ module Kernel
echo string echo string
echo "\r\n" echo "\r\n"
end end
def echoln_good(string)
echo "\e[32m" # Green text
echo string
echo "\e[0m" # Back to default text color
echo "\r\n"
end
def echoln_bad(string)
echo "\e[31m" # Red text
echo string
echo "\e[0m" # Back to default text color
echo "\r\n"
end
def echoln_warn(string)
echo "\e[33m" # Brown/yellow text
echo string
echo "\e[0m" # Back to default text color
echo "\r\n"
end
end end
Console.setup_console Console.setup_console

View File

@@ -676,7 +676,7 @@ module PluginManager
File.open("Data/PluginScripts.rxdata", 'wb') { |f| Marshal.dump(scripts, f) } File.open("Data/PluginScripts.rxdata", 'wb') { |f| Marshal.dump(scripts, f) }
# collect garbage # collect garbage
GC.start GC.start
echoln " done." echoln_good "done"
echoln "" echoln ""
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@@ -199,7 +199,7 @@ module SaveData
conversions_to_run.each do |conversion| conversions_to_run.each do |conversion|
echo "#{conversion.title}..." echo "#{conversion.title}..."
conversion.run(save_data) conversion.run(save_data)
echoln " done." echoln_good "done"
end end
echoln "" if conversions_to_run.length > 0 echoln "" if conversions_to_run.length > 0
save_data[:essentials_version] = Essentials::VERSION save_data[:essentials_version] = Essentials::VERSION

View File

@@ -702,59 +702,41 @@ module Compiler
def compile_all(mustCompile) def compile_all(mustCompile)
return if !mustCompile return if !mustCompile
FileLineData.clear FileLineData.clear
echoln _INTL("*** Starting full compile ***") echoln_warn _INTL("*** Starting full compile ***")
echoln "" echoln ""
yield(_INTL("Compiling town map data"))
compile_town_map # No dependencies compile_town_map # No dependencies
yield(_INTL("Compiling map connection data"))
compile_connections # No dependencies compile_connections # No dependencies
yield(_INTL("Compiling phone data"))
compile_phone # No dependencies compile_phone # No dependencies
yield(_INTL("Compiling type data"))
compile_types # No dependencies compile_types # No dependencies
yield(_INTL("Compiling ability data"))
compile_abilities # No dependencies compile_abilities # No dependencies
yield(_INTL("Compiling move data"))
compile_moves # Depends on Type compile_moves # Depends on Type
yield(_INTL("Compiling item data"))
compile_items # Depends on Move compile_items # Depends on Move
yield(_INTL("Compiling berry plant data"))
compile_berry_plants # Depends on Item compile_berry_plants # Depends on Item
yield(_INTL("Compiling Pokémon data"))
compile_pokemon # Depends on Move, Item, Type, Ability compile_pokemon # Depends on Move, Item, Type, Ability
yield(_INTL("Compiling Pokémon forms data"))
compile_pokemon_forms # Depends on Species, Move, Item, Type, Ability compile_pokemon_forms # Depends on Species, Move, Item, Type, Ability
yield(_INTL("Compiling Pokémon metrics data"))
compile_pokemon_metrics # Depends on Species compile_pokemon_metrics # Depends on Species
yield(_INTL("Compiling shadow moveset data"))
compile_shadow_movesets # Depends on Species, Move compile_shadow_movesets # Depends on Species, Move
yield(_INTL("Compiling Regional Dexes"))
compile_regional_dexes # Depends on Species compile_regional_dexes # Depends on Species
yield(_INTL("Compiling ribbon data"))
compile_ribbons # No dependencies compile_ribbons # No dependencies
yield(_INTL("Compiling encounter data"))
compile_encounters # Depends on Species compile_encounters # Depends on Species
yield(_INTL("Compiling Trainer type data"))
compile_trainer_types # No dependencies compile_trainer_types # No dependencies
yield(_INTL("Compiling Trainer data"))
compile_trainers # Depends on Species, Item, Move compile_trainers # Depends on Species, Item, Move
yield(_INTL("Compiling battle Trainer data"))
compile_trainer_lists # Depends on TrainerType compile_trainer_lists # Depends on TrainerType
yield(_INTL("Compiling metadata"))
compile_metadata # Depends on TrainerType compile_metadata # Depends on TrainerType
yield(_INTL("Compiling map metadata"))
compile_map_metadata # No dependencies compile_map_metadata # No dependencies
yield(_INTL("Compiling animations"))
compile_animations compile_animations
yield("") echoln ""
compile_trainer_events(mustCompile) compile_trainer_events(mustCompile)
yield(_INTL("Saving messages")) echo _INTL("Saving messages...")
pbSetTextMessages pbSetTextMessages
MessageTypes.saveMessages MessageTypes.saveMessages
MessageTypes.loadMessageFile("Data/messages.dat") if safeExists?("Data/messages.dat") MessageTypes.loadMessageFile("Data/messages.dat") if safeExists?("Data/messages.dat")
echoln_good _INTL("done")
echo _INTL("Reloading cache...")
System.reload_cache System.reload_cache
echoln_good _INTL("done")
echoln "" echoln ""
echoln _INTL("*** Finished full compile ***") echoln_warn _INTL("*** Finished full compile ***")
echoln "" echoln ""
end end
@@ -851,7 +833,7 @@ module Compiler
end end
end end
# Recompile all data # Recompile all data
compile_all(mustCompile) { |msg| echoln msg } compile_all(mustCompile)
rescue Exception rescue Exception
e = $! e = $!
raise e if "#{e.class}"=="Reset" || e.is_a?(Reset) || e.is_a?(SystemExit) raise e if "#{e.class}"=="Reset" || e.is_a?(Reset) || e.is_a?(SystemExit)

View File

@@ -5,6 +5,7 @@ module Compiler
# Compile Town Map data # Compile Town Map data
#============================================================================= #=============================================================================
def compile_town_map(path = "PBS/town_map.txt") def compile_town_map(path = "PBS/town_map.txt")
echo _INTL("Compiling Town Map data...")
nonglobaltypes = { nonglobaltypes = {
"Name" => [0, "s"], "Name" => [0, "s"],
"Filename" => [1, "s"], "Filename" => [1, "s"],
@@ -47,12 +48,15 @@ module Compiler
MessageTypes.setMessages(MessageTypes::RegionNames,rgnnames) MessageTypes.setMessages(MessageTypes::RegionNames,rgnnames)
MessageTypes.setMessagesAsHash(MessageTypes::PlaceNames,placenames) MessageTypes.setMessagesAsHash(MessageTypes::PlaceNames,placenames)
MessageTypes.setMessagesAsHash(MessageTypes::PlaceDescriptions,placedescs) MessageTypes.setMessagesAsHash(MessageTypes::PlaceDescriptions,placedescs)
echoln_good _INTL("done")
Graphics.update
end end
#============================================================================= #=============================================================================
# Compile map connections # Compile map connections
#============================================================================= #=============================================================================
def compile_connections(path = "PBS/map_connections.txt") def compile_connections(path = "PBS/map_connections.txt")
echo _INTL("Compiling map connections...")
records = [] records = []
pbCompilerEachPreppedLine(path) { |line,lineno| pbCompilerEachPreppedLine(path) { |line,lineno|
hashenum = { hashenum = {
@@ -88,6 +92,7 @@ module Compiler
records.push(record) records.push(record)
} }
save_data(records,"Data/map_connections.dat") save_data(records,"Data/map_connections.dat")
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -96,6 +101,7 @@ module Compiler
#============================================================================= #=============================================================================
def compile_phone(path = "PBS/phone.txt") def compile_phone(path = "PBS/phone.txt")
return if !safeExists?(path) return if !safeExists?(path)
echo _INTL("Compiling phone messages...")
database = PhoneDatabase.new database = PhoneDatabase.new
sections = [] sections = []
File.open(path, "rb") { |f| File.open(path, "rb") { |f|
@@ -127,12 +133,15 @@ module Compiler
} }
MessageTypes.setMessagesAsHash(MessageTypes::PhoneMessages,sections) MessageTypes.setMessagesAsHash(MessageTypes::PhoneMessages,sections)
save_data(database,"Data/phone.dat") save_data(database,"Data/phone.dat")
echoln_good _INTL("done")
Graphics.update
end end
#============================================================================= #=============================================================================
# Compile type data # Compile type data
#============================================================================= #=============================================================================
def compile_types(path = "PBS/types.txt") def compile_types(path = "PBS/types.txt")
echo _INTL("Compiling types...")
GameData::Type::DATA.clear GameData::Type::DATA.clear
type_names = [] type_names = []
# Read from PBS file # Read from PBS file
@@ -201,6 +210,7 @@ module Compiler
# Save all data # Save all data
GameData::Type.save GameData::Type.save
MessageTypes.setMessagesAsHash(MessageTypes::Types, type_names) MessageTypes.setMessagesAsHash(MessageTypes::Types, type_names)
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -208,6 +218,7 @@ module Compiler
# Compile ability data # Compile ability data
#============================================================================= #=============================================================================
def compile_abilities(path = "PBS/abilities.txt") def compile_abilities(path = "PBS/abilities.txt")
echo _INTL("Compiling abilities...")
GameData::Ability::DATA.clear GameData::Ability::DATA.clear
schema = GameData::Ability::SCHEMA schema = GameData::Ability::SCHEMA
ability_names = [] ability_names = []
@@ -271,6 +282,7 @@ module Compiler
GameData::Ability.save GameData::Ability.save
MessageTypes.setMessagesAsHash(MessageTypes::Abilities, ability_names) MessageTypes.setMessagesAsHash(MessageTypes::Abilities, ability_names)
MessageTypes.setMessagesAsHash(MessageTypes::AbilityDescs, ability_descriptions) MessageTypes.setMessagesAsHash(MessageTypes::AbilityDescs, ability_descriptions)
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -278,13 +290,17 @@ module Compiler
# Compile move data # Compile move data
#============================================================================= #=============================================================================
def compile_moves(path = "PBS/moves.txt") def compile_moves(path = "PBS/moves.txt")
echo _INTL("Compiling moves...")
GameData::Move::DATA.clear GameData::Move::DATA.clear
schema = GameData::Move::SCHEMA schema = GameData::Move::SCHEMA
move_names = [] move_names = []
move_descriptions = [] move_descriptions = []
move_hash = nil move_hash = nil
# Read each line of moves.txt at a time and compile it into an move # Read each line of moves.txt at a time and compile it into an move
idx = 0
pbCompilerEachPreppedLine(path) { |line, line_no| pbCompilerEachPreppedLine(path) { |line, line_no|
echo "." if idx % 500 == 0
idx += 1
if line[/^\s*\[\s*(.+)\s*\]\s*$/] # New section [move_id] if line[/^\s*\[\s*(.+)\s*\]\s*$/] # New section [move_id]
# Add previous move's data to records # Add previous move's data to records
if move_hash if move_hash
@@ -402,6 +418,7 @@ module Compiler
GameData::Move.save GameData::Move.save
MessageTypes.setMessagesAsHash(MessageTypes::Moves, move_names) MessageTypes.setMessagesAsHash(MessageTypes::Moves, move_names)
MessageTypes.setMessagesAsHash(MessageTypes::MoveDescriptions, move_descriptions) MessageTypes.setMessagesAsHash(MessageTypes::MoveDescriptions, move_descriptions)
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -409,6 +426,7 @@ module Compiler
# Compile item data # Compile item data
#============================================================================= #=============================================================================
def compile_items(path = "PBS/items.txt") def compile_items(path = "PBS/items.txt")
echo _INTL("Compiling items...")
GameData::Item::DATA.clear GameData::Item::DATA.clear
schema = GameData::Item::SCHEMA schema = GameData::Item::SCHEMA
item_names = [] item_names = []
@@ -416,7 +434,10 @@ module Compiler
item_descriptions = [] item_descriptions = []
item_hash = nil item_hash = nil
# Read each line of items.txt at a time and compile it into an item # Read each line of items.txt at a time and compile it into an item
idx = 0
pbCompilerEachPreppedLine(path) { |line, line_no| pbCompilerEachPreppedLine(path) { |line, line_no|
echo "." if idx % 250 == 0
idx += 1
if line[/^\s*\[\s*(.+)\s*\]\s*$/] # New section [item_id] if line[/^\s*\[\s*(.+)\s*\]\s*$/] # New section [item_id]
# Add previous item's data to records # Add previous item's data to records
GameData::Item.register(item_hash) if item_hash GameData::Item.register(item_hash) if item_hash
@@ -492,6 +513,7 @@ module Compiler
MessageTypes.setMessagesAsHash(MessageTypes::Items, item_names) MessageTypes.setMessagesAsHash(MessageTypes::Items, item_names)
MessageTypes.setMessagesAsHash(MessageTypes::ItemPlurals, item_names_plural) MessageTypes.setMessagesAsHash(MessageTypes::ItemPlurals, item_names_plural)
MessageTypes.setMessagesAsHash(MessageTypes::ItemDescriptions, item_descriptions) MessageTypes.setMessagesAsHash(MessageTypes::ItemDescriptions, item_descriptions)
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -499,6 +521,7 @@ module Compiler
# Compile berry plant data # Compile berry plant data
#============================================================================= #=============================================================================
def compile_berry_plants(path = "PBS/berry_plants.txt") def compile_berry_plants(path = "PBS/berry_plants.txt")
echo _INTL("Compiling berry plants...")
GameData::BerryPlant::DATA.clear GameData::BerryPlant::DATA.clear
pbCompilerEachCommentedLine(path) { |line, line_no| pbCompilerEachCommentedLine(path) { |line, line_no|
if line[/^\s*(\w+)\s*=\s*(.*)$/] # Of the format XXX = YYY if line[/^\s*(\w+)\s*=\s*(.*)$/] # Of the format XXX = YYY
@@ -520,6 +543,7 @@ module Compiler
} }
# Save all data # Save all data
GameData::BerryPlant.save GameData::BerryPlant.save
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -527,6 +551,7 @@ module Compiler
# Compile Pokémon data # Compile Pokémon data
#============================================================================= #=============================================================================
def compile_pokemon(path = "PBS/pokemon.txt") def compile_pokemon(path = "PBS/pokemon.txt")
echo _INTL("Compiling Pokémon...")
GameData::Species::DATA.clear GameData::Species::DATA.clear
species_names = [] species_names = []
species_form_names = [] species_form_names = []
@@ -539,7 +564,11 @@ module Compiler
# contents is a hash containing all the XXX=YYY lines in that section, where # contents is a hash containing all the XXX=YYY lines in that section, where
# the keys are the XXX and the values are the YYY (as unprocessed strings). # the keys are the XXX and the values are the YYY (as unprocessed strings).
schema = GameData::Species.schema schema = GameData::Species.schema
idx = 0
pbEachFileSection(f) { |contents, species_id| pbEachFileSection(f) { |contents, species_id|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
FileLineData.setSection(species_id, "header", nil) # For error reporting FileLineData.setSection(species_id, "header", nil) # For error reporting
contents["InternalName"] = species_id if !species_id[/^\d+/] contents["InternalName"] = species_id if !species_id[/^\d+/]
# Ensure all required properties have been defined, and raise an error # Ensure all required properties have been defined, and raise an error
@@ -641,7 +670,7 @@ module Compiler
end end
} }
} }
# Enumerate all evolution species and parameters (this couldn't be done earlier) # Enumerate all evolution species and parameters (this couldn't bedone earlier)
GameData::Species.each do |species| GameData::Species.each do |species|
FileLineData.setSection(species.id.to_s, "Evolutions", nil) # For error reporting FileLineData.setSection(species.id.to_s, "Evolutions", nil) # For error reporting
species.evolutions.each do |evo| species.evolutions.each do |evo|
@@ -673,6 +702,7 @@ module Compiler
MessageTypes.setMessagesAsHash(MessageTypes::FormNames, species_form_names) MessageTypes.setMessagesAsHash(MessageTypes::FormNames, species_form_names)
MessageTypes.setMessagesAsHash(MessageTypes::Kinds, species_categories) MessageTypes.setMessagesAsHash(MessageTypes::Kinds, species_categories)
MessageTypes.setMessagesAsHash(MessageTypes::Entries, species_pokedex_entries) MessageTypes.setMessagesAsHash(MessageTypes::Entries, species_pokedex_entries)
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -680,6 +710,7 @@ module Compiler
# Compile Pokémon forms data # Compile Pokémon forms data
#============================================================================= #=============================================================================
def compile_pokemon_forms(path = "PBS/pokemon_forms.txt") def compile_pokemon_forms(path = "PBS/pokemon_forms.txt")
echo _INTL("Compiling Pokémon forms...")
species_names = [] species_names = []
species_form_names = [] species_form_names = []
species_categories = [] species_categories = []
@@ -692,7 +723,11 @@ module Compiler
# contents is a hash containing all the XXX=YYY lines in that section, where # contents is a hash containing all the XXX=YYY lines in that section, where
# the keys are the XXX and the values are the YYY (as unprocessed strings). # the keys are the XXX and the values are the YYY (as unprocessed strings).
schema = GameData::Species.schema(true) schema = GameData::Species.schema(true)
idx = 0
pbEachFileSectionPokemonForms(f) { |contents, section_name| pbEachFileSectionPokemonForms(f) { |contents, section_name|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
FileLineData.setSection(section_name, "header", nil) # For error reporting FileLineData.setSection(section_name, "header", nil) # For error reporting
# Split section_name into a species number and form number # Split section_name into a species number and form number
split_section_name = section_name.split(/[-,\s]/) split_section_name = section_name.split(/[-,\s]/)
@@ -869,6 +904,7 @@ module Compiler
MessageTypes.addMessagesAsHash(MessageTypes::FormNames, species_form_names) MessageTypes.addMessagesAsHash(MessageTypes::FormNames, species_form_names)
MessageTypes.addMessagesAsHash(MessageTypes::Kinds, species_categories) MessageTypes.addMessagesAsHash(MessageTypes::Kinds, species_categories)
MessageTypes.addMessagesAsHash(MessageTypes::Entries, species_pokedex_entries) MessageTypes.addMessagesAsHash(MessageTypes::Entries, species_pokedex_entries)
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -877,6 +913,7 @@ module Compiler
#============================================================================= #=============================================================================
def compile_pokemon_metrics(path = "PBS/pokemon_metrics.txt") def compile_pokemon_metrics(path = "PBS/pokemon_metrics.txt")
return if !safeExists?(path) return if !safeExists?(path)
echo _INTL("Compiling Pokémon metrics...")
schema = GameData::SpeciesMetrics::SCHEMA schema = GameData::SpeciesMetrics::SCHEMA
# Read from PBS file # Read from PBS file
File.open(path, "rb") { |f| File.open(path, "rb") { |f|
@@ -884,7 +921,11 @@ module Compiler
# Read a whole section's lines at once, then run through this code. # Read a whole section's lines at once, then run through this code.
# contents is a hash containing all the XXX=YYY lines in that section, where # contents is a hash containing all the XXX=YYY lines in that section, where
# the keys are the XXX and the values are the YYY (as unprocessed strings). # the keys are the XXX and the values are the YYY (as unprocessed strings).
idx = 0
pbEachFileSection(f) { |contents, section_name| pbEachFileSection(f) { |contents, section_name|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
FileLineData.setSection(section_name, "header", nil) # For error reporting FileLineData.setSection(section_name, "header", nil) # For error reporting
# Split section_name into a species number and form number # Split section_name into a species number and form number
split_section_name = section_name.split(/[-,\s]/) split_section_name = section_name.split(/[-,\s]/)
@@ -924,6 +965,7 @@ module Compiler
} }
# Save all data # Save all data
GameData::SpeciesMetrics.save GameData::SpeciesMetrics.save
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -931,10 +973,15 @@ module Compiler
# Compile Shadow movesets # Compile Shadow movesets
#============================================================================= #=============================================================================
def compile_shadow_movesets(path = "PBS/shadow_movesets.txt") def compile_shadow_movesets(path = "PBS/shadow_movesets.txt")
echo _INTL("Compiling Shadow Pokémon movesets...")
sections = {} sections = {}
if safeExists?(path) if safeExists?(path)
idx = 0
pbCompilerEachCommentedLine(path) { |line, _line_no| pbCompilerEachCommentedLine(path) { |line, _line_no|
if line[/^\s*(\w+)\s*=\s*(.*)$/] if line[/^\s*(\w+)\s*=\s*(.*)$/]
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
key = $1 key = $1
value = $2 value = $2
value = value.split(",") value = value.split(",")
@@ -950,12 +997,15 @@ module Compiler
} }
end end
save_data(sections, "Data/shadow_movesets.dat") save_data(sections, "Data/shadow_movesets.dat")
echoln_good _INTL("done")
Graphics.update
end end
#============================================================================= #=============================================================================
# Compile Regional Dexes # Compile Regional Dexes
#============================================================================= #=============================================================================
def compile_regional_dexes(path = "PBS/regional_dexes.txt") def compile_regional_dexes(path = "PBS/regional_dexes.txt")
echo _INTL("Compiling Pokédex lists...")
dex_lists = [] dex_lists = []
section = nil section = nil
pbCompilerEachPreppedLine(path) { |line, line_no| pbCompilerEachPreppedLine(path) { |line, line_no|
@@ -987,6 +1037,7 @@ module Compiler
end end
# Save all data # Save all data
save_data(dex_lists, "Data/regional_dexes.dat") save_data(dex_lists, "Data/regional_dexes.dat")
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -994,6 +1045,7 @@ module Compiler
# Compile ribbon data # Compile ribbon data
#============================================================================= #=============================================================================
def compile_ribbons(path = "PBS/ribbons.txt") def compile_ribbons(path = "PBS/ribbons.txt")
echo _INTL("Compiling ribbons...")
GameData::Ribbon::DATA.clear GameData::Ribbon::DATA.clear
schema = GameData::Ribbon::SCHEMA schema = GameData::Ribbon::SCHEMA
ribbon_names = [] ribbon_names = []
@@ -1058,6 +1110,7 @@ module Compiler
GameData::Ribbon.save GameData::Ribbon.save
MessageTypes.setMessagesAsHash(MessageTypes::RibbonNames, ribbon_names) MessageTypes.setMessagesAsHash(MessageTypes::RibbonNames, ribbon_names)
MessageTypes.setMessagesAsHash(MessageTypes::RibbonDescriptions, ribbon_descriptions) MessageTypes.setMessagesAsHash(MessageTypes::RibbonDescriptions, ribbon_descriptions)
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -1065,12 +1118,17 @@ module Compiler
# Compile wild encounter data # Compile wild encounter data
#============================================================================= #=============================================================================
def compile_encounters(path = "PBS/encounters.txt") def compile_encounters(path = "PBS/encounters.txt")
echo _INTL("Compiling encounters...")
GameData::Encounter::DATA.clear GameData::Encounter::DATA.clear
encounter_hash = nil encounter_hash = nil
step_chances = nil step_chances = nil
current_type = nil current_type = nil
max_level = GameData::GrowthRate.max_level max_level = GameData::GrowthRate.max_level
idx = 0
pbCompilerEachPreppedLine(path) { |line, line_no| pbCompilerEachPreppedLine(path) { |line, line_no|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
next if line.length == 0 next if line.length == 0
if current_type && line[/^\d+,/] # Species line if current_type && line[/^\d+,/] # Species line
values = line.split(',').collect! { |v| v.strip } values = line.split(',').collect! { |v| v.strip }
@@ -1162,6 +1220,7 @@ module Compiler
end end
# Save all data # Save all data
GameData::Encounter.save GameData::Encounter.save
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -1169,6 +1228,7 @@ module Compiler
# Compile trainer type data # Compile trainer type data
#============================================================================= #=============================================================================
def compile_trainer_types(path = "PBS/trainer_types.txt") def compile_trainer_types(path = "PBS/trainer_types.txt")
echo _INTL("Compiling trainer types...")
GameData::TrainerType::DATA.clear GameData::TrainerType::DATA.clear
schema = GameData::TrainerType::SCHEMA schema = GameData::TrainerType::SCHEMA
tr_type_names = [] tr_type_names = []
@@ -1236,6 +1296,7 @@ module Compiler
# Save all data # Save all data
GameData::TrainerType.save GameData::TrainerType.save
MessageTypes.setMessagesAsHash(MessageTypes::TrainerTypes, tr_type_names) MessageTypes.setMessagesAsHash(MessageTypes::TrainerTypes, tr_type_names)
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -1243,6 +1304,7 @@ module Compiler
# Compile individual trainer data # Compile individual trainer data
#============================================================================= #=============================================================================
def compile_trainers(path = "PBS/trainers.txt") def compile_trainers(path = "PBS/trainers.txt")
echo _INTL("Compiling trainers...")
GameData::Trainer::DATA.clear GameData::Trainer::DATA.clear
schema = GameData::Trainer::SCHEMA schema = GameData::Trainer::SCHEMA
max_level = GameData::GrowthRate.max_level max_level = GameData::GrowthRate.max_level
@@ -1251,7 +1313,11 @@ module Compiler
trainer_hash = nil trainer_hash = nil
current_pkmn = nil current_pkmn = nil
# Read each line of trainers.txt at a time and compile it as a trainer property # Read each line of trainers.txt at a time and compile it as a trainer property
idx = 0
pbCompilerEachPreppedLine(path) { |line, line_no| pbCompilerEachPreppedLine(path) { |line, line_no|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
if line[/^\s*\[\s*(.+)\s*\]\s*$/] if line[/^\s*\[\s*(.+)\s*\]\s*$/]
# New section [trainer_type, name] or [trainer_type, name, version] # New section [trainer_type, name] or [trainer_type, name, version]
if trainer_hash if trainer_hash
@@ -1361,6 +1427,7 @@ module Compiler
GameData::Trainer.save GameData::Trainer.save
MessageTypes.setMessagesAsHash(MessageTypes::TrainerNames, trainer_names) MessageTypes.setMessagesAsHash(MessageTypes::TrainerNames, trainer_names)
MessageTypes.setMessagesAsHash(MessageTypes::TrainerLoseText, trainer_lose_texts) MessageTypes.setMessagesAsHash(MessageTypes::TrainerLoseText, trainer_lose_texts)
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -1368,6 +1435,7 @@ module Compiler
# Compile Battle Tower and other Cups trainers/Pokémon # Compile Battle Tower and other Cups trainers/Pokémon
#============================================================================= #=============================================================================
def compile_trainer_lists(path = "PBS/battle_facility_lists.txt") def compile_trainer_lists(path = "PBS/battle_facility_lists.txt")
echo _INTL("Compiling Battle Facility lists...")
btTrainersRequiredTypes = { btTrainersRequiredTypes = {
"Trainers" => [0, "s"], "Trainers" => [0, "s"],
"Pokemon" => [1, "s"], "Pokemon" => [1, "s"],
@@ -1389,7 +1457,11 @@ module Compiler
MessageTypes.setMessagesAsHash(MessageTypes::EndSpeechLose,[]) MessageTypes.setMessagesAsHash(MessageTypes::EndSpeechLose,[])
File.open(path, "rb") { |f| File.open(path, "rb") { |f|
FileLineData.file = path FileLineData.file = path
idx = 0
pbEachFileSection(f) { |section,name| pbEachFileSection(f) { |section,name|
echo "."
idx += 1
Graphics.update
next if name!="DefaultTrainerList" && name!="TrainerList" next if name!="DefaultTrainerList" && name!="TrainerList"
rsection = [] rsection = []
for key in section.keys for key in section.keys
@@ -1432,6 +1504,8 @@ module Compiler
} }
} }
save_data(sections,"Data/trainer_lists.dat") save_data(sections,"Data/trainer_lists.dat")
echoln_good _INTL("done")
Graphics.update
end end
def compile_battle_tower_trainers(filename) def compile_battle_tower_trainers(filename)
@@ -1479,6 +1553,7 @@ module Compiler
# Compile metadata # Compile metadata
#============================================================================= #=============================================================================
def compile_metadata(path = "PBS/metadata.txt") def compile_metadata(path = "PBS/metadata.txt")
echo _INTL("Compiling metadata...")
GameData::Metadata::DATA.clear GameData::Metadata::DATA.clear
GameData::PlayerMetadata::DATA.clear GameData::PlayerMetadata::DATA.clear
# Read from PBS file # Read from PBS file
@@ -1544,6 +1619,7 @@ module Compiler
# Save all data # Save all data
GameData::Metadata.save GameData::Metadata.save
GameData::PlayerMetadata.save GameData::PlayerMetadata.save
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -1551,6 +1627,7 @@ module Compiler
# Compile map metadata # Compile map metadata
#============================================================================= #=============================================================================
def compile_map_metadata(path = "PBS/map_metadata.txt") def compile_map_metadata(path = "PBS/map_metadata.txt")
echo _INTL("Compiling map metadata...")
GameData::MapMetadata::DATA.clear GameData::MapMetadata::DATA.clear
map_infos = pbLoadMapInfos map_infos = pbLoadMapInfos
map_names = [] map_names = []
@@ -1562,7 +1639,11 @@ module Compiler
# contents is a hash containing all the XXX=YYY lines in that section, where # contents is a hash containing all the XXX=YYY lines in that section, where
# the keys are the XXX and the values are the YYY (as unprocessed strings). # the keys are the XXX and the values are the YYY (as unprocessed strings).
schema = GameData::MapMetadata::SCHEMA schema = GameData::MapMetadata::SCHEMA
idx = 0
pbEachFileSectionNumbered(f) { |contents, map_id| pbEachFileSectionNumbered(f) { |contents, map_id|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
# Go through schema hash of compilable data and compile this section # Go through schema hash of compilable data and compile this section
for key in schema.keys for key in schema.keys
FileLineData.setSection(map_id, key, contents[key]) # For error reporting FileLineData.setSection(map_id, key, contents[key]) # For error reporting
@@ -1607,6 +1688,7 @@ module Compiler
# Save all data # Save all data
GameData::MapMetadata.save GameData::MapMetadata.save
MessageTypes.setMessages(MessageTypes::MapNames, map_names) MessageTypes.setMessages(MessageTypes::MapNames, map_names)
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -1614,6 +1696,7 @@ module Compiler
# Compile battle animations # Compile battle animations
#============================================================================= #=============================================================================
def compile_animations def compile_animations
echo _INTL("Compiling animations...")
begin begin
pbanims = load_data("Data/PkmnAnimations.rxdata") pbanims = load_data("Data/PkmnAnimations.rxdata")
rescue rescue
@@ -1655,5 +1738,7 @@ module Compiler
save_data(move2anim,"Data/move2anim.dat") save_data(move2anim,"Data/move2anim.dat")
save_data(pbanims,"Data/PkmnAnimations.rxdata") save_data(pbanims,"Data/PkmnAnimations.rxdata")
end end
echoln_good _INTL("done")
Graphics.update
end end
end end

View File

@@ -14,9 +14,14 @@ module Compiler
def write_town_map def write_town_map
mapdata = pbLoadTownMapData mapdata = pbLoadTownMapData
return if !mapdata return if !mapdata
echo _INTL("Writing Town Map data...")
File.open("PBS/town_map.txt","wb") { |f| File.open("PBS/town_map.txt","wb") { |f|
idx = 0
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
for i in 0...mapdata.length for i in 0...mapdata.length
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
map = mapdata[i] map = mapdata[i]
next if !map next if !map
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
@@ -32,6 +37,7 @@ module Compiler
end end
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -71,6 +77,7 @@ module Compiler
def write_connections def write_connections
conndata = load_data("Data/map_connections.dat") conndata = load_data("Data/map_connections.dat")
return if !conndata return if !conndata
echo _INTL("Writing map connections...")
mapinfos = pbLoadMapInfos mapinfos = pbLoadMapInfos
File.open("PBS/map_connections.txt","wb") { |f| File.open("PBS/map_connections.txt","wb") { |f|
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
@@ -93,6 +100,7 @@ module Compiler
f.write("\r\n") f.write("\r\n")
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -102,6 +110,7 @@ module Compiler
def write_phone def write_phone
data = load_data("Data/phone.dat") rescue nil data = load_data("Data/phone.dat") rescue nil
return if !data return if !data
echo _INTL("Writing phone messages...")
File.open("PBS/phone.txt", "wb") { |f| File.open("PBS/phone.txt", "wb") { |f|
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
@@ -126,6 +135,7 @@ module Compiler
f.write("[<Bodies2>]\r\n") f.write("[<Bodies2>]\r\n")
f.write(data.bodies2.join("\r\n") + "\r\n") f.write(data.bodies2.join("\r\n") + "\r\n")
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -133,6 +143,7 @@ module Compiler
# Save type data to PBS file # Save type data to PBS file
#============================================================================= #=============================================================================
def write_types def write_types
echo _INTL("Writing types...")
File.open("PBS/types.txt", "wb") { |f| File.open("PBS/types.txt", "wb") { |f|
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
# Write each type in turn # Write each type in turn
@@ -149,6 +160,7 @@ module Compiler
f.write("Immunities = #{type.immunities.join(",")}\r\n") if type.immunities.length > 0 f.write("Immunities = #{type.immunities.join(",")}\r\n") if type.immunities.length > 0
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -156,6 +168,7 @@ module Compiler
# Save ability data to PBS file # Save ability data to PBS file
#============================================================================= #=============================================================================
def write_abilities def write_abilities
echo _INTL("Writing abilities...")
File.open("PBS/abilities.txt", "wb") { |f| File.open("PBS/abilities.txt", "wb") { |f|
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
# Write each ability in turn # Write each ability in turn
@@ -167,6 +180,7 @@ module Compiler
f.write(sprintf("Flags = %s\r\n", ability.flags.join(","))) if ability.flags.length > 0 f.write(sprintf("Flags = %s\r\n", ability.flags.join(","))) if ability.flags.length > 0
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -174,10 +188,15 @@ module Compiler
# Save move data to PBS file # Save move data to PBS file
#============================================================================= #=============================================================================
def write_moves def write_moves
echo _INTL("Writing moves...")
File.open("PBS/moves.txt", "wb") { |f| File.open("PBS/moves.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
# Write each move in turn # Write each move in turn
GameData::Move.each do |move| GameData::Move.each do |move|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
f.write("[#{move.id}]\r\n") f.write("[#{move.id}]\r\n")
f.write("Name = #{move.real_name}\r\n") f.write("Name = #{move.real_name}\r\n")
@@ -195,6 +214,7 @@ module Compiler
f.write("Description = #{move.real_description}\r\n") f.write("Description = #{move.real_description}\r\n")
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -202,9 +222,14 @@ module Compiler
# Save item data to PBS file # Save item data to PBS file
#============================================================================= #=============================================================================
def write_items def write_items
echo _INTL("Writing items...")
File.open("PBS/items.txt", "wb") { |f| File.open("PBS/items.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
GameData::Item.each do |item| GameData::Item.each do |item|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
f.write(sprintf("[%s]\r\n", item.id)) f.write(sprintf("[%s]\r\n", item.id))
f.write(sprintf("Name = %s\r\n", item.real_name)) f.write(sprintf("Name = %s\r\n", item.real_name))
@@ -222,6 +247,7 @@ module Compiler
f.write(sprintf("Description = %s\r\n", item.real_description)) f.write(sprintf("Description = %s\r\n", item.real_description))
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -229,6 +255,7 @@ module Compiler
# Save berry plant data to PBS file # Save berry plant data to PBS file
#============================================================================= #=============================================================================
def write_berry_plants def write_berry_plants
echo _INTL("Writing berry plants...")
File.open("PBS/berry_plants.txt", "wb") { |f| File.open("PBS/berry_plants.txt", "wb") { |f|
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
@@ -242,6 +269,7 @@ module Compiler
)) ))
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -249,14 +277,14 @@ module Compiler
# Save Pokémon data to PBS file # Save Pokémon data to PBS file
#============================================================================= #=============================================================================
def write_pokemon def write_pokemon
echo _INTL("Writing species...") echo _INTL("Writing Pokémon...")
File.open("PBS/pokemon.txt", "wb") { |f| File.open("PBS/pokemon.txt", "wb") { |f|
idx = 0 idx = 0
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
GameData::Species.each_species do |species| GameData::Species.each_species do |species|
echo "." if idx % 50 == 0 echo "." if idx % 50 == 0
idx += 1 idx += 1
Graphics.update if idx % 100 == 0 Graphics.update if idx % 250 == 0
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
f.write(sprintf("[%s]\r\n", species.id)) f.write(sprintf("[%s]\r\n", species.id))
f.write(sprintf("Name = %s\r\n", species.real_name)) f.write(sprintf("Name = %s\r\n", species.real_name))
@@ -331,7 +359,7 @@ module Compiler
f.write(sprintf("Incense = %s\r\n", species.incense)) if species.incense f.write(sprintf("Incense = %s\r\n", species.incense)) if species.incense
end end
} }
echoln _INTL("done") echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -339,14 +367,16 @@ module Compiler
# Save Pokémon forms data to PBS file # Save Pokémon forms data to PBS file
#============================================================================= #=============================================================================
def write_pokemon_forms def write_pokemon_forms
echo _INTL("Writing Pokémon forms...")
File.open("PBS/pokemon_forms.txt", "wb") { |f| File.open("PBS/pokemon_forms.txt", "wb") { |f|
idx = 0 idx = 0
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
GameData::Species.each do |species| GameData::Species.each do |species|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
next if species.form == 0 next if species.form == 0
base_species = GameData::Species.get(species.species) base_species = GameData::Species.get(species.species)
idx += 1
Graphics.update if idx % 100 == 0
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
f.write(sprintf("[%s,%d]\r\n", species.species, species.form)) f.write(sprintf("[%s,%d]\r\n", species.species, species.form))
f.write(sprintf("FormName = %s\r\n", species.real_form_name)) if species.real_form_name && !species.real_form_name.empty? f.write(sprintf("FormName = %s\r\n", species.real_form_name)) if species.real_form_name && !species.real_form_name.empty?
@@ -430,6 +460,7 @@ module Compiler
end end
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -437,7 +468,7 @@ module Compiler
# Write species metrics # Write species metrics
#============================================================================= #=============================================================================
def write_pokemon_metrics def write_pokemon_metrics
echo _INTL("Writing species metrics...") echo _INTL("Writing Pokémon metrics...")
# Get in species order then in form order # Get in species order then in form order
sort_array = [] sort_array = []
dex_numbers = {} dex_numbers = {}
@@ -455,7 +486,7 @@ module Compiler
sort_array.each do |val| sort_array.each do |val|
echo "." if idx % 50 == 0 echo "." if idx % 50 == 0
idx += 1 idx += 1
Graphics.update if idx % 100 == 0 Graphics.update if idx % 250 == 0
species = GameData::SpeciesMetrics.get(val[1]) species = GameData::SpeciesMetrics.get(val[1])
if species.form > 0 if species.form > 0
base_species = GameData::SpeciesMetrics.get(val[2]) base_species = GameData::SpeciesMetrics.get(val[2])
@@ -482,7 +513,7 @@ module Compiler
f.write(sprintf("ShadowSize = %d\r\n", species.shadow_size)) f.write(sprintf("ShadowSize = %d\r\n", species.shadow_size))
end end
} }
echoln _INTL("done") echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -490,16 +521,21 @@ module Compiler
# Save Shadow movesets to PBS file # Save Shadow movesets to PBS file
#============================================================================= #=============================================================================
def write_shadow_movesets def write_shadow_movesets
echo _INTL("Writing Shadow Pokémon movesets...")
shadow_movesets = pbLoadShadowMovesets shadow_movesets = pbLoadShadowMovesets
File.open("PBS/shadow_movesets.txt", "wb") { |f| File.open("PBS/shadow_movesets.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
GameData::Species.each do |species_data| GameData::Species.each do |species_data|
echo "." if idx % 150 == 0
idx += 1
moveset = shadow_movesets[species_data.id] moveset = shadow_movesets[species_data.id]
next if !moveset || moveset.length == 0 next if !moveset || moveset.length == 0
f.write(sprintf("%s = %s\r\n", species_data.id, moveset.join(","))) f.write(sprintf("%s = %s\r\n", species_data.id, moveset.join(",")))
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -507,6 +543,7 @@ module Compiler
# Save Regional Dexes to PBS file # Save Regional Dexes to PBS file
#============================================================================= #=============================================================================
def write_regional_dexes def write_regional_dexes
echo _INTL("Writing Pokédex lists...")
dex_lists = pbLoadRegionalDexes dex_lists = pbLoadRegionalDexes
File.open("PBS/regional_dexes.txt", "wb") { |f| File.open("PBS/regional_dexes.txt", "wb") { |f|
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
@@ -531,6 +568,7 @@ module Compiler
f.write("\r\n") f.write("\r\n")
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -538,6 +576,7 @@ module Compiler
# Save ability data to PBS file # Save ability data to PBS file
#============================================================================= #=============================================================================
def write_ribbons def write_ribbons
echo _INTL("Writing ribbons...")
File.open("PBS/ribbons.txt", "wb") { |f| File.open("PBS/ribbons.txt", "wb") { |f|
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
# Write each ability in turn # Write each ability in turn
@@ -550,6 +589,7 @@ module Compiler
f.write(sprintf("Flags = %s\r\n", ribbon.flags.join(","))) if ribbon.flags.length > 0 f.write(sprintf("Flags = %s\r\n", ribbon.flags.join(","))) if ribbon.flags.length > 0
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -557,10 +597,15 @@ module Compiler
# Save wild encounter data to PBS file # Save wild encounter data to PBS file
#============================================================================= #=============================================================================
def write_encounters def write_encounters
echo _INTL("Writing encounters...")
map_infos = pbLoadMapInfos map_infos = pbLoadMapInfos
File.open("PBS/encounters.txt", "wb") { |f| File.open("PBS/encounters.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
GameData::Encounter.each do |encounter_data| GameData::Encounter.each do |encounter_data|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
map_name = (map_infos[encounter_data.map]) ? " # #{map_infos[encounter_data.map].name}" : "" map_name = (map_infos[encounter_data.map]) ? " # #{map_infos[encounter_data.map].name}" : ""
if encounter_data.version > 0 if encounter_data.version > 0
@@ -585,6 +630,7 @@ module Compiler
end end
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -592,6 +638,7 @@ module Compiler
# Save trainer type data to PBS file # Save trainer type data to PBS file
#============================================================================= #=============================================================================
def write_trainer_types def write_trainer_types
echo _INTL("Writing trainer types...")
File.open("PBS/trainer_types.txt", "wb") { |f| File.open("PBS/trainer_types.txt", "wb") { |f|
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
GameData::TrainerType.each do |t| GameData::TrainerType.each do |t|
@@ -608,6 +655,7 @@ module Compiler
f.write(sprintf("VictoryME = %s\r\n", t.victory_ME)) if !nil_or_empty?(t.victory_ME) f.write(sprintf("VictoryME = %s\r\n", t.victory_ME)) if !nil_or_empty?(t.victory_ME)
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -622,7 +670,7 @@ module Compiler
GameData::Trainer.each do |trainer| GameData::Trainer.each do |trainer|
echo "." if idx % 50 == 0 echo "." if idx % 50 == 0
idx += 1 idx += 1
Graphics.update if idx % 50 == 0 Graphics.update if idx % 250 == 0
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
if trainer.version > 0 if trainer.version > 0
f.write(sprintf("[%s,%s,%d]\r\n", trainer.trainer_type, trainer.real_name, trainer.version)) f.write(sprintf("[%s,%s,%d]\r\n", trainer.trainer_type, trainer.real_name, trainer.version))
@@ -660,7 +708,7 @@ module Compiler
end end
end end
} }
echoln _INTL("done") echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -670,9 +718,11 @@ module Compiler
def write_trainer_lists def write_trainer_lists
trainerlists = load_data("Data/trainer_lists.dat") rescue nil trainerlists = load_data("Data/trainer_lists.dat") rescue nil
return if !trainerlists return if !trainerlists
echo _INTL("Writing Battle Facility lists...")
File.open("PBS/battle_facility_lists.txt","wb") { |f| File.open("PBS/battle_facility_lists.txt","wb") { |f|
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
for tr in trainerlists for tr in trainerlists
echo "."
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
f.write(((tr[5]) ? "[DefaultTrainerList]" : "[TrainerList]")+"\r\n") f.write(((tr[5]) ? "[DefaultTrainerList]" : "[TrainerList]")+"\r\n")
f.write("Trainers = "+tr[3]+"\r\n") f.write("Trainers = "+tr[3]+"\r\n")
@@ -682,6 +732,7 @@ module Compiler
write_battle_tower_pokemon(tr[1],"PBS/"+tr[4]) write_battle_tower_pokemon(tr[1],"PBS/"+tr[4])
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -747,7 +798,10 @@ module Compiler
Graphics.update if i % 500 == 0 Graphics.update if i % 500 == 0
pkmn = btpokemon[i] pkmn = btpokemon[i]
c1 = (species[pkmn.species]) ? species[pkmn.species] : (species[pkmn.species] = GameData::Species.get(pkmn.species).species.to_s) c1 = (species[pkmn.species]) ? species[pkmn.species] : (species[pkmn.species] = GameData::Species.get(pkmn.species).species.to_s)
c2 = (items[pkmn.item]) ? items[pkmn.item] : (items[pkmn.item] = GameData::Item.get(pkmn.item).id.to_s) c2 = nil
if pkmn.item && GameData::Item.exists?(pkmn.item)
c2 = (items[pkmn.item]) ? items[pkmn.item] : (items[pkmn.item] = GameData::Item.get(pkmn.item).id.to_s)
end
c3 = (natures[pkmn.nature]) ? natures[pkmn.nature] : (natures[pkmn.nature] = GameData::Nature.get(pkmn.nature).id.to_s) c3 = (natures[pkmn.nature]) ? natures[pkmn.nature] : (natures[pkmn.nature] = GameData::Nature.get(pkmn.nature).id.to_s)
evlist = "" evlist = ""
pkmn.ev.each_with_index do |stat, i| pkmn.ev.each_with_index do |stat, i|
@@ -775,6 +829,7 @@ module Compiler
# Save metadata data to PBS file # Save metadata data to PBS file
#============================================================================= #=============================================================================
def write_metadata def write_metadata
echo _INTL("Writing metadata...")
File.open("PBS/metadata.txt", "wb") { |f| File.open("PBS/metadata.txt", "wb") { |f|
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
# Write metadata # Write metadata
@@ -805,6 +860,7 @@ module Compiler
end end
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -812,12 +868,17 @@ module Compiler
# Save map metadata data to PBS file # Save map metadata data to PBS file
#============================================================================= #=============================================================================
def write_map_metadata def write_map_metadata
echo _INTL("Writing map metadata...")
map_infos = pbLoadMapInfos map_infos = pbLoadMapInfos
schema = GameData::MapMetadata::SCHEMA schema = GameData::MapMetadata::SCHEMA
keys = schema.keys.sort { |a, b| schema[a][0] <=> schema[b][0] } keys = schema.keys.sort { |a, b| schema[a][0] <=> schema[b][0] }
File.open("PBS/map_metadata.txt", "wb") { |f| File.open("PBS/map_metadata.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
GameData::MapMetadata.each do |map_data| GameData::MapMetadata.each do |map_data|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
map_name = (map_infos && map_infos[map_data.id]) ? map_infos[map_data.id].name : nil map_name = (map_infos && map_infos[map_data.id]) ? map_infos[map_data.id].name : nil
if map_name if map_name
@@ -834,6 +895,7 @@ module Compiler
end end
end end
} }
echoln_good _INTL("done")
Graphics.update Graphics.update
end end
@@ -841,6 +903,9 @@ module Compiler
# Save all data to PBS files # Save all data to PBS files
#============================================================================= #=============================================================================
def write_all def write_all
echoln ""
echoln_warn _INTL("*** Writing all PBS files ***")
echoln ""
write_town_map write_town_map
write_connections write_connections
write_phone write_phone
@@ -861,5 +926,8 @@ module Compiler
write_trainer_lists write_trainer_lists
write_metadata write_metadata
write_map_metadata write_map_metadata
echoln ""
echoln_warn _INTL("*** Finished writing all PBS files ***")
echoln ""
end end
end end

View File

@@ -1435,9 +1435,13 @@ module Compiler
t = Time.now.to_i t = Time.now.to_i
Graphics.update Graphics.update
trainerChecker = TrainerChecker.new trainerChecker = TrainerChecker.new
any_changed = false change_record = []
echoln _INTL("Processing {1} maps...", mapData.mapinfos.keys.length) echo _INTL("Processing {1} maps...", mapData.mapinfos.keys.length)
idx = 0
for id in mapData.mapinfos.keys.sort for id in mapData.mapinfos.keys.sort
echo "." if idx % 20 == 0
idx += 1
Graphics.update if idx % 250 == 0
changed = false changed = false
map = mapData.getMap(id) map = mapData.getMap(id)
next if !map || !mapData.mapinfos[id] next if !map || !mapData.mapinfos[id]
@@ -1470,29 +1474,29 @@ module Compiler
end end
changed = true if check_counters(map,id,mapData) changed = true if check_counters(map,id,mapData)
if changed if changed
any_changed = true
mapData.saveMap(id) mapData.saveMap(id)
mapData.saveTilesets mapData.saveTilesets
echoln _INTL("Map {1}: '{2}' modified and saved.", id, mapData.mapinfos[id].name) change_record.push(_INTL("Map {1}: '{2}' modified and saved.", id, mapData.mapinfos[id].name))
end end
end end
echoln "" echoln_good "done"
change_record.each { |msg| echoln_warn msg }
changed = false changed = false
Graphics.update Graphics.update
commonEvents = load_data("Data/CommonEvents.rxdata") commonEvents = load_data("Data/CommonEvents.rxdata")
echoln _INTL("Processing common events") echo _INTL("Processing common events...")
for key in 0...commonEvents.length for key in 0...commonEvents.length
newevent = fix_event_use(commonEvents[key],0,mapData) newevent = fix_event_use(commonEvents[key],0,mapData)
if newevent if newevent
commonEvents[key] = newevent commonEvents[key] = newevent
changed = true changed = true
any_changed = true
end end
end end
save_data(commonEvents,"Data/CommonEvents.rxdata") if changed save_data(commonEvents,"Data/CommonEvents.rxdata") if changed
echoln "" echoln_good "done"
if any_changed if change_record.length > 0 || changed
echoln _INTL("!!! RMXP data was altered. Close RMXP now to ensure changes are applied. !!!") echoln ""
echoln_warn _INTL("!!! RMXP data was altered. Close RMXP now to ensure changes are applied. !!!")
echoln "" echoln ""
end end
end end