WoWInterface SVN NeedToKnow-Updated

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /branches
    from Rev 58 to Rev 59
    Reverse comparison

Rev 58 → Rev 59

Kitjan/NeedToKnow/NeedToKnow_Options.lua
397,10 → 397,19
 
function NeedToKnow.Bar_OnMouseUp(self, button)
if ( button == "RightButton" ) then
PlaySound("UChatScrollButton");
PlaySound("UChatScrollButton");
NeedToKnow.CurrentBar["barID"] = self:GetID();
NeedToKnow.CurrentBar["groupID"] = self:GetParent():GetID();
ToggleDropDownMenu(1, nil, getglobal(self:GetName().."DropDown"), "cursor", 0, 0);
if not NeedToKnow.DropDown then
NeedToKnow.DropDown = CreateFrame("Frame", "NeedToKnowDropDown", nil, "NeedToKnow_DropDownTemplate")
end
 
-- There's no OpenDropDownMenu that forces it to show in the new place,
-- so we have to check if the first Toggle opened or closed it
ToggleDropDownMenu(1, nil, NeedToKnow.DropDown, "cursor", 0, 0);
if not DropDownList1:IsShown() then
ToggleDropDownMenu(1, nil, NeedToKnow.DropDown, "cursor", 0, 0);
end
end
end
 
481,42 → 490,42
local barID = NeedToKnow.CurrentBar["barID"];
local barSettings = NeedToKnow_Settings["Spec"][NEEDTOKNOW.CURRENTSPEC]["Groups"][groupID]["Bars"][barID];
 
if ( barSettings.MissingBlink.a == 0 ) then
if ( barSettings.MissingBlink.a == 0 ) then
barSettings.blink_enabled = false;
end
NeedToKnow.BarMenu_SubMenus.Options = NeedToKnow.BarMenu_SubMenus["Opt_"..barSettings.BuffOrDebuff];
end
NeedToKnow.BarMenu_SubMenus.Options = NeedToKnow.BarMenu_SubMenus["Opt_"..barSettings.BuffOrDebuff];
 
if ( UIDROPDOWNMENU_MENU_LEVEL > 1 ) then
if ( UIDROPDOWNMENU_MENU_VALUE == "VisualCastTime" ) then
-- Create a summary title for the visual cast time submenu
local title = "";
if ( barSettings.vct_spell and "" ~= barSettings.vct_spell ) then
title = title .. barSettings.vct_spell;
end
local fExtra = tonumber(barSettings.vct_extra);
if ( fExtra and fExtra > 0 ) then
if ("" ~= title) then
title = title .. " + ";
end
title = title .. string.format("%0.1fs", fExtra);
end
if ( "" ~= title ) then
local info = UIDropDownMenu_CreateInfo();
info.text = title;
info.isTitle = true;
UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
end
end
local subMenus = NeedToKnow.BarMenu_SubMenus;
for index, value in ipairs(subMenus[UIDROPDOWNMENU_MENU_VALUE]) do
NeedToKnow.BarMenu_AddButton(barSettings, value, UIDROPDOWNMENU_MENU_VALUE);
end
if ( UIDROPDOWNMENU_MENU_LEVEL > 1 ) then
if ( UIDROPDOWNMENU_MENU_VALUE == "VisualCastTime" ) then
-- Create a summary title for the visual cast time submenu
local title = "";
if ( barSettings.vct_spell and "" ~= barSettings.vct_spell ) then
title = title .. barSettings.vct_spell;
end
local fExtra = tonumber(barSettings.vct_extra);
if ( fExtra and fExtra > 0 ) then
if ("" ~= title) then
title = title .. " + ";
end
title = title .. string.format("%0.1fs", fExtra);
end
if ( "" ~= title ) then
local info = UIDropDownMenu_CreateInfo();
info.text = title;
info.isTitle = true;
UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
end
end
local subMenus = NeedToKnow.BarMenu_SubMenus;
for index, value in ipairs(subMenus[UIDROPDOWNMENU_MENU_VALUE]) do
NeedToKnow.BarMenu_AddButton(barSettings, value, UIDROPDOWNMENU_MENU_VALUE);
end
 
if ( false == barSettings.OnlyMine and UIDROPDOWNMENU_MENU_LEVEL == 2 ) then
NeedToKnow.BarMenu_UncheckAndDisable(2, "bDetectExtends", false);
end
return;
end
if ( false == barSettings.OnlyMine and UIDROPDOWNMENU_MENU_LEVEL == 2 ) then
NeedToKnow.BarMenu_UncheckAndDisable(2, "bDetectExtends", false);
end
return;
end
 
-- show name
if ( barSettings.AuraName ) and ( barSettings.AuraName ~= "" ) then
605,13 → 614,13
local checkName = button:GetName() .. "Check";
local check = getglobal(checkName);
if ( i_bCheck ) then
check:Show();
button.checked = true;
else
check:Hide();
button.checked = false;
end
NeedToKnow.BarMenu_ToggleSetting(button);
check:Show();
button.checked = true;
else
check:Hide();
button.checked = false;
end
NeedToKnow.BarMenu_ToggleSetting(button);
end
end
 
729,24 → 738,38
NeedToKnow.Bar_Update(groupID, barID);
end
 
function MemberDump(v, bIndex)
print("members")
for index, value in pairs(v) do
print(" ", index, value);
end
local mt = getmetatable(v)
if ( mt ) then
print("metatable")
for index, value in pairs(mt) do
print(" ", index, value);
function MemberDump(v, bIndex, filter)
if not v then
print("nil")
return
elseif type(v) == "table" then
print("members")
for index, value in pairs(v) do
if (not filter) or (type(index) == "string" and index:find(filter)) then
print(" ", index, value);
end
end
if ( mt.__index and bIndex) then
print("__index")
for index, value in pairs(mt.__index) do
print(" ", index, value);
end
local mt = getmetatable(v)
if ( mt ) then
print("metatable")
for index, value in pairs(mt) do
if (not filter) or (type(index) == "string" and index:find(filter)) then
print(" ", index, value);
end
end
if ( mt.__index and bIndex) then
print("__index")
for index, value in pairs(mt.__index) do
if (not filter) or (type(index) == "string" and index:find(filter)) then
print(" ", index, value);
end
end
end
end
end
else
print(v)
end
 
end
 
function NeedToKnow.BarMenu_SetColor()
833,6 → 856,7
-- calculate & set new bar width
local newWidth = max(50, ((cursorX - self.oldCursorX)/uiScale + self.oldWidth * group.oldScale)/newScale);
NeedToKnow.SetWidth(groupID, newWidth);
 
end
 
function NeedToKnow.SetWidth(groupID, width)
Kitjan/NeedToKnow/NeedToKnow.xml
5,6 → 5,20
<Script file="NeedToKnow.lua"/>
<Script file="NeedToKnow_Options.lua"/>
 
<Frame name="NeedToKnow_DropDownTemplate" inherits="UIDropDownMenuTemplate" virtual="true">
<Anchors>
<Anchor point="TOP"/>
</Anchors>
<Scripts>
<OnLoad>
UIDropDownMenu_Initialize(this, NeedToKnow.BarMenu_Initialize, "MENU");
</OnLoad>
<OnShow>
UIDropDownMenu_Initialize(this, NeedToKnow.BarMenu_Initialize, "MENU");
</OnShow>
</Scripts>
</Frame>
 
<Frame name="NeedToKnow_GroupTemplate" virtual="true">
<Size>
<AbsDimension x="1" y="1"/>
56,7 → 70,7
</Frames>
</Frame>
 
<StatusBar name="NeedToKnow_BarTemplate" drawLayer="BORDER" toplevel="true" enableMouse="true" virtual="true">
<Frame name="NeedToKnow_BarTemplate" drawLayer="BORDER" toplevel="true" enableMouse="true" virtual="true">
<Size>
<AbsDimension x="271" y="18"/>
</Size>
79,6 → 93,16
</Texture>
</Layer>
<Layer level="ARTWORK">
<Texture name="$parentTexture">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT">
<AbsDimension x="0" y="-0"/>
</Anchor>
<Anchor point="BOTTOM" relativeTo="$parent" relativePoint="BOTTOM">
<AbsDimension x="-0" y="0"/>
</Anchor>
</Anchors>
</Texture>
<FontString name="$parentText" inherits="GameFontHighlight" justifyH="LEFT">
<Size>
<AbsDimension x="180" y="16"/>
128,6 → 152,9
<OnMouseUp>
NeedToKnow.Bar_OnMouseUp(self, button);
</OnMouseUp>
<OnSizeChanged>
NeedToKnow.Bar_OnSizeChanged(self)
</OnSizeChanged>
<OnDragStart>
self:GetParent():StartMoving();
</OnDragStart>
136,22 → 163,7
NeedToKnow.SavePosition(self:GetParent(), self:GetParent():GetID());
</OnDragStop>
</Scripts>
<Frames>
<Frame name="$parentDropDown" inherits="UIDropDownMenuTemplate" hidden="true">
<Anchors>
<Anchor point="TOP"/>
</Anchors>
<Scripts>
<OnLoad>
UIDropDownMenu_Initialize(this, NeedToKnow.BarMenu_Initialize, "MENU");
</OnLoad>
<OnShow>
UIDropDownMenu_Initialize(this, NeedToKnow.BarMenu_Initialize, "MENU");
</OnShow>
</Scripts>
</Frame>
</Frames>
</StatusBar>
</Frame>
 
<Frame name="NeedToKnow_Group1" inherits="NeedToKnow_GroupTemplate" toplevel="true" movable="true" parent="UIParent" id="1">
<Anchors>
Kitjan/NeedToKnow/NeedToKnow.lua
15,6 → 15,7
-- -------------
 
NeedToKnow = {}
 
-- NEEDTOKNOW = {} is defined in the localization file, which must be loaded before this file
 
NEEDTOKNOW.VERSION = "3.1.1"
139,14 → 140,13
 
function NeedToKnow.ExecutiveFrame_OnEvent(self, event, ...)
if ( event == "ADDON_LOADED" and select(1,...) == "NeedToKnow") then
 
if ( not NeedToKnow_Settings ) then
NeedToKnow_Settings = CopyTable(NEEDTOKNOW.DEFAULTS)
NeedToKnow_Settings["Spec"][1]["Groups"][1]["Enabled"] = true
NeedToKnow_Settings["Spec"][2]["Groups"][1]["Enabled"] = true
else
NeedToKnow.SafeUpgrade()
NeedToKnow.Update()
NeedToKnow.UIPanel_Update()
end
 
if ( not NeedToKnow_Settings.BarFont or NeedToKnow_Settings["BarFont"] == "DEFAULT" ) then
156,6 → 156,7
if ( not NeedToKnow_Visible ) then
NeedToKnow_Visible = true
end
 
NeedToKnow.last_cast = {} -- [spell][guidTarget] = { time, dur }
NeedToKnow.nSent = 0
NeedToKnow.totem_drops = {} -- array 1-4 of precise times the totems appeared
163,6 → 164,9
SlashCmdList["NEEDTOKNOW"] = NeedToKnow.SlashCommand
SLASH_NEEDTOKNOW1 = "/needtoknow"
SLASH_NEEDTOKNOW2 = "/ntk"
 
NeedToKnow.Update()
NeedToKnow.UIPanel_Update()
else
local fnName = "ExecutiveFrame_"..event
local fn = NeedToKnow[fnName]
261,6 → 265,21
end
 
 
local function SetStatusBarValue(bar,texture,value)
local pct = value / bar.max_value
texture.cur_value = value
if pct > 1 then pct = 1 end
local w = pct * bar:GetWidth()
if w < 1 then
texture:Hide()
else
texture:SetWidth(pct * bar:GetWidth())
texture:SetTexCoord(0,0,0,1,pct,0,pct,1)
texture:Show()
end
end
 
 
function NeedToKnow.SafeUpgrade()
-- If there had been an error during the previous upgrade, NeedToKnow_Settings
-- may be in an inconsistent, halfway state.
403,7 → 422,7
 
for barID = 1, groupSettings.NumberBars do
local barName = groupName.."Bar"..barID
local bar = _G[barName] or CreateFrame("StatusBar", barName, group, "NeedToKnow_BarTemplate")
local bar = _G[barName] or CreateFrame("Frame", barName, group, "NeedToKnow_BarTemplate")
bar:SetID(barID)
 
if ( barID > 1 ) then
465,6 → 484,7
bar.spark = _G[barName.."Spark"]
bar.text = _G[barName.."Text"]
bar.time = _G[barName.."Time"]
bar.bar1 = _G[barName.."Texture"]
 
local groupSettings = NeedToKnow_Settings["Spec"][NEEDTOKNOW.CURRENTSPEC]["Groups"][groupID]
local barSettings = groupSettings["Bars"][barID]
506,11 → 526,12
 
bar.fixedDuration = tonumber(groupSettings.FixedDuration)
 
bar:SetMinMaxValues(0,1)
bar:SetValue(1)
bar:SetStatusBarTexture(NeedToKnow.LSM:Fetch("statusbar", NeedToKnow_Settings["BarTexture"]))
bar:GetStatusBarTexture():SetHorizTile(false)
bar:GetStatusBarTexture():SetVertTile(false)
bar.max_value = 1
SetStatusBarValue(bar,bar.bar1,1)
bar.bar1:SetTexture(NeedToKnow.LSM:Fetch("statusbar", NeedToKnow_Settings["BarTexture"]))
if ( bar.bar2 ) then
bar.bar2:SetTexture(NeedToKnow.LSM:Fetch("statusbar", NeedToKnow_Settings["BarTexture"]))
end
local fontPath = NeedToKnow_Settings["BarFont"]
if ( fontPath ) then
-- TODO: I'd like to get that 12 from something rather than hard-code it
579,7 → 600,9
NeedToKnow.ClearScripts(bar)
-- Set up the bar to be configured
bar:EnableMouse(1)
bar:SetStatusBarColor(barSettings.BarColor.r, barSettings.BarColor.g, barSettings.BarColor.b, barSettings.BarColor.a)
 
bar.bar1:SetVertexColor(barSettings.BarColor.r, barSettings.BarColor.g, barSettings.BarColor.b)
bar.bar1:SetAlpha(barSettings.BarColor.a)
bar:Show()
bar.spark:Hide()
bar.time:Hide()
590,6 → 613,10
bar.vct:SetWidth( bar:GetWidth() / 16)
bar.vct:Show()
end
if ( bar.bar2 ) then
bar.bar2:Hide()
end
 
local txt=""
if ( barSettings.show_mypip ) then
txt = txt.."* "
679,6 → 706,11
bar:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end
 
function NeedToKnow.Bar_OnSizeChanged(self)
if (self.bar1.cur_value) then SetStatusBarValue(self, self.bar1, self.bar1.cur_value) end
if (self.bar2) then SetStatusBarValue(self, self.bar2, self.bar2.cur_value) end
end
 
function NeedToKnow.Bar_OnEvent(self, event, ...)
if ( event == "COMBAT_LOG_EVENT_UNFILTERED") then
local combatEvent = select(2, ...)
819,15 → 851,9
if ( not bar.bar2 ) then
local n = bar:GetName() .. "Bar2"
bar.bar2 = bar:CreateTexture(n, "ARTWORK")
local tex1 = bar:GetStatusBarTexture()
bar.bar2:SetPoint("TOPLEFT", tex1, "TOPLEFT")
bar.bar2:SetPoint("BOTTOM", tex1, "BOTTOM")
bar.bar2:SetWidth(tex1:GetWidth())
bar.bar2:SetAlpha(tex1:GetAlpha() * 0.5)
 
bar.bar2:SetTexture(NeedToKnow.LSM:Fetch("statusbar", NeedToKnow_Settings["BarTexture"]))
bar.bar2:SetHorizTile(false)
bar.bar2:SetVertTile(false)
bar.bar2:SetPoint("TOPLEFT", bar, "TOPLEFT")
bar.bar2:SetPoint("BOTTOM", bar, "BOTTOM")
bar.bar2:SetWidth(bar:GetWidth())
end
end
 
842,11 → 868,14
NeedToKnow.SizeBackground(bar, false)
end
 
local bShowBar2 = false
bar.bar1:SetVertexColor(bar.settings.BarColor.r, bar.settings.BarColor.g, bar.settings.BarColor.b)
bar.bar1:SetAlpha(bar.settings.BarColor.a)
if ( bar.max_expirationTime and bar.max_expirationTime ~= bar.expirationTime ) then
NeedToKnow.CreateBar2(bar)
bar.bar2:SetTexture(bar.bar1:GetTexture())
bar.bar2:SetVertexColor(bar.settings.BarColor.r, bar.settings.BarColor.g, bar.settings.BarColor.b)
bar.bar2:SetAlpha(bar.settings.BarColor.a * 0.5)
bar.bar2:Show()
bShowBar2 = true
elseif (bar.bar2) then
bar.bar2:Hide()
end
874,7 → 903,7
if ( bar.duration > 0 ) then
-- Configure the main status bar
local duration = bar.fixedDuration or bar.duration
bar:SetMinMaxValues(0, duration)
bar.max_value = duration
 
-- Determine the size of the visual cast bar
if ( bar.settings.vct_enabled ) then
889,8 → 918,9
bar.time:Show()
else
-- Hide the time text and spark for auras with "infinite" duration
bar:SetMinMaxValues(0, 1)
bar:SetValue(1)
bar.max_value = 1
SetStatusBarValue(bar,bar.bar1,1)
if bar.bar2 then SetStatusBarValue(bar,bar.bar2,1) end
 
bar.time:Hide()
bar.spark:Hide()
906,18 → 936,22
if ( not bar.blink ) then
bar.blink=true
bar.blink_phase=1
bar:SetStatusBarColor(settings.MissingBlink.r, settings.MissingBlink.g, settings.MissingBlink.b, settings.MissingBlink.a)
bar.bar1:SetVertexColor(settings.MissingBlink.r, settings.MissingBlink.g, settings.MissingBlink.b)
bar.bar1:SetAlpha(settings.MissingBlink.a)
end
bar.text:SetText(settings.blink_label)
bar.time:Hide()
bar.spark:Hide()
bar:SetMinMaxValues(0, 1)
bar:SetValue(1)
bar.max_value = 1
SetStatusBarValue(bar,bar.bar1,1)
 
if ( bar.icon ) then
bar.icon:Hide()
NeedToKnow.SizeBackground(bar, false)
end
if ( bar.bar2 ) then
bar.bar2:Hide()
end
end
 
function NeedToKnow.GetUtilityTooltips()
1272,6 → 1306,7
 
--bar.duration = tonumber(bar.fixedDuration) or duration
bar.duration = duration
 
bar.expirationTime = expirationTime
bar.buffName = buffName
bar.iconPath = iconPath
1281,10 → 1316,10
bar.max_expirationTime = nil
end
 
-- Mark the bar as not blinking before calling ConfigureVisibleBar,
-- since it calls OnUpdate which checks bar.blink
bar.blink=false
NeedToKnow.ConfigureVisibleBar(bar, count, extended)
bar.blink=false
bar:SetStatusBarColor(settings.BarColor.r, settings.BarColor.g, settings.BarColor.b, settings.BarColor.a)
 
bar:Show()
else
if (settings.bDetectExtends and bar.buffName) then
1348,6 → 1383,8
function NeedToKnow.Bar_OnUpdate(self, elapsed)
local now = GetTime()
if ( now > self.nextUpdate ) then
self.nextUpdate = now + NEEDTOKNOW.UPDATE_INTERVAL
 
if ( self.blink ) then
self.blink_phase = self.blink_phase + NEEDTOKNOW.UPDATE_INTERVAL
if ( self.blink_phase >= 2 ) then
1357,12 → 1394,12
if ( a > 1 ) then
a = 2 - a
end
self:SetStatusBarColor(self.settings.MissingBlink.r, self.settings.MissingBlink.g, self.settings.MissingBlink.b, self.settings.MissingBlink.a * a)
 
self.bar1:SetVertexColor(self.settings.MissingBlink.r, self.settings.MissingBlink.g, self.settings.MissingBlink.b)
self.bar1:SetAlpha(self.settings.MissingBlink.a * a)
return
end
 
self.nextUpdate = now + NEEDTOKNOW.UPDATE_INTERVAL
 
-- WORKAROUND: Although the existence of the enchant is correct at UNIT_INVENTORY_CHANGED
-- the expiry time is not yet correct. So we update the expiration every update :(
local origUnit = self.settings.Unit
1391,7 → 1428,7
end
timeLeft = 0
end
self:SetValue(timeLeft)
SetStatusBarValue(self, self.bar1, timeLeft);
if ( self.settings.show_time ) then
local fn = NeedToKnow[self.settings.TimeFormat]
local oldText = self.time:GetText()
1418,9 → 1455,7
 
if ( self.max_expirationTime ) then
local timeLeft = self.max_expirationTime - GetTime()
local pct = timeLeft / duration;
if ( pct > 1 ) then pct = 1 end
self.bar2:SetWidth(self:GetStatusBarTexture():GetWidth() * pct)
SetStatusBarValue(self, self.bar2, timeLeft)
end
 
if ( self.vct_refresh ) then