-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGroupCalendar_Alts.lua
More file actions
executable file
·68 lines (53 loc) · 1.96 KB
/
GroupCalendar_Alts.lua
File metadata and controls
executable file
·68 lines (53 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
----------------------------------------
-- Group Calendar 5 Copyright (c) 2018 John Stephen
-- This software is licensed under the MIT license.
-- See the included LICENSE.txt file for more information.
----------------------------------------
GroupCalendar._Alts = {}
function GroupCalendar._Alts:Construct()
--self:InstallAltMail()
end
function GroupCalendar._Alts:InstallAltMail()
if self.Orig_GetAutoCompleteResults then
return
end
self.Orig_GetAutoCompleteResults = GetAutoCompleteResults
GetAutoCompleteResults = function (...) return self:GetAutoCompleteResults(...) end
end
function GroupCalendar._Alts:UninstallAltMail()
if not self.Orig_GetAutoCompleteResults then
return
end
GetAutoCompleteResults = self.Orig_GetAutoCompleteResults
self.Orig_GetAutoCompleteResults = nil
end
function GroupCalendar._Alts:GetAutoCompleteResults(pText, pInclude, pExclude, pMaxResults, pCursorPosition, ...)
local vResults = {self.Orig_GetAutoCompleteResults(pText, pInclude, pExclude, pMaxResults, pCursorPosition, ...)}
if true or bit.band(pInclude, AUTOCOMPLETE_FLAG_FRIEND) then
local vText
if pCursorPosition then
vText = pText:utf8sub(1, pCursorPosition):utf8upper()
else
vText = pText:utf8upper()
end
local vTextLength = vText:utf8len()
local vFaction = UnitFactionGroup("player")
for vCharacterGUID, vCharacterInfo in pairs(GroupCalendar.RealmData.Characters) do
if vCharacterInfo.Faction == vFaction
and vText == vCharacterInfo.Name:utf8upper():utf8sub(1, vTextLength) then
table.insert(vResults, 1, vCharacterInfo.Name)
-- Remove extra instances of the same name
for vIndex, vName in ipairs(vResults) do
if vIndex > 1 and vName == vCharacterInfo.Name then
table.remove(vResults, vIndex)
break
end
end
end
end
end
while #vResults > pMaxResults do
table.remove(vResults, #vResults)
end
return unpack(vResults)
end