- Primera pasada de reorganització

This commit is contained in:
2026-03-12 17:30:56 +01:00
parent 8f185fa47c
commit 6c5d7a305a
30 changed files with 965 additions and 1096 deletions

View File

@@ -1,57 +1,40 @@
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,
ui = {}
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
draw.hline(x, h-1, w-1,16)
draw.vline(w-1, y, h-1,16)
draw.hline(x, y, w-1,28)
draw.vline(x, y, h-1,28)
function ui.pushbutton(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
function draw.inset(x, y, w, h)
draw.rectf(x, y, w, h, 23)
w,h = w+x,h+y
draw.hline(x, y, w-1,16)
draw.vline(x, y, h-1,16)
draw.hline(x, h-1, w-1,28)
draw.vline(w-1, y, h-1,28)
end
function ui.togglebutton(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