WoWInterface SVN impMotD

[/] [trunk/] [impMotD/] [core.lua] - Rev 3

Compare with Previous | Blame | View Log

--[[
        ##AddOn   : impMotD
        ##Subfile : core.lua
        ##Author  : Hati-EK             
--]]

--Carryframe
local imotd = CreateFrame('Frame','Improved_MotD_Frame',UIParent)
imotd:SetWidth(300)
imotd:SetHeight(100)
imotd:SetPoint("CENTER",UIParent,"CENTER",0,0)
imotd:SetFrameStrata("TOOLTIP")
--Background Texture (Pure Black)
imotd.bg = imotd:CreateTexture(imotd:GetName().."_Texture")
imotd.bg:SetTexture(0,0,0,1)
imotd.bg:SetAllPoints(imotd)
--Guildname
imotd.gname = imotd:CreateFontString(imotd:GetName().."_GuildName", "ARTWORK")
imotd.gname:SetPoint("TOP", imotd, "TOP", 0, 0)
imotd.gname:SetFont("Fonts\\FRIZQT__.TTF",16,"OUTLINE")
imotd.gname:SetTextColor(0, 1, 0)
imotd.gname:SetText(imotd.g)
imotd.gname:SetWidth(300)
imotd.gname:Show()
--MotD
imotd.text = imotd:CreateFontString(imotd:GetName().."_Text", "ARTWORK")
imotd.text:SetPoint("TOPLEFT", imotd, "TOPLEFT", 0, -18)
imotd.text:SetFont("Fonts\\FRIZQT__.TTF",12,"OUTLINE")
imotd.text:SetTextColor(0, 1, 0)
imotd.text:SetText()
imotd.text:SetWidth(300)
imotd.text:Show()
--Ok/Cancel Button
imotd.okBtn = CreateFrame("Button",imotd:GetName().."_OkBtn",imotd)
imotd.okBtn:SetWidth(50)
imotd.okBtn:SetHeight(10)
imotd.okBtn:SetPoint("BOTTOM", imotd ,"BOTTOM", 0, 0)
--[[ unnecessary 
imotd.okBtn.t = imotd.okBtn:CreateTexture(imotd.okBtn:GetName().."_Texture")
imotd.okBtn.t:SetAllPoints(imotd.okBtn)
imotd.okBtn.t:SetTexture(0,0,0,1)]]
imotd.okBtn.txt = imotd.okBtn:CreateFontString(imotd.okBtn:GetName().."_Text","ARTWORK")
imotd.okBtn.txt:SetPoint("Center", imotd.okBtn, "Center",0,0)
imotd.okBtn.txt:SetFont("Fonts\\FRIZQT__.TTF",12,"OUTLINE")
imotd.okBtn.txt:SetTextColor(1,1,1)
imotd.okBtn.txt:SetText("Ok")
imotd.okBtn:RegisterForClicks("AnyUp")
imotd.okBtn:SetScript("OnClick",
function(self, button, down)
        imotd:Hide()
end)


--#Script
--GetGuildName After Init - as this is  delayed
local counter = 0
imotd:SetScript('OnUpdate',function(self,elapsed)
        if not self.lastUpdate  then
                self.lastUpdate=0
        end
        self.lastUpdate = self.lastUpdate+elapsed
        while (self.lastUpdate > 1) do
                counter=counter+1
                local guild = GetGuildInfo('player')
                if guild then
                        self.gname:SetText(guild.."-MotD")
                        self.text:SetText(GetGuildRosterMOTD())
                        self:SetScript('OnUpdate',nil)
                        return
                --player has no Guild
                elseif counter>100 then
                        self:SetScript('OnUpdate',nil)
                        return
                end
                self.lastUpdate = self.lastUpdate - 1
        end
end)
--Show if MotD changes
function imotd:GUILD_MOTD(motd)
        local guild = GetGuildInfo('player')
        if guild then
                self.gname:SetText(guild)
        end     
        self.text:SetText(motd)
        self:Show()
end

imotd:RegisterEvent('GUILD_MOTD')
imotd:SetScript('OnEvent',function(self,event,...)
        self[event](self,...)
end)



Compare with Previous | Blame