ovolkov@29
|
1 -- [AUTOLOCAL START]
|
ovolkov@29
|
2 local CLASS_SORT_ORDER = CLASS_SORT_ORDER
|
ovolkov@29
|
3 local C_LFGList = C_LFGList
|
ovolkov@29
|
4 local GetLFGDungeonEncounterInfo = GetLFGDungeonEncounterInfo
|
ovolkov@29
|
5 local GetLFGDungeonNumEncounters = GetLFGDungeonNumEncounters
|
ovolkov@29
|
6 local MAX_CLASSES = MAX_CLASSES
|
ovolkov@7
|
7 local dump = DevTools_Dump
|
ovolkov@29
|
8 local match = string.match
|
ovolkov@29
|
9 local pairs = pairs
|
ovolkov@29
|
10 local setfenv = setfenv
|
ovolkov@29
|
11 local wipe = wipe
|
ovolkov@29
|
12 -- [AUTOLOCAL END]
|
ovolkov@29
|
13
|
ovolkov@3
|
14 LFGListFrame.SearchPanel.SearchBox:SetMaxLetters(2048)
|
ovolkov@0
|
15
|
ovolkov@3
|
16 local filter_expression_functions = setmetatable({}, {
|
ovolkov@3
|
17 __mode = "k",
|
ovolkov@3
|
18 __index = function(t, key)
|
ovolkov@3
|
19 local func, error = loadstring("return " .. key)
|
ovolkov@3
|
20 if error then print("Error in LFG filter expression:\n", error) end
|
ovolkov@3
|
21 t[key] = func
|
ovolkov@3
|
22 return func
|
ovolkov@3
|
23 end
|
ovolkov@3
|
24 })
|
ovolkov@3
|
25
|
ovolkov@10
|
26 local aliases = {
|
ovolkov@31
|
27 voice_chat = "voice",
|
ovolkov@18
|
28 hm = "highmaul",
|
ovolkov@18
|
29 brf = "blackrock_foundry",
|
ovolkov@18
|
30 blackrockfoundry = "blackrock_foundry",
|
ovolkov@18
|
31 healers = "healer",
|
ovolkov@18
|
32 members = "member",
|
ovolkov@18
|
33 tanks = "tank",
|
ovolkov@18
|
34 damagers = "damager",
|
ovolkov@18
|
35 damage = "damager",
|
ovolkov@18
|
36 plates = "plate",
|
ovolkov@18
|
37 mails = "mail",
|
ovolkov@18
|
38 leathers = "leather",
|
ovolkov@18
|
39 cloths = "cloth",
|
ovolkov@18
|
40 clothies = "cloth",
|
ovolkov@10
|
41 }
|
ovolkov@10
|
42 for idx = 1, MAX_CLASSES do
|
ovolkov@10
|
43 local class_lc = CLASS_SORT_ORDER[idx]:lower()
|
ovolkov@10
|
44 aliases[class_lc .. "s"] = class_lc
|
ovolkov@10
|
45 end
|
ovolkov@10
|
46
|
ovolkov@11
|
47 local token_to_encounter_id = {
|
ovolkov@11
|
48 highmaul = {
|
ovolkov@12
|
49 lfg_dungeon_id = 849,
|
ovolkov@12
|
50 { "kargath", "bladefist", "kargath_bladefist" },
|
ovolkov@12
|
51 { "butcher", "the_butcher" },
|
ovolkov@12
|
52 { "tectus" },
|
ovolkov@12
|
53 { "brackenspore", "bracken" },
|
ovolkov@12
|
54 { "twin_orgon", "twins" },
|
ovolkov@12
|
55 { "koragh", "breaker" },
|
ovolkov@12
|
56 { "imperator", "margok" },
|
ovolkov@23
|
57 },
|
ovolkov@23
|
58 blackrock_foundry = {
|
ovolkov@30
|
59 lfg_dungeon_id = 847,
|
ovolkov@30
|
60 { "oregorger", "oreg" },
|
ovolkov@30
|
61 { "gruul" },
|
ovolkov@30
|
62 { "hansgar", "franzok", "hans", "franz", "hans_and_franz", "twins" },
|
ovolkov@30
|
63 { "beastlord", "darmac" },
|
ovolkov@30
|
64 { "flamebender", "kagraz" },
|
ovolkov@30
|
65 { "operator", "thogar" },
|
ovolkov@30
|
66 { "blast_furnace", "bf", "furnace", "blast" },
|
ovolkov@30
|
67 { "kromog" },
|
ovolkov@30
|
68 { "iron_maidens", "im", "maidens" },
|
ovolkov@30
|
69 { "blackhand" },
|
ovolkov@11
|
70 }
|
ovolkov@11
|
71 }
|
ovolkov@11
|
72
|
ovolkov@3
|
73 function LFGListSearchPanel_DoSearch(self)
|
ovolkov@3
|
74 local searchText = self.SearchBox:GetText();
|
ovolkov@3
|
75 local real_search, filter_expression = searchText:match("^([^=]-)=(.+)$")
|
ovolkov@3
|
76 if filter_expression then
|
ovolkov@3
|
77 filter_expression = filter_expression:lower()
|
ovolkov@3
|
78 self.filter_func = filter_expression_functions[filter_expression]
|
ovolkov@3
|
79 end
|
ovolkov@3
|
80 self.filter_expression = filter_expression
|
ovolkov@3
|
81
|
ovolkov@3
|
82 -- print("lfgsearch", real_search, filter_expression)
|
ovolkov@3
|
83 C_LFGList.Search(self.categoryID, real_search or searchText, self.filters, self.preferredFilters);
|
ovolkov@3
|
84 self.searching = true;
|
ovolkov@3
|
85 self.searchFailed = false;
|
ovolkov@3
|
86 self.selectedResult = nil;
|
ovolkov@3
|
87 LFGListSearchPanel_UpdateResultList(self);
|
ovolkov@3
|
88 LFGListSearchPanel_UpdateResults(self);
|
ovolkov@3
|
89 end
|
ovolkov@3
|
90
|
ovolkov@12
|
91 local localized_encounter_name_to_idx = {}
|
ovolkov@11
|
92
|
ovolkov@22
|
93 local dead = true
|
ovolkov@22
|
94
|
ovolkov@11
|
95 local function InsertEncounterStateAliases(result_env, raid_token, completed_encounters)
|
ovolkov@11
|
96 local encounter_aliases = token_to_encounter_id[raid_token]
|
ovolkov@11
|
97 if not encounter_aliases then return end
|
ovolkov@11
|
98
|
ovolkov@12
|
99 local lfg_dungeon_id = encounter_aliases.lfg_dungeon_id
|
ovolkov@12
|
100 local encounter_names = localized_encounter_name_to_idx[lfg_dungeon_id]
|
ovolkov@11
|
101 if not encounter_names then
|
ovolkov@11
|
102 encounter_names = {}
|
ovolkov@12
|
103 for idx = 1, GetLFGDungeonNumEncounters(lfg_dungeon_id) do
|
ovolkov@12
|
104 local bossName, texture, isKilled = GetLFGDungeonEncounterInfo(lfg_dungeon_id, idx)
|
ovolkov@12
|
105 encounter_names[bossName] = idx
|
ovolkov@12
|
106 end
|
ovolkov@12
|
107 localized_encounter_name_to_idx[lfg_dungeon_id] = encounter_names
|
ovolkov@11
|
108 end
|
ovolkov@11
|
109
|
ovolkov@11
|
110 for idx = 1, #completed_encounters do
|
ovolkov@11
|
111 local encounter_id = encounter_names[completed_encounters[idx]]
|
ovolkov@11
|
112 if encounter_id then
|
ovolkov@11
|
113 local aliases = encounter_aliases[encounter_id]
|
ovolkov@22
|
114 result_env["boss" .. encounter_id] = dead
|
ovolkov@11
|
115 if aliases then
|
ovolkov@11
|
116 for alias_idx = 1, #aliases do
|
ovolkov@22
|
117 result_env[aliases[alias_idx]] = dead
|
ovolkov@11
|
118 end
|
ovolkov@11
|
119 end
|
ovolkov@11
|
120 end
|
ovolkov@11
|
121 end
|
ovolkov@11
|
122 end
|
ovolkov@11
|
123
|
ovolkov@3
|
124 local result_env = {}
|
ovolkov@3
|
125 -- =highmaul and ((normal and (name:match("imp") or defeated == 6)) or (heroic and defeated == 2))
|
ovolkov@0
|
126 function LFGListUtil_SortSearchResults(results)
|
ovolkov@3
|
127 local self = LFGListFrame.SearchPanel
|
ovolkov@3
|
128 if self.filter_expression then
|
ovolkov@3
|
129 local check = self.filter_func
|
ovolkov@0
|
130 local shift_down = 0
|
ovolkov@0
|
131 local original_size = #results
|
ovolkov@0
|
132 for idx = 1, original_size do
|
ovolkov@3
|
133 local id = results[idx]
|
ovolkov@3
|
134 local _, activityID, name, comment, voiceChat, iLvl, age, numBNetFriends, numCharFriends, numGuildMates, isDelisted, leaderName, numMembers = C_LFGList.GetSearchResultInfo(id)
|
ovolkov@3
|
135 local completedEncounters = C_LFGList.GetSearchResultEncounterInfo(id)
|
ovolkov@3
|
136 local memberCounts = C_LFGList.GetSearchResultMemberCounts(id)
|
ovolkov@3
|
137
|
ovolkov@3
|
138 wipe(result_env)
|
ovolkov@3
|
139 result_env.name = name:lower()
|
ovolkov@3
|
140 result_env.comment = comment:lower()
|
ovolkov@3
|
141 result_env.ilvl = iLvl
|
ovolkov@3
|
142 -- TODO: should be calculated in meta
|
ovolkov@3
|
143 result_env.defeated = completedEncounters and #completedEncounters or 0
|
ovolkov@6
|
144 result_env.member = numMembers
|
ovolkov@6
|
145 result_env.tank = memberCounts.TANK
|
ovolkov@6
|
146 result_env.healer = memberCounts.HEALER
|
ovolkov@6
|
147 result_env.damager = memberCounts.DAMAGER + memberCounts.NOROLE
|
ovolkov@3
|
148 result_env.my_server = leaderName and not leaderName:find('-')
|
ovolkov@31
|
149 if voiceChat and voiceChat ~= "" then
|
ovolkov@31
|
150 result_env.voice = voiceChat
|
ovolkov@31
|
151 end
|
ovolkov@3
|
152
|
ovolkov@7
|
153 for idx = 1, numMembers do
|
ovolkov@7
|
154 local role, class, classLocalized = C_LFGList.GetSearchResultMemberInfo(id, idx)
|
ovolkov@7
|
155 local class_lc = class:lower()
|
ovolkov@7
|
156 local prev_count = result_env[class_lc]
|
ovolkov@7
|
157 result_env[class_lc] = prev_count and (prev_count + 1) or 0
|
ovolkov@7
|
158 end
|
ovolkov@7
|
159 for idx = 1, MAX_CLASSES do
|
ovolkov@7
|
160 local class_lc = CLASS_SORT_ORDER[idx]:lower()
|
ovolkov@7
|
161 local count = result_env[class_lc]
|
ovolkov@10
|
162 if not count then result_env[class_lc] = 0 end
|
ovolkov@7
|
163 end
|
ovolkov@7
|
164
|
ovolkov@11
|
165 local raid_token
|
ovolkov@3
|
166 if activityID == 37 then
|
ovolkov@11
|
167 raid_token = "highmaul"
|
ovolkov@3
|
168 result_env.normal = true
|
ovolkov@3
|
169 elseif activityID == 38 then
|
ovolkov@11
|
170 raid_token = "highmaul"
|
ovolkov@3
|
171 result_env.heroic = true
|
ovolkov@18
|
172 elseif activityID == 39 then
|
ovolkov@18
|
173 raid_token = "blackrock_foundry"
|
ovolkov@18
|
174 result_env.normal = true
|
ovolkov@18
|
175 elseif activityID == 40 then
|
ovolkov@18
|
176 raid_token = "blackrock_foundry"
|
ovolkov@18
|
177 result_env.heroic = true
|
ovolkov@3
|
178 end
|
ovolkov@3
|
179
|
ovolkov@17
|
180 if raid_token then
|
ovolkov@17
|
181 result_env[raid_token] = true
|
ovolkov@17
|
182 if completedEncounters then InsertEncounterStateAliases(result_env, raid_token, completedEncounters) end
|
ovolkov@17
|
183 end
|
ovolkov@11
|
184
|
ovolkov@22
|
185 result_env.dead = dead
|
ovolkov@11
|
186
|
ovolkov@11
|
187 -- dump(result_env)
|
ovolkov@10
|
188
|
ovolkov@10
|
189 for alias, original in pairs(aliases) do result_env[alias] = result_env[original] end
|
ovolkov@10
|
190
|
ovolkov@10
|
191 -- dump(result_env)
|
ovolkov@7
|
192
|
ovolkov@3
|
193 local pass
|
ovolkov@3
|
194 if check then
|
ovolkov@3
|
195 setfenv(check, result_env)
|
ovolkov@3
|
196 pass = check()
|
ovolkov@3
|
197 end
|
ovolkov@3
|
198
|
ovolkov@3
|
199 if pass then
|
ovolkov@0
|
200 if shift_down > 0 then
|
ovolkov@3
|
201 results[idx - shift_down] = id
|
ovolkov@0
|
202 end
|
ovolkov@0
|
203 else
|
ovolkov@0
|
204 shift_down = shift_down + 1
|
ovolkov@0
|
205 end
|
ovolkov@3
|
206
|
ovolkov@0
|
207 end
|
ovolkov@0
|
208 for idx = original_size - shift_down + 1, original_size do
|
ovolkov@0
|
209 results[idx] = nil
|
ovolkov@0
|
210 end
|
ovolkov@0
|
211 end
|
ovolkov@3
|
212 table.sort(results, LFGListUtil_SortSearchResultsCB);
|
ovolkov@0
|
213 end
|
ovolkov@0
|
214
|
ovolkov@0
|
215 function LFGListUtil_SortSearchResultsCB(id1, id2)
|
ovolkov@0
|
216 local id1, activityID1, name1, comment1, voiceChat1, iLvl1, age1, numBNetFriends1, numCharFriends1, numGuildMates1, isDelisted1 = C_LFGList.GetSearchResultInfo(id1);
|
ovolkov@0
|
217 local id2, activityID2, name2, comment2, voiceChat2, iLvl2, age2, numBNetFriends2, numCharFriends2, numGuildMates2, isDelisted2 = C_LFGList.GetSearchResultInfo(id2);
|
ovolkov@0
|
218
|
ovolkov@0
|
219 --If one has more friends, do that one first
|
ovolkov@0
|
220 if ( numBNetFriends1 ~= numBNetFriends2 ) then
|
ovolkov@0
|
221 return numBNetFriends1 > numBNetFriends2;
|
ovolkov@0
|
222 end
|
ovolkov@0
|
223
|
ovolkov@0
|
224 if ( numCharFriends1 ~= numCharFriends2 ) then
|
ovolkov@0
|
225 return numCharFriends1 > numCharFriends2;
|
ovolkov@0
|
226 end
|
ovolkov@0
|
227
|
ovolkov@0
|
228 if ( numGuildMates1 ~= numGuildMates2 ) then
|
ovolkov@0
|
229 return numGuildMates1 > numGuildMates2;
|
ovolkov@0
|
230 end
|
ovolkov@0
|
231
|
ovolkov@0
|
232 if ( activityID1 ~= activityID2 ) then
|
ovolkov@0
|
233 return activityID1 > activityID2;
|
ovolkov@0
|
234 end
|
ovolkov@0
|
235
|
ovolkov@0
|
236 --If we aren't sorting by anything else, just go by ID
|
ovolkov@0
|
237 return id1 < id2;
|
ovolkov@0
|
238 end
|
ovolkov@0
|
239
|
ovolkov@0
|
240 function LFGPrintRawResults()
|
ovolkov@0
|
241 local totalResults, results = C_LFGList.GetSearchResults()
|
ovolkov@0
|
242 for idx = 1, totalResults do
|
ovolkov@0
|
243 local id1, activityID1, name1, comment1, voiceChat1, iLvl1, age1, numBNetFriends1, numCharFriends1, numGuildMates1, isDelisted1 = C_LFGList.GetSearchResultInfo(results[idx])
|
ovolkov@0
|
244 print(id1, activityID1, C_LFGList.GetActivityInfo(activityID1), '*', name1)
|
ovolkov@0
|
245 end
|
ovolkov@21
|
246 end
|
ovolkov@21
|
247
|
ovolkov@21
|
248 function LFGPrintFindDungeon(upper_limit, pattern)
|
ovolkov@21
|
249 local lower_limit = 1
|
ovolkov@21
|
250 if not pattern then
|
ovolkov@21
|
251 lower_limit = upper_limit
|
ovolkov@21
|
252 pattern = GetLFGDungeonInfo(upper_limit)
|
ovolkov@21
|
253 end
|
ovolkov@21
|
254 for idx = lower_limit, upper_limit do
|
ovolkov@21
|
255 local name = GetLFGDungeonInfo(idx)
|
ovolkov@21
|
256 if name and name:find(pattern) then
|
ovolkov@21
|
257 print(idx, name)
|
ovolkov@21
|
258 for enc_idx = 1, GetLFGDungeonNumEncounters(idx) do
|
ovolkov@21
|
259 local bossName, texture, isKilled = GetLFGDungeonEncounterInfo(idx, enc_idx)
|
ovolkov@21
|
260 print("*", enc_idx, bossName)
|
ovolkov@21
|
261 end
|
ovolkov@21
|
262 end
|
ovolkov@21
|
263 end
|
ovolkov@13
|
264 end |