Quantcast

2.4.2 alpha 3

Alar of Daggerspine [03-18-15 - 19:13]
2.4.2 alpha 3

Signed-off-by: Alar of Daggerspine <alar@aspide.it>
Filename
CHANGELOG.txt
FollowerCache.lua
FollowerRecruiting.lua
GarrisonCommander-Broker/ldb.lua
GarrisonCommander.lua
MatchMaker.lua
PartyCache.lua
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index bd8b63b..cb64631 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,4 +1,5 @@
 ==GarrisonCommander helps you when choosing the right follower for the right mission==
 * 2.4.2
 Fix: Using a full upgrade token on follower was warning about lost points
-Fix: Possible soloution for a couple of very rare lua errors
\ No newline at end of file
+Fix: Possible soloution for a couple of very rare lua errors
+Feature: Còicking on data broker opens missions report (same as clicking on minimap icon)
\ No newline at end of file
diff --git a/FollowerCache.lua b/FollowerCache.lua
index 278683a..4ac91a4 100644
--- a/FollowerCache.lua
+++ b/FollowerCache.lua
@@ -18,7 +18,10 @@ local format=format
 local tostring=tostring
 local GetItemInfo=GetItemInfo
 local index={}
+local names={}
 local sorted={}
+local threats={}
+local traits={}
 local function keyToIndex(key)
 	if (not Mbase.followers or not next(Mbase.followers)) then
 		Mbase.dirtyList=false
@@ -34,13 +37,30 @@ local function keyToIndex(key)
 	end
 	wipe(index)
 	wipe(sorted)
+	wipe(names)
+	wipe(threats)
+	wipe(traits)
 	for i=1,#Mbase.followers do
 		if Mbase.followers[i].isCollected then
-			index[Mbase.followers[i].followerID]=i
+			local follower=Mbase.followers[i]
+			names[follower.name]=i
+			index[follower.followerID]=i
 			tinsert(sorted,i)
-			if Mbase.followers[i].followerID==key then
+			if follower.followerID==key or follower.name==key then
 				idx=i
 			end
+			if (follower.abilities) then
+				for _,ability in pairs(follower.abilities) do
+					traits[ability.id]=traits[ability.id]or {}
+					tinsert(traits[ability.id],follower.followerID)
+					if (not ability.isTrait) then
+						for id,_ in pairs(ability.counters) do
+							threats[id]=threats[id]or {}
+							tinsert(threats[id],follower.followerID)
+						end
+					end
+				end
+			end
 		end
 	end
 	return idx
@@ -76,15 +96,15 @@ function addon:CanCounter(followerID,id)
 	end
 end
 function addon:HasTrait(followerID,trait)
-	local abilities=self:GetFollowerData(followerID,'abilities')
-	for i=1,#abilities do
-		local ability=abilities[i]
-		if ability.isTrait then
-			if ability.ID==trait then
-				return true
-			end
-		end
-	end
+	local list=traits[trait]
+	if list then return tContains(list,followerID) end
+end
+function addon:HasAbility(followerID,trait)
+	return self:HasTrait(followerID,trait)
+end
+function addon:CanCounter(followerID,threat)
+	local list=threats[threat]
+	if list then return tContains(list,followerID) end
 end
 function addon:GetFollowerData(followerID,key,default)
 	local idx=keyToIndex(followerID)
@@ -134,4 +154,10 @@ function addon:GetFollowerIterator(func)
 			end
 		end
 	end,sorted,0
+end
+function addon:GetFollowersWithTrait(trait)
+	return traits[trait]
+end
+function addon:GetFollowersWithCounterFor(threat)
+	return threats[threat]
 end
\ No newline at end of file
diff --git a/FollowerRecruiting.lua b/FollowerRecruiting.lua
index e69de29..0c693f7 100644
--- a/FollowerRecruiting.lua
+++ b/FollowerRecruiting.lua
@@ -0,0 +1,36 @@
+local me,ns=...
+local addon=ns.addon
+--@debug@
+if LibDebug then LibDebug() end
+--@end-debug@
+local GBF=GarrisonBuildingFrame
+local GBFMap=GBF.MapFrame
+local G=C_Garrison
+local CreateFrame=CreateFrame
+local GARRISON_FOLLOWER_MAX_LEVEL=GARRISON_FOLLOWER_MAX_LEVEL
+local L=ns.L
+local D=ns.D
+local C=ns.C
+local new,del=ns.new,ns.del
+local GRF=GarrisonRecruiterFrame.Pick
+local module=addon:NewModule("RecruitingPage",addon) --#module
+function module:OnInitialize()
+end
+local origGarrisonRecruiterFrame_AddEntryToDropdown=GarrisonRecruiterFrame_AddEntryToDropdown
+function _G.GarrisonRecruiterFrame_AddEntryToDropdown(entry,info,level)
+	info.text = entry.name;
+	info.value = entry.id;
+	info.checked = (GarrisonRecruiterFrame.Pick.dropDownValue == info.value);
+	if (entry.id) then
+		local list=GRF.Title2:GetText()==GARRISON_CHOOSE_THREAT and addon:GetFollowersWithCounterFor(entry.id) or addon:GetFollowersWithTrait(entry.id)
+		if list then
+			info.text=format("%s (%d)",entry.name,#list)
+			info.tooltipText=entry.description.."\n"
+			for i=1,#list do
+				info.tooltipText=info.tooltipText.."\n"..addon:GetFollowerData(list[i],'fullname',L["Some follower"]) .. " " .. addon:GetFollowerStatus(list[i],false,true)
+			end
+
+		end
+	end
+	UIDropDownMenu_AddButton(info, level);
+end
diff --git a/GarrisonCommander-Broker/ldb.lua b/GarrisonCommander-Broker/ldb.lua
index 32f8b9f..cae7bfd 100644
--- a/GarrisonCommander-Broker/ldb.lua
+++ b/GarrisonCommander-Broker/ldb.lua
@@ -76,6 +76,7 @@ dataobj=LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject(me, {
 	type = "data source",
 	label = "Missions ",
 	text=NONE,
+	category = "Interface",
 	icon = "Interface\\ICONS\\ACHIEVEMENT_GUILDPERK_WORKINGOVERTIME"
 })
 function dataobj:OnTooltipShow()
@@ -111,8 +112,12 @@ end
 function dataobj:OnLeave()
 	GameTooltip:Hide()
 end
+function dataobj:OnClick(button)
+	if (button=="LeftButton") then
+		GarrisonLandingPage_Toggle()
+	end
+end
+
 --@debug@
 _G.GACDB=addon
 --@end-debug@
---function dataobj:OnClick(button)
---end
diff --git a/GarrisonCommander.lua b/GarrisonCommander.lua
index 8116386..b9bd42f 100644
--- a/GarrisonCommander.lua
+++ b/GarrisonCommander.lua
@@ -933,9 +933,6 @@ do
 	end
 end
 function addon:ShowMissionControl()
-	ns.xprint("Click1")
-	--if ns.missionautocompleting then return end
-	ns.xprint("Click2")
 	if (not GMC:IsShown()) then
 		GarrisonMissionFrame_SelectTab(999)
 		GMF.FollowerTab:Hide()
@@ -1503,7 +1500,7 @@ end

 function addon:ScriptTrace(hook,frame,...)
 --@debug@
-	ns.xprint("Triggered " .. C(hook,"red").." script on",C(frame,"Azure"),...)
+	pp("Triggered " .. C(hook,"red").." script on",C(frame,"Azure"),...)
 --@end-debug@
 end
 function addon:IsProgressMissionPage()
@@ -1797,9 +1794,6 @@ end
 function addon:SetUp(...)
 	ns.CompletedMissions={}
 	self:FollowerCacheInit()
---@debug@
-	ns.dprint("Setup")
---@end-debug@
 --@alpha@
 	if (not db.alfa.v220) then
 		self:Popup(L["You are using an Alpha version of Garrison Commander. Please post bugs on Curse if you find them"],10)
@@ -1888,9 +1882,6 @@ end
 -- This method is called every time garrison mission panel is open because
 -- when it closes, I remove most of used hooks
 function addon:StartUp(...)
---@debug@
-	ns.dprint("Startup")
---@end-debug@
 	self:GrowPanel()
 	self:Unhook(GMF,"OnShow")
 	if (self:GetBoolean("PIN")) then
@@ -2332,7 +2323,6 @@ end
 function addon:OnShow_FollowerPage(page)
 	self:ShowUpgradeButtons()
 	if not GCFMissions then return end
-	ns.xprint("Onshow")
 	if type(GCFMissions.Header.info)=="table" then
 		self:HookedGarrisonFollowerPage_ShowFollower(page,GCFMissions.Header.info.followerID,true)
 --		local s =self:GetScroller("GFCMissions.Header")
diff --git a/MatchMaker.lua b/MatchMaker.lua
index 80e4b9a..d410122 100644
--- a/MatchMaker.lua
+++ b/MatchMaker.lua
@@ -167,9 +167,10 @@ local function MatchMaker(self,missionID,party,includeBusy,onlyBest)
 	--]]
 	for _,followerID in self:GetFollowerIterator() do
 		--if (not buffed[followerID]) then
-			P:AddFollower(followerID)
+		if P:AddFollower(followerID) then
 			tinsert(scores,format("%s0|%s",self:FollowerScore(mission,followerID),followerID))
 			P:RemoveFollower(followerID)
+		end
 		--end
 	end
 	if #scores > 0 then
diff --git a/PartyCache.lua b/PartyCache.lua
index 409e5cc..27cf93e 100644
--- a/PartyCache.lua
+++ b/PartyCache.lua
@@ -113,7 +113,7 @@ function party:AddFollower(followerID)
 		else
 			ns.xprint("Unable to add",followerID, G.GetFollowerName(followerID),"to",ID,code,self:IsIn(followerID),G.GetFollowerStatus(followerID))
 			ns.xprint(members[1],members[2],members[3])
-			ns.xprint(debugstack(1,6,0))
+			print(debugstack(1,6,0))
 --@end-debug@
 		end
 	end