Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.08 KB | None | 0 0
  1.  
  2.  
  3. --[[---------------------------------------------------------
  4. Name: Setup
  5. -----------------------------------------------------------]]
  6. local PANEL = {}
  7.  
  8. local function phrase(...)
  9. return VoidChar.Lang.GetPhrase(...)
  10. end
  11.  
  12. local function countSubstring(s1, s2)
  13. return select(2, s1:gsub(s2, ""))
  14. end
  15.  
  16. local mats = {
  17. add = Material("voidchar/plus.png", "smooth"),
  18. charbox = Material("voidchar/char-box.png", "smooth"),
  19. gradient = Material("voidchar/gradient.png", "nocull smooth"),
  20. locked = Material("voidchar/locked.png", "smooth"),
  21. remove = Material("voidchar/delete.png", "smooth"),
  22. highlight = Material("voidchar/charhighlight.png", "smooth")
  23. }
  24.  
  25.  
  26.  
  27. --[[---------------------------------------------------------
  28. Name: Panel
  29. -----------------------------------------------------------]]
  30. function PANEL:Init()
  31. self.buttons = {}
  32. self.donators = {}
  33. self.selectedChar = nil
  34. self.characters = LocalPlayer():GetCharacters()
  35.  
  36.  
  37.  
  38.  
  39. timer.Simple(0, function()
  40. self:Elements()
  41. self:GetParent().disconnect:SetVisible(true)
  42. end)
  43. end
  44.  
  45. function PANEL:Elements()
  46. local w, h = self:GetSize()
  47.  
  48. local reserved = LocalPlayer():GetReserved()
  49. local characters = self.characters
  50.  
  51. local amount = VoidChar.Config.MaxCharacters
  52. if amount > 5 then
  53. amount = 5
  54. end
  55.  
  56. local space = (ScrH() * 0.145 * amount)
  57.  
  58. local skip = 0
  59.  
  60. self.charModel = vgui.Create("VoidChar.Character", self)
  61. self.charModel:SetSize(ScrW() * 0.6, ScrH() * 1)
  62. self.charModel:SetPos(w / 2 - ScrW() * 0.03, h / 2 - ScrH() * 0.45)
  63.  
  64. self.charModel.mdl.customLayout = true
  65.  
  66.  
  67.  
  68. self.depPaint = vgui.Create("VoidChar.HoverButton", self)
  69.  
  70.  
  71.  
  72. self.depPaint:SetText("")
  73. self.depPaint:SetSize(ScrW() * 0.107, ScrH() * 0.079)
  74. self.depPaint:SetPos(w / 2 - ScrW() * 0.03 + ScrW() * 0.22, h - ScrH() * 0.26)
  75. self.depPaint:SetColor(Color(10,190,88,130))
  76. self.depPaint:SetFont("fc_3")
  77. self.depPaint.Paint = function (self, w, h)
  78. surface.SetDrawColor(Color(10,190,88,130))
  79.  
  80. if !self:GetParent().selectedChar then return end
  81.  
  82. local t = self:GetParent().selectedChar.char.job
  83.  
  84. local TEAM = RPExtraTeams[t]
  85. local max = TEAM.max
  86.  
  87. local numPlayers = team.NumPlayers(t)
  88.  
  89. if max == 0 then
  90. surface.DrawRect(0,0,w,h)
  91. elseif numPlayers >= max and LocalPlayer():Team() != t then
  92. surface.DrawOutlinedRect(0,0,w,h)
  93. else
  94. surface.DrawRect(0,0,w,h)
  95. end
  96.  
  97. draw.SimpleText(phrase("deploy"), "fc_3", w/2, h/2, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  98. end
  99.  
  100.  
  101. self.pGradient = vgui.Create("DPanel", self)
  102. self.pGradient:SetSize(ScrW(), ScrH() * 0.35)
  103. self.pGradient:SetPos(0, ScrH() - ScrH() * 0.35)
  104. self.pGradient.Paint = function (self, w, h)
  105. surface.SetMaterial(mats.gradient)
  106. surface.SetDrawColor(255,255,255,50)
  107.  
  108. surface.DrawTexturedRect(0,0,w,h)
  109. end
  110.  
  111. self.deploy = vgui.Create("VoidChar.HoverButton", self)
  112.  
  113. self.deploy:SetText("")
  114. self.deploy:SetSize(ScrW() * 0.107, ScrH() * 0.079)
  115. self.deploy:SetPos(w / 2 - ScrW() * 0.03 + ScrW() * 0.22, h - ScrH() * 0.26)
  116. self.deploy.Paint = function () end
  117. self.deploy.Think = function ()
  118.  
  119. self.depPaint._isHovered = self.deploy:IsHovered()
  120. end
  121. self.deploy.DoClick = function ()
  122. if self.selectedChar then
  123. self.selectedChar:DeployCharacter()
  124. end
  125. end
  126.  
  127. self.jobCounter = vgui.Create("DPanel", self)
  128. self.jobCounter:SetSize(ScrW() * 0.107, ScrH() * 0.03)
  129. self.jobCounter:SetPos(w / 2 - ScrW() * 0.03 + ScrW() * 0.22, h - ScrH() * 0.275 + ScrH() * 0.097)
  130. self.jobCounter.Paint = function (self, w, h)
  131.  
  132. if !self:GetParent().selectedChar then return end
  133.  
  134. local t = self:GetParent().selectedChar.char.job
  135.  
  136.  
  137. local TEAM = RPExtraTeams[t]
  138. local max = TEAM.max
  139.  
  140. local numPlayers = team.NumPlayers(t)
  141.  
  142. if max == 0 then
  143. surface.SetDrawColor(92, 113, 135)
  144. surface.DrawOutlinedRect(0,0,w,h)
  145. elseif numPlayers >= max and LocalPlayer():Team() != t then
  146. surface.SetDrawColor(255, 46, 0, 150)
  147. surface.DrawRect(0,0,w,h)
  148. else
  149. surface.SetDrawColor(92, 113, 135)
  150. surface.DrawOutlinedRect(0,0,w,h)
  151. end
  152.  
  153.  
  154. draw.SimpleText(string.format(phrase("online_players"), numPlayers, max), "fc_7", w/2, h/2, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  155.  
  156. end
  157.  
  158.  
  159. for i=1, amount do
  160. if i <= #characters then
  161. local button = vgui.Create("VoidChar.Select.EButton", self)
  162.  
  163. button:SetSize(ScrW() * 0.298, ScrH() * 0.114)
  164. //144
  165.  
  166. button:SetPos(ScrW() * 0.07, ScrH() * 0.54 - space / 2 + (i * (ScrH() * 0.114 + ScrH() * 0.04) - (ScrH() * 0.114)))
  167. button:SetCharacter(characters[i])
  168.  
  169. if i == 1 then
  170. self.selectedChar = button
  171. button:SelectChar()
  172. end
  173.  
  174. table.insert(self.buttons, button)
  175. else
  176. local button = vgui.Create("VoidChar.Select.AButton", self)
  177.  
  178. button:SetSize(ScrW() * 0.298, ScrH() * 0.114)
  179. //76561198070588089
  180.  
  181.  
  182. button:SetPos(ScrW() * 0.07, ScrH() * 0.54 - space / 2 + (i * (ScrH() * 0.114 + ScrH() * 0.04) - (ScrH() * 0.114)))
  183.  
  184. if i > amount - table.Count(reserved) then
  185. local num = i - amount + table.Count(reserved)
  186.  
  187. button:SetReserved(table.GetKeys(reserved)[num])
  188.  
  189. table.insert(self.donators, button)
  190. end
  191. end
  192. end
  193.  
  194. if characters[1] then
  195. self.charModel:SetJob(RPExtraTeams[tonumber(characters[1].job)])
  196. end
  197.  
  198. end
  199.  
  200. function PANEL:Paint(w, h)
  201.  
  202. draw.Text({
  203. text = phrase("title"),
  204. font = "fc_1",
  205. pos = {80, ScrH() * 0.133},
  206. xalign = TEXT_ALIGN_LEFT,
  207. yalign = 1,
  208. color = Color(255,255,255)
  209. })
  210.  
  211.  
  212. if self.selectedChar then
  213.  
  214. local x = self.selectedChar.x
  215. local y = self.selectedChar.y
  216.  
  217. local _w = self.selectedChar:GetWide()
  218. local _h = self.selectedChar:GetTall()
  219.  
  220. x = x-18
  221.  
  222. surface.SetDrawColor(255,255,255)
  223. surface.SetMaterial(mats.highlight)
  224. surface.DrawTexturedRect(x,y,_w+36,_h)
  225. end
  226.  
  227.  
  228. end
  229.  
  230.  
  231. vgui.Register("VoidChar.Select", PANEL, "DPanel")
  232.  
  233. --[[---------------------------------------------------------
  234. Name: Exixting Button
  235. -----------------------------------------------------------]]
  236. PANEL = {}
  237.  
  238. function PANEL:Init()
  239. self:SetText("")
  240.  
  241. self.mdl = vgui.Create("DModelPanel", self)
  242. self.mdl:SetSize(ScrW() * 0.076, ScrH() * 0.105)
  243. self.mdl:SetPos(ScrW() * 0.028, ScrH() * 0.004)
  244.  
  245. self.mdl.DoClick = function()
  246. self:SelectChar()
  247. end
  248.  
  249. timer.Simple(0, function()
  250. self:Elements()
  251. end)
  252. end
  253.  
  254. function PANEL:SelectChar()
  255. self:GetParent().selectedChar = self
  256. self:GetParent().charModel:SetJob(RPExtraTeams[tonumber(self.char.job)])
  257. self:GetParent().charModel:SetJobModel(self.char.model)
  258. end
  259.  
  260. function PANEL:DeployCharacter()
  261. DarkRP.setPreferredJobModel(self.char.job, self.char.model)
  262. VoidChar.Ply.SelectCharacter(self.char.id)
  263. end
  264.  
  265. function PANEL:DoClick()
  266. self:SelectChar()
  267. end
  268.  
  269. function PANEL:Elements()
  270. local w, h = self:GetSize()
  271.  
  272. self.delete = vgui.Create("VoidChar.HoverButton", self)
  273. self.delete:SetText("")
  274. self.delete:SetSize(ScrW() * 0.04, ScrW() * 0.04)
  275. self.delete:SetPos(w - ScrW() * 0.050, -8)
  276. self.delete.Paint = function (self, w, h)
  277. surface.SetDrawColor(255,255,255)
  278. surface.SetMaterial(mats.remove)
  279. surface.DrawTexturedRect(0,0,w,h)
  280. end
  281.  
  282. self.delete.DoClick = function(s, w, h)
  283. Derma_Query(string.format(phrase("delete_text"), self.char.name), string.format(phrase("delete_title"), self.char.name),
  284. phrase("delete_accept"), function()
  285. VoidChar.Ply.DeleteCharacter(self.char.id)
  286. end,
  287. phrase("delete_deny"))
  288. end
  289.  
  290. end
  291.  
  292. function PANEL:SetCharacter(character)
  293. self.char = character
  294.  
  295. local model = character.model
  296.  
  297. self.mdl:SetModel(model)
  298.  
  299.  
  300. local bone = self.mdl.Entity:LookupBone("ValveBiped.Bip01_Head1")
  301. local eyepos = Vector(0,0,22)
  302. if (bone and bone != NULL) then
  303. eyepos = self.mdl.Entity:GetBonePosition(bone) + Vector(0, 0, -2)
  304. else
  305. self.mdl:SetFOV(500)
  306. end
  307.  
  308. eyepos:Add(Vector(0, 0, 2))
  309.  
  310. self.mdl:SetLookAt(eyepos)
  311. self.mdl:SetCamPos(eyepos-Vector(-16, 0, 0))
  312. self.mdl.Entity:SetEyeTarget(eyepos-Vector(-16, 0, 0))
  313.  
  314. function self.mdl:LayoutEntity(ent)
  315. if self.bAnimated then
  316. self:RunAnimation()
  317. end
  318. end
  319. end
  320.  
  321. function PANEL:GetName()
  322. if not self.char then return "" end
  323.  
  324. if self.char.clone_id != "NULL" and self.char.clone_id != false then
  325. return self.char.name.. " ".. self.char.clone_id
  326. else
  327.  
  328. return self.char.name
  329. end
  330.  
  331. return ""
  332. end
  333.  
  334. function PANEL:Paint(w, h)
  335.  
  336.  
  337. surface.SetDrawColor(92, 113, 135)
  338. surface.SetMaterial(mats.charbox)
  339. surface.DrawTexturedRect(0,0,w,h)
  340.  
  341.  
  342. draw.SimpleText(string.upper(self.char.name), "fc_2", ScrW() * 0.103, 5, VoidChar.Config.CharButtonTextColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
  343. if self.char.clone_id != "NULL" and self.char.clone_id != false then
  344. draw.SimpleText("#" .. self.char.clone_id, "fc_5", w - ScrW() * 0.056, h-ScrH() * 0.024, VoidChar.Config.CharButtonTextColor, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP)
  345. end
  346. draw.SimpleText(string.upper(RPExtraTeams[tonumber(self.char.job)].name), "fc_7", ScrW() * 0.105, ScrH() * 0.038, VoidChar.Config.CharButtonTextColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
  347. draw.SimpleText(DarkRP.formatMoney(tonumber(self.char.wallet)), "fc_8", ScrW() * 0.105, h - ScrH() * 0.012, VoidChar.Config.CharButtonTextColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM)
  348.  
  349. if VoidChar.Config.LevelSystemSupport and self.char.level then
  350. draw.SimpleText("LEVEL: " .. self.char.level, "fc_5", w - ScrW() * 0.04, ScrH() * 0.038, VoidChar.Config.CharButtonTextColor, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP)
  351. end
  352.  
  353. end
  354.  
  355. vgui.Register("VoidChar.Select.EButton", PANEL, "DButton")
  356.  
  357.  
  358. --[[---------------------------------------------------------
  359. Name: Add Button
  360. -----------------------------------------------------------]]
  361. PANEL = {}
  362.  
  363. function PANEL:Init()
  364. self:SetText("")
  365.  
  366.  
  367. self.DoClick = function()
  368. if self.allowed == false then return end
  369.  
  370. local nextPage = (VoidChar.Config.FactionSystem and 0x3) or 0x2
  371. self:GetParent():GetParent():SetPage(nextPage)
  372. end
  373. end
  374.  
  375. function PANEL:SetReserved(name)
  376. self.reserved = VoidChar.Config.CharacterRank[name]
  377.  
  378. self.allowed = LocalPlayer():GetReserved()[name] or false
  379. end
  380.  
  381. function PANEL:Paint(w, h)
  382.  
  383. local drawColor = Color(92, 113, 135, 110)
  384. local opacity = 40
  385.  
  386. if !self.reserved or self.allowed then
  387. drawColor = Color(92, 113, 135)
  388. opacity = 230
  389. end
  390.  
  391. surface.SetDrawColor(drawColor)
  392. surface.SetMaterial(mats.charbox)
  393. surface.DrawTexturedRect(0,0,w,h)
  394.  
  395.  
  396.  
  397.  
  398.  
  399. surface.SetDrawColor(255,255,255, opacity)
  400.  
  401. if self.reserved and not self.allowed then
  402. draw.SimpleText(string.format(phrase("reserved"), self.reserved.name), "fc_4", ScrW() * 0.105, self:GetTall()/2, Color(255,255,255,110), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  403. surface.SetMaterial(mats.locked)
  404. surface.DrawTexturedRect(ScrW() * 0.049,ScrH() * 0.016,ScrW() * 0.038,ScrH() * 0.078)
  405. else
  406. opacity = 160
  407. draw.SimpleText(phrase("available"), "fc_4", ScrW() * 0.105, self:GetTall()/2, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
  408. surface.SetMaterial(mats.add)
  409. surface.DrawTexturedRect(ScrW() * 0.022,-ScrH() * 0.016,ScrW() * 0.09,ScrW() * 0.09)
  410. end
  411.  
  412.  
  413.  
  414.  
  415. end
  416.  
  417. vgui.Register("VoidChar.Select.AButton", PANEL, "DButton")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement