@cur_back = []
@text_list = []
@able = []
#光标
@item_max = 5
for i in 0...@item_max
@able = true
@cur_back = Sprite.new
@cur_back.bitmap = RPG::Cache.title("title-normal")#+i.to_s)
@cur_back.x = 435
@cur_back.y = 81+45*i
@text_list = Sprite.new
@text_list.bitmap = RPG::Cache.title("index-"+i.to_s)
@text_list.x = 435 + 47
@text_list.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 435
end
def origin_y
return 81
end
#--------------------------------------------------------------------------
# ● 一些方法的重载
#--------------------------------------------------------------------------
def dispose
@button_base.dispose
for i in 0...@item_max
@cur_back.dispose
@text_list.dispose
end
super
end
def z=(z)
super(z)
@button_base.z=z
for i in 0...@item_max
@cur_back.z=z
@text_list.z=z
end
end
def visible=(visible)
super(visible)
@button_base.visible = visible
for i in 0...@item_max
@cur_back.visible = visible
@text_list.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")
#NAME?
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
#NAME?
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