139 lines
6.0 KiB
Lua
139 lines
6.0 KiB
Lua
Entry = {}
|
|
Entry.__index = Entry
|
|
|
|
function Entry.new()
|
|
local self = setmetatable({}, Entry)
|
|
tex.load_animations("entry")
|
|
tex.load_folder("entry", "background")
|
|
tex.load_folder("entry", "side_select")
|
|
tex.load_folder("entry", "costume_select")
|
|
tex.load_folder("entry", "global")
|
|
self.bg_flicker = tex.get_animation(1)
|
|
self.side_select_fade = tex.get_animation(0)
|
|
self.bg_flicker:start()
|
|
self.text_question = text.create_text("entry_question", { 255, 255, 255, 255 }, { 0, 0, 0, 255 }, false, 4,
|
|
-1)
|
|
self.text_cancel = text.create_text("entry_cancel", { 255, 255, 255, 255 }, { 0, 0, 0, 255 }, false, 4,
|
|
-4)
|
|
-- cached texture IDs
|
|
self._id_bg_bg = tex.get_id("background", "bg") or 0
|
|
self._id_bg_tower = tex.get_id("background", "tower") or 0
|
|
self._id_bg_shops_center = tex.get_id("background", "shops_center") or 0
|
|
self._id_bg_people = tex.get_id("background", "people") or 0
|
|
self._id_bg_shops_left = tex.get_id("background", "shops_left") or 0
|
|
self._id_bg_shops_right = tex.get_id("background", "shops_right") or 0
|
|
self._id_bg_lights = tex.get_id("background", "lights") or 0
|
|
self._id_ss_box_top_left = tex.get_id("side_select", "box_top_left") or 0
|
|
self._id_ss_box_top_right = tex.get_id("side_select", "box_top_right") or 0
|
|
self._id_ss_box_bot_left = tex.get_id("side_select", "box_bottom_left") or 0
|
|
self._id_ss_box_bot_right = tex.get_id("side_select", "box_bottom_right") or 0
|
|
self._id_ss_box_top = tex.get_id("side_select", "box_top") or 0
|
|
self._id_ss_box_bottom = tex.get_id("side_select", "box_bottom") or 0
|
|
self._id_ss_box_left = tex.get_id("side_select", "box_left") or 0
|
|
self._id_ss_box_right = tex.get_id("side_select", "box_right") or 0
|
|
self._id_ss_box_center = tex.get_id("side_select", "box_center") or 0
|
|
self._id_ss_1p = tex.get_id("side_select", "1P") or 0
|
|
self._id_ss_cancel = tex.get_id("side_select", "cancel") or 0
|
|
self._id_ss_2p = tex.get_id("side_select", "2P") or 0
|
|
self._id_ss_1p_highlight = tex.get_id("side_select", "1P_highlight") or 0
|
|
self._id_ss_1p2p_outline = tex.get_id("side_select", "1P2P_outline") or 0
|
|
self._id_ss_cancel_highlight = tex.get_id("side_select", "cancel_highlight") or 0
|
|
self._id_ss_cancel_outline = tex.get_id("side_select", "cancel_outline") or 0
|
|
self._id_ss_2p_highlight = tex.get_id("side_select", "2P_highlight") or 0
|
|
self._id_ss_footer = tex.get_id("side_select", "footer") or 0
|
|
self._id_ss_footer_left = tex.get_id("side_select", "footer_left") or 0
|
|
self._id_ss_footer_right = tex.get_id("side_select", "footer_right") or 0
|
|
self._id_global_player_entry = tex.get_id("global", "player_entry") or 0
|
|
return self
|
|
end
|
|
|
|
function Entry:update(current_ms)
|
|
self.bg_flicker:update(current_ms)
|
|
self.side_select_fade:update(current_ms)
|
|
end
|
|
|
|
function Entry:start_side_select()
|
|
self.side_select_fade:start()
|
|
end
|
|
|
|
function Entry:restart_side_select()
|
|
self.side_select_fade:restart()
|
|
end
|
|
|
|
function Entry:get_side_select_fade()
|
|
return self.side_select_fade.attribute
|
|
end
|
|
|
|
function Entry:draw_background()
|
|
tex.draw_texture(self._id_bg_bg)
|
|
tex.draw_texture(self._id_bg_tower)
|
|
tex.draw_texture(self._id_bg_shops_center)
|
|
tex.draw_texture(self._id_bg_people)
|
|
tex.draw_texture(self._id_bg_shops_left)
|
|
tex.draw_texture(self._id_bg_shops_right)
|
|
tex.draw_texture(self._id_bg_lights, { scale = 2.0, fade = self.bg_flicker.attribute })
|
|
end
|
|
|
|
function Entry:draw_side_select()
|
|
local fade = self.side_select_fade.attribute
|
|
tex.draw_texture(self._id_ss_box_top_left, { fade = fade })
|
|
tex.draw_texture(self._id_ss_box_top_right, { fade = fade })
|
|
tex.draw_texture(self._id_ss_box_bot_left, { fade = fade })
|
|
tex.draw_texture(self._id_ss_box_bot_right, { fade = fade })
|
|
tex.draw_texture(self._id_ss_box_top, { fade = fade })
|
|
tex.draw_texture(self._id_ss_box_bottom, { fade = fade })
|
|
tex.draw_texture(self._id_ss_box_left, { fade = fade })
|
|
tex.draw_texture(self._id_ss_box_right, { fade = fade })
|
|
tex.draw_texture(self._id_ss_box_center, { fade = fade })
|
|
|
|
self.text_question:draw({
|
|
x = -self.text_question.width / 2,
|
|
fade = fade
|
|
});
|
|
end
|
|
|
|
function Entry:draw_side_select_buttons(side)
|
|
local fade = self.side_select_fade.attribute
|
|
tex.draw_texture(self._id_ss_1p, { fade = fade })
|
|
tex.draw_texture(self._id_ss_cancel, { fade = fade })
|
|
tex.draw_texture(self._id_ss_2p, { fade = fade })
|
|
|
|
if side == 0 then
|
|
tex.draw_texture(self._id_ss_1p_highlight, { fade = fade })
|
|
tex.draw_texture(self._id_ss_1p2p_outline, { mirror = "horizontal", fade = fade, index = 0 })
|
|
elseif side == 1 then
|
|
tex.draw_texture(self._id_ss_cancel_highlight, { fade = fade })
|
|
tex.draw_texture(self._id_ss_cancel_outline, { fade = fade })
|
|
else
|
|
tex.draw_texture(self._id_ss_2p_highlight, { fade = fade })
|
|
tex.draw_texture(self._id_ss_1p2p_outline, { fade = fade, index = 1 })
|
|
end
|
|
|
|
local tex_obj = tex.get_texture_info("side_select", "cancel")
|
|
local text_x = tex_obj.x[1] + (tex_obj.width / 2) - (self.text_cancel.width / 2)
|
|
local text_y = tex_obj.y[1] + (tex_obj.height / 2) - (self.text_cancel.height / 2)
|
|
self.text_cancel:draw({
|
|
x = text_x,
|
|
y = text_y,
|
|
fade = fade
|
|
});
|
|
end
|
|
|
|
function Entry:draw_footer(p1_joined, p2_joined)
|
|
tex.draw_texture(self._id_ss_footer)
|
|
if p1_joined and p2_joined then
|
|
-- both players joined, no footer sides
|
|
elseif not p1_joined and not p2_joined then
|
|
tex.draw_texture(self._id_ss_footer_left)
|
|
tex.draw_texture(self._id_ss_footer_right)
|
|
elseif p1_joined then
|
|
tex.draw_texture(self._id_ss_footer_right)
|
|
else
|
|
tex.draw_texture(self._id_ss_footer_left)
|
|
end
|
|
end
|
|
|
|
function Entry:draw_player_entry()
|
|
tex.draw_texture(self._id_global_player_entry)
|
|
end
|