changeset 1:f601b8507480

AfterDark - Initial Import
author wobin
date Sun, 20 Dec 2009 21:45:17 +1100
parents 1bfd89cb7f44
children e1cb3389b289
files .pkgmeta AfterDark.lua AfterDark.toc AfterOptions.lua Images/Toast.tga Images/ToastTopping.tga Images/WingDown.tga Images/WingNeutral.tga Images/WingUp.tga Images/fta.mp3 Images/rotv.mp3 Locale/Localization_enUS.lua Toast.lua Toaster.lua embeds.xml
diffstat 15 files changed, 407 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.pkgmeta	Sun Dec 20 21:45:17 2009 +1100
@@ -0,0 +1,10 @@
+package-as: AfterDark
+
+externals:
+    Libs/LibStub: svn://svn.wowace.com/wow/ace3/mainline/trunk/LibStub
+    Libs/CallbackHandler-1.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/CallbackHandler-1.0
+    Libs/AceConfigDialog-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConfigDialog-3.0
+    Libs/AceConfig-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConfig-3.0
+    Libs/AceDB-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceDB-3.0
+    Libs/AceLocale-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceLocale-3.0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AfterDark.lua	Sun Dec 20 21:45:17 2009 +1100
@@ -0,0 +1,154 @@
+AddonName, AfterDark = ...
+LibStub("AceTimer-3.0"):Embed(AfterDark)
+LibStub("AceEvent-3.0"):Embed(AfterDark)
+
+AfterDark.L = LibStub("AceLocale-3.0"):GetLocale("AfterDark", true)
+local L = AfterDark.L
+
+local RIDE = "Interface\\AddOns\\AfterDark\\Images\\rotv.mp3"
+local ANTHEM = "Interface\\AddOns\\AfterDark\\Images\\fta.mp3"
+
+local SCREEN_HEIGHT = GetScreenHeight()
+local SCREEN_WIDTH = GetScreenWidth()
+
+local ScreenSaving = false
+
+burntoutToasters, shinyToasters, toasterRack, pendingFlight = {}, {}, {}, {}
+
+function OnFinished(self)
+	if ScreenSaving then 
+		table.insert(pendingFlight, AfterDark:ScheduleTimer("SpawnMonkey", 0 ))
+		if #shinyToasters < AfterDark.db.profile.Busy then
+			table.insert(pendingFlight, AfterDark:ScheduleTimer("SpawnMonkey", math.random(0, AfterDark.db.profile.Speed)))
+		end
+	end
+	AfterDark:CleanCrumbTray(self.parent)
+end
+
+function AfterDark:BringMeTheHeadOfAlfredoGarcia()
+	local frame = table.remove(burntoutToasters)
+	if not frame then
+		frame = CreateFrame("Frame", nil, UIParent)
+		frame:SetFrameStrata("BACKGROUND")
+		frame:SetFrameLevel(math.random(1,60))
+		frame:SetHeight(64)
+		frame:SetWidth(64)
+	
+		frame.mover = frame:CreateAnimationGroup()
+		frame.mover.parent = frame
+		frame.mover:SetLooping("NONE")
+		frame.mover:SetScript("OnFinished", OnFinished)	
+
+		frame.transporter = frame.mover:CreateAnimation("Translation")
+		frame.zoomer = frame.mover:CreateAnimation("Scale")
+
+		if math.random(0,100) < 85 then
+			AfterDark:ConstructToaster(frame)
+		else
+			AfterDark:SliceBread(frame)
+		end	
+	end	
+
+
+	table.insert(shinyToasters, frame)
+	if not toasterRack[frame] then
+		toasterRack[frame] = true
+	end
+	return frame
+end
+
+function AfterDark:SpawnMonkey()
+	local halfHeight = SCREEN_HEIGHT/2
+	local yOffset = math.random(-halfHeight, halfHeight)
+	
+	local scale = math.random(0.75, 1.5)
+
+	if #shinyToasters >= AfterDark.db.profile.Busy then return end
+	local head = self:BringMeTheHeadOfAlfredoGarcia()
+
+	head:ClearAllPoints()
+	head:SetPoint("RIGHT", UIParent, "RIGHT", 64, yOffset)
+
+	local yLanding = math.random(-halfHeight, halfHeight)
+
+	if head.IsToast then head.shade:SetAlpha(1 - AfterDark.db.profile.Darkness) end -- Retoast the bread
+	head:Respeed()
+
+	head.transporter:SetOffset(-SCREEN_WIDTH - 64 * scale, yLanding)
+	head.transporter:SetDuration(AfterDark.db.profile.Speed)
+	head.zoomer:SetScale(scale, scale)
+	head.zoomer:SetDuration(AfterDark.db.profile.Speed)
+	head:Start()
+end
+
+function AfterDark:PlayThatFunkyMusic()
+	if AfterDark.db.profile.Music == "zRandom" then
+		if math.random(1,2) == 1 then
+			PlayMusic(RIDE)
+		else
+			PlayMusic(ANTHEM)
+		end
+		return
+	else
+		if AfterDark.db.profile.Music == "Ride" then
+			PlayMusic(RIDE)
+		else
+			PlayMusic(ANTHEM)
+		end
+	end
+end
+
+function AfterDark:ScheduleFlight()
+	StopMusic()
+	table.insert(pendingFlight, self:ScheduleTimer("PlayThatFunkyMusic", 1))
+	table.insert(pendingFlight, self:ScheduleTimer("BeFreeMyPretties", 4))
+end
+
+function AfterDark:BeFreeMyPretties()
+	for i=1,AfterDark.db.profile.Busy do
+		table.insert(pendingFlight, AfterDark:ScheduleTimer("SpawnMonkey", math.random(0, AfterDark.db.profile.Speed)))
+	end
+
+end
+
+function AfterDark:QuickItsTheFuzz()
+	for i,v in ipairs(pendingFlight) do
+		AfterDark:CancelTimer(v, true)
+	end
+	for v,_ in pairs(toasterRack) do
+		v:Finish()
+		self:CleanCrumbTray(v)
+	end
+	pendingFlight = {}
+	StopMusic()
+end
+
+function AfterDark:CleanCrumbTray(frame)
+	for i = #shinyToasters, 1, -1 do
+		if frame == shinyToasters[i] then
+			table.insert(burntoutToasters, table.remove(shinyToasters, i))
+			return
+		end
+	end
+end
+
+function AfterDark:LightsAreOnButNobodysHome(eventName, target)
+	if target ~= "player" then return end
+	if UnitIsAFK("player") then 
+		ScreenSaving = true
+		self:ScheduleFlight()
+	else
+		ScreenSaving = false
+		self:QuickItsTheFuzz()
+	end
+end
+
+function AfterDark:SetMeUp(event, addon)
+	if addon ~= "AfterDark" then return end
+	self:RegisterEvent("PLAYER_FLAGS_CHANGED", "LightsAreOnButNobodysHome")
+	self.db = LibStub("AceDB-3.0"):New("AfterDarkDB", {profile = { Busy = 30, Music = "zRandom", Darkness = 0.5, Speed = 10 } })
+	AfterDark:SetupOptions()
+end
+
+AfterDark:RegisterEvent("ADDON_LOADED", "SetMeUp")
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AfterDark.toc	Sun Dec 20 21:45:17 2009 +1100
@@ -0,0 +1,16 @@
+## Interface: 30300
+## Title: AfterDark
+## Notes: Artwork by Tomoya Ikeda & Igor Gasowski Original concept by Jack Eastman - Thank you for the memories...
+## Author: Wobin
+## Version: 1.0.0
+## OptionalDeps: Ace3
+## SavedVariables: AfterDarkDB
+
+embeds.xml
+
+Locale\Localization_enUS.lua
+
+AfterDark.lua
+Toaster.lua
+Toast.lua
+AfterOptions.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AfterOptions.lua	Sun Dec 20 21:45:17 2009 +1100
@@ -0,0 +1,74 @@
+local AddonName, AfterDark = ...
+local AceDialog 
+local L = AfterDark.L
+
+local function loadToasterOptions()
+	options.args.general = {
+		order = 1,
+		type = "group",
+		name = L["General"],
+		set = function(info, value) AfterDark.db.profile[info[#info]] = value end,
+		get = function(info) return AfterDark.db.profile[info[#info]] end,
+		args = {
+					Darkness = {
+						order = 1,
+						type = "range",
+						name = L["Darkness"],
+						desc = L["How well done you want your toast"],
+						min = 0, max = 1,
+					},
+					Music = {
+						order = 2,
+						type = "select",
+						name = L["Music"],
+						values = { ["Anthem"] = L["Anthem of the Flying Toasters"], ["Ride"]  = L["Ride of the Valkyries"], ["zRandom"] = L["Both"] },
+						style = "dropdown",
+						width = "double"
+					},
+					Busy = {
+						order = 3,
+						type = "range",
+						name = L["Busy"],
+						desc = L["How busy do you want it?"],
+						min = 10, max = 120, step = 1,
+						width = "full"
+					},
+					Speed = {
+						order = 4,
+						type = "range",
+						name = L["Speed"],
+						desc = L["Do you feel... the Need for Speed?"],
+						min = 1, max = 30, step = 1,
+						width = "full"
+					}
+				}
+			}
+end
+
+local function loadOptions()
+	options = {
+		type = "group",
+		name = "After Dark",
+		childGroups = "tab",
+		args = {}
+	}
+	loadToasterOptions()
+end
+
+
+SLASH_AFTERDARK1 = "/afterdark"
+SLASH_AFTERDARK2 = "/ad"
+
+SlashCmdList["AFTERDARK"] = function(msg)
+	InterfaceOptionsFrame_OpenToCategory(AfterDark.Config)
+end
+
+function AfterDark:SetupOptions()
+	if not AceDialog then
+		loadOptions()
+
+		AceDialog = LibStub("AceConfigDialog-3.0")
+		LibStub("AceConfig-3.0"):RegisterOptionsTable("AfterDark", options)
+		AfterDark.Config = AceDialog:AddToBlizOptions("AfterDark", "After Dark", nil, 'general') 
+	end
+end
Binary file Images/Toast.tga has changed
Binary file Images/ToastTopping.tga has changed
Binary file Images/WingDown.tga has changed
Binary file Images/WingNeutral.tga has changed
Binary file Images/WingUp.tga has changed
Binary file Images/fta.mp3 has changed
Binary file Images/rotv.mp3 has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Locale/Localization_enUS.lua	Sun Dec 20 21:45:17 2009 +1100
@@ -0,0 +1,14 @@
+local L = LibStub("AceLocale-3.0"):NewLocale("AfterDark", "enUS", true)
+
+L["Anthem of the Flying Toasters"] = "Anthem of the Flying Toasters"
+L["Both"] = "Both"
+L["Busy"] = "Busy"
+L["Darkness"] = "Darkness"
+L["Do you feel... the Need for Speed?"] = "Do you feel... the Need for Speed?"
+L["General"] = "General"
+L["How busy do you want it?"] = "How busy do you want it?"
+L["How well done you want your toast"] = "How well done you want your toast"
+L["Music"] = "Music"
+L["Ride of the Valkyries"] = "Ride of the Valkyries"
+L["Speed"] = "Speed"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Toast.lua	Sun Dec 20 21:45:17 2009 +1100
@@ -0,0 +1,42 @@
+local AddonName, AfterDark = ...
+
+local TOAST = "Interface\\AddOns\\AfterDark\\Images\\Toast"
+local JAM = "Interface\\AddOns\\AfterDark\\Images\\ToastTopping"
+
+function AfterDark:SliceBread(frame)
+	frame.toast = frame:CreateTexture(nil, "BACKGROUND")
+	frame.toast:SetAllPoints(frame)
+	frame.toast:SetTexture(TOAST)
+	
+	frame.shade = frame:CreateTexture(nil, "BACKGROUND")
+	frame.shade:SetAllPoints(frame)
+	frame.shade:SetTexture(JAM)
+	frame.shade:SetBlendMode("ADD")
+	frame.shade:SetAlpha(1 - AfterDark.db.profile.Darkness)
+	frame.tumbler = frame:CreateAnimationGroup()
+	frame.tumbler.parent = frame
+	frame.tumbler:SetLooping("NONE")
+
+	frame.spin = frame.tumbler:CreateAnimation("Rotation")
+	frame.spin:SetDegrees(math.random(1,2) == 1 and 360 or -360)
+	frame.spin:SetOrigin("CENTER", 0,0)
+	frame.spin:SetStartDelay(math.random(3, AfterDark.db.profile.Speed))
+	frame.spin:SetDuration(3)
+
+	frame.IsToast = true
+
+	frame.Respeed = function(self)
+		frame.spin:SetStartDelay(math.random(3,AfterDark.db.profile.Speed))
+	end
+
+	frame.Start = function(self)
+		self.mover:Play()
+		self.tumbler:Play()
+		self:Show()
+	end
+
+	frame.Finish = function(self)
+		self:StopAnimating()
+		self:Hide()
+	end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Toaster.lua	Sun Dec 20 21:45:17 2009 +1100
@@ -0,0 +1,88 @@
+local AddonName, AfterDark = ...
+
+local TOASTERUP = "Interface\\AddOns\\AfterDark\\Images\\WingUp"
+local TOASTERCOASTER = "Interface\\AddOns\\AfterDark\\Images\\WingNeutral"
+local TOASTERDOWN = "Interface\\AddOns\\AfterDark\\Images\\WingDown"
+
+function AfterDark:ConstructToaster(frame)
+		frame.toasterup = frame:CreateTexture(nil, "BACKGROUND")
+		frame.toasterup:SetAllPoints(frame)
+		frame.toasterup:SetTexture(TOASTERUP)
+		
+		frame.toasterdown = frame:CreateTexture(nil, "BACKGROUND")
+		frame.toasterdown:SetAllPoints(frame)
+		frame.toasterdown:SetTexture(TOASTERDOWN)
+		frame.toasterdown:SetAlpha(0)
+
+		frame.toasterglide = frame:CreateTexture(nil, "BACKGROUND")
+		frame.toasterglide:SetAllPoints(frame)
+		frame.toasterglide:SetTexture(TOASTERCOASTER)
+		frame.toasterglide:SetAlpha(0)
+		
+		frame.fader = frame.toasterup:CreateAnimationGroup()
+		frame.fader.parent = frame.toasterup
+		frame.fader:SetLooping("BOUNCE")
+		
+		frame.toasterup.fade = frame.fader:CreateAnimation("Alpha")
+		frame.toasterup.fade:SetDuration(1)
+		frame.toasterup.fade:SetChange(-1)
+		frame.toasterup.fade:SetOrder(1)
+		
+		frame.crossfader = frame.toasterdown:CreateAnimationGroup()
+		frame.crossfader.parent = frame.toasterdown
+		frame.crossfader:SetLooping("BOUNCE")
+
+		frame.toasterdown.fade = frame.crossfader:CreateAnimation("Alpha")
+		frame.toasterdown.fade:SetDuration(1)
+		frame.toasterdown.fade:SetChange(1)
+		frame.toasterdown.fade:SetOrder(1)
+
+		frame.hashfader = frame.toasterglide:CreateAnimationGroup()
+		frame.hashfader.parent = frame.toasterglide
+		frame.hashfader:SetLooping("BOUNCE")
+
+		frame.toasterglide.fade = frame.hashfader:CreateAnimation("Alpha")
+		frame.toasterglide.fade:SetDuration(0.5)
+		frame.toasterglide.fade:SetChange(1)
+		frame.toasterglide.fade:SetOrder(1)
+
+		if math.random(0,5) > 4 then
+			local delay = math.random(30,AfterDark.db.profile.Speed * 10)
+
+			frame.tumbler = frame:CreateAnimationGroup()
+			frame.tumbler.parent = frame
+			frame.tumbler:SetLooping("NONE")
+
+			frame.spin = frame.tumbler:CreateAnimation("Rotation")
+			frame.spin:SetDegrees(360)
+			frame.spin:SetOrigin("CENTER", -20,-20)
+			frame.spin:SetStartDelay(delay/10)
+			frame.spin:SetDuration(1)
+			frame.spin:SetOrder(1)
+		end
+	
+		frame.IsToaster = true
+
+		frame.Respeed = function(self)
+			if frame.spin then
+				frame.spin:SetStartDelay(math.random(30, AfterDark.db.profile.Speed * 10)/10)
+			end
+		end
+	
+		frame.Start = function(self)
+			self.mover:Play()
+			self.fader:Play()
+			self.crossfader:Play()
+			self.hashfader:Play()
+			if self.tumbler then
+				self.tumbler:Play()
+			end
+			self:Show()
+		end
+
+		frame.Finish = function(self)
+			self:StopAnimating()
+			self:Hide()
+		end
+
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/embeds.xml	Sun Dec 20 21:45:17 2009 +1100
@@ -0,0 +1,9 @@
+<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
+..\FrameXML\UI.xsd">
+	<Script file="Libs\LibStub\LibStub.lua"/>
+	<Include file="Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
+	<Include file="Libs\AceLocale-3.0\AceLocale-3.0.xml"/>
+	<Include file="Libs\AceDB-3.0\AceDB-3.0.xml"/>
+	<Include file="Libs\AceConfig-3.0\AceConfig-3.0.xml"/>
+	<Include file="Libs\AceConfigDialog-3.0\AceConfigDialog-3.0.xml"/>
+</Ui>