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