Quantcast

* *2.9.0*

Alar of Daggerspine [12-28-15 - 19:06]
* *2.9.0*

Feature: Missions can be blacklisted. Blacklisted mission are shown in
mission control, but not started, nor use followers

Signed-off-by: Alar of Daggerspine <alar@aspide.it>
Filename
CHANGELOG.txt
GarrisonCommander.lua
Init.lua
MissionControl.lua
Widgets.lua
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index ef44d45..b227774 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,5 +1,8 @@
 *GarrisonCommander helps you when choosing the right follower for the right mission*

+* *2.9.0*
+Feature: Missions can be blacklisted. Blacklisted mission are shown in mission control, but not started, nor use followers
+
 * *2.8.2*
 Fix: ticket #107 FollowerPage.lua error

diff --git a/GarrisonCommander.lua b/GarrisonCommander.lua
index bc900a0..61f934b 100644
--- a/GarrisonCommander.lua
+++ b/GarrisonCommander.lua
@@ -388,8 +388,9 @@ print("Initialize")
 		b.Title:SetFont(f,h*scale,s)
 		local f,h,s=b.Summary:GetFont()
 		b.Summary:SetFont(f,h*scale,s)
+		b:RegisterForClicks("LeftButtonUp","RightButtonUp")
 		addon:SafeRawHookScript(b,"OnEnter","ScriptGarrisonMissionButton_OnEnter")
-		addon:SafeSecureHookScript(b,"OnClick","ScriptGarrisonMissionButton_OnClick")
+		addon:SafeRawHookScript(b,"OnClick","ScriptGarrisonMissionButton_OnClick")
 	end
 	self:CreatePrivateDb()
 	db=self.db.global
@@ -406,6 +407,7 @@ print("Initialize")
 		dbGAC.namespaces.missionscache=nil  -- Removed in 2.6.9
 		dbGAC.namespaces=nil
 	end
+	blacklist=chardb.missionControl.blacklist
 	self:AddLabel(L["Garrison Appearance"])
 	self:AddToggle("MOVEPANEL",true,L["Unlock Panel"],L["Makes main mission panel movable"])
 	self:AddToggle("BIGSCREEN",true,L["Big screen"],L["Disabling this will give you the interface from 1.1.8, given or taken. Need to reload interface"])
@@ -793,6 +795,7 @@ function addon:CreatePrivateDb()
 					}
 				},
 				missionControl={
+					blacklist={},
 					version=3,
 					allowedRewards = {
 						['*']=true,
@@ -1879,6 +1882,9 @@ function addon:FillMissionPage(missionInfo)
 	holdEvents()
 	local main=missionInfo.followerTypeID==LE_FOLLOWER_TYPE_GARRISON_6_0 and GMF or GSF
 	local missionpage=main.MissionTab.MissionPage
+--@debug@
+	print(missionpage)
+--@end-debug@
 	main:ClearParty()
 	local party=self:GetParty(missionID)
 	if (party) then
@@ -2255,7 +2261,20 @@ function addon:ScriptGarrisonMissionButton_OnClick(tab,button)
 		return
 	end
 	if (type(tab.info)~="table") then return end
-	self:FillMissionPage(tab.info)
+	if (button=="LeftButton") then
+		self.hooks[tab].OnClick(tab,button)
+		self:FillMissionPage(tab.info)
+	else
+		blacklist[tab.info.missionID]=not blacklist[tab.info.missionID]
+		if blacklist[tab.info.missionID] then
+			tab.Title:SetTextColor(0,0,0)
+		else
+			tab.Title:SetTextColor(1,1,1)
+		end
+		GameTooltip:Hide()
+		addon:ScriptGarrisonMissionButton_OnEnter(tab,button)
+	end
+
 end
 function addon:OnClick_GCMissionButton(frame,button)
 	if (button=="RightButton") then
@@ -2503,6 +2522,13 @@ function addon:ScriptGarrisonMissionButton_OnEnter(this, button)
 		--@end-debug@
 		GameTooltip:AddLine(GARRISON_MISSION_AVAILABILITY);
 		GameTooltip:AddLine(this.info.offerTimeRemaining, 1, 1, 1);
+		if (blacklist[this.info.missionID]) then
+			GameTooltip:AddDoubleLine(L["Blacklisted"],L["Right-Click to remove from blacklist"],1,0.125,0.125,C:Green())
+			GameTooltip:AddLine(L["Blacklisted missions are ignored in Mission Control"])
+		else
+			GameTooltip:AddDoubleLine(L["Not blacklisted"],L["Right-Click to blacklist"],0.125,1.0,0.125,C:Red())
+		end
+		GameTooltip:AddLine(this.info.offerTimeRemaining, 1, 1, 1);
 		addon:AddFollowersToTooltip(this.info.missionID,LE_FOLLOWER_TYPE_GARRISON_6_0 or 0)
 		if not C_Garrison.IsOnGarrisonMap() and not GMF:IsVisible() then
 			GameTooltip:AddLine(" ");
@@ -2551,6 +2577,8 @@ function addon:DrawSingleButton(source,frame,progressing,bigscreen)
 				end
 			end
 		end
+		if (blacklist[missionID]) then frame.Title:SetTextColor(0,0,0) else frame.Title:SetTextColor(1,1,1) end
+
 		frame:Show();

 	else
@@ -2589,7 +2617,7 @@ function addon:AddStandardDataToButton(source,button,mission,missionID,bigscreen
 		button.Rewards[1]:SetPoint("RIGHT",button,"RIGHT",-500 - (GMM and 40 or 0),0)
 	end
 	button.MissionType:SetAtlas(mission.typeAtlas);
-	if source=="blizzard" then return end
+	if source=="blizzard" then print("source blizzard")return end
 	if (mission.isRare) then
 		button.RareOverlay:Show();
 		button.RareText:Show();
diff --git a/Init.lua b/Init.lua
index 0643f5e..e028102 100644
--- a/Init.lua
+++ b/Init.lua
@@ -30,6 +30,7 @@ ns.C=ns.addon:GetColorTable()
 ns.L=ns.addon:GetLocale()
 ns.G=C_Garrison
 ns.GMF=_G.GarrisonMissionFrame
+ns.blacklist=false
 if not ns.GMF then
 --@debug@
 	print("GarrisonCommander is being loaded before Blizzard_GarrisonUI is available")
diff --git a/MissionControl.lua b/MissionControl.lua
index b02def6..369ca19 100644
--- a/MissionControl.lua
+++ b/MissionControl.lua
@@ -146,7 +146,7 @@ function module:GMCRunMission(missionID,start)
 		if (missionID and party.missionID==missionID or not missionID) then
 			GMC.list.widget:RemoveChild(party.missionID)
 			GMC.list.widget:DoLayout()
-			if (party.full) then
+			if (party.full and not blacklist[party.missionID]) then
 				for j=1,#party.members do
 					G.AddFollowerToMission(party.missionID, party.members[j])
 				end
@@ -159,18 +159,34 @@ function module:GMCRunMission(missionID,start)
 					self:ScheduleTimer("GMCRunMission",0.25,party.missionID,true)
 					return
 				end
+			else
+				if not missionID then coroutine.yield(true) end
 			end
 		end
 		addon:RefreshFollowerStatus()
 	end
 end
 do
+	local function leftclick(this)
+		print("leftclick")
+		local missionID=this.frame.info.missionID
+		if (blacklist[missionID]) then return end
+		module:GMCRunMission(missionID)
+		GMF.MissionControlTab.list.widget:RemoveChild(missionID)
+	end
+	local function rightclick(this)
+		print("rightclick")
+		local missionID=this.frame.info.missionID
+		blacklist[missionID]=not blacklist[missionID]
+		module:Refresh()
+	end
 	local timeElapsed=0
 	local currentMission=0
 	local x=0
 	function module:GMCCalculateMissions(this,elapsed)
 		local GMC=GMF.MissionControlTab
 		db.news.MissionControl=true
+
 		timeElapsed = timeElapsed + elapsed
 		if (#aMissions == 0 ) then
 			if timeElapsed >= 1 then
@@ -213,22 +229,22 @@ do
 				--@end-debug@
 				if ( party.full and party.perc >= minimumChance) then
 					--@debug@
-					print(missionID,"  Acccepted",party)
+					print(missionID,"  Accepted",party)
 					--@end-debug@
 					local mb=AceGUI:Create("GMCMissionButton")
-					for i=1,#party.members do
-						GMCUsedFollowers[party.members[i]]=true
+					if not blacklist[missionID] then
+						for i=1,#party.members do
+							GMCUsedFollowers[party.members[i]]=true
+						end
 					end
 					party.missionID=missionID
 					tinsert(GMC.list.Parties,party)
 					GMC.list.widget:PushChild(mb,missionID)
 					mb:SetFullWidth(true)
 					mb:SetMission(self:GetMissionData(missionID),party,false,"control")
-					mb:SetCallback("OnClick",function(...)
-						module:GMCRunMission(missionID)
-						GMC.list.widget:RemoveChild(missionID)
-					end
-					)
+					mb:Blacklist(blacklist[missionID])
+					mb:SetCallback("OnClick",leftclick)
+					mb:SetCallback("OnRightClick",rightclick)
 				end
 				timeElapsed=0
 			end
diff --git a/Widgets.lua b/Widgets.lua
index ca4304a..922e5db 100644
--- a/Widgets.lua
+++ b/Widgets.lua
@@ -343,6 +343,8 @@ local function GMCMissionButton()
 		frame:SetAlpha(1)
 		frame:SetScale(1.0)
 		frame:Enable()
+		frame.Overlay:Hide()
+		frame.Overlay.Overlay:SetAlpha(.4)
 		for i=1,#self.scripts do
 			frame:SetScript(self.scripts[i],nil)
 		end
@@ -370,6 +372,39 @@ local function GMCMissionButton()
 	function m:SetScale(s)
 		return self.frame:SetScale(s)
 	end
+	function m:Blacklist(blacklisted)
+		local mb=self.frame
+		if blacklisted then
+			print("Blacklisting",mb:GetName())
+			mb.Overlay:Show()
+			mb.Overlay.Overlay:SetAlpha(1)
+			for i,v in pairs(mb.gcPANEL.Party) do
+				v.PortraitFrame.Portrait:SetDesaturated(true)
+				v.PortraitFrame.PortraitRingQuality:Hide()
+				v.PortraitFrame.LevelBorder:Hide()
+			end
+			for i,v in pairs(mb.Rewards) do
+				v.Icon:SetDesaturated(true)
+				v.Quantity:Hide()
+			end
+			return true
+		else
+			print("UnBlacklisting",mb:GetName())
+			mb.Overlay:Hide()
+			mb.Overlay.Overlay:SetAlpha(0.4)
+			for i,v in pairs(mb.gcPANEL.Party) do
+				v.PortraitFrame.Portrait:SetDesaturated(false)
+				v.PortraitFrame.PortraitRingQuality:Show()
+				v.PortraitFrame.LevelBorder:Show()
+			end
+			for i,v in pairs(mb.Rewards) do
+				v.Icon:SetDesaturated(false)
+				v.Quantity:Show()
+			end
+			return false
+		end
+
+	end
 	function m:SetMission(mission,party,perc,source)
 		self.frame.info=mission
 		self.frame.fromFollowerPage=true
@@ -397,7 +432,8 @@ local function GMCMissionButton()
 		frame.Summary:SetFontObject("QuestFont_Shadow_Small")
 		frame:SetScript("OnEnter",nil)
 		frame:SetScript("OnLeave",nil)
-		frame:SetScript("OnClick",function(self,button) return self.obj:Fire("OnClick",self,button) end)
+		frame:RegisterForClicks("LeftButtonUp","RightButtonUp")
+		frame:SetScript("OnClick",function(self,button) print(button) return button=="RightButton" and self.obj:Fire("OnRightClick",self,button) or  self.obj:Fire("OnClick",self,button) end)
 		frame.LocBG:SetPoint("LEFT")
 		frame.MissionType:SetPoint("TOPLEFT",5,-2)
 		--[[