def self.refresh
if $scene.is_a?(Scene_Map)
$scene.spriteset.minimap.refresh
end
end
def self.update_object
if $scene.is_a?(Scene_Map)
$scene.spriteset.minimap.update_object_list
end
end
end
#==============================================================================
# ?RPG::MapInfo
#==============================================================================
class RPG::MapInfo
def name
return @name.gsub(/\[.*\]/) { }
end
def original_name
return @name
end
def show_minimap?
return [email protected]?(MiniMap::TAG_NO_MINIMAP)
end
end
#==============================================================================
# ?Game_System
#==============================================================================
class Game_System
attr_accessor :minimap
alias wora_minimap_gamsys_ini initialize
def initialize
wora_minimap_gamsys_ini
@minimap = MiniMap::MAP_RECT
end
def show_minimap
return !$game_switches[MiniMap::SWITCH_NO_MINIMAP]
end
end
#==============================================================================
# ?Game_Map
#==============================================================================
class Game_Map
alias wora_minimap_gammap_setup setup
def setup(map_id)
wora_minimap_gammap_setup(map_id)
@db_info = load_data('Data/MapInfos.rvdata') if @db_info.nil?
@map_info = @db_info[map_id]
end
def show_minimap?
return @map_info.show_minimap?
end
end
#==============================================================================
# ?Game_Event
#==============================================================================
class Game_Event < Game_Character
def mm_comment?(comment, return_comment = false )
if [email protected]?
for i in [email protected] - 1
next if @list.code != 108
if @list.parameters[0].include?(comment)
return @list.parameters[0] if return_comment
return true
end
end
end
return '' if return_comment
return false
end
end
#==============================================================================
# ?Game_MiniMap
#------------------------------------------------------------------------------
class Game_MiniMap
def initialize(tilemap)
@tilemap = tilemap
refresh
end
$game_map.width.times do |i|
$game_map.height.times do |j|
if !$game_map.passable?(i, j)
next
end
rect = Rect.new(map_rect.width / 2 + grid_size * i,
map_rect.height / 2 + grid_size * j,
grid_size, grid_size)
if grid_size >= 3
if !$game_map.passable?(i, j)
rect.height -= 1
rect.x += 1
rect.width -= 1
rect.width -= 1
rect.y += 1
rect.height -= 1
end
end
bitmap.fill_rect(rect, MiniMap::FOREGROUND_COLOR)
end
end
end
def update_object_list
@object_list = {}
$game_map.events.values.each do |e|
comment = e.mm_comment?(MiniMap::TAG_EVENT, true)
if comment != ''
type = comment.gsub(/#{MiniMap::TAG_EVENT}/){}.gsub(/\s+/){}
@object_list[type] = [] if @object_list[type].nil?
@object_list[type] << e
end
end
end
@object_list.each do |key, events|
color = MiniMap::OBJECT_COLOR[key]
next if events.nil? or color.nil?
events.each do |obj|
if !obj.character_name.empty?
rect.x = mw + obj.real_x * grid_size / 256
rect.y = mh + obj.real_y * grid_size / 256
# Event's Outline
if MiniMap::USE_OUTLINE_EVENT and MiniMap::GRID_SIZE >= 3
bitmap.fill_rect(rect, MiniMap::EVENT_OUTLINE_COLOR)
brect = Rect.new(rect.x + 1, rect.y + 1, rect.width - 2,
rect.height - 2)
bitmap.clear_rect(brect)
else
brect = bitmap.rect
end
bitmap.fill_rect(brect, color)
end
end
end
end
def update
if @mmr != $game_system.minimap
dispose
refresh
end
draw_object
update_position
if @map_sprite.visible
@map_sprite.update
@object_sprite.update
@position_sprite.update
end
end
def update_position
map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
grid_size = [MiniMap::GRID_SIZE, 1].max
sx = $game_player.real_x * grid_size / 256
sy = $game_player.real_y * grid_size / 256
@map_sprite.src_rect.x = sx
@map_sprite.src_rect.y = sy
@object_sprite.src_rect.x = sx
@object_sprite.src_rect.y = sy
end
end
#==============================================================================
# ?Spriteset_Map
#------------------------------------------------------------------------------
class Spriteset_Map
attr_reader :minimap
alias wora_minimap_sprsetmap_ini initialize
alias wora_minimap_sprsetmap_dis dispose
alias wora_minimap_sprsetmap_upd update
def initialize
wora_minimap_sprsetmap_ini
if $game_map.show_minimap?
@minimap = Game_MiniMap.new(@tilemap)
$game_system.show_minimap = true if $game_system.show_minimap.nil?
@minimap.visible = $game_system.show_minimap
end
end
def dispose
@minimap.dispose if [email protected]?
wora_minimap_sprsetmap_dis
end
def update
if [email protected]?
if $game_system.show_minimap
@minimap.visible = true
@minimap.update
else
@minimap.visible = false
end
end
wora_minimap_sprsetmap_upd
end
end
#==============================================================================
# ?Scene_Map
#------------------------------------------------------------------------------
class Scene_Map < Scene_Base
attr_reader :spriteset
end