mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 05:34:58 +00:00
Turned Town Map PBS data into a GameData class
This commit is contained in:
@@ -246,6 +246,7 @@ module GameData
|
|||||||
# A bulk loader method for all data stored in .dat files in the Data folder.
|
# A bulk loader method for all data stored in .dat files in the Data folder.
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
def self.load_all
|
def self.load_all
|
||||||
|
TownMap.load
|
||||||
Type.load
|
Type.load
|
||||||
Ability.load
|
Ability.load
|
||||||
Move.load
|
Move.load
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
# Data caches.
|
# Data caches.
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class Game_Temp
|
class Game_Temp
|
||||||
attr_accessor :town_map_data
|
|
||||||
attr_accessor :regional_dexes_data
|
attr_accessor :regional_dexes_data
|
||||||
attr_accessor :battle_animations_data
|
attr_accessor :battle_animations_data
|
||||||
attr_accessor :move_to_battle_animation_data
|
attr_accessor :move_to_battle_animation_data
|
||||||
@@ -11,7 +10,6 @@ end
|
|||||||
|
|
||||||
def pbClearData
|
def pbClearData
|
||||||
if $game_temp
|
if $game_temp
|
||||||
$game_temp.town_map_data = nil
|
|
||||||
$game_temp.regional_dexes_data = nil
|
$game_temp.regional_dexes_data = nil
|
||||||
$game_temp.battle_animations_data = nil
|
$game_temp.battle_animations_data = nil
|
||||||
$game_temp.move_to_battle_animation_data = nil
|
$game_temp.move_to_battle_animation_data = nil
|
||||||
@@ -24,17 +22,6 @@ def pbClearData
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# Method to get Town Map data.
|
|
||||||
#===============================================================================
|
|
||||||
def pbLoadTownMapData
|
|
||||||
$game_temp = Game_Temp.new if !$game_temp
|
|
||||||
if !$game_temp.town_map_data
|
|
||||||
$game_temp.town_map_data = load_data("Data/town_map.dat")
|
|
||||||
end
|
|
||||||
return $game_temp.town_map_data
|
|
||||||
end
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Method to get Regional Dexes data.
|
# Method to get Regional Dexes data.
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
40
Data/Scripts/010_Data/002_PBS data/002_TownMap.rb
Normal file
40
Data/Scripts/010_Data/002_PBS data/002_TownMap.rb
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
module GameData
|
||||||
|
class TownMap
|
||||||
|
attr_reader :id
|
||||||
|
attr_reader :real_name
|
||||||
|
attr_reader :filename
|
||||||
|
attr_reader :point
|
||||||
|
attr_reader :flags
|
||||||
|
|
||||||
|
DATA = {}
|
||||||
|
DATA_FILENAME = "town_map.dat"
|
||||||
|
|
||||||
|
SCHEMA = {
|
||||||
|
"SectionName" => [:id, "u"],
|
||||||
|
"Name" => [:real_name, "s"],
|
||||||
|
"Filename" => [:filename, "s"],
|
||||||
|
"Point" => [:point, "^uussUUUU"],
|
||||||
|
"Flags" => [:flags, "*s"]
|
||||||
|
}
|
||||||
|
|
||||||
|
extend ClassMethodsIDNumbers
|
||||||
|
include InstanceMethods
|
||||||
|
|
||||||
|
def initialize(hash)
|
||||||
|
@id = hash[:id]
|
||||||
|
@real_name = hash[:real_name] || "???"
|
||||||
|
@filename = hash[:filename]
|
||||||
|
@point = hash[:point] || []
|
||||||
|
@flags = hash[:flags] || []
|
||||||
|
end
|
||||||
|
|
||||||
|
# @return [String] the translated name of this region
|
||||||
|
def name
|
||||||
|
return pbGetMessage(MessageTypes::RegionNames, @id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_flag?(flag)
|
||||||
|
return @flags.any? { |f| f.downcase == flag.downcase }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -17,13 +17,13 @@ class PokemonPokedexInfo_Scene
|
|||||||
@sprites["infosprite"].setOffset(PictureOrigin::CENTER)
|
@sprites["infosprite"].setOffset(PictureOrigin::CENTER)
|
||||||
@sprites["infosprite"].x = 104
|
@sprites["infosprite"].x = 104
|
||||||
@sprites["infosprite"].y = 136
|
@sprites["infosprite"].y = 136
|
||||||
@mapdata = pbLoadTownMapData
|
|
||||||
mappos = $game_map.metadata&.town_map_position
|
mappos = $game_map.metadata&.town_map_position
|
||||||
if @region < 0 # Use player's current region
|
if @region < 0 # Use player's current region
|
||||||
@region = (mappos) ? mappos[0] : 0 # Region 0 default
|
@region = (mappos) ? mappos[0] : 0 # Region 0 default
|
||||||
end
|
end
|
||||||
|
@mapdata = GameData::TownMap.get(@region)
|
||||||
@sprites["areamap"] = IconSprite.new(0, 0, @viewport)
|
@sprites["areamap"] = IconSprite.new(0, 0, @viewport)
|
||||||
@sprites["areamap"].setBitmap("Graphics/UI/Town Map/#{@mapdata[@region][1]}")
|
@sprites["areamap"].setBitmap("Graphics/UI/Town Map/#{@mapdata.filename}")
|
||||||
@sprites["areamap"].x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2
|
@sprites["areamap"].x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2
|
||||||
@sprites["areamap"].y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2
|
@sprites["areamap"].y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2
|
||||||
Settings::REGION_MAP_EXTRAS.each do |hidden|
|
Settings::REGION_MAP_EXTRAS.each do |hidden|
|
||||||
@@ -296,7 +296,7 @@ class PokemonPokedexInfo_Scene
|
|||||||
# defined point in town_map.txt, and which either have no Self Switch
|
# defined point in town_map.txt, and which either have no Self Switch
|
||||||
# controlling their visibility or whose Self Switch is ON)
|
# controlling their visibility or whose Self Switch is ON)
|
||||||
visible_points = []
|
visible_points = []
|
||||||
@mapdata[@region][2].each do |loc|
|
@mapdata.point.each do |loc|
|
||||||
next if loc[7] && !$game_switches[loc[7]] # Point is not visible
|
next if loc[7] && !$game_switches[loc[7]] # Point is not visible
|
||||||
visible_points.push([loc[0], loc[1]])
|
visible_points.push([loc[0], loc[1]])
|
||||||
end
|
end
|
||||||
@@ -375,7 +375,7 @@ class PokemonPokedexInfo_Scene
|
|||||||
)
|
)
|
||||||
textpos.push([_INTL("Area unknown"), Graphics.width / 2, (Graphics.height / 2) + 6, 2, base, shadow])
|
textpos.push([_INTL("Area unknown"), Graphics.width / 2, (Graphics.height / 2) + 6, 2, base, shadow])
|
||||||
end
|
end
|
||||||
textpos.push([pbGetMessage(MessageTypes::RegionNames, @region), 414, 50, 2, base, shadow])
|
textpos.push([@mapdata.name, 414, 50, 2, base, shadow])
|
||||||
textpos.push([_INTL("{1}'s area", GameData::Species.get(@species).name),
|
textpos.push([_INTL("{1}'s area", GameData::Species.get(@species).name),
|
||||||
Graphics.width / 2, 358, 2, base, shadow])
|
Graphics.width / 2, 358, 2, base, shadow])
|
||||||
pbDrawTextPositions(overlay, textpos)
|
pbDrawTextPositions(overlay, textpos)
|
||||||
|
|||||||
@@ -72,27 +72,26 @@ class PokemonRegionMap_Scene
|
|||||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||||
@viewport.z = 99999
|
@viewport.z = 99999
|
||||||
@sprites = {}
|
@sprites = {}
|
||||||
@map_data = pbLoadTownMapData
|
|
||||||
@fly_map = fly_map
|
@fly_map = fly_map
|
||||||
@mode = fly_map ? 1 : 0
|
@mode = fly_map ? 1 : 0
|
||||||
map_metadata = $game_map.metadata
|
map_metadata = $game_map.metadata
|
||||||
playerpos = (map_metadata) ? map_metadata.town_map_position : nil
|
playerpos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||||
if !playerpos
|
if !playerpos
|
||||||
mapindex = 0
|
mapindex = 0
|
||||||
@map = @map_data[0]
|
@map = GameData::TownMap.get(0)
|
||||||
@map_x = LEFT
|
@map_x = LEFT
|
||||||
@map_y = TOP
|
@map_y = TOP
|
||||||
elsif @region >= 0 && @region != playerpos[0] && @map_data[@region]
|
elsif @region >= 0 && @region != playerpos[0] && GameData::TownMap.exists?(@region)
|
||||||
mapindex = @region
|
mapindex = @region
|
||||||
@map = @map_data[@region]
|
@map = GameData::TownMap.get(@region)
|
||||||
@map_x = LEFT
|
@map_x = LEFT
|
||||||
@map_y = TOP
|
@map_y = TOP
|
||||||
else
|
else
|
||||||
mapindex = playerpos[0]
|
mapindex = playerpos[0]
|
||||||
@map = @map_data[playerpos[0]]
|
@map = GameData::TownMap.get(playerpos[0])
|
||||||
@map_x = playerpos[1]
|
@map_x = playerpos[1]
|
||||||
@map_y = playerpos[2]
|
@map_y = playerpos[2]
|
||||||
mapsize = map_metadata.town_map_size
|
mapsize = map_metadata.town_map_size
|
||||||
if mapsize && mapsize[0] && mapsize[0] > 0
|
if mapsize && mapsize[0] && mapsize[0] > 0
|
||||||
sqwidth = mapsize[0]
|
sqwidth = mapsize[0]
|
||||||
sqheight = (mapsize[1].length.to_f / mapsize[0]).ceil
|
sqheight = (mapsize[1].length.to_f / mapsize[0]).ceil
|
||||||
@@ -106,7 +105,7 @@ class PokemonRegionMap_Scene
|
|||||||
end
|
end
|
||||||
addBackgroundOrColoredPlane(@sprites, "background", "Town Map/bg", Color.black, @viewport)
|
addBackgroundOrColoredPlane(@sprites, "background", "Town Map/bg", Color.black, @viewport)
|
||||||
@sprites["map"] = IconSprite.new(0, 0, @viewport)
|
@sprites["map"] = IconSprite.new(0, 0, @viewport)
|
||||||
@sprites["map"].setBitmap("Graphics/UI/Town Map/#{@map[1]}")
|
@sprites["map"].setBitmap("Graphics/UI/Town Map/#{@map.filename}")
|
||||||
@sprites["map"].x += (Graphics.width - @sprites["map"].bitmap.width) / 2
|
@sprites["map"].x += (Graphics.width - @sprites["map"].bitmap.width) / 2
|
||||||
@sprites["map"].y += (Graphics.height - @sprites["map"].bitmap.height) / 2
|
@sprites["map"].y += (Graphics.height - @sprites["map"].bitmap.height) / 2
|
||||||
Settings::REGION_MAP_EXTRAS.each do |graphic|
|
Settings::REGION_MAP_EXTRAS.each do |graphic|
|
||||||
@@ -122,7 +121,7 @@ class PokemonRegionMap_Scene
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
@sprites["mapbottom"] = MapBottomSprite.new(@viewport)
|
@sprites["mapbottom"] = MapBottomSprite.new(@viewport)
|
||||||
@sprites["mapbottom"].mapname = pbGetMessage(MessageTypes::RegionNames, mapindex)
|
@sprites["mapbottom"].mapname = @map.name
|
||||||
@sprites["mapbottom"].maplocation = pbGetMapLocation(@map_x, @map_y)
|
@sprites["mapbottom"].maplocation = pbGetMapLocation(@map_x, @map_y)
|
||||||
@sprites["mapbottom"].mapdetails = pbGetMapDetails(@map_x, @map_y)
|
@sprites["mapbottom"].mapdetails = pbGetMapDetails(@map_x, @map_y)
|
||||||
if playerpos && mapindex == playerpos[0]
|
if playerpos && mapindex == playerpos[0]
|
||||||
@@ -177,27 +176,13 @@ class PokemonRegionMap_Scene
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbSaveMapData
|
def pbSaveMapData
|
||||||
File.open("PBS/town_map.txt", "wb") { |f|
|
GameData::TownMap.save
|
||||||
Compiler.add_PBS_header_to_file(f)
|
Compiler.write_town_map
|
||||||
@map_data.length.times do |i|
|
|
||||||
map = @map_data[i]
|
|
||||||
next if !map
|
|
||||||
f.write("\#-------------------------------\r\n")
|
|
||||||
f.write(sprintf("[%d]\r\n", i))
|
|
||||||
f.write(sprintf("Name = %s\r\n", Compiler.csvQuote(map[0])))
|
|
||||||
f.write(sprintf("Filename = %s\r\n", Compiler.csvQuote(map[1])))
|
|
||||||
map[2].each do |loc|
|
|
||||||
f.write("Point = ")
|
|
||||||
Compiler.pbWriteCsvRecord(loc, f, [nil, "uussUUUU"])
|
|
||||||
f.write("\r\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbGetMapLocation(x, y)
|
def pbGetMapLocation(x, y)
|
||||||
return "" if !@map[2]
|
return "" if !@map.point
|
||||||
@map[2].each do |point|
|
@map.point.each do |point|
|
||||||
next if point[0] != x || point[1] != y
|
next if point[0] != x || point[1] != y
|
||||||
return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
|
return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
|
||||||
name = pbGetMessageFromHash(MessageTypes::PlaceNames, point[2])
|
name = pbGetMessageFromHash(MessageTypes::PlaceNames, point[2])
|
||||||
@@ -207,25 +192,25 @@ class PokemonRegionMap_Scene
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbChangeMapLocation(x, y)
|
def pbChangeMapLocation(x, y)
|
||||||
return "" if !@editor || !@map[2]
|
return "" if !@editor || !@map.point
|
||||||
map = @map[2].select { |loc| loc[0] == x && loc[1] == y }[0]
|
point = @map.point.select { |loc| loc[0] == x && loc[1] == y }[0]
|
||||||
currentobj = map
|
currentobj = point
|
||||||
currentname = (map) ? map[2] || "" : ""
|
currentname = (point) ? point[2] : ""
|
||||||
currentname = pbMessageFreeText(_INTL("Set the name for this point."), currentname, false, 250) { pbUpdate }
|
currentname = pbMessageFreeText(_INTL("Set the name for this point."), currentname, false, 250) { pbUpdate }
|
||||||
if currentname
|
if currentname
|
||||||
if currentobj
|
if currentobj
|
||||||
currentobj[2] = currentname
|
currentobj[2] = currentname
|
||||||
else
|
else
|
||||||
newobj = [x, y, currentname, ""]
|
newobj = [x, y, currentname, ""]
|
||||||
@map[2].push(newobj)
|
@map.point.push(newobj)
|
||||||
end
|
end
|
||||||
@changed = true
|
@changed = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbGetMapDetails(x, y) # From Wichu, with my help
|
def pbGetMapDetails(x, y) # From Wichu, with my help
|
||||||
return "" if !@map[2]
|
return "" if !@map.point
|
||||||
@map[2].each do |point|
|
@map.point.each do |point|
|
||||||
next if point[0] != x || point[1] != y
|
next if point[0] != x || point[1] != y
|
||||||
return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
|
return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
|
||||||
mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions, point[3])
|
mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions, point[3])
|
||||||
@@ -235,8 +220,8 @@ class PokemonRegionMap_Scene
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbGetHealingSpot(x, y)
|
def pbGetHealingSpot(x, y)
|
||||||
return nil if !@map[2]
|
return nil if !@map.point
|
||||||
@map[2].each do |point|
|
@map.point.each do |point|
|
||||||
next if point[0] != x || point[1] != y
|
next if point[0] != x || point[1] != y
|
||||||
return nil if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
|
return nil if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
|
||||||
return (point[4] && point[5] && point[6]) ? [point[4], point[5], point[6]] : nil
|
return (point[4] && point[5] && point[6]) ? [point[4], point[5], point[6]] : nil
|
||||||
|
|||||||
@@ -105,9 +105,8 @@ class RegionMapSprite
|
|||||||
end
|
end
|
||||||
|
|
||||||
def createRegionMap(map)
|
def createRegionMap(map)
|
||||||
@mapdata = pbLoadTownMapData
|
town_map = GameData::TownMap.get(map)
|
||||||
@map = @mapdata[map]
|
bitmap = AnimatedBitmap.new("Graphics/UI/Town Map/#{town_map.filename}").deanimate
|
||||||
bitmap = AnimatedBitmap.new("Graphics/UI/Town Map/#{@map[1]}").deanimate
|
|
||||||
retbitmap = BitmapWrapper.new(bitmap.width / 2, bitmap.height / 2)
|
retbitmap = BitmapWrapper.new(bitmap.width / 2, bitmap.height / 2)
|
||||||
retbitmap.stretch_blt(
|
retbitmap.stretch_blt(
|
||||||
Rect.new(0, 0, bitmap.width / 2, bitmap.height / 2),
|
Rect.new(0, 0, bitmap.width / 2, bitmap.height / 2),
|
||||||
|
|||||||
@@ -769,15 +769,10 @@ module RegionMapCoordsProperty
|
|||||||
selregion = regions[0][0]
|
selregion = regions[0][0]
|
||||||
else
|
else
|
||||||
cmds = []
|
cmds = []
|
||||||
regions.each do |region|
|
regions.each { |region| cmds.push(region[1]) }
|
||||||
cmds.push(region[1])
|
|
||||||
end
|
|
||||||
selcmd = pbMessage(_INTL("Choose a region map."), cmds, -1)
|
selcmd = pbMessage(_INTL("Choose a region map."), cmds, -1)
|
||||||
if selcmd >= 0
|
return oldsetting if selcmd < 0
|
||||||
selregion = regions[selcmd][0]
|
selregion = regions[selcmd][0]
|
||||||
else
|
|
||||||
return oldsetting
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
mappoint = chooseMapPoint(selregion, true)
|
mappoint = chooseMapPoint(selregion, true)
|
||||||
return (mappoint) ? [selregion, mappoint[0], mappoint[1]] : oldsetting
|
return (mappoint) ? [selregion, mappoint[0], mappoint[1]] : oldsetting
|
||||||
@@ -788,12 +783,8 @@ module RegionMapCoordsProperty
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.getMapNameList
|
def self.getMapNameList
|
||||||
mapdata = pbLoadTownMapData
|
|
||||||
ret = []
|
ret = []
|
||||||
mapdata.length.times do |i|
|
GameData::TownMap.each { |town_map| ret.push([town_map.id, town_map.name]) }
|
||||||
next if !mapdata[i]
|
|
||||||
ret.push([i, pbGetMessage(MessageTypes::RegionNames, i)])
|
|
||||||
end
|
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -60,80 +60,28 @@ module Compiler
|
|||||||
# Compile Town Map data
|
# Compile Town Map data
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
def compile_town_map(path = "PBS/town_map.txt")
|
def compile_town_map(path = "PBS/town_map.txt")
|
||||||
compile_pbs_file_message_start(path)
|
compile_PBS_file_generic(GameData::TownMap, path) do |final_validate, hash|
|
||||||
sections = []
|
(final_validate) ? validate_all_compiled_town_maps : validate_compiled_town_map(hash)
|
||||||
# Read from PBS file
|
end
|
||||||
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 = {
|
|
||||||
"SectionName" => [:id, "u"],
|
|
||||||
"Name" => [:real_name, "s"],
|
|
||||||
"Filename" => [:filename, "s"],
|
|
||||||
"Point" => [:point, "^uussUUUU"]
|
|
||||||
}
|
|
||||||
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}
|
|
||||||
# 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
|
|
||||||
if key == "SectionName"
|
|
||||||
data_hash[schema[key][0]] = pbGetCsvRecord(section_name, key, schema[key])
|
|
||||||
next
|
|
||||||
end
|
|
||||||
# Skip empty properties
|
|
||||||
next if contents[key].nil?
|
|
||||||
# Compile value for key
|
|
||||||
if schema[key][1][0] == "^"
|
|
||||||
contents[key].each do |val|
|
|
||||||
value = pbGetCsvRecord(val, key, schema[key])
|
|
||||||
value = nil if value.is_a?(Array) && value.empty?
|
|
||||||
data_hash[schema[key][0]] ||= []
|
|
||||||
data_hash[schema[key][0]].push(value)
|
|
||||||
end
|
|
||||||
data_hash[schema[key][0]].compact!
|
|
||||||
else
|
|
||||||
value = pbGetCsvRecord(contents[key], key, schema[key])
|
|
||||||
value = nil if value.is_a?(Array) && value.empty?
|
|
||||||
data_hash[schema[key][0]] = value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# Validate and modify the compiled data
|
|
||||||
validate_compiled_town_map(data_hash)
|
|
||||||
if sections[data_hash[:id]]
|
|
||||||
raise _INTL("Region ID '{1}' is used twice.\r\n{2}", data_hash[:id], FileLineData.linereport)
|
|
||||||
end
|
|
||||||
# Add town map messages to records
|
|
||||||
sections[data_hash[:id]] = [data_hash[:real_name], data_hash[:filename], data_hash[:point]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
validate_all_compiled_town_maps(sections)
|
|
||||||
# Save all data
|
|
||||||
save_data(sections, "Data/town_map.dat")
|
|
||||||
process_pbs_file_message_end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_compiled_town_map(hash)
|
def validate_compiled_town_map(hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_all_compiled_town_maps(sections)
|
def validate_all_compiled_town_maps
|
||||||
# Get town map names and descriptions for translating
|
# Get town map names and descriptions for translating
|
||||||
region_names = []
|
region_names = []
|
||||||
point_names = []
|
point_names = []
|
||||||
interest_names = []
|
interest_names = []
|
||||||
sections.each_with_index do |region, i|
|
GameData::TownMap.each do |town_map|
|
||||||
region_names[i] = region[0]
|
region_names[town_map.id] = town_map.real_name
|
||||||
region[2].each do |point|
|
town_map.point.each do |point|
|
||||||
point_names.push(point[2])
|
point_names.push(point[2])
|
||||||
interest_names.push(point[3])
|
interest_names.push(point[3])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
point_names.uniq!
|
||||||
|
interest_names.uniq!
|
||||||
MessageTypes.setMessages(MessageTypes::RegionNames, region_names)
|
MessageTypes.setMessages(MessageTypes::RegionNames, region_names)
|
||||||
MessageTypes.setMessagesAsHash(MessageTypes::PlaceNames, point_names)
|
MessageTypes.setMessagesAsHash(MessageTypes::PlaceNames, point_names)
|
||||||
MessageTypes.setMessagesAsHash(MessageTypes::PlaceDescriptions, interest_names)
|
MessageTypes.setMessagesAsHash(MessageTypes::PlaceDescriptions, interest_names)
|
||||||
@@ -182,43 +130,6 @@ module Compiler
|
|||||||
process_pbs_file_message_end
|
process_pbs_file_message_end
|
||||||
end
|
end
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Compile phone messages
|
|
||||||
#=============================================================================
|
|
||||||
def compile_phone(path = "PBS/phone.txt")
|
|
||||||
compile_PBS_file_generic(GameData::PhoneMessage, path) do |final_validate, hash|
|
|
||||||
(final_validate) ? validate_all_compiled_phone_contacts : validate_compiled_phone_contact(hash)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def validate_compiled_phone_contact(hash)
|
|
||||||
# Split trainer type/name/version into their own values, generate compound ID from them
|
|
||||||
if hash[:id].strip.downcase == "default"
|
|
||||||
hash[:id] = "default"
|
|
||||||
hash[:trainer_type] = hash[:id]
|
|
||||||
else
|
|
||||||
line_data = pbGetCsvRecord(hash[:id], -1, [0, "esU", :TrainerType])
|
|
||||||
hash[:trainer_type] = line_data[0]
|
|
||||||
hash[:real_name] = line_data[1]
|
|
||||||
hash[:version] = line_data[2] || 0
|
|
||||||
hash[:id] = [hash[:trainer_type], hash[:real_name], hash[:version]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def validate_all_compiled_phone_contacts
|
|
||||||
# Get all phone messages for translating
|
|
||||||
messages = []
|
|
||||||
GameData::PhoneMessage.each do |contact|
|
|
||||||
[:intro, :intro_morning, :intro_afternoon, :intro_evening, :body, :body1,
|
|
||||||
:body2, :battle_request, :battle_remind, :end].each do |msg_type|
|
|
||||||
msgs = contact.send(msg_type)
|
|
||||||
next if !msgs || msgs.length == 0
|
|
||||||
msgs.each { |msg| messages.push(msg) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
MessageTypes.setMessagesAsHash(MessageTypes::PhoneMessages, messages)
|
|
||||||
end
|
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Compile type data
|
# Compile type data
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
@@ -1220,6 +1131,43 @@ module Compiler
|
|||||||
def validate_all_compiled_dungeon_parameters
|
def validate_all_compiled_dungeon_parameters
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Compile phone messages
|
||||||
|
#=============================================================================
|
||||||
|
def compile_phone(path = "PBS/phone.txt")
|
||||||
|
compile_PBS_file_generic(GameData::PhoneMessage, path) do |final_validate, hash|
|
||||||
|
(final_validate) ? validate_all_compiled_phone_contacts : validate_compiled_phone_contact(hash)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_compiled_phone_contact(hash)
|
||||||
|
# Split trainer type/name/version into their own values, generate compound ID from them
|
||||||
|
if hash[:id].strip.downcase == "default"
|
||||||
|
hash[:id] = "default"
|
||||||
|
hash[:trainer_type] = hash[:id]
|
||||||
|
else
|
||||||
|
line_data = pbGetCsvRecord(hash[:id], -1, [0, "esU", :TrainerType])
|
||||||
|
hash[:trainer_type] = line_data[0]
|
||||||
|
hash[:real_name] = line_data[1]
|
||||||
|
hash[:version] = line_data[2] || 0
|
||||||
|
hash[:id] = [hash[:trainer_type], hash[:real_name], hash[:version]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_all_compiled_phone_contacts
|
||||||
|
# Get all phone messages for translating
|
||||||
|
messages = []
|
||||||
|
GameData::PhoneMessage.each do |contact|
|
||||||
|
[:intro, :intro_morning, :intro_afternoon, :intro_evening, :body, :body1,
|
||||||
|
:body2, :battle_request, :battle_remind, :end].each do |msg_type|
|
||||||
|
msgs = contact.send(msg_type)
|
||||||
|
next if !msgs || msgs.length == 0
|
||||||
|
msgs.each { |msg| messages.push(msg) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
MessageTypes.setMessagesAsHash(MessageTypes::PhoneMessages, messages)
|
||||||
|
end
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Compile battle animations
|
# Compile battle animations
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|||||||
@@ -48,36 +48,7 @@ module Compiler
|
|||||||
# Save Town Map data to PBS file
|
# Save Town Map data to PBS file
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
def write_town_map(path = "PBS/town_map.txt")
|
def write_town_map(path = "PBS/town_map.txt")
|
||||||
write_pbs_file_message_start(path)
|
write_PBS_file_generic(GameData::TownMap, path)
|
||||||
schema = {
|
|
||||||
"Name" => [0, "s"],
|
|
||||||
"Filename" => [1, "s"],
|
|
||||||
"Point" => [2, "^uussUUUU"]
|
|
||||||
}
|
|
||||||
File.open(path, "wb") { |f|
|
|
||||||
add_PBS_header_to_file(f)
|
|
||||||
# Write each element in turn
|
|
||||||
pbLoadTownMapData.each_with_index do |element, i|
|
|
||||||
f.write("\#-------------------------------\r\n")
|
|
||||||
f.write(sprintf("[%d]\r\n", i))
|
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
@@ -140,13 +111,6 @@ module Compiler
|
|||||||
process_pbs_file_message_end
|
process_pbs_file_message_end
|
||||||
end
|
end
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Save phone messages to PBS file
|
|
||||||
#=============================================================================
|
|
||||||
def write_phone(path = "PBS/phone.txt")
|
|
||||||
write_PBS_file_generic(GameData::PhoneMessage, path)
|
|
||||||
end
|
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Save type data to PBS file
|
# Save type data to PBS file
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
@@ -712,6 +676,13 @@ module Compiler
|
|||||||
write_PBS_file_generic(GameData::DungeonParameters, path)
|
write_PBS_file_generic(GameData::DungeonParameters, path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Save phone messages to PBS file
|
||||||
|
#=============================================================================
|
||||||
|
def write_phone(path = "PBS/phone.txt")
|
||||||
|
write_PBS_file_generic(GameData::PhoneMessage, path)
|
||||||
|
end
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Save all data to PBS files
|
# Save all data to PBS files
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user