mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 21:54:58 +00:00
Turned Town Map PBS data into a GameData class
This commit is contained in:
@@ -72,27 +72,26 @@ class PokemonRegionMap_Scene
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
@map_data = pbLoadTownMapData
|
||||
@fly_map = fly_map
|
||||
@mode = fly_map ? 1 : 0
|
||||
map_metadata = $game_map.metadata
|
||||
playerpos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||
if !playerpos
|
||||
mapindex = 0
|
||||
@map = @map_data[0]
|
||||
@map = GameData::TownMap.get(0)
|
||||
@map_x = LEFT
|
||||
@map_y = TOP
|
||||
elsif @region >= 0 && @region != playerpos[0] && @map_data[@region]
|
||||
elsif @region >= 0 && @region != playerpos[0] && GameData::TownMap.exists?(@region)
|
||||
mapindex = @region
|
||||
@map = @map_data[@region]
|
||||
@map = GameData::TownMap.get(@region)
|
||||
@map_x = LEFT
|
||||
@map_y = TOP
|
||||
else
|
||||
mapindex = playerpos[0]
|
||||
@map = @map_data[playerpos[0]]
|
||||
@map_x = playerpos[1]
|
||||
@map_y = playerpos[2]
|
||||
mapsize = map_metadata.town_map_size
|
||||
@map = GameData::TownMap.get(playerpos[0])
|
||||
@map_x = playerpos[1]
|
||||
@map_y = playerpos[2]
|
||||
mapsize = map_metadata.town_map_size
|
||||
if mapsize && mapsize[0] && mapsize[0] > 0
|
||||
sqwidth = mapsize[0]
|
||||
sqheight = (mapsize[1].length.to_f / mapsize[0]).ceil
|
||||
@@ -106,7 +105,7 @@ class PokemonRegionMap_Scene
|
||||
end
|
||||
addBackgroundOrColoredPlane(@sprites, "background", "Town Map/bg", Color.black, @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"].y += (Graphics.height - @sprites["map"].bitmap.height) / 2
|
||||
Settings::REGION_MAP_EXTRAS.each do |graphic|
|
||||
@@ -122,7 +121,7 @@ class PokemonRegionMap_Scene
|
||||
)
|
||||
end
|
||||
@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"].mapdetails = pbGetMapDetails(@map_x, @map_y)
|
||||
if playerpos && mapindex == playerpos[0]
|
||||
@@ -177,27 +176,13 @@ class PokemonRegionMap_Scene
|
||||
end
|
||||
|
||||
def pbSaveMapData
|
||||
File.open("PBS/town_map.txt", "wb") { |f|
|
||||
Compiler.add_PBS_header_to_file(f)
|
||||
@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
|
||||
}
|
||||
GameData::TownMap.save
|
||||
Compiler.write_town_map
|
||||
end
|
||||
|
||||
def pbGetMapLocation(x, y)
|
||||
return "" if !@map[2]
|
||||
@map[2].each do |point|
|
||||
return "" if !@map.point
|
||||
@map.point.each do |point|
|
||||
next if point[0] != x || point[1] != y
|
||||
return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
|
||||
name = pbGetMessageFromHash(MessageTypes::PlaceNames, point[2])
|
||||
@@ -207,25 +192,25 @@ class PokemonRegionMap_Scene
|
||||
end
|
||||
|
||||
def pbChangeMapLocation(x, y)
|
||||
return "" if !@editor || !@map[2]
|
||||
map = @map[2].select { |loc| loc[0] == x && loc[1] == y }[0]
|
||||
currentobj = map
|
||||
currentname = (map) ? map[2] || "" : ""
|
||||
return "" if !@editor || !@map.point
|
||||
point = @map.point.select { |loc| loc[0] == x && loc[1] == y }[0]
|
||||
currentobj = point
|
||||
currentname = (point) ? point[2] : ""
|
||||
currentname = pbMessageFreeText(_INTL("Set the name for this point."), currentname, false, 250) { pbUpdate }
|
||||
if currentname
|
||||
if currentobj
|
||||
currentobj[2] = currentname
|
||||
else
|
||||
newobj = [x, y, currentname, ""]
|
||||
@map[2].push(newobj)
|
||||
@map.point.push(newobj)
|
||||
end
|
||||
@changed = true
|
||||
end
|
||||
end
|
||||
|
||||
def pbGetMapDetails(x, y) # From Wichu, with my help
|
||||
return "" if !@map[2]
|
||||
@map[2].each do |point|
|
||||
return "" if !@map.point
|
||||
@map.point.each do |point|
|
||||
next if point[0] != x || point[1] != y
|
||||
return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
|
||||
mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions, point[3])
|
||||
@@ -235,8 +220,8 @@ class PokemonRegionMap_Scene
|
||||
end
|
||||
|
||||
def pbGetHealingSpot(x, y)
|
||||
return nil if !@map[2]
|
||||
@map[2].each do |point|
|
||||
return nil if !@map.point
|
||||
@map.point.each do |point|
|
||||
next if point[0] != x || point[1] != y
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user