#==============================================================================
# ** Window_Tile_Info
#------------------------------------------------------------------------------
# Show the tiles the player is standing on (excluding tiles from tileset A1 - A4)
#==============================================================================
class Window_Tile_Info < Window_Base
def initialize
super(0, 0, 34 * 4, 96)
# Make window transparant
self.opacity = 150
# Refresh window's content
refresh
end
#--------------------------------------------------------------------------
# * Refresh
# Show the tiles the player is standing on (excluding tiles from tileset A1 - A4)
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# Remember the player's location
@player_x, @player_y = $game_player.x, $game_player.y
# Draw the tiles the player is standing on
for z in 0..2
tile_id = $game_map.data[@player_x, @player_y, z]
# Draw tile image on the window
draw_tile(z * 34, 0, tile_id)
end
end
#--------------------------------------------------------------------------
# * Update
# Refresh if the player has moved
#--------------------------------------------------------------------------
def update
refresh unless @player_x == $game_player.x and @player_y == $game_player.y
end
#--------------------------------------------------------------------------
# * Draw tile
#--------------------------------------------------------------------------
def draw_tile(x, y, tile_id)
# Get tileset bitmap
bitmap = tileset_bitmap(tile_id)
# Stop if tile_id is out of range
return if bitmap.nil? or tile_id / 256 >= 8
# Get x and y locations of the tile_id
sx = (tile_id / 128 % 2 * 8 + tile_id % 8) * 32
sy = (tile_id % 256 / 8 % 16 ) * 32
self.contents.blt(x, y, bitmap, Rect.new(sx, sy, 32, 32))
end
#--------------------------------------------------------------------------
# * Get tile set image that includes the designated tile
# tile_id : Tile ID
#--------------------------------------------------------------------------
def tileset_bitmap(tile_id)
set_number = tile_id / 256
return Cache.system("TileB") if set_number == 0
return Cache.system("TileC") if set_number == 1
return Cache.system("TileD") if set_number == 2
return Cache.system("TileE") if set_number == 3
return Cache.system("TileA5") if set_number >= 6 and set_number < 8
return nil
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# Create, update and dispose the tile info window
#==============================================================================
class Scene_Map
alias start_tile_info start unless $@
def start
start_tile_info
@tile_info_window = Window_Tile_Info.new
end
alias update_tile_info update unless $@
def update
@tile_info_window.update
update_tile_info
end
alias terminate_tile_info terminate unless $@
def terminate
@tile_info_window.dispose
terminate_tile_info
end
end