Quantcast

Nice stuff for artifact

Darthpred [09-16-16 - 15:54]
Nice stuff for artifact
Filename
ElvUI_SLE/core/install.lua
ElvUI_SLE/defaults/private.lua
ElvUI_SLE/modules/orderhall.lua
ElvUI_SLE/options/orderhall_c.lua
diff --git a/ElvUI_SLE/core/install.lua b/ElvUI_SLE/core/install.lua
index 46a419b..859a829 100644
--- a/ElvUI_SLE/core/install.lua
+++ b/ElvUI_SLE/core/install.lua
@@ -627,6 +627,7 @@ function PI:DarthSetup()

 	E.global["sle"]["advanced"]["optionsLimits"] = true
 	E.global["sle"]["advanced"]["cyrillics"]["commands"] = true
+	E.global["sle"]["LinkArtifactTrait"] = true
 	E.global["general"]["animateConfig"] = false
 	E.global["general"]["commandBarSetting"] = "DISABLED"
 	E.global["general"]["fadeMapWhenMoving"] = false
diff --git a/ElvUI_SLE/defaults/private.lua b/ElvUI_SLE/defaults/private.lua
index b28a9b2..e29daf1 100644
--- a/ElvUI_SLE/defaults/private.lua
+++ b/ElvUI_SLE/defaults/private.lua
@@ -203,6 +203,7 @@ G["sle"] = {
 		["Blacklist"] = "",
 		["TradeOpen"] = false,
 	},
+	["LinkArtifactTrait"] = false,
 	["advanced"] = {
 		["general"] = false,
 		["optionsLimits"] = false,
@@ -216,4 +217,4 @@ G["sle"] = {
 			["devCommands"] = false,
 		},
 	},
-}
\ No newline at end of file
+	}
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/orderhall.lua b/ElvUI_SLE/modules/orderhall.lua
index 3740841..383bce2 100644
--- a/ElvUI_SLE/modules/orderhall.lua
+++ b/ElvUI_SLE/modules/orderhall.lua
@@ -2,6 +2,7 @@ local SLE, T, E, L, V, P, G = unpack(select(2, ...))
 local OH = SLE:NewModule("OrderHall", 'AceEvent-3.0')
 local _G = _G
 local C_Garrison = C_Garrison
+local PowerButton_OnClick, OnRelicSlotClicked

 function OH:SHIPMENT_CRAFTER_INFO(event, success, _, maxShipments, plotID)
 	if not _G["GarrisonCapacitiveDisplayFrame"] then return end --Just in case
@@ -23,6 +24,41 @@ function OH:SHIPMENT_CRAFTER_CLOSED()
 	OH.clicked = false
 end

+--Based on ArtifactTraitLink by Ketho
+function OH:ArtClickHook(event, addon)
+	if addon == "Blizzard_ArtifactUI" then
+		PowerButton_OnClick = ArtifactPowerButtonMixin.OnClick
+		-- rather prehook than posthook to prevent purchasing traits
+		function ArtifactPowerButtonMixin:OnClick(button)
+			if IsModifiedClick("CHATLINK") then
+				ChatEdit_InsertLink(GetSpellLink(self.spellID))
+			else
+				PowerButton_OnClick(self, button)
+			end
+		end
+
+		OnRelicSlotClicked = ArtifactTitleTemplateMixin.OnRelicSlotClicked
+		-- ArtifactTitleTemplateMixin.OnRelicSlotClicked
+		function ArtifactFrame.PerksTab.TitleContainer:OnRelicSlotClicked(relicSlot)
+			if IsModifiedClick("CHATLINK") then
+				for i = 1, #self.RelicSlots do
+					if self.RelicSlots[i] == relicSlot then
+						ChatEdit_InsertLink( select(4, C_ArtifactUI.GetRelicInfo(i)) )
+						break
+					end
+				end
+			else
+				OnRelicSlotClicked(self, relicSlot)
+			end
+		end
+		OH:UnregisterEvent(event)
+	end
+end
+
+function OH:CreateArtifactButton()
+	OH.ArtifactButton = CreateFrame("Button", "SLE_ArtifactButton", E.UIParent)
+end
+
 function OH:Initialize()
 	if not SLE.initialized then return end
 	OH.db = E.db.sle.orderhall
@@ -32,6 +68,10 @@ function OH:Initialize()
 		OH.db = E.db.sle.orderhall
 	end

+	if E.global.sle.LinkArtifactTrait then
+		self:RegisterEvent("ADDON_LOADED", "ArtClickHook")
+	end
+
 	self:RegisterEvent("SHIPMENT_CRAFTER_INFO");
 	self:RegisterEvent("SHIPMENT_CRAFTER_CLOSED");
 end
diff --git a/ElvUI_SLE/options/orderhall_c.lua b/ElvUI_SLE/options/orderhall_c.lua
index 7ee7bcc..0e2b8d2 100644
--- a/ElvUI_SLE/options/orderhall_c.lua
+++ b/ElvUI_SLE/options/orderhall_c.lua
@@ -36,6 +36,14 @@ local function configTable()
 					},
 				},
 			},
+			LinkArtifactTrait = {
+				order = 3,
+				type = "toggle",
+				name = L["Link Artifact Traits"],
+				desc = L["Allows you to link artifact traits and relics in chat by shift+click."],
+				get = function(info) return E.global.sle.LinkArtifactTrait end,
+				set = function(info, value) E.global.sle.LinkArtifactTrait = value; E:StaticPopup_Show("GLOBAL_RL") end,
+			},
 		},
 	}
 end