ttg-logo #35
@@ -12,9 +12,19 @@ end
|
|||||||
--- @within UI
|
--- @within UI
|
||||||
--- @param items table A table of menu items.<br/>
|
--- @param items table A table of menu items.<br/>
|
||||||
--- @param selected_item number The index of the currently selected item.<br/>
|
--- @param selected_item number The index of the currently selected item.<br/>
|
||||||
--- @param x number The x-coordinate for the menu.<br/>
|
--- @param x number The x-coordinate for the menu (ignored if centered is true).<br/>
|
||||||
--- @param y number The y-coordinate for the menu.<br/>
|
--- @param y number The y-coordinate for the menu.<br/>
|
||||||
function UI.draw_menu(items, selected_item, x, y)
|
--- @param[opt] centered boolean Whether to center the menu block horizontally. Defaults to false.<br/>
|
||||||
|
function UI.draw_menu(items, selected_item, x, y, centered)
|
||||||
|
if centered then
|
||||||
|
local max_w = 0
|
||||||
|
for _, item in ipairs(items) do
|
||||||
|
local w = print(item.label, 0, -10, 0, false, 1, false)
|
||||||
|
if w > max_w then max_w = w end
|
||||||
|
end
|
||||||
|
x = (Config.screen.width - max_w) / 2
|
||||||
|
end
|
||||||
|
|
||||||
for i, item in ipairs(items) do
|
for i, item in ipairs(items) do
|
||||||
local current_y = y + (i-1)*10
|
local current_y = y + (i-1)*10
|
||||||
if i == selected_item then
|
if i == selected_item then
|
||||||
|
|||||||
@@ -4,8 +4,15 @@ local _menu_items = {}
|
|||||||
--- Draws the menu window.
|
--- Draws the menu window.
|
||||||
--- @within MenuWindow
|
--- @within MenuWindow
|
||||||
function MenuWindow.draw()
|
function MenuWindow.draw()
|
||||||
UI.draw_top_bar("Main Menu")
|
UI.draw_top_bar("Definitely not an Impostor")
|
||||||
UI.draw_menu(_menu_items, Context.current_menu_item, 108, 70)
|
|
||||||
|
local menu_h = #_menu_items * 10
|
||||||
|
local y = 10 + (Config.screen.height - 10 - 10 - menu_h) / 2
|
||||||
|
UI.draw_menu(_menu_items, Context.current_menu_item, 0, y, true)
|
||||||
|
|
||||||
|
local ttg_text = "TTG"
|
||||||
|
local ttg_w = print(ttg_text, 0, -10, 0, false, 1, false)
|
||||||
|
Print.text(ttg_text, Config.screen.width - ttg_w - 5, Config.screen.height - 10, Config.colors.light_blue)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Updates the menu window logic.
|
--- Updates the menu window logic.
|
||||||
|
|||||||
Reference in New Issue
Block a user