Quantcast

Feature: Level added to follower line

Alar of Daggerspine [11-21-14 - 21:11]
Feature: Level added to follower line
Feature: All counterd traits listed on the same line
Feature: For "In mission" follower time letf is shown instead of "In
mission"
Feature: Trait related lines are now silver, while abilities related are
Blue
Feature: Mission panel can now optionally be relocked
Feature: You can select to ignore "busy" followers

Signed-off-by: Alar of Daggerspine <alar@aspide.it>
Filename
GarrisonCommander.lua
GarrisonCommander.toc
RelNotes.lua
diff --git a/GarrisonCommander.lua b/GarrisonCommander.lua
index 3598e81..053ab7e 100644
--- a/GarrisonCommander.lua
+++ b/GarrisonCommander.lua
@@ -8,34 +8,37 @@ local C=LibStub("AlarCrayon-3.0"):GetColorTable()
 local addon=LibStub("AlarLoader-3.0")(__FILE__,me,ns):CreateAddon(me,true) --#Addon
 local print=ns.print or print
 local debug=ns.debug or print
+local dump=ns.dump or print
 --@debug@
 ns.debugEnable('on')
 --@end-debug@
 -----------------------------------------------------------------
 local followerIndexes
 local followers
-local GMF=GarrisonMissionFrame
-local GMFFollowers=GarrisonMissionFrameFollowers
-local GMFMissions=GarrisonMissionFrameMissions
-local GMFTab1=GarrisonMissionFrameTab1
-local GMFTab2=GarrisonMissionFrameTab2
-function addon:dump(...)
-	print("dump",...)
-end
+local compactTooltip=true
+local GMF
+local GMFFollowers
+local GMFMissions
+local GMFTab1
+local GMFTab2
+local GMFMissionsTab1
+local GMFMissionsTab2
+local GARRISON_FOLLOWER_WORKING=GARRISON_FOLLOWER_WORKING
+local GARRISON_FOLLOWER_ON_MISSION=GARRISON_FOLLOWER_ON_MISSION
+local AVAILABLE=AVAILABLE
+local timers={}
 function addon:AddLine(icon,name,status,r,g,b,...)
-	local r2,g2,b2=C.Green()
-	if (status) then
-		r2,g2,b2=C.Red()
+	local r2,g2,b2=C.Red()
+	if (status==AVAILABLE) then
+		r2,g2,b2=C.Green()
+	elseif (status==GARRISON_FOLLOWER_WORKING) then
+		r2,g2,b2=C.Orange()
 	end
 	--GameTooltip:AddDoubleLine(name, status or AVAILABLE,r,g,b,r2,g2,b2)
 	--GameTooltip:AddTexture(icon)
-	GameTooltip:AddDoubleLine("|T" .. tostring(icon) .. ":0|t  " .. name, status or AVAILABLE,r,g,b,r2,g2,b2)
+	GameTooltip:AddDoubleLine(icon and "|T" .. tostring(icon) .. ":0|t  " .. name or name, status,r,g,b,r2,g2,b2)
 end
-function addon:TooltipAdder(missionID)
---@debug@
-	GameTooltip:AddLine("ID:" .. tostring(missionID))
---@end-debug@
-	local _,_,_,perc=C_Garrison.GetPartyMissionInfo(missionID)
+function addon:GetDifficultyColor(perc)
 	local difficulty='impossible'
 	if (perc > 99) then
 			difficulty='trivial'
@@ -46,36 +49,91 @@ function addon:TooltipAdder(missionID)
 	elseif(perc>34) then
 			difficulty='verydifficult'
 	end
-	local q=QuestDifficultyColors[difficulty]
+	return QuestDifficultyColors[difficulty]
+end
+function addon:TooltipAdder(missionID)
+--@debug@
+	GameTooltip:AddLine("ID:" .. tostring(missionID))
+--@end-debug@
+	local perc=select(4,C_Garrison.GetPartyMissionInfo(missionID))
+	local q=self:GetDifficultyColor(perc)
 	GameTooltip:AddLine(format(GARRISON_MISSION_PERCENT_CHANCE,perc),q.r,q.g,q.b)
-	GameTooltip:AddLine(GARRISON_FOLLOWER_CAN_COUNTER)
 	local buffed=self:NewTable()
 	local traited=self:NewTable()
+	local buffs=self:NewTable()
+	local traits=self:NewTable()
 	for id,d in pairs(C_Garrison.GetBuffedFollowersForMission(missionID)) do
 		buffed[id]=d
 	end
 	for id,d in pairs(C_Garrison.GetFollowersTraitsForMission(missionID)) do
-		traited[id]=d
+		for x,y in pairs(d) do
+			if (y.traitID~=236) then --Ignore hearthstone traits
+				traited[id]=d
+				break
+			end
+		end
 	end
 	local followerList=GarrisonMissionFrameFollowers.followersList
 	for j=1,#followerList do
 		local index=followerList[j]
 		local follower=followers[index]
-		if (not follower.garrFollowerID) then return end
-		local b=buffed[follower.followerID]
-		if (b) then
-			for _,ability in pairs(b) do
-				self:AddLine(ability.icon,follower.name,follower.status,C.Azure())
+		if (not follower.isCollected) then break end
+		if (follower.status and self:GetBoolean('IGM')) then
+		else
+			local id=follower.followerID
+			local b=buffed[id]
+			local t=traited[id]
+			local followerBias = C_Garrison.GetFollowerBiasForMission(missionID,id);
+			local formato=C("%3d","White")
+			if (followerBias==-1) then
+				formato=C("%3d","Red")
+			elseif (followerBias < 0) then
+				formato=C("%3d","Orange")
 			end
-		end
-		local t=traited[follower.followerID]
-		if (t) then
-			for _,ability in pairs(t) do
-				self:AddLine(ability.icon,follower.name,follower.status,C.Orange())
+			formato=formato.." %s"
+--@debug@
+			formato=formato .. " 0x+(0*8)  " .. id:sub(11)
+--@end-debug
+			if (b) then
+				if (not buffs[id]) then
+					buffs[id]={name=format(formato,follower.level,follower.name),status=(follower.status or AVAILABLE)}
+				end
+				for _,ability in pairs(b) do
+					buffs[id].name=buffs[id].name .. " |T" .. tostring(ability.icon) .. ":0|t"
+				end
+			end
+			if (t) then
+				if (not traits[id]) then
+					traits[id]={name=format(formato,follower.level,follower.name),status=follower.status or AVAILABLE}
+				end
+				for _,ability in pairs(t) do
+					traits[id].name=traits[id].name .. " |T" .. tostring(ability.icon) .. ":0|t"
+				end
 			end
 		end
 	end
+--@debug@
+-- Working on calculating max possible success percent
+	debug("Tooltip generation")
+	_G.MISSION=select(8,C_Garrison.GetMissionInfo(missionID))
+	_G.TRAITS=traited
+	_G.BUFFS=buffed
+--@end-debug@
+	if (next(traits) or next(buffs) ) then
+		GameTooltip:AddLine(GARRISON_FOLLOWER_CAN_COUNTER)
+		for id,v in pairs(traits) do
+			local status=(v.status == GARRISON_FOLLOWER_ON_MISSION and (timers[id] or GARRISON_FOLLOWER_ON_MISSION)) or v.status
+			self:AddLine(nil,v.name,status,C.Silver())
+		end
+		for id,v in pairs(buffs) do
+			local status=(v.status == GARRISON_FOLLOWER_ON_MISSION and (timers[id] or GARRISON_FOLLOWER_ON_MISSION)) or v.status
+			self:AddLine(nil,v.name,status,C.Azure())
+		end
+	end
 	self:DelTable(buffed)
+	self:DelTable(traited)
+	self:DelTable(buffs)
+	self:DelTable(traits)
 end
 function addon:FillFollowersList()
 	if (GarrisonFollowerList_UpdateFollowers) then
@@ -84,28 +142,104 @@ function addon:FillFollowersList()
 end
 function addon:CacheFollowers()
 	followers=C_Garrison.GetFollowers()
+	self:GetRunningMissionData()
+end
+function addon:GetRunningMissionData()
+	local list=GarrisonMissionFrame.MissionTab.MissionList
+	C_Garrison.GetInProgressMissions(list.inProgressMissions);
+	--C_Garrison.GetAvailableMissions(list.availableMissions);
+	wipe(timers)
+	if (#list.inProgressMissions > 0) then
+		for i,mission in pairs(list.inProgressMissions) do
+			for _,id in pairs(mission.followers) do
+				timers[id]=mission.timeLeft
+			end
+		end
+	end
+end
+function addon:ADDON_LOADED(event,addon)
+	if (addon=="Blizzard_GarrisonUI") then
+		self:UnregisterEvent("ADDON_LOADED")
+		self:Init()
+	end
 end

+function addon:ApplyLMF(value)
+	print("LMF",value)
+	if (not GMF) then return end
+	if (value) then
+		GMF:SetScript("OnDragStart",nil)
+		GMF:SetScript("OnDragStop",nil)
+		GMF:ClearAllPoints()
+		GMF:SetPoint("CENTER",UIParent)
+		GMF:SetMovable(false)
+	else
+		GMF:SetMovable(true)
+		GMF:ClearAllPoints()
+		if (self.db.global.a1) then
+			GMF:SetPoint(self.db.global.a1,db.global.ref or UIParent,self.db.global.a2,self.db.global.x,self.db.global.y)
+		end
+		GMF:SetClampedToScreen(true)
+		GMF:RegisterForDrag("LeftButton")
+		GMF:SetScript("OnDragStart",function(frame) frame:StartMoving() end)
+		GMF:SetScript("OnDragStop",function(frame)
+			frame:StopMovingOrSizing()
+			self.db.global.a1,db.global.ref,self.db.global.a2,self.db.global.x,self.db.global.y=self:GetPoint(1)
+		end)
+	end
+end
 function addon:OnInitialized()
-	self:FillFollowersList()
-	self:CacheFollowers()
+	self.OptionsTable.args.on=nil
+	self.OptionsTable.args.off=nil
+	self.OptionsTable.args.standby=nil
+	self:RegisterEvent("ADDON_LOADED")
+	self:AddToggle("LMF",false,L["Lock Garrison Mission Panel"]).width="full"
+	self:AddToggle("IGM",false,L["Ignore followers On mission"]).width="full"
 	self:loadHelp()
-end
-function addon:OnDisabled()
-	self:UnhookAll()
+	return true
 end
 local hooks={
 	"GarrisonMissionList_Update",
 	"GarrisonMissionButton_OnEnter",
 	"GarrisonFollowerList_OnShow",
 }
-function addon:GarrisonMissionListTab_OnClick(frame, button)
-	if (frame:GetID()==1) then
-		self:CacheFollowers()
+function addon:ScriptTrace(hook,frame,...)
+	print("Triggered script on",frame:GetName(),...)
+	return self.hooks[frame][hook](frame)
+end
+function addon:postHookScript(frame,hook,method)
+	if (method) then
+		self:HookScript(frame,hook,
+		function(frame,...)
+			local t={self.hooks[frame][hook](frame,...)}
+			self[method](self,frame,...)
+			return unpack(t)
+		end)
+	else
+		return self:HookScript(frame,hook,function(...) addon:ScriptTrace(hook,...) end)
 	end
-	self.hooks[frame].OnClick(frame)
 end
-function addon:OnEnabled()
+function addon:preHookScript(frame,hook,method)
+	if (method) then
+		self:HookScript(frame,hook,
+		function(frame,...)
+			self[method](self,frame,...)
+			return self.hooks[frame][hook](frame,...)
+		end)
+	else
+		return self:HookScript(frame,hook,function(...) addon:ScriptTrace(hook,...) end)
+	end
+end
+function addon:Init()
+	GMF=GarrisonMissionFrame
+	GMFFollowers=GarrisonMissionFrameFollowers
+	GMFMissions=GarrisonMissionFrameMissions
+	GMFTab1=GarrisonMissionFrameTab1
+	GMFTab2=GarrisonMissionFrameTab2
+	GMFMissionsTab1=GarrisonMissionFrameMissionsTab1
+	GMFMissionsTab2=GarrisonMissionFrameMissionsTab2
+	self:FillFollowersList()
+	self:CacheFollowers()
 	for _,f in pairs(hooks) do
 		self[f]=function(...) debug(f,...) end
 		self:SecureHook(f,f)
@@ -114,11 +248,34 @@ function addon:OnEnabled()
 	self:SecureHook("GarrisonFollowerList_UpdateFollowers","CacheFollowers")
 	self:HookScript(GMFTab1,"OnClick","GarrisonMissionListTab_OnClick")
 	self:HookScript(GMFTab2,"OnClick","GarrisonMissionListTab_OnClick")
-	GMF:SetMovable(true)
-	GMF:RegisterForDrag("LeftButton")
-	GMF:SetScript("OnDragStart",function(self) self:StartMoving() end)
-	GMF:SetScript("OnDragStop",function(self) self:StopMovingOrSizing() end)
+	self:preHookScript(GMFMissions,"OnShow")
+	self:preHookScript(GMFMissionsTab1,"OnClick")
+	self:preHookScript(GMFMissionsTab2,"OnClick")
+	if (not self:GetBoolean("LMF")) then
+		self:ApplyLMF(false)
+	end
+	compactTooltip=self:GetBoolean("CT")
+end
+
+function addon:GarrisonMissionListTab_OnClick(frame, button)
+	local id=frame:GetID()
+	if (id==1) then
+		self:CacheFollowers()
+	end
+	self.hooks[frame].OnClick(frame)
+	GarrisonMissionFrame_SelectTab(id);
+	if (true) then return end
+	if (id == 1)  then
+			GMF:SetWidth(1600)
+			GMFMissions:SetWidth(890+1600-1250)
+			GMFFollowers:Show()
+			GMFMissions:ClearAllPoints()
+			GMFMissions:SetPoint("TOPLEFT",GMF,"TOPLEFT",GMFFollowers:GetWidth()+35,-65)
+	else
+			GMF:SetWidth(930)
+	end
 end
+
 --@do-not-package@
 if (false) then
 	local ga=GarrisonMissionFrame
@@ -199,4 +356,26 @@ if (false) then
 		f3:SetPoint("TOPLEFT",f2,"TOPRIGHT",10,0)
 	end
 end
---@end-do-not-package@
\ No newline at end of file
+--@end-do-not-package@
+--[[
+Garrison page structure
+Tab selection:
+Managed by
+GarrisonMissionFrameTab(1|2) onclick:
+->GarrisonMissionFrameTab_OnClick(self)
+--->GarrisonMissionFrame_SelectTab(self:GetID()) - 1 for Missions, 2 for followers
+
+Main Container is GarrisonMissionFrame
+Followers tab selected:
+->GarrisonMissionFrameFollowers -> anchored GarrisonMissionFrame TOPLEFT 33,-64
+-->GarrisonMissionFrameFollowersListScrollFrame
+--->GarrisonMissionFrameFollowersListScrooFrameScrollChild
+---->GarrisonMissionFrameFollowersListScrooFrameButton(1..9)
+->GarrisonMissionFrame.FollowerTab -> abcuored GarrisonMissionFrame TOPRIGHT -35 -64
+Missions tab selected
+->GarrisonMissionFrameMissions -> anchored (parent)e TOPLEFT 35,-65
+
+
+
+
+--]]
diff --git a/GarrisonCommander.toc b/GarrisonCommander.toc
index f607423..b841d45 100644
--- a/GarrisonCommander.toc
+++ b/GarrisonCommander.toc
@@ -8,17 +8,13 @@
 ## X-Revision: @project-abbreviated-hash@
 ## eMail: alar@aspide.it
 ## URL: http://wow.aspide.it
-## RequiredDeps: Blizzard_GarrisonUI
+## X-RequiredDeps: Blizzard_GarrisonUI
 ## OptionalDeps: AlarArtRemover
 ## DefaultState: Enabled
-## LoadOnDemand: 1
-## LoadWith: Blizzard_GarrisonUI
 ## SavedVariables: dbGAC
 ## X-ID: GAC
 ## X-Database:dbGAC
 ## X-Category: Garrison
-## X-ID: MRF
-## X-Database: dbMRF
 ## X-License: GPL v3
 ## X-eMail: alar@aspide.it
 ## X-Date: @project-date-iso@
diff --git a/RelNotes.lua b/RelNotes.lua
index ce34382..11d9173 100644
--- a/RelNotes.lua
+++ b/RelNotes.lua
@@ -11,15 +11,25 @@ GarrisonCommander adds to mission tooltips the following informations:
 * makes mission panel movable (position NOT yet saved between sessions)
 * base success chance (does NOT account for followers)
 * list of follower that have the necessary counters for the mission, with their status (on mission, available etc)
-* both traits (orange lines) and abilities(blue lines) are shown
+* both traits (silver lines) and abilities(blue lines) are shown
 * every follower line has now the icon for countered trait/ability
+* time left shown for In mission follower

 == Future plans ==
+# Will calculate the success chance with the best possible setup
 # Showing information in an overlay on mission buttons to have all needed information for all missions at a glance
 # Mission assign optimizer: I think I could also propone the best assignment to maximise your chances of success

 ]])
 self:RelNotes(1,0,2,[[
+Feature: Level added to follower line
+Feature: All counterd traits listed on the same line
+Feature: For "In mission" follower time letf is shown instead of "In mission"
+Feature: Trait related lines are now silver, while abilities related are Blue
+Feature: Mission panel can now optionally be relocked
+Feature: You can select to ignore "busy" followers
+]])
+self:RelNotes(1,0,1,[[
 Fixed: Follower info refresh should be now more reliable
 Feature: Mission panel is now movable
 Feature: Shows also countered traits( i.e. environmente/racial bonuses)