Advertisement
Roite

xwo

Feb 7th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.22 KB | None | 0 0
  1.     Property.Categories = {}
  2.  
  3.     local function GenerateCategory(name)
  4.  
  5.         for k, v in pairs(Property.Categories) do
  6.             if v.Title == name then return v end
  7.         end
  8.  
  9.         local AriviaCategory = vgui.Create("AriviaCategory", Property.Scroll)
  10.         AriviaCategory:Dock(TOP)
  11.         AriviaCategory:DockMargin(0, 5, 0, 0)
  12.         AriviaCategory:HeaderTitle(name)
  13.         table.insert(Property.Categories, AriviaCategory)
  14.  
  15.         AriviaCategory.List = vgui.Create("DIconLayout", AriviaCategory)
  16.         AriviaCategory.List:SetLayoutDir(TOP)
  17.         AriviaCategory.List:Dock(LEFT)
  18.         AriviaCategory.List:DockMargin( 6, 5, 0, 0 )
  19.         AriviaCategory.List:SetSize(Property:GetParent():GetWide() - Property:GetParent():GetWide() / 3 + 9, 65)
  20.         AriviaCategory.List.Paint = function(panel, w, h) end
  21.         AriviaCategory.List:SetSpaceY(5)
  22.         AriviaCategory.List:SetSpaceX(5)
  23.  
  24.         return AriviaCategory
  25.     end
  26.  
  27.     for i = 0, 0 do
  28.         for k, v in ipairs(RPExtraTeams) do
  29.  
  30.             if v.name == team.GetName(Arivia.Panel.CurJob) then continue end
  31.             if !Arivia.TabJobs.showUnavailableJobs and !AriviaAllowJobSelection(v) then continue end
  32.  
  33.             if !Property.Value then
  34.                 Property.Value = v
  35.             end
  36.  
  37.             if v.category then
  38.                 AriviaCategory = GenerateCategory( v.category )
  39.             else
  40.                 AriviaCategory = GenerateCategory( Arivia.Language.CategoryOther )
  41.             end
  42.  
  43.             local ListItem = vgui.Create("DButton")
  44.             ListItem:SetSize((Property:GetParent():GetWide() / 3) - 4, 60)
  45.             ListItem:SetText("")
  46.             ListItem.oldpaint = ListItem.Paint
  47.  
  48.             ListItem.DoClick = function()
  49.                 Property.Value = v
  50.                 Property.Value.Key = 1
  51.                 if istable(Property.Value.model) then
  52.                     Property.PanelPreview.ModelObject:SetModel(Property.Value.model[Property.Value.Key])
  53.                 else
  54.                     Property.PanelPreview.ModelObject:SetModel(Property.Value.model)
  55.                 end
  56.                 Property.PanelPreview.ModelObject:InvalidateLayout()
  57.                 Property.PanelPreview.ButtonAction:InvalidateLayout()
  58.  
  59.                 Property.PanelPreview.Skins = istable(Property.Value.model) and table.Count(Property.Value.model) or 0
  60.             end
  61.  
  62.             function ListItem:Paint( w, h )
  63.  
  64.                 local jobUnavailable = false
  65.  
  66.                 local color = Arivia.TabJobs.buttonColor
  67.                 local txtColor = textNormal
  68.  
  69.                 if ListItem:IsHovered() or ListItem:IsDown() then
  70.                     color = Arivia.TabJobs.buttonHoverColor
  71.                     txtColor = textHover
  72.                 end
  73.  
  74.                 local objectName = v.name
  75.  
  76.                 if Arivia.TruncateEnabled then
  77.                     local maxW = Arivia.TruncateLength or 170
  78.                     surface.SetFont("AriviaFontObjectListName")
  79.                     local fw,fh = surface.GetTextSize(objectName)
  80.                     if fw > maxW then
  81.                         objectName = string.sub(objectName, 1, objectName:len()-3).."..."
  82.                     end
  83.                 end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement