Added PBS schema character ^ for repeated lines, more refactoring of PBS compilers/writers

This commit is contained in:
Maruno17
2022-11-20 20:15:04 +00:00
parent 1ff7307868
commit f33eb4d896
19 changed files with 516 additions and 934 deletions

View File

@@ -6,6 +6,10 @@ module GameData
# For data that is known by a symbol or an ID number.
#=============================================================================
module ClassMethods
def schema
return self::SCHEMA
end
def register(hash)
self::DATA[hash[:id]] = self::DATA[hash[:id_number]] = self.new(hash)
end
@@ -72,6 +76,10 @@ module GameData
# For data that is only known by a symbol.
#=============================================================================
module ClassMethodsSymbols
def schema
return self::SCHEMA
end
def register(hash)
self::DATA[hash[:id]] = self.new(hash)
end
@@ -143,6 +151,10 @@ module GameData
# For data that is only known by an ID number.
#=============================================================================
module ClassMethodsIDNumbers
def schema
return self::SCHEMA
end
def register(hash)
self::DATA[hash[:id]] = self.new(hash)
end
@@ -222,7 +234,7 @@ module GameData
def get_property_for_PBS(key)
ret = nil
if self.class::SCHEMA.include?(key)
if self.class::SCHEMA.include?(key) && self.respond_to?(self.class::SCHEMA[key][0])
ret = self.send(self.class::SCHEMA[key][0])
ret = nil if ret == false || (ret.is_a?(Array) && ret.length == 0)
end

View File

@@ -812,7 +812,7 @@ module GameData
return data
end
alias __orig__get_property_for_PBS get_property_for_PBS
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)
def get_property_for_PBS(key)
ret = __orig__get_property_for_PBS(key)
ret = nil if ["Power", "Priority", "EffectChance"].include?(key) && ret == 0

View File

@@ -193,7 +193,7 @@ module GameData
return combos[species]&.include?(@id)
end
alias __orig__get_property_for_PBS get_property_for_PBS
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)
def get_property_for_PBS(key)
ret = __orig__get_property_for_PBS(key)
case key

View File

@@ -342,7 +342,7 @@ module GameData
return 1
end
alias __orig__get_property_for_PBS get_property_for_PBS
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)
def get_property_for_PBS(key, writing_form = false)
ret = nil
if self.class.schema(writing_form).include?(key)

View File

@@ -85,7 +85,7 @@ module GameData
# return @front_sprite_altitude > 0
end
alias __orig__get_property_for_PBS get_property_for_PBS
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)
def get_property_for_PBS(key)
ret = __orig__get_property_for_PBS(key)
case key

View File

@@ -104,7 +104,7 @@ module GameData
return @flags.any? { |f| f.downcase == flag.downcase }
end
alias __orig__get_property_for_PBS get_property_for_PBS
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)
def get_property_for_PBS(key)
ret = __orig__get_property_for_PBS(key)
ret = nil if key == "SkillLevel" && ret == @base_money

View File

@@ -74,22 +74,5 @@ module GameData
ret = pbGetMessage(MessageTypes::StorageCreator, 0)
return nil_or_empty?(ret) ? _INTL("Bill") : ret
end
def property_from_string(str)
case str
when "StartMoney" then return @start_money
when "StartItemStorage" then return @start_item_storage
when "Home" then return @home
when "StorageCreator" then return @real_storage_creator
when "WildBattleBGM" then return @wild_battle_BGM
when "TrainerBattleBGM" then return @trainer_battle_BGM
when "WildVictoryBGM" then return @wild_victory_BGM
when "TrainerVictoryBGM" then return @trainer_victory_BGM
when "WildCaptureME" then return @wild_capture_ME
when "SurfBGM" then return @surf_BGM
when "BicycleBGM" then return @bicycle_BGM
end
return nil
end
end
end

View File

@@ -82,20 +82,5 @@ module GameData
def surf_fish_charset
return @surf_fish_charset || fish_charset
end
def property_from_string(str)
case str
when "TrainerType" then return @trainer_type
when "WalkCharset" then return @walk_charset
when "RunCharset" then return @run_charset
when "CycleCharset" then return @cycle_charset
when "SurfCharset" then return @surf_charset
when "DiveCharset" then return @dive_charset
when "FishCharset" then return @fish_charset
when "SurfFishCharset" then return @surf_fish_charset
when "Home" then return @home
end
return nil
end
end
end

View File

@@ -109,34 +109,6 @@ module GameData
@flags = hash[:flags] || []
end
def property_from_string(str)
case str
when "Name" then return @real_name
when "Outdoor" then return @outdoor_map
when "ShowArea" then return @announce_location
when "Bicycle" then return @can_bicycle
when "BicycleAlways" then return @always_bicycle
when "HealingSpot" then return @teleport_destination
when "Weather" then return @weather
when "MapPosition" then return @town_map_position
when "DiveMap" then return @dive_map_id
when "DarkMap" then return @dark_map
when "SafariMap" then return @safari_map
when "SnapEdges" then return @snap_edges
when "Dungeon" then return @random_dungeon
when "BattleBack" then return @battle_background
when "WildBattleBGM" then return @wild_battle_BGM
when "TrainerBattleBGM" then return @trainer_battle_BGM
when "WildVictoryBGM" then return @wild_victory_BGM
when "TrainerVictoryBGM" then return @trainer_victory_BGM
when "WildCaptureME" then return @wild_capture_ME
when "MapSize" then return @town_map_size
when "Environment" then return @battle_environment
when "Flags" then return @flags
end
return nil
end
# @return [String] the translated name of this map
def name
return pbGetMapNameFromId(@id)

View File

@@ -15,8 +15,9 @@ module GameData
DATA_FILENAME = "dungeon_tilesets.dat"
SCHEMA = {
"Autotile" => [:autotile, "um"],
"Tile" => [:tile, "um"],
"SectionName" => [:id, "u"],
"Autotile" => [:autotile, "^um"],
"Tile" => [:tile, "^um"],
"SnapToLargeGrid" => [:snap_to_large_grid, "b"],
"LargeVoidTiles" => [:large_void_tiles, "b"],
"LargeWallTiles" => [:large_wall_tiles, "b"],
@@ -192,18 +193,27 @@ module GameData
return ret
end
def property_from_string(str)
case str
when "SnapToLargeGrid" then return @snap_to_large_grid
when "LargeVoidTiles" then return @large_void_tiles
when "LargeWallTiles" then return @large_wall_tiles
when "LargeFloorTiles" then return @large_floor_tiles
when "DoubleWalls" then return @double_walls
when "FloorPatchUnderWalls" then return @floor_patch_under_walls
when "ThinNorthWallOffset" then return @thin_north_wall_offset
when "Flags" then return @flags
end
return nil
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)
def get_property_for_PBS(key)
ret = __orig__get_property_for_PBS(key)
case key
when "ThinNorthWallOffset"
ret = nil if ret == 0
when "Tile", "Autotile"
ret = []
@tile_type_ids.each do |tile_type, tile_ids|
tile_ids.each do |tile|
case key
when "Tile"
ret.push([tile[0] - 384, tile_type]) if !tile[1] && tile[0] >= 384
when "Autotile"
ret.push([tile[0] / 48, tile_type]) if !tile[1] && tile[0] < 384
end
end
end
ret = nil if ret.length == 0
end
return ret
end
end
end

View File

@@ -115,7 +115,7 @@ module GameData
return width, height
end
alias __orig__get_property_for_PBS get_property_for_PBS
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)
def get_property_for_PBS(key)
case key
when "SectionName" then return [@area, (@version > 0) ? @version : nil]

View File

@@ -11,29 +11,36 @@ module GameData
DATA_FILENAME = "phone.dat"
SCHEMA = {
"Intro" => [:intro, "q"],
"IntroMorning" => [:intro_morning, "q"],
"IntroAfternoon" => [:intro_afternoon, "q"],
"IntroEvening" => [:intro_evening, "q"],
"Body" => [:body, "q"],
"Body1" => [:body1, "q"],
"Body2" => [:body2, "q"],
"BattleRequest" => [:battle_request, "q"],
"BattleRemind" => [:battle_remind, "q"],
"End" => [:end, "q"]
"SectionName" => [:id, "q"],
"Intro" => [:intro, "^q"],
"IntroMorning" => [:intro_morning, "^q"],
"IntroAfternoon" => [:intro_afternoon, "^q"],
"IntroEvening" => [:intro_evening, "^q"],
"Body1" => [:body1, "^q"],
"Body2" => [:body2, "^q"],
"Body" => [:body, "^q"],
"BattleRequest" => [:battle_request, "^q"],
"BattleRemind" => [:battle_remind, "^q"],
"End" => [:end, "^q"]
}
extend ClassMethodsSymbols
include InstanceMethods
# @param tr_type [Symbol, String]
# @param tr_name [String]
# @param tr_name [String, nil] only nil for the default message set
# @param tr_version [Integer, nil]
# @return [Boolean] whether the given other is defined as a self
def self.exists?(tr_type, tr_name, tr_version = 0)
def self.exists?(tr_type, tr_name = nil, tr_version = 0)
if tr_type.is_a?(Array)
tr_name = tr_type[1]
tr_version = tr_type[2]
tr_type = tr_type[0]
end
validate tr_type => [Symbol, String]
validate tr_name => [String]
validate tr_name => [String, NilClass]
key = [tr_type.to_sym, tr_name, tr_version]
key = key[0] if key[1] == nil
return !self::DATA[key].nil?
end
@@ -63,7 +70,7 @@ module GameData
def initialize(hash)
@id = hash[:id]
@trainer_type = hash[:trainer_type]
@real_name = hash[:name]
@real_name = hash[:real_name]
@version = hash[:version] || 0
@intro = hash[:intro]
@intro_morning = hash[:intro_morning]
@@ -77,20 +84,14 @@ module GameData
@end = hash[:end]
end
def property_from_string(str)
case str
when "Intro" then return @intro
when "IntroMorning" then return @intro_morning
when "IntroAfternoon" then return @intro_afternoon
when "IntroEvening" then return @intro_evening
when "Body" then return @body
when "Body1" then return @body1
when "Body2" then return @body2
when "BattleRequest" then return @battle_request
when "BattleRemind" then return @battle_remind
when "End" then return @end
alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS)
def get_property_for_PBS(key)
if key == "SectionName"
return "Default" if @id == "default"
ret = [@trainer_type, @real_name, (@version > 0) ? @version : nil]
return ret.compact.join(",")
end
return nil
return __orig__get_property_for_PBS(key)
end
end
end

View File

@@ -345,7 +345,7 @@ end
#===============================================================================
def pbTrainerTypeEditor
gender_array = []
GameData::TrainerType::SCHEMA["Gender"][2].each { |key, value| gender_array[value] = key if !gender_array[value] }
GameData::TrainerType.schema["Gender"][2].each { |key, value| gender_array[value] = key if !gender_array[value] }
trainer_type_properties = [
[_INTL("ID"), ReadOnlyProperty, _INTL("ID of this Trainer Type (used as a symbol like :XXX).")],
[_INTL("Name"), StringProperty, _INTL("Name of this Trainer Type as displayed by the game.")],
@@ -732,7 +732,9 @@ def pbEditMetadata
metadata = GameData::Metadata.get
properties = GameData::Metadata.editor_properties
properties.each do |property|
data.push(metadata.property_from_string(property[0]))
val = metadata.get_property_for_PBS(property[0])
val = property[1].defaultValue if val.nil? && property[1].respond_to?(:defaultValue)
data.push(val)
end
if pbPropertyList(_INTL("Global Metadata"), data, properties, true)
# Construct metadata hash
@@ -741,7 +743,7 @@ def pbEditMetadata
:start_money => data[0],
:start_item_storage => data[1],
:home => data[2],
:storage_creator => data[3],
:real_storage_creator => data[3],
:wild_battle_BGM => data[4],
:trainer_battle_BGM => data[5],
:wild_victory_BGM => data[6],
@@ -776,7 +778,9 @@ def pbEditPlayerMetadata(player_id = 1)
metadata = GameData::PlayerMetadata.try_get(player_id) if metadata.nil?
properties = GameData::PlayerMetadata.editor_properties
properties.each do |property|
data.push(metadata.property_from_string(property[0]))
val = metadata.get_property_for_PBS(property[0])
val = property[1].defaultValue if val.nil? && property[1].respond_to?(:defaultValue)
data.push(val)
end
if pbPropertyList(_INTL("Player {1}", metadata.id), data, properties, true)
# Construct player metadata hash
@@ -789,7 +793,8 @@ def pbEditPlayerMetadata(player_id = 1)
:surf_charset => data[4],
:dive_charset => data[5],
:fish_charset => data[6],
:surf_fish_charset => data[7]
:surf_fish_charset => data[7],
:home => data[8]
}
# Add player metadata's data to records
GameData::PlayerMetadata.register(metadata_hash)
@@ -819,13 +824,15 @@ def pbEditMapMetadata(map_id)
metadata = GameData::MapMetadata.new({ :id => map_id }) if !metadata
properties = GameData::MapMetadata.editor_properties
properties.each do |property|
data.push(metadata.property_from_string(property[0]))
val = metadata.get_property_for_PBS(property[0])
val = property[1].defaultValue if val.nil? && property[1].respond_to?(:defaultValue)
data.push(val)
end
if pbPropertyList(map_name, data, properties, true)
# Construct map metadata hash
metadata_hash = {
:id => map_id,
:name => data[0],
:real_name => data[0],
:outdoor_map => data[1],
:announce_location => data[2],
:can_bicycle => data[3],
@@ -862,9 +869,9 @@ end
#===============================================================================
def pbItemEditor
field_use_array = [_INTL("Can't use in field")]
GameData::Item::SCHEMA["FieldUse"][2].each { |key, value| field_use_array[value] = key if !field_use_array[value] }
GameData::Item.schema["FieldUse"][2].each { |key, value| field_use_array[value] = key if !field_use_array[value] }
battle_use_array = [_INTL("Can't use in battle")]
GameData::Item::SCHEMA["BattleUse"][2].each { |key, value| battle_use_array[value] = key if !battle_use_array[value] }
GameData::Item.schema["BattleUse"][2].each { |key, value| battle_use_array[value] = key if !battle_use_array[value] }
item_properties = [
[_INTL("ID"), ReadOnlyProperty, _INTL("ID of this item (used as a symbol like :XXX).")],
[_INTL("Name"), ItemNameProperty, _INTL("Name of this item as displayed by the game.")],

View File

@@ -240,7 +240,7 @@ class StringListProperty
def self.set(_setting_name, old_setting)
real_cmds = []
real_cmds.push([_INTL("[ADD VALUE]"), -1])
old_setting.length.times do
old_setting.length.times do |i|
real_cmds.push([old_setting[i], 0])
end
# Edit list

View File

@@ -92,7 +92,7 @@ module Compiler
#=============================================================================
# PBS file readers
#=============================================================================
def pbEachFileSectionEx(f)
def pbEachFileSectionEx(f, schema = nil)
lineno = 1
havesection = false
sectionname = nil
@@ -120,9 +120,14 @@ module Compiler
end
r1 = $~[1]
r2 = $~[2]
if schema && schema[r1] && schema[r1][1][0] == "^"
lastsection[r1] ||= []
lastsection[r1].push(r2.gsub(/\s+$/, ""))
else
lastsection[r1] = r2.gsub(/\s+$/, "")
end
end
end
lineno += 1
Graphics.update if lineno % 1000 == 0
}
@@ -133,15 +138,15 @@ module Compiler
# pokemon.txt, pokemon_forms.txt, pokemon_metrics.txt, shadow_pokemon.txt,
# ribbons.txt, trainer_types.txt, battle_facility_lists.txt, Battle Tower
# trainers PBS files and dungeon_parameters.txt
def pbEachFileSection(f)
pbEachFileSectionEx(f) { |section, name|
def pbEachFileSection(f, schema = nil)
pbEachFileSectionEx(f, schema) { |section, name|
yield section, name if block_given? && name[/^.+$/]
}
end
# Used for metadata.txt and map_metadata.txt
def pbEachFileSectionNumbered(f)
pbEachFileSectionEx(f) { |section, name|
def pbEachFileSectionNumbered(f, schema = nil)
pbEachFileSectionEx(f, schema) { |section, name|
yield section, name.to_i if block_given? && name[/^\d+$/]
}
end
@@ -401,10 +406,14 @@ module Compiler
def pbGetCsvRecord(rec, lineno, schema)
record = []
repeat = false
schema_length = schema[1].length
start = 0
if schema[1][0, 1] == "*"
repeat = true
start = 1
elsif schema[1][0, 1] == "^"
start = 1
schema_length -= 1
end
subarrays = repeat && schema[1].length > 2
loop do
@@ -560,7 +569,7 @@ module Compiler
break if repeat && nil_or_empty?(rec)
break unless repeat
end
return (!repeat && schema[1].length == 1) ? record[0] : record
return (!repeat && schema_length == 1) ? record[0] : record
end
#=============================================================================
@@ -568,7 +577,7 @@ module Compiler
#=============================================================================
def pbWriteCsvRecord(record, file, schema)
rec = (record.is_a?(Array)) ? record.flatten : [record]
start = (schema[1][0, 1] == "*") ? 1 : 0
start = (["*", "^"].include?(schema[1][0, 1])) ? 1 : 0
index = -1
loop do
(start...schema[1].length).each do |i|

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@ module Compiler
def write_PBS_file_generic(game_data, path)
write_pbs_file_message_start(path)
schema = game_data::SCHEMA
schema = game_data.schema
File.open(path, "wb") { |f|
add_PBS_header_to_file(f)
# Write each element in turn
@@ -27,11 +27,19 @@ module Compiler
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
}
process_pbs_file_message_end
end
@@ -40,28 +48,33 @@ module Compiler
# Save Town Map data to PBS file
#=============================================================================
def write_town_map(path = "PBS/town_map.txt")
mapdata = pbLoadTownMapData
return if !mapdata
write_pbs_file_message_start(path)
schema = {
"Name" => [0, "s"],
"Filename" => [1, "s"],
"Point" => [2, "^uussUUUU"]
}
File.open(path, "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
mapdata.length.times do |i|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
map = mapdata[i]
next if !map
# Write each element in turn
pbLoadTownMapData.each_with_index do |element, i|
f.write("\#-------------------------------\r\n")
f.write(sprintf("[%d]\r\n", i))
rname = pbGetMessage(MessageTypes::RegionNames, i)
f.write(sprintf("Name = %s\r\n", (rname && rname != "") ? rname : _INTL("Unnamed")))
f.write(sprintf("Filename = %s\r\n", csvQuote((map[1].is_a?(Array)) ? map[1][0] : map[1])))
map[2].each do |loc|
f.write("Point = ")
pbWriteCsvRecord(loc, f, [nil, "uussUUUU"])
schema.each_key do |key|
val = element[schema[key][0]]
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
}
process_pbs_file_message_end
@@ -131,28 +144,7 @@ module Compiler
# Save phone messages to PBS file
#=============================================================================
def write_phone(path = "PBS/phone.txt")
write_pbs_file_message_start(path)
keys = GameData::PhoneMessage::SCHEMA.keys
File.open(path, "wb") { |f|
add_PBS_header_to_file(f)
# Write message sets
GameData::PhoneMessage.each do |contact|
f.write("\#-------------------------------\r\n")
if contact.id == "default"
f.write("[Default]\r\n")
elsif contact.version > 0
f.write(sprintf("[%s,%s,%d]\r\n", contact.trainer_type, contact.real_name, contact.version))
else
f.write(sprintf("[%s,%s]\r\n", contact.trainer_type, contact.real_name))
end
keys.each do |key|
msgs = contact.property_from_string(key)
next if !msgs || msgs.length == 0
msgs.each { |msg| f.write(key + " = " + msg + "\r\n") }
end
end
}
process_pbs_file_message_end
write_PBS_file_generic(GameData::PhoneMessage, path)
end
#=============================================================================
@@ -192,6 +184,8 @@ module Compiler
#=============================================================================
# Save Pokémon data to PBS file
# 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)
@@ -212,17 +206,27 @@ module Compiler
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
}
process_pbs_file_message_end
end
#=============================================================================
# Save 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)
@@ -244,21 +248,32 @@ module Compiler
next if key == "SectionName"
val = element.get_property_for_PBS(key, true)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
}
process_pbs_file_message_end
end
#=============================================================================
# Write species metrics
# NOTE: Doesn't use write_PBS_file_generic because it needs to ignore defined
# 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)
schema = GameData::SpeciesMetrics::SCHEMA
schema = GameData::SpeciesMetrics.schema
File.open(path, "wb") { |f|
add_PBS_header_to_file(f)
# Write each element in turn
@@ -270,10 +285,6 @@ module Compiler
element.front_sprite_altitude == base_element.front_sprite_altitude &&
element.shadow_x == base_element.shadow_x &&
element.shadow_size == base_element.shadow_size
else
next if element.back_sprite == [0, 0] && element.front_sprite == [0, 0] &&
element.front_sprite_altitude == 0 &&
element.shadow_x == 0 && element.shadow_size == 2
end
f.write("\#-------------------------------\r\n")
if schema["SectionName"]
@@ -287,11 +298,19 @@ module Compiler
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
}
process_pbs_file_message_end
end
@@ -556,11 +575,13 @@ module Compiler
#=============================================================================
# Save metadata data to PBS file
# 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)
global_schema = GameData::Metadata::SCHEMA
player_schema = GameData::PlayerMetadata::SCHEMA
global_schema = GameData::Metadata.schema
player_schema = GameData::PlayerMetadata.schema
File.open(path, "wb") { |f|
add_PBS_header_to_file(f)
# Write each element in turn
@@ -580,23 +601,33 @@ module Compiler
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
end
}
process_pbs_file_message_end
end
#=============================================================================
# Save map metadata data to PBS file
# NOTE: Doesn't use write_PBS_file_generic because it writes the RMXP map name
# next to the section header for each map.
#=============================================================================
def write_map_metadata(path = "PBS/map_metadata.txt")
write_pbs_file_message_start(path)
map_infos = pbLoadMapInfos
schema = GameData::MapMetadata::SCHEMA
schema = GameData::MapMetadata.schema
File.open(path, "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
@@ -613,59 +644,59 @@ module Compiler
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
else
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end
end
}
process_pbs_file_message_end
end
#=============================================================================
# Save dungeon tileset contents data to PBS file
# NOTE: Doesn't use write_PBS_file_generic because it writes the tileset name
# next to the section header for each tileset.
#=============================================================================
def write_dungeon_tilesets(path = "PBS/dungeon_tilesets.txt")
write_pbs_file_message_start(path)
tilesets = load_data("Data/Tilesets.rxdata")
schema = GameData::DungeonTileset::SCHEMA
keys = schema.keys
schema = GameData::DungeonTileset.schema
File.open(path, "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
GameData::DungeonTileset.each do |tileset_data|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
# Write each element in turn
GameData::DungeonTileset.each do |element|
f.write("\#-------------------------------\r\n")
tileset_name = (tilesets && tilesets[tileset_data.id]) ? tilesets[tileset_data.id].name : nil
if tileset_name
f.write(sprintf("[%d] # %s\r\n", tileset_data.id, tileset_name))
if schema["SectionName"]
f.write("[")
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
f.write("]")
f.write(" # #{tilesets[element.id].name}") if tilesets && tilesets[element.id]
f.write("\r\n")
else
f.write(sprintf("[%d]\r\n", tileset_data.id))
end
keys.each do |key|
if ["Autotile", "Tile"].include?(key)
tiles = tileset_data.tile_type_ids
tiles.each do |tile_type, tile_ids|
tile_ids.each do |tile|
next if tile[1] # Tile was auto-generated from "walls" property
if tile[0] < 384
next if key == "Tile"
f.write(sprintf("Autotile = %i,%s", tile[0] / 48, tile_type.to_s))
else
next if key == "Autotile"
f.write(sprintf("Tile = %i,%s", tile[0] - 384, tile_type.to_s))
f.write("[#{element.id}]\r\n")
end
schema.each_key do |key|
next if key == "SectionName"
val = element.get_property_for_PBS(key)
next if val.nil?
if schema[key][1][0] == "^" && val.is_a?(Array)
val.each do |sub_val|
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(sub_val, f, schema[key])
f.write("\r\n")
end
end
else
record = tileset_data.property_from_string(key)
next if record.nil? || (record.is_a?(Array) && record.empty?)
next if record == false || record == 0
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(record, f, schema[key])
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
end

View File

@@ -28,7 +28,7 @@ Body1 = My \TP is looking more and more like me. It's getting cuter!
Body2 = And you know? Now we can KO \TE easily.\mI should challenge the Cedolan Gym.
Body2 = And you know? We just failed to beat \TE by a tiny margin.\mI'm guessing my Pokémon's levels aren't high enough yet...
BattleRequest = You must be a lot better now, huh?\mHow about showing me your technique in a real battle with me?\mI'll be waiting on \TM.
BattleReminder = Where are you? Let's have our battle soon!\mI'll be waiting on \TM.
BattleRemind = Where are you? Let's have our battle soon!\mI'll be waiting on \TM.
End = See you later!
#-------------------------------
[PICNICKER,Susie]
@@ -44,5 +44,5 @@ Body1 = My \TP and I are getting more in sync with each other.
Body2 = We battled a wild \TE and managed to beat it in a close match.\mWe're getting into the groove!
Body2 = But, you know what? I still haven't caught \TE.\mIt's getting beyond frustrating...
BattleRequest = Would you be my practice partner again sometime?\mI'll be waiting on \TM...\mCould you take it a little easier on me next time?
BattleReminder = How soon can I expect to see you?\mDon't forget, \TM!
BattleRemind = How soon can I expect to see you?\mDon't forget, \TM!
End = Bye! Let's chat again!

View File

@@ -3,34 +3,34 @@
[0]
Name = Essen
Filename = mapRegion0.png
Point = 13,12,Lappet Town,Oak's Lab,2,8,8,
Point = 13,11,Route 1,,,,,
Point = 13,10,Cedolan City,Cedolan Dept. Store,7,47,11,
Point = 14,10,Cedolan City,,7,47,11,
Point = 14,9,Route 2,,,,,
Point = 14,8,Route 2,,,,,
Point = 15,8,Lerucean Town,,23,11,15,
Point = 16,8,Natural Park,,,,,
Point = 15,7,Route 3,,,,,
Point = 15,6,Route 3,Ice Cave,,,,
Point = 14,6,Route 3,,,,,
Point = 13,6,Ingido Plateau,,35,17,7,
Point = 12,6,Route 4,,,,,
Point = 11,6,Route 4,,,,,
Point = 11,7,Route 5,Cycle Road,,,,
Point = 11,8,Route 5,Cycle Road,,,,
Point = 11,9,Route 5,Cycle Road,,,,
Point = 11,10,Route 6,,,,,
Point = 12,10,Route 6,,,,,
Point = 15,10,Route 7,,,,,
Point = 16,10,Route 7,Rock Cave,,,,
Point = 17,10,Battle Frontier,,52,17,14,
Point = 12,12,Safari Zone,,,,,
Point = 13,13,Route 8,Diving area,,,,
Point = 18,17,Berth Island,,,,,51
Point = 22,16,Faraday Island,,,,,52
Point = 13,12,Lappet Town,Oak's Lab,2,8,8
Point = 13,11,Route 1,
Point = 13,10,Cedolan City,Cedolan Dept. Store,7,47,11
Point = 14,10,Cedolan City,,7,47,11
Point = 14,9,Route 2,
Point = 14,8,Route 2,
Point = 15,8,Lerucean Town,,23,11,15
Point = 16,8,Natural Park,
Point = 15,7,Route 3,
Point = 15,6,Route 3,Ice Cave
Point = 14,6,Route 3,
Point = 13,6,Ingido Plateau,,35,17,7
Point = 12,6,Route 4,
Point = 11,6,Route 4,
Point = 11,7,Route 5,Cycle Road
Point = 11,8,Route 5,Cycle Road
Point = 11,9,Route 5,Cycle Road
Point = 11,10,Route 6,
Point = 12,10,Route 6,
Point = 15,10,Route 7,
Point = 16,10,Route 7,Rock Cave
Point = 17,10,Battle Frontier,,52,17,14
Point = 12,12,Safari Zone,
Point = 13,13,Route 8,Diving area
Point = 18,17,Berth Island,,51
Point = 22,16,Faraday Island,,52
#-------------------------------
[1]
Name = Tiall
Filename = mapRegion1.png
Point = 13,16,Here,,,,,
Point = 13,16,Here,