Quantcast

Altered the position on dropdown on specswitch.

Darth Predator [02-24-17 - 10:22]
Altered the position on dropdown on specswitch.
Need to actually add options for that. Ref - #436
Filename
ElvUI_SLE/modules/datatexts.lua
ElvUI_SLE/modules/sledatatexts/load_datatexts.xml
ElvUI_SLE/modules/sledatatexts/specswitch.lua
diff --git a/ElvUI_SLE/modules/datatexts.lua b/ElvUI_SLE/modules/datatexts.lua
index d0263d9..8b5c7b0 100644
--- a/ElvUI_SLE/modules/datatexts.lua
+++ b/ElvUI_SLE/modules/datatexts.lua
@@ -224,6 +224,7 @@ function DTP:Initialize()
 	DTP:HookDurabilityDT()
 	DTP:CreateMailDT()
 	DTP:CreateCurrencyDT()
+	DTP:ReplaceSpecSwitch()

 	--Remove char
 	local popup = E.PopupDialogs['SLE_CONFIRM_DELETE_CURRENCY_CHARACTER']
diff --git a/ElvUI_SLE/modules/sledatatexts/load_datatexts.xml b/ElvUI_SLE/modules/sledatatexts/load_datatexts.xml
index dc28bd2..02523c1 100644
--- a/ElvUI_SLE/modules/sledatatexts/load_datatexts.xml
+++ b/ElvUI_SLE/modules/sledatatexts/load_datatexts.xml
@@ -15,4 +15,5 @@
 	<Script file='currency.lua'/>
 	<Script file='range.lua'/>
 	<Script file='durability.lua'/>
+	<Script file='specswitch.lua'/>
 </Ui>
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/sledatatexts/specswitch.lua b/ElvUI_SLE/modules/sledatatexts/specswitch.lua
new file mode 100644
index 0000000..e628d36
--- /dev/null
+++ b/ElvUI_SLE/modules/sledatatexts/specswitch.lua
@@ -0,0 +1,85 @@
+local SLE, T, E, L, V, P, G = unpack(select(2, ...))
+local DT = E:GetModule('DataTexts')
+local DTP = SLE:GetModule('Datatexts')
+
+-- GLOBALS: PlayerTalentFrame, LoadAddOn
+local format = string.format
+
+local EasyMenu = EasyMenu
+local GetLootSpecialization = GetLootSpecialization
+local GetSpecialization = GetSpecialization
+local GetSpecializationInfo = GetSpecializationInfo
+local HideUIPanel = HideUIPanel
+local IsShiftKeyDown = IsShiftKeyDown
+local ShowUIPanel = ShowUIPanel
+local SetSpecialization = SetSpecialization
+local SetLootSpecialization = SetLootSpecialization
+local SELECT_LOOT_SPECIALIZATION = SELECT_LOOT_SPECIALIZATION
+local LOOT_SPECIALIZATION_DEFAULT = LOOT_SPECIALIZATION_DEFAULT
+
+local menuFrame = _G["LootSpecializationDatatextClickMenu"]
+local menuList = {
+	{ text = SELECT_LOOT_SPECIALIZATION, isTitle = true, notCheckable = true },
+	{ notCheckable = true, func = function() SetLootSpecialization(0) end },
+	{ notCheckable = true },
+	{ notCheckable = true },
+	{ notCheckable = true },
+	{ notCheckable = true }
+}
+local specList = {
+	{ text = SPECIALIZATION, isTitle = true, notCheckable = true },
+	{ notCheckable = true },
+	{ notCheckable = true },
+	{ notCheckable = true },
+	{ notCheckable = true }
+}
+
+function DTP:ReplaceSpecSwitch()
+	DT.RegisteredDataTexts["Talent/Loot Specialization"].onClick = function(self, button)
+		local specIndex = GetSpecialization();
+		if not specIndex then return end
+
+		if button == "LeftButton" then
+			DT.tooltip:Hide()
+			if not PlayerTalentFrame then
+				LoadAddOn("Blizzard_TalentUI")
+			end
+			if IsShiftKeyDown() then
+				if not PlayerTalentFrame:IsShown() then
+					ShowUIPanel(PlayerTalentFrame)
+				else
+					HideUIPanel(PlayerTalentFrame)
+				end
+			else
+				for index = 1, 4 do
+					local id, name, _, texture = GetSpecializationInfo(index);
+					if ( id ) then
+						specList[index + 1].text = format('|T%s:14:14:0:0:64:64:4:60:4:60|t  %s', texture, name)
+						specList[index + 1].func = function() SetSpecialization(index) end
+					else
+						specList[index + 1] = nil
+					end
+				end
+				-- EasyMenu(specList, menuFrame, "cursor", -15, -7, "MENU", 2)
+				EasyMenu(specList, menuFrame, "cursor", -15, 50, "MENU", 2)
+			end
+		else
+			DT.tooltip:Hide()
+			local _, specName = GetSpecializationInfo(specIndex);
+			menuList[2].text = format(LOOT_SPECIALIZATION_DEFAULT, specName);
+
+			for index = 1, 4 do
+				local id, name = GetSpecializationInfo(index);
+				if ( id ) then
+					menuList[index + 2].text = name
+					menuList[index + 2].func = function() SetLootSpecialization(id) end
+				else
+					menuList[index + 2] = nil
+				end
+			end
+
+			-- EasyMenu(menuList, menuFrame, "cursor", -15, -7, "MENU", 2)
+			EasyMenu(menuList, menuFrame, "cursor", -15, 50, "MENU", 2)
+		end
+	end
+end
\ No newline at end of file