Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[---------------------------------------------------------
- Name: Setup
- -----------------------------------------------------------]]
- local PANEL = {}
- local function phrase(...)
- return VoidChar.Lang.GetPhrase(...)
- end
- local function countSubstring(s1, s2)
- return select(2, s1:gsub(s2, ""))
- end
- local mats = {
- add = Material("voidchar/plus.png", "smooth"),
- charbox = Material("voidchar/char-box.png", "smooth"),
- gradient = Material("voidchar/gradient.png", "nocull smooth"),
- locked = Material("voidchar/locked.png", "smooth"),
- remove = Material("voidchar/delete.png", "smooth"),
- highlight = Material("voidchar/charhighlight.png", "smooth")
- }
- --[[---------------------------------------------------------
- Name: Panel
- -----------------------------------------------------------]]
- function PANEL:Init()
- self.buttons = {}
- self.donators = {}
- self.selectedChar = nil
- self.characters = LocalPlayer():GetCharacters()
- timer.Simple(0, function()
- self:Elements()
- self:GetParent().disconnect:SetVisible(true)
- end)
- end
- function PANEL:Elements()
- local w, h = self:GetSize()
- local reserved = LocalPlayer():GetReserved()
- local characters = self.characters
- local amount = VoidChar.Config.MaxCharacters
- if amount > 5 then
- amount = 5
- end
- local space = (ScrH() * 0.145 * amount)
- local skip = 0
- self.charModel = vgui.Create("VoidChar.Character", self)
- self.charModel:SetSize(ScrW() * 0.6, ScrH() * 1)
- self.charModel:SetPos(w / 2 - ScrW() * 0.03, h / 2 - ScrH() * 0.45)
- self.charModel.mdl.customLayout = true
- self.depPaint = vgui.Create("VoidChar.HoverButton", self)
- self.depPaint:SetText("")
- self.depPaint:SetSize(ScrW() * 0.107, ScrH() * 0.079)
- self.depPaint:SetPos(w / 2 - ScrW() * 0.03 + ScrW() * 0.22, h - ScrH() * 0.26)
- self.depPaint:SetColor(Color(10,190,88,130))
- self.depPaint:SetFont("fc_3")
- self.depPaint.Paint = function (self, w, h)
- surface.SetDrawColor(Color(10,190,88,130))
- if !self:GetParent().selectedChar then return end
- local t = self:GetParent().selectedChar.char.job
- local TEAM = RPExtraTeams[t]
- local max = TEAM.max
- local numPlayers = team.NumPlayers(t)
- if max == 0 then
- surface.DrawRect(0,0,w,h)
- elseif numPlayers >= max and LocalPlayer():Team() != t then
- surface.DrawOutlinedRect(0,0,w,h)
- else
- surface.DrawRect(0,0,w,h)
- end
- draw.SimpleText(phrase("deploy"), "fc_3", w/2, h/2, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- end
- self.pGradient = vgui.Create("DPanel", self)
- self.pGradient:SetSize(ScrW(), ScrH() * 0.35)
- self.pGradient:SetPos(0, ScrH() - ScrH() * 0.35)
- self.pGradient.Paint = function (self, w, h)
- surface.SetMaterial(mats.gradient)
- surface.SetDrawColor(255,255,255,50)
- surface.DrawTexturedRect(0,0,w,h)
- end
- self.deploy = vgui.Create("VoidChar.HoverButton", self)
- self.deploy:SetText("")
- self.deploy:SetSize(ScrW() * 0.107, ScrH() * 0.079)
- self.deploy:SetPos(w / 2 - ScrW() * 0.03 + ScrW() * 0.22, h - ScrH() * 0.26)
- self.deploy.Paint = function () end
- self.deploy.Think = function ()
- self.depPaint._isHovered = self.deploy:IsHovered()
- end
- self.deploy.DoClick = function ()
- if self.selectedChar then
- self.selectedChar:DeployCharacter()
- end
- end
- self.jobCounter = vgui.Create("DPanel", self)
- self.jobCounter:SetSize(ScrW() * 0.107, ScrH() * 0.03)
- self.jobCounter:SetPos(w / 2 - ScrW() * 0.03 + ScrW() * 0.22, h - ScrH() * 0.275 + ScrH() * 0.097)
- self.jobCounter.Paint = function (self, w, h)
- if !self:GetParent().selectedChar then return end
- local t = self:GetParent().selectedChar.char.job
- local TEAM = RPExtraTeams[t]
- local max = TEAM.max
- local numPlayers = team.NumPlayers(t)
- if max == 0 then
- surface.SetDrawColor(92, 113, 135)
- surface.DrawOutlinedRect(0,0,w,h)
- elseif numPlayers >= max and LocalPlayer():Team() != t then
- surface.SetDrawColor(255, 46, 0, 150)
- surface.DrawRect(0,0,w,h)
- else
- surface.SetDrawColor(92, 113, 135)
- surface.DrawOutlinedRect(0,0,w,h)
- end
- 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)
- end
- for i=1, amount do
- if i <= #characters then
- local button = vgui.Create("VoidChar.Select.EButton", self)
- button:SetSize(ScrW() * 0.298, ScrH() * 0.114)
- //144
- button:SetPos(ScrW() * 0.07, ScrH() * 0.54 - space / 2 + (i * (ScrH() * 0.114 + ScrH() * 0.04) - (ScrH() * 0.114)))
- button:SetCharacter(characters[i])
- if i == 1 then
- self.selectedChar = button
- button:SelectChar()
- end
- table.insert(self.buttons, button)
- else
- local button = vgui.Create("VoidChar.Select.AButton", self)
- button:SetSize(ScrW() * 0.298, ScrH() * 0.114)
- //76561198070588089
- button:SetPos(ScrW() * 0.07, ScrH() * 0.54 - space / 2 + (i * (ScrH() * 0.114 + ScrH() * 0.04) - (ScrH() * 0.114)))
- if i > amount - table.Count(reserved) then
- local num = i - amount + table.Count(reserved)
- button:SetReserved(table.GetKeys(reserved)[num])
- table.insert(self.donators, button)
- end
- end
- end
- if characters[1] then
- self.charModel:SetJob(RPExtraTeams[tonumber(characters[1].job)])
- end
- end
- function PANEL:Paint(w, h)
- draw.Text({
- text = phrase("title"),
- font = "fc_1",
- pos = {80, ScrH() * 0.133},
- xalign = TEXT_ALIGN_LEFT,
- yalign = 1,
- color = Color(255,255,255)
- })
- if self.selectedChar then
- local x = self.selectedChar.x
- local y = self.selectedChar.y
- local _w = self.selectedChar:GetWide()
- local _h = self.selectedChar:GetTall()
- x = x-18
- surface.SetDrawColor(255,255,255)
- surface.SetMaterial(mats.highlight)
- surface.DrawTexturedRect(x,y,_w+36,_h)
- end
- end
- vgui.Register("VoidChar.Select", PANEL, "DPanel")
- --[[---------------------------------------------------------
- Name: Exixting Button
- -----------------------------------------------------------]]
- PANEL = {}
- function PANEL:Init()
- self:SetText("")
- self.mdl = vgui.Create("DModelPanel", self)
- self.mdl:SetSize(ScrW() * 0.076, ScrH() * 0.105)
- self.mdl:SetPos(ScrW() * 0.028, ScrH() * 0.004)
- self.mdl.DoClick = function()
- self:SelectChar()
- end
- timer.Simple(0, function()
- self:Elements()
- end)
- end
- function PANEL:SelectChar()
- self:GetParent().selectedChar = self
- self:GetParent().charModel:SetJob(RPExtraTeams[tonumber(self.char.job)])
- self:GetParent().charModel:SetJobModel(self.char.model)
- end
- function PANEL:DeployCharacter()
- DarkRP.setPreferredJobModel(self.char.job, self.char.model)
- VoidChar.Ply.SelectCharacter(self.char.id)
- end
- function PANEL:DoClick()
- self:SelectChar()
- end
- function PANEL:Elements()
- local w, h = self:GetSize()
- self.delete = vgui.Create("VoidChar.HoverButton", self)
- self.delete:SetText("")
- self.delete:SetSize(ScrW() * 0.04, ScrW() * 0.04)
- self.delete:SetPos(w - ScrW() * 0.050, -8)
- self.delete.Paint = function (self, w, h)
- surface.SetDrawColor(255,255,255)
- surface.SetMaterial(mats.remove)
- surface.DrawTexturedRect(0,0,w,h)
- end
- self.delete.DoClick = function(s, w, h)
- Derma_Query(string.format(phrase("delete_text"), self.char.name), string.format(phrase("delete_title"), self.char.name),
- phrase("delete_accept"), function()
- VoidChar.Ply.DeleteCharacter(self.char.id)
- end,
- phrase("delete_deny"))
- end
- end
- function PANEL:SetCharacter(character)
- self.char = character
- local model = character.model
- self.mdl:SetModel(model)
- local bone = self.mdl.Entity:LookupBone("ValveBiped.Bip01_Head1")
- local eyepos = Vector(0,0,22)
- if (bone and bone != NULL) then
- eyepos = self.mdl.Entity:GetBonePosition(bone) + Vector(0, 0, -2)
- else
- self.mdl:SetFOV(500)
- end
- eyepos:Add(Vector(0, 0, 2))
- self.mdl:SetLookAt(eyepos)
- self.mdl:SetCamPos(eyepos-Vector(-16, 0, 0))
- self.mdl.Entity:SetEyeTarget(eyepos-Vector(-16, 0, 0))
- function self.mdl:LayoutEntity(ent)
- if self.bAnimated then
- self:RunAnimation()
- end
- end
- end
- function PANEL:GetName()
- if not self.char then return "" end
- if self.char.clone_id != "NULL" and self.char.clone_id != false then
- return self.char.name.. " ".. self.char.clone_id
- else
- return self.char.name
- end
- return ""
- end
- function PANEL:Paint(w, h)
- surface.SetDrawColor(92, 113, 135)
- surface.SetMaterial(mats.charbox)
- surface.DrawTexturedRect(0,0,w,h)
- draw.SimpleText(string.upper(self.char.name), "fc_2", ScrW() * 0.103, 5, VoidChar.Config.CharButtonTextColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
- if self.char.clone_id != "NULL" and self.char.clone_id != false then
- 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)
- end
- 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)
- 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)
- if VoidChar.Config.LevelSystemSupport and self.char.level then
- draw.SimpleText("LEVEL: " .. self.char.level, "fc_5", w - ScrW() * 0.04, ScrH() * 0.038, VoidChar.Config.CharButtonTextColor, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP)
- end
- end
- vgui.Register("VoidChar.Select.EButton", PANEL, "DButton")
- --[[---------------------------------------------------------
- Name: Add Button
- -----------------------------------------------------------]]
- PANEL = {}
- function PANEL:Init()
- self:SetText("")
- self.DoClick = function()
- if self.allowed == false then return end
- local nextPage = (VoidChar.Config.FactionSystem and 0x3) or 0x2
- self:GetParent():GetParent():SetPage(nextPage)
- end
- end
- function PANEL:SetReserved(name)
- self.reserved = VoidChar.Config.CharacterRank[name]
- self.allowed = LocalPlayer():GetReserved()[name] or false
- end
- function PANEL:Paint(w, h)
- local drawColor = Color(92, 113, 135, 110)
- local opacity = 40
- if !self.reserved or self.allowed then
- drawColor = Color(92, 113, 135)
- opacity = 230
- end
- surface.SetDrawColor(drawColor)
- surface.SetMaterial(mats.charbox)
- surface.DrawTexturedRect(0,0,w,h)
- surface.SetDrawColor(255,255,255, opacity)
- if self.reserved and not self.allowed then
- 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)
- surface.SetMaterial(mats.locked)
- surface.DrawTexturedRect(ScrW() * 0.049,ScrH() * 0.016,ScrW() * 0.038,ScrH() * 0.078)
- else
- opacity = 160
- draw.SimpleText(phrase("available"), "fc_4", ScrW() * 0.105, self:GetTall()/2, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
- surface.SetMaterial(mats.add)
- surface.DrawTexturedRect(ScrW() * 0.022,-ScrH() * 0.016,ScrW() * 0.09,ScrW() * 0.09)
- end
- end
- vgui.Register("VoidChar.Select.AButton", PANEL, "DButton")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement