forked from Yonokid/PyTaikoGreen
49 lines
1.9 KiB
Lua
49 lines
1.9 KiB
Lua
EntryBox = {}
|
|
EntryBox.__index = EntryBox
|
|
|
|
function EntryBox.new(text_str, font_size)
|
|
local self = setmetatable({}, EntryBox)
|
|
|
|
self.text = text.create_raw_text(text_str, font_size, { 255, 255, 255, 255 }, { 109, 68, 24, 255 }, true, 5)
|
|
|
|
self.box = tex.load_texture("entry/mode_select/box")
|
|
self.hl_center = tex.load_texture("entry/mode_select/box_highlight_center")
|
|
self.hl_left = tex.load_texture("entry/mode_select/box_highlight_left")
|
|
self.hl_right = tex.load_texture("entry/mode_select/box_highlight_right")
|
|
|
|
local box_info = tex.get_texture_info("mode_select", "box")
|
|
local hl_left_info = tex.get_texture_info("mode_select", "box_highlight_left")
|
|
local hl_offset = tex.get_skin_config("entry_box_highlight_offset")
|
|
local text_offset = tex.get_skin_config("entry_box_text_offset")
|
|
|
|
self.y = box_info.y[1]
|
|
self.box_width = box_info.width
|
|
self.hl_left_width = hl_left_info.width
|
|
self.hl_offset_x = hl_offset.x
|
|
self.text_y_offset = text_offset.y
|
|
|
|
return self
|
|
end
|
|
|
|
function EntryBox:draw(x, left_x, right_x, is_selected, move_finished, open_attr, fade)
|
|
local y = self.y
|
|
if is_selected and move_finished then
|
|
tex.draw_texture(self.hl_center, {
|
|
x = left_x + self.hl_left_width,
|
|
y = y,
|
|
x2 = right_x - left_x + self.hl_offset_x,
|
|
fade = fade,
|
|
})
|
|
tex.draw_texture(self.hl_left, { x = left_x, y = y, fade = fade })
|
|
tex.draw_texture(self.hl_right, { x = right_x, y = y, fade = fade })
|
|
else
|
|
tex.draw_texture(self.box, { x = x, fade = fade })
|
|
end
|
|
|
|
local text_x = x + self.box_width / 2 - self.text.width / 2
|
|
if is_selected then
|
|
text_x = text_x + open_attr
|
|
end
|
|
self.text:draw({ x = text_x, y = y + self.text_y_offset, fade = fade })
|
|
end
|