-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGH_ItemAsk.lua
More file actions
executable file
·104 lines (90 loc) · 4.56 KB
/
GH_ItemAsk.lua
File metadata and controls
executable file
·104 lines (90 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
local L = LibStub("AceLocale-3.0"):GetLocale("GearHelper")
local function IsTargetValid(target)
if nil == target or "" == target or string.find(target, GetUnitName("player")) then
return false
end
return true
end
local function AskIfHeNeed(link, sendTo)
local className, classFile, classID = UnitClass(sendTo)
local itemTable = GHItem:Create(link)
local itemLink = itemTable["itemLink"]
local lienPerso = tostring(GHToolbox:GetClassColor(classFile)) .. tostring(sendTo) .. "|r"
StaticPopupDialogs["AskIfHeNeed"] = {
text = GearHelper.locals["demande1"] .. lienPerso .. GearHelper.locals["demande2"] .. itemLink .. " ?",
button1 = GearHelper.locals["yes"],
button2 = GearHelper.locals["no"],
OnAccept = function(GearHelper2, data, data2)
local LibRealmInfo = LibStub:GetLibrary("LibRealmInfo")
local _, _, _, _, unitLocale = LibRealmInfo:GetRealmInfoByUnit(sendTo)
if unitLocale == nil then
unitLocale = "enUS"
end
local theSource = GearHelper.db.global.messages[unitLocale].demande4 or GearHelper.locals["demande4enUS"]
local theSource2 = GearHelper.db.global.messages[unitLocale].demande42 or GearHelper.locals["demande4enUS2"]
local msg = theSource .. itemLink .. theSource2 .. "?"
local rep = GearHelper.db.global.messages[unitLocale].rep or GearHelper.locals["repenUS"]
local rep2 = GearHelper.db.global.messages[unitLocale].rep2 or ""
local msgRep = rep .. GearHelper.locals["maLangue" .. unitLocale] .. rep2
SendChatMessage(msg, "WHISPER", "Common", sendTo)
SendChatMessage(msgRep, "WHISPER", "Common", sendTo)
StaticPopup_Hide("AskIfHeNeed")
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3 -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
}
StaticPopup_Show("AskIfHeNeed")
end
function GearHelper:CreateLinkAskIfHeNeeds(debug, message, sender, language, channelString, target, flags, unknown1, channelNumber, channelName, unknown2, counter)
-- local message = message or "|cffff8000|Hitem:13262::::::::100:105::::::|h[Porte-cendres ma Gueule]|h|r"
local message = message or "|cffff8000|Hitem:19019::::::::120:::::::|h[Thunderfury ma Gueule]|h|r"
-- local message = message or "|cffff8000|Hitem:30212::::::::120:::::::|h[Zeub zeub]|h|r"
local target = target or GetUnitName("player")
if (debug ~= 1) then
if not self.db.profile.askLootRaid or not IsTargetValid(target) or string.find(string.lower(message), "bonus") then
return
end
end
local couleur, tar = ""
local _, classFile = UnitClass(target)
local tar = ""
if classFile ~= nil then
tar = GHToolbox:GetClassColor(classFile) .. tostring(target) .. "|r"
end
local nameLink
local OldSetItemRef = SetItemRef
if (debug == 1) then
AskIfHeNeed(message, target)
end
function SetItemRef(link, text, button, chatFrame)
local func = strmatch(link, "^GHWhispWhenClick:(%a+)")
if func == "askIfHeNeed" then
local _, nomPerso, itID, persoLink = strsplit("_", link)
local _, theItemLink = GetItemInfo(itID)
local itemTable = GHItem:Create(theItemLink)
local itLink1 = itemTable.itemLink
AskIfHeNeed(itLink1, nomPerso)
else
OldSetItemRef(link, text, button, chatFrame)
end
end
for itemLink in message:gmatch("|%x+|Hitem:.-|h.-|h|r") do
local shouldBeCompared, err = pcall(self.ShouldBeCompared, nil, itemLink)
if (shouldBeCompared) then
local item = GHItem:Create(itemLink)
local quality = GHToolbox:GetQualityFromColor(item.rarity)
if quality ~= nil and quality < 5 then
nameLink = GHToolbox:ReturnGoodLink(itemLink, target, tar)
local item = GHItem:Create(itemLink)
local isItemBetter = self:IsItemBetter(item)
if (isItemBetter) then
UIErrorsFrame:AddMessage(GHToolbox:ColorizeString(self.locals["ask1"], "Yellow") .. nameLink .. GHToolbox:ColorizeString(self.locals["ask2"], "Yellow") .. itemLink, 0.0, 1.0, 0.0)
print(GHToolbox:ColorizeString(self.locals["ask1"], "Yellow") .. nameLink .. GHToolbox:ColorizeString(self.locals["ask2"], "Yellow") .. itemLink)
PlaySound(5274, "Master")
end
end
end
end
end