Guest User

Untitled

a guest
Oct 13th, 2021
60
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ADDON.SpellRow = {}
  2. ADDON.SpellRow.__index = ADDON.SpellRow
  3.  
  4. function ADDON.SpellRow:GetFrame()
  5.     return self.frame
  6. end
  7.  
  8. function ADDON.SpellRow:CreateRow(parent, index, spell)
  9.     self.frame = CreateFrame('BUTTON', 'spellIdRow' .. index, parent)
  10.     self.frame:SetSize(ADDON:Scale(290), ADDON:Scale(16))
  11.  
  12.     self.frame.background = self.frame:CreateTexture(nil, 'BACKGROUND')
  13.     self.frame.background:SetAllPoints(self.frame)
  14.     self.frame.background:SetTexture([[Interface\AddOns\AstralAnalytics\Media\Texture\Flat.tga]])
  15.     self.frame.background:SetAlpha(.6)
  16.     self.frame.background:Show()
  17.  
  18.     self.frame.name = self.frame:CreateFontString(nil, 'OVERLAY', 'AstralFontNormal')
  19.     self.frame.name:SetPoint('LEFT', self.frame, 'LEFT', 4, -1)
  20.     self.frame.name:SetTextColor(1, 1, 1)
  21.     self:SetSpell(spell)
  22.     return self
  23. end
  24.  
  25. function ADDON.SpellRow:SetSpell(spell)
  26.     local name, rank, icon = GetSpellInfo(spell)
  27.     self.frame.name:SetText(name .. " (" .. spell .. ")")
  28.     self.frame:Show()
  29. end
  30.  
  31. function ADDON.SpellRow:ClearSpell()
  32.     self.frame.name:SetText('')
  33.     self.frame:Hide()
  34. end
  35.  
  36. local listScrollFrame = CreateFrame('ScrollFrame', 'parentListContainer', ADDON.AAOptionsFrame, 'FauxScrollFrameTemplate')
  37. listScrollFrame:SetSize(415, 375)
  38. listScrollFrame:SetPoint('TOPLEFT')
  39.  
  40. local currentDropdownValue = 'taunt'
  41. local row = {}
  42.  
  43. local function CreateSpellList()
  44.     for key, value in pairs(row) do
  45.         ADDON.Print("Hiding")
  46.         value:ClearSpell()
  47.     end
  48.  
  49.     row[1] = ADDON.SpellRow:CreateRow(listScrollFrame, 1, 1)
  50.     row[1]:GetFrame():SetPoint('TOPLEFT', 'AAOptionsFrame', 'TOPLEFT', 25, -10)
  51.     local currentRow = 1
  52.     for spellId, _ in pairs(AstralAnalytics.spellIds[currentDropdownValue]) do
  53.         if row[currentRow] == nil then
  54.             ADDON.Print('new row for ' .. currentRow .. ' with id ' .. spellId)
  55.             row[currentRow] = ADDON.SpellRow:CreateRow(listScrollFrame, currentRow, spellId)
  56.             row[currentRow]:GetFrame():SetPoint('TOPLEFT', 'spellIdRow' .. currentRow-1, 'BOTTOMLEFT', 0, 0)
  57.         else
  58.             ADDON.Print('setting existing row for ' .. currentRow .. ' with id ' .. spellId)
  59.             row[currentRow]:SetSpell(spellId)
  60.             row[currentRow]:GetFrame():Show()
  61.         end
  62.         currentRow = currentRow + 1
  63.     end
  64.     ADDON.Print(table.getn(row))
  65. end
  66.  
  67. local function spellCategoryDropdown_OnClick(self, arg1, arg2, checked)
  68.     currentDropdownValue = arg1
  69.     UIDropDownMenu_SetText(spellCategoryDropdown, currentDropdownValue)
  70.     CreateSpellList()
  71. end
  72.  
  73. local function initSpellCategoryDropdown(frame, level, menulist)
  74.     local info = UIDropDownMenu_CreateInfo()
  75.     info.func = spellCategoryDropdown_OnClick
  76.     for key, value in pairs(AstralAnalytics.spellIds) do
  77.         info.text, info.arg1, info.checked = key, key, key == currentDropdownValue
  78.         UIDropDownMenu_AddButton(info)
  79.     end
  80. end
  81.  
  82. local spellCategoryDropdown = CreateFrame("Frame", "spellCategoryDropdown", listScrollFrame, "UIDropDownMenuTemplate")
  83. spellCategoryDropdown:SetPoint('TOPLEFT', listScrollFrame, 'TOPRIGHT', 20, 0)
  84. spellCategoryDropdown:SetWidth(200)
  85. UIDropDownMenu_Initialize(spellCategoryDropdown, initSpellCategoryDropdown)
  86. UIDropDownMenu_SetText(spellCategoryDropdown, currentDropdownValue)
RAW Paste Data