#==============================================================================
# ■ Window_Title_Command
#------------------------------------------------------------------------------
# 标题的主菜单。
#==============================================================================
class Window_Title_Command < Window_Base
attr_reader :index
attr_reader :slide_over #滚动结束
#start load option exit
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(index=0)
@index = index
#选项背景
@button_base = Sprite.new
@button_base.bitmap = RPG::Cache.title("title-base-light")
@button_base.x = 1200-680+409
@button_base.y = 56
@cur_back = []
@text_list = []
@able = []
#光标
@item_max = 7
for i in 0...@item_max
@able[i] = true
@cur_back[i] = Sprite.new
@cur_back[i].bitmap = RPG::Cache.title("title-normal")#+i.to_s)
@cur_back[i].x = 1200-680+435
@cur_back[i].y = 81+45*i
@text_list[i] = Sprite.new
@text_list[i].bitmap = RPG::Cache.title("index-"+i.to_s)
@text_list[i].x = 1200-680+435 + 47
@text_list[i].y = 81+45*i + 9
end
@slide_over = false
super(0, 0, 0, 0)
self.opacity = 0
self.active = true
end
def origin_x
return 1200-680+435
end
def origin_y
return 81
end
#--------------------------------------------------------------------------
# ● 一些方法的重载
#--------------------------------------------------------------------------
def dispose
@button_base.dispose
for i in 0...@item_max
@cur_back[i].dispose
@text_list[i].dispose
end
super
end
def z=(z)
super(z)
@button_base.z=z
for i in 0...@item_max
@cur_back[i].z=z
@text_list[i].z=z
end
end
def visible=(visible)
super(visible)
@button_base.visible = visible
for i in 0...@item_max
@cur_back[i].visible = visible
@text_list[i].visible = visible
end
end
def index=(index)
@index=index
end
def disable_item(i)
end
#--------------------------------------------------------------------------
# ● 光标不被选中状态
#--------------------------------------------------------------------------
def back_normal(index)
if index != -1
@cur_back[index].bitmap = RPG::Cache.title("title-normal")#+i.to_s)
@text_list[index].bitmap = RPG::Cache.title("index-"+index.to_s)
end
end
def disable_item(index)
@cur_back[index].bitmap = RPG::Cache.title("title-pressed")#+i.to_s)
@able[index] = false
@text_list[index].bitmap = RPG::Cache.title("index-"+index.to_s+"-black")
#@cur_back[index].color = Color.new(0,0,0,128)
end
#--------------------------------------------------------------------------
# ● 更新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
for i in 0...@item_max
back_normal(i)
end
return
end
@cur_back[@index].bitmap = RPG::Cache.title("title-highlight")#+i.to_s)
@text_list[@index].bitmap = RPG::Cache.title("index-"+index.to_s+"-hl")
=begin
speed = 40#闪烁速度
if Graphics.frame_count % speed
< speed/2
@cur_back[@index].color = Color.new(255,255,255,100+(Graphics.frame_count%speed)*2)
else
@cur_back[@index].color = Color.new(255,255,255,100+(speed-Graphics.frame_count%speed)*2)
end
=end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
#@cur_back[i].x = 644#640-188
@slide_over = true
if self.active
# 方向键左被按下的情况下
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
back_normal(@index)
@index = (@index+1)%@item_max
until @able[@index]
@index = (@index+1)%@item_max
end
end
# 方向键右被按下的情况下
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
back_normal(@index)
@index = (@index+@item_max-1)%@item_max
until @able[@index]
@index = (@index+@item_max-1)%@item_max
end
end
end
# 刷新光标矩形
update_cursor_rect if @slide_over
end
end