WoWInterface SVN MoveOverErrors

[/] [trunk/] [MoveOverErrors/] [moe.lua] - Rev 7

Compare with Previous | Blame | View Log

local db
local frames = {UIErrorsFrame, RaidWarningFrame, RaidBossEmoteFrame}
local UIErrorsFrame, RaidWarningFrame, RaidBossEmoteFrame = UIErrorsFrame, RaidWarningFrame, RaidBossEmoteFrame
local RN_AM = RaidNotice_AddMessage

local function MoveUIEF(anchor, x, y)
        if anchor then
                UIErrorsFrame:ClearAllPoints()
                UIErrorsFrame:SetPoint(anchor, x, y)
        end
end

local function NEW_RN_AM(frame, ...)
        if frame == RaidBossEmoteFrame then
                return RN_AM(RaidWarningFrame, ...)
        else
                return RN_AM(frame, ...)
        end
end

local function SlashHandler(args)
        if args ~= "" then
                local a, x, y = strsplit(" ", strupper(args), 3)
                x, y = tonumber(x), tonumber(y)
                if a == "CONDENSE" then
                        db.condense = not db.condense
                        RaidNotice_AddMessage = db.condense and NEW_RN_AM or RN_AM
                        if UIErrorsFrame.bg and UIErrorsFrame.bg:IsShown() then
                                RaidNotice_Clear(RaidWarningFrame)
                                RaidNotice_Clear(RaidBossEmoteFrame)
                                RaidNotice_AddMessage(RaidWarningFrame, "This is a TEST of Raid Warnings!", ChatTypeInfo["RAID_WARNING"], 500)
                                RaidNotice_AddMessage(RaidBossEmoteFrame, "Raid Boss Emotes now shown here!", ChatTypeInfo["RAID_BOSS_EMOTE"], 500)
                        end
                        print("|cffff9000MoveOverErrors:|r  Boss emotes are "..((db.condense and "now") or "no longer").." condensed with raid warnings.")
                elseif x and y then
                        MoveUIEF(a, x, y)
                        db.anchor, db.x, db.y = a, x, y
                else
                        print("|cffff9000MoveOverErrors:|r  Slash-command help")
                        print([[ - type "/moe condense" to toggle moving messages from the RaidBossEmoteFrame into the RaidWarningFrame.]])
                        print([[ - type "/moe anchor x y" to move the UIErrorsFrame (and those attached to it). anchor may be "BOTTOM", "TOP", "CENTER", "RIGHT", "LEFT", "TOPRIGHT", etc. x and y are horizontal and vertical offsets (+/- numbers).]])
                end
        else
                local bg
                if not UIErrorsFrame.bg then
                        for i=1,3 do
                                bg = frames[i]:CreateTexture()
                                frames[i].bg = bg
                                bg:SetAllPoints()
                                bg:SetTexture("Interface\\Buttons\\WHITE8x8")
                                bg:SetVertexColor(i==1 and 1 or 0, i==2 and 1 or 0, i==3 and 1 or 0, .4)
                                bg:Hide()
                        end
                        local bgText = UIErrorsFrame:CreateFontString(nil, nil, "GameFontHighlightLarge")
                        UIErrorsFrame.bgText = bgText
                        bgText:SetPoint("CENTER")
                        bgText:SetText("UI messages and quest text")
                        bgText:Hide()
                end
                if UIErrorsFrame.bg:IsShown() then
                        for i=1,3 do
                                frames[i].bg:Hide()
                        end
                        RaidNotice_Clear(RaidWarningFrame)
                        RaidNotice_Clear(RaidBossEmoteFrame)
                        UIErrorsFrame.bgText:Hide()
                else
                        RaidNotice_AddMessage(RaidWarningFrame, "This is a TEST of Raid Warnings!", ChatTypeInfo["RAID_WARNING"], 500)
                        RaidNotice_AddMessage(RaidBossEmoteFrame, "This is a TEST of Raid Boss Emotes!", ChatTypeInfo["RAID_BOSS_EMOTE"], 500)
                        --UIErrorsFrame:AddMessage("UI messages and quest text")
                        --UIErrorsFrame:AddMessage("UIErrorsFrame")
                        for i=1,3 do
                                frames[i].bg:Show()
                        end
                        UIErrorsFrame.bgText:Show()
                end
        end
end

local f = CreateFrame("Frame")
local function SetupAndRestore()
        db = MOEDB or {}
        MoveUIEF(db.anchor, db.x, db.y)
        RaidNotice_AddMessage = db.condense and NEW_RN_AM or RN_AM
        
        SlashCmdList["MOVEOVERERRORS"] = SlashHandler
        SLASH_MOVEOVERERRORS1 = "/moveovererrors"
        SLASH_MOVEOVERERRORS2 = "/moe"
        
        f:UnregisterEvent("PLAYER_LOGIN")
        SetupAndRestore = nil
end

f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", SetupAndRestore)

Compare with Previous | Blame