Quantcast

Loot Announce

Darthpred [03-04-13 - 09:47]
Loot Announce
Filename
ElvUI_SLE/config/profile.lua
ElvUI_SLE/config/sle_private.lua
ElvUI_SLE/locales/english.lua
ElvUI_SLE/locales/russian.lua
ElvUI_SLE/modules/load_modules.xml
ElvUI_SLE/modules/loot/load_loot.xml
ElvUI_SLE/modules/loot/loot.lua
ElvUI_SLE/modules/loot/options.lua
diff --git a/ElvUI_SLE/config/profile.lua b/ElvUI_SLE/config/profile.lua
index 06c7ed8..c382b40 100644
--- a/ElvUI_SLE/config/profile.lua
+++ b/ElvUI_SLE/config/profile.lua
@@ -187,6 +187,13 @@ P['sle'] = {
 		['mouse'] = false,
 		['position'] = "uib_vert",
 	},
+
+	--Loot
+	['loot'] = {
+		['quality'] = "EPIC",
+		['chat'] = "RAID",
+		['auto'] = true,
+	},
 }

 --For some reason datatext settings refuses to work if there is no general setting block here O_o
diff --git a/ElvUI_SLE/config/sle_private.lua b/ElvUI_SLE/config/sle_private.lua
index 0f8a53f..0e91423 100644
--- a/ElvUI_SLE/config/sle_private.lua
+++ b/ElvUI_SLE/config/sle_private.lua
@@ -43,4 +43,8 @@ V['sle'] = {
 			['enable'] = true,
 		},
 	},
+
+	['loot'] = {
+		['enable'] = false,
+	},
 }
diff --git a/ElvUI_SLE/locales/english.lua b/ElvUI_SLE/locales/english.lua
index 9890cf8..5f4acf7 100644
--- a/ElvUI_SLE/locales/english.lua
+++ b/ElvUI_SLE/locales/english.lua
@@ -171,6 +171,15 @@ L["This will import non class specific filters from this author."] = true
 L["This will import All Class specific filters from this author."] = true
 L['Import All'] = true

+--Loot--
+L['Loot Annouce'] = true
+L["LOOT_DESC"] = [[This module will announce loot dropped when you open loot window.
+This will work only if you are master looter or if you hold left control key during loot opening to force announce.]]
+L["Autoannounce"] = true
+L["Automatically announce in selected chat channel."] = true
+L["Minimum quality"] = true
+L["Minimum quality of an item to announce it."] = true
+L["The chat channel to announce to."] = true

 --Marks--
 L["Raid Marks"] = true
diff --git a/ElvUI_SLE/locales/russian.lua b/ElvUI_SLE/locales/russian.lua
index 1d3d05a..ecb1741 100644
--- a/ElvUI_SLE/locales/russian.lua
+++ b/ElvUI_SLE/locales/russian.lua
@@ -179,6 +179,16 @@ L["This will import non class specific filters from this author."] = "Это и
 L["This will import All Class specific filters from this author."] = "Это импортирует все классовые фильтры этого автора."
 L['Import All'] = "Импорт всего"

+--Loot--
+L['Loot Annouce'] = "Оповещение о добыче"
+L["LOOT_DESC"] = [[Этот модуль будет выводить список выпавшей добычи при открытии окна добычи.
+Вывод осуществляется только если Вы ответственный за добычу или при зажатии левой клавиши control при открытии окна для принудительного вывода.]]
+L["Autoannounce"] = "Авто оповещение"
+L["Automatically announce in selected chat channel."] = "Автоматически выводить список добычи в выбранный канал чата"
+L["Minimum quality"] = "Минимальное качество"
+L["Minimum quality of an item to announce it."] = "Минимальное качество предмета, для вывода в чате."
+L["The chat channel to announce to."] = "Канал чата, для вывода сообщений."
+
 --Minimap--
 L["Minimap Options"] = "Опции миникарты"
 L['MINIMAP_DESC'] = "Эти опции влияют на различные функции миникарты.  Некоторые опции погут не работать, если вы отключите миникарты в основных настройках ElvUI."
diff --git a/ElvUI_SLE/modules/load_modules.xml b/ElvUI_SLE/modules/load_modules.xml
index c6dd126..7269209 100644
--- a/ElvUI_SLE/modules/load_modules.xml
+++ b/ElvUI_SLE/modules/load_modules.xml
@@ -12,6 +12,7 @@
 	<Include file='exprepbar\load_exprepbar.xml'/>
 	<Include file='farm\load_farm.xml'/>
 	<Include file='imports\load_imports.xml'/>
+	<Include file='loot\load_loot.xml'/>
 	<Include file='marks\load_marks.xml'/>
 	<Include file='minimap\load_minimap.xml'/>
 	<Include file='raidutility\load_raidutility.xml'/>
diff --git a/ElvUI_SLE/modules/loot/load_loot.xml b/ElvUI_SLE/modules/loot/load_loot.xml
new file mode 100644
index 0000000..fb84134
--- /dev/null
+++ b/ElvUI_SLE/modules/loot/load_loot.xml
@@ -0,0 +1,4 @@
+<Ui xmlns="http://www.blizzard.com/wow/ui/">
+	<Script file='loot.lua'/>
+	<Script file='options.lua'/>
+</Ui>
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/loot/loot.lua b/ElvUI_SLE/modules/loot/loot.lua
new file mode 100644
index 0000000..f656230
--- /dev/null
+++ b/ElvUI_SLE/modules/loot/loot.lua
@@ -0,0 +1,117 @@
+--Raid mark bar. Similar to quickmark which just semms to be impossible to skin
+local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore
+local LT = E:NewModule('Loot', 'AceHook-3.0', 'AceEvent-3.0')
+local check = false
+local t = 0
+local loottemp = {}
+
+function LT:Announce()
+	local name = {}
+	local loot = {}
+	local numbers = {}
+	local m = 0
+	local q = E.db.sle.loot.quality == "EPIC" and 4 or E.db.sle.loot.quality == "RARE" and 3 or E.db.sle.loot.quality == "UNCOMMON" and 2
+	local n = 0
+	local inGroup, inRaid, inPartyLFG = IsInGroup(), IsInRaid(), IsPartyLFG()
+	local p, chat
+	if not inGroup then return end -- not in group, exit.
+	local masterlooterRaidID = select(3, GetLootMethod())
+	if (masterlooterRaidID ~= nil and UnitName("raid"..masterlooterRaidID) == UnitName("player") and E.db.sle.loot.auto) or (IsLeftControlKeyDown() and (IsInGroup() or IsInRaid())) then
+		for i = 1, GetNumLootItems() do
+			if GetLootSlotType(i) == 1 then
+				for j = 1, t do
+					if GetLootSlotLink(i) == loottemp[j] then
+						check = true
+					end
+				end
+			end
+		end
+		if check == false or IsLeftControlKeyDown() then
+			for i = 1, GetNumLootItems() do
+				if GetLootSlotType(i) ~= 1 then
+					m = m + 1
+				else
+					local _, item, quantity, quality = GetLootSlotInfo(i)
+					if quality >= q then
+						name[i] = item
+
+						k = 1
+						while name[i] ~= name[k] do
+						k = k + 1
+						end
+
+						if i == k then
+							n = n + 1
+							loot[n] = GetLootSlotLink(i)
+						numbers[n] = quantity
+						else
+
+						p = 1
+						while GetLootSlotLink(k) ~= loot[p] do
+						p = p + 1
+						end
+						numbers[p] = numbers[p] + quantity
+
+					end
+				end
+			end
+		end
+		if n ~= 0 then
+			if E.db.sle.loot.chat == "PARTY" then
+				SendChatMessage(L["Loot Dropped:"], inPartyLFG and "INSTANCE_CHAT" or "PARTY")
+			elseif E.db.sle.loot.chat == "RAID" then
+				if inRaid then
+					SendChatMessage(L["Loot Dropped:"], inPartyLFG and "INSTANCE_CHAT" or "RAID")
+				else
+					SendChatMessage(L["Loot Dropped:"], inPartyLFG and "INSTANCE_CHAT" or "PARTY")
+				end
+			elseif E.db.sle.loot.chat == "SAY" then
+				SendChatMessage(L["Loot Dropped:"], "SAY")
+			end
+		end
+		for i = 1, n do
+			if E.db.sle.loot.chat == "PARTY" then
+				if numbers[i] == 1 then
+					SendChatMessage(i..". "..loot[i], inPartyLFG and "INSTANCE_CHAT" or "PARTY")
+				elseif numbers[i] > 1 then
+					SendChatMessage(i..". "..loot[i].."x"..numbers[i], inPartyLFG and "INSTANCE_CHAT" or "PARTY")
+				end
+			elseif E.db.sle.loot.chat == "RAID" then
+				if inRaid then
+					if numbers[i] == 1 then
+						SendChatMessage(i..". "..loot[i], inPartyLFG and "INSTANCE_CHAT" or "RAID")
+					elseif numbers[i] > 1 then
+							SendChatMessage(i..". "..loot[i].."x"..numbers[i], inPartyLFG and "INSTANCE_CHAT" or "RAID")
+						end
+					else
+						if numbers[i] == 1 then
+							SendChatMessage(i..". "..loot[i], inPartyLFG and "INSTANCE_CHAT" or "PARTY")
+						elseif numbers[i] > 1 then
+							SendChatMessage(i..". "..loot[i].."x"..numbers[i], inPartyLFG and "INSTANCE_CHAT" or "PARTY")
+						end
+					end
+			elseif E.db.sle.loot.chat == "SAY" then
+				if numbers[i] == 1 then
+					SendChatMessage(i..". "..loot[i], "SAY")
+				elseif numbers[i] > 1 then
+					SendChatMessage(i..". "..loot[i].."x"..numbers[i], "SAY")
+					end
+				end
+			end
+		end
+		for i = 1, GetNumLootItems() do
+			if GetLootSlotType(i) == 1 then
+				loottemp[i] = GetLootSlotLink(i)
+			end
+		end
+		t = GetNumLootItems()
+		check = false
+	end
+end
+
+function LT:Initialize()
+	if not E.private.sle.loot.enable then return end
+	self:RegisterEvent("LOOT_OPENED", "Announce")
+end
+
+E:RegisterModule(LT:GetName())
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/loot/options.lua b/ElvUI_SLE/modules/loot/options.lua
new file mode 100644
index 0000000..e7358ac
--- /dev/null
+++ b/ElvUI_SLE/modules/loot/options.lua
@@ -0,0 +1,73 @@
+local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore
+local LT = E:GetModule('Loot')
+local function configTable()
+
+--Main options group
+E.Options.args.sle.args.loot = {
+	order = 5,
+	type = "group",
+	name = L['Loot Annouce'],
+	args = {
+		marksheader = {
+			order = 1,
+			type = "header",
+			name = L['Loot Annouce'],
+		},
+		info = {
+			order = 2,
+			type = "description",
+			name = L["LOOT_DESC"],
+		},
+		enabled = {
+			order = 3,
+			type = "toggle",
+			name = L["Enable"],
+			get = function(info) return E.private.sle.loot.enable end,
+			set = function(info, value) E.private.sle.loot.enable = value; E:StaticPopup_Show("PRIVATE_RL") end
+		},
+		auto = {
+			order = 4,
+			type = "toggle",
+			name = L["Autoannounce"],
+			desc = L["Automatically announce in selected chat channel."],
+			get = function(info) return E.db.sle.loot.auto end,
+			set = function(info, value) E.db.sle.loot.auto = value; end
+		},
+		spacer = {
+			order = 5,
+			type = "description",
+			name = "",
+		},
+		quality = {
+			order = 6,
+			type = "select",
+			name = L["Minimum quality"],
+			desc = L["Minimum quality of an item to announce it."],
+			disabled = function() return not E.private.sle.loot.enable end,
+			get = function(info) return E.db.sle.loot.quality end,
+			set = function(info, value) E.db.sle.loot.quality = value;  end,
+			values = {
+				['EPIC'] = "|cffA335EE"..ITEM_QUALITY4_DESC.."|r",
+				['RARE'] = "|cff0070DD"..ITEM_QUALITY3_DESC.."|r",
+				['UNCOMMON'] = "|cff1EFF00"..ITEM_QUALITY2_DESC.."|r",
+			},
+		},
+		chat = {
+			order = 7,
+			type = "select",
+			name = L["Chat"],
+			desc = L["The chat channel to announce to."],
+			disabled = function() return not E.private.sle.loot.enable end,
+			get = function(info) return E.db.sle.loot.chat end,
+			set = function(info, value) E.db.sle.loot.chat = value;  end,
+			values = {
+				['RAID'] = "|cffFF7F00"..RAID.."|r",
+				['PARTY'] = "|cffAAAAFF"..PARTY.."|r",
+				['SAY'] = "|cffFFFFFF"..SAY.."|r",
+			},
+		},
+	},
+}
+end
+
+table.insert(E.SLEConfigs, configTable)
\ No newline at end of file