#encoding:utf-8
#==============================================================================
# ■ Window_Steps
#------------------------------------------------------------------------------
# 地图上显示步数窗口
#==============================================================================
# 在不想要显示的地图备注栏中放上 <NOSTEPS> 就可以隐藏。
#==============================================================================
STHUD_X = 384 #显示变量的 X 座标
STHUD_Y = 0 #显示变量的 Y 座标
STHUD_UNIT = "步" #步数单位
STHUD_OP = 0 #窗口的不透明度 0-255
STHUD_BK = true #是否显示背景色? true = 是, false = 否
STHUD_INPUT = :C #切换显示/隐藏按钮, 若不想要按钮切换, 等号右边可以清除, 或改为 nil 或 "" 或 ''
class Window_Steps < Window_Base
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, fitting_height(1))
self.opacity = STHUD_OP
@variable = 0
@o_steps = 0
refresh
end
#--------------------------------------------------------------------------
# ● 取得视窗的宽度
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
return if $game_party.steps == @o_steps && $game_party.steps > 0 #如果步数没增加就不刷新
@o_steps = $game_party.steps #更新记录步数的变量
contents.clear #清除窗口内容
draw_background(contents.rect) if STHUD_BK
change_color(normal_color) #改字体颜色为正常色
draw_text(0, 0, contents.width - text_size(STHUD_UNIT).width - 4, line_height, @o_steps, 2) #显示步数
change_color(system_color) #改字体颜色为系统色
draw_text(0, 0, contents.width, line_height, STHUD_UNIT, 2) #显示步数单位
end
#--------------------------------------------------------------------------
# ● 绘制背景
#--------------------------------------------------------------------------
def draw_background(rect)
temp_rect = rect.clone
contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
end
#--------------------------------------------------------------------------
# ● 取得背景色 1
#--------------------------------------------------------------------------
def back_color1
Color.new(0, 0, 0, 10)
end
#--------------------------------------------------------------------------
# ● 取得背景色 2
#--------------------------------------------------------------------------
def back_color2
Color.new(0, 0, 0, 90)
end
end
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
# 地图生成窗口
#==============================================================================
class Scene_Map < Scene_Base
alias st_start start
def start
st_start
@st_window = Window_Steps.new
#@st_window.x = Graphics.width - @st_window.width
@st_window.x = STHUD_X
@st_window.y = STHUD_Y
@st_window.visible = false
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
alias new_update update
def update
new_update
#地图备注检查
return if (/<NOSTEPS>/i.match($game_map.note)) != nil
#初始值
@show_st_hud = true if @show_st_hud == nil
#按键切换开/关
if STHUD_INPUT != nil && STHUD_INPUT != "" && STHUD_INPUT != ''
if Input.trigger?(STHUD_INPUT)
if @show_st_hud != true
@show_st_hud = true
else
@show_st_hud = false
end
end
end
#显示/隐藏执行
if @show_st_hud == true
@st_window.refresh
@st_window.visible = true
else
@st_window.visible = false
#close_varia_window
end
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
alias st_terminate terminate
def terminate
@st_window.dispose
st_terminate
end
#--------------------------------------------------------------------------
# ● 关闭
#--------------------------------------------------------------------------
def close_varia_window
@st_window.close
update until @st_window.close?
end
end
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
# 管理地图的类。
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● 取得地图备注栏
#--------------------------------------------------------------------------
def note
@map.note
end
end