Advertisement
NanoBob

dx class example

Aug 23rd, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. InfoWindow={}
  2. function InfoWindow:create(text,timeOut)
  3.     local object={
  4.         element=createElement("genisys-infoBox"),
  5.         text=text,
  6.         relative=relative or false,
  7.         color={25,25,25},
  8.         alpha=220,
  9.         draw=self.draw,
  10.         visible=true,
  11.         enabled=true,
  12.         fontSize=1,
  13.         font="pricedown",
  14.         text=text,
  15.         fading=false
  16.        
  17.     }
  18.     addGlobalFunctions(object)
  19.     genisysGUIObjects[object.element]=object
  20.     setTimer(function(object) if object==nil then return end object.fading=true genisysGUIObjects[object.element]=object end,timeOut or 5000,1,object)
  21.     return object
  22. end
  23.  
  24.  
  25. function drawGenisysInfoWindows()
  26.     local infoBoxes=getElementsByType("genisys-infoBox")
  27.     for i,infoBox in pairs(infoBoxes) do
  28.         local object=genisysGUIObjects[infoBox]
  29.         if object.visible~=false then
  30.             local color=object.color
  31.             if object.fading==true then
  32.                 object.alpha=object.alpha-1
  33.                 if object.alpha==0 then
  34.                      destroyElement(object.element)
  35.                      object=nil
  36.                 end
  37.             end
  38.             if object~=nil then
  39.                 dxDrawRectangle(screenx*0.05,screeny*0.05+(i-1)*screeny*0.14,screenx*0.15,screeny*0.13,tocolor(color[1],color[2],color[3],object.alpha),false)
  40.                 dxDrawText(object.text,screenx*0.05,screeny*0.05+(i-1)*screeny*0.14,screenx*0.15,screeny*0.13+(i-1)*screeny*0.14,tocolor(255,255,255,object.alpha+25),object.fontSize,object.font,"left","top",true,true)      
  41.             end        
  42.         end
  43.     end
  44. end
  45. addEventHandler("onClientRender",getRootElement(),drawGenisysInfoWindows)
  46.  
  47.  
  48. local infoWindow=InfoWindow:create("Welcome to Project Genisys, Enjoy your stay!",7000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement