WoWInterface SVN DarkSimAlert

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 3 to Rev 4
    Reverse comparison

Rev 3 → Rev 4

tags/09a/DarkSimAlert.lua New file
0,0 → 1,309
local iconSize
local dsSlot = nil
local haveDS = false
 
local defaultsettings = {
iconSize = 75,
x = UIParent:GetWidth()/2,
y = UIParent:GetHeight()/2
}
 
local DSA = CreateFrame("frame")
DSA:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)
DSA:SetMovable(true)
DSA:RegisterForDrag("LeftButton")
DSA:SetScript("OnDragStart", function(self) self:StartMoving() end)
DSA:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
DSA_Saved.x = self:GetLeft()+self:GetWidth()/2
DSA_Saved.y = self:GetBottom()+self:GetHeight()/2
self:ClearAllPoints()
self:SetPoint("CENTER",UIParent,"BOTTOMLEFT",DSA_Saved.x,DSA_Saved.y)
end)
 
local DSAT = DSA:CreateTexture(nil,"BACKGROUND")
local DSAF = DSA:CreateFontString("DarkSimFontString","OVERLAY","GameFontNormalLarge")
 
DSAF:SetFontObject(CombatLogFont)
DSAF:SetTextColor(0.0,1.0,1.0,1.0)
DSAF:SetPoint('CENTER', DSA, 'CENTER', 0, -40)
DSAF:Show()
 
DSAT:SetAllPoints(DSA)
 
-----------------------
-- Utility Functions --
-----------------------
local function tcount(tab)
local n = 0
for _ in pairs(tab) do
n = n + 1
end
return n
end
 
local function RefreshLocals()
iconSize = DSA_Saved.iconSize
end
 
local function dump(...)
local out = "";
local numVarArgs = select("#", ...);
for i = 1, numVarArgs do
local d = select(i, ...);
local t = type(d);
if (t == "table") then
out = out .. "{";
local first = true;
if (d) then
for k, v in pairs(d) do
if (not first) then out = out .. ", "; end
first = false;
out = out .. dump(k);
out = out .. " = ";
out = out .. dump(v);
end
end
out = out .. "}";
elseif (t == "nil") then
out = out .. "NIL";
elseif (t == "number") then
out = out .. d;
elseif (t == "string") then
out = out .. "\"" .. d .. "\"";
elseif (t == "boolean") then
if (d) then
out = out .. "true";
else
out = out .. "false";
end
else
out = out .. t:upper() .. "??";
end
 
if (i < numVarArgs) then out = out .. ", "; end
end
return out;
end
 
local function DSA_PopulateBlizzardOptions()
 
local sliders = {
{ text = "Icon Size", value = "iconSize", min = 30, max = 125, step = 5, relative="LEFT", x=2, y=-40 },
}
 
local buttons = {
{ text = "Unlock", func = function(self)
if (self:GetText() == "Unlock") then
RefreshLocals()
DSA:SetWidth(iconSize)
DSA:SetHeight(iconSize)
self:SetText("Lock")
DSA:SetScript("OnUpdate", nil)
DSA:SetAlpha(1)
DSAT:SetTexture("Interface\\Icons\\Spell_Shadow_Shadesofdarkness")
DSAF:SetText("Dark Simulacrum")
DSA:EnableMouse(true)
else
DSA:SetAlpha(0)
self:SetText("Unlock")
DSA:EnableMouse(false)
end end },
{ text = "Defaults", func = function(self)
for i,v in pairs(defaultsettings) do
DSA_Saved[i] = v
end
for i,v in pairs(sliders) do
getglobal("DSA_OptionsFrameSlider"..i):SetValue(DSA_Saved[v.value])
end
DSA:ClearAllPoints()
DSA:SetPoint("CENTER",UIParent,"BOTTOMLEFT",DSA_Saved.x,DSA_Saved.y)
end },
}
 
local frame = CreateFrame("frame", "DSA_BlizzardOptions", UIParent);
frame.name = "DarkSimAlert";
frame:SetWidth(300);
frame:SetHeight(200);
frame:Show();
 
for i,v in pairs(buttons) do
 
local button = CreateFrame("Button", "DSA_OptionsFrameButton"..i, frame, "OptionsButtonTemplate");
button:SetWidth(75);
button:SetHeight(24);
if (i == 1) then
button:SetPoint("TOPLEFT", 10, -20)
else
button:SetPoint("LEFT", getglobal("DSA_OptionsFrameButton"..(i-1)), "RIGHT", 10, 0)
end
button:SetText(v.text)
button:SetScript("OnClick", function(self)
PlaySound("igMainMenuOption")
v.func(self)
end)
button:GetFontString():SetPoint("TOP", button, "TOP", 0, -6)
end
 
for i,v in pairs(sliders) do
 
local valuetext = frame:CreateFontString("DSA_SliderText"..i,"ARTWORK","GameFontNormal");
valuetext:SetPoint("LEFT",getglobal("DSA_OptionsFrameButton1"),v.relative,v.x,v.y)
valuetext:SetText(format("%.1f",DSA_Saved[v.value]))
 
local slider = CreateFrame("Slider", "DSA_OptionsFrameSlider"..i, frame, "OptionsSliderTemplate")
slider:SetPoint("LEFT", getglobal("DSA_SliderText"..(i)), "RIGHT", 10, 0)
slider:SetMinMaxValues(v.min,v.max)
slider:SetValueStep(v.step)
slider:SetWidth(200)
slider:SetHeight(18)
getglobal("DSA_OptionsFrameSlider"..i.."Text"):SetText(v.text)
getglobal("DSA_OptionsFrameSlider"..i.."Low"):SetText(v.min)
getglobal("DSA_OptionsFrameSlider"..i.."High"):SetText(v.max)
slider:SetValue(DSA_Saved[v.value])
slider:SetScript("OnValueChanged",function()
local val=slider:GetValue()
DSA_Saved[v.value]=val
DSA:PrintDEBUG("saved",v.value,val)
valuetext:SetText(format("%.1f",val))
if (DSA:IsMouseEnabled()) then
DSA:SetWidth(DSA_Saved.iconSize)
DSA:SetHeight(DSA_Saved.iconSize)
end
end)
end
 
InterfaceOptions_AddCategory(frame);
end
 
--------------------
-- Event Handlers --
--------------------
function DSA:ADDON_LOADED(addon)
if (not DSA_Saved) then
DSA_Saved = defaultsettings
else
for i,v in pairs(defaultsettings) do
if (not DSA_Saved[i]) then
DSA_Saved[i] = v
end
end
end
 
for i=1,120 do
local type,spellId = GetActionInfo(i)
if (spellId ~= nil) then
if (spellId == 77606) then
dsSlot = i
break
end
end
end
 
RefreshLocals()
self:SetPoint("CENTER",UIParent,"BOTTOMLEFT",DSA_Saved.x,DSA_Saved.y)
 
DSA_PopulateBlizzardOptions()
 
self:UnregisterEvent("ADDON_LOADED")
end
DSA:RegisterEvent("ADDON_LOADED")
 
function DSA:UNIT_AURA(unit)
local name, rank, icon, count, atype, duration, expires, caster, stealable
 
if (unit == "player") then
 
-- check for dark sim
name, rank, icon, count, atype, duration, expires, caster, stealable = UnitAura("player", "Dark Simulacrum")
 
if (not haveDS) then
 
if (name ~= nil) then
local type, spellId = GetActionInfo(dsSlot)
local name = GetSpellInfo(spellId)
local helpful = IsHelpfulSpell(name)
local texture = GetSpellTexture(spellId)
 
haveDS = true
 
self:SetWidth(iconSize)
self:SetHeight(iconSize)
self:SetAlpha(1)
DSAT:SetTexture(texture)
 
if (not helpful) then
DSAF:SetTextColor(1.0,0.0,0.0,1.0)
else
DSAF:SetTextColor(0.0,1.0,0.0,1.0)
end
 
DSAF:SetText(name)
self:Show()
 
PlaySoundFile("Sound\Spells\SeepingGaseous_Fel_Nova.wav")
end
else
if (name == nil) then
haveDS = false
self:SetAlpha(0)
DSAT:SetTexture()
DSAF:SetText("")
self:Hide()
end
end
end
end
DSA:RegisterEvent("UNIT_AURA")
 
function DSA:PLAYER_ENTERING_WORLD()
local inInstance,instanceType = IsInInstance()
if (inInstance and instanceType == "arena") then
self:SetScript("OnUpdate", nil)
wipe(cooldowns)
wipe(watching)
end
end
DSA:RegisterEvent("PLAYER_ENTERING_WORLD")
 
function DSA:PrintDEBUG(...)
 
local debugWin;
 
for i=1, NUM_CHAT_WINDOWS do
if (GetChatWindowInfo(i):lower() == "dsadebug") then
debugWin = i;
break;
end
end
 
local out = time()..",";
 
for i = 1, select("#", ...) do
if (i > 1) then out = out .. ", "; end
local currentArg = select(i, ...)
local argType = type(currentArg);
if (argType == "string") then
out = out .. '"'..currentArg..'"';
elseif (argType == "number") then
out = out .. currentArg;
else
out = out .. dump(currentArg);
end
end
 
if (not debugWin) then
return
end
 
getglobal("ChatFrame"..debugWin):AddMessage(out, 1.0, 1.0, 0.3);
end
-------------------
-- Options Frame --
-------------------
 
SlashCmdList["DARKSIMALERT"] = function()
InterfaceOptionsFrame_OpenToCategory('DarkSimAlert')
end
SLASH_DARKSIMALERT1 = "/dsa"
SLASH_DARKSIMALERT2 = "/darksimalert"
\ No newline at end of file
tags/09a/DarkSimAlert.toc New file
0,0 → 1,7
## Interface: 40000
## Title: DarkSimAlert
## Notes: Flash the copied ability of a Death Knight's "Dark Simulacrum" target in the middle of the screen when it happens.
## Author: Hanzo (Mature of Deathwing[US])
## SavedVariables: DSA_Saved
 
DarkSimAlert.lua
\ No newline at end of file