WoWInterface SVN NeedToKnow-Updated

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 124 to Rev 125
    Reverse comparison

Rev 124 → Rev 125

trunk/NeedToKnow/NeedToKnow_Options.xml
639,6 → 639,27
</Scripts>
</Slider>
 
<Slider name="$parentFontOutlineSlider" inherits="OptionsSliderTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parentFontSizeSlider" relativePoint="TOPRIGHT">
<Offset>
<AbsDimension x="24"/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnValueChanged>
NeedToKnow.ProfileSettings["FontOutline"] = value;
local str;
if value == 0 then str = "None" -- FIXME: Localization
elseif value == 1 then str = "Normal" -- FIXME: Localization
else str = "Heavy" end
_G[self:GetName().."Text"]:SetText("Font Outline: "..str); -- FIXME: LOCALIZATION
NeedToKnow.Update();
</OnValueChanged>
</Scripts>
</Slider>
 
<Button name="$parentConfigModeButton" inherits="UIPanelButtonTemplate">
<Size>
<AbsDimension x="128" y="22"/>
trunk/NeedToKnow/NeedToKnow_Options.lua
1,4 → 1,6
NEEDTOKNOW.MAXBARSPACING = 24;
local trace = print
 
NEEDTOKNOW.MAXBARSPACING = 24;
NEEDTOKNOW.MAXBARPADDING = 12;
 
local GetActiveTalentGroup = _G.GetActiveSpecGroup
253,6 → 255,7
local barSpacingSlider = _G[panelName.."BarSpacingSlider"];
local barPaddingSlider = _G[panelName.."BarPaddingSlider"];
local fontSizeSlider = _G[panelName.."FontSizeSlider"];
local fontOutlineSlider = _G[panelName.."FontOutlineSlider"];
 
-- Mimic the behavior of the context menu, and force the alpha to one in the swatch
local r,g,b = unpack(settings.BkgdColor);
267,6 → 270,9
fontSizeSlider:SetMinMaxValues(5,20);
fontSizeSlider:SetValue(settings.FontSize);
fontSizeSlider:SetValueStep(0.5);
fontOutlineSlider:SetMinMaxValues(0,2);
fontOutlineSlider:SetValue(settings.FontOutline);
fontOutlineSlider:SetValueStep(1);
 
NeedToKnowOptions.UpdateBarTextureDropDown(_G[panelName.."Textures"]);
NeedToKnowOptions.UpdateBarFontDropDown(_G[panelName.."Fonts"]);
734,6 → 740,7
-- The code that drives it remains so that any existing users' bars won't break.
-- { Setting = "USABLE", MenuText = NEEDTOKNOW.BARMENU_USABLE },
{ Setting = "EQUIPSLOT", MenuText = NEEDTOKNOW.BARMENU_EQUIPSLOT },
{ Setting = "POWER", MenuText = NEEDTOKNOW.BARMENU_POWER }
},
TimeFormat = {
{ Setting = "Fmt_SingleUnit", MenuText = NEEDTOKNOW.FMT_SINGLEUNIT },
780,6 → 787,11
{
{ VariableName = "append_cd", MenuText = "Append \"CD\"" }, -- LOCME
},
Opt_POWER =
{
{ VariableName = "Unit", MenuText = NEEDTOKNOW.BARMENU_CHOOSEUNIT, Type = "Submenu" },
{ VariableName = "power_sole", MenuText = "Only Show When Primary" }, -- LOCME
},
Opt_BUFFCD =
{
{ VariableName = "buffcd_duration", MenuText = "Cooldown duration...", Type = "Dialog", DialogText = "BUFFCD_DURATION_DIALOG", Numeric=true },
813,6 → 825,9
{ Setting = "18", MenuText = NEEDTOKNOW.ITEM_NAMES[18] },
{ Setting = "19", MenuText = NEEDTOKNOW.ITEM_NAMES[19] },
},
PowerTypeList =
{
},
VisualCastTime = {
{ VariableName = "vct_enabled", MenuText = NEEDTOKNOW.BARMENU_VCT_ENABLE },
{ VariableName = "vct_color", MenuText = NEEDTOKNOW.BARMENU_VCT_COLOR, Type = "Color" },
844,6 → 859,7
{
DebuffUnit = "Unit",
EquipmentSlotList = "AuraName",
PowerTypeList = "AuraName",
}
 
function NeedToKnowRMB.ShowMenu(bar)
1130,15 → 1146,36
if ( type == "EQUIPSLOT" ) then
button = NeedToKnowRMB.BarMenu_GetItem(1, "AuraName");
if ( button ) then
button.oldvalue = button.value
else
button = NeedToKnowRMB.BarMenu_GetItem(1, "PowerTypeList")
end
if ( button ) then
local arrow = _G[button:GetName().."ExpandArrow"]
arrow:Show();
button.hasArrow = true
button.oldvalue = button.value
button.value = "EquipmentSlotList"
button:SetText(NEEDTOKNOW.BARMENU_CHOOSESLOT)
-- TODO: really should disable the button press verb somehow
end
elseif ( type == "POWER" ) then
button = NeedToKnowRMB.BarMenu_GetItem(1, "AuraName");
if ( button ) then
button.oldvalue = button.value
else
button = NeedToKnowRMB.BarMenu_GetItem(1, "EquipmentSlotList")
end
if ( button ) then
local arrow = _G[button:GetName().."ExpandArrow"]
arrow:Show();
button.hasArrow = true
button.value = "PowerTypeList"
button:SetText(NEEDTOKNOW.BARMENU_CHOOSEPOWER)
-- TODO: really should disable the button press verb somehow
end
else
button = NeedToKnowRMB.BarMenu_GetItem(1, "EquipmentSlotList");
if not button then button = NeedToKnowRMB.BarMenu_GetItem(1, "PowerTypeList") end
if ( button ) then
local arrow = _G[button:GetName().."ExpandArrow"]
arrow:Hide();
1410,6 → 1447,8
end
 
function NeedToKnowRMB.BarMenu_ShowNameDialog(self, a1, a2, checked)
if not self.value.text or not NEEDTOKNOW[self.value.text] then return end
 
StaticPopupDialogs["NEEDTOKNOW.CHOOSENAME_DIALOG"].text = NEEDTOKNOW[self.value.text];
local dialog = StaticPopup_Show("NEEDTOKNOW.CHOOSENAME_DIALOG");
dialog.variable = self.value.variable;
trunk/NeedToKnow/NeedToKnow.lua
3,8 → 3,7
-- by Kitjan, lieandswell
-- ----------------------
 
 
if not trace then trace = print end
local trace = print
--function maybe_trace(...)
--local so_far = ""
--local p = _G
48,11 → 47,13
local m_bInCombat, m_bCombatWithBoss
 
local mfn_Bar_AuraCheck
local mfn_EnergyBar_OnUpdate
local mfn_AuraCheck_Single
local mfn_AuraCheck_TOTEM
local mfn_AuraCheck_BUFFCD
local mfn_AuraCheck_USABLE
local mfn_AuraCheck_EQUIPSLOT
local mfn_AuraCheck_POWER
local mfn_AuraCheck_CASTCD
local mfn_AuraCheck_Weapon
local mfn_AuraCheck_AllStacks
109,7 → 110,7
}
-- NEEDTOKNOW = {} is defined in the localization file, which must be loaded before this file
 
NEEDTOKNOW.VERSION = "4.0.09"
NEEDTOKNOW.VERSION = "4.0.12"
local c_UPDATE_INTERVAL = 0.05
local c_MAXBARS = 20
 
195,6 → 196,7
BarSpacing = 3,
BarPadding = 3,
FontSize = 12,
FontOutline = 0,
}
 
NEEDTOKNOW.SHORTENINGS= {
252,6 → 254,7
--BarSpacing = "BSp",
--BarPadding = "BPd",
--FontSize = "FSz",
--FontOutline = "FOl",
}
 
NEEDTOKNOW.LENGTHENINGS= {
309,6 → 312,7
--BarSpacing = "BSp",
--BarPadding = "BPd",
--FontSize = "FSz",
--FontOutline = "FOl";
}
 
-- -------------------
492,11 → 496,12
local _, player_CLASS = UnitClass("player")
if player_CLASS == "DEATHKNIGHT" then
NeedToKnow.is_DK = 1
end
if player_CLASS == "DRUID" then
elseif player_CLASS == "DRUID" then
NeedToKnow.is_Druid = 1
end
 
NeedToKnowLoader.SetPowerTypeList(player_CLASS)
 
NeedToKnow_ExecutiveFrame:RegisterEvent("PLAYER_TALENT_UPDATE")
NeedToKnow_ExecutiveFrame:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
NeedToKnow_ExecutiveFrame:RegisterEvent("UNIT_TARGET")
1048,7 → 1053,131
end
 
 
function NeedToKnowLoader.SetPowerTypeList(player_CLASS)
if player_CLASS == "DRUID" or
player_CLASS == "MONK"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = "4", MenuText = NEEDTOKNOW.POWER_TYPES[4] } )
end
 
-- -1 - Combo Points
if player_CLASS == "DRUID" or
player_CLASS == "ROGUE"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = "-1", MenuText = NEEDTOKNOW.COMBO_POINTS } )
end
 
-- 0 - Mana
if player_CLASS == "DRUID" or
player_CLASS == "MAGE" or
player_CLASS == "PALADIN" or
player_CLASS == "PRIEST" or
player_CLASS == "SHAMAN" or
player_CLASS == "WARLOCK"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_MANA), MenuText = MANA } )
end
 
-- 1 - Rage
if player_CLASS == "DRUID" or
player_CLASS == "WARRIOR"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_RAGE), MenuText = RAGE } )
end
 
-- 2 - Focus
if player_CLASS == "HUNTER"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_FOCUS), MenuText = FOCUS } )
end
 
-- 3 - Energy
if player_CLASS == "DRUID" or
player_CLASS == "MONK" or
player_CLASS == "ROGUE"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_ENERGY), MenuText = ENERGY } )
end
 
-- 4 - HAPPINESS no longer used
 
-- 5 - Runes These don't make sense as a bar, and UnitPower returns 0 anyway
-- if player_CLASS == "DEATHKNIGHT"
-- then
-- table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
-- { Setting = tostring(SPELL_POWER_RUNES), MenuText = RUNES } )
--end
 
-- 6 - Runic Power
if player_CLASS == "DEATHKNIGHT"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_RUNIC_POWER), MenuText = RUNIC_POWER } )
end
 
-- 7 - Soul Shards for affliction
if player_CLASS == "WARLOCK"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_SOUL_SHARDS), MenuText = SOUL_SHARDS } )
end
 
-- 8 - Eclipse for balance druids
if player_CLASS == "DRUID"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_ECLIPSE), MenuText = ECLIPSE } )
end
 
-- 9 - Holy Power
if player_CLASS == "PALADIN"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_HOLY_POWER), MenuText = HOLY_POWER } )
end
 
-- 10 - "Alternate" power, for various boss fights, useful for everybody
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = "10", MenuText = NEEDTOKNOW.ALTERNATE_POWER } )
 
-- 11 - Dark Force, currently unused
 
-- 12 - Monk Chi
if player_CLASS == "MONK"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_CHI), MenuText = CHI } )
end
 
-- 13 - Shadow Orbs for shadow priest
if player_CLASS == "PRIEST"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_SHADOW_ORBS), MenuText = SHADOW_ORBS } )
end
 
-- 14 - Burning Embers for Destruction warlocks
if player_CLASS == "WARLOCK"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_BURNING_EMBERS), MenuText = BURNING_EMBERS } )
end
 
-- 15 - Demonic Fury for demonology
if player_CLASS == "WARLOCK"
then
table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
{ Setting = tostring(SPELL_POWER_DEMONIC_FURY), MenuText = DEMONIC_FURY } )
end
end
 
 
function NeedToKnow.DeepCopy(object)
if type(object) ~= "table" then
return object
1305,8 → 1434,17
end
local fontPath = NeedToKnow.LSM:Fetch("font", NeedToKnow.ProfileSettings["BarFont"])
if ( fontPath ) then
bar.text:SetFont(fontPath, NeedToKnow.ProfileSettings["FontSize"])
bar.time:SetFont(fontPath, NeedToKnow.ProfileSettings["FontSize"])
local ol = NeedToKnow.ProfileSettings["FontOutline"]
if ( ol == 0 ) then
ol = nil
elseif (ol == 1) then
ol = "OUTLINE"
else
ol = "THICKOUTLINE"
end
 
bar.text:SetFont(fontPath, NeedToKnow.ProfileSettings["FontSize"],ol)
bar.time:SetFont(fontPath, NeedToKnow.ProfileSettings["FontSize"],ol)
end
 
bar:SetWidth(groupSettings.Width)
1360,7 → 1498,7
for barSpell in bar.auraName:gmatch("([^,]+)") do
iSpell = iSpell+1
barSpell = strtrim(barSpell)
local _, nDigits = barSpell:find("^%d+")
local _, nDigits = barSpell:find("^-?%d+")
if ( nDigits == barSpell:len() ) then
table.insert(bar.spells, { idxName=iSpell, id=tonumber(barSpell) } )
else
1397,6 → 1535,8
end
 
barSettings.bAutoShot = nil
bar.is_counter = nil
bar.ticker = NeedToKnow.Bar_OnUpdate
 
-- Determine which helper functions to use
if "BUFFCD" == barSettings.BuffOrDebuff then
1407,6 → 1547,11
bar.fnCheck = mfn_AuraCheck_USABLE
elseif "EQUIPSLOT" == barSettings.BuffOrDebuff then
bar.fnCheck = mfn_AuraCheck_EQUIPSLOT
elseif "POWER" == barSettings.BuffOrDebuff then
bar.fnCheck = mfn_AuraCheck_POWER
bar.is_counter = true
bar.ticker = nil
bar.ticking = false
elseif "CASTCD" == barSettings.BuffOrDebuff then
bar.fnCheck = mfn_AuraCheck_CASTCD
for idx, entry in ipairs(bar.spells) do
1506,7 → 1651,10
 
function NeedToKnow.SetScripts(bar)
bar:SetScript("OnEvent", NeedToKnow.Bar_OnEvent)
bar:SetScript("OnUpdate", NeedToKnow.Bar_OnUpdate)
 
if ( bar.ticker ) then
bar:SetScript("OnUpdate", bar.ticker)
end
if ( "TOTEM" == bar.settings.BuffOrDebuff ) then
bar:RegisterEvent("PLAYER_TOTEM_UPDATE")
elseif ( "CASTCD" == bar.settings.BuffOrDebuff ) then
1518,6 → 1666,13
bar:RegisterEvent("SPELL_UPDATE_COOLDOWN")
elseif ( "EQUIPSLOT" == bar.settings.BuffOrDebuff ) then
bar:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN")
elseif ( "POWER" == bar.settings.BuffOrDebuff ) then
if bar.settings.AuraName == "-1" then
bar:RegisterEvent("UNIT_COMBO_POINTS")
else
bar:RegisterEvent("UNIT_POWER")
bar:RegisterEvent("UNIT_DISPLAYPOWER")
end
elseif ( "USABLE" == bar.settings.BuffOrDebuff ) then
bar:RegisterEvent("SPELL_UPDATE_USABLE")
elseif ( "mhand" == bar.settings.Unit or "ohand" == bar.settings.Unit ) then
1530,21 → 1685,21
NeedToKnow.CheckCombatLogRegistration(bar)
else
bar:RegisterEvent("UNIT_AURA")
if ( bar.unit == "focus" ) then
bar:RegisterEvent("PLAYER_FOCUS_CHANGED")
elseif ( bar.unit == "target" ) then
bar:RegisterEvent("PLAYER_TARGET_CHANGED")
elseif ( bar.unit == "pet" ) then
bar:RegisterEvent("UNIT_PET")
elseif ( "lastraid" == bar.settings.Unit ) then
if ( not NeedToKnow.BarsForPSS ) then
NeedToKnow.BarsForPSS = {}
end
NeedToKnow.BarsForPSS[bar] = true
NeedToKnow.RegisterSpellcastSent()
end
 
if ( bar.unit == "focus" ) then
bar:RegisterEvent("PLAYER_FOCUS_CHANGED")
elseif ( bar.unit == "target" ) then
bar:RegisterEvent("PLAYER_TARGET_CHANGED")
elseif ( bar.unit == "pet" ) then
bar:RegisterEvent("UNIT_PET")
elseif ( "lastraid" == bar.settings.Unit ) then
if ( not NeedToKnow.BarsForPSS ) then
NeedToKnow.BarsForPSS = {}
end
NeedToKnow.BarsForPSS[bar] = true
NeedToKnow.RegisterSpellcastSent()
end
 
 
if bar.settings.bDetectExtends then
local idx,entry
1582,6 → 1737,9
bar:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
bar:UnregisterEvent("PLAYER_TOTEM_UPDATE")
bar:UnregisterEvent("UNIT_AURA")
bar:UnregisterEvent("UNIT_COMBO_POINTS")
bar:UnregisterEvent("UNIT_POWER")
bar:UnregisterEvent("UNIT_DISPLAYPOWER")
bar:UnregisterEvent("UNIT_INVENTORY_CHANGED")
bar:UnregisterEvent("UNIT_TARGET")
bar:UnregisterEvent("START_AUTOREPEAT_SPELL")
1615,77 → 1773,9
if (self.bar2 and self.bar2.cur_value) then mfn_SetStatusBarValue(self, self.bar2, self.bar2.cur_value, self.bar1.cur_value) end
end
 
function NeedToKnow.Bar_OnEvent(self, event, unit, ...)
if ( event == "COMBAT_LOG_EVENT_UNFILTERED") then
local combatEvent = select(1, ...)
 
if ( c_AURAEVENTS[combatEvent] ) then
local guidTarget = select(7, ...)
if ( guidTarget == g_UnitGUID(self.unit) ) then
local idSpell, nameSpell = select(11, ...)
if (self.auraName:find(idSpell) or
self.auraName:find(nameSpell))
then
mfn_Bar_AuraCheck(self)
end
end
elseif ( combatEvent == "UNIT_DIED" ) then
local guidDeceased = select(7, ...)
if ( guidDeceased == UnitGUID(self.unit) ) then
mfn_Bar_AuraCheck(self)
end
end
elseif ( event == "PLAYER_TOTEM_UPDATE" ) or
( event == "ACTIONBAR_UPDATE_COOLDOWN" ) or
( event == "SPELL_UPDATE_COOLDOWN" ) or
( event == "SPELL_UPDATE_USABLE" )
then
mfn_Bar_AuraCheck(self)
elseif ( event == "UNIT_AURA" ) and ( unit == self.unit ) then
mfn_Bar_AuraCheck(self)
elseif ( event == "UNIT_INVENTORY_CHANGED" and unit == "player" ) then
NeedToKnow.UpdateWeaponEnchants()
mfn_Bar_AuraCheck(self)
elseif ( event == "PLAYER_TARGET_CHANGED" ) or ( event == "PLAYER_FOCUS_CHANGED" ) then
if self.unit == "targettarget" then
NeedToKnow.CheckCombatLogRegistration(self)
end
mfn_Bar_AuraCheck(self)
elseif ( event == "UNIT_TARGET" and unit == "target" ) then
if self.unit == "targettarget" then
NeedToKnow.CheckCombatLogRegistration(self)
end
mfn_Bar_AuraCheck(self)
elseif ( event == "UNIT_PET" and unit == "player" ) then
mfn_Bar_AuraCheck(self)
elseif ( event == "PLAYER_SPELLCAST_SUCCEEDED" ) then
local spellName, spellID, tgt = select(1,...)
local i,entry
for i,entry in ipairs(self.spells) do
if entry.id == spellID or entry.name == spellName then
self.unit = tgt or "unknown"
--trace("Updating",self:GetName(),"since it was recast on",self.unit)
mfn_Bar_AuraCheck(self)
break;
end
end
elseif ( event == "START_AUTOREPEAT_SPELL" ) then
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
elseif ( event == "STOP_AUTOREPEAT_SPELL" ) then
self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
elseif ( event == "UNIT_SPELLCAST_SUCCEEDED" ) then
local spell = select(1,...)
if ( self.settings.bAutoShot and unit == "player" and spell == c_AUTO_SHOT_NAME ) then
local interval = UnitRangedDamage("player")
self.tAutoShotCD = interval
self.tAutoShotStart = g_GetTime()
mfn_Bar_AuraCheck(self)
end
end
end
 
 
 
-- AuraCheck calls on this to compute the "text" of the bar
-- It is separated out like this in part to be hooked by other addons
function NeedToKnow.ComputeBarText(buffName, count, extended, buff_stacks, bar)
1788,6 → 1878,10
local idx = tonumber(barSettings.AuraName)
if idx then return NEEDTOKNOW.ITEM_NAMES[idx] end
return ""
elseif ( barSettings.BuffOrDebuff == "POWER" ) then
local idx = tonumber(barSettings.AuraName)
if idx then return NEEDTOKNOW.POWER_TYPES[idx] end
return ""
else
return barSettings.AuraName
end
1853,7 → 1947,7
 
-- Is this an aura with a finite duration?
local vct_width = 0
if ( bar.duration > 0 ) then
if ( not bar.is_counter and bar.duration > 0 ) then
-- Configure the main status bar
local duration = bar.fixedDuration or bar.duration
bar.max_value = duration
1871,9 → 1965,22
end
 
bar.time:Show()
else
elseif bar.is_counter then
bar.max_value = 1
local pct = buff_stacks.total_ttn[1] / buff_stacks.total_ttn[2]
mfn_SetStatusBarValue(bar,bar.bar1,pct)
if bar.bar2 then mfn_SetStatusBarValue(bar,bar.bar2,pct) end
 
bar.time:Hide()
bar.spark:Hide()
 
if ( bar.vct ) then
bar.vct:Hide()
end
else
-- Hide the time text and spark for auras with "infinite" duration
bar.max_value = 1
 
mfn_SetStatusBarValue(bar,bar.bar1,1)
if bar.bar2 then mfn_SetStatusBarValue(bar,bar.bar2,1) end
 
2286,6 → 2393,74
 
 
 
-- Bar_AuraCheck helper for power and combo points. The current
-- amount is reported as the first tooltip number rather than
-- stacks since 1 stack doesn't get displayed normally
mfn_AuraCheck_POWER = function (bar, bar_entry, all_stacks)
local spellName, spellRank, spellIconPath
local cpt = UnitPowerType(bar.unit)
local pt = bar_entry.id
 
if ( pt ) then
if pt == 4 then pt = cpt end
 
local curPower, maxPower;
if ( pt == -1 ) then
curPower = GetComboPoints("player", bar.unit)
maxPower = MAX_COMBO_POINTS
else
curPower = UnitPower(bar.unit, pt)
maxPower = UnitPowerMax(bar.unit, pt)
end
 
if ( maxPower and maxPower > 0 and
(not bar.settings.power_sole or pt == cpt) )
then
local bTick = false
if pt == 3 then
if (pt == cpt) then
bar.power_regen = GetPowerRegen()
end
if (bar.power_regen and bar.power_regen > 0) then
bTick = true
end
end
if bTick then
if not bar.ticking then
bar.ticker = mfn_EnergyBar_OnUpdate
bar:SetScript("OnUpdate", bar.ticker)
bar.ticking = true
end
elseif bar.ticking then
bar:SetScript("OnUpdate", nil)
bar.ticking = false
end
 
if bar.ticking then
local now = g_GetTime()
if not bar.tPower or now - bar.tPower > 2 or bar.last_power ~= curPower then
bar.tPower = now
bar.last_power = curPower
bar.last_power_max = maxPower
end
end
 
mfn_AddInstanceToStacks(all_stacks, bar_entry,
0, -- duration
NEEDTOKNOW.POWER_TYPES[pt], -- name
1, -- count
0, -- expiration time
nil, -- icon path
bar.unit, -- caster
curPower, -- tooltip #1
maxPower, -- tooltip #2
floor(curPower*1000/maxPower)/10 ) -- tooltip #3
end
end
end
 
 
 
-- Bar_AuraCheck helper that checks the bar.weapon_enchants
-- (computed by UpdateWeaponEnchants) for the given spell.
-- FIXME: this is the only bar type that does not work with spell ids.
2449,6 → 2624,7
id,
_, -- uao.canCast -- The player's class/spec can cast this spell
_, -- A boss applied this
_, -- Unknown boolean
v1,
v2,
v3,
2456,8 → 2632,8
= UnitAura(a,b,c,d)
if name then
-- There is a boolean at the end of the list whos purpose is unknown
-- It can be either true or false, so we must test against nil explicitly
-- Between the boss boolean and this end boolean will be 0-3 integers
-- It can be either true or false, so we must test against nil explicitly
-- Between the boss boolean and this end boolean will be 0-3 integers
if nil == bEnd then
-- some or all tooltip values are missing
if nil == v3 then
2839,3 → 3015,126
end
end
end
 
 
mfn_EnergyBar_OnUpdate = function(bar, elapsed)
local now = g_GetTime()
if ( now > bar.nextUpdate ) then
bar.nextUpdate = now + c_UPDATE_INTERVAL
local delta = now - bar.tPower
local predicted = bar.last_power + bar.power_regen * delta
local bCapped = false
if predicted >= bar.last_power_max then
predicted = bar.last_power_max
bCapped = true
elseif predicted <= 0 then
predicted = 0
bCapped = true
end
 
bar.max_value = bar.last_power_max
mfn_SetStatusBarValue(bar, bar.bar1, predicted);
 
if bCapped then
bar.ticking = false
bar:SetScript("OnUpdate", nil)
end
end
end
 
 
 
 
-- Define the event dispatching table. Note, this comes last as the referenced
-- functions must already be declared. Avoiding the re-evaluation of all that
-- is one of the reasons this is an optimization!
local fnAuraCheckIfUnitMatches = function(self, unit)
if ( unit == self.unit ) then
mfn_Bar_AuraCheck(self)
end
end
 
local fnAuraCheckIfUnitPlayer = function(self, unit)
if ( unit == "player" ) then
mfn_Bar_AuraCheck(self)
end
end
 
local EDT = {}
EDT["COMBAT_LOG_EVENT_UNFILTERED"] = function(self, unit, ...)
local combatEvent = select(1, ...)
 
if ( c_AURAEVENTS[combatEvent] ) then
local guidTarget = select(7, ...)
if ( guidTarget == g_UnitGUID(self.unit) ) then
local idSpell, nameSpell = select(11, ...)
if (self.auraName:find(idSpell) or
self.auraName:find(nameSpell))
then
mfn_Bar_AuraCheck(self)
end
end
elseif ( combatEvent == "UNIT_DIED" ) then
local guidDeceased = select(7, ...)
if ( guidDeceased == UnitGUID(self.unit) ) then
mfn_Bar_AuraCheck(self)
end
end
end
EDT["PLAYER_TOTEM_UPDATE"] = mfn_Bar_AuraCheck
EDT["ACTIONBAR_UPDATE_COOLDOWN"] = mfn_Bar_AuraCheck
EDT["SPELL_UPDATE_COOLDOWN"] = mfn_Bar_AuraCheck
EDT["SPELL_UPDATE_USABLE"] = mfn_Bar_AuraCheck
EDT["UNIT_AURA"] = fnAuraCheckIfUnitMatches
EDT["UNIT_POWER"] = fnAuraCheckIfUnitMatches
EDT["UNIT_DISPLAYPOWER"] = fnAuraCheckIfUnitMatches
EDT["UNIT_COMBO_POINTS"] = mfn_Bar_AuraCheck
EDT["UNIT_INVENTORY_CHANGED"] = fnAuraCheckIfUnitPlayer
EDT["PLAYER_TARGET_CHANGED"] = function(self, unit)
if self.unit == "targettarget" then
NeedToKnow.CheckCombatLogRegistration(self)
end
mfn_Bar_AuraCheck(self)
end
EDT["PLAYER_FOCUS_CHANGED"] = EDT["PLAYER_TARGET_CHANGED"]
EDT["UNIT_TARGET"] = function(self, unit)
if unit == "target" and self.unit == "targettarget" then
NeedToKnow.CheckCombatLogRegistration(self)
end
mfn_Bar_AuraCheck(self)
end
EDT["UNIT_PET"] = fnAuraCheckIfUnitPlayer
EDT["PLAYER_SPELLCAST_SUCCEEDED"] = function(self, unit, ...)
local spellName, spellID, tgt = select(1,...)
local i,entry
for i,entry in ipairs(self.spells) do
if entry.id == spellID or entry.name == spellName then
self.unit = tgt or "unknown"
--trace("Updating",self:GetName(),"since it was recast on",self.unit)
mfn_Bar_AuraCheck(self)
break;
end
end
end
EDT["START_AUTOREPEAT_SPELL"] = function(self, unit, ...)
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end
EDT["STOP_AUTOREPEAT_SPELL"] = function(self, unit, ...)
self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end
EDT["UNIT_SPELLCAST_SUCCEEDED"] = function(self, unit, ...)
local spell = select(1,...)
if ( self.settings.bAutoShot and unit == "player" and spell == c_AUTO_SHOT_NAME ) then
local interval = UnitRangedDamage("player")
self.tAutoShotCD = interval
self.tAutoShotStart = g_GetTime()
mfn_Bar_AuraCheck(self)
end
end
 
function NeedToKnow.Bar_OnEvent(self, event, unit, ...)
local fn = EDT[event]
if fn then
fn(self, unit, ...)
end
end
\ No newline at end of file
trunk/NeedToKnow/NeedToKnow.toc
1,7 → 1,7
## Interface: 050001
## Interface: 050100
## Title: NeedToKnow
## Author: Kitjan, lieandswell
## Version: 4.0.09
## Version: 4.0.12
## Notes: Timer bars for buffs, debuffs, cooldowns, etc.
## X-Credits: Bilt, Fxfighter EU-Echsenkessel, metalchoir, sp00n, Vlakarados, wowui.cn
## X-Category: Buffs, Combat
trunk/NeedToKnow/NeedToKnow_Localization.lua
9,6 → 9,7
NEEDTOKNOW = {};
 
-- Seems like this should already exist somewhere
-- Strings come from the chart on http://www.wowwiki.com/WoW_constants
NEEDTOKNOW.ITEM_NAMES =
{
HEADSLOT,
32,7 → 33,10
TABARDSLOT
};
 
 
-- Define defaults in enUS
NEEDTOKNOW.ALTERNATE_POWER = "Alternate Power";
NEEDTOKNOW.COMBO_POINTS = "Combo Points";
NEEDTOKNOW.BAR_TOOLTIP1 = "NeedToKnow";
NEEDTOKNOW.BAR_TOOLTIP2 = "Right click bars to configure. More options in the Blizzard interface options menu. Type /needtoknow to lock and enable.";
 
41,6 → 45,7
NEEDTOKNOW.BARMENU_ENABLE = "Enable bar";
NEEDTOKNOW.BARMENU_CHOOSENAME = "Choose buff/debuff to time...";
NEEDTOKNOW.BARMENU_CHOOSESLOT = "Choose Equipment Slot...";
NEEDTOKNOW.BARMENU_CHOOSEPOWER = "Choose Power Type...";
NEEDTOKNOW.CHOOSENAME_DIALOG = "Enter the name of the buff or debuff to time with this bar"
NEEDTOKNOW.IMPORTEXPORT_DIALOG = "The current settings for the bar appear below. To copy these settings to the clipboard, press Ctrl+C. To paste the last settings you copied (such as from another bar), press Ctrl+V. Clear this text to reset the bar to the defaults.";
NEEDTOKNOW.CHOOSE_OVERRIDE_TEXT = "Normally, the name of the aura/item/spell that activated the bar is displayed. By entering text here, you can override that text with something else. Leave this blank to use the default behavior."
59,6 → 64,7
NEEDTOKNOW.BARMENU_ONLYMINE = "Only show if cast by self";
NEEDTOKNOW.BARMENU_BARCOLOR = "Bar color";
NEEDTOKNOW.BARMENU_CLEARSETTINGS = "Clear settings";
NEEDTOKNOW.BARMENU_POWER_PRIMARY = "Primary";
NEEDTOKNOW.BARMENU_SHOW = "Show";
NEEDTOKNOW.BARMENU_SHOW_ICON = "Icon";
NEEDTOKNOW.BARMENU_SHOW_TEXT = "Aura Name";
97,7 → 103,9
NEEDTOKNOW.UIPANEL_BARTEXTURE = "Bar texture";
NEEDTOKNOW.UIPANEL_BARFONT = "Bar font";
NEEDTOKNOW.UIPANEL_FONT = "Font";
NEEDTOKNOW.UIPANEL_FONT_OUTLINE = "Font Outline";
 
 
NEEDTOKNOW.UIPANEL_PROFILES_SUBTEXT1 = "These options allow you to manage profiles. Each profile is a complete NeedToKnow configuration for one talent spec.\nBy default, profiles are per-character (and have character: in front of their name.) Per-character profiles are only available to this character. Profiles can be switched between per-character and per-account so that the same profile can be used by multiple characters on the same account.";
NEEDTOKNOW.UIPANEL_CURRENTPRIMARY = "Current Primary Profile:";
NEEDTOKNOW.UIPANEL_CURRENTSECONDARY = "Current Secondary Profile:";
121,6 → 129,7
NEEDTOKNOW.BARMENU_BUFFCD = "Internal Cooldown";
NEEDTOKNOW.BARMENU_USABLE = "Conditional Spell";
NEEDTOKNOW.BARMENU_EQUIPSLOT = "Equipment Slot";
NEEDTOKNOW.BARMENU_POWER = "Power (experimental)";
NEEDTOKNOW.CMD_HIDE = "hide";
NEEDTOKNOW.CMD_PROFILE = "profile";
NEEDTOKNOW.CMD_SHOW = "show";
333,3 → 342,24
 
end
 
NEEDTOKNOW.POWER_TYPES =
{
RAGE,
FOCUS,
ENERGY,
NEEDTOKNOW.BARMENU_POWER_PRIMARY,
RUNES,
RUNIC_POWER,
SOUL_SHARDS,
ECLIPSE,
HOLY_POWER,
NEEDTOKNOW.ALTERNATE_POWER, -- index 10
"Dark Force", -- Currently unused according to wowpedia
CHI, -- Chi
SHADOW_ORBS,
BURNING_EMBERS,
DEMONIC_FURY
};
NEEDTOKNOW.POWER_TYPES[0] = MANA
NEEDTOKNOW.POWER_TYPES[-1] = NEEDTOKNOW.COMBO_POINTS