mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Fixed up code added by previous commit, improved scene closings when using Fly
This commit is contained in:
@@ -4,45 +4,44 @@
|
||||
class MapBottomSprite < SpriteWrapper
|
||||
attr_reader :mapname, :maplocation
|
||||
|
||||
TEXT_MAIN_COLOR = Color.new(248, 248, 248)
|
||||
TEXT_SHADOW_COLOR = Color.new(0, 0, 0)
|
||||
|
||||
def initialize(viewport = nil)
|
||||
super(viewport)
|
||||
@mapname = ""
|
||||
@maplocation = ""
|
||||
@mapdetails = ""
|
||||
@thisbitmap = BitmapWrapper.new(Graphics.width, Graphics.height)
|
||||
self.bitmap = BitmapWrapper.new(Graphics.width, Graphics.height)
|
||||
pbSetSystemFont(self.bitmap)
|
||||
refresh
|
||||
end
|
||||
|
||||
def mapname=(value)
|
||||
if @mapname != value
|
||||
@mapname = value
|
||||
refresh
|
||||
end
|
||||
return if @mapname == value
|
||||
@mapname = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def maplocation=(value)
|
||||
if @maplocation != value
|
||||
@maplocation = value
|
||||
refresh
|
||||
end
|
||||
return if @maplocation == value
|
||||
@maplocation = value
|
||||
refresh
|
||||
end
|
||||
|
||||
# From Wichu
|
||||
def mapdetails=(value)
|
||||
if @mapdetails != value
|
||||
@mapdetails = value
|
||||
refresh
|
||||
end
|
||||
return if @mapdetails == value
|
||||
@mapdetails = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def refresh
|
||||
bitmap.clear
|
||||
textpos = [
|
||||
[@mapname, 18, -8, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)],
|
||||
[@maplocation, 18, 348, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)],
|
||||
[@mapdetails, Graphics.width - 16, 348, 1, Color.new(248, 248, 248), Color.new(0, 0, 0)]
|
||||
[@mapname, 18, -8, 0, TEXT_MAIN_COLOR, TEXT_SHADOW_COLOR],
|
||||
[@maplocation, 18, 348, 0, TEXT_MAIN_COLOR, TEXT_SHADOW_COLOR],
|
||||
[@mapdetails, Graphics.width - 16, 348, 1, TEXT_MAIN_COLOR, TEXT_SHADOW_COLOR]
|
||||
]
|
||||
pbDrawTextPositions(bitmap, textpos)
|
||||
end
|
||||
@@ -77,17 +76,17 @@ class PokemonRegionMap_Scene
|
||||
@fly_map = fly_map
|
||||
@mode = fly_map ? 1 : 0
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
playerpos = map_metadata ? map_metadata.town_map_position : nil
|
||||
playerpos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||
if !playerpos
|
||||
mapindex = 0
|
||||
@map = @map_data[0]
|
||||
@map_x = LEFT
|
||||
@map_y = TOP
|
||||
@map_x = LEFT
|
||||
@map_y = TOP
|
||||
elsif @region >= 0 && @region != playerpos[0] && @map_data[@region]
|
||||
mapindex = @region
|
||||
@map = @map_data[@region]
|
||||
@map_x = LEFT
|
||||
@map_y = TOP
|
||||
@map_x = LEFT
|
||||
@map_y = TOP
|
||||
else
|
||||
mapindex = playerpos[0]
|
||||
@map = @map_data[playerpos[0]]
|
||||
@@ -96,12 +95,12 @@ class PokemonRegionMap_Scene
|
||||
mapsize = map_metadata.town_map_size
|
||||
if mapsize && mapsize[0] && mapsize[0] > 0
|
||||
sqwidth = mapsize[0]
|
||||
sqheight = (mapsize[1].length * 1.0 / mapsize[0]).ceil
|
||||
sqheight = (mapsize[1].length.to_f / mapsize[0]).ceil
|
||||
@map_x += ($game_player.x * sqwidth / $game_map.width).floor if sqwidth > 1
|
||||
@map_y += ($game_player.y * sqheight / $game_map.height).floor if sqheight > 1
|
||||
end
|
||||
end
|
||||
unless @map
|
||||
if !@map
|
||||
pbMessage(_INTL("The map data cannot be found."))
|
||||
return false
|
||||
end
|
||||
@@ -110,16 +109,16 @@ class PokemonRegionMap_Scene
|
||||
@sprites["map"].setBitmap("Graphics/Pictures/#{@map[1]}")
|
||||
@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 |hidden|
|
||||
next unless hidden[0] == mapindex && ((@wallmap && hidden[5]) || location_hidden?(hidden[1]))
|
||||
unless @sprites["map2"]
|
||||
Settings::REGION_MAP_EXTRAS.each do |graphic|
|
||||
next if graphic[0] != mapindex || !location_shown?(graphic)
|
||||
if !@sprites["map2"]
|
||||
@sprites["map2"] = BitmapSprite.new(480, 320, @viewport)
|
||||
@sprites["map2"].x = @sprites["map"].x
|
||||
@sprites["map2"].y = @sprites["map"].y
|
||||
end
|
||||
pbDrawImagePositions(@sprites["map2"].bitmap, [
|
||||
["Graphics/Pictures/#{hidden[4]}", hidden[2] * SQUARE_WIDTH, hidden[3] * SQUARE_HEIGHT]
|
||||
])
|
||||
["Graphics/Pictures/#{graphic[4]}", graphic[2] * SQUARE_WIDTH, graphic[3] * SQUARE_HEIGHT]
|
||||
])
|
||||
end
|
||||
@sprites["mapbottom"] = MapBottomSprite.new(@viewport)
|
||||
@sprites["mapbottom"].mapname = pbGetMessage(MessageTypes::RegionNames, mapindex)
|
||||
@@ -128,18 +127,18 @@ class PokemonRegionMap_Scene
|
||||
if playerpos && mapindex == playerpos[0]
|
||||
@sprites["player"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["player"].setBitmap(GameData::TrainerType.player_map_icon_filename($Trainer.trainer_type))
|
||||
@sprites["player"].x = get_x_coord_on_grid(@map_x)
|
||||
@sprites["player"].y = get_y_coord_on_grid(@map_y)
|
||||
@sprites["player"].x = point_x_to_screen_x(@map_x)
|
||||
@sprites["player"].y = point_y_to_screen_y(@map_y)
|
||||
end
|
||||
k = 0
|
||||
(LEFT..RIGHT).each do |i|
|
||||
(TOP..BOTTOM).each do |j|
|
||||
healspot = pbGetHealingSpot(i, j)
|
||||
next unless healspot && $PokemonGlobal.visitedMaps[healspot[0]]
|
||||
next if !healspot || !$PokemonGlobal.visitedMaps[healspot[0]]
|
||||
@sprites["point#{k}"] = AnimatedSprite.create("Graphics/Pictures/mapFly", 2, 16)
|
||||
@sprites["point#{k}"].viewport = @viewport
|
||||
@sprites["point#{k}"].x = get_x_coord_on_grid(i)
|
||||
@sprites["point#{k}"].y = get_y_coord_on_grid(j)
|
||||
@sprites["point#{k}"].x = point_x_to_screen_x(i)
|
||||
@sprites["point#{k}"].y = point_y_to_screen_y(j)
|
||||
@sprites["point#{k}"].visible = @mode == 1
|
||||
@sprites["point#{k}"].play
|
||||
k += 1
|
||||
@@ -147,25 +146,33 @@ class PokemonRegionMap_Scene
|
||||
end
|
||||
@sprites["cursor"] = AnimatedSprite.create("Graphics/Pictures/mapCursor", 2, 5)
|
||||
@sprites["cursor"].viewport = @viewport
|
||||
@sprites["cursor"].x = get_x_coord_on_grid(@map_x)
|
||||
@sprites["cursor"].y = get_y_coord_on_grid(@map_y)
|
||||
@sprites["cursor"].x = point_x_to_screen_x(@map_x)
|
||||
@sprites["cursor"].y = point_y_to_screen_y(@map_y)
|
||||
@sprites["cursor"].play
|
||||
@sprites["help"] = BitmapSprite.new(Graphics.width, 28, @viewport)
|
||||
@sprites["help"] = BitmapSprite.new(Graphics.width, 32, @viewport)
|
||||
pbSetSystemFont(@sprites["help"].bitmap)
|
||||
refresh_fly_screen
|
||||
@changed = false
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def get_x_coord_on_grid(x)
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites)
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def point_x_to_screen_x(x)
|
||||
return -SQUARE_WIDTH / 2 + (x * SQUARE_WIDTH) + (Graphics.width - @sprites["map"].bitmap.width) / 2
|
||||
end
|
||||
|
||||
def get_y_coord_on_grid(y)
|
||||
def point_y_to_screen_y(y)
|
||||
return -SQUARE_HEIGHT / 2 + (y * SQUARE_HEIGHT) + (Graphics.height - @sprites["map"].bitmap.height) / 2
|
||||
end
|
||||
|
||||
def location_hidden?(loc)
|
||||
return !@wallmap && loc.is_a?(Integer) && loc >0 && $game_switches[loc]
|
||||
def location_shown?(point)
|
||||
return point[5] if @wallmap
|
||||
return point[1] > 0 && $game_switches[point[1]]
|
||||
end
|
||||
|
||||
# TODO: Why is this PBS file writer here?
|
||||
@@ -181,35 +188,26 @@ class PokemonRegionMap_Scene
|
||||
Compiler.csvQuote(map[0]), Compiler.csvQuote(map[1])))
|
||||
for loc in map[2]
|
||||
f.write("Point = ")
|
||||
Compiler.pbWriteCsvRecord(loc,f,[nil,"uussUUUU"])
|
||||
Compiler.pbWriteCsvRecord(loc, f, [nil, "uussUUUU"])
|
||||
f.write("\r\n")
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites)
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbGetMapLocation(x, y)
|
||||
return "" unless @map[2]
|
||||
maps = @map[2].select { |loc| loc[0] == x && loc[1] == y }
|
||||
return "" if maps.empty?
|
||||
maps.each do |loc|
|
||||
if !location_hidden?(loc[7])
|
||||
maploc = pbGetMessageFromHash(MessageTypes::PlaceNames, loc[2])
|
||||
return @editor ? loc[2] : maploc
|
||||
else
|
||||
return ""
|
||||
end
|
||||
return "" if !@map[2]
|
||||
for point in @map[2]
|
||||
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])
|
||||
return (@editor) ? point[2] : name
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
def pbChangeMapLocation(x,y)
|
||||
return "" unless @editor && @map[2]
|
||||
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[2]
|
||||
@@ -225,38 +223,37 @@ class PokemonRegionMap_Scene
|
||||
end
|
||||
end
|
||||
|
||||
def pbGetMapDetails(x,y) # From Wichu, with my help
|
||||
return "" unless @map[2]
|
||||
maps = @map[2].select { |loc| loc[0] == x && loc[1] == y }
|
||||
return "" if maps.empty?
|
||||
maps.each do |loc|
|
||||
if !location_hidden?(loc[7])
|
||||
mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions,loc[3])
|
||||
return (@editor) ? loc[3] : mapdesc
|
||||
else
|
||||
return ""
|
||||
end
|
||||
def pbGetMapDetails(x, y) # From Wichu, with my help
|
||||
return "" if !@map[2]
|
||||
for point in @map[2]
|
||||
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])
|
||||
return (@editor) ? point[3] : mapdesc
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
def pbGetHealingSpot(x,y)
|
||||
return nil unless @map[2]
|
||||
maps = @map[2].select { |loc| loc[0] == x && loc[1] == y }
|
||||
return nil if maps.empty?
|
||||
maps.each do |loc|
|
||||
return ((loc[4] && loc[5] && loc[6]) ? [loc[4],loc[5],loc[6]] : nil)
|
||||
def pbGetHealingSpot(x, y)
|
||||
return nil if !@map[2]
|
||||
for point in @map[2]
|
||||
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
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def refresh_fly_screen
|
||||
return if @fly_map || !pbCanFly? || !Settings::CAN_FLY_FROM_TOWN_MAP
|
||||
return if @fly_map || !Settings::CAN_FLY_FROM_TOWN_MAP || !pbCanFly?
|
||||
@sprites["help"].bitmap.clear
|
||||
pbSetSystemFont(@sprites["help"].bitmap)
|
||||
text = @mode == 0 ? _INTL("ACTION: Open Fly Menu") : _INTL("ACTION: Close Fly Menu")
|
||||
pbDrawTextPositions(@sprites["help"].bitmap, [[text, Graphics.width - 8, -8, 1, Color.new(248,248,248), Color.new(0,0,0)]])
|
||||
text = (@mode == 0) ? _INTL("ACTION: Fly") : _INTL("ACTION: Cancel Fly")
|
||||
pbDrawTextPositions(@sprites["help"].bitmap, [
|
||||
[text, Graphics.width - 16, -8, 1, Color.new(248, 248, 248), Color.new(0, 0, 0)]
|
||||
])
|
||||
@sprites.each do |key, sprite|
|
||||
next if !key.include?("point")
|
||||
sprite.visible = @mode == 1
|
||||
sprite.visible = (@mode == 1)
|
||||
sprite.frame = 0
|
||||
end
|
||||
end
|
||||
@@ -281,25 +278,15 @@ class PokemonRegionMap_Scene
|
||||
ox = 0
|
||||
oy = 0
|
||||
case Input.dir8
|
||||
when 1 # lower left
|
||||
when 1, 2, 3
|
||||
oy = 1 if @map_y < BOTTOM
|
||||
ox = -1 if @map_x > LEFT
|
||||
when 2 # down
|
||||
oy = 1 if @map_y < BOTTOM
|
||||
when 3 # lower right
|
||||
oy = 1 if @map_y < BOTTOM
|
||||
ox = 1 if @map_x < RIGHT
|
||||
when 4 # left
|
||||
ox = -1 if @map_x > LEFT
|
||||
when 6 # right
|
||||
ox = 1 if @map_x < RIGHT
|
||||
when 7 # upper left
|
||||
when 7, 8, 9
|
||||
oy = -1 if @map_y > TOP
|
||||
end
|
||||
case Input.dir8
|
||||
when 1, 4, 7
|
||||
ox = -1 if @map_x > LEFT
|
||||
when 8 # up
|
||||
oy = -1 if @map_y > TOP
|
||||
when 9 # upper right
|
||||
oy = -1 if @map_y > TOP
|
||||
when 3, 6, 9
|
||||
ox = 1 if @map_x < RIGHT
|
||||
end
|
||||
if ox != 0 || oy != 0
|
||||
@@ -319,18 +306,19 @@ class PokemonRegionMap_Scene
|
||||
else
|
||||
break
|
||||
end
|
||||
elsif Input.trigger?(Input::USE) && @mode == 1 # Choosing an area to fly to
|
||||
elsif Input.trigger?(Input::USE) && @mode == 1 # Choosing an area to fly to
|
||||
healspot = pbGetHealingSpot(@map_x, @map_y)
|
||||
if healspot &&
|
||||
($PokemonGlobal.visitedMaps[healspot[0]] || ($DEBUG && Input.press?(Input::CTRL)))
|
||||
if healspot && ($PokemonGlobal.visitedMaps[healspot[0]] ||
|
||||
($DEBUG && Input.press?(Input::CTRL)))
|
||||
return healspot if @fly_map
|
||||
name = pbGetMapNameFromId(healspot[0])
|
||||
return healspot if @fly_map || pbConfirmMessage(_INTL("Would you like to fly to {1}?", name)) { pbUpdate }
|
||||
return healspot if pbConfirmMessage(_INTL("Would you like to fly to {1}?", name)) { pbUpdate }
|
||||
end
|
||||
elsif Input.trigger?(Input::USE) && @editor # Intentionally after other USE input check
|
||||
pbChangeMapLocation(@map_x, @map_y)
|
||||
elsif Input.trigger?(Input::ACTION) && !@wallmap && !@fly_map && pbCanFly?
|
||||
pbPlayDecisionSE
|
||||
@mode = (@mode == 1 ? 0 : 1)
|
||||
@mode = (@mode == 1) ? 0 : 1
|
||||
refresh_fly_screen
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user