--stat ids --588 - Total --383 - arena general --1111 - 2v2 --1110 - 3v3 --1109 - 5v5 --382 - bg general --1113 - alterac valles --1114 - arathi basin --1112 - eye of the storm --4779 - isle of conquest --1486 - strand of the ancients --1115 - warsong gulch --5795 - twin peaks --5796 - the battle of gineas --381 - world local dailystats = {}; local config = {}; local initdone = false; --dirty hack hiding stuff remap = {}; --need cleanup remove not needed stuff leftover from the template local listinfo = { [1] = {"Misc",true,true,false,false,nil,nil }, [2] = {"Total",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(2) end,function () return GetStatistic(588) end,nil }, [3] = {"World",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(3) end,function () return GetStatistic(381) end,nil }, [4] = {"Arena",true,true,false,false,nil,nil }, [5] = {"Total",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(5) end,function () return GetStatistic(383) end,nil }, [6] = {"2v2",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(6) end,function () return GetStatistic(1111) end,nil }, [7] = {"3v3",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(7) end,function () return GetStatistic(1110) end,nil }, [8] = {"5v5",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(8) end,function () return GetStatistic(1109) end,nil }, [9] = {"Battleground",true,true,false,false,nil,nil }, [10] = {"Total",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(10) end,function () return GetStatistic(382) end,nil }, [11] = {"Alterac Valley",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(11) end,function () return GetStatistic(1113) end,nil }, [12] = {"Arathi Basin",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(12) end,function () return GetStatistic(1114) end,nil }, [13] = {"Eye of the Storm",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(13) end,function () return GetStatistic(1112) end,nil }, [14] = {"Isle of Conquest",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(14) end,function () return GetStatistic(4779) end,nil }, [15] = {"Strand of the Ancients",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(15) end,function () return GetStatistic(1486) end,nil }, [16] = {"Warsong Gulch",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(16) end,function () return GetStatistic(1115) end,nil }, [17] = {"The Battle for Gilneas",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(17) end,function () return GetStatistic(5796) end,nil }, [18] = {"Twin Peaks",false,true,false,false,function () return HonorKillTab_GetTodayStatistic(18) end,function () return GetStatistic(5795) end,nil }, } local function remap_update() local hide = false; local i2 = 1; remap = {}; for i=1,18 do if(listinfo[i][2]==true and listinfo[i][3]==false) then hide = true; remap[i2] = i; i2=i2+1; elseif(listinfo[i][2]==true and listinfo[i][3]==true) then hide = false; remap[i2] = i; i2=i2+1; elseif(listinfo[i][2]==false and hide==false) then remap[i2] = i; i2=i2+1; end end end function HonorKillTab_GetTodayStatistic (index) if(initdone == false) then return end; local curval = tonumber(listinfo[index][7]()); if(type(curval)~="number") then return "--"; end local retval = curval - dailystats[index]; if(retval == 0) then retval = "--"; end return retval; end function HonorKillTab_OnClick(self, button, down) if ( self.isHeader ) then if ( self.isExpanded ) then self.IsExpanded = false; listinfo[remap[self.index]][3] = false; config[remap[self.index]] = false; else self.IsExpanded = true; listinfo[remap[self.index]][3] = true; config[remap[self.index]] = true end remap_update(); end HonorKillTab_Update(); end local function GetHKs(index) if(listinfo[index]) then return unpack(listinfo[index]); else return nil; end end local function HideStuff(self) local index = self:GetID() PanelTemplates_SetTab(self:GetParent(), index); --self:GetParent().lastSelectedTab = self; PVPFrameRightButton:Hide(); PVPFrame.panel1:Hide(); PVPFrame.panel2:Hide(); PVPFrame.panel3:Hide(); PVPFrame.panel4:Hide(); PVPFrame.lowLevelFrame:Hide(); PVPFrameLeftButton:Hide(); PVPFrameTitleText:SetText(self:GetText()); PVPFrame.Inset:SetPoint("TOPLEFT", PANEL_INSET_LEFT_OFFSET, PANEL_INSET_ATTIC_OFFSET); PVPFrame.topInset:Hide(); end function PVPHKFrame_OnLoad() PVPHKFrameContainerScrollBar.Show = function (self) PVPHKFrameContainer:SetPoint("BOTTOMRIGHT", PVPFrameInset, "BOTTOMRIGHT", -23, 4); for _, button in next, _G["PVPHKFrameContainer"].buttons do button:SetWidth(295); end PVPHKFrameContainer.scrollChild:SetWidth(295); getmetatable(self).__index.Show(self); end PVPHKFrameContainerScrollBar.Hide = function (self) PVPHKFrameContainer:SetPoint("BOTTOMRIGHT", PVPFrameInset, "BOTTOMRIGHT", -4, 4); for _, button in next, PVPHKFrameContainer.buttons do button:SetWidth(317); end PVPHKFrameContainer.scrollChild:SetWidth(317); getmetatable(self).__index.Hide(self); end PVPHKFrameContainer.update = HonorKillTab_Update; end --need cleanup remove not needed stuff leftover from the template function HonorKillTabButton_OnLoad(self) local name = self:GetName(); self.count = _G[name.."Count"]; self.name = _G[name.."Name"]; self.icon = _G[name.."Icon"]; self.check = _G[name.."Check"]; self.expandIcon = _G[name.."ExpandIcon"]; self.highlight = _G[name.."Highlight"]; self.stripe = _G[name.."Stripe"]; end --need cleanup remove not needed stuff leftover from the template function HonorKillTab_Update() if (not PVPHKFrameContainer.buttons) then return; end local buttons = PVPHKFrameContainer.buttons; local button = buttons[1]; local scrollFrame = PVPHKFrameContainer; local offset = HybridScrollFrame_GetOffset(scrollFrame); local buttons = scrollFrame.buttons; local numButtons = #buttons; local name, isHeader, isExpanded, isUnused, isWatched, count, icon; local button, index; local hidebuttons = false; local displayedHeight=0; for i=1, numButtons do index = offset+i; name, isHeader, isExpanded, isUnused, isWatched, count, icon = GetHKs(remap[index]); button = buttons[i]; button.check:Hide(); if ( not name or name == "") then button:Hide(); --elseif (isHeader == false and hidebuttons==true) then --button:Hide(); else if ( isHeader ) then button.categoryLeft:Show(); button.categoryRight:Show(); button.categoryMiddle:Show(); button.expandIcon:Show(); button.count:SetText(""); button.icon:SetText(""); if ( isExpanded ) then hidebuttons = false; button.expandIcon:SetTexCoord(0.5625, 1, 0, 0.4375); else hidebuttons = true; button.expandIcon:SetTexCoord(0, 0.4375, 0, 0.4375); end button.highlight:SetTexture("Interface\\TokenFrame\\UI-TokenFrame-CategoryButton"); button.highlight:SetPoint("TOPLEFT", button, "TOPLEFT", 3, -2); button.highlight:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -3, 2); button.name:SetText(name); button.name:SetFontObject("GameFontNormal"); button.name:SetPoint("LEFT", 22, 0); button.itemID = nil; --button.LinkButton:Hide(); else button.categoryLeft:Hide(); button.categoryRight:Hide(); button.categoryMiddle:Hide(); button.expandIcon:Hide(); button.count:SetText(count()); button.icon:SetText(icon()); if ( isWatched ) then button.check:Show(); end button.highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight"); button.highlight:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0); button.highlight:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 0, 0); --Gray out the text if the count is 0 if ( count == 0 ) then button.count:SetFontObject("GameFontDisable"); button.name:SetFontObject("GameFontDisable"); else button.count:SetFontObject("GameFontHighlight"); button.name:SetFontObject("GameFontHighlight"); end button.name:SetText(name); button.name:SetPoint("LEFT", 11, 0); button.itemID = itemID; --button.LinkButton:Show(); end --Manage highlight if ( name == PVPHKFrame.selectedToken ) then PVPHKFrame.selectedID = index; button:LockHighlight(); else button:UnlockHighlight(); end button.index = index; button.isHeader = isHeader; button.isExpanded = isExpanded; button.isUnused = isUnused; button.isWatched = isWatched; button:Show(); end displayedHeight = displayedHeight + button:GetHeight(); end local totalHeight = #listinfo * (button:GetHeight()); HybridScrollFrame_Update(scrollFrame, totalHeight, displayedHeight); end --local local f = CreateFrame("Button","PVPFrameTab5",PVPFrame,"CharacterFrameTabButtonTemplate"); local function ShowHonorKillTab(self) HideStuff(self); PVPHKFrame:Show(); if (not PVPHKFrameContainer.buttons) then HybridScrollFrame_CreateButtons(PVPHKFrameContainer, "HonorKillTabButtonTemplate", 1, -2, "TOPLEFT", "TOPLEFT", 0, 0); end HonorKillTab_Update(); end local function HideHonorKillTab(self) _G[f:GetName().."LeftDisabled"]:Hide(); _G[f:GetName().."MiddleDisabled"]:Hide(); _G[f:GetName().."RightDisabled"]:Hide(); _G[f:GetName().."Left"]:Show(); _G[f:GetName().."Middle"]:Show(); _G[f:GetName().."Right"]:Show(); PVPHKFrame:Hide(); end --relaxed checking for new day only on load and when getting loading screens local function resetdaily() local _,month, day, year = CalendarGetDate(); local ndate = month..day..year; if(not dailystats["cdate"] or dailystats["cdate"] ~= ndate) then for i=1,18 do if(listinfo[i][2] == false) then local num = tonumber(listinfo[i][7]()); if(type(num) ~= "number") then num = 0; end dailystats[i] = num; end end dailystats["cdate"] = ndate; end initdone = true; end local function eventhandler (self,event,...) if(event=="PLAYER_ENTERING_WORLD") then resetdaily(); elseif(event =="ADDON_LOADED") then local arg1 = ...; if(arg1=="HonorKillTab") then if not (HonorKillCounter) then HonorKillCounter = {}; HonorKillCounter["daily"] = {}; HonorKillCounter["config"] = {}; end dailystats = HonorKillCounter["daily"]; config = HonorKillCounter["config"]; setmetatable(config, { __index = function(t,v) t[v] = true; return true; end }); for k,v in pairs(config) do listinfo[k][3] = v; end remap_update(); if(CanShowAchievementUI()) then f:UnregisterEvent("RECEIVED_ACHIEVEMENT_LIST"); f:RegisterEvent("PLAYER_ENTERING_WORLD"); resetdaily(); end f:UnregisterEvent("ADDON_LOADED"); PanelTemplates_SetNumTabs(PVPFrame, 5) --increase the numtabs of the pvpframe so the tab button highlighting is handled end elseif(event == "RECEIVED_ACHIEVEMENT_LIST") then if(CanShowAchievementUI()) then f:UnregisterEvent("RECEIVED_ACHIEVEMENT_LIST"); f:RegisterEvent("PLAYER_ENTERING_WORLD"); resetdaily(); end end end f:SetText("Honor Kills"); f:SetID(5); --f:SetPoint("LEFT","PVPFrameTab4","RIGHT",-15,0); f:SetPoint("BOTTOMLEFT","PVPFrameTab1","BOTTOMLEFT",10,-26); f:SetFrameStrata("LOW") f:SetScript("OnClick",ShowHonorKillTab); f:SetScript("OnEvent",eventhandler); --f:RegisterEvent("PLAYER_PVP_KILLS_CHANGED"); f:RegisterEvent("RECEIVED_ACHIEVEMENT_LIST"); f:RegisterEvent("ADDON_LOADED"); f:Show(); hooksecurefunc("PVPFrame_TabClicked",HideHonorKillTab); PVPHKFrame_OnLoad();