mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +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:
@@ -246,24 +246,34 @@ module GameData
|
||||
# A bulk loader method for all data stored in .dat files in the Data folder.
|
||||
#=============================================================================
|
||||
def self.load_all
|
||||
TownMap.load
|
||||
Type.load
|
||||
Ability.load
|
||||
Move.load
|
||||
Item.load
|
||||
BerryPlant.load
|
||||
Species.load
|
||||
SpeciesMetrics.load
|
||||
ShadowPokemon.load
|
||||
Ribbon.load
|
||||
Encounter.load
|
||||
TrainerType.load
|
||||
Trainer.load
|
||||
Metadata.load
|
||||
PlayerMetadata.load
|
||||
MapMetadata.load
|
||||
DungeonTileset.load
|
||||
DungeonParameters.load
|
||||
PhoneMessage.load
|
||||
self.constants.each do |c|
|
||||
next if !self.const_get(c).is_a?(Class)
|
||||
self.const_get(c).load if self.const_get(c).const_defined?(:DATA_FILENAME)
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_all_data_filenames
|
||||
ret = []
|
||||
self.constants.each do |c|
|
||||
next if !self.const_get(c).is_a?(Class)
|
||||
ret.push(self.const_get(c)::DATA_FILENAME) if self.const_get(c).const_defined?(:DATA_FILENAME)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def self.get_all_pbs_base_filenames
|
||||
ret = {}
|
||||
self.constants.each do |c|
|
||||
next if !self.const_get(c).is_a?(Class)
|
||||
ret[c] = self.const_get(c)::PBS_BASE_FILENAME if self.const_get(c).const_defined?(:PBS_BASE_FILENAME)
|
||||
if ret[c].is_a?(Array)
|
||||
ret[c].length.times do |i|
|
||||
next if i == 0
|
||||
ret[(c.to_s + i.to_s).to_sym] = ret[c][i] # :Species1 => "pokemon_forms"
|
||||
end
|
||||
ret[c] = ret[c][0] # :Species => "pokemon"
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,9 +5,11 @@ module GameData
|
||||
attr_reader :filename
|
||||
attr_reader :point
|
||||
attr_reader :flags
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "town_map.dat"
|
||||
PBS_BASE_FILENAME = "town_map"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "u"],
|
||||
@@ -26,6 +28,7 @@ module GameData
|
||||
@filename = hash[:filename]
|
||||
@point = hash[:point] || []
|
||||
@flags = hash[:flags] || []
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this region
|
||||
|
||||
@@ -9,9 +9,11 @@ module GameData
|
||||
attr_reader :resistances
|
||||
attr_reader :immunities
|
||||
attr_reader :flags
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "types.dat"
|
||||
PBS_BASE_FILENAME = "types"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "m"],
|
||||
@@ -41,6 +43,7 @@ module GameData
|
||||
@immunities = hash[:immunities] || []
|
||||
@immunities = [@immunities] if !@immunities.is_a?(Array)
|
||||
@flags = hash[:flags] || []
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this item
|
||||
|
||||
@@ -4,9 +4,11 @@ module GameData
|
||||
attr_reader :real_name
|
||||
attr_reader :real_description
|
||||
attr_reader :flags
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "abilities.dat"
|
||||
PBS_BASE_FILENAME = "abilities"
|
||||
|
||||
extend ClassMethodsSymbols
|
||||
include InstanceMethods
|
||||
@@ -23,6 +25,7 @@ module GameData
|
||||
@real_name = hash[:real_name] || "Unnamed"
|
||||
@real_description = hash[:real_description] || "???"
|
||||
@flags = hash[:flags] || []
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this ability
|
||||
|
||||
@@ -14,9 +14,11 @@ module GameData
|
||||
attr_reader :flags
|
||||
attr_reader :effect_chance
|
||||
attr_reader :real_description
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "moves.dat"
|
||||
PBS_BASE_FILENAME = "moves"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "m"],
|
||||
@@ -53,6 +55,7 @@ module GameData
|
||||
@flags = [@flags] if !@flags.is_a?(Array)
|
||||
@effect_chance = hash[:effect_chance] || 0
|
||||
@real_description = hash[:real_description] || "???"
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this move
|
||||
|
||||
@@ -12,9 +12,11 @@ module GameData
|
||||
attr_reader :consumable
|
||||
attr_reader :move
|
||||
attr_reader :real_description
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "items.dat"
|
||||
PBS_BASE_FILENAME = "items"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "m"],
|
||||
@@ -95,6 +97,7 @@ module GameData
|
||||
@consumable = !is_important? if @consumable.nil?
|
||||
@move = hash[:move]
|
||||
@real_description = hash[:real_description] || "???"
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this item
|
||||
|
||||
@@ -4,9 +4,11 @@ module GameData
|
||||
attr_reader :hours_per_stage
|
||||
attr_reader :drying_per_hour
|
||||
attr_reader :yield
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "berry_plants.dat"
|
||||
PBS_BASE_FILENAME = "berry_plants"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "m"],
|
||||
@@ -29,6 +31,7 @@ module GameData
|
||||
@drying_per_hour = hash[:drying_per_hour] || 15
|
||||
@yield = hash[:yield] || [2, 5]
|
||||
@yield.reverse! if @yield[1] < @yield[0]
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
def minimum_yield
|
||||
|
||||
@@ -40,9 +40,11 @@ module GameData
|
||||
attr_reader :mega_move
|
||||
attr_reader :unmega_form
|
||||
attr_reader :mega_message
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "species.dat"
|
||||
PBS_BASE_FILENAME = ["pokemon", "pokemon_forms"]
|
||||
|
||||
extend ClassMethodsSymbols
|
||||
include InstanceMethods
|
||||
@@ -175,6 +177,7 @@ module GameData
|
||||
@mega_move = hash[:mega_move]
|
||||
@unmega_form = hash[:unmega_form] || 0
|
||||
@mega_message = hash[:mega_message] || 0
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this species
|
||||
|
||||
@@ -8,9 +8,11 @@ module GameData
|
||||
attr_accessor :front_sprite_altitude
|
||||
attr_accessor :shadow_x
|
||||
attr_accessor :shadow_size
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "species_metrics.dat"
|
||||
PBS_BASE_FILENAME = "pokemon_metrics"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "eV", :Species],
|
||||
@@ -63,6 +65,7 @@ module GameData
|
||||
@front_sprite_altitude = hash[:front_sprite_altitude] || 0
|
||||
@shadow_x = hash[:shadow_x] || 0
|
||||
@shadow_size = hash[:shadow_size] || 2
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
def apply_metrics_to_sprite(sprite, index, shadow = false)
|
||||
|
||||
@@ -4,9 +4,11 @@ module GameData
|
||||
attr_reader :moves
|
||||
attr_reader :gauge_size
|
||||
attr_reader :flags
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "shadow_pokemon.dat"
|
||||
PBS_BASE_FILENAME = "shadow_pokemon"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "e", :Species],
|
||||
@@ -24,6 +26,7 @@ module GameData
|
||||
@gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE
|
||||
@moves = hash[:moves] || []
|
||||
@flags = hash[:flags] || []
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
def has_flag?(flag)
|
||||
|
||||
@@ -5,9 +5,11 @@ module GameData
|
||||
attr_reader :icon_position # Where this ribbon's graphic is within ribbons.png
|
||||
attr_reader :real_description
|
||||
attr_reader :flags
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "ribbons.dat"
|
||||
PBS_BASE_FILENAME = "ribbons"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "m"],
|
||||
@@ -26,6 +28,7 @@ module GameData
|
||||
@icon_position = hash[:icon_position] || 0
|
||||
@real_description = hash[:real_description] || "???"
|
||||
@flags = hash[:flags] || []
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this ribbon
|
||||
|
||||
@@ -5,9 +5,11 @@ module GameData
|
||||
attr_accessor :version
|
||||
attr_reader :step_chances
|
||||
attr_reader :types
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "encounters.dat"
|
||||
PBS_BASE_FILENAME = "encounters"
|
||||
|
||||
extend ClassMethodsSymbols
|
||||
include InstanceMethods
|
||||
@@ -63,6 +65,7 @@ module GameData
|
||||
@version = hash[:version] || 0
|
||||
@step_chances = hash[:step_chances]
|
||||
@types = hash[:types] || {}
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,9 +9,11 @@ module GameData
|
||||
attr_reader :intro_BGM
|
||||
attr_reader :battle_BGM
|
||||
attr_reader :victory_BGM
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "trainer_types.dat"
|
||||
PBS_BASE_FILENAME = "trainer_types"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "m"],
|
||||
@@ -90,6 +92,7 @@ module GameData
|
||||
@intro_BGM = hash[:intro_BGM]
|
||||
@battle_BGM = hash[:battle_BGM]
|
||||
@victory_BGM = hash[:victory_BGM]
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this trainer type
|
||||
|
||||
@@ -7,9 +7,11 @@ module GameData
|
||||
attr_reader :items
|
||||
attr_reader :real_lose_text
|
||||
attr_reader :pokemon
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "trainers.dat"
|
||||
PBS_BASE_FILENAME = "trainers"
|
||||
|
||||
SCHEMA = {
|
||||
"Items" => [:items, "*e", :Item],
|
||||
@@ -84,6 +86,7 @@ module GameData
|
||||
pkmn[:ev][s.id] ||= 0 if pkmn[:ev]
|
||||
end
|
||||
end
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this trainer
|
||||
|
||||
@@ -12,9 +12,11 @@ module GameData
|
||||
attr_reader :wild_capture_ME
|
||||
attr_reader :surf_BGM
|
||||
attr_reader :bicycle_BGM
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "metadata.dat"
|
||||
PBS_BASE_FILENAME = "metadata"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "u"],
|
||||
@@ -67,11 +69,12 @@ module GameData
|
||||
@wild_capture_ME = hash[:wild_capture_ME]
|
||||
@surf_BGM = hash[:surf_BGM]
|
||||
@bicycle_BGM = hash[:bicycle_BGM]
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of the Pokémon Storage creator
|
||||
def storage_creator
|
||||
ret = pbGetMessage(MessageTypes::StorageCreator, 0)
|
||||
ret = pbGetMessageFromHash(MessageTypes::StorageCreator, @real_storage_creator)
|
||||
return nil_or_empty?(ret) ? _INTL("Bill") : ret
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,6 +4,7 @@ module GameData
|
||||
attr_reader :trainer_type
|
||||
attr_reader :walk_charset
|
||||
attr_reader :home
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "player_metadata.dat"
|
||||
@@ -57,6 +58,7 @@ module GameData
|
||||
@fish_charset = hash[:fish_charset]
|
||||
@surf_fish_charset = hash[:surf_fish_charset]
|
||||
@home = hash[:home]
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
def run_charset
|
||||
|
||||
@@ -23,9 +23,11 @@ module GameData
|
||||
attr_reader :town_map_size
|
||||
attr_reader :battle_environment
|
||||
attr_reader :flags
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "map_metadata.dat"
|
||||
PBS_BASE_FILENAME = "map_metadata"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "u"],
|
||||
@@ -107,6 +109,7 @@ module GameData
|
||||
@town_map_size = hash[:town_map_size]
|
||||
@battle_environment = hash[:battle_environment]
|
||||
@flags = hash[:flags] || []
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this map
|
||||
|
||||
@@ -10,9 +10,11 @@ module GameData
|
||||
attr_reader :floor_patch_under_walls
|
||||
attr_reader :thin_north_wall_offset
|
||||
attr_reader :flags
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "dungeon_tilesets.dat"
|
||||
PBS_BASE_FILENAME = "dungeon_tilesets"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "u"],
|
||||
@@ -51,6 +53,7 @@ module GameData
|
||||
@flags = hash[:flags] || []
|
||||
@tile_type_ids = {}
|
||||
set_tile_type_ids(hash)
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
def set_tile_type_ids(hash)
|
||||
|
||||
@@ -25,9 +25,11 @@ module GameData
|
||||
attr_reader :void_decoration_density, :void_decoration_large_density
|
||||
attr_reader :rng_seed
|
||||
attr_reader :flags
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "dungeon_parameters.dat"
|
||||
PBS_BASE_FILENAME = "dungeon_parameters"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "mV"],
|
||||
@@ -91,6 +93,7 @@ module GameData
|
||||
@void_decoration_large_density = (hash[:void_decorations]) ? hash[:void_decorations][1] : 200
|
||||
@rng_seed = hash[:rng_seed]
|
||||
@flags = hash[:flags] || []
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
def has_flag?(flag)
|
||||
|
||||
@@ -6,9 +6,11 @@ module GameData
|
||||
attr_reader :body, :body1, :body2
|
||||
attr_reader :battle_request, :battle_remind
|
||||
attr_reader :end
|
||||
attr_reader :pbs_file_suffix
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "phone.dat"
|
||||
PBS_BASE_FILENAME = "phone"
|
||||
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "q"],
|
||||
@@ -16,9 +18,9 @@ module GameData
|
||||
"IntroMorning" => [:intro_morning, "^q"],
|
||||
"IntroAfternoon" => [:intro_afternoon, "^q"],
|
||||
"IntroEvening" => [:intro_evening, "^q"],
|
||||
"Body" => [:body, "^q"],
|
||||
"Body1" => [:body1, "^q"],
|
||||
"Body2" => [:body2, "^q"],
|
||||
"Body" => [:body, "^q"],
|
||||
"BattleRequest" => [:battle_request, "^q"],
|
||||
"BattleRemind" => [:battle_remind, "^q"],
|
||||
"End" => [:end, "^q"]
|
||||
@@ -82,6 +84,7 @@ module GameData
|
||||
@battle_request = hash[:battle_request]
|
||||
@battle_remind = hash[:battle_remind]
|
||||
@end = hash[:end]
|
||||
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
|
||||
end
|
||||
|
||||
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)
|
||||
|
||||
@@ -81,7 +81,8 @@ def pbEncountersEditor
|
||||
:map => new_map_ID,
|
||||
:version => new_version,
|
||||
:step_chances => {},
|
||||
:types => {}
|
||||
:types => {},
|
||||
:pbs_file_suffix => GameData::Encounter.get(this_set[0], this_set[1]).pbs_file_suffix
|
||||
}
|
||||
GameData::Encounter.get(this_set[0], this_set[1]).step_chances.each do |type, value|
|
||||
encounter_hash[:step_chances][type] = value
|
||||
@@ -392,7 +393,8 @@ def pbTrainerTypeEditor
|
||||
:flags => data[5],
|
||||
:intro_BGM => data[6],
|
||||
:battle_BGM => data[7],
|
||||
:victory_BGM => data[8]
|
||||
:victory_BGM => data[8],
|
||||
:pbs_file_suffix => t_data.pbs_file_suffix
|
||||
}
|
||||
# Add trainer type's data to records
|
||||
GameData::TrainerType.register(type_hash)
|
||||
@@ -548,7 +550,8 @@ def pbTrainerBattleEditor
|
||||
:version => data[2],
|
||||
:lose_text => data[3],
|
||||
:pokemon => party,
|
||||
:items => items
|
||||
:items => items,
|
||||
:pbs_file_suffix => tr_data.pbs_file_suffix
|
||||
}
|
||||
# Add trainer type's data to records
|
||||
trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]]
|
||||
@@ -750,7 +753,8 @@ def pbEditMetadata
|
||||
:trainer_victory_BGM => data[7],
|
||||
:wild_capture_ME => data[8],
|
||||
:surf_BGM => data[9],
|
||||
:bicycle_BGM => data[10]
|
||||
:bicycle_BGM => data[10],
|
||||
:pbs_file_suffix => metadata.pbs_file_suffix
|
||||
}
|
||||
# Add metadata's data to records
|
||||
GameData::Metadata.register(metadata_hash)
|
||||
@@ -794,7 +798,8 @@ def pbEditPlayerMetadata(player_id = 1)
|
||||
:dive_charset => data[5],
|
||||
:fish_charset => data[6],
|
||||
:surf_fish_charset => data[7],
|
||||
:home => data[8]
|
||||
:home => data[8],
|
||||
:pbs_file_suffix => metadata.pbs_file_suffix
|
||||
}
|
||||
# Add player metadata's data to records
|
||||
GameData::PlayerMetadata.register(metadata_hash)
|
||||
@@ -853,7 +858,8 @@ def pbEditMapMetadata(map_id)
|
||||
:wild_capture_ME => data[18],
|
||||
:town_map_size => data[19],
|
||||
:battle_environment => data[20],
|
||||
:flags => data[21]
|
||||
:flags => data[21],
|
||||
:pbs_file_suffix => metadata.pbs_file_suffix
|
||||
}
|
||||
# Add map metadata's data to records
|
||||
GameData::MapMetadata.register(metadata_hash)
|
||||
@@ -927,7 +933,8 @@ def pbItemEditor
|
||||
:battle_use => data[8],
|
||||
:consumable => data[9],
|
||||
:flags => data[10],
|
||||
:move => data[11]
|
||||
:move => data[11],
|
||||
:pbs_file_suffix => itm.pbs_file_suffix
|
||||
}
|
||||
# Add item's data to records
|
||||
GameData::Item.register(item_hash)
|
||||
@@ -1146,7 +1153,8 @@ def pbPokemonEditor
|
||||
:shape => data[35],
|
||||
:habitat => data[36],
|
||||
:generation => data[37],
|
||||
:flags => data[38]
|
||||
:flags => data[38],
|
||||
:pbs_file_suffix => spec.pbs_file_suffix
|
||||
}
|
||||
# Add species' data to records
|
||||
GameData::Species.register(species_hash)
|
||||
|
||||
@@ -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_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 # Depends on TrainerType
|
||||
compile_map_metadata
|
||||
compile_dungeon_tilesets
|
||||
compile_dungeon_parameters
|
||||
compile_phone # 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)
|
||||
# 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("PBS/#{filename}") { |file|
|
||||
latestTextTime = [latestTextTime, file.mtime.to_i].max
|
||||
}
|
||||
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
|
||||
|
||||
@@ -1,22 +1,29 @@
|
||||
module Compiler
|
||||
module_function
|
||||
|
||||
def compile_PBS_file_generic(game_data, path)
|
||||
compile_pbs_file_message_start(path)
|
||||
def compile_PBS_file_generic(game_data, *paths)
|
||||
game_data::DATA.clear
|
||||
# Read from PBS file
|
||||
schema = game_data.schema
|
||||
# Read from PBS file(s)
|
||||
paths.each do |path|
|
||||
compile_pbs_file_message_start(path)
|
||||
base_filename = game_data::PBS_BASE_FILENAME
|
||||
base_filename = base_filename[0] if base_filename.is_a?(Array) # For Species
|
||||
file_suffix = File.basename(path, ".txt")[base_filename.length + 1, path.length] || ""
|
||||
File.open(path, "rb") { |f|
|
||||
FileLineData.file = path # For error reporting
|
||||
# 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
|
||||
# the keys are the XXX and the values are the YYY (as unprocessed strings).
|
||||
schema = game_data.schema
|
||||
idx = 0
|
||||
pbEachFileSection(f, schema) { |contents, section_name|
|
||||
echo "." if idx % 50 == 0
|
||||
Graphics.update if idx % 250 == 0
|
||||
idx += 1
|
||||
data_hash = {:id => section_name.to_sym}
|
||||
data_hash = {
|
||||
:id => section_name.to_sym,
|
||||
:pbs_file_suffix => file_suffix
|
||||
}
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
schema.each_key do |key|
|
||||
FileLineData.setSection(section_name, key, contents[key]) # For error reporting
|
||||
@@ -50,17 +57,18 @@ module Compiler
|
||||
game_data.register(data_hash)
|
||||
}
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
yield true, nil if block_given?
|
||||
# Save all data
|
||||
game_data.save
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Compile Town Map data
|
||||
#=============================================================================
|
||||
def compile_town_map(path = "PBS/town_map.txt")
|
||||
compile_PBS_file_generic(GameData::TownMap, path) do |final_validate, hash|
|
||||
def compile_town_map(*paths)
|
||||
compile_PBS_file_generic(GameData::TownMap, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_town_maps : validate_compiled_town_map(hash)
|
||||
end
|
||||
end
|
||||
@@ -90,9 +98,10 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile map connections
|
||||
#=============================================================================
|
||||
def compile_connections(path = "PBS/map_connections.txt")
|
||||
compile_pbs_file_message_start(path)
|
||||
def compile_connections(*paths)
|
||||
records = []
|
||||
paths.each do |path|
|
||||
compile_pbs_file_message_start(path)
|
||||
pbCompilerEachPreppedLine(path) { |line, lineno|
|
||||
hashenum = {
|
||||
"N" => "N", "North" => "N",
|
||||
@@ -126,15 +135,16 @@ module Compiler
|
||||
end
|
||||
records.push(record)
|
||||
}
|
||||
save_data(records, "Data/map_connections.dat")
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
save_data(records, "Data/map_connections.dat")
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Compile type data
|
||||
#=============================================================================
|
||||
def compile_types(path = "PBS/types.txt")
|
||||
compile_PBS_file_generic(GameData::Type, path) do |final_validate, hash|
|
||||
def compile_types(*paths)
|
||||
compile_PBS_file_generic(GameData::Type, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_types : validate_compiled_type(hash)
|
||||
end
|
||||
end
|
||||
@@ -171,8 +181,8 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile ability data
|
||||
#=============================================================================
|
||||
def compile_abilities(path = "PBS/abilities.txt")
|
||||
compile_PBS_file_generic(GameData::Ability, path) do |final_validate, hash|
|
||||
def compile_abilities(*paths)
|
||||
compile_PBS_file_generic(GameData::Ability, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_abilities : validate_compiled_ability(hash)
|
||||
end
|
||||
end
|
||||
@@ -195,8 +205,8 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile move data
|
||||
#=============================================================================
|
||||
def compile_moves(path = "PBS/moves.txt")
|
||||
compile_PBS_file_generic(GameData::Move, path) do |final_validate, hash|
|
||||
def compile_moves(*paths)
|
||||
compile_PBS_file_generic(GameData::Move, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_moves : validate_compiled_move(hash)
|
||||
end
|
||||
end
|
||||
@@ -227,8 +237,8 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile item data
|
||||
#=============================================================================
|
||||
def compile_items(path = "PBS/items.txt")
|
||||
compile_PBS_file_generic(GameData::Item, path) do |final_validate, hash|
|
||||
def compile_items(*paths)
|
||||
compile_PBS_file_generic(GameData::Item, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_items : validate_compiled_item(hash)
|
||||
end
|
||||
end
|
||||
@@ -254,8 +264,8 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile berry plant data
|
||||
#=============================================================================
|
||||
def compile_berry_plants(path = "PBS/berry_plants.txt")
|
||||
compile_PBS_file_generic(GameData::BerryPlant, path) do |final_validate, hash|
|
||||
def compile_berry_plants(*paths)
|
||||
compile_PBS_file_generic(GameData::BerryPlant, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_berry_plants : validate_compiled_berry_plant(hash)
|
||||
end
|
||||
end
|
||||
@@ -269,8 +279,8 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile Pokémon data
|
||||
#=============================================================================
|
||||
def compile_pokemon(path = "PBS/pokemon.txt")
|
||||
compile_PBS_file_generic(GameData::Species, path) do |final_validate, hash|
|
||||
def compile_pokemon(*paths)
|
||||
compile_PBS_file_generic(GameData::Species, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_pokemon : validate_compiled_pokemon(hash)
|
||||
end
|
||||
end
|
||||
@@ -361,21 +371,26 @@ module Compiler
|
||||
# NOTE: Doesn't use compile_PBS_file_generic because it needs its own schema
|
||||
# and shouldn't clear GameData::Species at the start.
|
||||
#=============================================================================
|
||||
def compile_pokemon_forms(path = "PBS/pokemon_forms.txt")
|
||||
def compile_pokemon_forms(*paths)
|
||||
schema = GameData::Species.schema(true)
|
||||
# Read from PBS file(s)
|
||||
paths.each do |path|
|
||||
compile_pbs_file_message_start(path)
|
||||
# Read from PBS file
|
||||
file_suffix = File.basename(path, ".txt")[GameData::Species::PBS_BASE_FILENAME[1].length + 1, path.length] || ""
|
||||
File.open(path, "rb") { |f|
|
||||
FileLineData.file = path # For error reporting
|
||||
# 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
|
||||
# the keys are the XXX and the values are the YYY (as unprocessed strings).
|
||||
schema = GameData::Species.schema(true)
|
||||
idx = 0
|
||||
pbEachFileSection(f, schema) { |contents, section_name|
|
||||
echo "." if idx % 50 == 0
|
||||
Graphics.update if idx % 250 == 0
|
||||
idx += 1
|
||||
data_hash = {:id => section_name.to_sym}
|
||||
data_hash = {
|
||||
:id => section_name.to_sym,
|
||||
:pbs_file_suffix => file_suffix
|
||||
}
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
schema.each_key do |key|
|
||||
FileLineData.setSection(section_name, key, contents[key]) # For error reporting
|
||||
@@ -409,10 +424,11 @@ module Compiler
|
||||
GameData::Species.register(data_hash)
|
||||
}
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
validate_all_compiled_pokemon_forms
|
||||
# Save all data
|
||||
GameData::Species.save
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
|
||||
def validate_compiled_pokemon_form(hash)
|
||||
@@ -491,8 +507,8 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile Pokémon metrics data
|
||||
#=============================================================================
|
||||
def compile_pokemon_metrics(path = "PBS/pokemon_metrics.txt")
|
||||
compile_PBS_file_generic(GameData::SpeciesMetrics, path) do |final_validate, hash|
|
||||
def compile_pokemon_metrics(*paths)
|
||||
compile_PBS_file_generic(GameData::SpeciesMetrics, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_pokemon_metrics : validate_compiled_pokemon_metrics(hash)
|
||||
end
|
||||
end
|
||||
@@ -516,8 +532,8 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile Shadow Pokémon data
|
||||
#=============================================================================
|
||||
def compile_shadow_pokemon(path = "PBS/shadow_pokemon.txt")
|
||||
compile_PBS_file_generic(GameData::ShadowPokemon, path) do |final_validate, hash|
|
||||
def compile_shadow_pokemon(*paths)
|
||||
compile_PBS_file_generic(GameData::ShadowPokemon, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_shadow_pokemon : validate_compiled_shadow_pokemon(hash)
|
||||
end
|
||||
end
|
||||
@@ -531,9 +547,10 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile Regional Dexes
|
||||
#=============================================================================
|
||||
def compile_regional_dexes(path = "PBS/regional_dexes.txt")
|
||||
compile_pbs_file_message_start(path)
|
||||
def compile_regional_dexes(*paths)
|
||||
dex_lists = []
|
||||
paths.each do |path|
|
||||
compile_pbs_file_message_start(path)
|
||||
section = nil
|
||||
pbCompilerEachPreppedLine(path) { |line, line_no|
|
||||
Graphics.update if line_no % 200 == 0
|
||||
@@ -553,6 +570,8 @@ module Compiler
|
||||
end
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
# Check for duplicate species in a Regional Dex
|
||||
dex_lists.each_with_index do |list, index|
|
||||
unique_list = list.uniq
|
||||
@@ -564,14 +583,13 @@ module Compiler
|
||||
end
|
||||
# Save all data
|
||||
save_data(dex_lists, "Data/regional_dexes.dat")
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Compile ribbon data
|
||||
#=============================================================================
|
||||
def compile_ribbons(path = "PBS/ribbons.txt")
|
||||
compile_PBS_file_generic(GameData::Ribbon, path) do |final_validate, hash|
|
||||
def compile_ribbons(*paths)
|
||||
compile_PBS_file_generic(GameData::Ribbon, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_ribbons : validate_compiled_ribbon(hash)
|
||||
end
|
||||
end
|
||||
@@ -594,13 +612,15 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile wild encounter data
|
||||
#=============================================================================
|
||||
def compile_encounters(path = "PBS/encounters.txt")
|
||||
compile_pbs_file_message_start(path)
|
||||
def compile_encounters(*paths)
|
||||
GameData::Encounter::DATA.clear
|
||||
max_level = GameData::GrowthRate.max_level
|
||||
paths.each do |path|
|
||||
compile_pbs_file_message_start(path)
|
||||
file_suffix = File.basename(path, ".txt")[GameData::Encounter::PBS_BASE_FILENAME.length + 1, path.length] || ""
|
||||
encounter_hash = nil
|
||||
step_chances = nil
|
||||
current_type = nil
|
||||
max_level = GameData::GrowthRate.max_level
|
||||
idx = 0
|
||||
pbCompilerEachPreppedLine(path) { |line, line_no|
|
||||
echo "." if idx % 50 == 0
|
||||
@@ -658,7 +678,8 @@ module Compiler
|
||||
:map => map_number,
|
||||
:version => map_version,
|
||||
:step_chances => step_chances,
|
||||
:types => {}
|
||||
:types => {},
|
||||
:pbs_file_suffix => file_suffix
|
||||
}
|
||||
current_type = nil
|
||||
elsif !encounter_hash # File began with something other than a map ID line
|
||||
@@ -695,16 +716,17 @@ module Compiler
|
||||
end
|
||||
GameData::Encounter.register(encounter_hash)
|
||||
end
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
# Save all data
|
||||
GameData::Encounter.save
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Compile trainer type data
|
||||
#=============================================================================
|
||||
def compile_trainer_types(path = "PBS/trainer_types.txt")
|
||||
compile_PBS_file_generic(GameData::TrainerType, path) do |final_validate, hash|
|
||||
def compile_trainer_types(*paths)
|
||||
compile_PBS_file_generic(GameData::TrainerType, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_trainer_types : validate_compiled_trainer_type(hash)
|
||||
end
|
||||
end
|
||||
@@ -724,13 +746,15 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile individual trainer data
|
||||
#=============================================================================
|
||||
def compile_trainers(path = "PBS/trainers.txt")
|
||||
compile_pbs_file_message_start(path)
|
||||
def compile_trainers(*paths)
|
||||
GameData::Trainer::DATA.clear
|
||||
schema = GameData::Trainer.schema
|
||||
max_level = GameData::GrowthRate.max_level
|
||||
trainer_names = []
|
||||
trainer_lose_texts = []
|
||||
paths.each do |path|
|
||||
compile_pbs_file_message_start(path)
|
||||
file_suffix = File.basename(path, ".txt")[GameData::Trainer::PBS_BASE_FILENAME.length + 1, path.length] || ""
|
||||
trainer_hash = nil
|
||||
current_pkmn = nil
|
||||
# Read each line of trainers.txt at a time and compile it as a trainer property
|
||||
@@ -755,7 +779,8 @@ module Compiler
|
||||
:trainer_type => line_data[0],
|
||||
:name => line_data[1],
|
||||
:version => line_data[2] || 0,
|
||||
:pokemon => []
|
||||
:pokemon => [],
|
||||
:pbs_file_suffix => file_suffix
|
||||
}
|
||||
current_pkmn = nil
|
||||
trainer_names.push(trainer_hash[:name])
|
||||
@@ -844,11 +869,12 @@ module Compiler
|
||||
trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]]
|
||||
GameData::Trainer.register(trainer_hash)
|
||||
end
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
# Save all data
|
||||
GameData::Trainer.save
|
||||
MessageTypes.setMessagesAsHash(MessageTypes::TrainerNames, trainer_names)
|
||||
MessageTypes.setMessagesAsHash(MessageTypes::TrainerLoseText, trainer_lose_texts)
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -973,25 +999,30 @@ module Compiler
|
||||
# NOTE: Doesn't use compile_PBS_file_generic because it contains data for two
|
||||
# different GameData classes.
|
||||
#=============================================================================
|
||||
def compile_metadata(path = "PBS/metadata.txt")
|
||||
compile_pbs_file_message_start(path)
|
||||
def compile_metadata(*paths)
|
||||
GameData::Metadata::DATA.clear
|
||||
GameData::PlayerMetadata::DATA.clear
|
||||
global_schema = GameData::Metadata.schema
|
||||
player_schema = GameData::PlayerMetadata.schema
|
||||
paths.each do |path|
|
||||
compile_pbs_file_message_start(path)
|
||||
file_suffix = File.basename(path, ".txt")[GameData::Metadata::PBS_BASE_FILENAME.length + 1, path.length] || ""
|
||||
# Read from PBS file
|
||||
File.open(path, "rb") { |f|
|
||||
FileLineData.file = path # For error reporting
|
||||
# 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
|
||||
# the keys are the XXX and the values are the YYY (as unprocessed strings).
|
||||
global_schema = GameData::Metadata.schema
|
||||
player_schema = GameData::PlayerMetadata.schema
|
||||
idx = 0
|
||||
pbEachFileSection(f) { |contents, section_name|
|
||||
echo "." if idx % 50 == 0
|
||||
Graphics.update if idx % 250 == 0
|
||||
idx += 1
|
||||
schema = (section_name.to_i == 0) ? global_schema : player_schema
|
||||
data_hash = {:id => section_name.to_sym}
|
||||
data_hash = {
|
||||
:id => section_name.to_sym,
|
||||
:pbs_file_suffix => file_suffix
|
||||
}
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
schema.each_key do |key|
|
||||
FileLineData.setSection(section_name, key, contents[key]) # For error reporting
|
||||
@@ -1036,11 +1067,12 @@ module Compiler
|
||||
end
|
||||
}
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
validate_all_compiled_metadata
|
||||
# Save all data
|
||||
GameData::Metadata.save
|
||||
GameData::PlayerMetadata.save
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
|
||||
def validate_compiled_global_metadata(hash)
|
||||
@@ -1064,14 +1096,14 @@ module Compiler
|
||||
end
|
||||
# Get storage creator's name for translating
|
||||
storage_creator = [GameData::Metadata.get.real_storage_creator]
|
||||
MessageTypes.setMessages(MessageTypes::StorageCreator, storage_creator)
|
||||
MessageTypes.setMessagesAsHash(MessageTypes::StorageCreator, storage_creator)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Compile map metadata
|
||||
#=============================================================================
|
||||
def compile_map_metadata(path = "PBS/map_metadata.txt")
|
||||
compile_PBS_file_generic(GameData::MapMetadata, path) do |final_validate, hash|
|
||||
def compile_map_metadata(*paths)
|
||||
compile_PBS_file_generic(GameData::MapMetadata, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_map_metadata : validate_compiled_map_metadata(hash)
|
||||
end
|
||||
end
|
||||
@@ -1093,8 +1125,8 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile dungeon tileset data
|
||||
#=============================================================================
|
||||
def compile_dungeon_tilesets(path = "PBS/dungeon_tilesets.txt")
|
||||
compile_PBS_file_generic(GameData::DungeonTileset, path) do |final_validate, hash|
|
||||
def compile_dungeon_tilesets(*paths)
|
||||
compile_PBS_file_generic(GameData::DungeonTileset, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_dungeon_tilesets : validate_compiled_dungeon_tileset(hash)
|
||||
end
|
||||
end
|
||||
@@ -1108,8 +1140,8 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile dungeon parameters data
|
||||
#=============================================================================
|
||||
def compile_dungeon_parameters(path = "PBS/dungeon_parameters.txt")
|
||||
compile_PBS_file_generic(GameData::DungeonParameters, path) do |final_validate, hash|
|
||||
def compile_dungeon_parameters(*paths)
|
||||
compile_PBS_file_generic(GameData::DungeonParameters, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_dungeon_parameters : validate_compiled_dungeon_parameters(hash)
|
||||
end
|
||||
end
|
||||
@@ -1134,8 +1166,8 @@ module Compiler
|
||||
#=============================================================================
|
||||
# Compile phone messages
|
||||
#=============================================================================
|
||||
def compile_phone(path = "PBS/phone.txt")
|
||||
compile_PBS_file_generic(GameData::PhoneMessage, path) do |final_validate, hash|
|
||||
def compile_phone(*paths)
|
||||
compile_PBS_file_generic(GameData::PhoneMessage, *paths) do |final_validate, hash|
|
||||
(final_validate) ? validate_all_compiled_phone_contacts : validate_compiled_phone_contact(hash)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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,13 +20,20 @@ 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|
|
||||
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("[")
|
||||
@@ -43,12 +62,13 @@ module Compiler
|
||||
}
|
||||
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,13 +171,27 @@ 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|
|
||||
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("[")
|
||||
@@ -186,20 +220,38 @@ module Compiler
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save Pokémon forms data to PBS file
|
||||
# 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|
|
||||
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("[")
|
||||
@@ -228,6 +280,7 @@ module Compiler
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Write species metrics
|
||||
@@ -235,13 +288,27 @@ 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|
|
||||
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 &&
|
||||
@@ -250,6 +317,9 @@ module Compiler
|
||||
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("[")
|
||||
@@ -278,12 +348,13 @@ module Compiler
|
||||
}
|
||||
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,34 +392,37 @@ 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
|
||||
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 |encounter_data|
|
||||
GameData::Encounter.each do |element|
|
||||
next if element.pbs_file_suffix != path[1]
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
idx += 1
|
||||
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))
|
||||
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("[%03d]%s\r\n", encounter_data.map, map_name))
|
||||
f.write(sprintf("[%03d]%s\r\n", element.map, map_name))
|
||||
end
|
||||
encounter_data.types.each do |type, slots|
|
||||
element.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]))
|
||||
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("%s\r\n", type.to_s))
|
||||
end
|
||||
@@ -364,37 +438,41 @@ module Compiler
|
||||
}
|
||||
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|
|
||||
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 |trainer|
|
||||
GameData::Trainer.each do |element|
|
||||
next if element.pbs_file_suffix != path[1]
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
idx += 1
|
||||
f.write("\#-------------------------------\r\n")
|
||||
if trainer.version > 0
|
||||
f.write(sprintf("[%s,%s,%d]\r\n", trainer.trainer_type, trainer.real_name, trainer.version))
|
||||
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", trainer.trainer_type, trainer.real_name))
|
||||
f.write(sprintf("[%s,%s]\r\n", element.trainer_type, element.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))
|
||||
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
|
||||
trainer.pokemon.each do |pkmn|
|
||||
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
|
||||
@@ -423,6 +501,7 @@ module Compiler
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save trainer list data to PBS file
|
||||
@@ -542,17 +621,32 @@ 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|
|
||||
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("[")
|
||||
@@ -582,23 +676,27 @@ module Compiler
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save map metadata data to PBS file
|
||||
# NOTE: Doesn't use write_PBS_file_generic because it writes the RMXP map name
|
||||
# next to the section header for each map.
|
||||
#=============================================================================
|
||||
def write_map_metadata(path = "PBS/map_metadata.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
def write_map_metadata
|
||||
paths = get_all_PBS_file_paths(GameData::MapMetadata)
|
||||
map_infos = pbLoadMapInfos
|
||||
schema = GameData::MapMetadata.schema
|
||||
File.open(path, "wb") { |f|
|
||||
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
|
||||
idx += 1
|
||||
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))
|
||||
@@ -624,20 +722,24 @@ module Compiler
|
||||
}
|
||||
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(path = "PBS/dungeon_tilesets.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
tilesets = load_data("Data/Tilesets.rxdata")
|
||||
def write_dungeon_tilesets
|
||||
paths = get_all_PBS_file_paths(GameData::DungeonTileset)
|
||||
schema = GameData::DungeonTileset.schema
|
||||
File.open(path, "wb") { |f|
|
||||
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("[")
|
||||
@@ -668,19 +770,20 @@ module Compiler
|
||||
}
|
||||
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