Skip to content

Commit

Permalink
No, I don't know why I was building a table first either
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuller committed Jul 29, 2024
1 parent 8cf39a6 commit 3ede85e
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions OmniCC_Config/preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@ local L = LibStub("AceLocale-3.0"):GetLocale("OmniCC")
local DEFAULT_DURATION = 30

local function getRandomIcon()
local icons = {}

for i = 1, GetNumSpellTabs() do
local offset, numSpells = select(3, GetSpellTabInfo(i))
local tabEnd = offset + numSpells

for j = offset, tabEnd - 1 do
local texture = GetSpellBookItemTexture(j, "player")
if texture then
tinsert(icons, texture)
end
end
if type(GetSpellBookItemTexture) == "function" then
local _, _, offset, numSlots = GetSpellTabInfo(GetNumSpellTabs())
return GetSpellBookItemTexture(math.random(offset + numSlots - 1), 'player')
end

return icons[math.random(1, #icons)]
local i = C_SpellBook.GetSpellBookSkillLineInfo(C_SpellBook.GetNumSpellBookSkillLines())
local offset = i.itemIndexOffset
local numSlots = i.numSpellBookItems
return C_SpellBook.GetSpellBookItemTexture(math.random(offset + numSlots - 1), Enum.SpellBookSpellBank.Player)
end

-- preview dialog
Expand Down Expand Up @@ -86,8 +80,9 @@ cooldown:SetSwipeColor(0, 0, 0)
cooldown:SetDrawEdge(false)
cooldown:SetScript(
"OnCooldownDone",
function(self)
function()
if PreviewDialog:IsVisible() then
PreviewDialog.icon:SetTexture(getRandomIcon())
PreviewDialog:StartCooldown(PreviewDialog.duration:GetValue())
end
end
Expand All @@ -107,7 +102,7 @@ editBox:SetWidth(container:GetWidth() - 54)
editBox:SetMinMaxValues(0, 9999999)
editBox:SetMaxLetters(7)
editBox:SetValue(DEFAULT_DURATION)
editBox:SetOnValueChangedCallback(function(self, value)
editBox:SetOnValueChangedCallback(function(_, value)
PreviewDialog:StartCooldown(value or 0)
end)

Expand Down

0 comments on commit 3ede85e

Please sign in to comment.