/
## Interface: 20400 |
## Title: NaturCombat |
## Version: 9.0BETA3 |
## Version: wowi:revision |
## Author: Macca, Beladona |
## Notes: Enemy cast bars for cooldowns, buffs, debuffs and casts for both pvp and pve |
## OptionalDeps: LibStub, LibWombat, GTB-1.0, LibSharedMedia-3.0 |
## OptionalDeps: LibStub, LibWombat, NaturGTB, LibSharedMedia-3.0 |
## SavedVariables: NaturDB |
embed\LibStub\LibStub.lua |
embed\LibSharedMedia-3.0\LibSharedMedia-3.0.lua |
addon\spells.lua |
addon\spells\Druid.lua |
addon\spells\Rogue.lua |
addon\spells\Priest.lua |
addon\spells\Paladin.lua |
addon\spells\Hunter.lua |
addon\spells\Shaman.lua |
addon\spells\Mage.lua |
addon\spells\Warlock.lua |
addon\spells\Warrior.lua |
addon\generator.lua |
addon\parser.lua |
local addon = LibStub:GetLibrary("NaturCombat"); |
assert(addon,"NaturCombatTimers failed to load in 'NaturCombat\addon\parser.lua' on line 1"); |
LibStub:GetLibrary("LibWombat"):NewParser(addon); |
assert(addon.StartParsing,"LibWombat failed to load in 'NaturCombat\addon\parser.lua' on line 3"); |
NaturDB = NaturDB or {Height=20,Width=270,Scale=1,FontSize=15,MaxBars=10,Lock=true,Growth="UP",Invert=true,Texture="NaturGlaze",Cooldowns=true,Diminishing=true,Sounds=true}; |
addon.factor = 1; |
local CPAura, KillCounter, KillTimer = false, 0; |
local expTime, activeDR = {}, {}; |
local CDTable = {}; |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("VARIABLES_LOADED", function() |
addon.group = addon.bar:RegisterGroup("NaturCombat", addon.media:Fetch("statusbar", NaturDB.Texture)); |
addon.group:SetScale(NaturDB.Scale); |
addon.group:SetWidth(NaturDB.Width); |
addon.group:SetHeight(NaturDB.Height); |
addon.group:SetDisplayGroup("NaturCombat"); -- This redirects every bar to this certain group. |
addon.group:SetAnchorVisible(NaturDB.Lock); |
addon.group:SetGroupFontSize(NaturDB.FontSize); |
addon.group:SetMaxBars(NaturDB.MaxBars); |
addon.group:SetBarGrowth(NaturDB.Growth); |
addon.group:SetInvert(NaturDB.Invert); |
addon.group:SetPoint("CENTER"); |
addon.group:RegisterOnFade(addon, "OnFade"); |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("PLAYER_ENTERING_WORLD", function() |
local _, z = IsInInstance(); |
if (z == "arena") then -- Player is in an arena, clean bars |
addon.group:UnregisterAllBars(); |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("SPELL_AURA_APPLIED", function(when,what,srcGUID,srcName,srcFlags,dstGUID,dstName,dstFlags,...) |
local spell = addon:GetSpellData(...); |
if (dstGUID == UnitGUID("target") or dstGUID == UnitGUID("focus")) and (dstGUID ~= UnitGUID("player")) then |
if (spell) and (spell.duration) then |
-- Talents? |
if (spell.talent) then |
if (spell.talent[5] == select(2,UnitClass("player"))) then |
local _, _, _, _, rank = GetTalentInfo(spell.talent[1], spell.talent[2]); |
if (rank) and (rank > 0) then |
spell.duration = spell.talent[3] + rank * spell.talent[4]; |
end |
end |
end |
-- Set Bar Color |
local color = addon.colors["GREY"]; |
if (spell.type == "BUFF") then |
if (CombatLog_Object_IsA(dstFlags, COMBATLOG_FILTER_HOSTILE_PLAYERS)) then |
color = addon.colors["HOSTILEBUFF"]; |
elseif (CombatLog_Object_IsA(dstFlags, COMBATLOG_FILTER_FRIENDLY_UNITS)) then |
color = addon.colors["FRIENDLYBUFF"]; |
end |
elseif (spell.type == "DEBUFF") then |
if (spell.stun) then |
color = addon.colors["STUN"]; |
elseif (spell.dot) then |
color = addon.colors["DOT"]; |
else |
color = addon.colors["DEBUFF"]; |
end |
end |
-- PVP Duration? |
local duration = 1; |
local guid = strsub(dstGUID, 1 ,5); |
if (spell.pvpdur) and (bit.band(guid, 0x00F) == 0) then -- Player? |
duration = spell.pvpdur; |
else |
duration = spell.duration; |
end |
-- DR? only on target. |
if (dstGUID == UnitGUID("target")) and (spell.drcat) and (NaturDB.Diminishing) then |
addon:ApplyDiminish(spell.id, dstName, dstGUID); |
duration = duration * addon.factor; |
end |
-- Combo? |
if (spell.combo) then CPAura = true; end |
local text = spell.name .. " - " .. addon:StripName(dstName); |
addon.group:RegisterBar(dstGUID..spell.id, text, duration, nil, spell.icon, color.r, color.g, color.b); |
end |
end |
end); |
---------------------------------------------------------------------------------------------------- |
-- Deal with cooldowns and instant casts |
-- Add cooldown to the CDTable so we can remove/show on target change |
addon:StartParsing("SPELL_CAST_SUCCESS", function(when,what,srcGUID,srcName,srcFlags,dstGUID,dstName,dstFlags,...) |
local spell = addon:GetSpellData(...); |
--Quick fix for refreshing spells until 2.4.3 SPELL_AURA_REFRESH |
if (spell) and (spell.duration) then |
if (dstGUID == UnitGUID("target") or dstGUID == UnitGUID("focus")) and (dstGUID ~= UnitGUID("player")) then |
addon.group:SetTime(dstGUID..spell.id, spell.duration); |
end |
end |
----------- |
if (spell.special) and (srcGUID == UnitGUID("player")) then -- show this even tho the player casted it. |
local color = addon.colors["FRIENDLYBUFF"]; |
local text = spell.name .. " - " .. srcName; |
addon.group:RegisterBar(srcGUID..spell.id, text, spell.duration, nil, spell.icon, color.r, color.g, color.b); |
end |
if (srcGUID == UnitGUID("player")) then return; end |
if (srcGUID == UnitGUID("target")) then --We don't want to show cooldowns for our focus.. maybe change this if someone requests it. |
if (spell) and (spell.cooldown) then |
if (spell.type == "CAST") and (spell.instant) then |
if (spell.duration) then |
local color; |
if (CombatLog_Object_IsA(srcFlags, COMBATLOG_FILTER_HOSTILE_PLAYERS)) then |
color = addon.colors["HOSTILEBUFF"]; |
elseif (CombatLog_Object_IsA(srcFlags, COMBATLOG_FILTER_FRIENDLY_UNITS)) then |
color = addon.colors["FRIENDLYBUFF"]; |
end |
local text = spell.name .. " - " .. addon:StripName(srcName); |
addon.group:RegisterBar(srcGUID..spell.id, text, spell.duration, nil, spell.icon, color.r, color.g, color.b); |
end |
if (NaturDB.Cooldowns) then |
local color = addon.colors["COOLDOWN"]; |
local text = spell.name .. " [CD] - " .. addon:StripName(srcName); |
addon.group:RegisterBar(srcGUID..spell.id.."CD", text, spell.cooldown, nil, spell.icon, color.r, color.g, color.b); |
--Add to CDTable |
CDTable[srcGUID..spell.id.."CD"] = {srcGUID,spell.cooldown}; |
end |
elseif (spell.type == "BUFF") then |
if (NaturDB.Cooldowns) then |
local color = addon.colors["COOLDOWN"]; |
local text = spell.name .. " [CD] - " .. addon:StripName(srcName); |
addon.group:RegisterBar(srcGUID..spell.id.."CD", text, spell.cooldown, nil, spell.icon, color.r, color.g, color.b); |
-- Add to DB |
CDTable[srcGUID..spell.id.."CD"] = {srcGUID,spell.cooldown}; |
end |
end |
end |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("SPELL_AURA_REMOVED", function(when,what,srcGUID,srcName,srcFlags,dstGUID,dstName,dstFlags,...) |
local spell = addon:GetSpellData(...); |
if (spell) and (spell.duration) then |
if (spell.combo) then CPAura = false; end |
if (spell.drcat) then |
addon:RemoveDiminish(spell.id, dstName, dstGUID); |
end |
addon.group:UnregisterBar(dstGUID..spell.id); |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("SPELL_AURA_DISPELLED", function(when,what,srcGUID,srcName,srcFlags,dstGUID,dstName,dstFlags,...) |
local spell = addon:GetSpellData(select(12, ...)); |
if (spell) and (spell.duration) then |
addon.group:UnregisterBar(dstGUID..spell.id); |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("SPELL_INTERRUPT", function(when,what,srcGUID,srcName,srcFlags,dstGUID,dstName,dstFlags,...) |
local spell = addon:GetSpellData(select(12, ...)); |
if (spell) and (spell.duration) then |
addon.group:UnregisterBar(dstGUID..spell.id); |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("SPELL_MISSED", function(when,what,srcGUID,srcName,srcFlags,dstGUID,dstName,dstFlags,...) |
local spell = addon:GetSpellData(...); |
if (spell) and (spell.duration) then |
addon.group:UnregisterBar(dstGUID..spell.id); |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("SPELL_AURA_APPLIED_DOSE", function(when,what,srcGUID,srcName,srcFlags,dstGUID,dstName,dstFlags,...) |
local spell = addon:GetSpellData(...); |
local stack = select(5, ...); |
if (dstGUID == UnitGUID("player")) then return; end |
if (dstGUID == UnitGUID("target")) or (dstGUID == UnitGUID("focus")) then |
if (spell) and (spell.stacks) and (spell.duration) then |
local text = "(" .. stack .. ") " .. spell.name .. " - " .. addon:StripName(dstName); |
addon.group:SetBarText(dstGUID..spell.id, text); |
addon.group:SetTime(dstGUID..spell.id, spell.duration); |
end |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("SPELL_AURA_REMOVED_DOSE", function(when,what,srcGUID,srcName,srcFlags,dstGUID,dstName,dstFlags,...) |
local spell = addon:GetSpellData(...); |
local stack = select(5, ...); |
if (dstGUID == UnitGUID("player")) then return; end |
if (dstGUID == UnitGUID("target")) or (dstGUID == UnitGUID("focus")) then |
if (spell) and (spell.stacks) and (spell.duration) then |
local text = "(" .. stack .. ") " .. spell.name .. " - " .. addon:StripName(dstName); |
addon.group:SetBarText(dstGUID..spell.id, text); |
end |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("UNIT_DIED", function(when,what,srcGUID,srcName,srcFlags,dstGUID,dstName,dstFlags,...) |
if (dstGUID == UnitGUID("player")) then return; end |
for k, v in pairs(addon.spelldata) do |
addon.group:UnregisterBar(dstGUID..k); |
addon.group:UnregisterBar(dstGUID..k.."CD"); |
if (addon.spelldata[k].drcat) then |
addon.group:UnregisterBar(dstGUID..addon.spelldata[k].drcat); |
end |
CDTable[dstGUID..k.."CD"] = nil; |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("UNIT_SPELLCAST_START", function(unitid, spell, ...) |
if (UnitGUID(unitid) == UnitGUID("player")) then return; end |
if (unitid == "target" and spell) or (unitid == "focus" and spell) then |
local color; |
if (UnitReaction(unitid, "player") < 4) then -- Hostile |
color = addon.colors["HOSTILECAST"]; |
else |
color = addon.colors["FRIENDLYCAST"]; |
end |
local icon, sTime, eTime = select(4, UnitCastingInfo(unitid)); |
local text = spell .. " - " .. addon:StripName(UnitName(unitid)); |
sTime, eTime = sTime/1000, eTime/1000; |
addon.group:RegisterBar(UnitGUID(unitid).."cast", text, eTime - sTime, nil, icon, color.r, color.g, color.b); |
end |
end); |
addon:StartParsing("UNIT_SPELLCAST_STOP", function(unitid, ...) -- This is suppose to return the spellname yet fails to do so.. |
if (UnitGUID(unitid) == UnitGUID("player")) then return; end |
if (unitid == "target") or (unitid == "focus") then |
addon.group:UnregisterBar(UnitGUID(unitid).."cast"); |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("UNIT_SPELLCAST_CHANNEL_START", function(unitid, spell, ...) |
if (UnitGUID(unitid) == UnitGUID("player")) then return; end |
if (unitid == "target" and spell) or (unitid == "focus" and spell) then |
local color; |
if (UnitReaction(unitid, "player") < 4) then -- Hostile |
color = addon.colors["HOSTILECAST"]; |
else |
color = addon.colors["FRIENDLYCAST"]; |
end |
local icon, sTime, eTime = select(4, UnitChannelInfo(unitid)); |
local text = spell .. " - " .. addon:StripName(UnitName(unitid)); |
sTime, eTime = sTime/1000, eTime/1000; |
addon.group:RegisterBar(UnitGUID(unitid).."channel", text, eTime - sTime, nil, icon, color.r, color.g, color.b); |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("UNIT_SPELLCAST_CHANNEL_STOP", function(unitid, spell, ...) |
if (UnitGUID(unitid) == UnitGUID("player")) then return; end |
if (unitid == "target") or (unitid == "focus") then |
addon.group:UnregisterBar(UnitGUID(unitid).."channel"); |
end |
end); |
---------------------------------------------------------------------------------------------------- |
-- NOTE: There has to be a better way to deal with combo point abilites :/ |
addon:StartParsing("UNIT_AURA", function(unitid) |
if (UnitGUID(unitid) == UnitGUID("player")) then return; end |
if (unitid == "target") or (unitid == "focus") then |
local name, duration; |
if (not CPAura) then return; end |
local id = 0; |
while (true) do |
id = id + 1; |
name, _, _, _, _, duration = UnitDebuff(unitid, id); |
if (not name) then break; end |
if (addon.spellkeys[name]) then |
if (addon.spelldata[addon.spellkeys[name]].combo) and (addon.spelldata[addon.spellkeys[name]].duration) then |
local text = name .. " - " .. addon:StripName(UnitName(unitid)); |
if (not duration) then |
duration = addon.spelldata[addon.spellkeys[name]].duration; |
end |
addon.group:SetTime(UnitGUID(unitid)..addon.spelldata[addon.spellkeys[name]].id, duration); |
CPAura = false; |
end |
end |
end |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("PLAYER_TARGET_CHANGED", function() |
-- Remove CD's from old target |
for id, cooldown in pairs(CDTable) do |
if (UnitGUID("target") ~= cooldown[1]) then |
addon.group:HideBar(id); |
else |
addon.group:ShowBar(id, cooldown[2]); |
end |
end |
end); |
---------------------------------------------------------------------------------------------------- |
addon:StartParsing("PARTY_KILL", function(when,what,srcGUID,srcName,srcFlags,dstGUID,dstName,dstFlags,...) |
local guid = strsub(dstGUID, 1, 5); |
if (srcGUID == UnitGUID("player")) and (bit.band(guid, 0x00F) == 0) and (NaturDB.Sounds) then |
if (not KillTimer) or (GetTime() - KillTimer > 60) then |
PlaySoundFile(addon.media:Fetch("sound", "First Blood")); |
KillCounter = 0; |
elseif (GetTime() - KillTimer <= 60) then |
KillCounter = KillCounter + 1 |
if (KillCounter == 1) then |
PlaySoundFile(addon.media:Fetch("sound", "Dominating")); |
elseif (KillCounter == 2) then |
PlaySoundFile(addon.media:Fetch("sound", "Killing Spree")); |
elseif (KillCounter == 3) then |
PlaySoundFile(addon.media:Fetch("sound", "Unstoppable")); |
elseif (KillCounter == 4) then |
PlaySoundFile(addon.media:Fetch("sound", "Monster Kill")); |
elseif (KillCounter > 4) then |
PlaySoundFile(addon.media:Fetch("sound", "Godlike")); |
end |
end |
KillTimer = GetTime(); |
end |
end); |
---------------------------------------------------------------------------------------------------- |
-- TODO: Look over DR code and improve it. |
-- Massive thanks to Shadowd the author of DR Tracker. |
function addon:ApplyDiminish(spellID, dstName, dstGUID) |
local spell = addon:GetSpellData(spellID); |
local id = dstGUID .. spell.drcat; |
local time = GetTime(); |
local diminished = 100; |
if (expTime[id] and expTime[id] >= time) then |
diminished = self:GetDR(activeDR[id]); |
addon.factor = select(3, self:GetDR(activeDR[id])); |
activeDR[id] = diminished; |
expTime[id] = GetTime() + 15; |
addon.group:UnregisterBar(id); |
elseif (not expTime[id] or expTime[id] <= time) then |
activeDR[id] = diminished; |
addon.factor = 1; |
expTime[id] = GetTime() + 15; |
end |
end; |
---------------------------------------------------------------------------------------------------- |
function addon:RemoveDiminish(spellId, dstName, dstGUID) |
local spell = addon:GetSpellData(spellId); |
local id = dstGUID .. spell.drcat; |
if (activeDR[id]) then |
local text = spell.name .. " [".. spell.drcat .." |cffff2020DR " .. select(2,addon:GetDR(activeDR[id])) .. "/3|r] - " .. addon:StripName(dstName); |
local color = addon.colors["COOLDOWN"]; |
addon.group:RegisterBar(id, text, 15, nil, spell.icon, color.r, color.g, color.b); |
end |
expTime[id] = GetTime() + 15; |
end; |
---------------------------------------------------------------------------------------------------- |
function addon:GetDR(dr) |
if (dr == 100) then |
return 50, 1, 0.5; |
elseif (dr == 50) then |
return 25, 2, 0.25; |
elseif (dr == 25) then |
return 0, "Immune! 3", 0; |
end |
end; |
---------------------------------------------------------------------------------------------------- |
function addon:OnFade(barid) |
if (CDTable[barid]) then |
CDTable[barid] = nil; |
end |
end; |
local addon = LibStub:NewLibrary("NaturCombat",20080514); |
assert(addon,"NaturCombatTimers failed to load in 'NaturCombatTimers\addon\spells.lua' on line 1"); |
local addon = LibStub:NewLibrary("NaturCombat", 20080716); |
---------------------------------------------------------------------------------------------------- |
addon.spelldata = {}; -- lookup table used for data storage, stored by spellid |
addon.spellkeys = {}; -- lookup table used for spell names that default to a spellid |
addon.spellmeta = {}; |
addon.spellmeta.__newindex = function(tbl,key,value) |
addon.spelldata = {}; -- Lookup table for data, stored by spellid |
addon.spellkeys = {}; -- Lookup table for spell names that default to a spellid |
addon.spellmeta = {}; -- Metatable |
addon.spellmeta.__newindex = function(tbl, key, value) |
local name = GetSpellInfo(key); |
if (not addon.spelldata[key]) then addon.spelldata[key] = value; end |
if (not addon.spellkeys[name]) then addon.spellkeys[name] = key; end |
end; |
addon.spellmeta.__index = function(tbl,key) |
local name,rank,icon,_,_,_,castTime = GetSpellInfo(key); |
addon.spellmeta.__index = function(tbl, key) |
local name, rank, icon, _, _, _, castTime = GetSpellInfo(key); |
if (not addon.spelldata[key]) then key = addon.spellkeys[name]; end |
local data = addon.spelldata[key] or {}; |
data.id, data.name, data.rank, data.icon, data.castTime = key, name, rank, icon, castTime/1000; |
data.id, data.name, data.rank, data.icon, data.castTime = key, name, rank, icon, castTime / 1000; |
return data; |
end; |
addon.spells = setmetatable({},addon.spellmeta); |
local spells = setmetatable({}, addon.spellmeta); |
function addon:GetSpellData(id) |
if (id) then return addon.spells[id]; end |
end; |
if (id) then return spells[id]; end |
end |
---------------------------------------------------------------------------------------------------- |
-- RACIALS |
addon.spells[20600] = {duration=20,cooldown=180,type="BUFF"}; -- Perception |
addon.spells[7744] = {duration=5,cooldown=120,type="BUFF"}; -- Will of the Forsaken |
addon.spells[20594] = {duration=8,cooldown=180,type="BUFF"}; -- Stoneform |
addon.spells[26297] = {duration=10,cooldown=180,type="BUFF"}; -- Berseking |
addon.spells[28880] = {duration=15,cooldown=180,type="BUFF"}; -- Gift of the Naaru |
addon.spells[20549] = {duration=2,type="DEBUFF"}; -- War Stomp |
addon.spells[25467] = {duration=24,dot=true,type="DEBUFF"}; -- Devouring Plague |
addon.spells[25446] = {duration=15,dot=true,type="DEBUFF"}; -- Starshards |
-- Misc. |
addon.spells[5530] = {duration=3,stun=true,type="DEBUFF"}; -- Mace Stun |
local addon = LibStub:GetLibrary("NaturCombat"); |
assert(addon,"NaturCombat failed to load in 'NaturCombat\addon\generator.lua' on line 1"); |
addon.bar = LibStub:GetLibrary("GTB-1.0"); |
assert(addon.bar,"GTB-1.0 failed to load in 'NaturCombat\addon\generator.lua' on line 3"); |
addon.media = LibStub:GetLibrary("LibSharedMedia-3.0"); |
assert(addon.media, "LibSharedMedia-3.0 failed to load in 'NaturCombat\addon\generator.lua' on line 5"); |
local addon = LibStub("NaturCombat"); -- Our Library |
addon.bar = LibStub("NaturGTB"); -- Bar Library |
addon.media = LibStub("LibSharedMedia-3.0"); -- Textures/Icons |
---------------------------------------------------------------------------------------------------- |
addon.colors = {}; |
addon.colors["HOSTILECAST"] = {r = 1, g = 0, b = 0}; |
addon.colors["FRIENDLYCAST"] = {r = 0, g= 1, b = 0}; |
addon.colors["COOLDOWN"] = {r = 0, g = 0, b = 1}; |
addon.colors["HOSTILEBUFF"] = {r = 0.5, g = 0, b = 0.65}; |
addon.colors["FRIENDLYBUFF"] = {r = 1, g = 0, b = 1}; |
addon.colors["STUN"] = {r = 0.5, g = 0.2, b = 0.1}; |
addon.colors["DOT"] = {r = 0, g = 0.8, b = 0.8}; |
addon.colors["DEBUFF"] = {r = 0.8, g = 0.8, b = 0}; |
addon.colors["GREY"] = { r = 0.8, g = 0.8, b = 0.8}; |
-- DEFAULT VARIABLES |
---------------------------------------------------------------------------------------------------- |
addon.default = { Version=GetAddOnMetadata("NaturCombat", "Version"), Height=20, Width=270, Scale=1, FontSize=15, MaxBars=10, Lock=true, Icon=true, |
Growth="UP", Invert=true, Texture="NaturGlaze", Vertical=0, Cooldowns=true, Diminish=true, Sounds=true, Groups=false, Track=false, TargetFocus=true, Casting=true, |
Colors = { |
["HOSTILECAST"] = {r = 1, g = 0, b = 0}, |
["FRIENDLYCAST"] = {r = 0, g= 1, b = 0}, |
["COOLDOWN"] = {r = 0, g = 0, b = 1}, |
["HOSTILEBUFF"] = {r = 0.5, g = 0, b = 0.65}, |
["FRIENDLYBUFF"] = {r = 1, g = 0, b = 1}, |
["STUN"] = {r = 0.5, g = 0.2, b = 0.1}, |
["DOT"] = {r = 0, g = 0.8, b = 0.8}, |
["DEBUFF"] = {r = 0.8, g = 0.8, b = 0}, |
["GREY"] = { r = 0.8, g = 0.8, b = 0.8}, |
},}; |
NaturDB = NaturDB or addon.default; |
addon.killcounter, addon.killtimer, addon.timers = 0, nil, {}; |
---------------------------------------------------------------------------------------------------- |
-- BAR GROUPS |
---------------------------------------------------------------------------------------------------- |
addon.bargroups = { |
["COOLDOWNS"] = "Cooldowns"; |
["DEBUFFS"] = "Debuffs"; |
["HOSTILEGAIN"] = "Hostile Gains"; |
["FRIENDLYGAIN"] = "Friendly Gains"; |
["HOSTILECAST"] = "Hostile Casts"; |
["FRIENDLYCAST"] = "Friendly Casts"; |
}; |
addon.groups = {}; -- Table for bar anchors |
addon.CDTable = {}; -- Table for cooldowns |
---------------------------------------------------------------------------------------------------- |
-- REGISTER MEDIA FILES |
---------------------------------------------------------------------------------------------------- |
addon.media:Register("statusbar", "NaturGlaze", [[Interface\AddOns\NaturCombat\media\glaze]]); |
addon.media:Register("icon", "Target", [[Interface\AddOns\NaturCombat\media\Target]]); |
addon.media:Register("icon", "Focus", [[Interface\AddOns\NaturCombat\media\Focus]]); |
---------------------------------------------------------------------------------------------------- |
addon.media:Register("sound", "First Blood", [[Interface\AddOns\NaturCombat\media\sounds\firstblood.mp3]]); |
addon.media:Register("sound", "Dominating", [[Interface\AddOns\NaturCombat\media\sounds\dominating.mp3]]); |
addon.media:Register("sound", "Monster Kill", [[Interface\AddOns\NaturCombat\media\sounds\monsterkill.mp3]]); |
addon.media:Register("sound", "Godlike", [[Interface\AddOns\NaturCombat\media\sounds\godlike.mp3]]); |
---------------------------------------------------------------------------------------------------- |
-- This is to deal with realm names from cross realm battlegroups |
function addon:StripName(name) |
name = string.match(name, "[^-]*"); |
return name; |
end |
-- FUNCTIONS |
---------------------------------------------------------------------------------------------------- |
local f = CreateFrame("Frame", nil, InterfaceOptionsFrame) |
function addon:StripName(str) |
return string.match(str, "[^-]*"); |
end; |
---------------------------------------------------------------------------------------------------- |
function addon:CreateBarGroup(name) |
local group = addon.bar:RegisterGroup(name, addon.media:Fetch("statusbar", NaturDB.Texture)); |
group:SetScale(NaturDB.Scale); |
group:SetWidth(NaturDB.Width); |
group:SetHeight(NaturDB.Height); |
group:SetAnchorVisible(NaturDB.Lock); |
group:SetMaxBars(NaturDB.MaxBars); |
group:SetBarGrowth(NaturDB.Growth); |
group:SetInvert(NaturDB.Invert); |
group:SetVerticalSpacing(NaturDB.Vertical); |
group:SetPoint("CENTER"); |
group:RegisterOnFade(addon, "OnFade"); |
return group; |
end; |
---------------------------------------------------------------------------------------------------- |
function addon:OnFade(barID) |
if (addon.CDTable[barID]) then |
addon.CDTable[barID] = nil; |
end |
end; |
---------------------------------------------------------------------------------------------------- |
function addon:GetColor(type) -- USED BY OPTIONS |
if (not NaturDB.Colors[type]) then return; end |
return NaturDB.Colors[type].r, NaturDB.Colors[type].g, NaturDB.Colors[type].b; |
end; |
---------------------------------------------------------------------------------------------------- |
function addon:SetColor(type, ...) -- USED BY OPTIONS |
if (not NaturDB.Colors[type]) then return; end |
NaturDB.Colors[type] = {r = select(1, ...), g = select(2, ...), b = select(3, ...)}; |
end; |
---------------------------------------------------------------------------------------------------- |
-- OPTIONS SLASH COMMAND |
-- /necb, /natur, /nct |
---------------------------------------------------------------------------------------------------- |
local f = CreateFrame("Frame", nil, InterfaceOptionsMenu); |
f:SetScript("OnShow", function(self) LoadAddOn("NaturOptions"); self:SetScript("OnShow", nil) end); |
SlashCmdList["NaturCombat"] = function() |
SlashCmdList["NaturCombat"] = function(cmd) |
if (LoadAddOn("NaturOptions")) then |
InterfaceOptionsFrame_OpenToFrame("NaturCombat"); |
end |
end; |
SLASH_NaturCombat1 = "/necb"; |
SLASH_NaturCombat2 = "/natur"; |
watcher:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP"); |
watcher:RegisterEvent("UNIT_AURA"); |
watcher:RegisterEvent("PLAYER_TARGET_CHANGED"); |
watcher:RegisterEvent("PLAYER_FOCUS_CHANGED"); |
-- |
wombat.parser = wombat.parser or {}; |
local CleanParser = function() |
local major = "GTB-1.0" |
local major = "NaturGTB" |
local minor = tonumber(string.match("$Revision: 752 $", "(%d+)") or 1) |
assert(LibStub, string.format("%s requires LibStub.", major)) |
["MUST_CALL"] = "You must call '%s' from a registered GTB object.", |
["GROUP_EXISTS"] = "The group '%s' already exists.", |
["BAD_FUNC"] = "You must pass an actual handler and function to '%s'.", |
["ALT_DRAG"] = "ALT + Drag to move the frame anchor.", |
["ALT_DRAG"] = "Drag to move the frame anchor.", |
} |
-- Validation for passed arguments |
local framePool = GTB.framePool |
local groups = GTB.groups |
local methods = {"RegisterOnMove", "SetAnchorVisible", "GetReversed", "GetGrowth", "GetMaxBars", "GetScale", "GetFontSize", "GetWidth", "GetHeight", "SetMaxBars", "SetBaseColor", "EnableGradient", "SetPoint", "SetScale", "SetWidth", "SetHeight", "SetTexture", "SetBarGrowth", "SetIconPosition", "SetTextColor", "HideBar", "ShowBar", "SortBars", |
"SetTimerColor", "SetFadeTime", "RegisterOnFade", "RegisterOnClick", "SetGroupFontSize", "SetInvert", "SetDisplayGroup", "GetDisplayGroup", "RegisterBar", "UnregisterBar", "SetRepeatingTimer", "UnregisterAllBars", "SetBarIcon", "SetTime", "SetBarText"} |
local methods = {"RegisterOnMove", "SetAnchorVisible", "SetAlpha", "GetAlpha", "SetFlashTime", "GetFlashTime", "GetReversed", "GetGrowth", "GetMaxBars", "GetScale", "GetFontSize", "GetWidth", "GetHeight", "SetMaxBars", "SetBaseColor", "EnableGradient", "SetPoint", "SetScale", "SetWidth", "SetHeight", "SetTexture", "SetBarGrowth", "SetIconPosition", "SetTextColor", "HideBar", "ShowBar", "SortBars", |
"SetTimerColor", "SetFadeTime", "RegisterOnFade", "RegisterOnClick", "GetVertical", "SetVerticalSpacing", "SetGroupFontSize", "SetInvert", "SetDisplayGroup", "GetDisplayGroup", "RegisterBar", "UnregisterBar", "SetRepeatingTimer", "UnregisterAllBars", "SetBarIcon", "SetTime", "SetBarText"} |
-- Internal functions for managing bars |
local function getFrame() |
-- Create icon |
frame.icon = frame:CreateTexture(nil, "ARTWORK") |
-- Create Focus/Target Icon |
frame.ticon = frame:CreateTexture(nil, "ARTWORK") |
-- Sparky |
frame.spark = frame:CreateTexture(nil, "OVERLAY") |
frame.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark") |
end |
end |
-- Fadeout OnUpdate |
local function fadeOnUpdate(self, elapsed) |
local time = GetTime() |
-- Reposition the group |
-- edited for NaturCombat |
local function sortBars(a, b) |
local group = groups["NaturCombat"] |
for id, bar in pairs(group.bars) do |
if (not bar:IsShown()) then -- this specific bar exists.. but it's hidden |
return false |
else |
return a.endTime < b.endTime |
end |
end |
return a.endTime < b.endTime |
end |
local function repositionFrames(group) |
if( i > 1 ) then |
if( group.barGrowth == "DOWN" ) then |
bar:SetPoint("TOPLEFT", group.usedBars[i - 1], "BOTTOMLEFT", 0, 0) |
bar:SetPoint("TOPLEFT", group.usedBars[i - 1], "BOTTOMLEFT", 0, group.vertical) |
else |
bar:SetPoint("BOTTOMLEFT", group.usedBars[i - 1], "TOPLEFT", 0, 0) |
bar:SetPoint("BOTTOMLEFT", group.usedBars[i - 1], "TOPLEFT", 0, group.vertical) |
end |
elseif( group.barGrowth == "UP" ) then |
bar:SetPoint("BOTTOMLEFT", group.frame, "TOPLEFT", offset, 0) |
fadeoutBar(self) |
return |
end |
--flashTime = 5 |
self:SetAlpha(NaturDB.Alpha) |
-- Timer text, need to see if this can be optimized a bit later |
local hour = floor(self.secondsLeft / 3600) |
local minutes = self.secondsLeft - (hour * 3600) |
-- Dragging functions |
local function OnDragStart(self) |
if( IsAltKeyDown() ) then |
self.isMoving = true |
self:StartMoving() |
end |
self.isMoving = true |
self:StartMoving() |
end |
local function OnDragStop(self) |
GameTooltip:Hide() |
end |
function GTB:UnregisterAllBarGroups() |
for a, _ in pairs(groups) do |
groups[a] = nil; |
end |
end |
function GTB:UnregisterGroup(name) |
if groups[name] then |
groups[name] = nil; |
end |
end |
function GTB:RegisterGroup(name, texture) |
argcheck(name, 1, "string") |
argcheck(texture, 2, "string") |
assert(3, not groups[name], string.format(L["GROUP_EXISTS"], name)) |
local obj = {name = name, frame = CreateFrame("Frame", name, UIParent), fontSize = 11, height = 16, obj = obj, bars = {}, usedBars = {}, reversed = false} |
local obj = {name = name, frame = CreateFrame("Frame", name, UIParent), fontSize = 11, height = 16, obj = obj, bars = {}, usedBars = {}, vertical = 0} |
-- Inject our methods |
for _, func in pairs(methods) do |
obj:SetScale(1.0) |
obj:SetWidth(200) |
obj:SetFadeTime(0.25) |
--obj:SetFlashTime(5) |
obj:SetMaxBars(20) |
obj:EnableGradient(true) |
obj:SetAnchorVisible(true) |
--Edit the timer value of a bar |
function GTB.SetTime(group, id, value) |
if( group.redirectTo and groups[group.redirectTo] ) then |
group = groups[group.redirectTo] |
end |
if not group.bars[id] then return end |
group.bars[id].timer:SetText(value) |
group.bars[id].secondsLeft = value |
-- Edit the text on an active bar |
local origBarID = {} |
function GTB.SetBarText(group, id, text) |
if( group.redirectTo and groups[group.redirectTo] ) then |
group = groups[group.redirectTo] |
end |
if not group.bars[id] then return end |
group.bars[id].text:SetText(text) |
group.bars[id].barText = text |
end |
function GTB.HideBar(group, id) |
if( group.redirectTo and groups[group.redirectTo] ) then |
group = groups[group.redirectTo] |
end |
if not group.bars[id] then return end |
--Keep record of this timer |
origBarID[id] = {update=group.bars[id].lastUpdate,text=group.bars[id].barText,timer=group.bars[id].secondsLeft,icon=group.bars[id].iconPath,color={r=group.bars[id].r,g=group.bars[id].g,b=group.bars[id].b}} |
origBarID[id] = {update=group.bars[id].lastUpdate,text=group.bars[id].barText,timer=group.bars[id].secondsLeft,icon=group.bars[id].iconPath,ticon=group.bars[id].ticonPath,color={r=group.bars[id].r,g=group.bars[id].g,b=group.bars[id].b}} |
GTB.UnregisterBar(group, id) |
end |
function GTB.ShowBar(group, id, timer) |
if( group.redirectTo and groups[group.redirectTo] ) then |
group = groups[group.redirectTo] |
end |
if not origBarID[id] then return end |
local time = origBarID[id].timer - (GetTime() - origBarID[id].update) |
-- group, id, text, 60, 54, icon, r, g, b |
GTB.RegisterBar(group, id, origBarID[id].text, time, timer, origBarID[id].icon, origBarID[id].color.r, origBarID[id].color.g, origBarID[id].color.b) |
GTB.RegisterBar(group, id, origBarID[id].text, time, timer, origBarID[id].icon, origBarID[id].ticon, origBarID[id].color.r, origBarID[id].color.g, origBarID[id].color.b) |
end |
function GTB.SetInvert(group, value) |
if( group.redirectTo and groups[group.redirectTo] ) then |
group = groups[group.redirectTo] |
end |
group.reversed = value |
end |
function GTB.GetReversed(group) |
function GTB.GetScale(group) |
return group.scale |
end |
function GTB.GetFontSize(group) |
return group.fontSize |
end |
function GTB.GetMaxBars(group) |
return group.maxBars |
end |
function GTB.GetGrowth(group) |
return group.barGrowth |
end |
function GTB.SetVerticalSpacing(group, val) |
if( group.redirectTo and groups[group.redirectTo] ) then |
group = groups[group.redirectTo] |
end |
group.vertical = val |
end |
function GTB.GetVertical(group) |
return group.vertical |
end |
function GTB.SetAlpha(group, val) |
if( group.redirectTo and groups[group.redirectTo] ) then |
group = groups[group.redirectTo] |
end |
for k, v in pairs(group.bars) do |
group.bars[k]:SetAlpha(val); |
end |
end |
-- Change the font size of the group |
function GTB.SetGroupFontSize(group, size) |
if( group.redirectTo and groups[group.redirectTo] ) then |
group = groups[group.redirectTo] |
end |
group.fontSize = size |
end |
group.fadeTime = seconds |
end |
-- When should we start flashing the bar |
function GTB.SetFlashTime(group, seconds) |
argcheck(seconds, 2, "number") |
assert(3, group.name and groups[group.name], string.format(L["MUST_CALL"], "SetFadeTime")) |
group.flasherTime = seconds |
end |
function GTB.GetFlashTime(group) |
return group.flasherTime |
end |
-- Redirect everything to the specified group |
function GTB.SetDisplayGroup(group, name) |
argcheck(name, 2, "string", "nil") |
-------------------- |
-- Register |
function GTB.RegisterBar(group, id, text, seconds, startSeconds, icon, r, g, b) |
function GTB.RegisterBar(group, id, text, seconds, startSeconds, icon, ticon, r, g, b) |
argcheck(id, 2, "string", "number") |
argcheck(text, 3, "string") |
argcheck(seconds, 4, "number") |
argcheck(icon, 5, "string", "nil") |
argcheck(r, 6, "number", "nil") |
argcheck(g, 7, "number", "nil") |
argcheck(b, 8, "number", "nil") |
argcheck(icon, 5, "string", "number", "nil") |
argcheck(ticon, 6, "string", "nil") |
argcheck(r, 7, "number", "nil") |
argcheck(g, 8, "number", "nil") |
argcheck(b, 9, "number", "nil") |
assert(3, group.name and groups[group.name], string.format(L["MUST_CALL"], "RegisterBar")) |
local originalOwner = group.name |
-- Update icon |
if( icon ) then |
if (type(icon) == "number") then |
icon = select(3, GetSpellInfo(icon)); |
end |
frame.icon:SetTexture(icon) |
if( frame.icon:GetTexture() ) then |
frame.icon:Hide() |
end |
-- Update Target/Focus Icon |
if ( ticon ~= type("string") ) then |
frame.ticon:SetTexture(ticon) |
if (frame.ticon:GetTexture()) then |
frame.ticon:SetWidth(group.height) |
frame.ticon:SetHeight(group.height) |
frame.ticon:SetTexCoord(0.07, 0.93, 0.07, 0.93) |
frame.ticon:SetPoint("TOPLEFT", frame, "TOPRIGHT", offset, 0) |
frame.ticon:Show() |
else |
frame.ticon:Hide() |
end |
end |
-- Set info the bar needs to know |
frame.r = r or group.baseColor.r |
frame.g = g or group.baseColor.g |
frame.gradients = group.gradients |
frame.groupName = group.name |
frame.iconPath = icon |
frame.ticonPath = ticon |
frame.barText = text |
frame.barID = id |
frame.group = group |
frame.reversed = group.reversed |
frame.vertical = group.vertical |
-- Setup background |
frame.bg:SetStatusBarTexture(group.texture) |
frame.bg:SetStatusBarColor(0.0, 0.5, 0.5, 0.5) |
-- Start it up |
frame:SetStatusBarTexture(group.texture) |
frame:SetStatusBarColor(frame.r, frame.g, frame.b) |
frame:SetStatusBarColor(r, g, b) |
frame:SetWidth(group.width) |
frame:SetHeight(group.height) |
frame:SetScale(group.scale) |
frame:SetScript("OnUpdate", barOnUpdate) |
--[[frame.button:SetScript("OnClick", function(self, button) |
frame.button:SetScript("OnClick", function(self, button) |
if (button == "RightButton") then |
-- delete bar |
GTB.UnregisterBar(group, id) |
end |
end)]] |
end) |
-- Reposition this group |
repositionFrames(group) |
## Interface: 20400 |
## Title: NaturCombat Options |
## Version: 9.0BETA2 |
## Version: 1.wowi:revision |
## Notes: Options for NaturCombat |
## Author: Macca, Beladona |
## LoadOnDemand: 1 |
function NaturOptions:OnLoad() |
self.name = "NaturCombat"; |
local bar = self:CreateBarPanel(); |
bar:SetPoint("TOPLEFT", 10, -60); |
local header = self:CreateHeader(self, "NaturCombat"); |
header:SetPoint("TOPLEFT", 16, -16); |
local general = self:CreateGeneralPanel(); |
general:SetPoint("BOTTOMLEFT", 10, 10); |
local tab1 = self:CreateTab("Tab1", self, "General", "General Options"); |
tab1:SetPoint("TOPLEFT", 10, -60); |
local tab2 = self:CreateTab("Tab2", self, "Bar", "Bar Options"); |
tab2:SetPoint("LEFT", tab1, "RIGHT", -15, 0); |
local tab1page = self:CreateGeneralPanel(tab1); |
tab1page:SetPoint("TOPLEFT", 5, -50); |
local tab2page = self:CreateBarPanel(tab2); |
tab2page:SetPoint("TOPLEFT", -58, -50); |
tab2page:Hide(); |
local colorp = self:CreateColorPanel(tab1); |
colorp:SetPoint("TOPLEFT", tab1page, "BOTTOMLEFT", 0, -20); |
local tab1spacer = self:CreateSpacer(270, self); |
tab1spacer:SetPoint("LEFT", tab2, "BOTTOMRIGHT", -10, 2); |
local tab2spacer = self:CreateSpacer(26, self); |
tab2spacer:SetPoint("LEFT", tab1, "BOTTOMRIGHT", -10, 2); |
local tab3spacer = self:CreateSpacer(35, self); |
tab3spacer:SetPoint("RIGHT", tab1, "BOTTOMLEFT", 12, 2); |
PanelTemplates_SetNumTabs(self, 2); |
PanelTemplates_SetTab(self, 1); |
tab1:SetScript("OnClick", function() |
PanelTemplates_SetTab(self, 1); |
tab1.spacer:Hide(); |
tab1page:Show(); |
tab2page:Hide(); |
colorp:Show(); |
tab2.spacer:Show(); |
end); |
tab2:SetScript("OnClick", function() |
PanelTemplates_SetTab(self, 2); |
tab2.spacer:Hide(); |
tab2page:Show(); |
tab1page:Hide(); |
colorp:Hide(); |
tab1.spacer:Show(); |
end); |
InterfaceOptions_AddCategory(self); |
end |
---------------------------------------------------------------------------------------------------- |
end |
---------------------------------------------------------------------------------------------------- |
-- Create options |
function NaturOptions:CreateGeneralPanel() |
local p = self:CreatePanel("General Options"); |
p:SetHeight(120); |
p:SetWidth(367); |
function NaturOptions:CreateGeneralPanel(parent) |
local p = self:CreatePanel("General Options", parent); |
p:SetHeight(170); |
p:SetWidth(357); |
-- Locked (CHECKBOX) |
local lock = self:CreateCheckBox("Locked", p, "Unlock/Lock the bars."); |
else |
NaturDB.Lock = true; |
end |
addon.group:SetAnchorVisible(NaturDB.Lock); |
for k, v in pairs(addon.groups) do |
if (NaturDB.Groups) then |
addon.groups[k]:SetAnchorVisible(NaturDB.Lock); |
addon.groups["NATUR"]:SetAnchorVisible(false); |
else |
addon.groups["NATUR"]:SetAnchorVisible(NaturDB.Lock); |
end |
end |
end); |
lock:SetPoint("TOPLEFT", 10, -8); |
-- Cooldowns (CHECKBOX) |
dr:SetPoint("LEFT", lock, "RIGHT", 100, 0); |
-- Test Bars (BUTTON) |
local test = self:CreateButton(p, "Test Bars", "Create 3 bars to test settings."); |
test:SetPoint("TOPLEFT", lock, "BOTTOMLEFT", 0, -40); |
test:SetPoint("TOPLEFT", lock, "BOTTOMLEFT", 0, -80); |
test:SetScript("OnClick", function(self) |
for i = 1, 3 do |
addon.group:RegisterBar("Testing"..i, "Testing NaturCombat Bar #"..i, 10, nil, "Interface\\Icons\\Spell_Holy_HolyProtection", 0, 1, 0); |
addon.groups["FRIENDLYCAST"]:RegisterBar("Testing"..i, "Testing NaturCombat Bar #"..i, 10, nil, "Interface\\Icons\\Spell_Holy_HolyProtection", nil, 0, 1, 0); |
end |
end); |
local sound = self:CreateCheckBox("Killing Blow Sounds", p, "Turn on/off sounds when you get a killing blow."); |
end |
end); |
sound:SetPoint("TOPLEFT", dr, "BOTTOMLEFT", 0, 0); |
local track = self:CreateCheckBox("Track only my abilites", p, "Show only your debuffs and buffs rather then everyones."); |
track:SetScript("OnShow", function(self) |
self:SetChecked(NaturDB.Track); |
end); |
track:SetScript("OnClick", function(self) |
if (self:GetChecked()) then |
NaturDB.Track = true; |
else |
NaturDB.Track = false; |
end |
end); |
track:SetPoint("TOPLEFT", sound, "BOTTOMLEFT", 0, 0); |
local focus = self:CreateCheckBox("Track all units.", p, "Track everyone in range of your Combat Log.\n|cffff2020WARING:|r This may be inaccurate and can display a lot of bars."); |
focus:SetScript("OnShow", function(self) |
self:SetChecked(not NaturDB.TargetFocus); |
end); |
focus:SetScript("OnClick", function(self) |
if (self:GetChecked()) then |
NaturDB.TargetFocus = false; |
else |
NaturDB.TargetFocus = true; |
end |
end); |
focus:SetPoint("TOPLEFT", track, "BOTTOMLEFT", 0, 0); |
local cast = self:CreateCheckBox("Enable Cast bars", p, "Enable/Disable cast bars"); |
cast:SetScript("OnShow", function(self) |
self:SetChecked(NaturDB.Casting); |
end); |
cast:SetScript("OnClick", function(self) |
if (self:GetChecked()) then |
NaturDB.Casting = true; |
else |
NaturDB.Casting = false; |
end |
end); |
cast:SetPoint("TOPLEFT", focus, "BOTTOMLEFT", 0, 0); |
local groups = self:CreateCheckBox("Separate Groups", p, "Show multiple bar groups or only one"); |
groups:SetScript("OnShow", function(self) |
self:SetChecked(NaturDB.Groups); |
end); |
groups:SetScript("OnClick", function(self) |
if (self:GetChecked()) then |
NaturDB.Groups = true; |
for k, v in pairs(addon.groups) do |
addon.groups[k]:SetDisplayGroup(nil); |
addon.groups[k]:SetAnchorVisible(true); |
end |
addon.groups["NATUR"]:SetAnchorVisible(false); |
NaturDB.Lock = true; |
lock:SetChecked(false); |
else |
for k, v in pairs(addon.groups) do |
addon.groups[k]:SetDisplayGroup("NaturCombat"); |
addon.groups[k]:SetAnchorVisible(false); |
end |
addon.groups["NATUR"]:SetAnchorVisible(true); |
NaturDB.Groups = false; |
NaturDB.Lock = true; |
lock:SetChecked(false); |
end |
end); |
groups:SetPoint("TOPLEFT", cd, "BOTTOMLEFT", 0, 0); |
return p; |
end |
---------------------------------------------------------------------------------------------------- |
function NaturOptions:CreateBarPanel() |
local p = self:CreatePanel("Bar Options"); |
p:SetWidth(367); |
p:SetHeight(200); |
----------------------------------------------------------------------------------------------------- |
function NaturOptions:CreateColorPanel(parent) |
local p = self:CreatePanel("Color Options", parent); |
p:SetWidth(250); |
p:SetHeight(100); |
local fc = self:CreateColorButton(p, "Friendly Cast", "FRIENDLYCAST"); |
fc:SetPoint("TOPLEFT", p, "TOPLEFT", 10, -8) |
local hc = self:CreateColorButton(p, "Hostile Cast", "HOSTILECAST"); |
hc:SetPoint("TOPLEFT", fc, "BOTTOMLEFT", 0, -3); |
local fg = self:CreateColorButton(p, "Friendly Gain", "FRIENDLYBUFF"); |
fg:SetPoint("TOPLEFT", hc, "BOTTOMLEFT", 0, -3); |
local hg = self:CreateColorButton(p, "Hostile Gain", "HOSTILEBUFF"); |
hg:SetPoint("TOPLEFT", fg, "BOTTOMLEFT", 0, -3); |
local st = self:CreateColorButton(p, "Stuns", "STUN"); |
st:SetPoint("LEFT", fc, "RIGHT", 90, 0); |
local dt = self:CreateColorButton(p, "DoTs", "DOT"); |
dt:SetPoint("TOPLEFT", st, "BOTTOMLEFT", 0, -3); |
local cd = self:CreateColorButton(p, "Cooldowns", "COOLDOWN"); |
cd:SetPoint("TOPLEFT", dt, "BOTTOMLEFT", 0, -3); |
local db = self:CreateColorButton(p, "Debuffs", "DEBUFF"); |
db:SetPoint("TOPLEFT", cd, "BOTTOMLEFT", 0, -3); |
local rd = self:CreateButton(p, "Reset", "Reset to default colors."); |
rd:SetPoint("LEFT", st, "RIGHT", 60, 0); |
rd:SetWidth(50); |
rd:SetHeight(20); |
rd:SetScript("OnClick", function(self) |
for a, b in pairs(NaturDB.Colors) do |
NaturDB.Colors[a] = addon.default.Colors[a]; |
fc:Hide(); fc:Show(); |
hc:Hide(); hc:Show(); |
fg:Hide(); fg:Show(); |
hg:Hide(); hg:Show(); |
cd:Hide(); cd:Show(); |
db:Hide(); db:Show(); |
st:Hide(); st:Show(); |
dt:Hide(); dt:Show(); |
end |
end); |
return p; |
end |
----------------------------------------------------------------------------------------------------- |
local colorSelectors, colorCopier; |
function NaturOptions:CreateColorButton(parent, name, type) |
local f = CreateFrame("Button", parent:GetName()..name, parent); |
f:SetWidth(16); |
f:SetHeight(16); |
f:SetNormalTexture("Interface\\ChatFrame\\ChatFrameColorSwatch"); |
f.type = type; |
local t = f:CreateFontString(nil, "BACKGROUND"); |
t:SetFontObject("GameFontHighlightSmall"); |
t:SetPoint("LEFT", f, "RIGHT", 7, 0); |
f.Text = t; |
local b = f:CreateTexture(nil, "BACKGROUND"); |
b:SetWidth(14); |
b:SetHeight(14); |
b:SetTexture(1, 1, 1); |
b:SetPoint("CENTER"); |
f.bg = b; |
f.SetColor = function(self, ...) self:GetNormalTexture():SetVertexColor(...); addon:SetColor(self.type, ...); end |
f.swatchFunc = function() f:SetColor(ColorPickerFrame:GetColorRGB()); end |
f.cancelFunc = function() f:SetColor(f.r, f.g, f.b); end |
f:SetScript("OnClick", function(self) |
if (ColorPickerFrame:IsShown()) then |
ColorPickerFrame:Hide(); |
else |
self.r, self.g, self.b = addon:GetColor(self.type); |
UIDropDownMenuButton_OpenColorPicker(self) |
ColorPickerFrame:SetFrameStrata("TOOLTIP"); |
ColorPickerFrame:Raise(); |
end |
end); |
f:SetScript("OnEnter", function(self) |
local c = NORMAL_FONT_COLOR |
self.bg:SetVertexColor(c.r, c.g, c.b); |
end); |
f:SetScript("OnLeave", function(self) |
local c = HIGHLIGHT_FONT_COLOR; |
self.bg:SetVertexColor(c.r, c.g, c.b); |
end); |
f:SetScript("OnShow", function(self) |
self.r, self.g, self.b = addon:GetColor(self.type); |
f:GetNormalTexture():SetVertexColor(self.r, self.g, self.b); |
f.Text:SetText(name); |
end); |
if colorSelectors then |
tinsert(colorSelectors, f); |
else |
colorSelectors = {f}; |
end |
return f; |
end |
----------------------------------------------------------------------------------------------------- |
function NaturOptions:CreateBarPanel(parent) |
local p = self:CreatePanel("Bar Options", parent); |
p:SetWidth(357); |
p:SetHeight(280); |
-- Header! |
local header = self:CreateHeader(self, "NaturCombat"); |
header:SetPoint("TOPLEFT", 16, -16); |
-- Height (SLIDER) |
local height = self:CreateSlider("Height", p, 0, 30, 1, "Change the height of the bars"); |
height:SetScript("OnShow", function(self) |
self.onShow = true; |
self:SetValue(addon.group:GetHeight()); |
self:SetValue(addon.groups["NATUR"]:GetHeight()); |
self.onShow = nil; |
end); |
height:SetScript("OnValueChanged", function(self, v) |
self.valText:SetText(format("%.1f", v)); |
if not self.onShow then |
addon.group:SetHeight(v); |
for k, b in pairs(addon.groups) do |
addon.groups[k]:SetHeight(v); |
end |
NaturDB.Height = v; |
end |
end); |
local width = self:CreateSlider("Width", p, 50, 300, 1, "Change the width of the bars"); |
width:SetScript("OnShow", function(self) |
self.onShow = true; |
self:SetValue(addon.group:GetWidth()); |
self:SetValue(addon.groups["NATUR"]:GetWidth()); |
self.onShow = nil; |
end); |
width:SetScript("OnValueChanged", function(self, v) |
self.valText:SetText(format("%.1f", v)); |
if not self.onShow then |
addon.group:SetWidth(v); |
for k, b in pairs(addon.groups) do |
addon.groups[k]:SetWidth(v); |
end |
NaturDB.Width = v; |
end |
end); |
width:SetPoint("TOPLEFT", height, "BOTTOMLEFT", 0, -20); |
local vert = self:CreateSlider("Vertical Spacing", p, 0, 20, 1, "Change the space between bars."); |
vert:SetScript("OnShow", function(self) |
self.onShow = true; |
self:SetValue(addon.groups["NATUR"]:GetVertical()); |
self.onShow = nil; |
end); |
vert:SetScript("OnValueChanged", function(self, v) |
self.valText:SetText(format("%.1f",v)); |
if not self.onShow then |
for k, b in pairs(addon.groups) do |
addon.groups[k]:SetVerticalSpacing(v); |
end |
NaturDB.Vertical = v; |
end |
end); |
vert:SetPoint("TOPLEFT", width, "BOTTOMLEFT", 0, -20); |
-- Scale (SLIDER) |
local scale = self:CreateSlider("Scale", p, 1, 5, 1, "Change the scale of the bars"); |
local scale = self:CreateSlider("Scale", p, 0.1, 5, 0.1, "Change the scale of the bars"); |
scale:SetScript("OnShow", function(self) |
self.onShow = true; |
self:SetValue(addon.group:GetScale()); |
self:SetValue(addon.groups["NATUR"]:GetScale()); |
self.onShow = nil; |
end); |
scale:SetScript("OnValueChanged", function(self, v) |
self.valText:SetText(format("%.1f",v)); |
if not self.onShow then |
addon.group:SetScale(v); |
for k, b in pairs(addon.groups) do |
addon.groups[k]:SetScale(v); |
end |
NaturDB.Scale = v; |
end |
end); |
local font = self:CreateSlider("Font Size", p, 1, 30, 1, "Change the font size on the bars"); |
font:SetScript("OnShow", function(self) |
self.onShow = true; |
self:SetValue(addon.group:GetFontSize()); |
self:SetValue(addon.groups["NATUR"]:GetFontSize()); |
self.onShow = nil; |
end); |
font:SetScript("OnValueChanged", function(self, v) |
self.valText:SetText(format("%.1f",v)); |
if not self.onShow then |
addon.group:SetGroupFontSize(v); |
for k, b in pairs(addon.groups) do |
addon.groups[k]:SetGroupFontSize(v); |
end |
NaturDB.FontSize = v; |
end |
end); |
local maxbars = self:CreateSlider("Max Bars", p, 1, 20, 1, "Change how many bars are shown at one time"); |
maxbars:SetScript("OnShow", function(self) |
self.onShow = true; |
self:SetValue(addon.group:GetMaxBars()); |
self:SetValue(addon.groups["NATUR"]:GetMaxBars()); |
self.onShow = nil; |
end); |
maxbars:SetScript("OnValueChanged", function(self, v) |
self.valText:SetText(format("%.1f",v)); |
if not self.onShow then |
addon.group:SetMaxBars(v); |
for k, b in pairs(addon.groups) do |
addon.groups[k]:SetMaxBars(v); |
end |
NaturDB.MaxBars = v; |
end |
end); |
maxbars:SetPoint("TOPLEFT", font, "BOTTOMLEFT", 0, -20); |
local alpha = self:CreateSlider("Alpha", p, 0, 1, 0.1, "Change the alpha of the bars"); |
alpha:SetScript("OnShow", function(self) |
self.onShow = true; |
self:SetValue(NaturDB.Alpha); |
self.onShow = nil; |
end); |
alpha:SetScript("OnValueChanged", function(self, v) |
self.valText:SetText(format("%.1f",v)); |
if not self.onShow then |
for k, b in pairs(addon.groups) do |
addon.groups[k]:SetAlpha(v); |
end |
NaturDB.Alpha = v; |
end |
end); |
alpha:SetPoint("TOPLEFT", maxbars, "BOTTOMLEFT", 0, -20); |
--Invert (CHECKBOX) |
local invert = self:CreateCheckBox("Invert", p, "Set the fill of the bar to be inverted"); |
invert:SetScript("OnShow", function(self) self:SetChecked(addon.group:GetReversed()); end); |
invert:SetScript("OnShow", function(self) self:SetChecked(addon.groups["NATUR"]:GetReversed()); end); |
invert:SetScript("OnClick", function(self) |
if (self:GetChecked()) then |
addon.group:SetInvert(true); |
for k,b in pairs(addon.groups) do |
addon.groups[k]:SetInvert(true); |
end |
NaturDB.Invert = true; |
else |
addon.group:SetInvert(false); |
for k,b in pairs(addon.groups) do |
addon.groups[k]:SetInvert(false); |
end |
NaturDB.Invert = false |
end |
end); |
invert:SetPoint("TOPLEFT", width, "BOTTOMLEFT", 0, -10); |
invert:SetPoint("TOPLEFT", vert, "BOTTOMLEFT", 0, -10); |
-- Growth (CHECKBOX) |
local growth = self:CreateCheckBox("Grow Up", p, "Set whether the bars grow up or down"); |
growth:SetScript("OnShow", function(self) self:SetChecked(addon.group:GetGrowth()); end); |
growth:SetScript("OnShow", function(self) |
local val = addon.groups["NATUR"]:GetGrowth(); |
if (val == "UP") then |
self:SetChecked(true); |
else |
self:SetChecked(false); |
end |
end); |
growth:SetScript("OnClick", function(self) |
local val = self:GetChecked(); |
local value; |
else |
value = "DOWN"; |
end |
addon.group:SetBarGrowth(value); |
for k, v in pairs(addon.groups) do |
addon.groups[k]:SetBarGrowth(value); |
end |
NaturDB.Growth = value; |
end); |
growth:SetPoint("TOPLEFT", invert, "BOTTOMLEFT", 0, 0); |
local icon = self:CreateCheckBox("Show Target/Focus Icons", p, "Set whether to show the target/focus icons."); |
icon:SetScript("OnShow", function(self) |
self:SetChecked(NaturDB.Icon); |
end); |
icon:SetScript("OnClick", function(self) |
local v = self:GetChecked(); |
if (v == 1) then |
NaturDB.Icon = true; |
else |
NaturDB.Icon = false; |
end |
end); |
icon:SetPoint("TOPLEFT", growth, "BOTTOMLEFT", 0, 0); |
-- Texture (DROPDOWN) --yuck |
local texture = self:CreateDropDown("Texture", p); |
texture:SetPoint("TOPLEFT", maxbars, "BOTTOMLEFT", 0, -40); |
local texture = self:CreateTextureDropDown("Texture", p); |
texture:SetPoint("TOPLEFT", maxbars, "BOTTOMLEFT", -10, -60); |
return p; |
end |
---------------------------------------------------------------------------------------------------- |
---------------------------------------------------------------------------------------------------- |
function NaturOptions:CreateButton(panel, name, tiptext) |
local f = CreateFrame("Button", panel:GetName().."Buttons", panel, "UIPanelButtonTemplate"); |
local f = CreateFrame("Button", panel:GetName()..name, panel, "UIPanelButtonTemplate"); |
f:SetHeight(30); |
f:SetWidth(100); |
getglobal(panel:GetName().."Buttons".."Text"):SetText(name); |
getglobal(panel:GetName()..name.."Text"):SetText(name); |
f:SetScript("OnEnter", ShowTooltip); |
f:SetScript("OnLeave", HideTooltip); |
f.tiptext = tiptext; |
return b; |
end |
---------------------------------------------------------------------------------------------------- |
function NaturOptions:CreateDropDown(name, panel) |
function NaturOptions:CreateTextureDropDown(name, panel) |
local f = CreateFrame("Frame", panel:GetName()..name, panel, "UIDropDownMenuTemplate"); |
local t = f:CreateFontString(nil, "BACKGROUND"); |
t:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 21, 0); |
getglobal(self:GetName().."Text"):SetText(NaturDB.Texture); |
end); |
local function ListButton_OnClick(self) |
addon.group:SetTexture(media:Fetch("statusbar", self.texture)); |
--addon.group:SetTexture(media:Fetch("statusbar", self.texture)); |
for k, v in pairs(addon.groups) do |
addon.groups[k]:SetTexture(media:Fetch("statusbar", self.texture)); |
end |
NaturDB.Texture = self.texture; |
local p = self:GetParent(); |
p:Hide(); |
return f; |
end |
---------------------------------------------------------------------------------------------------- |
function NaturOptions:CreatePanel(name) |
local p = CreateFrame("Frame", self:GetName()..name, self, "OptionFrameBoxTemplate"); |
function NaturOptions:CreatePanel(name, parent) |
local p = CreateFrame("Frame", self:GetName()..name, parent, "OptionFrameBoxTemplate"); |
p:SetBackdropBorderColor(.4, .4, .4); |
p:SetBackdropColor(.15, .15, .15, .75); |
getglobal(p:GetName().."Title"):SetText(name); |
return p; |
end |
---------------------------------------------------------------------------------------------------- |
function NaturOptions:CreateTab(name, parent, text, tooltip) |
local p = CreateFrame("Button", parent:GetName()..name, parent, "OptionsFrameTabButtonTemplate"); |
p:SetText(text); |
p:SetScript("OnEnter", ShowTooltip); |
p:SetScript("OnLeave", HideTooltip); |
p.tiptext = tooltip; |
PanelTemplates_TabResize(0, p); |
local s = self:CreateSpacer(p:GetWidth(), p); |
p.spacer = s; |
return p; |
end |
function NaturOptions:CreateSpacer(width, parent) |
local s = parent:CreateTexture(nil, "ARTWORK"); |
s:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-Spacer"); |
s:SetHeight(16); |
s:SetWidth(width-20); |
return s; |
end |
-- Go! |
NaturOptions:OnLoad(); |