#==============================================================================
# 地图名及区域名显示 by Beside
#------------------------------------------------------------------------------
# 功能: 动态显示玩家所在区域及地图名。
#==============================================================================
class Window_Map < Window_Base
#--------------------------------------------------------------------------
# ● 以下是窗口的相关设置
#--------------------------------------------------------------------------
MWINDOW_X = 240 # 窗口X坐标
MWINDOW_Y = 25 # 窗口Y坐标
WEIGH = 160 # 窗口宽度
START_TIME = 30 # 窗口出现时间
COUN_TIME = 30 # 窗口持续时间
FADE_TIME = 30 # 窗口淡去时间
TEXT1_SIZE = 20 # 地图名的字体大小
TEXT2_SIZE = 18 # 区域名的字体大小
TEXT3_SIZE = 18 # 附加名的字体大小
TEXT1_COLOR = Color.new(255,60,60) # 地图名的默认颜色
TEXT2_COLOR = 3 # 区域名的默认颜色代码(0-31)
TEXT3_COLOR = 5 # 附加名的默认颜色代码(0-31)
SKIN = "window" # 窗口皮肤的文件名
HEIGHT = TEXT1_SIZE + TEXT2_SIZE + TEXT3_SIZE + 32
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
@id = 0
@a_id = 0
super(MWINDOW_X, MWINDOW_Y, WEIGH, HEIGHT)
self.opacity = 0
self.contents_opacity = 0
self.windowskin = Cache.system(SKIN)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
@map_id = $game_map.map_id
locationname = load_data("Data/MapInfos.rvdata")[@map_id].name
if $game_player.area_id.is_a?(Numeric)
if $game_player.area_id != @a_id or @map_id != @id
self.contents.clear
if @map_id != @id
@id = @map_id
@time_count = START_TIME + COUN_TIME + FADE_TIME
self.contents.font.color = TEXT1_COLOR
self.contents.font.size = TEXT1_SIZE
self.contents.draw_text(0, 0, WEIGH-32, TEXT1_SIZE, locationname, 1)
end
@time_count = START_TIME + COUN_TIME + FADE_TIME
@a_id = $game_player.area_id
area_name = $data_areas[@a_id].name_p1
other_name = $data_areas[@a_id].name_p2
self.contents.font.size = TEXT2_SIZE
self.contents.font.color = text_color($data_areas[@a_id].color_1)
self.contents.draw_text(0, TEXT1_SIZE, WEIGH-32, TEXT2_SIZE, area_name, 1)
self.contents.font.size = TEXT3_SIZE
self.contents.font.color = text_color($data_areas[@a_id].color_2)
self.contents.draw_text(0, TEXT1_SIZE+TEXT2_SIZE, WEIGH-32, TEXT3_SIZE, other_name, 1)
end
elsif @map_id != @id
@id = @map_id
@time_count = START_TIME + COUN_TIME + FADE_TIME
self.contents.clear
self.contents.font.color = TEXT1_COLOR
self.contents.font.size = TEXT1_SIZE
self.contents.draw_text(0, (HEIGHT-TEXT1_SIZE)/2-16, WEIGH-32, TEXT1_SIZE, locationname, 1)
elsif @a_id != 0
@a_id = 0
@time_count = START_TIME + COUN_TIME + FADE_TIME
self.contents.clear
self.contents.font.color = TEXT1_COLOR
self.contents.font.size = TEXT1_SIZE
self.contents.draw_text(0, (HEIGHT-TEXT1_SIZE)/2-16, WEIGH-32, TEXT1_SIZE, locationname, 1)
end
if @time_count > COUN_TIME + FADE_TIME
self.opacity += 255 / START_TIME
self.contents_opacity += 255 / START_TIME
@time_count -= 1
elsif @time_count > FADE_TIME
self.opacity = 255
self.contents_opacity = 255
@time_count -= 1
elsif @time_count > 0
self.opacity -= 255 / FADE_TIME
self.contents_opacity -= 255 / FADE_TIME
@time_count -= 1
else
@time_count = 0
self.opacity = 0
self.contents_opacity = 0
end
end
end
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
# 处理地图画面的类。
#==============================================================================
class Scene_Map < Scene_Base
alias _start start
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
@map_window = Window_Map.new
_start
end
alias _terminate terminate
def terminate
@map_window.dispose
_terminate
end
alias _update update
def update
@map_window.refresh
_update
end
end
module RPG
class Area
def name_p1
name = @name.split(/#/)[0]
return name != nil ? name : ""
end
def name_p2
name = @name.split(/#/)[1]
return name != nil ? name : ""
end
def color_1
color = @name.split(/#/)[2]
return color != nil ? color.to_i : TEXT2_COLOR
end
def color_2
color = @name.split(/#/)[3]
return color != nil ? color.to_i : TEXT3_COLOR
end
end
end
class Game_Character
def area_id
for area in $data_areas.values
if in_area?(area)
return area.id
end
end
end
end