#encoding:utf-8
#==============================================================================
# ■ Window_MapName
#------------------------------------------------------------------------------
# 显示地图名称的窗口。
#==============================================================================
class Window_MapName < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, fitting_height(2))
self.opacity = 0
self.contents_opacity = 0
self.x = 0
self.y = Graphics.height / 2
@mapnamebj = Sprite.new
@mapnamebj1 = Sprite.new
@show_count = 0
refresh
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
Graphics.width
#~ return 240
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
if @show_count > 0 && $game_map.name_display
update_fadein
@show_count -= 1
else
update_fadeout
end
end
#--------------------------------------------------------------------------
# ● 更新淡入
#--------------------------------------------------------------------------
def update_fadein
self.contents_opacity += 16
@mapnamebj.opacity += 16
@mapnamebj1.opacity += 16
end
#--------------------------------------------------------------------------
# ● 更新淡出
#--------------------------------------------------------------------------
def update_fadeout
self.contents_opacity -= 16
@mapnamebj.opacity -= 16
@mapnamebj1.opacity -= 16
end
#--------------------------------------------------------------------------
# ● 打开窗口
#--------------------------------------------------------------------------
def open
refresh
@show_count = 100
self.contents_opacity = 0
self
end
#--------------------------------------------------------------------------
# ● 关闭窗口
#--------------------------------------------------------------------------
def close
@show_count = 0
self
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
unless $game_map.display_name.empty?
draw_background(contents.rect)
#~ color = Color.new(172, 16, 24)
#~ change_color(color)
contents.font.size = 36
draw_text(contents.rect, $game_map.display_name, 1)
end
end
#--------------------------------------------------------------------------
# ● 绘制背景
#----------------- ---------------------------------------------------------
def draw_background(rect)
temp_rect = rect.clone
temp_rect.width /= 2
contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
@mapnamebj = Sprite.new
@mapnamebj.bitmap = Cache.system("mapnamebj.png")
@mapnamebj.z = 9999
@mapnamebj.x = temp_rect.width - 48
@mapnamebj.y = Graphics.height / 2 - 20
@mapnamebj1 = Sprite.new
@mapnamebj1.bitmap = Cache.system("mapnamebj1.png")
@mapnamebj1.z = 9999
@mapnamebj1.x = temp_rect.width - 48
@mapnamebj1.y = Graphics.height / 2 +40
for i in 1..15
@mapnamebj.x += 5
@mapnamebj1.x -= 5
Graphics.update
end
@mapnamebj.opacity = 0
@mapnamebj1.opacity = 0
temp_rect.x = temp_rect.width
contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
end
#--------------------------------------------------------------------------
# ● 获取背景色 1
#--------------------------------------------------------------------------
def back_color1
Color.new(21, 66, 95, 192)
end
#--------------------------------------------------------------------------
# ● 获取背景色 2
#--------------------------------------------------------------------------
def back_color2
Color.new(0, 0, 0, 0)
end
end