Advertisement
Guest User

Robo PC with halo pinpong

a guest
Dec 3rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 54.04 KB | None | 0 0
  1.  
  2.  
  3. --[[
  4.  
  5. BOOTSTRAP
  6.  
  7. --===========================
  8. --=== PersonalTable Launcher
  9. --===== 20.11.2014
  10. --===========================
  11.  
  12. http.Fetch( "http://mc.torengo.org/robo/PT/#"..math.random(0,999999999999), function ( data )
  13. RunStringEx( data, "PTXX" )
  14. PT.Ent = ents.GetByIndex( 177 )
  15. end, function (err) print(err) end)
  16. --===========================
  17.  
  18. ------------------------------
  19. --Program About
  20. ------------------------------
  21.  
  22. Apps.appAbout = Apps:Create("appInfo") // Ynikalnoe ima, ne delat sovpodeniy, appInfo zanato
  23. Apps.appAbout.title = "About"
  24. Apps.appAbout.category = "Help"
  25. Apps.appAbout.ico = GUI:GetTextureID( "vgui/e2logo" )
  26. function Apps.appAbout:Init()
  27. end
  28.  
  29. function Apps.appAbout:Draw()
  30. draw.SimpleText( "Personal Table", GUI:GetStyle("button","text","font"), self.Frame.pos.x+self.Frame.size.x/2,
  31. self.Frame.pos.y+35, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  32.  
  33. draw.SimpleText( "Made by RoboLV", GUI:GetStyle("button","text","font"), self.Frame.pos.x+20,
  34. self.Frame.pos.y+80, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  35.  
  36. draw.SimpleText( "Special thanks: ", GUI:GetStyle("button","text","font"), self.Frame.pos.x+20,
  37. self.Frame.pos.y+100, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  38. end
  39.  
  40. Apps:Run(name)
  41.  
  42.  
  43.  
  44. INFO
  45.  
  46. Functions :
  47.  
  48. class PT :
  49. PT:AddScreen( name, scr )
  50. name - screen name ( unique )
  51. scr - Screen source ( Lua Class )
  52.  
  53. scr :
  54. function Init
  55. function Draw
  56. function Update
  57.  
  58. PT:SetScr( id )
  59. id - unique Screen ID
  60.  
  61. PT:DrawMouse()
  62. Draw mouses ( all players )
  63.  
  64. PT:ComputeMouse( ply )
  65. ply - player
  66. retrurn {x,y} mouse position
  67.  
  68. PT:ScrW()
  69. return Screen width
  70.  
  71. PT:ScrH()
  72. return Screen Height
  73.  
  74. class GUI :
  75.  
  76. GUI:Draw()
  77. -- draw GUI
  78.  
  79. GUI:Update()
  80. -- update gui
  81.  
  82. GUI:Register(name, parent)
  83. name - unique elemnt name
  84. parent - base element
  85. return Element
  86.  
  87. GUI:Create ( name )
  88. name - element name
  89. return Element Object
  90.  
  91. ELEMENT LIST = {
  92. Base :
  93.  
  94. Button :
  95.  
  96. }
  97.  
  98.  
  99. --Marlett -- UI font
  100.  
  101. ]]
  102.  
  103. --PT = {}
  104. if not PT then PT = {} end
  105.  
  106. ------------------------------
  107. -- Cfg
  108. ------------------------------
  109. function PT:CFG()
  110.  
  111. self.Ent = ents.GetByIndex( 98 )
  112. self.lEnt = self.Ent
  113.  
  114. self.settings = {
  115. user = {
  116.  
  117. }
  118. }
  119.  
  120. end
  121.  
  122. ------------------------------
  123. -- Init
  124. ------------------------------
  125. function PT:Init()
  126.  
  127. self:CFG()
  128.  
  129. self.screens = {}
  130. self.current = nil
  131.  
  132. self.dev = true
  133.  
  134. self.stats = {
  135. drawStart = 0,
  136. drawTime = 0,
  137. thinkStart = 0,
  138. thinkTime = 0
  139. }
  140.  
  141. self.posDir = self.Ent:GetPos()
  142. self.angles = self.Ent:LocalToWorldAngles( Angle(0,90,0) )
  143.  
  144. self.drawDistance = 400
  145. self.ppi = 0.13
  146. self.size = { x= self.Ent:OBBMaxs()[2]/self.ppi*2, y= self.Ent:OBBMaxs()[1]/self.ppi*2}
  147. self.size.x = math.Round(self.size.x)
  148. self.size.y = math.Round(self.size.y)
  149.  
  150. self.UserCur = self:ComputeMouse( LocalPlayer() )
  151.  
  152. --Hooks
  153. hook.Add("Think", "PT_Screen_Update", function() self:Update() end)
  154. hook.Add("PostDrawOpaqueRenderables", "PT_Screen_Draw", function() self:Draw() end) --PostDrawOpaqueRenderables
  155. end
  156.  
  157. ------------------------------
  158. -- EntChanged
  159. ------------------------------
  160.  
  161. function PT:Reload()
  162.  
  163. self.lEnt = self.Ent
  164. self.size = { x= self.Ent:OBBMaxs()[2]/self.ppi*2, y= self.Ent:OBBMaxs()[1]/self.ppi*2}
  165. self.size.x = math.Round(self.size.x)
  166. self.size.y = math.Round(self.size.y)
  167.  
  168. end
  169.  
  170. ------------------------------
  171. -- Update
  172. ------------------------------
  173. function PT:Update()
  174.  
  175. self.stats.thinkStart = os.clock()
  176.  
  177. if not IsValid( self.Ent ) then return end
  178.  
  179. if self.Ent ~= self.lEnt then
  180. self:Reload()
  181. end
  182.  
  183.  
  184. -- allow proces
  185. if self.current ~= nil then
  186. self.screens[self.current]:Update( self )
  187. end
  188.  
  189. if LocalPlayer():GetPos():Distance(self.Ent:GetPos()) > self.drawDistance then return end
  190.  
  191. self.posDir = self.Ent:GetPos()+self.Ent:GetUp()*self.Ent:OBBMaxs()[3]
  192. - self.Ent:GetForward()*self.Ent:OBBMaxs()[1]
  193. + self.Ent:GetRight()*self.Ent:OBBMaxs()[2]
  194.  
  195. self.angles = self.Ent:LocalToWorldAngles( Angle(0,90,0) )
  196.  
  197. self.UserCur = self:ComputeMouse( LocalPlayer() )
  198.  
  199. self.stats.thinkTime = os.clock() - self.stats.thinkStart
  200. end
  201.  
  202. ------------------------------
  203. -- Draw
  204. ------------------------------
  205. function PT:Draw()
  206. self.stats.drawStart = os.clock()
  207. if not IsValid( self.Ent ) then return end
  208. if LocalPlayer():GetPos():Distance(self.Ent:GetPos()) > self.drawDistance then return end
  209.  
  210. cam.Start3D2D( self.posDir, self.angles , self.ppi )
  211.  
  212. draw.RoundedBox( 0, 0, 0,self.size.x, self.size.y, Color(0, 0, 0, 255))
  213.  
  214. if self.current ~= nil then
  215. self.screens[self.current]:Draw( self )
  216. end
  217.  
  218. if self.dev then
  219.  
  220. draw.DrawText( "Draw time :"..math.Round(self.stats.drawTime*1000,2).."us", "TargetID", 10, self:ScrH()-20, Color( 255, 255, 255, 100 ) )
  221. draw.DrawText( "Think time:"..math.Round(self.stats.thinkTime*1000,2).."us", "TargetID", 10, self:ScrH()-40, Color( 255, 255, 255, 100 ) )
  222. draw.DrawText( "Res :("..self:ScrW().."x"..self:ScrH()..")", "TargetID", 10, self:ScrH()-60, Color( 255, 255, 255, 100 ) )
  223.  
  224. draw.DrawText( "Active Apps:"..#Apps.runing, "TargetID", 10, self:ScrH()-80, Color( 255, 255, 255, 100 ) )
  225.  
  226. draw.DrawText( "Active GUI:"..#GUI.obj, "TargetID", 10, self:ScrH()-100, Color( 255, 255, 255, 100 ) )
  227.  
  228. /*for k,v in pairs(GUI.obj) do
  229. draw.DrawText( k.."-"..v.type.."-"..(v.text or ""), "TargetID", 200, self:ScrH()-k*20, Color( 255, 255, 255, 255 ) )
  230. end*/
  231.  
  232. end
  233.  
  234. self:DrawMouse()
  235. cam.End3D2D()
  236.  
  237. self.stats.drawTime = os.clock() - self.stats.drawStart
  238. end
  239.  
  240. ------------------------------
  241. -- Add screen
  242. ------------------------------
  243.  
  244. function PT:AddScreen( name, scr )
  245.  
  246. self.screens[name] = scr
  247.  
  248. if scr.def and scr.def == true then
  249. self:SetScr( name )
  250. end
  251. end
  252.  
  253. ------------------------------
  254. -- Change screen
  255. ------------------------------
  256. function PT:SetScr( id )
  257. self.current = id
  258. if _G['PT']['screens'][id]['Init'] then
  259. self.screens[id]:Init(self)
  260. end
  261. end
  262.  
  263. ------------------------------
  264. -- Draw Mouse
  265. ------------------------------
  266. function PT:DrawMouse()
  267. mouseTeksture = surface.GetTextureID( "sprites/arrow" )
  268. surface.SetTexture( mouseTeksture )
  269. for k,ply in pairs( player.GetAll() ) do
  270.  
  271. local Xpos = self:ComputeMouse( ply )
  272. if Xpos.x == -1 or Xpos.y == -1 then continue end
  273.  
  274.  
  275. surface.SetDrawColor(25, 25, 25)
  276. surface.DrawTexturedRect( Xpos.x-11,Xpos.y-11, 22, 22 )
  277.  
  278. surface.SetDrawColor(255, 255, 255)
  279. surface.DrawTexturedRect( Xpos.x-10,Xpos.y-10, 20, 20 )
  280.  
  281.  
  282. draw.DrawText( ply:Nick(), "TargetID", 15+Xpos.x, 0+Xpos.y, Color( 255, 255, 255, 255 ) )
  283. end
  284. end
  285.  
  286. ------------------------------
  287. -- Compute mouse to screen
  288. ------------------------------
  289. function PT:ComputeMouse( ply )
  290.  
  291. -- thx to wire Graphic table
  292. local trace = ply:GetEyeTraceNoCursor()
  293. local ent = trace.Entity
  294. if ent:IsValid() and ent == self.Ent then
  295. local dist = trace.Normal:Dot(trace.HitNormal)*trace.Fraction*-16384
  296. dist = math.max(dist, trace.Fraction*16384-ent:BoundingRadius())
  297. if dist < self.drawDistance then
  298. local cpos = WorldToLocal(trace.HitPos, Angle(), self.Ent:GetPos(), self.angles)
  299. local cx = cpos.x/self.ppi+self.size.x/2
  300. local cy = -cpos.y/self.ppi+self.size.y/2
  301. return {x=cx, y=cy}
  302. end
  303. end
  304. return {x=-1, y=-1}
  305. end
  306.  
  307. ------------------------------
  308. -- Screen Width
  309. ------------------------------
  310. function PT:ScrW()
  311. return self.size.x
  312. end
  313.  
  314. ------------------------------
  315. -- Screen Height
  316. ------------------------------
  317. function PT:ScrH()
  318. return self.size.y
  319. end
  320.  
  321. PT:Init()
  322. ------------------------------------------------------------
  323. ------------------------------------------------------------
  324. ------------------------------------------------------------
  325. -- GUI
  326. ---- GUI.lua
  327. ------------------------------------------------------------
  328. ------------------------------------------------------------
  329. ------------------------------------------------------------
  330.  
  331.  
  332. GUI = {}
  333. GUI.obj = {}
  334. GUI.elemnts = {}
  335. GUI.hoveron = nil
  336. GUI.clickon = nil
  337. GUI.texturecache = {}
  338.  
  339. GUI.style={
  340. _current = "def",
  341. def = {
  342. button = {
  343. body = {
  344. def = Color(199,160,30),
  345. hover = Color(160,120,30),
  346. clk = Color(130,100,10),
  347. round = false
  348. },
  349. border = {
  350. def = Color(0,0,0,0),
  351. hover = Color(0,0,0,0),
  352. clk = Color(0,0,0,0)
  353. },
  354. text = {
  355. def = Color(255,255,255),
  356. hover = Color(255,255,255),
  357. clk = Color(255,255,255),
  358. font = "TargetID"
  359. }
  360. },
  361. frame = {
  362. body = {
  363. def = Color(30,30,30,240)
  364. },
  365. border = {
  366. def = Color(100,100,100,240)
  367. }
  368. }
  369. }
  370. }
  371.  
  372. function GUI:GetStyle( el, name, status )
  373. if self.style[self.style._current][el][name][status] then
  374. return self.style[self.style._current][el][name][status]
  375. end
  376. end
  377.  
  378. function GUI:SetStyle(name)
  379. if self.style[name] then
  380. self.style._current = name
  381. end
  382. end
  383.  
  384.  
  385. ------------------------------
  386. -- Draw
  387. ------------------------------
  388. function GUI:Draw( this )
  389. for k,v in pairs( self.obj ) do
  390. if v.parent then continue end
  391. self:DrawChilds(v)
  392. end
  393. end
  394.  
  395. ------------------------------
  396. -- Draw childs
  397. ------------------------------
  398. function GUI:DrawChilds( obj )
  399. if obj.visible then
  400. obj:Draw()
  401. for k,v in pairs( obj.childs ) do
  402. self:DrawChilds( v )
  403. end
  404. end
  405. end
  406.  
  407. ------------------------------
  408. -- Update
  409. ------------------------------
  410. function GUI:Update( this )
  411. for k,v in pairs( table.Reverse(self.obj) ) do
  412. --bug fix D:
  413. if not v.visible and GUI.clickon == v then GUI.clickon = nil end
  414. if v.parent then continue end
  415. self:UpdateChilds(v)
  416. end
  417. end
  418.  
  419. ------------------------------
  420. -- update childs
  421. ------------------------------
  422. function GUI:UpdateChilds( obj )
  423. if obj.visible then
  424. for k,v in pairs( obj.childs ) do
  425. self:UpdateChilds( v )
  426. end
  427. obj:Updatex()
  428. obj:Update()
  429. end
  430. end
  431.  
  432.  
  433. ------------------------------
  434. -- Register element
  435. ------------------------------
  436.  
  437. function GUI:Register(name, parent)
  438.  
  439. local obj = {}
  440.  
  441. if parent then
  442. obj = table.Copy( self.elemnts[parent] )
  443. end
  444. self.elemnts[name] = obj
  445. return obj
  446. end
  447.  
  448. ------------------------------
  449. -- Create/spawn element
  450. ------------------------------
  451.  
  452. function GUI:Create( name, parent )
  453. if not self.elemnts[name] then print("ERROR, element not found") return end
  454.  
  455. local el = {}
  456. el = table.Copy( self.elemnts[name] )
  457. if parent then
  458. el:SetParent(parent)
  459. end
  460. table.insert( self.obj, el )
  461.  
  462. el:Init()
  463. return el
  464. end
  465.  
  466. ------------------------------
  467. -- Clear all elements
  468. ------------------------------
  469.  
  470. function GUI:Clear()
  471. for k,v in pairs(self.obj) do
  472. v:Destruct()
  473. end
  474. self.obj = {}
  475. end
  476.  
  477. ------------------------------
  478. -- Get Texture
  479. ---- Starfall code!
  480. ------------------------------
  481. function GUI:GetTextureID ( tx )
  482. local id = surface.GetTextureID( tx )
  483. if id then
  484. self.texturecache[ id ] = { tx }
  485. local cacheentry = self.texturecache[ id ]
  486. local mat = Material( tx ) -- Hacky way to get ITexture, if there is a better way - do it!
  487. cacheentry[ 2 ] = CreateMaterial( "SF_TEXTURE_" .. id, "UnlitGeneric", {
  488. [ "$nolod" ] = 1,
  489. [ "$ignorez" ] = 1,
  490. [ "$vertexcolor" ] = 1,
  491. [ "$vertexalpha" ] = 1
  492. } )
  493. cacheentry[ 2 ]:SetTexture( "$basetexture", mat:GetTexture( "$basetexture" ) )
  494. return id
  495. end
  496. end
  497.  
  498. --- Sets the texture
  499. -- @param id Texture id
  500. function GUI:SetTexture ( id )
  501. if id then
  502. surface.SetMaterial( self.texturecache[ id ][ 2 ] )
  503. return
  504. end
  505. draw.NoTexture()
  506. end
  507.  
  508.  
  509. ------------------------------------------------------------
  510. ------------------------------------------------------------
  511. ------------------------------------------------------------
  512. -- GUI BASE
  513. ---- gui/base.lua
  514. ------------------------------------------------------------
  515. ------------------------------------------------------------
  516. ------------------------------------------------------------
  517.  
  518. GUI.uBase = GUI:Register("Base")
  519. GUI.uBase.posLocal = {x=10,y=10}
  520. GUI.uBase.pos = {x=10,y=10}
  521. GUI.uBase.size = {x=0,y=0}
  522. GUI.uBase.type = "base"
  523. GUI.uBase.childs = {}
  524. GUI.uBase.parent = false
  525. GUI.uBase.hover = false
  526. GUI.uBase.click = false
  527. GUI.uBase.visible = true
  528. GUI.uBase.clickOnce = false
  529. GUI.uBase.kill = false
  530.  
  531. function GUI.uBase:Draw() end
  532. function GUI.uBase.PostDraw() end
  533. function GUI.uBase:Update() end
  534. function GUI.uBase.PostUpdate() end
  535. function GUI.uBase:Init() end
  536. function GUI.uBase:Destruct() end
  537. function GUI.uBase.OnClose() end
  538.  
  539. function GUI.uBase:ComputeClick()
  540. if self.kill then return end
  541. if not GUI.hoveron or GUI.hoveron == self then
  542. --PT.UserCur
  543. if PT.UserCur.x > self.pos.x and PT.UserCur.x < self.pos.x + self.size.x and
  544. PT.UserCur.y > self.pos.y and PT.UserCur.y < self.pos.y + self.size.y then
  545. GUI.hoveron = self
  546. self.hover = true
  547. else
  548. GUI.hoveron = nil
  549. self.hover = false
  550. end
  551. end
  552.  
  553. if GUI.hoveron == self and input.IsKeyDown( KEY_E ) and ( not GUI.clickon or GUI.clickon==self ) then
  554. GUI.clickon = self
  555. self.click = true
  556. elseif GUI.clickon == self and not input.IsKeyDown( KEY_E ) then
  557. GUI.clickon = nil
  558. self.click = false
  559. self.clickOnce = false
  560. end
  561. end
  562. function GUI.uBase:Updatex()
  563. self:ComputeClick()
  564. end
  565.  
  566. function GUI.uBase:SetPos(x,y)
  567. if self.parent then
  568. self.posLocal.x = x
  569. self.posLocal.y = y
  570.  
  571. self.pos.x = x + self.parent.pos.x
  572. self.pos.y = y + self.parent.pos.y
  573. else
  574. self.pos.x = x
  575. self.pos.y = y
  576. end
  577.  
  578. if #self.childs > 0 then
  579. for k,v in pairs(self.childs) do
  580. v:SetPos(v.posLocal.x, v.posLocal.y)
  581. end
  582. end
  583. end
  584.  
  585. function GUI.uBase:SetSize(w,h)
  586. self.size.x = w
  587. self.size.y = h
  588. end
  589.  
  590. function GUI.uBase:SetParent(obj)
  591. if self.kill then return end
  592. if obj then
  593. table.insert( obj.childs, self )
  594. self.parent = obj
  595.  
  596. self.posLocal.x = self.pos.x
  597. self.posLocal.y = self.pos.y
  598.  
  599. self.pos.x = obj.pos.x + self.posLocal.x
  600. self.pos.y = obj.pos.y + self.posLocal.y
  601. end
  602. end
  603.  
  604. function GUI.uBase:Clip()
  605. if not self.parent then
  606. if self.pos.x+ self.size.x > PT:ScrW() then
  607. self:SetPos(PT:ScrW()-self.size.x,self.pos.y)
  608. end
  609. if self.pos.y+ self.size.y > PT:ScrH() then
  610. self:SetPos(self.pos.x,PT:ScrH()-self.size.y)
  611. end
  612. if self.pos.x < 0 then
  613. self:SetPos(0,self.pos.y)
  614. end
  615. if self.pos.y < 30 then
  616. self:SetPos(self.pos.x,30)
  617. end
  618. end
  619. end
  620.  
  621. function GUI.uBase:Visible(staus)
  622. self.visible = staus
  623. GUI.hoveron = nil
  624. GUI.clickon = nil
  625. self.click = false
  626. self.hover = false
  627. self.clickOnce = false
  628. end
  629.  
  630. function GUI.uBase:LayerTop()
  631. if self.kill then return end
  632. local newTab = {}
  633. for k,v in pairs(GUI.obj) do
  634. if v!=self then
  635. table.insert( newTab, v )
  636. end
  637. end
  638. table.insert( newTab, self )
  639. GUI.obj = {}
  640. GUI.obj = newTab
  641. end
  642.  
  643. function GUI.uBase:Kill()
  644. self.kill = true
  645. for k,v in pairs(self.childs) do
  646. v:Kill()
  647. end
  648. table.RemoveByValue(GUI.obj,self)
  649. self:Destruct()
  650. self = {}
  651. end
  652.  
  653.  
  654. ------------------------------------------------------------
  655. ------------------------------------------------------------
  656. ------------------------------------------------------------
  657. -- GUI BUTTON
  658. ---- gui/button.lua
  659. ------------------------------------------------------------
  660. ------------------------------------------------------------
  661. ------------------------------------------------------------
  662.  
  663. GUI.uButton = GUI:Register("Button","Base")
  664. GUI.uButton.type = "button"
  665. GUI.uButton.text = "uButton"
  666. GUI.uButton.prevCl = false
  667. GUI.uButton.img = nil
  668. GUI.uButton.ico = nil
  669. GUI.uButton.customStyle = false
  670. GUI.uButton.style = GUI.style[GUI.style._current]["button"]
  671.  
  672. function GUI.uButton:OnClick() end
  673. function GUI.uButton:OnUnClick() end
  674. function GUI.uButton:OnClickOnce() end
  675. function GUI.uButton:OnHover() end
  676.  
  677. function GUI.uButton:Draw()
  678. if not self.customStyle then GUI.uButton.style = GUI.style[GUI.style._current]["button"] end
  679.  
  680. if self.click then
  681.  
  682. if not self.style["body"]["round"] then
  683. surface.SetDrawColor( self.style["body"]["clk"] )
  684. surface.DrawRect( self.pos.x, self.pos.y, self.size.x, self.size.y)
  685. else
  686. draw.RoundedBox(self.style["body"]["round"], self.pos.x, self.pos.y, self.size.x, self.size.y, self.style["body"]["clk"] )
  687. end
  688.  
  689. surface.SetDrawColor( self.style["border"]["clk"] )
  690. surface.DrawOutlinedRect( self.pos.x, self.pos.y, self.size.x, self.size.y)
  691.  
  692. if self.img then
  693. surface.SetTexture(surface.GetTextureID( self.img ))
  694. surface.DrawTexturedRect( self.pos.x, self.pos.y, self.size.x, self.size.y)
  695. else
  696.  
  697. if self.ico then
  698. surface.SetTexture(surface.GetTextureID( self.ico ))
  699. surface.DrawTexturedRect( 0,0, 160, 160)
  700. end
  701.  
  702. draw.SimpleText( self.text, self.style["text"]["font"], self.pos.x+self.size.x/2,
  703. self.pos.y+self.size.y/2, self.style["text"]["clk"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  704. end
  705.  
  706. elseif self.hover then
  707.  
  708. if not self.style["body"]["round"] then
  709. surface.SetDrawColor( self.style["body"]["hover"] )
  710. surface.DrawRect( self.pos.x, self.pos.y, self.size.x, self.size.y)
  711. else
  712. draw.RoundedBox(self.style["body"]["round"], self.pos.x, self.pos.y, self.size.x, self.size.y, self.style["body"]["hover"] )
  713. end
  714.  
  715. surface.SetDrawColor( self.style["border"]["hover"] )
  716. surface.DrawOutlinedRect( self.pos.x, self.pos.y, self.size.x, self.size.y)
  717.  
  718. if self.img then
  719. surface.SetTexture(surface.GetTextureID( self.img ))
  720. surface.DrawTexturedRect( self.pos.x, self.pos.y, self.size.x, self.size.y)
  721. else
  722. if self.ico then
  723. surface.SetTexture(surface.GetTextureID( self.ico ))
  724. surface.DrawTexturedRect( 0,0, 160, 160)
  725. end
  726.  
  727. draw.SimpleText( self.text, self.style["text"]["font"], self.pos.x+self.size.x/2,
  728. self.pos.y+self.size.y/2, self.style["text"]["clk"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  729. end
  730. else
  731.  
  732. if not self.style["body"]["round"] then
  733. surface.SetDrawColor( self.style["body"]["def"] )
  734. surface.DrawRect( self.pos.x, self.pos.y, self.size.x, self.size.y)
  735. else
  736. draw.RoundedBox(self.style["body"]["round"], self.pos.x, self.pos.y, self.size.x, self.size.y, self.style["body"]["def"] )
  737. end
  738.  
  739. surface.SetDrawColor( self.style["border"]["def"] )
  740. surface.DrawOutlinedRect( self.pos.x, self.pos.y, self.size.x, self.size.y)
  741.  
  742. if self.img then
  743. surface.SetTexture(surface.GetTextureID( self.img ))
  744. surface.DrawTexturedRect( self.pos.x, self.pos.y, self.size.x, self.size.y)
  745. else
  746. if self.ico then
  747. surface.SetTexture(surface.GetTextureID( self.ico ))
  748. surface.DrawTexturedRect( self.pos.x+8, self.pos.y+self.size.y/2-8, 16, 16)
  749. end
  750.  
  751. draw.SimpleText( self.text, self.style["text"]["font"], self.pos.x+self.size.x/2,
  752. self.pos.y+self.size.y/2, self.style["text"]["clk"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  753. end
  754. end
  755.  
  756.  
  757. end
  758.  
  759. function GUI.uButton:Updatex()
  760. self:ComputeClick()
  761. if self.click then
  762. self.prevCl = true
  763. if not self.clickOnce then
  764. self.clickOnce = true
  765. self:OnClickOnce()
  766. end
  767. self:OnClick()
  768. elseif self.hover then
  769. self:OnHover()
  770. end
  771.  
  772. if self.prevCl and not self.click then
  773. self.prevCl = false
  774. self:OnUnClick()
  775. end
  776. end
  777.  
  778.  
  779. ------------------------------------------------------------
  780. ------------------------------------------------------------
  781. ------------------------------------------------------------
  782. -- GUI Frame
  783. ---- gui/frame.lua
  784. ------------------------------------------------------------
  785. ------------------------------------------------------------
  786. ------------------------------------------------------------
  787.  
  788. GUI.uFrame = GUI:Register("Frame","Base")
  789. GUI.uFrame.type = "frame"
  790. GUI.uFrame.text = "uFrame"
  791.  
  792.  
  793. function GUI.uFrame:Init()
  794.  
  795. self.close = GUI:Create("Button", self)
  796. self.close:SetPos(self.size.x-20, 0)
  797. self.close:SetSize(20,20)
  798. self.close.text = "r"
  799.  
  800. self.close.customStyle = true
  801. self.close.style["text"]["font"] = "Marlett"
  802.  
  803. function self.close:OnClickOnce()
  804. self.parent.OnClose()
  805. self.parent:Visible(false)
  806. end
  807.  
  808. self.full = GUI:Create("Button", self)
  809. self.full:SetPos(self.size.x-41, 0)
  810. self.full:SetSize(20,20)
  811. self.full.text = "1"
  812. self.full.status = true
  813. self.full.customStyle = true
  814. self.full.style["text"]["font"] = "Marlett"
  815. function self.full:OnClickOnce()
  816.  
  817. self.parent:LayerTop()
  818.  
  819. if self.status then
  820. self.text = "2"
  821. self.prevPos = table.Copy(self.parent.pos)
  822. self.prevSize = table.Copy(self.parent.size)
  823.  
  824. self.parent:SetPos(0,30)
  825. self.parent:SetSize(PT:ScrW(), PT:ScrH()-30)
  826. else
  827. self.text = "1"
  828. self.parent:SetPos(self.prevPos.x,self.prevPos.y)
  829. self.parent:SetSize(self.prevSize.x, self.prevSize.y)
  830. end
  831. self.status = not self.status
  832. end
  833.  
  834. self.min = GUI:Create("Button", self)
  835. self.min:SetPos(self.size.x-62, 0)
  836. self.min:SetSize(20,20)
  837. self.min.text = "0"
  838. self.min.customStyle = true
  839. self.min.style["text"]["font"] = "Marlett"
  840. function self.min:OnClickOnce()
  841. end
  842.  
  843. self.move = GUI:Create("Button", self)
  844. self.move:SetPos(0, 0)
  845. self.move:SetSize(20,20)
  846. self.move.text = self.text
  847. self.move.orPos = nil
  848. function self.move:OnClick()
  849. if not self.orPos then
  850. self.orPos = {}
  851. self.orPos.x = PT.UserCur.x - self.parent.pos.x
  852. self.orPos.y = PT.UserCur.y - self.parent.pos.y
  853. self.parent:LayerTop()
  854. end
  855. self.parent:SetPos( PT.UserCur.x - self.orPos.x, PT.UserCur.y - self.orPos.y )
  856. end
  857.  
  858. function self.move:OnUnClick()
  859. self.orPos = nil
  860. end
  861. end
  862.  
  863. function GUI.uFrame:Destruct()
  864. end
  865.  
  866. function GUI.uFrame:Updatex()
  867. self:ComputeClick()
  868. GUI.hoveron = nil
  869. self.close:SetPos(self.size.x-20, 0)
  870. self.full:SetPos(self.size.x-41, 0)
  871. self.min:SetPos(self.size.x-62, 0)
  872. self.move:SetSize(self.size.x-63,20)
  873. self.move.text = self.text
  874. self:Clip()
  875. self.PostUpdate()
  876. --print(self.text)
  877. if self.click then
  878. self:LayerTop()
  879. end
  880. end
  881.  
  882. function GUI.uFrame:Draw()
  883. surface.SetDrawColor( GUI:GetStyle("frame","body","def") )
  884. surface.DrawRect(self.pos.x, self.pos.y, self.size.x, self.size.y)
  885.  
  886. surface.SetDrawColor( GUI:GetStyle("frame","border","def") )
  887. surface.DrawRect( self.pos.x, self.pos.y + 20, self.size.x, 1)
  888.  
  889. self.PostDraw()
  890. end
  891.  
  892.  
  893.  
  894. ------------------------------------------------------------
  895. ------------------------------------------------------------
  896. ------------------------------------------------------------
  897. -- GUI BackGround
  898. ---- gui/bg.lua
  899. ------------------------------------------------------------
  900. ------------------------------------------------------------
  901. ------------------------------------------------------------
  902.  
  903. GUI.uBg = GUI:Register("Background","Base")
  904. GUI.uBg.type = "bg"
  905. GUI.uBg.img = {
  906. GUI:GetTextureID("../backgrounds/gm_astronauts.jpg"),
  907. GUI:GetTextureID("../backgrounds/gm_roaddrift.jpg"),
  908. GUI:GetTextureID("../backgrounds/tf_pipeline.jpg"),
  909. }
  910. GUI.uBg.prev = 1
  911. GUI.uBg.cur = 2
  912. GUI.uBg.tim = 0
  913.  
  914. GUI.uBg.col1 = Color(255,255,255,255)
  915. GUI.uBg.col2 = Color(255,255,255,255)
  916.  
  917. function GUI.uBg:Init()
  918. timer.Create("PT_GUI_BG_img",0,0.1, function() self:ImageChanger() end)
  919. end
  920.  
  921. function GUI.uBg:ImageChanger()
  922. -- 10 = 1 sek
  923. self.tim = self.tim + 1
  924. local t = self.tim
  925. if t < 10 then
  926. GUI.uBg.col2 = Color(255,255,255,255-255/9*t)
  927. elseif t < 100 then
  928. --idle
  929. elseif t<101 then
  930. -- change
  931. if self.prev == # self.img then
  932. self.prev = 1
  933. else
  934. self.prev = self.prev + 1
  935. end
  936. elseif t< 110 then
  937. GUI.uBg.col2 = Color(255,255,255,255/9*t)
  938. elseif t<200 then
  939. --idle
  940. else
  941. self.tim = 0
  942. if self.cur == # self.img then
  943. self.cur = 1
  944. else
  945. self.cur = self.cur + 1
  946. end
  947. end
  948. end
  949.  
  950. function GUI.uBg:Destruct()
  951. timer.Remove("PT_GUI_BG_img")
  952. end
  953.  
  954. function GUI.uBg:Updatex() end
  955.  
  956. function GUI.uBg:Draw()
  957. surface.SetDrawColor( GUI.uBg.col1 )
  958. GUI:SetTexture(self.img[self.cur] )
  959. surface.DrawTexturedRect(self.pos.x, self.pos.y, self.size.x, self.size.y)
  960.  
  961. surface.SetDrawColor( GUI.uBg.col2 )
  962. GUI:SetTexture(self.img[self.prev] )
  963. surface.DrawTexturedRect(self.pos.x, self.pos.y, self.size.x, self.size.y)
  964. end
  965.  
  966. function GUI.uBg:Update()
  967. end
  968.  
  969. ------------------------------------------------------------
  970. ------------------------------------------------------------
  971. ------------------------------------------------------------
  972. -- GUI TaskPanel
  973. ---- gui/tp.lua
  974. ------------------------------------------------------------
  975. ------------------------------------------------------------
  976. ------------------------------------------------------------
  977.  
  978. GUI.uTP = GUI:Register("TaskPanel","Base")
  979. GUI.uTP.type = "tp"
  980. GUI.uTP.appCount = 0
  981. GUI.uTP.menus = {}
  982. GUI.uTP.category = {
  983. {
  984. category = "PT",
  985. img = nil,
  986. w = 40,
  987. text= "PT"
  988. },
  989. {
  990. category = "Internet",
  991. img = nil,
  992. w = 80,
  993. text= "Internet"
  994. },
  995. {
  996. category = "Media",
  997. img = nil,
  998. w = 60,
  999. text= "Media"
  1000. },
  1001. {
  1002. category = "Help",
  1003. img = nil,
  1004. w = 50,
  1005. text= "Help"
  1006. }
  1007. }
  1008.  
  1009. function GUI.uTP:Init()
  1010. self:SetPos(0,0)
  1011. self:SetSize(PT:ScrW(), 30)
  1012. end
  1013.  
  1014. function GUI.uTP:Destruct()
  1015. end
  1016.  
  1017. function GUI.uTP:Updatex()
  1018.  
  1019.  
  1020. if self.appCount ~= table.Count(Apps.list) then
  1021. -- clear old menu
  1022. for k,v in pairs(self.menus) do
  1023. v:Kill()
  1024. end
  1025.  
  1026. local prewW = 0
  1027. -- Create new menus
  1028. for k,v in pairs(self.category) do
  1029.  
  1030. local menu = GUI:Create("TaskPanelDD", self)
  1031. menu:SetPos(1+prewW, 0)
  1032. menu:SetSize(v.w,29)
  1033. menu.text = v.text
  1034.  
  1035. prewW = prewW + v.w+1
  1036.  
  1037. for aid,app in pairs(Apps.list) do
  1038. if app.category == v.category then
  1039.  
  1040. local appItem = GUI:Create("Button")
  1041. appItem:SetSize(110,30)
  1042. appItem.runAppId = app.name
  1043. appItem.text = app.title
  1044.  
  1045. if app.ico then
  1046. appItem.ico = app.ico
  1047. end
  1048.  
  1049. function appItem:OnClickOnce()
  1050. Apps:Run(self.runAppId)
  1051. self.parent.show = false
  1052. end
  1053.  
  1054. menu:AddItem(appItem)
  1055.  
  1056. end
  1057. end
  1058. end
  1059. self.appCount = table.Count(Apps.list)
  1060. end
  1061. end
  1062.  
  1063. function GUI.uTP:Draw()
  1064. surface.SetDrawColor( Color(30,30,30,200) )
  1065. surface.DrawTexturedRect(self.pos.x, self.pos.y, self.size.x, self.size.y)
  1066.  
  1067. surface.SetDrawColor( Color(100,100,100,200) )
  1068. surface.DrawLine( self.pos.x, self.size.y, PT:ScrW(), self.size.y)
  1069.  
  1070. -- time
  1071. draw.SimpleText( os.date( "%X" , os.time() ), GUI:GetStyle("button","text","font"), self.size.x-5,
  1072. 15, GUI:GetStyle("button","text","clk"), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
  1073. end
  1074.  
  1075. function GUI.uTP:Update()
  1076. end
  1077.  
  1078.  
  1079. ------------------------------------------------------------
  1080. ------------------------------------------------------------
  1081. ------------------------------------------------------------
  1082. -- GUI TaskPanelDropDown
  1083. ---- gui/TPDropDown.lua
  1084. ------------------------------------------------------------
  1085. ------------------------------------------------------------
  1086. ------------------------------------------------------------
  1087.  
  1088. GUI.uTPDD = GUI:Register("TaskPanelDD","Button")
  1089. GUI.uTPDD.type = "tpdd"
  1090. GUI.uTPDD.elList = {}
  1091. GUI.uTPDD.show = false
  1092. GUI.uTPDD.showCheck = false
  1093. GUI.uTPDD.elSize = 0
  1094.  
  1095. function GUI.uTPDD:Init()
  1096. end
  1097.  
  1098. function GUI.uTPDD:Destruct()
  1099. end
  1100.  
  1101. function GUI.uTPDD:AddItem(item)
  1102. item:SetParent(self)
  1103. item:Visible(false)
  1104. table.insert(self.elList, item)
  1105. end
  1106.  
  1107. function GUI.uTPDD:OnClickOnce()
  1108. self.show = not self.show
  1109. self.showCheck = self.show
  1110. if self.show then
  1111. self.elSize = self.size.y
  1112. for k,v in pairs( self.elList ) do
  1113. v:SetPos(1, 1 + self.elSize )
  1114. --v:SetSize(self.size.x-2, v.size.y)
  1115. self.elSize = self.elSize + v.size.y + 1
  1116. v:Visible(true)
  1117.  
  1118. end
  1119. self:LayerTop()
  1120. else
  1121. for k,v in pairs( self.elList ) do
  1122. v:Visible(false)
  1123. end
  1124. end
  1125. GUI.hoveron = self
  1126. end
  1127.  
  1128. function GUI.uTPDD:Update()
  1129. if self.showCheck != self.show and self.showCheck then
  1130. for k,v in pairs( self.elList ) do
  1131. v:Visible(false)
  1132. end
  1133. self.showCheck = self.show
  1134. end
  1135. end
  1136.  
  1137.  
  1138. ------------------------------------------------------------
  1139. ------------------------------------------------------------
  1140. ------------------------------------------------------------
  1141. -- GUI TaskPanelDropDown
  1142. ---- gui/KeyBoard.lua
  1143. ------------------------------------------------------------
  1144. ------------------------------------------------------------
  1145. ------------------------------------------------------------
  1146.  
  1147. GUI.uKeyB = GUI:Register("KeyBoard","Base")
  1148. GUI.uKeyB.type = "keyb"
  1149. GUI.uKeyB.show = false
  1150. GUI.uKeyB.lang = "en"
  1151. GUI.uKeyB.shift = false
  1152. GUI.uKeyB.keysEl = {}
  1153. GUI.uKeyB.keys = {
  1154. en = {
  1155. "`1234567890-=",
  1156. "Tqwertyuiop[]",
  1157. "Casdfghjkl;'\\",
  1158. "Szxcvbnm,./",
  1159. "MNBSEL"
  1160. },
  1161. ru = {
  1162. "`1234567890-=",
  1163. "TаЙб†бƒаКаЕаНаГбˆб‰аЗб…бŠ",
  1164. "Cб„б‹аВаАаПб€аОаЛаДаЖб\\",
  1165. "Sбб‡баМаИб‚бŒаБбŽ.",
  1166. "MNBSEL"
  1167. }
  1168. }
  1169.  
  1170. function GUI.uKeyB:Togle()
  1171. self.show = not self.show
  1172. if self.show then
  1173. self:Visible(true)
  1174. --self:TopLayer()
  1175. else
  1176. self:Visible(false)
  1177. end
  1178.  
  1179.  
  1180. self.skeys = {
  1181. T = {
  1182. text = "Tab",
  1183. w = 100,
  1184. call = function(this) end
  1185. },
  1186. C = {
  1187. text = "Caps Lock",
  1188. w = 110,
  1189. call = function(this) end
  1190. },
  1191. S = {
  1192. text = "Shift",
  1193. w = 120,
  1194. call = function(this)
  1195. this.parent.shift = not this.parent.shift
  1196. for k,v in pairs( this.parent.keysEl ) do
  1197. if string.len(v.text) > 1 then continue end
  1198.  
  1199. if this.parent.shift then
  1200. v.text = string.upper(v.text)
  1201. else
  1202. v.text = string.lower(v.text)
  1203. end
  1204. end
  1205. end
  1206. },
  1207. B = {
  1208. text="_______",
  1209. w=200,
  1210. call = function(this) end
  1211. },
  1212. M = {
  1213. text = "Ctrl",
  1214. w = 120,
  1215. call = function(this) end
  1216. },
  1217. N = {
  1218. text = "Alt",
  1219. w = 120,
  1220. call = function(this) end
  1221. },
  1222. L = {
  1223. text = "Lang: "..self.lang,
  1224. w = 120,
  1225. call = function(this)
  1226.  
  1227. end
  1228. },
  1229. E = {
  1230. text = "Enter",
  1231. w = 120,
  1232. call = function(this) end
  1233. }
  1234. }
  1235.  
  1236.  
  1237.  
  1238. end
  1239.  
  1240. function GUI.uKeyB:Updatex() end
  1241.  
  1242. function GUI.uKeyB:SpawnButtons()
  1243.  
  1244. for k,v in pairs( self.keysEl ) do
  1245. v:Kill()
  1246. table.remove(self.keysEl,k)
  1247. end
  1248.  
  1249. for rid,row in pairs(self.keys[self.lang]) do
  1250.  
  1251. local clen = string.len(row)
  1252. local butLen = math.floor((PT:ScrW()-clen+1)/clen)
  1253.  
  1254. local xpos = 0
  1255. local xlen = 0
  1256. local xout = 0
  1257.  
  1258. for ch=1, clen do
  1259. --print(rid.."["..ch.."]["..row[ch].."]")
  1260.  
  1261. local text = row[ch]
  1262. local buttonLen = butLen
  1263.  
  1264. self.keysEl[rid..ch] = GUI:Create("Button",self)
  1265.  
  1266. local elem = self.keysEl[rid..ch]
  1267.  
  1268. if self.skeys[row[ch]] then
  1269. xout = xout +1
  1270. text = self.skeys[row[ch]].text
  1271. buttonLen= self.skeys[row[ch]].w or buttonLen
  1272. butLen = math.floor((PT:ScrW()-(clen+1))/(clen+xout))
  1273. elem.callbeckKeyb = self.skeys[row[ch]].call
  1274. function elem:OnClickOnce()
  1275. self.callbeckKeyb(self)
  1276. end
  1277. else
  1278.  
  1279. end
  1280.  
  1281. elem.text = text
  1282. elem:SetPos(xpos, (rid-1)*51)
  1283. elem:SetSize(buttonLen,50)
  1284.  
  1285. xpos = xpos + buttonLen + 1
  1286. end
  1287. end
  1288.  
  1289. self:SetPos(0,(PT:ScrH()+#self.keys[self.lang]-1)-(#self.keys[self.lang]*50))
  1290. self:SetSize(PT:ScrW(),(#self.keys[self.lang]*50))
  1291.  
  1292. end
  1293.  
  1294. function GUI.uKeyB:Init()
  1295.  
  1296. self:Togle()
  1297. self:SpawnButtons()
  1298.  
  1299. end
  1300.  
  1301. function GUI.uKeyB:Destruct()
  1302. end
  1303.  
  1304. function GUI.uKeyB:Update()
  1305. end
  1306.  
  1307. function GUI.uKeyB:Draw()
  1308. surface.SetDrawColor( Color(30,30,30,240) )
  1309. surface.DrawRect(self.pos.x, self.pos.y, self.size.x, self.size.y)
  1310. end
  1311.  
  1312. ------------------------------------------------------------
  1313. ------------------------------------------------------------
  1314. ------------------------------------------------------------
  1315. -- Apps
  1316. ---- apps.lua
  1317. ------------------------------------------------------------
  1318. ------------------------------------------------------------
  1319. ------------------------------------------------------------
  1320.  
  1321. Apps = Apps or {}
  1322. Apps.list = {}
  1323. Apps.runing = {}
  1324.  
  1325. function Apps:Create(name)
  1326. local app = {}
  1327. app = table.Copy(self.base)
  1328. app.name = name
  1329. self.list[name] = app
  1330. return app
  1331. end
  1332.  
  1333. function Apps:Run(name)
  1334. if not self.list[name] then return end
  1335. local app = table.Copy( self.list[name] )
  1336. table.insert(self.runing, app)
  1337. app:SysInit()
  1338. end
  1339.  
  1340.  
  1341. function Apps:Draw()
  1342. for k,v in pairs(self.runing) do
  1343. v:SysDraw()
  1344. end
  1345. end
  1346.  
  1347. function Apps:Update()
  1348. for k,v in pairs(self.runing) do
  1349. v:SysDraw()
  1350. end
  1351. end
  1352.  
  1353. -- BASE
  1354.  
  1355. Apps.base = {}
  1356. Apps.base.title = "Some App"
  1357. Apps.base.window = true
  1358. Apps.base.category = "Other"
  1359.  
  1360. function Apps.base:SysInit()
  1361.  
  1362. self.Frame = GUI:Create("Frame")
  1363. self.Frame:SetPos(100+math.random(0,100),100+math.random(0,100))
  1364. self.Frame:SetSize(200,200)
  1365. self.Frame.text = self.title
  1366. self.Frame.PostDraw = function()
  1367. self:Draw()
  1368. end
  1369. self.Frame.PostUpdate = function()
  1370. self.Frame.text = self.title
  1371. self:Update()
  1372. end
  1373.  
  1374. self.Frame.OnClose = function()
  1375. self:Stop()
  1376. self:Destruct()
  1377. end
  1378.  
  1379. self:Init()
  1380. end
  1381.  
  1382. function Apps.base:Destruct()
  1383. end
  1384.  
  1385. function Apps.base:Stop()
  1386. self.Frame:Kill()
  1387. table.RemoveByValue( Apps.runing, self )
  1388. end
  1389.  
  1390. function Apps.base:Init()
  1391. end
  1392.  
  1393. function Apps.base:Update()
  1394. end
  1395.  
  1396. function Apps.base:Draw()
  1397. end
  1398.  
  1399. ------------------------------
  1400. --Program About
  1401. ------------------------------
  1402.  
  1403. Apps.appPin = Apps:Create("appPin") // Ynikalnoe ima, ne delat sovpodeniy, appInfo zanato
  1404. Apps.appPin.title = "PinPong"
  1405. Apps.appPin.category = "Media"
  1406. Apps.appPin.ico = GUI:GetTextureID( "sprites/sent_ball")
  1407.  
  1408. function Apps.appPin:Init()
  1409. ------| Changeble values |------
  1410. box_speed = 2.5 -- game speed / variable from 0 to 3.5, maybe 4
  1411. critical_fps = 8 -- number of fps, when game speed will not math on player fps.
  1412. BallSize_init = 1 -- ball size
  1413. --------------------------------
  1414. pos_y = 0 pos_x = 0 pos2_y = 0 pos2_x = 0 can_play = 0 Bpos_x = 0 Bpos_y = 0 Bvel_x = -box_speed*1.8 Bvel_y = 0 Bcolor = Color( 255, 255, 255 ) pl_1 = 0 pl_2 = 0
  1415. limit = 4 -- ball speed limit / do not change this value
  1416.  
  1417. FSize = self.Frame.size
  1418. FPos = self.Frame.pos
  1419. end
  1420.  
  1421. function Apps.appPin:Spawn(num)
  1422. if num == 1 then pl_1 = pl_1 + 1 elseif num ~= 0 then pl_2 = pl_2 + 1 end
  1423. Bpos_x = (FSize.x/2 - BallSize/2) Bpos_y = (FSize.y/2 - BallSize/2) Bvel_x = -box_speed*1.5 Bvel_y = 0 can_play = 0
  1424. Bcolor = Color( math.random(30,255), math.random(31,255), math.random(32,255) ) pos2_y = (Bpos_y + FPos.y)
  1425. end
  1426.  
  1427. function Apps.appPin:Update()
  1428.  
  1429. -- \/ ------------------------------------------------------------------- \/ -| Our_line |- \/ --------------
  1430.  
  1431. size_x = (self.Frame.size.x*0.02)
  1432. size_y = (self.Frame.size.y*0.2)
  1433.  
  1434. pos_x = (self.Frame.pos.x + self.Frame.size.x/20 - size_x/2)
  1435.  
  1436. local aimpos_y = (PT.UserCur.y - size_y/2)
  1437.  
  1438. if((0.02/FrameTime()*45) < critical_fps) then
  1439. box_speed_result = (self.Frame.size.y/(200/box_speed))
  1440. else
  1441. box_speed_result = (self.Frame.size.y/(200/box_speed))*(FrameTime()*45)
  1442. end
  1443.  
  1444. local UpLimit = (self.Frame.pos.y + self.Frame.size.y*0.1)
  1445. local DownLimit = (self.Frame.pos.y + self.Frame.size.y/1.25)
  1446.  
  1447. if pos_y < aimpos_y then pos_y = math.Clamp(pos_y + box_speed_result, pos_y, aimpos_y)
  1448. else pos_y = math.Clamp(pos_y - box_speed_result, aimpos_y, pos_y) end
  1449.  
  1450. if pos_y > DownLimit then pos_y = DownLimit end
  1451. if pos_y < UpLimit then pos_y = UpLimit end
  1452.  
  1453. -- /\ ------------------------------------------------------------------- /\ -| Our_line |- /\ --------------
  1454.  
  1455. --
  1456. --
  1457. --
  1458.  
  1459. -- \/ ------------------------------------------------------------------- \/ -| Ball |- \/ --------------
  1460.  
  1461. BallSize = (self.Frame.size.y/10)*BallSize_init
  1462.  
  1463. if self.Frame.click and can_play == 0 then can_play = 1 end
  1464.  
  1465. if can_play == 0 and Bpos_y ~= (self.Frame.size.y/2 - BallSize/2) then self:Spawn(0) end
  1466.  
  1467. if can_play == 1 then
  1468.  
  1469. Bpos_x = Bpos_x + Bvel_x*box_speed_result/2
  1470. Bpos_y = Bpos_y - Bvel_y*box_speed_result/2
  1471.  
  1472. local BallPos1_x = (Bpos_x - BallSize/4 + self.Frame.pos.x)
  1473. local BallPos2_x = (Bpos_x + BallSize/3.8 + self.Frame.pos.x)
  1474.  
  1475. local BallPos1_y = (Bpos_y - BallSize/3 + self.Frame.pos.y)
  1476. local BallPos2_y = (Bpos_y + BallSize/3 + self.Frame.pos.y)
  1477.  
  1478. if (BallPos1_x < (pos_x + BallSize/4) and BallPos1_y < (pos_y + size_y/1.2) and BallPos2_y > (pos_y - (size_y/2)/1.5) and Bvel_x < 0)
  1479. then Bvel_x = -Bvel_x Bvel_y = (Bvel_y + math.random(-1,1)) end -- Our_line with FPS
  1480.  
  1481. if (self.Frame.pos.x + Bpos_x) < (self.Frame.pos.x) then self:Spawn(2) end
  1482.  
  1483. if (self.Frame.pos.x + Bpos_x) > (self.Frame.pos.x + self.Frame.size.x - self.Frame.size.x/20) then self:Spawn(1) end
  1484.  
  1485. local Up = (self.Frame.pos.y + self.Frame.size.y*0.05)
  1486. local Down = (self.Frame.pos.y + self.Frame.size.y - BallSize/1.1)
  1487.  
  1488. if ((BallPos1_y < Up and Bvel_y > 0) or (BallPos2_y > Down and Bvel_y < 0))
  1489. then
  1490. Bvel_x = Bvel_x Bvel_y = (-Bvel_y + math.random(-1,1)) end -- UpDown
  1491. if (Bvel_y > -0.3 and Bvel_y < 0) then Bvel_y = -0.3 end
  1492. if (Bvel_y < 0.3 and Bvel_y > 0) then Bvel_y = 0.3 end
  1493. end
  1494.  
  1495. if(Bvel_x > limit) then Bvel_x = limit end if(Bvel_x < -limit) then Bvel_x = -limit end if(Bvel_y > limit) then Bvel_y = limit end if(Bvel_y < -limit) then Bvel_y = -limit end
  1496.  
  1497. -- /\ ------------------------------------------------------------------- /\ -| Ball |- /\ --------------
  1498.  
  1499. --
  1500. --
  1501. --
  1502.  
  1503. -- \/ ------------------------------------------------------------------- \/ -| Bot_line |- \/ --------------
  1504.  
  1505. size2_x = (self.Frame.size.x*0.02)
  1506. size2_y = (self.Frame.size.y*0.2)
  1507.  
  1508. pos2_x = (self.Frame.pos.x + self.Frame.size.x - self.Frame.size.x/20 - size2_x/2)
  1509.  
  1510. local BallPos1_x = (Bpos_x + BallSize/2 + self.Frame.pos.x)
  1511. local BallPos2_x = (Bpos_x - BallSize/1.8 + self.Frame.pos.x)
  1512.  
  1513. local BallPos1_y = (Bpos_y - BallSize/3 + self.Frame.pos.y)
  1514. local BallPos2_y = (Bpos_y + BallSize/3 + self.Frame.pos.y)
  1515.  
  1516. if (BallPos1_x > (pos2_x - BallSize/2) and BallPos1_y < (pos2_y + size2_y/1.2) and BallPos2_y > (pos2_y - (size2_y/2)/1.5) and Bvel_x > 0)
  1517. then Bvel_x = -Bvel_x Bvel_y = (Bvel_y + math.random(-1,1)) end -- Bot_line with FPS
  1518.  
  1519. local target_y = (self.Frame.pos.y + Bpos_y)
  1520.  
  1521. if pos2_y < target_y then pos2_y = math.Clamp(pos2_y + box_speed_result, pos2_y, target_y)
  1522. else pos2_y = math.Clamp(pos2_y - box_speed_result, target_y, pos2_y) end
  1523.  
  1524. if pos2_y > DownLimit then pos2_y = DownLimit end
  1525. if pos2_y < UpLimit then pos2_y = UpLimit end
  1526.  
  1527. -- /\ ------------------------------------------------------------------- /\ -| Bot_line |- /\ --------------
  1528.  
  1529. end
  1530.  
  1531. function Apps.appPin:Draw()
  1532.  
  1533. draw.SimpleText( "#Score:", GUI:GetStyle("button","text","font"), self.Frame.pos.x+self.Frame.size.x/2, self.Frame.pos.y + PT:ScrH()/23.5, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  1534.  
  1535. draw.SimpleText( "P1: "..pl_1.." P2: "..pl_2, GUI:GetStyle("button","text","font"), self.Frame.pos.x+self.Frame.size.x/2, self.Frame.pos.y + PT:ScrH()/16.3, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  1536.  
  1537. -- \/ ------------------------------------------------------------------- \/ -| Ball |- \/ --------------
  1538.  
  1539. local TexturedQuadStructure = {
  1540. texture = surface.GetTextureID( 'sprites/sent_ball' ),
  1541. color = Bcolor,
  1542. x = (self.Frame.pos.x + Bpos_x),
  1543. y = (self.Frame.pos.y + Bpos_y),
  1544. w = BallSize,
  1545. h = BallSize
  1546. }
  1547. draw.TexturedQuad( TexturedQuadStructure )
  1548.  
  1549. if(can_play == 0) then
  1550. draw.SimpleText( "#Press 'E' to start ", GUI:GetStyle("button","text","font"),
  1551. self.Frame.pos.x+self.Frame.size.x/2, self.Frame.pos.y+self.Frame.size.y/1.65, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  1552. end
  1553.  
  1554. -- /\ ------------------------------------------------------------------- /\ -| Ball |- /\ --------------
  1555.  
  1556. --
  1557. --
  1558. --
  1559.  
  1560. -- \/ ------------------------------------------------------------------- \/ -| Our_line |- \/ --------------
  1561.  
  1562. draw.RoundedBox( 0, pos_x, pos_y, size_x, size_y, Color(255,255,255) )
  1563.  
  1564. -- /\ ------------------------------------------------------------------- /\ -| Our_line |- /\ --------------
  1565.  
  1566. --
  1567. --
  1568. --
  1569.  
  1570. -- \/ ------------------------------------------------------------------- \/ -| Bot_line |- \/ --------------
  1571.  
  1572. draw.RoundedBox( 0, pos2_x, pos2_y, size2_x, size2_y, Color(255,255,255) )
  1573.  
  1574. -- /\ ------------------------------------------------------------------- /\ -| Bot_line |- /\ --------------
  1575.  
  1576. end
  1577.  
  1578. Apps:Run("appPin")
  1579.  
  1580.  
  1581. ------------------------------
  1582. -- Program About
  1583. ------------------------------
  1584.  
  1585. Apps.appAbout = Apps:Create("appInfo")
  1586. Apps.appAbout.title = "About"
  1587. Apps.appAbout.category = "Help"
  1588. Apps.appAbout.ico = "vgui/e2logo"
  1589. function Apps.appAbout:Init()
  1590. end
  1591.  
  1592. function Apps.appAbout:Draw()
  1593. draw.SimpleText( "Personal Table", GUI:GetStyle("button","text","font"), self.Frame.pos.x+self.Frame.size.x/2,
  1594. self.Frame.pos.y+35, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  1595.  
  1596. draw.SimpleText( "Made by RoboLV", GUI:GetStyle("button","text","font"), self.Frame.pos.x+20,
  1597. self.Frame.pos.y+80, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  1598.  
  1599. draw.SimpleText( "Special thanks: ", GUI:GetStyle("button","text","font"), self.Frame.pos.x+20,
  1600. self.Frame.pos.y+100, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  1601. end
  1602.  
  1603.  
  1604. ------------------------------
  1605. -- Program About
  1606. ------------------------------
  1607.  
  1608. Apps.sysSettings = Apps:Create("sysSettings")
  1609. Apps.sysSettings.title = "Setings"
  1610. Apps.sysSettings.category = "PT"
  1611. Apps.sysSettings.ico = "vgui/e2logo"
  1612. function Apps.sysSettings:Init()
  1613. self.Frame:SetSize(400,400)
  1614. end
  1615.  
  1616. function Apps.sysSettings:Draw()
  1617.  
  1618. end
  1619.  
  1620.  
  1621. Apps.mediaPlayer = Apps:Create("mediaVKMusic")
  1622. Apps.mediaPlayer.title = "VKMusic"
  1623. Apps.mediaPlayer.category = "Media"
  1624. Apps.mediaPlayer.ico = "vgui/e2logo"
  1625. Apps.mediaPlayer.height = 0
  1626. Apps.mediaPlayer.itemCount = 0
  1627. Apps.mediaPlayer.rebuild = false
  1628.  
  1629. Apps.mediaPlayer.playing = nil
  1630. Apps.mediaPlayer.stream = nil
  1631. Apps.mediaPlayer.lastSongID = 2
  1632.  
  1633. Apps.mediaPlayer.musicButons = {}
  1634. Apps.mediaPlayer.musicList = {}
  1635. Apps.mediaPlayer.page = 0
  1636. Apps.mediaPlayer.token = "dfe8bf7bd3e86ab3d9d114bbd88f6adbad61e69adf27c47a5783045b2332403bbc0261e6776808b2f623e"
  1637.  
  1638. function Apps.mediaPlayer:Init()
  1639.  
  1640. self:FindMusicByID( 44110706 )
  1641.  
  1642. self.Frame:SetSize(400,400)
  1643.  
  1644. self.playButton = GUI:Create("Button", self.Frame)
  1645. self.playButton:SetPos(5, 25)
  1646. self.playButton:SetSize(30,30)
  1647. self.playButton.text = "8"
  1648. self.playButton.customStyle = true
  1649. self.playButton.style["body"]["def"] = Color(0,100,150)
  1650. self.playButton.style["body"]["hover"] = Color(0,80,130)
  1651. self.playButton.style["body"]["clk"] = Color(0,60,120)
  1652. self.playButton.style["body"]["round"] = 2
  1653. self.playButton.style["text"]["font"] = "Marlett"
  1654.  
  1655. function self.playButton.OnClickOnce()
  1656. if self.playButton.text == "8" then
  1657. if #self.musicList>0 and self.lastSongID > self.musicList[1] then
  1658. self.lastSongID = 2
  1659. end
  1660. self:PlayID( self.lastSongID )
  1661. else
  1662. self:StopPlay()
  1663. end
  1664. self.rebuild = true
  1665. end
  1666.  
  1667. self.playPrevButton = GUI:Create("Button", self.Frame)
  1668. self.playPrevButton:SetPos(40, 30)
  1669. self.playPrevButton:SetSize(30,20)
  1670. self.playPrevButton.text = "33"
  1671. self.playPrevButton.customStyle = true
  1672. self.playPrevButton.style["body"]["def"] = Color(0,100,150)
  1673. self.playPrevButton.style["body"]["hover"] = Color(0,80,130)
  1674. self.playPrevButton.style["body"]["clk"] = Color(0,60,120)
  1675. self.playPrevButton.style["body"]["round"] = 2
  1676. self.playPrevButton.style["text"]["font"] = "Marlett"
  1677.  
  1678. function self.playPrevButton.OnClickOnce()
  1679. if self.lastSongID > 2 then
  1680. self:PlayID( self.lastSongID - 1 )
  1681. self.rebuild = true
  1682. end
  1683. end
  1684.  
  1685. self.playNextButton = GUI:Create("Button", self.Frame)
  1686. self.playNextButton:SetPos(75, 30)
  1687. self.playNextButton:SetSize(30,20)
  1688. self.playNextButton.text = "88"
  1689. self.playNextButton.customStyle = true
  1690. self.playNextButton.style["body"]["def"] = Color(0,100,150)
  1691. self.playNextButton.style["body"]["hover"] = Color(0,80,130)
  1692. self.playNextButton.style["body"]["clk"] = Color(0,60,120)
  1693. self.playNextButton.style["body"]["round"] = 2
  1694. self.playNextButton.style["text"]["font"] = "Marlett"
  1695.  
  1696. function self.playNextButton.OnClickOnce()
  1697. if self.lastSongID <= #self.musicList then
  1698. self:PlayID( self.lastSongID + 1 )
  1699. self.rebuild = true
  1700. end
  1701. end
  1702.  
  1703. self.pagePrevButton = GUI:Create("Button", self.Frame)
  1704. self.pagePrevButton:SetPos(5, self.Frame.size.y - 35 )
  1705. self.pagePrevButton:SetSize( (self.Frame.size.x-150)/2 - 10 ,30)
  1706. self.pagePrevButton.text = "33"
  1707. self.pagePrevButton.customStyle = true
  1708. self.pagePrevButton.style["body"]["def"] = Color(0,100,150)
  1709. self.pagePrevButton.style["body"]["hover"] = Color(0,80,130)
  1710. self.pagePrevButton.style["body"]["clk"] = Color(0,60,120)
  1711. self.pagePrevButton.style["body"]["round"] = 2
  1712. self.pagePrevButton.style["text"]["font"] = "Marlett"
  1713.  
  1714. function self.pagePrevButton.OnClickOnce()
  1715. if self.page > 1 then
  1716. self.page = self.page - 1
  1717. self.rebuild = true
  1718. end
  1719. end
  1720.  
  1721. self.pageNextButton = GUI:Create("Button", self.Frame)
  1722. self.pageNextButton:SetPos(5 + (self.Frame.size.x-150)/2, self.Frame.size.y - 35 )
  1723. self.pageNextButton:SetSize( (self.Frame.size.x-150)/2 - 10 ,30)
  1724. self.pageNextButton.text = "88"
  1725. self.pageNextButton.customStyle = true
  1726. self.pageNextButton.style["body"]["def"] = Color(0,100,150)
  1727. self.pageNextButton.style["body"]["hover"] = Color(0,80,130)
  1728. self.pageNextButton.style["body"]["clk"] = Color(0,60,120)
  1729. self.pageNextButton.style["body"]["round"] = 2
  1730. self.pageNextButton.style["text"]["font"] = "Marlett"
  1731.  
  1732. function self.pageNextButton.OnClickOnce()
  1733. self.page = self.page + 1
  1734. self.rebuild = true
  1735. end
  1736.  
  1737. end
  1738.  
  1739. function Apps.mediaPlayer:Draw()
  1740.  
  1741. -- BG
  1742. surface.SetDrawColor( Color(255,255,255) )
  1743. surface.DrawRect( self.Frame.pos.x, self.Frame.pos.y+20, self.Frame.size.x, self.Frame.size.y-20 )
  1744.  
  1745. -- top bg panel
  1746. surface.SetDrawColor( Color(240,241,242) )
  1747. surface.DrawRect( self.Frame.pos.x, self.Frame.pos.y+20, self.Frame.size.x, 40 )
  1748. --draw.RoundedBox( 0, self.Frame.pos.x, self.Frame.pos.y+20, self.Frame.size.x, 40 , Color(220,221,222) )
  1749.  
  1750. --border top bg panel
  1751. surface.SetDrawColor( Color(210,211,212) )
  1752. surface.DrawOutlinedRect( self.Frame.pos.x, self.Frame.pos.y+20, self.Frame.size.x, 40 )
  1753.  
  1754. --right panel
  1755. surface.SetDrawColor( Color(240,241,242) )
  1756. surface.DrawRect( self.Frame.pos.x+ self.Frame.size.x-150, self.Frame.pos.y+60, 150, self.Frame.size.y-60 )
  1757.  
  1758. --right panle border
  1759. surface.SetDrawColor( Color(190,191,192) )
  1760. surface.DrawOutlinedRect( self.Frame.pos.x+ self.Frame.size.x-150, self.Frame.pos.y+60, 150, self.Frame.size.y-60 )
  1761.  
  1762. --Playing Tytle
  1763. songTitle = "Not Playing..."
  1764. if self.playing ~= nil then
  1765. songTitle = self.playing.artist .. " - " .. self.playing.title
  1766. end
  1767. draw.SimpleText( string.sub( songTitle, 0, (self.Frame.size.x-150)/8 ), "DermaDefault", self.Frame.pos.x + 110, self.Frame.pos.y + 20+10, Color(150,150,150), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM )
  1768.  
  1769. --progress bar bg
  1770. surface.SetDrawColor( Color(210,211,212) )
  1771. surface.DrawRect( self.Frame.pos.x + 110, self.Frame.pos.y + 20+25, self.Frame.size.x-200, 6 )
  1772.  
  1773. --ProgressBar time
  1774.  
  1775. --local items = math.floor( ( self.Frame.size.y - 60-20 ) / 30 )-1
  1776.  
  1777. surface.DrawLine( self.Frame.pos.x, self.Frame.pos.y+90, self.Frame.pos.x+ self.Frame.size.x-150, self.Frame.pos.y+90 )
  1778. for k,v in pairs( self.musicButons ) do
  1779. surface.SetDrawColor( Color(210,211,212) )
  1780. surface.DrawLine( self.Frame.pos.x, self.Frame.pos.y+90 + k*30 + 30, self.Frame.pos.x+ self.Frame.size.x-150, self.Frame.pos.y+90 + k*30 + 30 )
  1781.  
  1782. draw.SimpleText( v.song, "DermaDefault", self.Frame.pos.x + 40,
  1783. self.Frame.pos.y+90 + k*30 + 15, Color(150,150,150), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
  1784.  
  1785. end
  1786.  
  1787.  
  1788. draw.SimpleText( self.page.."/"..math.floor((self.musicList[1] or 1)/self.itemCount), "DermaDefault", self.Frame.pos.x + (self.Frame.size.x-150)/2,
  1789. self.Frame.pos.y+ self.Frame.size.y - 20, Color(150,150,150), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  1790.  
  1791. end
  1792.  
  1793. function Apps.mediaPlayer:Update()
  1794.  
  1795. if self.height ~= self.Frame.size.y or self.rebuild then
  1796. self.rebuild = false
  1797. self.itemCount = math.floor( ( self.Frame.size.y - 60-20 ) / 30 )-2
  1798. self.height = self.Frame.size.y
  1799. --self.musicButons = {}
  1800. for k,v in pairs( self.musicButons ) do
  1801. v:Visible(false)
  1802. v:Kill()
  1803. end
  1804.  
  1805. --Gui Fix
  1806. -- Button Prev page
  1807. self.pagePrevButton:SetPos(5, self.Frame.size.y - 35 )
  1808. self.pagePrevButton:SetSize( (self.Frame.size.x-150)/2 - 30 ,30)
  1809. --Button next page
  1810. self.pageNextButton:SetPos(25 + (self.Frame.size.x-150)/2, self.Frame.size.y - 35 )
  1811. self.pageNextButton:SetSize( (self.Frame.size.x-150)/2 - 30 ,30)
  1812.  
  1813. --table.Remove(self.musicButons)
  1814. self.musicButons = {}
  1815.  
  1816. --PrintTable( self.musicList )
  1817.  
  1818. for item = 0, self.itemCount do
  1819. local id = item+2 + (self.page-1)*self.itemCount
  1820. if not self.musicList[id] then break end
  1821. songtitle = (self.musicList[id].artist .. " - " .. self.musicList[id].title) or "No Song"
  1822.  
  1823. self.musicButons[item] = GUI:Create("Button", self.Frame)
  1824. self.musicButons[item]:SetPos(5, 90+item*30 +5 )
  1825. self.musicButons[item]:SetSize( 20, 20)
  1826.  
  1827. if self.playing ~= nil and self.playing.id == id then
  1828. self.musicButons[item].text = "g"
  1829. else
  1830. self.musicButons[item].text = "8"
  1831. end
  1832.  
  1833.  
  1834. self.musicButons[item].song = string.sub( songtitle, 0, (self.Frame.size.x-150)/9 )
  1835. self.musicButons[item].songID = id
  1836.  
  1837. self.musicButons[item].OnUnClick = function()
  1838. if self.playing ~= nil and self.playing.id == id then
  1839. self.rebuild = true
  1840. self:StopPlay()
  1841. else
  1842. self:PlayID( id )
  1843. self.rebuild = true
  1844. end
  1845. end
  1846.  
  1847. self.musicButons[item].style["body"]["def"] = Color(0,100,150)
  1848. self.musicButons[item].style["body"]["hover"] = Color(0,80,130)
  1849. self.musicButons[item].style["body"]["clk"] = Color(0,60,120)
  1850. self.musicButons[item].style["body"]["round"] = 2
  1851. self.musicButons[item].style["text"]["font"] = "Marlett"
  1852.  
  1853. end
  1854.  
  1855. end
  1856.  
  1857. if ( IsValid( self.stream ) ) then
  1858. self.stream:SetPos( PT.Ent:GetPos() )
  1859. end
  1860. end
  1861.  
  1862. function Apps.mediaPlayer:StopPlay()
  1863. self.playing = nil
  1864. self.playButton.text = "8"
  1865. if ( IsValid( self.stream ) ) then
  1866. self.stream:Stop()
  1867. end
  1868. self.stream = nil
  1869. end
  1870.  
  1871. function Apps.mediaPlayer:PlayID( id )
  1872. self.playButton.text = "g"
  1873. self.playing = self.musicList[id]
  1874. self.playing.id = id
  1875. self.lastSongID = id
  1876.  
  1877. sound.PlayURL ( self.playing.url, "3d", function( station )
  1878. if ( IsValid( self.stream ) ) then
  1879. self.stream:Stop()
  1880. end
  1881. if ( IsValid( station ) ) then
  1882. self.stream = station
  1883. self.stream:SetPos( PT.Ent:GetPos() )
  1884. self.stream:Play()
  1885. else
  1886. LocalPlayer():ChatPrint( "Invalid URL!" )
  1887. end
  1888. end )
  1889. end
  1890.  
  1891. function Apps.mediaPlayer:FindMusic( name )
  1892. end
  1893.  
  1894. function Apps.mediaPlayer:FindMusicByID( id )
  1895.  
  1896. local url = "https://api.vk.com/method/audio.get?owner_id=" .. id .. "&access_token=" .. self.token .. "&count=5000"
  1897.  
  1898. http.Fetch( url, function(data)
  1899. local music = util.JSONToTable( data )
  1900. table.remove(music["response"], 2 )
  1901. --table.remove(music["response"], 1 )
  1902. --print(music["response"][3].artist)
  1903. self.musicList = music["response"]
  1904. self.page = 1
  1905. self.rebuild = true
  1906. end)
  1907.  
  1908. end
  1909.  
  1910. ------------------------------------------------------------
  1911. ------------------------------------------------------------
  1912. ------------------------------------------------------------
  1913. -- Screens
  1914. ---- screens.lua
  1915. ------------------------------------------------------------
  1916. ------------------------------------------------------------
  1917. ------------------------------------------------------------
  1918. ------------------------------
  1919. -- SCREEN TEST
  1920. ------------------------------
  1921. SCREEN = {}
  1922. SCREEN.def = true
  1923.  
  1924.  
  1925. function SCREEN:Init( this )
  1926. self.t = 0
  1927. GUI:Clear()
  1928.  
  1929. self.bg = GUI:Create("Background")
  1930. self.bg:SetPos(0,0)
  1931. self.bg:SetSize(PT:ScrW(),PT:ScrH())
  1932.  
  1933. self.taskP = GUI:Create("TaskPanel")
  1934.  
  1935. --self.key = GUI:Create("KeyBoard")
  1936.  
  1937. Apps:Run("mediaVKMusic")
  1938.  
  1939.  
  1940. end
  1941.  
  1942. function SCREEN:Draw(this )
  1943. self.t = self.t + 1
  1944. GUI:Draw( this )
  1945. end
  1946.  
  1947. function SCREEN:Update(this)
  1948.  
  1949. GUI:Update( this )
  1950. end
  1951. PT:AddScreen( "test",SCREEN )
  1952.  
  1953. ------------------------------
  1954. -- SCREEN Loading
  1955. ------------------------------
  1956. SCREEN = {}
  1957. --SCREEN.def = true
  1958. SCREEN.step = 1
  1959.  
  1960. function SCREEN:Init( this )
  1961. timer.Simple(5, function() PT:SetScr("test") end)
  1962. end
  1963.  
  1964. function SCREEN:Draw(this )
  1965.  
  1966. GUI:Draw( this )
  1967. end
  1968.  
  1969. function SCREEN:Update(this)
  1970.  
  1971.  
  1972. GUI:Update( this )
  1973. end
  1974. PT:AddScreen( "loading",SCREEN )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement