Fixed some buttons stuff

This commit is contained in:
2023-02-23 08:14:29 +01:00
parent 3432f5d36e
commit c1484655cd
3 changed files with 28 additions and 20 deletions
+21 -16
View File
@@ -1,26 +1,28 @@
function state_menu()
local selected = 1
local buttons = {
make_button({x=10, y=10, w=30, text="pLAY", data={i=1},
on_click=function() set_state(states.loading) end,
on_hover=function(btn) selected=1 end,
}),
}
local buttons = {}
-- local buttons = {
-- make_button({x=10, y=10, w=30, text="pLAY", data={i=1},
-- on_click=function() set_state(states.loading) end,
-- on_hover=function(btn) selected=1 end,
-- }),
-- }
local game_sizes = {
{"mINI bOARD - 4x4", 4},
{"sMALL bOARD - 6x6", 6},
{"mEDIUM bOARD - 8x8", 8},
{"lARGE bOARD - 10x10", 10}
{"mINI bOARD - 4X4", 4},
{"sMALL bOARD - 6X6", 6},
{"mEDIUM bOARD - 8X8", 8},
{"lARGE bOARD - 10X10", 10}
}
for k, item in ipairs(game_sizes) do
add(buttons,
make_button({
x=10, y=10+k*10, w=200,
text=item[1], data={i=2},
x=10, y=10+k*10,
selected_color=7,
text=item[1],
on_click=function() board_size=item[2] set_state(states.loading) end,
on_hover=function(btn) selected=k+1 end,
on_hover=function() selected=k end,
})
)
end
@@ -28,9 +30,10 @@ function state_menu()
local rulesId = #buttons+1
add(buttons,
make_button({x=10, y=10+(#game_sizes+1)*10, w=30, text="rULES", data={i=2},
make_button({x=10, y=20+(#game_sizes+1)*10, w=30, text="rULES",
color=13, selected_color=12,
on_click=function() set_state(states.rules) end,
on_hover=function(btn) selected=rulesId end,
on_hover=function() selected=rulesId end,
})
)
@@ -42,7 +45,9 @@ function state_menu()
local function _draw()
cls()
draw_bg_menu()
-- printh(selected)
print("pLAY", 10, 8, 8)
for k,button in ipairs(buttons) do
button:draw(selected == k)
end