Advertisement
Bolodefchoco_LUAXML

[UI] ui.addCheckBox

Dec 12th, 2015
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 12/12/2015
  3. --Last update: 16/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Adiciona uma textarea para checkboxes. Pode-se identificar uma ativa/desativa utilizando ui.checkBoxList[id].
  7.     Args:
  8.         n --> Jogador
  9.         alpha --> Opacidade
  10.         x --> Posição horizontal da textarea
  11.         y --> Posição vertical da textarea
  12.         w --> Largura da textarea
  13.         sets --> As opções (tabela)
  14. ]]--
  15.  
  16. ui.checkBoxList={}
  17. ui.addCheckBox=coroutine.wrap(function(n,alpha,x,y,w,sets)
  18.     local id = 0
  19.     while true do
  20.         n = n or nil
  21.         alpha = alpha or 1
  22.         x,y,w = x or 300,y or 90,w or 250
  23.         sets = type(sets)=="table" and sets or {"CheckBox"}
  24.         local checkBoxes = #sets
  25.         ui.addTextArea(id + 0,"",n,x,y-1,w,25*checkBoxes+25,0x5D7D90,0x5D7D90,alpha,true)
  26.         ui.addTextArea(id + 1,"",n,x,y+1,w,25*checkBoxes+25,0x11171C,0x11171C,alpha,true)
  27.         ui.addTextArea(id + 2,"",n,x,y,w,25*checkBoxes+25,0x2E424C,0x2E424C,alpha,true)
  28.         id = id + 3
  29.         for i = 1,checkBoxes do
  30.             ui.addTextArea(id + 0,"<font size='30'><G>•",n,x+5,y-11,nil,nil,1,1,0,true)
  31.             ui.addTextArea(id + 1,"<font size='28' color='#12272A'>•",n,x+5,y-10,nil,nil,1,1,0,true)
  32.             ui.addTextArea(id + 2,"<font size='16'><a href='event:checkBox_add_"..tostring(n).."'>&nbsp;&nbsp;</a>",n,x+9,y,nil,nil,1,1,0,true)
  33.             ui.checkBoxList[id+2]=false
  34.             ui.addTextArea(id + 3,sets[i],n,x+25,y+2,nil,nil,1,1,0,true)
  35.             y = y + 25
  36.             id = id + 4
  37.         end
  38.         ui.addTextArea(id + 5,"",n,x+5,y+5,w-10,15,0x5D7D90,0x5D7D90,alpha,true)
  39.         ui.addTextArea(id + 6,"",n,x+5,y+7,w-10,15,0x11171C,0x11171C,alpha,true)
  40.         ui.addTextArea(id + 7,"<p align='center'><a href='event:checkBox_close_"..checkBoxes.."'>Close</a>",n,x+5,y+6,w-10,15,0x3C5064,0x3C5064,alpha,true)
  41.         id = id + 8
  42.         n,alpha,x,y,w,sets = coroutine.yield()
  43.     end
  44. end)
  45.  
  46. eventTextAreaCallback=function(i,n,c)
  47.     local p = {};for val in c:gmatch("[^_]+") do table.insert(p,val) end
  48.     if p[1] == "checkBox" then
  49.         if p[2] == "close" then
  50.             for v = i-(10+p[3]*4),i do
  51.                 ui.removeTextArea(v,n)
  52.             end
  53.         elseif p[2] == "add" or p[2] == "rem" then
  54.             local what = 0
  55.             if p[2] == "rem" then what=1 end
  56.             ui.checkBoxList[i] = what==0
  57.             ui.updateTextArea(i,("<font size='%d'><a href='event:checkBox_%s'>%s"):format(what==0 and 13 or 16,what==0 and "rem_"..tostring(p[2]).."_"..i or "add_"..tostring(p[2]),what==0 and "•" or "&nbsp;&nbsp;"),v)
  58.         end
  59.     end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement