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