- [FIX] msgbox arreglat i redissenyat
- [FIX] Quan està el menu fora s'inhabiliten els shortcuts en l'editor - [NEW] Menu nou funcionant
This commit is contained in:
39
data/ui.lua
39
data/ui.lua
@@ -1,4 +1,43 @@
|
||||
ui = {
|
||||
pushbutton = function(label,x,y,h,col1,col2,callback,selected)
|
||||
local size = (#label*4)-1+4
|
||||
local text_y = (h-5)//2
|
||||
local button_h=0
|
||||
local mx, my = mouse.pos()
|
||||
if mx>=x and mx<x+size and my>=y and my<y+h then
|
||||
button_h = mouse.down(mouse.LEFT) and -1 or 1
|
||||
if mouse.press(mouse.LEFT) then callback() end
|
||||
end
|
||||
draw.rrectf(x,y+1,size,h,1,col2)
|
||||
draw.rrectf(x,y-button_h,size,h,1,col1)
|
||||
draw.text(label,x+2,y+text_y-button_h,col2)
|
||||
if selected then
|
||||
draw.rrect(x-1,y-button_h-1,size+2,h+3+button_h,3,1)
|
||||
end
|
||||
end,
|
||||
|
||||
togglebutton = function(label,x,y,h,col1,col2,dis1,dis2,state,callback,selected)
|
||||
local size = (#label*4)-1+4
|
||||
local text_y = (h-5)//2
|
||||
local bh=0
|
||||
local mx, my = mouse.pos()
|
||||
if mx>=x and mx<x+size and my>=y and my<y+h then
|
||||
bh = mouse.down(mouse.LEFT) and -1 or 1
|
||||
if mouse.press(mouse.LEFT) then callback() end
|
||||
end
|
||||
if not state then
|
||||
col1,col2 = dis1,dis2
|
||||
else
|
||||
if bh>-1 then bh=bh-1 end
|
||||
end
|
||||
draw.rrectf(x,y+1,size,h,1,col2)
|
||||
draw.rrectf(x,y-bh,size,h,1,col1)
|
||||
draw.text(label,x+2,y+text_y-bh,col2)
|
||||
if selected then
|
||||
draw.rrect(x-1,y-bh-1,size+2,h+3+bh,3,1)
|
||||
end
|
||||
end,
|
||||
}
|
||||
function draw.outset(x, y, w, h)
|
||||
draw.rectf(x, y, w, h, 23)
|
||||
w,h = w+x,h+y
|
||||
|
||||
Reference in New Issue
Block a user