Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local debugging = true;
- --main parent frame
- local mainFrame = CreateFrame("Frame", "Main", UIParent)
- mainFrame:SetPoint("CENTER", 0, 0)
- mainFrame:SetWidth(1)
- mainFrame:SetHeight(1)
- mainFrame:Show()
- local allFrames = {}
- local framesConstructor = {}
- function framesConstructor:create(name, width, height, constructor, updater)--method for frame creation - simulates OOP
- local tbl = {}
- tbl.frame = CreateFrame("Frame", name .. "BackgroundFrame", mainFrame)
- tbl.frame:SetPoint("CENTER", mainFrame, "CENTER")
- tbl.name = name
- tbl.height = height
- tbl.width = width
- tbl.constructor = constructor
- tbl.updater = updater
- return tbl
- end
- function getFrameIndexFromTable(name)
- for i = 1, #allFrames do
- if allFrames[i].name == name then return i
- end
- end
- end
- local ServerReady = false
- mainFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
- mainFrame:SetScript("OnEvent", function(self, event)
- if event == "PLAYER_ENTERING_WORLD" then
- mainFrame:UnregisterEvent("PLAYER_ENTERING_WORLD")
- ServerReady = true
- end
- end)
- --runic power
- function setupRpower()
- local base = allFrames[getFrameIndexFromTable("runicpower")]
- rpowerFrame = CreateFrame("Frame", nil, base.frame)
- rpowerFrame:SetPoint("TOP", base.frame, "TOP")
- rpowerFrame:SetHeight(base.height)
- rpowerFrame:SetWidth(base.width)
- rpowerBackground = rpowerFrame:CreateTexture("ARTWORK")
- rpowerBackground:SetAllPoints(rpowerFrame)
- rpowerBackground:SetColorTexture(0, 0, 0)
- rpowerBackground:SetAlpha(.5)
- barFrame = CreateFrame("StatusBar", nil, rpowerFrame)
- barFrame:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")
- barFrame:SetMinMaxValues(0, UnitPowerMax("player"))
- barFrame:SetHeight(base.height)
- barFrame:SetWidth(base.width)
- barFrame:SetPoint("CENTER", rpowerFrame, "CENTER")
- barFrame:SetStatusBarColor(0, 209, 255)
- rpowerText = barFrame:CreateFontString("Rpower number", "ARTWORK", "TextStatusBarText")
- rpowerText:SetText(0)
- base.frame:Show()
- if debugging then
- print("runic power setup")
- end
- end
- function updateRpower()
- barFrame:SetMinMaxValues(0, UnitPowerMax("player"))
- barFrame:SetValue(UnitPower("player"))
- rpowerText:SetText("" .. UnitPower("player") .. " / " .. UnitPowerMax("player") .. "")
- end
- --runes
- function setupRunes()
- local base = allFrames[getFrameIndexFromTable("runes")]
- runesFrame = CreateFrame("Frame", nil, base.frame)
- runesFrame:SetPoint("TOP", base.frame, "TOP")
- runesFrame:SetHeight(base.height)
- runesFrame:SetWidth(base.width)
- runeBars = {}
- for i = 1, 6 do
- local start, duration, runeReady = GetRuneCooldown(i)
- runeBars[i] = CreateFrame("StatusBar", nil, base.frame)
- runeBars[i]:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")
- runeBars[i]:SetHeight(base.height)
- runeBars[i]:SetWidth(base.width)
- if i<4 then
- runeBars[i]:SetPoint("CENTER", runesFrame, -base.width, (i-1)*(-base.height))
- else
- runeBars[i]:SetPoint("CENTER", runesFrame, base.width, (i-4)*(-base.height))
- end
- --status bar colors - blood is red, frost blue, unholy purple
- --if specName == "blood" then
- -- runeBars[i]:SetStatusBarColor(255, 0, 0)
- --elseif specName == "frost" then
- --runeBars[i]:SetStatusBarColor(0, 191, 255)
- --elseif specName == "unholy" then
- runeBars[i]:SetStatusBarColor(225, 0, 255)
- --end
- end
- base.frame:Show()
- if debugging then
- print("runes setup")
- end
- end
- function updateRunes()
- for i = 1, 6 do
- runeStart, runeDuration, runeReady = GetRuneCooldown(i)
- if runeReady ~= true then
- runeBars[i]:SetMinMaxValues(0, runeDuration-runeStart)
- runeBars[i]:SetValue(GetTime() - runeStart)
- end
- end
- end
- --diseases
- local currentSpec = GetSpecialization()
- local specID = GetInspectSpecialization("player")
- local specName
- if specID == 250 then
- specName = "blood"
- elseif specID == 251 then
- specName = "frost"
- elseif specID == 252 then
- specName = "unholy"
- end
- local diseaseIds = {}
- local diseaseTextures = {}
- diseaseIds["blood"], diseaseIds["frost"], diseaseIds["unholy"] = { 55078, 55095, 191587 }
- diseaseTextures["blood"], diseaseTextures["frost"], diseaseTextures["unholy"] =
- {
- "Interface\\Icons\\spell_deathknight_bloodplague",
- "Interface\\Icons\\spell_deathknight_frostfever",
- "Interface\\Icons\\ability_creature_disease_02",
- }
- function setupDis()
- local base = allFrames[getFrameIndexFromTable("diseases")]
- disFrame = CreateFrame("Frame", nil, base.frame)
- disFrame:SetPoint("TOP", base.frame, "TOP")
- disFrame:SetHeight(base.height)
- disFrame:SetWidth(base.width)
- disTexture = disFrame:CreateTexture("ARTWORK")
- disTexture:SetTexture(diseaseTextures[specName])
- disCd = CreateFrame("Cooldown", nil, disFrame, "CooldownFrameTemplate")
- disCd:SetReverse(true)
- base.frame:Show()
- if debugging then
- print("diseases setup")
- end
- end
- function updateDis()
- for i =1, 40 do
- local name, _, _, _, duration, expire, _, _, _, id = UnitDebuff("target", i, "PLAYER")
- if duration ~= nil and expire ~= nil then
- if id == diseaseIds[specName] and id ~= nil then
- disCd:SetCooldown(expire-duration, duration)
- end
- end
- end
- end
- --constructs base frames for each component
- allFrames[#allFrames + 1] = framesConstructor:create("runicpower", 120, 16, setupRpower, updateRpower)
- allFrames[#allFrames + 1] = framesConstructor:create("runes", 120, 12, setupRunes, updateRunes)
- allFrames[#allFrames + 1] = framesConstructor:create("diseases", 64, 64, setupDis, updateDis)
- local function setitallup()
- for i = 1, #allFrames do
- allFrames[i].frame:SetPoint("TOP", mainFrame, "TOP", 0)
- allFrames[i].frame:SetWidth(allFrames[i].width)
- allFrames[i].frame:SetHeight(allFrames[i].height)
- allFrames[i].frame:SetFrameLevel(15)
- end
- end
- local hasInitialized = false
- mainFrame:SetScript("OnUpdate", function(self, elapsed)
- if ServerReady == true then
- if hasInitialized == false then
- for i =1, #allFrames do
- setitallup()
- allFrames[i].constructor()
- allFrames[i].frame:Show()
- end
- hasInitialized = true;
- end
- end
- for i=1, #allFrames do
- allFrames[i].updater()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement