Quantcast

Added immediate frame, updated license and did some other small fixes.

F16Gaming [01-06-13 - 17:11]
Added immediate frame, updated license and did some other small fixes.
Filename
Broker.lua
Command.lua
Dialogs.lua
ImmediateFrame.lua
KillTrack.lua
KillTrack.toc
MobList.lua
Timer.lua
TimerFrame.lua
TimerFrame.xml
Tools.lua
diff --git a/Broker.lua b/Broker.lua
index 404083d..6fada1a 100644
--- a/Broker.lua
+++ b/Broker.lua
@@ -1,5 +1,5 @@
 --[[
-	* Copyright (c) 2011 by Adam Hellberg.
+	* Copyright (c) 2011-2013 by Adam Hellberg.
 	*
 	* This file is part of KillTrack.
 	*
diff --git a/Command.lua b/Command.lua
index 3a8bbd2..ccd3cee 100644
--- a/Command.lua
+++ b/Command.lua
@@ -1,5 +1,5 @@
 --[[
-	* Copyright (c) 2011 by Adam Hellberg.
+	* Copyright (c) 2011-2013 by Adam Hellberg.
 	*
 	* This file is part of KillTrack.
 	*
@@ -74,6 +74,7 @@ C:Register("__DEFAULT__", function(args)
 	KT:Msg("/kt purge [threshold] - Open dialog to purge entries, specifiying a threshold here is optional.")
 	KT:Msg("/kt reset - Clear the mob database.")
 	KT:Msg("/kt time - Track kills within specified time.")
+	KT:Msg("/kt immediate - Track kills made from this point on.")
 	KT:Msg("/kt threshold <threshold> - Set threshold for kill record notices to show.")
 	KT:Msg("/kt countmode - Toggle between counting group killing blows or your killing blows only.")
 	KT:Msg("/kt - Displays this help message.")
@@ -165,6 +166,8 @@ C:Register({"time", "timer"}, function(args)
 	KT.TimerFrame:Start(s, m, h)
 end)

+C:Register({"immediate", "imm", "i"}, function(args) KT.Immediate:Show() end)
+
 C:Register({"threshold"}, function(args)
 	if #args <= 0 then
 		KT:Msg("Usage: threshold <threshold>")
diff --git a/Dialogs.lua b/Dialogs.lua
index 4649379..6026797 100644
--- a/Dialogs.lua
+++ b/Dialogs.lua
@@ -1,5 +1,5 @@
 --[[
-	* Copyright (c) 2011 by Adam Hellberg.
+	* Copyright (c) 2011-2013 by Adam Hellberg.
 	*
 	* This file is part of KillTrack.
 	*
diff --git a/ImmediateFrame.lua b/ImmediateFrame.lua
new file mode 100644
index 0000000..621680d
--- /dev/null
+++ b/ImmediateFrame.lua
@@ -0,0 +1,111 @@
+--[[
+	* Copyright (c) 2013 by Adam Hellberg.
+	*
+	* This file is part of KillTrack.
+	*
+	* KillTrack is free software: you can redistribute it and/or modify
+	* it under the terms of the GNU General Public License as published by
+	* the Free Software Foundation, either version 3 of the License, or
+	* (at your option) any later version.
+	*
+	* KillTrack is distributed in the hope that it will be useful,
+	* but WITHOUT ANY WARRANTY; without even the implied warranty of
+	* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	* GNU General Public License for more details.
+	*
+	* You should have received a copy of the GNU General Public License
+	* along with KillTrack. If not, see <http://www.gnu.org/licenses/>.
+--]]
+
+local KT = KillTrack
+
+KT.Immediate = {
+	Active = false,
+	Kills = 0
+}
+
+local I = KT.Immediate
+
+local function SetupFrame()
+	if frame then return end
+	local G = KT.Global.IMMEDIATE
+	frame = CreateFrame("Frame", nil, UIParent)
+	frame:Hide()
+	frame:EnableMouse(true)
+	frame:SetMovable(true)
+	if G.POSITION.POINT then
+		frame:SetPoint(G.POSITION.POINT, UIParent, G.POSITION.RELATIVE, G.POSITION.X, G.POSITION.Y)
+	else
+		frame:SetPoint("CENTER")
+	end
+	frame:SetWidth(240)
+	frame:SetHeight(30)
+
+	local bd = {
+		bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
+		edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+		tile = true,
+		edgeSize = 16,
+		tileSize = 32,
+		insets = {
+			left = 2.5,
+			right = 2.5,
+			top = 2.5,
+			bottom = 2.5
+		}
+	}
+
+	frame:SetBackdrop(bd)
+
+	frame:SetScript("OnMouseDown", function(f) f:StartMoving() end)
+	frame:SetScript("OnMouseUp", function(f)
+		f:StopMovingOrSizing()
+		local point, _, relative, x, y = f:GetPoint()
+		G.POSITION.POINT = point
+		G.POSITION.RELATIVE = relative
+		G.POSITION.X = x
+		G.POSITION.Y = y
+	end)
+
+	frame.killLabel = frame:CreateFontString(nil, "OVERLAY", nil)
+	frame.killLabel:SetFont("Fonts\\FRIZQT__.TTF", 16, nil)
+	frame.killLabel:SetWidth(100)
+	--frame.killLabel:SetHeight(24)
+	frame.killLabel:SetPoint("LEFT", frame, "LEFT", 2, 0)
+	frame.killLabel:SetText("Kills so far:")
+
+	frame.killCount = frame:CreateFontString(nil, "OVERLAY", nil)
+	frame.killCount:SetFont("Fonts\\FRIZQT__.TTF", 16, nil)
+	frame.killCount:SetWidth(100)
+	--frame.killCount:SetHeight(24)
+	frame.killCount:SetPoint("RIGHT", frame, "RIGHT", -68, 0)
+	frame.killCount:SetJustifyH("RIGHT")
+	frame.killCount:SetText("0")
+
+	frame.closeButton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
+	frame.closeButton:SetWidth(60)
+	frame.closeButton:SetHeight(24)
+	frame.closeButton:SetPoint("RIGHT", frame, "RIGHT", -3, 0)
+	frame.closeButton:SetText("Close")
+	frame.closeButton:SetScript("OnClick", function() I:Hide() end)
+end
+
+function I:Show()
+	if not frame then SetupFrame() end
+	self.Kills = 0
+	frame.killCount:SetText(self.Kills)
+	frame:Show()
+	self.Active = true
+end
+
+function I:Hide()
+	frame:Hide()
+	self.Kills = 0
+	frame.killCount:SetText(self.Kills)
+	self.Active = false
+end
+
+function I:AddKill()
+	self.Kills = self.Kills + 1
+	frame.killCount:SetText(tostring(self.Kills))
+end
diff --git a/KillTrack.lua b/KillTrack.lua
index 3690d62..71bd053 100644
--- a/KillTrack.lua
+++ b/KillTrack.lua
@@ -1,5 +1,5 @@
 --[[
-	* Copyright (c) 2011 by Adam Hellberg.
+	* Copyright (c) 2011-2013 by Adam Hellberg.
 	*
 	* This file is part of KillTrack.
 	*
@@ -111,19 +111,26 @@ function KT.Events.ADDON_LOADED(self, ...)
 	if type(self.Global.MOBS) ~= "table" then
 		self.Global.MOBS = {}
 	end
-	if type(_G["KILLTRACK_CHAR"]) ~= "table" then
-		_G["KILLTRACK_CHAR"] = {}
+	if type(self.Global.IMMEDIATE) ~= "table" then
+		self.Global.IMMEDIATE = {}
+	end
+	if type(self.Global.IMMEDIATE.POSITION) ~= "table" then
+		self.Global.IMMEDIATE.POSITION = {}
+	end
+	if type(self.Global.BROKER) ~= "table" then
+		self.Global.BROKER = {}
 	end
-	if type(KT.Global.BROKER) ~= "table" then
-		KT.Global.BROKER = {}
+	if type(self.Global.BROKER.SHORT_TEXT) ~= "boolean" then
+		self.Global.BROKER.SHORT_TEXT = false
 	end
-	if type(KT.Global.BROKER.SHORT_TEXT) ~= "boolean" then
-		KT.Global.BROKER.SHORT_TEXT = false
+	if type(_G["KILLTRACK_CHAR"]) ~= "table" then
+		_G["KILLTRACK_CHAR"] = {}
 	end
 	self.CharGlobal = _G["KILLTRACK_CHAR"]
 	if type(self.CharGlobal.MOBS) ~= "table" then
 		self.CharGlobal.MOBS = {}
 	end
+	self.PlayerName = UnitName("player")
 	self:Msg("AddOn Loaded!")
 	self.Session.Start = time()
 	self.Broker:OnLoad()
@@ -133,42 +140,43 @@ function KT.Events.COMBAT_LOG_EVENT_UNFILTERED(self, ...)
 	local event = (select(2, ...))
 	if event == "SWING_DAMAGE" or event == "RANGE_DAMAGE" or event == "SPELL_DAMAGE" then
 		local s_name = tostring((select(5, ...)))
-		local guid = (select(8, ...))
+		local t_guid = (select(8, ...))
 		--local t_id = tonumber(KTT:GUIDToID((select(8, ...))))
-		if FirstDamage[guid] == nil then
+		if FirstDamage[t_guid] == nil then
 			-- s_name is (probably) the player who first damaged this mob and probably has the tag
-			FirstDamage[guid] = s_name
+			FirstDamage[t_guid] = s_name
 		end

-		LastDamage[guid] = s_name
+		LastDamage[t_guid] = s_name

-		if DamageValid[guid] == nil then
+		if DamageValid[t_guid] == nil then
 			-- if DamageValid returns true for a GUID, we can tell with 100% certainty that it's valid
 			-- But this relies on one of the valid unit names currently being the damaged mob
 			-- Or if it's false, we can tell with 100% certainty that someone else tagged the mob

-			local unit = FindUnitByGUID(guid)
+			local t_unit = FindUnitByGUID(t_guid)

-			if not unit then return end
+			if not t_unit then return end

-			local tapped = UnitIsTapped(unit)
+			local tapped = UnitIsTapped(t_unit)

 			if not tapped then return end

-			DamageValid[guid] = tapped and UnitIsTappedByPlayer(unit)
+			DamageValid[t_guid] = tapped and UnitIsTappedByPlayer(t_unit)
 		end

 		return
 	end

 	if event ~= "UNIT_DIED" then return end
+
 	-- Perform solo/group checks
-	local guid = (select(8, ...))
-	local id = KTT:GUIDToID(guid)
+	local t_guid = (select(8, ...))
+	local t_id = KTT:GUIDToID(t_guid)
 	local name = tostring((select(9, ...)))
-	local firstDamage = FirstDamage[guid] or "<No One>"
-	local lastDamage = LastDamage[guid] or "<No One>"
-	local firstByPlayer = firstDamage == UnitName("player") or firstDamage == UnitName("pet")
+	local firstDamage = FirstDamage[t_guid] or "<No One>"
+	local lastDamage = LastDamage[t_guid] or "<No One>"
+	local firstByPlayer = firstDamage == (self.PlayerName or UnitName("player")) or firstDamage == UnitName("pet")
 	local firstByGroup = self:IsInGroup(firstDamage)
 	local lastByPlayer = lastDamage == UnitName("player") or lastDamage == UnitName("pet")
 	local pass
@@ -178,8 +186,8 @@ function KT.Events.COMBAT_LOG_EVENT_UNFILTERED(self, ...)
 	-- Scenario: You deal the killing blow to an already tapped mob <- Would count as kill with current code

 	-- if DamageValid[guid] is set, it can be used to decide if the kill was valid with 100% certainty
-	if DamageValid[guid] ~= nil then
-		pass = DamageValid[guid]
+	if DamageValid[t_guid] ~= nil then
+		pass = DamageValid[t_guid]
 	else -- The one who dealt the very first bit of damage was probably the one who got the tag on the mob
 		-- This should apply in most (if not all) situations and is probably a safe fallback when we couldn't retrieve tapped status from GUID->Unit
 		pass = firstByPlayer or firstByGroup
@@ -189,10 +197,10 @@ function KT.Events.COMBAT_LOG_EVENT_UNFILTERED(self, ...)
 		pass = false -- Player or player's pet did not deal the killing blow and addon only tracks player kills
 	end

-	if not pass or id == 0 then return end
-	FirstDamage[guid] = nil
-	DamageValid[guid] = nil
-	self:AddKill(id, name)
+	if not pass or t_id == 0 then return end
+	FirstDamage[t_guid] = nil
+	DamageValid[t_guid] = nil
+	self:AddKill(t_id, name)
 	if self.Timer:IsRunning() then
 		self.Timer:SetData("Kills", self.Timer:GetData("Kills", true) + 1)
 	end
@@ -261,6 +269,9 @@ function KT:AddKill(id, name)
 		self:Msg(("Updated %q, new kill count: %d. Kill count on this character: %d"):format(name, self.Global.MOBS[id].Kills, self.CharGlobal.MOBS[id].Kills))
 	end
 	self:AddSessionKill(name)
+	if self.Immediate.Active then
+		self.Immediate:AddKill()
+	end
 	if type(self.Global.MOBS[id].AchievCount) ~= "number" then
 		self.Global.MOBS[id].AchievCount = floor(self.Global.MOBS[id].Kills / self.Global.ACHIEV_THRESHOLD)
 		if self.Global.MOBS[id].AchievCount >= 1 then
diff --git a/KillTrack.toc b/KillTrack.toc
index 3ad7200..39a1153 100644
--- a/KillTrack.toc
+++ b/KillTrack.toc
@@ -20,4 +20,5 @@ MobList.lua
 Timer.lua
 TimerFrame.lua
 TimerFrame.xml
+ImmediateFrame.lua
 Broker.lua
diff --git a/MobList.lua b/MobList.lua
index a914bba..f131905 100644
--- a/MobList.lua
+++ b/MobList.lua
@@ -1,5 +1,5 @@
 --[[
-	* Copyright (c) 2011 by Adam Hellberg.
+	* Copyright (c) 2011-2013 by Adam Hellberg.
 	*
 	* This file is part of KillTrack.
 	*
diff --git a/Timer.lua b/Timer.lua
index ec1ea07..c70de81 100644
--- a/Timer.lua
+++ b/Timer.lua
@@ -1,4 +1,21 @@
---
+--[[
+	* Copyright (c) 2011-2013 by Adam Hellberg.
+	*
+	* This file is part of KillTrack.
+	*
+	* KillTrack is free software: you can redistribute it and/or modify
+	* it under the terms of the GNU General Public License as published by
+	* the Free Software Foundation, either version 3 of the License, or
+	* (at your option) any later version.
+	*
+	* KillTrack is distributed in the hope that it will be useful,
+	* but WITHOUT ANY WARRANTY; without even the implied warranty of
+	* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	* GNU General Public License for more details.
+	*
+	* You should have received a copy of the GNU General Public License
+	* along with KillTrack. If not, see <http://www.gnu.org/licenses/>.
+--]]

 KillTrack.Timer = {
 	Time = {
diff --git a/TimerFrame.lua b/TimerFrame.lua
index 3613ef7..682aabd 100644
--- a/TimerFrame.lua
+++ b/TimerFrame.lua
@@ -1,5 +1,5 @@
 --[[
-	* Copyright (c) 2011 by Adam Hellberg.
+	* Copyright (c) 2011-2013 by Adam Hellberg.
 	*
 	* This file is part of KillTrack.
 	*
diff --git a/TimerFrame.xml b/TimerFrame.xml
index 9aeabbc..5a186e8 100644
--- a/TimerFrame.xml
+++ b/TimerFrame.xml
@@ -1,5 +1,5 @@
 <!--
-	* Copyright (c) 2011 by Adam Hellberg.
+	* Copyright (c) 2011-2013 by Adam Hellberg.
 	*
 	* This file is part of KillTrack.
 	*
@@ -148,7 +148,7 @@
 			</Layer>
 		</Layers>
 		<Frames>
-			<Button name="$parent_CancelButton" inherits="UIPanelButtonTemplate" text="Cancel">
+			<Button name="$parent_CancelButton" inherits="UIPanelButtonTemplate" text="Stop">
 				<Size>
 					<AbsDimension x="60" y="16" />
 				</Size>
diff --git a/Tools.lua b/Tools.lua
index 899c9b9..ac517f2 100644
--- a/Tools.lua
+++ b/Tools.lua
@@ -1,5 +1,5 @@
 --[[
-	* Copyright (c) 2011 by Adam Hellberg.
+	* Copyright (c) 2011-2013 by Adam Hellberg.
 	*
 	* This file is part of KillTrack.
 	*