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