WoWInterface SVN HolidayFun

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

trunk/Holiday Fun/media/string of lights - off.blp Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
trunk/Holiday Fun/media/red lights on - overlay.blp Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
trunk/Holiday Fun/media/CarolBells.wav Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
trunk/Holiday Fun/media/hohoho.wav Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
trunk/Holiday Fun/media/green lights on - overlay.blp Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
trunk/Holiday Fun/media/snow1.blp Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
trunk/Holiday Fun/media/snow2.blp Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
trunk/Holiday Fun/Holiday Fun.toc New file
0,0 → 1,8
## Interface: 30300
## Title: Holiday Fun!
## Author: Seerah
## Version: 1.0
## Notes: Get in the holiday spirit with a Christmas themed UI!
## SavedVariables: HolidayFunDB
 
holiday.lua
\ No newline at end of file
trunk/Holiday Fun/holiday.lua New file
0,0 → 1,217
--LOCALS AND FRAME CREATION--
-----------------------------
local redLightsOn = "Interface\\AddOns\\Holiday Fun\\media\\red lights on - overlay"
local greenLightsOn = "Interface\\AddOns\\Holiday Fun\\media\\green lights on - overlay"
local lightString = "Interface\\AddOns\\Holiday Fun\\media\\string of lights - off"
local count = 0
local musicplayed = false
local db
 
local f = CreateFrame("Frame") --event handler frame and OnUpdate for music's playOnce if true
local snowframe = CreateFrame("PlayerModel", nil, UIParent)
local snowbaseleft = CreateFrame("Frame", nil, UIParent)
local snowbaseright = CreateFrame("Frame", nil, UIParent)
local lightsframeleft = CreateFrame("Frame", nil, UIParent)
lightsframeleft:Hide() --don't bother with OnUpdate until visible, also helps delay music longer
local lightsframeright = CreateFrame("Frame", nil, UIParent)
local redLightsLeft = lightsframeleft:CreateTexture()
local redLightsRight = lightsframeright:CreateTexture()
local greenLightsLeft = lightsframeleft:CreateTexture()
local greenLightsRight = lightsframeright:CreateTexture()
 
local defaults = {
firstLoad = true,
lightsOn = true,
snowOn = true,
musicOn = true,
playOnce = false,
}
 
----GOOD STUFF----
------------------
local function lightsUpdate(self,elapsed)
count = count + elapsed
if count <= .5 then
redLightsLeft:SetAlpha(count*2)
redLightsRight:SetAlpha(count*2)
elseif count > 1 and count <= 2.5 then
return
elseif count > 2.5 and count <= 3 then
redLightsLeft:SetAlpha((3-count)*2)
redLightsRight:SetAlpha((3-count)*2)
elseif count > 3 and count <= 3.5 then
greenLightsLeft:SetAlpha((count-3)*2)
greenLightsRight:SetAlpha((count-3)*2)
elseif count > 3.5 and count <= 5 then
return
elseif count > 5 and count <= 5.5 then
greenLightsLeft:SetAlpha((5.5-count)*2)
greenLightsRight:SetAlpha((5.5-count)*2)
elseif count > 5.5 then
count = 0
end
end
 
local function framesSetup()
--THE ANIMATED SNOW MODEL
snowframe:SetScale(1.2)
snowframe:SetModelScale(.8)
snowframe:SetAllPoints()
snowframe:SetAlpha(.35)
if db.snowOn then
snowframe:SetModel("SPELLS\\ChristmasSnowRain.m2")
end
 
--THE SNOW ALONG THE BOTTOM
snowbaseleft:SetPoint("BOTTOMLEFT", 0, -10)
snowbaseleft:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOM", 0, -10)
snowbaseleft:SetBackdrop({bgFile = "Interface\\AddOns\\Holiday Fun\\media\\snow1"})
snowbaseleft:SetHeight(100)
snowbaseleft:SetAlpha(.9)
snowbaseleft:SetFrameStrata("HIGH")
snowbaseright:SetPoint("BOTTOMRIGHT", 0, -10)
snowbaseright:SetPoint("BOTTOMLEFT", snowbaseleft, "BOTTOMRIGHT")
snowbaseright:SetBackdrop({bgFile = "Interface\\AddOns\\Holiday Fun\\media\\snow2"})
snowbaseright:SetHeight(100)
snowbaseright:SetAlpha(.9)
snowbaseright:SetFrameStrata("HIGH")
 
--THE STRING OF LIGHTS
lightsframeleft:SetPoint("TOPRIGHT", UIParent, "TOP")
lightsframeleft:SetFrameStrata("HIGH")
lightsframeleft:SetBackdrop({bgFile = lightString})
lightsframeright:SetPoint("TOPLEFT", UIParent, "TOP", -1,0)
lightsframeright:SetFrameStrata("HIGH")
lightsframeright:SetBackdrop({bgFile = lightString})
 
--THE RED AND GREEN LIGHTS ON
redLightsLeft:SetTexture(redLightsOn)
redLightsRight:SetTexture(redLightsOn)
greenLightsLeft:SetTexture(greenLightsOn)
greenLightsRight:SetTexture(greenLightsOn)
 
--SET ALPHA TO 0 TO START
redLightsLeft:SetAlpha(0)
redLightsRight:SetAlpha(0)
greenLightsLeft:SetAlpha(0)
greenLightsRight:SetAlpha(0)
 
if db.lightsOn then --only set OnUpdate if we want the lights to flash
lightsframeleft:SetScript("OnUpdate", lightsUpdate)
end
end
 
local function finalSetup()
--screen width isn't set until later when the var for resolution is passed
local screenWidth = GetScreenWidth()
lightsframeleft:SetWidth(screenWidth/2 + 1)
lightsframeright:SetWidth(screenWidth/2 + 1)
lightsframeleft:SetHeight(screenWidth/16)
lightsframeright:SetHeight(screenWidth/16)
--now that the lights frames have sizes, we can anchor textures
redLightsLeft:SetAllPoints()
redLightsRight:SetAllPoints()
greenLightsLeft:SetAllPoints()
greenLightsRight:SetAllPoints()
 
lightsframeleft:Show() --ready to start OnUpdate now if db.lightsOn == true
 
PlaySoundFile("Interface\\AddOns\\Holiday Fun\\media\\hohoho.wav")
if db.musicOn then
local count = 0 --this count var is local to only this scope(?)
f:SetScript("OnUpdate", function(self,elapsed)
count = count + elapsed
if count >= 3 and not musicplayed then --music gets overwritten by zone music if not delayed at login
PlayMusic("Interface\\AddOns\\Holiday Fun\\media\\CarolBells.wav")
musicplayed = true
if not db.playOnce then --if db.playOnce == false then stop OnUpdate from counting, keeping the music looping
f:Hide()
end
elseif count >= 225 then --if db.playOnce == true then stop music from looping
StopMusic()
f:Hide()
end
end)
end
end
 
local function Initialization()
HolidayFunDB = HolidayFunDB or {}
for k,v in pairs(defaults) do
if type(HolidayFunDB[k]) == "nil" then
HolidayFunDB[k] = v
end
end
db = HolidayFunDB
 
if db.firstLoad then
print("|cff78AB46Holiday Fun!:|r Happy Holidays! Type /holidayfun or /hf for options. (You will only see this message once.)")
db.firstLoad = false
end
 
SLASH_HOLIDAYFUN1 = "/holidayfun"
SLASH_HOLIDAYFUN2 = "/hf"
SlashCmdList["HOLIDAYFUN"] = function(arg)
arg = string.lower(arg)
if arg == "snow" then
db.snowOn = not db.snowOn
if db.snowOn then
print("|cff78AB46Holiday Fun!:|r Snowfall enabled")
snowframe:SetModel("SPELLS\\ChristmasSnowRain.m2")
else
print("|cff78AB46Holiday Fun!:|r Snowfall disabled")
snowframe:ClearModel()
end
elseif arg == "lights" then
db.lightsOn = not db.lightsOn
if db.lightsOn then
print("|cff78AB46Holiday Fun!:|r Lights turned on.")
lightsframeleft:SetScript("OnUpdate", lightsUpdate)
else
print("|cff78AB46Holiday Fun!:|r Lights turned off.")
lightsframeleft:SetScript("OnUpdate", function() end)
count = 0
redLightsLeft:SetAlpha(0)
redLightsRight:SetAlpha(0)
greenLightsLeft:SetAlpha(0)
greenLightsRight:SetAlpha(0)
end
elseif arg == "music" then
db.musicOn = not db.musicOn
if db.musicOn then
print("|cff78AB46Holiday Fun!:|r Music will be played when logging in.")
else
print("|cff78AB46Holiday Fun!:|r Music will not be played when logging in.")
end
elseif arg == "loopmusic" then
db.playOnce = not db.playOnce
if db.playOnce then
print("|cff78AB46Holiday Fun!:|r Loop music set to off. 'Carol of the Bells' will only play once before resuming your zone music, regardless of if you have background music set to play continuously in your sound options. Does not take effect until next login or reload.")
else
print("|cff78AB46Holiday Fun!:|r Loop music set to on. 'Carol of the Bells' will play continuously.")
end
elseif arg == "playmusic" then
PlayMusic("Interface\\AddOns\\Holiday Fun\\media\\CarolBells.wav")
print("|cff78AB46Holiday Fun!:|r Now playing 'Carol of the Bells' - if you have music set to loop in your sound options, this will play continuously. Type '/holidayfun stopmusic' to stop the song from playing.")
elseif arg == "stopmusic" then
StopMusic()
print("|cff78AB46Holiday Fun!:|r Music stopped.")
else
print("|cff78AB46Holiday Fun!:|r Options are snow, lights, music, playmusic, stopmusic, or loopmusic.")
end
end
end
 
f:SetScript("OnEvent", function(self, event, addon)
if event == "ADDON_LOADED" and addon == "Holiday Fun" then
f:UnregisterEvent("ADDON_LOADED")
Initialization()
framesSetup()
elseif event == "PLAYER_ENTERING_WORLD" then
finalSetup()
f:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
end)
 
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("ADDON_LOADED")
\ No newline at end of file