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