|
ShadowTheAge@0
|
1 CrossRealmAssist = LibStub("AceAddon-3.0"):NewAddon("CrossRealmAssist", "AceEvent-3.0", "AceConsole-3.0", "AceTimer-3.0")
|
|
ShadowTheAge@0
|
2 local addon = CrossRealmAssist;
|
|
ShadowTheAge@0
|
3 local wholib = LibStub:GetLibrary('LibWho-2.0'):Library()
|
|
ShadowTheAge@12
|
4 local ScrollingTable = LibStub("ScrollingTable");
|
|
ShadowTheAge@13
|
5 local ldb = LibStub("LibDataBroker-1.1")
|
|
ShadowTheAge@13
|
6 local minimapIcon = LibStub("LibDBIcon-1.0")
|
|
ShadowTheAge@13
|
7 local db
|
|
ShadowTheAge@0
|
8
|
|
ShadowTheAge@13
|
9 local homeRealm, realmSep, gui, btRefresh, btSettings, btQuick, btManual, lbRealm, lbStatus, playerName, lfgui, lfgTabSelected, lfgTable, lbThrottle, curLfgGroup, sheduledScan, wasInGroup, inInstance
|
|
ShadowTheAge@13
|
10 local settingsMenu
|
|
ShadowTheAge@13
|
11 local hintShown
|
|
ShadowTheAge@25
|
12 local cbHideGroups, cbHideRaids, cbHideNoAutoinv
|
|
ShadowTheAge@0
|
13
|
|
ShadowTheAge@12
|
14 local tabs = {}
|
|
ShadowTheAge@27
|
15 local curRealmStat
|
|
ShadowTheAge@0
|
16 local scanstate=0
|
|
ShadowTheAge@0
|
17 local recentRealms={}
|
|
ShadowTheAge@12
|
18 local recentgroups={}
|
|
ShadowTheAge@13
|
19 local autoScanGroups={}
|
|
ShadowTheAge@0
|
20 local active=false
|
|
ShadowTheAge@21
|
21 local allLanguageTable={}
|
|
ShadowTheAge@0
|
22
|
|
ShadowTheAge@0
|
23 local lfgGroups={
|
|
ShadowTheAge@0
|
24 6, -- Custom
|
|
ShadowTheAge@0
|
25 10, -- Ashran
|
|
ShadowTheAge@0
|
26 1, -- Quests
|
|
ShadowTheAge@13
|
27 3, -- Raids
|
|
ShadowTheAge@13
|
28 8 -- BGs
|
|
ShadowTheAge@0
|
29 }
|
|
ShadowTheAge@0
|
30
|
|
ShadowTheAge@12
|
31 local StatusTable = {
|
|
ShadowTheAge@12
|
32 ["invited"]="Invited",
|
|
ShadowTheAge@12
|
33 ["declined"]="Declined",
|
|
ShadowTheAge@12
|
34 ["timedout"]="Timed out",
|
|
ShadowTheAge@12
|
35 ["applied"]="Applied",
|
|
ShadowTheAge@12
|
36 ["cancelled"]="Join cancelled",
|
|
ShadowTheAge@12
|
37 ["inviteaccepted"]="Joined",
|
|
ShadowTheAge@13
|
38 ["_init"]="Join request",
|
|
ShadowTheAge@13
|
39 ["_skip"]="Skipped"
|
|
ShadowTheAge@12
|
40 }
|
|
ShadowTheAge@13
|
41 local DefaultWidgetPos = {x=0, y=200, to="CENTER"}
|
|
ShadowTheAge@13
|
42 local SettingsDefaults={
|
|
ShadowTheAge@13
|
43 global={
|
|
ShadowTheAge@13
|
44 minimap = {},
|
|
ShadowTheAge@13
|
45 widgetPos=DefaultWidgetPos,
|
|
ShadowTheAge@13
|
46 quickJoinHint = true,
|
|
ShadowTheAge@27
|
47 quickJoin={[6]=1},
|
|
ShadowTheAge@27
|
48 allLanguages = true,
|
|
ShadowTheAge@29
|
49 stoplist = {"no hop","kick"}
|
|
ShadowTheAge@13
|
50 }
|
|
ShadowTheAge@13
|
51 }
|
|
ShadowTheAge@12
|
52
|
|
ShadowTheAge@12
|
53
|
|
ShadowTheAge@12
|
54 -- Utils functions
|
|
ShadowTheAge@12
|
55
|
|
ShadowTheAge@12
|
56 local function PlayerName(fullname)
|
|
ShadowTheAge@12
|
57 fullname = fullname or "???-???"
|
|
ShadowTheAge@12
|
58 local name, realm = strsplit(realmSep, fullname)
|
|
ShadowTheAge@12
|
59 realm = realm or homeRealm;
|
|
ShadowTheAge@12
|
60 return name, realm;
|
|
ShadowTheAge@12
|
61 end
|
|
ShadowTheAge@12
|
62
|
|
ShadowTheAge@12
|
63 local function canJoinGroup()
|
|
ShadowTheAge@12
|
64 return (not IsInGroup()) or (UnitIsGroupLeader('player') and not IsInRaid())
|
|
ShadowTheAge@12
|
65 end
|
|
ShadowTheAge@12
|
66
|
|
ShadowTheAge@12
|
67 local function sortByWeight(a,b)
|
|
ShadowTheAge@12
|
68 return b.weight < a.weight
|
|
ShadowTheAge@12
|
69 end
|
|
ShadowTheAge@12
|
70
|
|
ShadowTheAge@12
|
71
|
|
ShadowTheAge@12
|
72 -- UI functions
|
|
ShadowTheAge@12
|
73
|
|
ShadowTheAge@12
|
74 local function createIcon(owner, icon, id)
|
|
ShadowTheAge@12
|
75 local image = owner:CreateTexture(nil, "BACKGROUND")
|
|
ShadowTheAge@12
|
76 image:SetWidth(16)
|
|
ShadowTheAge@12
|
77 image:SetHeight(16)
|
|
ShadowTheAge@12
|
78 image:SetTexture(icon)
|
|
ShadowTheAge@12
|
79 image:SetPoint("TOPLEFT",owner,"TOPLEFT",id*16,0)
|
|
ShadowTheAge@12
|
80 return image
|
|
ShadowTheAge@12
|
81 end
|
|
ShadowTheAge@0
|
82
|
|
ShadowTheAge@11
|
83 local function setupWidget(widget, parameters, x, y)
|
|
ShadowTheAge@11
|
84 if parameters then
|
|
ShadowTheAge@11
|
85 for key,value in pairs(parameters) do widget[key](widget,value) end
|
|
ShadowTheAge@11
|
86 end
|
|
ShadowTheAge@11
|
87 if y then
|
|
ShadowTheAge@11
|
88 widget:SetPoint("TOPLEFT",widget:GetParent(),"TOPLEFT",x,-y)
|
|
ShadowTheAge@11
|
89 end
|
|
ShadowTheAge@11
|
90 return widget
|
|
ShadowTheAge@11
|
91 end
|
|
ShadowTheAge@11
|
92
|
|
ShadowTheAge@11
|
93 local function ShowTooltip(widget)
|
|
ShadowTheAge@11
|
94 GameTooltip:SetOwner(widget, widget.TooltipAnchor)
|
|
ShadowTheAge@11
|
95 GameTooltip:ClearLines()
|
|
ShadowTheAge@11
|
96 widget:TooltipFactory()
|
|
ShadowTheAge@11
|
97 GameTooltip:Show()
|
|
ShadowTheAge@11
|
98 end
|
|
ShadowTheAge@11
|
99
|
|
ShadowTheAge@11
|
100 local function HideTooltip(widget)
|
|
ShadowTheAge@11
|
101 GameTooltip:Hide()
|
|
ShadowTheAge@11
|
102 end
|
|
ShadowTheAge@11
|
103
|
|
ShadowTheAge@11
|
104 local function setupTooltip(widget, anchor, factory)
|
|
ShadowTheAge@11
|
105 widget.TooltipAnchor = anchor;
|
|
ShadowTheAge@11
|
106 widget.TooltipFactory = factory;
|
|
ShadowTheAge@11
|
107 widget:SetScript("OnEnter", ShowTooltip)
|
|
ShadowTheAge@11
|
108 widget:SetScript("OnLeave", HideTooltip)
|
|
ShadowTheAge@11
|
109 end
|
|
ShadowTheAge@11
|
110
|
|
ShadowTheAge@13
|
111 local function TabClick(tab)
|
|
ShadowTheAge@13
|
112 if tab == lfgTabSelected then return end
|
|
ShadowTheAge@13
|
113 addon.LfgScan(tab.searchID)
|
|
ShadowTheAge@13
|
114 end
|
|
ShadowTheAge@13
|
115
|
|
ShadowTheAge@13
|
116 local function changeTab(tab)
|
|
ShadowTheAge@12
|
117 PanelTemplates_DeselectTab(lfgTabSelected)
|
|
ShadowTheAge@12
|
118 lfgTabSelected = tab
|
|
ShadowTheAge@12
|
119 PanelTemplates_SelectTab(lfgTabSelected)
|
|
ShadowTheAge@12
|
120 end
|
|
ShadowTheAge@0
|
121
|
|
ShadowTheAge@12
|
122 local function realmToolip()
|
|
ShadowTheAge@12
|
123 if not curRealmStat then return end
|
|
ShadowTheAge@12
|
124 local players = curRealmStat.players;
|
|
ShadowTheAge@12
|
125 local threshold = curRealmStat.threshold
|
|
ShadowTheAge@12
|
126 GameTooltip:AddLine("Players in zone: "..players)
|
|
ShadowTheAge@12
|
127 if not curRealmStat.complete then
|
|
ShadowTheAge@12
|
128 GameTooltip:AppendText("+")
|
|
ShadowTheAge@12
|
129 end
|
|
ShadowTheAge@12
|
130 for i=1,curRealmStat.realms do
|
|
ShadowTheAge@12
|
131 local data = curRealmStat[i]
|
|
ShadowTheAge@12
|
132 local percent = math.ceil(100 * data.count / players - 0.5) .. "%";
|
|
ShadowTheAge@12
|
133 if data.count >= threshold then
|
|
ShadowTheAge@12
|
134 GameTooltip:AddDoubleLine(data.realm, percent, 0,1,0,0,1,0)
|
|
ShadowTheAge@12
|
135 else
|
|
ShadowTheAge@12
|
136 GameTooltip:AddDoubleLine(data.realm, percent, 0.5,0.5,0.5,0.5,0.5,0.5)
|
|
ShadowTheAge@12
|
137 end
|
|
ShadowTheAge@12
|
138 end
|
|
ShadowTheAge@0
|
139 end
|
|
ShadowTheAge@0
|
140
|
|
ShadowTheAge@13
|
141 local function ClearRealmHistory()
|
|
ShadowTheAge@13
|
142 recentRealms = {}
|
|
ShadowTheAge@13
|
143 addon:updateCurrentRealm()
|
|
ShadowTheAge@13
|
144 if lfgTable then lfgTable:Refresh() end
|
|
ShadowTheAge@13
|
145 end
|
|
ShadowTheAge@13
|
146
|
|
ShadowTheAge@12
|
147
|
|
ShadowTheAge@12
|
148
|
|
ShadowTheAge@12
|
149
|
|
ShadowTheAge@12
|
150
|
|
ShadowTheAge@12
|
151
|
|
ShadowTheAge@12
|
152
|
|
ShadowTheAge@12
|
153 -- LFG list data providers, filters and tooltips
|
|
ShadowTheAge@12
|
154
|
|
ShadowTheAge@12
|
155 local lfgScanInProgress=false
|
|
ShadowTheAge@12
|
156 local hasLfgListChanges=false
|
|
ShadowTheAge@12
|
157
|
|
ShadowTheAge@12
|
158 local function addTooltipLineIcon(predicat, text, icon, r, g, b, wrap)
|
|
ShadowTheAge@12
|
159 if predicat then
|
|
ShadowTheAge@12
|
160 GameTooltip:AddLine(text, r, g, b, wrap)
|
|
ShadowTheAge@12
|
161 if icon then GameTooltip:AddTexture(icon) end
|
|
ShadowTheAge@12
|
162 end
|
|
ShadowTheAge@12
|
163 end
|
|
ShadowTheAge@12
|
164
|
|
ShadowTheAge@12
|
165 local function WeightLfgItem(id, forAutoJoin)
|
|
ShadowTheAge@12
|
166 local _, action, caption, desc, voice, ilvl, time, bnetfr, charfr, guild, delisted, fullname, pcount, autoinv = C_LFGList.GetSearchResultInfo(id)
|
|
ShadowTheAge@12
|
167 if delisted then return 0 end
|
|
ShadowTheAge@12
|
168 local name,realm = PlayerName(fullname);
|
|
ShadowTheAge@29
|
169 local stoplist = db.global.stoplist or {}
|
|
ShadowTheAge@29
|
170 local ldesc = string.lower(caption) .. "|" .. string.lower(desc);
|
|
ShadowTheAge@29
|
171 local isHopGroup = string.find(ldesc, "realm hop")
|
|
ShadowTheAge@29
|
172 for i=1, #stoplist do
|
|
ShadowTheAge@29
|
173 if string.find(ldesc, stoplist[i], 1, true) then return 0 end
|
|
ShadowTheAge@29
|
174 end
|
|
ShadowTheAge@12
|
175 if forAutoJoin then
|
|
ShadowTheAge@27
|
176 if not autoinv or recentgroups[fullname] or (not isHopGroup and (pcount >= 35 or pcount <= 5)) then return 0 end
|
|
ShadowTheAge@12
|
177 end
|
|
ShadowTheAge@12
|
178
|
|
ShadowTheAge@12
|
179 local autoinvWeight = autoinv and 5 or 2
|
|
ShadowTheAge@29
|
180 local hopCoef = isHopGroup and 3 or 1
|
|
ShadowTheAge@12
|
181
|
|
ShadowTheAge@12
|
182 local visCoef = 1
|
|
ShadowTheAge@12
|
183 if recentgroups[fullname] then
|
|
ShadowTheAge@12
|
184 local ago = GetTime() - recentgroups[fullname].time;
|
|
ShadowTheAge@12
|
185 visCoef = math.min(1,ago/600)
|
|
ShadowTheAge@12
|
186 end
|
|
ShadowTheAge@12
|
187
|
|
ShadowTheAge@12
|
188 local leaderRealm = 3 -- recently visited realms
|
|
ShadowTheAge@13
|
189 local realmVis = recentRealms[realm]
|
|
ShadowTheAge@13
|
190 local leaderRealm = 3;
|
|
ShadowTheAge@13
|
191 if realmVis then
|
|
ShadowTheAge@13
|
192 local ago = GetTime() - realmVis
|
|
ShadowTheAge@13
|
193 leaderRealm = 1 + 2*math.min(1,ago/600);
|
|
ShadowTheAge@13
|
194 end
|
|
ShadowTheAge@12
|
195
|
|
ShadowTheAge@12
|
196 local countWeight = 4 -- count weight
|
|
ShadowTheAge@29
|
197 if not isHopGroup then
|
|
ShadowTheAge@29
|
198 if pcount >= 39 or pcount <= 1 then countWeight = 1
|
|
ShadowTheAge@29
|
199 elseif pcount >= 35 or pcount <= 5 then countWeight = 2
|
|
ShadowTheAge@29
|
200 elseif pcount >= 30 or pcount <= 10 then countWeight = 3 end
|
|
ShadowTheAge@27
|
201 end
|
|
ShadowTheAge@12
|
202
|
|
ShadowTheAge@12
|
203 local ageWeight = 2
|
|
ShadowTheAge@12
|
204 if time > 1200 then ageWeight = 4
|
|
ShadowTheAge@12
|
205 elseif time > 300 then ageWeight = 3 end
|
|
ShadowTheAge@12
|
206
|
|
ShadowTheAge@27
|
207 return leaderRealm * countWeight * visCoef * autoinvWeight * ageWeight * hopCoef;
|
|
ShadowTheAge@12
|
208 end
|
|
ShadowTheAge@12
|
209
|
|
ShadowTheAge@13
|
210 local function AddLfgGroupInfo(id, short)
|
|
ShadowTheAge@13
|
211 local _, action, caption, desc, voice, ilvl, time, bnetfr, charfr, guild, delisted, fullname, pcount, autoinv = C_LFGList.GetSearchResultInfo(id)
|
|
ShadowTheAge@12
|
212 local friends = bnetfr+charfr+guild
|
|
ShadowTheAge@12
|
213 GameTooltip:ClearLines()
|
|
ShadowTheAge@12
|
214 GameTooltip:AddLine(caption,1,1,1)
|
|
ShadowTheAge@12
|
215 addTooltipLineIcon(desc ~= "", desc, nil, 0.5, 0.5, 0.5, true)
|
|
ShadowTheAge@12
|
216 local name, realm = PlayerName(fullname)
|
|
ShadowTheAge@13
|
217 GameTooltip:AddDoubleLine("Players:",pcount)
|
|
ShadowTheAge@12
|
218 GameTooltip:AddDoubleLine("Leader:",name)
|
|
ShadowTheAge@12
|
219 GameTooltip:AddDoubleLine("Leader realm:",realm)
|
|
ShadowTheAge@13
|
220 if recentRealms[realm] then
|
|
ShadowTheAge@13
|
221 local ago = GetTime() - recentRealms[realm]
|
|
ShadowTheAge@13
|
222 GameTooltip:AddDoubleLine("Realm visited",SecondsToTime(ago, false, false, 1, false).." ago",1,0.5,0,1,0.5,0)
|
|
ShadowTheAge@13
|
223 else
|
|
ShadowTheAge@13
|
224 GameTooltip:AddDoubleLine(" ","Realm not visited!",0,0,0,0,1,0)
|
|
ShadowTheAge@13
|
225 end
|
|
ShadowTheAge@13
|
226 if not short then
|
|
ShadowTheAge@13
|
227 addTooltipLineIcon(ilvl > 0, "Min. ilvl: "..ilvl, READY_CHECK_WAITING_TEXTURE, 1, 1, 0)
|
|
ShadowTheAge@13
|
228 addTooltipLineIcon(voice ~= "", "Voice: "..voice, READY_CHECK_WAITING_TEXTURE, 1, 1, 0)
|
|
ShadowTheAge@13
|
229 addTooltipLineIcon(friends > 0, "Friends: "..friends, READY_CHECK_WAITING_TEXTURE, 1, 1, 0)
|
|
ShadowTheAge@13
|
230 addTooltipLineIcon(autoinv, "Autoinvite!", READY_CHECK_READY_TEXTURE, 0, 1, 0)
|
|
ShadowTheAge@13
|
231 local visitinfo = recentgroups[fullname]
|
|
ShadowTheAge@13
|
232 if visitinfo then
|
|
ShadowTheAge@13
|
233 local ago = GetTime() - visitinfo.time;
|
|
ShadowTheAge@13
|
234 GameTooltip:AddDoubleLine(StatusTable[visitinfo.status] or visitinfo.status,SecondsToTime(ago, false, false, 1, false).." ago",1,0,0,1,0,0)
|
|
ShadowTheAge@13
|
235 GameTooltip:AddTexture(READY_CHECK_NOT_READY_TEXTURE)
|
|
ShadowTheAge@13
|
236 end
|
|
ShadowTheAge@12
|
237 end
|
|
ShadowTheAge@12
|
238 GameTooltip:Show()
|
|
ShadowTheAge@12
|
239 end
|
|
ShadowTheAge@12
|
240
|
|
ShadowTheAge@13
|
241 local function ShowLfgInfo(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
|
|
ShadowTheAge@13
|
242 if not realrow then return end
|
|
ShadowTheAge@13
|
243 local rowdata = scrollingTable:GetRow(realrow);
|
|
ShadowTheAge@13
|
244 GameTooltip:SetOwner(rowFrame, "ANCHOR_BOTTOMLEFT",-10,25)
|
|
ShadowTheAge@13
|
245 AddLfgGroupInfo(rowdata.id);
|
|
ShadowTheAge@13
|
246 end
|
|
ShadowTheAge@13
|
247
|
|
ShadowTheAge@12
|
248 local function updateTableData(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
|
|
ShadowTheAge@12
|
249 if fShow then
|
|
ShadowTheAge@12
|
250 local rowdata = table:GetRow(realrow);
|
|
ShadowTheAge@12
|
251 local icons = cellFrame.icons
|
|
ShadowTheAge@12
|
252 local _, action, caption, desc, voice, ilvl, time, bnetfr, charfr, guild, delisted, fullname, pcount, autoinv = C_LFGList.GetSearchResultInfo(rowdata.id)
|
|
ShadowTheAge@12
|
253 if not icons then
|
|
ShadowTheAge@12
|
254 local miscdata = createIcon(cellFrame,READY_CHECK_WAITING_TEXTURE,0)
|
|
ShadowTheAge@12
|
255 local autoinv = createIcon(cellFrame,READY_CHECK_READY_TEXTURE, 1)
|
|
ShadowTheAge@12
|
256 local visited = createIcon(cellFrame,READY_CHECK_NOT_READY_TEXTURE, 2)
|
|
ShadowTheAge@12
|
257 icons = {misc=miscdata, autoinv=autoinv, visited=visited}
|
|
ShadowTheAge@12
|
258 cellFrame.icons = icons
|
|
ShadowTheAge@12
|
259 end
|
|
ShadowTheAge@12
|
260 icons.misc:SetShown(voice ~= "" or bnetfr > 0 or charfr > 0 or guild > 0 or ilvl > 0)
|
|
ShadowTheAge@12
|
261 icons.autoinv:SetShown(autoinv)
|
|
ShadowTheAge@12
|
262 icons.visited:SetShown(recentgroups[fullname])
|
|
ShadowTheAge@12
|
263 if GameTooltip:GetOwner() == rowFrame then ShowLfgInfo(rowFrame, cellFrame, data, cols, row, realrow, column, table) end
|
|
ShadowTheAge@12
|
264 end
|
|
ShadowTheAge@12
|
265 end
|
|
ShadowTheAge@12
|
266
|
|
ShadowTheAge@12
|
267 local function updateGroupName(id)
|
|
ShadowTheAge@12
|
268 return select(3, C_LFGList.GetSearchResultInfo(id))
|
|
ShadowTheAge@12
|
269 end
|
|
ShadowTheAge@12
|
270
|
|
ShadowTheAge@12
|
271 local function updateGroupCount(id)
|
|
ShadowTheAge@12
|
272 return select(13, C_LFGList.GetSearchResultInfo(id))
|
|
ShadowTheAge@12
|
273 end
|
|
ShadowTheAge@12
|
274
|
|
ShadowTheAge@12
|
275 local function updateGroupRealm(id)
|
|
ShadowTheAge@12
|
276 local name = select(12, C_LFGList.GetSearchResultInfo(id))
|
|
ShadowTheAge@12
|
277 local pname, realm = PlayerName(name);
|
|
ShadowTheAge@12
|
278 return realm
|
|
ShadowTheAge@12
|
279 end
|
|
ShadowTheAge@12
|
280
|
|
ShadowTheAge@13
|
281 local COLOR_YELLOW = {r=1,g=1,b=0,a=1}
|
|
ShadowTheAge@13
|
282 local COLOR_GREEN = {r=0,g=1,b=0,a=1}
|
|
ShadowTheAge@13
|
283 local function updateRealmColor(id)
|
|
ShadowTheAge@13
|
284 local name = select(12, C_LFGList.GetSearchResultInfo(id))
|
|
ShadowTheAge@13
|
285 local pname, realm = PlayerName(name);
|
|
ShadowTheAge@13
|
286 return recentRealms[realm] and COLOR_YELLOW or COLOR_GREEN;
|
|
ShadowTheAge@13
|
287 end
|
|
ShadowTheAge@13
|
288
|
|
ShadowTheAge@12
|
289 local function filterTable(self, row)
|
|
ShadowTheAge@25
|
290 local _, _, _, _, _, _, _, _, _, _, delisted, _, pcount, autoinv = C_LFGList.GetSearchResultInfo(row.id)
|
|
ShadowTheAge@25
|
291 if delisted then return false end;
|
|
ShadowTheAge@25
|
292 if pcount > 5 and cbHideRaids:GetChecked() then return false end;
|
|
ShadowTheAge@25
|
293 if pcount <= 5 and cbHideGroups:GetChecked() then return false end;
|
|
ShadowTheAge@25
|
294 if not autoinv and cbHideNoAutoinv:GetChecked() then return false end;
|
|
ShadowTheAge@25
|
295 return true;
|
|
ShadowTheAge@12
|
296 end
|
|
ShadowTheAge@12
|
297
|
|
ShadowTheAge@12
|
298 function addon:UpdateResponseData(event, result)
|
|
ShadowTheAge@13
|
299 if not lfgTable then return end
|
|
ShadowTheAge@12
|
300 if select(11, C_LFGList.GetSearchResultInfo(result)) then
|
|
ShadowTheAge@12
|
301 lfgTable:SetFilter(filterTable)
|
|
ShadowTheAge@12
|
302 end
|
|
ShadowTheAge@12
|
303 hasLfgListChanges = true
|
|
ShadowTheAge@12
|
304 end
|
|
ShadowTheAge@12
|
305
|
|
ShadowTheAge@12
|
306 local function refreshLFGList()
|
|
ShadowTheAge@12
|
307 if lfgScanInProgress or not lfgTable then return end
|
|
ShadowTheAge@12
|
308 local count, list = C_LFGList.GetSearchResults()
|
|
ShadowTheAge@12
|
309 local tableData = {}
|
|
ShadowTheAge@12
|
310 for i = 1,count do
|
|
ShadowTheAge@12
|
311 local rid = list[i];
|
|
ShadowTheAge@12
|
312 if not rid then break end
|
|
ShadowTheAge@12
|
313 local data = list[i];
|
|
ShadowTheAge@12
|
314 local cols = {}
|
|
ShadowTheAge@12
|
315 local row = {rid}
|
|
ShadowTheAge@12
|
316 cols[1] = {value=updateGroupName,args=row}
|
|
ShadowTheAge@12
|
317 cols[2] = {value=updateGroupCount,args=row}
|
|
ShadowTheAge@13
|
318 cols[3] = {value=updateGroupRealm,args=row,color=updateRealmColor,colorargs=row}
|
|
ShadowTheAge@12
|
319 cols[4] = {}
|
|
ShadowTheAge@12
|
320 table.insert(tableData, {cols=cols,id=rid,weight=WeightLfgItem(rid)})
|
|
ShadowTheAge@12
|
321 end
|
|
ShadowTheAge@12
|
322 table.sort(tableData, sortByWeight);
|
|
ShadowTheAge@12
|
323 lfgTable:SetData(tableData)
|
|
ShadowTheAge@21
|
324 if #tableData == 0 then
|
|
ShadowTheAge@21
|
325 lbThrottle:SetText("No groups found")
|
|
ShadowTheAge@21
|
326 end
|
|
ShadowTheAge@12
|
327 end
|
|
ShadowTheAge@12
|
328
|
|
ShadowTheAge@13
|
329 local function JoinGroup(rid)
|
|
ShadowTheAge@13
|
330 local tank, heal, dd = C_LFGList.GetAvailableRoles()
|
|
ShadowTheAge@25
|
331 local noHealTank = not db.global.applyAsDD;
|
|
ShadowTheAge@13
|
332 addon:SetGroupJoinStatus(rid, "_init")
|
|
ShadowTheAge@25
|
333 C_LFGList.ApplyToGroup(rid, "", tank and noHealTank, heal and noHealTank, dd)
|
|
ShadowTheAge@13
|
334 end
|
|
ShadowTheAge@13
|
335
|
|
ShadowTheAge@13
|
336 local function TableCellClick(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
|
|
ShadowTheAge@12
|
337 if not realrow or not canJoinGroup() then return end
|
|
ShadowTheAge@12
|
338 local rowdata = scrollingTable:GetRow(realrow);
|
|
ShadowTheAge@13
|
339 JoinGroup(rowdata.id)
|
|
ShadowTheAge@12
|
340 end
|
|
ShadowTheAge@12
|
341
|
|
ShadowTheAge@12
|
342
|
|
ShadowTheAge@12
|
343
|
|
ShadowTheAge@12
|
344
|
|
ShadowTheAge@12
|
345
|
|
ShadowTheAge@12
|
346
|
|
ShadowTheAge@12
|
347 -- Addon functions and gui constructors
|
|
ShadowTheAge@12
|
348
|
|
ShadowTheAge@13
|
349 function addon.ShowMmTooltip(tooltip)
|
|
ShadowTheAge@13
|
350 tooltip:AddLine("Cross Realm Assist",1,1,1)
|
|
ShadowTheAge@13
|
351 tooltip:Show()
|
|
ShadowTheAge@13
|
352 end
|
|
ShadowTheAge@13
|
353
|
|
ShadowTheAge@13
|
354 function addon:OnInitialize()
|
|
ShadowTheAge@13
|
355 db = LibStub("AceDB-3.0"):New("CrossRealmAssistDB", SettingsDefaults)
|
|
ShadowTheAge@13
|
356 local minimapData = ldb:NewDataObject("CrossRealmAssistMinimapIcon",{
|
|
ShadowTheAge@13
|
357 type = "data source",
|
|
ShadowTheAge@13
|
358 text = "Cross Realm Assist",
|
|
ShadowTheAge@13
|
359 icon = "Interface/Icons/INV_Misc_GroupNeedMore",
|
|
ShadowTheAge@13
|
360 OnClick = addon.Activate,
|
|
ShadowTheAge@13
|
361 OnTooltipShow = addon.ShowMmTooltip
|
|
ShadowTheAge@13
|
362 })
|
|
ShadowTheAge@13
|
363 minimapIcon:Register("CrossRealmAssistMinimapIcon", minimapData, db.global.minimap)
|
|
ShadowTheAge@13
|
364 end
|
|
ShadowTheAge@13
|
365
|
|
ShadowTheAge@0
|
366 function addon:OnEnable()
|
|
ShadowTheAge@0
|
367 realmSep = _G.REALM_SEPARATORS
|
|
ShadowTheAge@11
|
368 playerName = UnitName("player")
|
|
ShadowTheAge@0
|
369 homeRealm = GetRealmName()
|
|
ShadowTheAge@0
|
370 addon:RegisterChatCommand("cra", "Activate")
|
|
ShadowTheAge@0
|
371 addon:RegisterChatCommand("crossrealmassist", "Activate")
|
|
ShadowTheAge@29
|
372 if db.global.autoCreateHopGroup then
|
|
ShadowTheAge@29
|
373 addon:RegisterEvent("PLAYER_FLAGS_CHANGED", "PlayerFlagsUpdate")
|
|
ShadowTheAge@29
|
374 end
|
|
ShadowTheAge@0
|
375 end
|
|
ShadowTheAge@0
|
376
|
|
ShadowTheAge@0
|
377 function addon:OnDisable()
|
|
ShadowTheAge@0
|
378 addon:Deactivate()
|
|
ShadowTheAge@0
|
379 end
|
|
ShadowTheAge@0
|
380
|
|
ShadowTheAge@0
|
381 function addon:Activate()
|
|
ShadowTheAge@0
|
382 if active then return end
|
|
ShadowTheAge@0
|
383 active=true
|
|
ShadowTheAge@0
|
384 wasInGroup = IsInGroup()
|
|
ShadowTheAge@11
|
385 if not gui then addon:CreateUI() end
|
|
ShadowTheAge@11
|
386 addon:updateCurrentRealm();
|
|
ShadowTheAge@13
|
387 addon:RefreshZoneAndClearHistory();
|
|
ShadowTheAge@11
|
388 gui:Show()
|
|
ShadowTheAge@13
|
389 addon:RegisterEvent("ZONE_CHANGED_NEW_AREA", "RefreshZoneAndClearHistory")
|
|
ShadowTheAge@13
|
390 addon:RegisterEvent("SCENARIO_UPDATE", "RefreshZoneAndClearHistory")
|
|
ShadowTheAge@12
|
391 addon:RegisterEvent("LFG_LIST_SEARCH_RESULTS_RECEIVED", "LfgResponseData")
|
|
ShadowTheAge@12
|
392 addon:RegisterEvent("LFG_LIST_SEARCH_RESULT_UPDATED", "UpdateResponseData")
|
|
ShadowTheAge@12
|
393 addon:RegisterEvent("LFG_LIST_SEARCH_FAILED", "LfgScanFailed")
|
|
ShadowTheAge@12
|
394 addon:RegisterEvent("GROUP_ROSTER_UPDATE", "updatePartyInfo")
|
|
ShadowTheAge@12
|
395 addon:RegisterEvent("LFG_LIST_APPLICATION_STATUS_UPDATED", "updateAppStatus")
|
|
ShadowTheAge@13
|
396 addon.LfgScan(addon.GetNextAutoScanCategory() or 1)
|
|
ShadowTheAge@0
|
397 end
|
|
ShadowTheAge@0
|
398
|
|
ShadowTheAge@0
|
399 function addon:Deactivate()
|
|
ShadowTheAge@0
|
400 if not active then return end
|
|
ShadowTheAge@0
|
401 active = false
|
|
ShadowTheAge@12
|
402 gui:Hide()
|
|
ShadowTheAge@12
|
403 if lfgui then lfgui:Hide() end
|
|
ShadowTheAge@0
|
404 scanstate = 0
|
|
ShadowTheAge@0
|
405 lfgScanInProgress = false
|
|
ShadowTheAge@0
|
406 addon:UnregisterEvent("ZONE_CHANGED_NEW_AREA")
|
|
ShadowTheAge@17
|
407 addon:UnregisterEvent("SCENARIO_UPDATE")
|
|
ShadowTheAge@0
|
408 addon:UnregisterEvent("PLAYER_REGEN_ENABLED")
|
|
ShadowTheAge@0
|
409 addon:UnregisterEvent("LFG_LIST_SEARCH_RESULTS_RECEIVED")
|
|
ShadowTheAge@12
|
410 addon:UnregisterEvent("LFG_LIST_SEARCH_RESULT_UPDATED")
|
|
ShadowTheAge@0
|
411 addon:UnregisterEvent("LFG_LIST_SEARCH_FAILED")
|
|
ShadowTheAge@0
|
412 addon:UnregisterEvent("GROUP_ROSTER_UPDATE")
|
|
ShadowTheAge@0
|
413 addon:UnregisterEvent("LFG_LIST_APPLICATION_STATUS_UPDATED")
|
|
ShadowTheAge@0
|
414 end
|
|
ShadowTheAge@0
|
415
|
|
ShadowTheAge@11
|
416 function addon:SetStatus(status)
|
|
ShadowTheAge@11
|
417 if status then
|
|
ShadowTheAge@11
|
418 lbStatus:SetText(status)
|
|
ShadowTheAge@11
|
419 else
|
|
ShadowTheAge@13
|
420 lbStatus:SetText("")
|
|
ShadowTheAge@11
|
421 end
|
|
ShadowTheAge@11
|
422 end
|
|
ShadowTheAge@11
|
423
|
|
ShadowTheAge@13
|
424 local function stopMovingWidget()
|
|
ShadowTheAge@13
|
425 gui:StopMovingOrSizing()
|
|
ShadowTheAge@13
|
426 local point,_,_,x,y = gui:GetPoint(1);
|
|
ShadowTheAge@13
|
427 db.global.widgetPos = {x=x,y=y,to=point}
|
|
ShadowTheAge@13
|
428 end
|
|
ShadowTheAge@13
|
429
|
|
ShadowTheAge@0
|
430 function addon:CreateUI()
|
|
ShadowTheAge@25
|
431 gui = setupWidget(CreateFrame("Frame","CrossRealmAssistMainUI",nil,"InsetFrameTemplate3"), {SetFrameStrata="LOW",SetWidth=208,SetHeight=60,EnableMouse=true,SetMovable=true,SetClampedToScreen=true})
|
|
ShadowTheAge@11
|
432 local title = setupWidget(CreateFrame("Frame",nil,gui), {SetWidth=190,SetHeight=18,EnableMouse=true,RegisterForDrag="LeftButton"}, 0, 6);
|
|
ShadowTheAge@11
|
433 title:SetScript("OnDragStart", function() gui:StartMoving() end)
|
|
ShadowTheAge@13
|
434 title:SetScript("OnDragStop", stopMovingWidget)
|
|
ShadowTheAge@11
|
435 gui:SetScript("OnHide", addon.Deactivate)
|
|
ShadowTheAge@12
|
436 setupTooltip(title, "ANCHOR_TOP", realmToolip)
|
|
ShadowTheAge@11
|
437
|
|
ShadowTheAge@11
|
438 lbRealm = setupWidget(gui:CreateFontString(nil,"BACKGROUND", "GameFontNormal"), {SetWidth=200,SetHeight=18}, 0, 6)
|
|
ShadowTheAge@11
|
439 lbStatus = setupWidget(gui:CreateFontString(nil,"BACKGROUND", "GameFontHighlightSmallLeft"), {SetWidth=200,SetHeight=10}, 6, 23)
|
|
ShadowTheAge@11
|
440
|
|
ShadowTheAge@12
|
441 btQuick = setupWidget(CreateFrame("Button",nil,gui,"UIMenuButtonStretchTemplate"),{SetWidth=90,SetHeight=20,SetText="Quick join"},4,36)
|
|
ShadowTheAge@13
|
442 btQuick:RegisterForClicks("RightButtonUp","LeftButtonUp")
|
|
ShadowTheAge@12
|
443 btQuick:SetScript("OnClick",addon.DoAutoAction)
|
|
ShadowTheAge@13
|
444 setupTooltip(btQuick, "ANCHOR_BOTTOM", addon.actionTooltip)
|
|
ShadowTheAge@12
|
445 btManual = setupWidget(CreateFrame("Button",nil,gui,"UIMenuButtonStretchTemplate"),{SetWidth=90,SetHeight=20,SetText="Manual join"},94,36)
|
|
ShadowTheAge@12
|
446 btManual:SetScript("OnClick",addon.ShowManualLfg)
|
|
ShadowTheAge@11
|
447 setupWidget(CreateFrame("Button",nil,gui,"UIPanelCloseButton"),{EnableMouse=true,SetWidth=20,SetHeight=20},188,0)
|
|
ShadowTheAge@11
|
448
|
|
ShadowTheAge@13
|
449 btRefresh = setupWidget(CreateFrame("Button",nil,gui,"UIPanelSquareButton"),{SetWidth=20,SetHeight=20},184,16)
|
|
ShadowTheAge@11
|
450 btRefresh.icon:SetTexture("Interface/BUTTONS/UI-RefreshButton")
|
|
ShadowTheAge@11
|
451 btRefresh.icon:SetTexCoord(0,1,0,1);
|
|
ShadowTheAge@11
|
452 btRefresh:SetScript("OnClick",addon.RefreshZone)
|
|
ShadowTheAge@11
|
453
|
|
ShadowTheAge@13
|
454 btSettings = setupWidget(CreateFrame("Button",nil,gui,"UIPanelSquareButton"),{SetWidth=20,SetHeight=20},184,36)
|
|
ShadowTheAge@13
|
455 btSettings.icon:SetTexture("Interface/Worldmap/Gear_64Grey")
|
|
ShadowTheAge@13
|
456 btSettings.icon:SetTexCoord(0.1,0.9,0.1,0.9);
|
|
ShadowTheAge@13
|
457 btSettings:SetScript("OnClick",addon.ShowSettings)
|
|
ShadowTheAge@13
|
458
|
|
ShadowTheAge@13
|
459 local savedPos = db.global.widgetPos
|
|
ShadowTheAge@13
|
460 gui:SetPoint(savedPos.to,savedPos.x,savedPos.y)
|
|
ShadowTheAge@12
|
461 addon:UpdateAutoButtonStatus()
|
|
ShadowTheAge@21
|
462
|
|
ShadowTheAge@21
|
463 local languages = C_LFGList.GetAvailableLanguageSearchFilter()
|
|
ShadowTheAge@21
|
464 for i=1,#languages do
|
|
ShadowTheAge@21
|
465 allLanguageTable[languages[i]] = true;
|
|
ShadowTheAge@21
|
466 end
|
|
ShadowTheAge@12
|
467 end
|
|
ShadowTheAge@11
|
468
|
|
ShadowTheAge@12
|
469 function addon:ShowManualLfg()
|
|
ShadowTheAge@12
|
470 if not lfgui then addon:CreateLFGUI() end
|
|
ShadowTheAge@12
|
471 lfgui:Show()
|
|
ShadowTheAge@12
|
472 end
|
|
ShadowTheAge@0
|
473
|
|
ShadowTheAge@12
|
474 function addon.lfgUpdate()
|
|
ShadowTheAge@12
|
475 if hasLfgListChanges then
|
|
ShadowTheAge@12
|
476 lfgTable:Refresh()
|
|
ShadowTheAge@12
|
477 hasLfgListChanges = false
|
|
ShadowTheAge@12
|
478 end
|
|
ShadowTheAge@12
|
479 end
|
|
ShadowTheAge@0
|
480
|
|
ShadowTheAge@25
|
481 function addon.refreshList()
|
|
ShadowTheAge@25
|
482 lfgTable:SetFilter(filterTable)
|
|
ShadowTheAge@25
|
483 end
|
|
ShadowTheAge@25
|
484
|
|
ShadowTheAge@12
|
485 function addon:CreateLFGUI()
|
|
ShadowTheAge@25
|
486 lfgui = setupWidget(CreateFrame("Frame","CrossRealmAssistJoinUI",nil,"UIPanelDialogTemplate"), {SetFrameStrata="DIALOG",SetWidth=405,SetHeight=323,EnableMouse=true,SetMovable=true})
|
|
ShadowTheAge@12
|
487 lfgui.title:SetText("Click to join group")
|
|
ShadowTheAge@12
|
488 lfgui:SetScript("OnUpdate",addon.lfgUpdate)
|
|
ShadowTheAge@12
|
489 local titlereg = lfgui:CreateTitleRegion()
|
|
ShadowTheAge@12
|
490 titlereg:SetAllPoints(lfgui.title)
|
|
ShadowTheAge@12
|
491 addon:CreateTabs()
|
|
ShadowTheAge@0
|
492
|
|
ShadowTheAge@12
|
493 lfgTable = ScrollingTable:CreateST({
|
|
ShadowTheAge@12
|
494 {name="Title",width=160},
|
|
ShadowTheAge@12
|
495 {name="#",width=30,align="CENTER"},
|
|
ShadowTheAge@12
|
496 {name="Realm",width=120,align="RIGHT"},
|
|
ShadowTheAge@12
|
497 {name="",width=50,DoCellUpdate=updateTableData}
|
|
ShadowTheAge@12
|
498 },15,16,nil,lfgui);
|
|
ShadowTheAge@0
|
499
|
|
ShadowTheAge@13
|
500 lfgTable:RegisterEvents({OnEnter=ShowLfgInfo,OnLeave=HideTooltip,OnClick=TableCellClick})
|
|
ShadowTheAge@0
|
501
|
|
ShadowTheAge@12
|
502 setupWidget(lfgTable.frame, nil, 10, 45);
|
|
ShadowTheAge@12
|
503 lfgTable.frame:SetBackdrop(nil)
|
|
ShadowTheAge@12
|
504 lfgui:SetPoint("CENTER",0,0)
|
|
ShadowTheAge@12
|
505 refreshLFGList()
|
|
ShadowTheAge@0
|
506
|
|
ShadowTheAge@12
|
507 lbThrottle = setupWidget(lfgui:CreateFontString(nil,"BACKGROUND", "GameFontHighlightSmall"), {SetWidth=300}, 50, 100)
|
|
ShadowTheAge@12
|
508 lbThrottle:Hide();
|
|
ShadowTheAge@0
|
509
|
|
ShadowTheAge@12
|
510 local btRefresh = setupWidget(CreateFrame("Button",nil,lfgui,"UIPanelSquareButton"),{SetWidth=22,SetHeight=22},379,27)
|
|
ShadowTheAge@12
|
511 btRefresh.icon:SetTexture("Interface/BUTTONS/UI-RefreshButton")
|
|
ShadowTheAge@12
|
512 btRefresh.icon:SetTexCoord(0,1,0,1);
|
|
ShadowTheAge@12
|
513 btRefresh:SetScript("OnClick",addon.refreshLfgCurrent)
|
|
ShadowTheAge@25
|
514
|
|
ShadowTheAge@25
|
515 setupWidget(CreateFrame("Frame",nil,lfgui,"HorizontalBarTemplate"),{SetWidth=392,SetHeight=2}, 8, 294)
|
|
ShadowTheAge@25
|
516 local text = setupWidget(lfgui:CreateFontString(nil,"BACKGROUND", "GameFontHighlightSmall"), {SetText="Hide:"}, 20, 302)
|
|
ShadowTheAge@25
|
517
|
|
ShadowTheAge@25
|
518 cbHideGroups = setupWidget(CreateFrame("CheckButton",nil,lfgui,"UICheckButtonTemplate"),{SetWidth=22,SetHeight=22})
|
|
ShadowTheAge@25
|
519 cbHideGroups:SetPoint("TOPLEFT",text,"TOPRIGHT",5,7)
|
|
ShadowTheAge@25
|
520 cbHideGroups:SetScript("OnClick",addon.refreshList)
|
|
ShadowTheAge@25
|
521 text = setupWidget(lfgui:CreateFontString(nil,"BACKGROUND", "GameFontHighlightSmall"), {SetText="5p Groups"})
|
|
ShadowTheAge@25
|
522 text:SetPoint("TOPLEFT",cbHideGroups,"TOPRIGHT",0,-7)
|
|
ShadowTheAge@25
|
523
|
|
ShadowTheAge@25
|
524 cbHideRaids = setupWidget(CreateFrame("CheckButton",nil,lfgui,"UICheckButtonTemplate"),{SetWidth=22,SetHeight=22})
|
|
ShadowTheAge@25
|
525 cbHideRaids:SetPoint("TOPLEFT",text,"TOPRIGHT",5,7)
|
|
ShadowTheAge@25
|
526 cbHideRaids:SetScript("OnClick",addon.refreshList)
|
|
ShadowTheAge@25
|
527 text = setupWidget(lfgui:CreateFontString(nil,"BACKGROUND", "GameFontHighlightSmall"), {SetText="Raids"})
|
|
ShadowTheAge@25
|
528 text:SetPoint("TOPLEFT",cbHideRaids,"TOPRIGHT",0,-7)
|
|
ShadowTheAge@25
|
529
|
|
ShadowTheAge@25
|
530 cbHideNoAutoinv = setupWidget(CreateFrame("CheckButton",nil,lfgui,"UICheckButtonTemplate"),{SetWidth=22,SetHeight=22})
|
|
ShadowTheAge@25
|
531 cbHideNoAutoinv:SetPoint("TOPLEFT",text,"TOPRIGHT",5,7)
|
|
ShadowTheAge@25
|
532 cbHideNoAutoinv:SetScript("OnClick",addon.refreshList)
|
|
ShadowTheAge@25
|
533 text = setupWidget(lfgui:CreateFontString(nil,"BACKGROUND", "GameFontHighlightSmall"), {SetText="Groups w/o Autoinvite"})
|
|
ShadowTheAge@25
|
534 text:SetPoint("TOPLEFT",cbHideNoAutoinv,"TOPRIGHT",0,-7)
|
|
ShadowTheAge@12
|
535 end
|
|
ShadowTheAge@0
|
536
|
|
ShadowTheAge@12
|
537 function addon:CreateTabs()
|
|
ShadowTheAge@12
|
538 local prevTab
|
|
ShadowTheAge@12
|
539 for i=1,#lfgGroups do
|
|
ShadowTheAge@12
|
540 local tab = CreateFrame("Button","$parentTab"..i,lfgui,"CharacterFrameTabButtonTemplate")
|
|
ShadowTheAge@12
|
541 tab:SetText((C_LFGList.GetCategoryInfo(lfgGroups[i])));
|
|
ShadowTheAge@13
|
542 tab.searchID = i;
|
|
ShadowTheAge@12
|
543 tab:SetID(i);
|
|
ShadowTheAge@12
|
544 PanelTemplates_TabResize(tab, 0)
|
|
ShadowTheAge@12
|
545 if i == 1 then
|
|
ShadowTheAge@12
|
546 tab:SetPoint("TOPLEFT", lfgui, "BOTTOMLEFT", 10, 7)
|
|
ShadowTheAge@12
|
547 lfgTabSelected = tab
|
|
ShadowTheAge@13
|
548 else
|
|
ShadowTheAge@13
|
549 tab:SetPoint("TOPLEFT", prevTab, "TOPRIGHT",-15,0)
|
|
ShadowTheAge@13
|
550 end
|
|
ShadowTheAge@13
|
551 if curLfgGroup == i then
|
|
ShadowTheAge@12
|
552 PanelTemplates_SelectTab(tab)
|
|
ShadowTheAge@12
|
553 else
|
|
ShadowTheAge@12
|
554 PanelTemplates_DeselectTab(tab)
|
|
ShadowTheAge@12
|
555 end
|
|
ShadowTheAge@13
|
556 tab:SetScript("OnClick", TabClick)
|
|
ShadowTheAge@12
|
557 tabs[i] = tab
|
|
ShadowTheAge@12
|
558 prevTab = tab
|
|
ShadowTheAge@12
|
559 end
|
|
ShadowTheAge@0
|
560 end
|
|
ShadowTheAge@0
|
561
|
|
ShadowTheAge@0
|
562 -- LFG scanning routine
|
|
ShadowTheAge@0
|
563
|
|
ShadowTheAge@12
|
564 function addon.refreshLfgCurrent()
|
|
ShadowTheAge@12
|
565 addon.LfgScan(curLfgGroup)
|
|
ShadowTheAge@0
|
566 end
|
|
ShadowTheAge@0
|
567
|
|
ShadowTheAge@13
|
568 function addon.GetNextAutoScanCategory()
|
|
ShadowTheAge@13
|
569 for i=1,#lfgGroups do
|
|
ShadowTheAge@13
|
570 if not autoScanGroups[i] and db.global.quickJoin[lfgGroups[i]] and i ~= curLfgGroup then return i end
|
|
ShadowTheAge@13
|
571 end
|
|
ShadowTheAge@13
|
572 return nil
|
|
ShadowTheAge@13
|
573 end
|
|
ShadowTheAge@13
|
574
|
|
ShadowTheAge@12
|
575 function addon.LfgScan(group)
|
|
ShadowTheAge@13
|
576 if lfgTable then
|
|
ShadowTheAge@13
|
577 lfgTable:SetData({})
|
|
ShadowTheAge@13
|
578 changeTab(tabs[group])
|
|
ShadowTheAge@13
|
579 end
|
|
ShadowTheAge@0
|
580 lfgScanInProgress = true
|
|
ShadowTheAge@12
|
581 curLfgGroup = group
|
|
ShadowTheAge@21
|
582 local languages = db.global.allLanguages and allLanguageTable or C_LFGList.GetLanguageSearchFilter();
|
|
ShadowTheAge@21
|
583 C_LFGList.Search(lfgGroups[curLfgGroup],"",nil,nil,languages)
|
|
ShadowTheAge@0
|
584 end
|
|
ShadowTheAge@0
|
585
|
|
ShadowTheAge@0
|
586 function addon:LfgScanFailed(event, reason)
|
|
ShadowTheAge@21
|
587 reason = reason or "Unknown reason";
|
|
ShadowTheAge@0
|
588 if reason == "throttled" then
|
|
ShadowTheAge@12
|
589 addon:ScheduleTimer(addon.LfgScan, 2, curLfgGroup)
|
|
ShadowTheAge@0
|
590 end
|
|
ShadowTheAge@13
|
591 if lbThrottle then
|
|
ShadowTheAge@13
|
592 if reason == "throttled" then
|
|
ShadowTheAge@13
|
593 lbThrottle:SetText("LFG scan is delayed (throttled).\nThis page will update automatically...")
|
|
ShadowTheAge@13
|
594 else
|
|
ShadowTheAge@13
|
595 lbThrottle:SetText("Scan failed ("..reason..")")
|
|
ShadowTheAge@13
|
596 end
|
|
ShadowTheAge@13
|
597 lbThrottle:Show()
|
|
ShadowTheAge@13
|
598 end
|
|
ShadowTheAge@0
|
599 end
|
|
ShadowTheAge@0
|
600
|
|
ShadowTheAge@0
|
601 function addon:LfgResponseData()
|
|
ShadowTheAge@0
|
602 lfgScanInProgress = false;
|
|
ShadowTheAge@13
|
603 addon:UpdateAutoButtonStatus()
|
|
ShadowTheAge@12
|
604 if lbThrottle then lbThrottle:Hide() end
|
|
ShadowTheAge@12
|
605 refreshLFGList()
|
|
ShadowTheAge@0
|
606 end
|
|
ShadowTheAge@0
|
607
|
|
ShadowTheAge@0
|
608 function addon:updateAppStatus(event, id, status, oldstatus)
|
|
ShadowTheAge@0
|
609 if status == "invited" then
|
|
ShadowTheAge@0
|
610 LFGListInviteDialog_Accept(LFGListInviteDialog)
|
|
ShadowTheAge@0
|
611 end
|
|
ShadowTheAge@12
|
612 addon:UpdateAutoButtonStatus()
|
|
ShadowTheAge@12
|
613 addon:SetGroupJoinStatus(id, status)
|
|
ShadowTheAge@12
|
614 end
|
|
ShadowTheAge@12
|
615
|
|
ShadowTheAge@12
|
616 function addon:SetGroupJoinStatus(id, status)
|
|
ShadowTheAge@12
|
617 local name = select(12, C_LFGList.GetSearchResultInfo(id))
|
|
ShadowTheAge@13
|
618 if name then
|
|
ShadowTheAge@13
|
619 recentgroups[name] = {status=status, time=GetTime()}
|
|
ShadowTheAge@13
|
620 end
|
|
ShadowTheAge@13
|
621 end
|
|
ShadowTheAge@13
|
622
|
|
ShadowTheAge@13
|
623 function addon:RealmVisited(realm, head)
|
|
ShadowTheAge@13
|
624 recentRealms[realm] = GetTime()
|
|
ShadowTheAge@12
|
625 end
|
|
ShadowTheAge@12
|
626
|
|
ShadowTheAge@12
|
627 function addon:updatePartyInfo()
|
|
ShadowTheAge@27
|
628 if IsInGroup() ~= wasInGroup then
|
|
ShadowTheAge@13
|
629 addon:RefreshZone(true)
|
|
ShadowTheAge@27
|
630 wasInGroup = IsInGroup()
|
|
ShadowTheAge@12
|
631 addon:UpdateAutoButtonStatus()
|
|
ShadowTheAge@12
|
632 end
|
|
ShadowTheAge@12
|
633 end
|
|
ShadowTheAge@12
|
634
|
|
ShadowTheAge@12
|
635
|
|
ShadowTheAge@12
|
636
|
|
ShadowTheAge@0
|
637
|
|
ShadowTheAge@0
|
638 -- Zone scanning routine
|
|
ShadowTheAge@0
|
639
|
|
ShadowTheAge@0
|
640 function addon:LeaveCombat()
|
|
ShadowTheAge@0
|
641 addon:UnregisterEvent("PLAYER_REGEN_ENABLED")
|
|
ShadowTheAge@0
|
642 scanstate = 0
|
|
ShadowTheAge@0
|
643 addon:ScanRealm();
|
|
ShadowTheAge@0
|
644 end
|
|
ShadowTheAge@0
|
645
|
|
ShadowTheAge@13
|
646 function addon:RefreshZoneAndClearHistory()
|
|
ShadowTheAge@13
|
647 ClearRealmHistory()
|
|
ShadowTheAge@11
|
648 addon:RefreshZone(true)
|
|
ShadowTheAge@11
|
649 end
|
|
ShadowTheAge@11
|
650
|
|
ShadowTheAge@11
|
651 function addon:RefreshZone(shedule)
|
|
ShadowTheAge@11
|
652 local inst, instType = IsInInstance()
|
|
ShadowTheAge@12
|
653 inInstance = (inst or instType ~= "none")
|
|
ShadowTheAge@12
|
654 if inInstance then
|
|
ShadowTheAge@11
|
655 lbRealm:SetText("Instanced zone")
|
|
ShadowTheAge@11
|
656 curRealmStat = nil
|
|
ShadowTheAge@12
|
657 inInstance = true
|
|
ShadowTheAge@11
|
658 else
|
|
ShadowTheAge@12
|
659 inInstance = false;
|
|
ShadowTheAge@11
|
660 if scanstate == 0 then
|
|
ShadowTheAge@11
|
661 addon:ScanRealm()
|
|
ShadowTheAge@11
|
662 elseif shedule == true and scanstate == 2 then
|
|
ShadowTheAge@27
|
663 addon:SetStatus("Rescan scheduled...")
|
|
ShadowTheAge@11
|
664 scanstate = 3
|
|
ShadowTheAge@11
|
665 end
|
|
ShadowTheAge@11
|
666 end
|
|
ShadowTheAge@12
|
667 addon:UpdateAutoButtonStatus()
|
|
ShadowTheAge@11
|
668 end
|
|
ShadowTheAge@11
|
669
|
|
ShadowTheAge@0
|
670 function addon:ScanRealm()
|
|
ShadowTheAge@0
|
671 if scanstate > 0 then return end
|
|
ShadowTheAge@0
|
672 if InCombatLockdown() then
|
|
ShadowTheAge@0
|
673 addon:RegisterEvent("PLAYER_REGEN_ENABLED","LeaveCombat")
|
|
ShadowTheAge@0
|
674 scanstate = 1
|
|
ShadowTheAge@27
|
675 addon:SetStatus("Scan scheduled after combat...");
|
|
ShadowTheAge@0
|
676 return
|
|
ShadowTheAge@0
|
677 end
|
|
ShadowTheAge@0
|
678 scanstate = 2
|
|
ShadowTheAge@11
|
679 addon:SetStatus("Scanning current realm...");
|
|
ShadowTheAge@0
|
680 local searchString = _G.WHO_TAG_ZONE .. '"' .. GetZoneText() .. '"';
|
|
ShadowTheAge@0
|
681 wholib:Who(searchString, {callback = "ScanResult", handler=addon})
|
|
ShadowTheAge@0
|
682 end
|
|
ShadowTheAge@0
|
683
|
|
ShadowTheAge@0
|
684 function addon:ScanResult(query, results, complete)
|
|
ShadowTheAge@0
|
685 local realms = {}
|
|
ShadowTheAge@0
|
686 for _, player in ipairs(results) do
|
|
ShadowTheAge@0
|
687 addon:AddRealmStat(player.Name, realms);
|
|
ShadowTheAge@0
|
688 end
|
|
ShadowTheAge@0
|
689 curRealmStat = addon:GetRealmStat(realms);
|
|
ShadowTheAge@11
|
690 curRealmStat.complete = complete
|
|
ShadowTheAge@0
|
691 addon:updateCurrentRealm();
|
|
ShadowTheAge@0
|
692 local rescan = scanstate == 3
|
|
ShadowTheAge@0
|
693 scanstate = 0;
|
|
ShadowTheAge@0
|
694 if rescan then addon:ScanRealm() end
|
|
ShadowTheAge@0
|
695 end
|
|
ShadowTheAge@0
|
696
|
|
ShadowTheAge@0
|
697 function addon:AddRealmStat(name, realms)
|
|
ShadowTheAge@11
|
698 if (name == playerName) then return end
|
|
ShadowTheAge@11
|
699 local _, realm = strsplit(realmSep, name)
|
|
ShadowTheAge@0
|
700 realm = realm or homeRealm
|
|
ShadowTheAge@0
|
701 realms[realm] = (realms[realm] or 0) + 1
|
|
ShadowTheAge@0
|
702 end
|
|
ShadowTheAge@0
|
703
|
|
ShadowTheAge@0
|
704 function addon:AddUnitIdStat(unitid, realms)
|
|
ShadowTheAge@0
|
705 local name, realm = UnitName(unitid);
|
|
ShadowTheAge@0
|
706 if not name then return end
|
|
ShadowTheAge@0
|
707 if realm == "" then realm = homeRealm end
|
|
ShadowTheAge@0
|
708 realm = realm or homeRealm
|
|
ShadowTheAge@0
|
709 realms[realm] = (realms[realm] or 0) + 1
|
|
ShadowTheAge@0
|
710 end
|
|
ShadowTheAge@0
|
711
|
|
ShadowTheAge@0
|
712 function addon:GetRealmStat(realms)
|
|
ShadowTheAge@0
|
713 local rcount = 0;
|
|
ShadowTheAge@0
|
714 local stat = {};
|
|
ShadowTheAge@0
|
715 local pcount = 0;
|
|
ShadowTheAge@19
|
716 if realms then
|
|
ShadowTheAge@19
|
717 for realm,count in pairs(realms) do
|
|
ShadowTheAge@19
|
718 table.insert(stat,{realm=realm,count=count})
|
|
ShadowTheAge@19
|
719 rcount = rcount + 1;
|
|
ShadowTheAge@19
|
720 pcount = pcount + count;
|
|
ShadowTheAge@19
|
721 end
|
|
ShadowTheAge@0
|
722 end
|
|
ShadowTheAge@0
|
723 if rcount > 1 then
|
|
ShadowTheAge@0
|
724 table.sort(stat, function(a,b) return a.count > b.count end)
|
|
ShadowTheAge@0
|
725 stat.max = stat[1].count
|
|
ShadowTheAge@0
|
726 else stat.max = 0 end
|
|
ShadowTheAge@0
|
727 stat.players = pcount;
|
|
ShadowTheAge@0
|
728 stat.realms = rcount;
|
|
ShadowTheAge@0
|
729 return stat;
|
|
ShadowTheAge@0
|
730 end
|
|
ShadowTheAge@0
|
731
|
|
ShadowTheAge@0
|
732 function addon:updateCurrentRealm()
|
|
ShadowTheAge@11
|
733 addon:SetStatus();
|
|
ShadowTheAge@11
|
734 if not curRealmStat or curRealmStat.realms < 1 then
|
|
ShadowTheAge@11
|
735 lbRealm:SetText("Unknown realm (No players)")
|
|
ShadowTheAge@11
|
736 return;
|
|
ShadowTheAge@0
|
737 end
|
|
ShadowTheAge@11
|
738
|
|
ShadowTheAge@11
|
739 local bestRealm = curRealmStat[1]
|
|
ShadowTheAge@13
|
740 addon:RealmVisited(bestRealm.realm, true)
|
|
ShadowTheAge@12
|
741 local prevThreshold = math.min(bestRealm.count/3,10)
|
|
ShadowTheAge@11
|
742 local mixCount = 0
|
|
ShadowTheAge@11
|
743 for i=2,curRealmStat.realms do
|
|
ShadowTheAge@0
|
744 local data = curRealmStat[i]
|
|
ShadowTheAge@11
|
745 if data.count >= prevThreshold then
|
|
ShadowTheAge@11
|
746 mixCount = mixCount + 1
|
|
ShadowTheAge@13
|
747 addon:RealmVisited(data.realm)
|
|
ShadowTheAge@12
|
748 prevThreshold = math.min(data.count/3,10)
|
|
ShadowTheAge@0
|
749 end
|
|
ShadowTheAge@0
|
750 end
|
|
ShadowTheAge@11
|
751 curRealmStat.threshold = prevThreshold
|
|
ShadowTheAge@11
|
752
|
|
ShadowTheAge@11
|
753 if (mixCount > 0) then
|
|
ShadowTheAge@11
|
754 lbRealm:SetText("Mixed "..bestRealm.realm.." +"..mixCount)
|
|
ShadowTheAge@11
|
755 else
|
|
ShadowTheAge@11
|
756 lbRealm:SetText(bestRealm.realm)
|
|
ShadowTheAge@0
|
757 end
|
|
ShadowTheAge@0
|
758 end
|
|
ShadowTheAge@0
|
759
|
|
ShadowTheAge@12
|
760
|
|
ShadowTheAge@12
|
761
|
|
ShadowTheAge@12
|
762
|
|
ShadowTheAge@12
|
763
|
|
ShadowTheAge@12
|
764
|
|
ShadowTheAge@12
|
765 -- Auto action button
|
|
ShadowTheAge@12
|
766
|
|
ShadowTheAge@13
|
767 local action
|
|
ShadowTheAge@12
|
768
|
|
ShadowTheAge@27
|
769 local function getPartyStat()
|
|
ShadowTheAge@29
|
770 local curPartyStat = {}
|
|
ShadowTheAge@27
|
771 if IsInGroup() then
|
|
ShadowTheAge@27
|
772 if IsInRaid() then
|
|
ShadowTheAge@27
|
773 for i=1, MAX_RAID_MEMBERS do
|
|
ShadowTheAge@27
|
774 addon:AddUnitIdStat("raid"..i, curPartyStat)
|
|
ShadowTheAge@27
|
775 end
|
|
ShadowTheAge@27
|
776 else
|
|
ShadowTheAge@27
|
777 for i=1, MAX_PARTY_MEMBERS do
|
|
ShadowTheAge@27
|
778 addon:AddUnitIdStat("party"..i, curPartyStat)
|
|
ShadowTheAge@27
|
779 end
|
|
ShadowTheAge@27
|
780 end
|
|
ShadowTheAge@27
|
781 end
|
|
ShadowTheAge@29
|
782 return curPartyStat
|
|
ShadowTheAge@27
|
783 end
|
|
ShadowTheAge@27
|
784
|
|
ShadowTheAge@13
|
785 local LeaveGroup = {
|
|
ShadowTheAge@13
|
786 func = LeaveParty;
|
|
ShadowTheAge@17
|
787 tooltip = function(self)
|
|
ShadowTheAge@27
|
788 local partyStat = addon:GetRealmStat(getPartyStat())
|
|
ShadowTheAge@17
|
789 GameTooltip:AddLine("Players in party "..partyStat.players)
|
|
ShadowTheAge@17
|
790 local max = partyStat.max;
|
|
ShadowTheAge@17
|
791 for i=1,#partyStat do
|
|
ShadowTheAge@17
|
792 local data = partyStat[i]
|
|
ShadowTheAge@17
|
793 local percent = math.ceil(100 * data.count / partyStat.players - 0.5) .. "%";
|
|
ShadowTheAge@17
|
794 local pmax = data.count/max;
|
|
ShadowTheAge@17
|
795 local green = 0.5 + pmax * 0.5;
|
|
ShadowTheAge@17
|
796 local gray = 0.5 * (1-pmax)
|
|
ShadowTheAge@17
|
797 GameTooltip:AddDoubleLine(data.realm, percent, gray,green,gray,gray,green,gray)
|
|
ShadowTheAge@17
|
798 end
|
|
ShadowTheAge@17
|
799 GameTooltip:AddLine("Click to leave party",1,0.5,0)
|
|
ShadowTheAge@17
|
800 end,
|
|
ShadowTheAge@13
|
801 text = "Leave group"
|
|
ShadowTheAge@13
|
802 }
|
|
ShadowTheAge@13
|
803
|
|
ShadowTheAge@13
|
804 local CancelJoin = {
|
|
ShadowTheAge@13
|
805 func = function()
|
|
ShadowTheAge@13
|
806 local apps = C_LFGList.GetApplications();
|
|
ShadowTheAge@13
|
807 if apps[1] then
|
|
ShadowTheAge@13
|
808 C_LFGList.CancelApplication(apps[1])
|
|
ShadowTheAge@13
|
809 end
|
|
ShadowTheAge@13
|
810 end,
|
|
ShadowTheAge@13
|
811 tooltip = "Cancel your current join application",
|
|
ShadowTheAge@13
|
812 text = "Cancel join"
|
|
ShadowTheAge@13
|
813 }
|
|
ShadowTheAge@13
|
814
|
|
ShadowTheAge@13
|
815 local QuickJoin = {
|
|
ShadowTheAge@13
|
816 func = function(self, button)
|
|
ShadowTheAge@13
|
817 if button == "RightButton" then
|
|
ShadowTheAge@13
|
818 addon:SetGroupJoinStatus(self.groupToJoin, "_skip")
|
|
ShadowTheAge@13
|
819 else
|
|
ShadowTheAge@13
|
820 local delisted = select(11, C_LFGList.GetSearchResultInfo(self.groupToJoin))
|
|
ShadowTheAge@13
|
821 if delisted == false then
|
|
ShadowTheAge@13
|
822 JoinGroup(self.groupToJoin)
|
|
ShadowTheAge@13
|
823 else
|
|
ShadowTheAge@13
|
824 addon:SetStatus("Group just delisted")
|
|
ShadowTheAge@13
|
825 end
|
|
ShadowTheAge@13
|
826 end
|
|
ShadowTheAge@13
|
827 end,
|
|
ShadowTheAge@13
|
828 findGroup = function()
|
|
ShadowTheAge@13
|
829 local count, list = C_LFGList.GetSearchResults()
|
|
ShadowTheAge@13
|
830 local best
|
|
ShadowTheAge@13
|
831 local bestvalue = 0
|
|
ShadowTheAge@13
|
832 for i = 1,count do
|
|
ShadowTheAge@13
|
833 local rid = list[i];
|
|
ShadowTheAge@13
|
834 if not rid then break end
|
|
ShadowTheAge@13
|
835 local value = WeightLfgItem(rid, true);
|
|
ShadowTheAge@13
|
836 if value > bestvalue then
|
|
ShadowTheAge@13
|
837 best = rid
|
|
ShadowTheAge@13
|
838 bestvalue = value
|
|
ShadowTheAge@13
|
839 end
|
|
ShadowTheAge@13
|
840 end
|
|
ShadowTheAge@13
|
841 return best
|
|
ShadowTheAge@13
|
842 end,
|
|
ShadowTheAge@13
|
843 tooltip = function(self)
|
|
ShadowTheAge@13
|
844 AddLfgGroupInfo(self.groupToJoin, true)
|
|
ShadowTheAge@13
|
845 GameTooltip:AddLine(" ")
|
|
ShadowTheAge@13
|
846 GameTooltip:AddDoubleLine("Click to join","Right click to skip",0,1,0,1,0.5,0)
|
|
ShadowTheAge@13
|
847 end,
|
|
ShadowTheAge@13
|
848 text = "Quick join"
|
|
ShadowTheAge@13
|
849 }
|
|
ShadowTheAge@13
|
850
|
|
ShadowTheAge@13
|
851 local ScanNext = {
|
|
ShadowTheAge@13
|
852 func = function(self)
|
|
ShadowTheAge@13
|
853 autoScanGroups[curLfgGroup] = 1
|
|
ShadowTheAge@13
|
854 addon.LfgScan(self.category)
|
|
ShadowTheAge@13
|
855 end,
|
|
ShadowTheAge@13
|
856 tooltip = function(self)
|
|
ShadowTheAge@13
|
857 GameTooltip:AddLine("Scan "..(C_LFGList.GetCategoryInfo(lfgGroups[self.category])))
|
|
ShadowTheAge@13
|
858 end,
|
|
ShadowTheAge@13
|
859 text = "Scan more"
|
|
ShadowTheAge@13
|
860 }
|
|
ShadowTheAge@13
|
861
|
|
ShadowTheAge@13
|
862 local NeedReset = {
|
|
ShadowTheAge@13
|
863 func = function()
|
|
ShadowTheAge@13
|
864 wipe(autoScanGroups);
|
|
ShadowTheAge@13
|
865 local categoryToScan = addon.GetNextAutoScanCategory()
|
|
ShadowTheAge@13
|
866 if categoryToScan then
|
|
ShadowTheAge@13
|
867 addon.LfgScan(categoryToScan)
|
|
ShadowTheAge@13
|
868 end
|
|
ShadowTheAge@13
|
869 end,
|
|
ShadowTheAge@13
|
870 tooltip = "Scan again",
|
|
ShadowTheAge@13
|
871 text = "Restart scan"
|
|
ShadowTheAge@13
|
872 }
|
|
ShadowTheAge@13
|
873
|
|
ShadowTheAge@13
|
874 local Wait = {
|
|
ShadowTheAge@13
|
875 tooltip = "Scan in progress",
|
|
ShadowTheAge@13
|
876 text = "Wait..."
|
|
ShadowTheAge@13
|
877 }
|
|
ShadowTheAge@13
|
878
|
|
ShadowTheAge@13
|
879 local ShowQuickHint = {
|
|
ShadowTheAge@13
|
880 tooltip = "Quick Join",
|
|
ShadowTheAge@13
|
881 text = "Quick Join",
|
|
ShadowTheAge@13
|
882 func = function()
|
|
ShadowTheAge@13
|
883 StaticPopupDialogs["CROSS_REALM_ASSIST"] = {
|
|
ShadowTheAge@13
|
884 text = "Quick Join button will automatically join you to a random group with autoinvite and medium number of players. You never join same group twice, you need to clear join history to do so. This message can be disabled in options.",
|
|
ShadowTheAge@13
|
885 button1 = OKAY,
|
|
ShadowTheAge@13
|
886 hideOnEscape = true,
|
|
ShadowTheAge@13
|
887 preferredIndex = 3,
|
|
ShadowTheAge@13
|
888 }
|
|
ShadowTheAge@13
|
889 StaticPopup_Show("CROSS_REALM_ASSIST")
|
|
ShadowTheAge@13
|
890 hintShown = true;
|
|
ShadowTheAge@13
|
891 end
|
|
ShadowTheAge@13
|
892 }
|
|
ShadowTheAge@13
|
893
|
|
ShadowTheAge@13
|
894 function addon.DoAutoAction(widget, button)
|
|
ShadowTheAge@13
|
895 addon:SetStatus()
|
|
ShadowTheAge@13
|
896 if action and action.func then
|
|
ShadowTheAge@13
|
897 action:func(button)
|
|
ShadowTheAge@13
|
898 end
|
|
ShadowTheAge@13
|
899 addon:UpdateAutoButtonStatus()
|
|
ShadowTheAge@13
|
900 end
|
|
ShadowTheAge@13
|
901
|
|
ShadowTheAge@13
|
902 function addon.actionTooltip()
|
|
ShadowTheAge@13
|
903 local tooltip = action.tooltip
|
|
ShadowTheAge@13
|
904 if type(tooltip) == 'function' then
|
|
ShadowTheAge@13
|
905 tooltip(action)
|
|
ShadowTheAge@13
|
906 else
|
|
ShadowTheAge@13
|
907 GameTooltip:AddLine(tooltip)
|
|
ShadowTheAge@11
|
908 end
|
|
ShadowTheAge@11
|
909 end
|
|
ShadowTheAge@11
|
910
|
|
ShadowTheAge@13
|
911 function addon:UpdateAutoButtonStatus()
|
|
ShadowTheAge@13
|
912 if not btQuick then return end
|
|
ShadowTheAge@13
|
913 btQuick:Enable()
|
|
ShadowTheAge@19
|
914 if IsInGroup() then
|
|
ShadowTheAge@13
|
915 action = LeaveGroup;
|
|
ShadowTheAge@13
|
916 elseif C_LFGList.GetNumApplications() > 0 then
|
|
ShadowTheAge@13
|
917 action = CancelJoin;
|
|
ShadowTheAge@13
|
918 elseif lfgScanInProgress then
|
|
ShadowTheAge@13
|
919 action = Wait
|
|
ShadowTheAge@19
|
920 elseif not hintShown and db.global.quickJoinHint then
|
|
ShadowTheAge@19
|
921 action = ShowQuickHint;
|
|
ShadowTheAge@13
|
922 else
|
|
ShadowTheAge@13
|
923 local group = QuickJoin.findGroup();
|
|
ShadowTheAge@13
|
924 if group then
|
|
ShadowTheAge@13
|
925 action = QuickJoin;
|
|
ShadowTheAge@13
|
926 QuickJoin.groupToJoin = group
|
|
ShadowTheAge@13
|
927 else
|
|
ShadowTheAge@13
|
928 local categoryToScan = addon.GetNextAutoScanCategory()
|
|
ShadowTheAge@13
|
929 if (categoryToScan) then
|
|
ShadowTheAge@13
|
930 action = ScanNext;
|
|
ShadowTheAge@13
|
931 ScanNext.category = categoryToScan
|
|
ShadowTheAge@13
|
932 else
|
|
ShadowTheAge@13
|
933 action = NeedReset;
|
|
ShadowTheAge@13
|
934 end
|
|
ShadowTheAge@13
|
935 end
|
|
ShadowTheAge@13
|
936 end
|
|
ShadowTheAge@13
|
937 btQuick:SetText(action.text)
|
|
ShadowTheAge@13
|
938 if GameTooltip:GetOwner() == btQuick then
|
|
ShadowTheAge@13
|
939 ShowTooltip(btQuick)
|
|
ShadowTheAge@0
|
940 end
|
|
ShadowTheAge@0
|
941 end
|
|
ShadowTheAge@0
|
942
|
|
ShadowTheAge@12
|
943
|
|
ShadowTheAge@13
|
944
|
|
ShadowTheAge@13
|
945
|
|
ShadowTheAge@27
|
946 -- Realm hop group
|
|
ShadowTheAge@13
|
947
|
|
ShadowTheAge@27
|
948 local function CreateHopGroup()
|
|
ShadowTheAge@29
|
949 if canJoinGroup() then
|
|
ShadowTheAge@29
|
950 C_LFGList.CreateListing(16,"Realm hopping - "..homeRealm,0,"","",true)
|
|
ShadowTheAge@29
|
951 addon:ScheduleTimer(ConvertToRaid, 5)
|
|
ShadowTheAge@29
|
952 end
|
|
ShadowTheAge@27
|
953 end
|
|
ShadowTheAge@27
|
954
|
|
ShadowTheAge@27
|
955 function addon:PlayerFlagsUpdate(event, target)
|
|
ShadowTheAge@29
|
956 if target == "player" and UnitIsAFK("player") and C_Garrison.IsOnGarrisonMap() and db.global.autoCreateHopGroup then
|
|
ShadowTheAge@29
|
957 CreateHopGroup()
|
|
ShadowTheAge@29
|
958 end
|
|
ShadowTheAge@27
|
959 end
|
|
ShadowTheAge@13
|
960
|
|
ShadowTheAge@13
|
961 -- Settings
|
|
ShadowTheAge@13
|
962
|
|
ShadowTheAge@13
|
963 local function toggleMinimapIcon(btn, arg1, arg2, checked)
|
|
ShadowTheAge@13
|
964 local hidden = not checked;
|
|
ShadowTheAge@13
|
965 db.global.minimap.hide = hidden;
|
|
ShadowTheAge@13
|
966 if hidden then
|
|
ShadowTheAge@13
|
967 DEFAULT_CHAT_FRAME:AddMessage("|cffff0000Type |cffffffff/cra |cffff0000in chat to open Cross Realm Assist without minimap button");
|
|
ShadowTheAge@13
|
968 minimapIcon:Hide("CrossRealmAssistMinimapIcon")
|
|
ShadowTheAge@13
|
969 else
|
|
ShadowTheAge@13
|
970 minimapIcon:Show("CrossRealmAssistMinimapIcon")
|
|
ShadowTheAge@13
|
971 end
|
|
ShadowTheAge@0
|
972 end
|
|
ShadowTheAge@0
|
973
|
|
ShadowTheAge@13
|
974 local function toggleQuickJoinHint(btn, arg1, arg2, checked)
|
|
ShadowTheAge@13
|
975 db.global.quickJoinHint = checked
|
|
ShadowTheAge@0
|
976 end
|
|
ShadowTheAge@0
|
977
|
|
ShadowTheAge@13
|
978 local function toggleQuickJoin(btn, arg1, arg2, checked)
|
|
ShadowTheAge@13
|
979 db.global.quickJoin[arg1] = checked
|
|
ShadowTheAge@13
|
980 end
|
|
ShadowTheAge@13
|
981
|
|
ShadowTheAge@21
|
982 local function toggleAllLanguages(btn, arg1, arg2, checked)
|
|
ShadowTheAge@21
|
983 db.global.allLanguages = checked
|
|
ShadowTheAge@21
|
984 end
|
|
ShadowTheAge@21
|
985
|
|
ShadowTheAge@25
|
986 local function toggleApplyAsDD(btn, arg1, arg2, checked)
|
|
ShadowTheAge@25
|
987 db.global.applyAsDD = checked
|
|
ShadowTheAge@25
|
988 end
|
|
ShadowTheAge@25
|
989
|
|
ShadowTheAge@27
|
990 local function toggleCreateHopGroup(btn, arg1, arg2, checked)
|
|
ShadowTheAge@27
|
991 db.global.autoCreateHopGroup = checked
|
|
ShadowTheAge@29
|
992 if checked then addon:RegisterEvent("PLAYER_FLAGS_CHANGED", "PlayerFlagsUpdate") end
|
|
ShadowTheAge@27
|
993 end
|
|
ShadowTheAge@27
|
994
|
|
ShadowTheAge@13
|
995 local function ClearJoinHistory()
|
|
ShadowTheAge@13
|
996 recentgroups = {}
|
|
ShadowTheAge@13
|
997 addon:UpdateAutoButtonStatus()
|
|
ShadowTheAge@13
|
998 if lfgTable then lfgTable:Refresh() end
|
|
ShadowTheAge@13
|
999 end
|
|
ShadowTheAge@13
|
1000
|
|
ShadowTheAge@27
|
1001 local function QuickJoinStoplist()
|
|
ShadowTheAge@27
|
1002 StaticPopupDialogs["CROSS_REALM_ASSIST_STOPLIST"] = {
|
|
ShadowTheAge@29
|
1003 OnShow = function (self, data)
|
|
ShadowTheAge@29
|
1004 self.editBox:SetText(table.concat(db.global.stoplist or {}, ","))
|
|
ShadowTheAge@29
|
1005 end,
|
|
ShadowTheAge@29
|
1006 OnAccept=function(self)
|
|
ShadowTheAge@29
|
1007 local text = self.editBox:GetText();
|
|
ShadowTheAge@29
|
1008 local stoplist = {}
|
|
ShadowTheAge@29
|
1009 for item in string.gmatch(text, "[^, ][^,]*") do
|
|
ShadowTheAge@29
|
1010 table.insert(stoplist,string.lower(item))
|
|
ShadowTheAge@29
|
1011 end
|
|
ShadowTheAge@29
|
1012 db.global.stoplist = stoplist
|
|
ShadowTheAge@29
|
1013 end,
|
|
ShadowTheAge@29
|
1014 button1 = OKAY,
|
|
ShadowTheAge@29
|
1015 button2 = CANCEL,
|
|
ShadowTheAge@29
|
1016 editBoxWidth = 350,
|
|
ShadowTheAge@29
|
1017 hasEditBox=true,
|
|
ShadowTheAge@29
|
1018 text = "Ignore groups containing following words:\nSeparated by comma",
|
|
ShadowTheAge@29
|
1019 preferredIndex = 3
|
|
ShadowTheAge@29
|
1020 }
|
|
ShadowTheAge@29
|
1021 StaticPopup_Show("CROSS_REALM_ASSIST_STOPLIST")
|
|
ShadowTheAge@27
|
1022 end
|
|
ShadowTheAge@13
|
1023
|
|
ShadowTheAge@13
|
1024 local function initMenu(self, level)
|
|
ShadowTheAge@13
|
1025 if not level then return end
|
|
ShadowTheAge@13
|
1026 if level == 1 then
|
|
ShadowTheAge@13
|
1027 UIDropDownMenu_AddButton({text="Clear realm history",notCheckable=1,func=ClearRealmHistory}, level)
|
|
ShadowTheAge@13
|
1028 UIDropDownMenu_AddButton({text="Clear join history",notCheckable=1,func=ClearJoinHistory}, level)
|
|
ShadowTheAge@29
|
1029
|
|
ShadowTheAge@29
|
1030 if canJoinGroup() then
|
|
ShadowTheAge@29
|
1031 UIDropDownMenu_AddButton({disabled=1,notCheckable=1}, level)
|
|
ShadowTheAge@29
|
1032 UIDropDownMenu_AddButton({text="Create a group for realm hoppers",notCheckable=1,func=CreateHopGroup}, level)
|
|
ShadowTheAge@29
|
1033 end
|
|
ShadowTheAge@29
|
1034
|
|
ShadowTheAge@29
|
1035 UIDropDownMenu_AddButton({disabled=1,notCheckable=1}, level)
|
|
ShadowTheAge@29
|
1036 UIDropDownMenu_AddButton({text="Show Quick Join Hint",checked=db.global.quickJoinHint, func=toggleQuickJoinHint,keepShownOnClick=true,isNotRadio=true}, level)
|
|
ShadowTheAge@29
|
1037 UIDropDownMenu_AddButton({text="Settings",notCheckable=1,hasArrow=1,value="settings",keepShownOnClick=true}, level)
|
|
ShadowTheAge@13
|
1038 elseif level == 2 then
|
|
ShadowTheAge@29
|
1039 if UIDROPDOWNMENU_MENU_VALUE == "settings" then
|
|
ShadowTheAge@29
|
1040 UIDropDownMenu_AddButton({text="Show Minimap Button",checked=not db.global.minimap.hide, func=toggleMinimapIcon,keepShownOnClick=true,isNotRadio=true}, level)
|
|
ShadowTheAge@29
|
1041 UIDropDownMenu_AddButton({text="All language groups",checked=db.global.allLanguages, func=toggleAllLanguages,keepShownOnClick=true,isNotRadio=true}, level)
|
|
ShadowTheAge@29
|
1042 UIDropDownMenu_AddButton({text="Apply to groups as DD only",checked=db.global.applyAsDD, func=toggleApplyAsDD,keepShownOnClick=true,isNotRadio=true}, level)
|
|
ShadowTheAge@29
|
1043 UIDropDownMenu_AddButton({disabled=1,notCheckable=1}, level)
|
|
ShadowTheAge@29
|
1044 UIDropDownMenu_AddButton({text="Quick join categories",notCheckable=1,hasArrow=1,value="qjc",keepShownOnClick=true}, level)
|
|
ShadowTheAge@29
|
1045 UIDropDownMenu_AddButton({text="Edit Quick Join Stoplist",notCheckable=1,func=QuickJoinStoplist}, level)
|
|
ShadowTheAge@29
|
1046 UIDropDownMenu_AddButton({disabled=1,notCheckable=1}, level)
|
|
ShadowTheAge@29
|
1047 UIDropDownMenu_AddButton({text="Experimental features",notCheckable=1,hasArrow=1,value="experimental",keepShownOnClick=true}, level)
|
|
ShadowTheAge@29
|
1048 end
|
|
ShadowTheAge@27
|
1049 elseif level == 3 then
|
|
ShadowTheAge@29
|
1050 if UIDROPDOWNMENU_MENU_VALUE == "qjc" then
|
|
ShadowTheAge@13
|
1051 for i=1,#lfgGroups do
|
|
ShadowTheAge@13
|
1052 local groupId = lfgGroups[i]
|
|
ShadowTheAge@13
|
1053 UIDropDownMenu_AddButton({text=(C_LFGList.GetCategoryInfo(groupId)),checked=db.global.quickJoin[groupId],arg1=groupId,func=toggleQuickJoin,keepShownOnClick=true,isNotRadio=true}, level)
|
|
ShadowTheAge@13
|
1054 end
|
|
ShadowTheAge@27
|
1055 elseif UIDROPDOWNMENU_MENU_VALUE == "experimental" then
|
|
ShadowTheAge@29
|
1056 UIDropDownMenu_AddButton({isTitle=1,text="Use at your own risk!",notCheckable=1}, level)
|
|
ShadowTheAge@29
|
1057 UIDropDownMenu_AddButton({text="Auto create group for realm hopping when AFK at garrison",checked=db.global.autoCreateHopGroup,keepShownOnClick=true,isNotRadio=true,func=toggleCreateHopGroup}, level)
|
|
ShadowTheAge@29
|
1058 end
|
|
ShadowTheAge@29
|
1059 end
|
|
ShadowTheAge@13
|
1060 end
|
|
ShadowTheAge@13
|
1061
|
|
ShadowTheAge@13
|
1062 function addon.ShowSettings(frame)
|
|
ShadowTheAge@13
|
1063 if not settingsMenu then
|
|
ShadowTheAge@13
|
1064 settingsMenu = CreateFrame("Frame", "CrossRealmAssistMenu")
|
|
ShadowTheAge@13
|
1065 settingsMenu.displayMode = "MENU"
|
|
ShadowTheAge@13
|
1066 settingsMenu.initialize = initMenu
|
|
ShadowTheAge@13
|
1067 end
|
|
ShadowTheAge@13
|
1068 ToggleDropDownMenu(1, nil, settingsMenu, frame, 10, 0)
|
|
ShadowTheAge@12
|
1069 end |