automatically recording alts and suggesting their names for sending

This commit is contained in:
Manuel Simon Hirsig
2016-09-26 23:45:13 +02:00
parent 6914e5a243
commit 839560ff47
2 changed files with 35 additions and 18 deletions
+34 -17
View File
@@ -6,6 +6,8 @@ for _, event in { 'ADDON_LOADED', 'VARIABLES_LOADED', 'UI_ERROR_MESSAGE', 'CURSO
self:RegisterEvent(event) self:RegisterEvent(event)
end end
Postal_Characters = {}
local ATTACHMENTS_MAX = 21 local ATTACHMENTS_MAX = 21
local ATTACHMENTS_PER_ROW_SEND = 7 local ATTACHMENTS_PER_ROW_SEND = 7
local ATTACHMENTS_MAX_ROWS_SEND = 3 local ATTACHMENTS_MAX_ROWS_SEND = 3
@@ -67,7 +69,7 @@ function self:MAIL_CLOSED()
-- Hides the minimap unread mail button if there are no unread mail on closing the mailbox. -- Hides the minimap unread mail button if there are no unread mail on closing the mailbox.
-- Does not scan past the first 50 items since only the first 50 are viewable. -- Does not scan past the first 50 items since only the first 50 are viewable.
for i = 1, GetInboxNumItems() do for i = 1, GetInboxNumItems() do
if not ({GetInboxHeaderInfo(i)})[9] then return end if not ({ GetInboxHeaderInfo(i) })[9] then return end
end end
MiniMapMailFrame:Hide() MiniMapMailFrame:Hide()
end end
@@ -88,6 +90,17 @@ function self:UI_ERROR_MESSAGE()
end end
end end
function self:UpdateCharacters()
local realm = GetCVar'realmName'
Postal_Characters[realm] = Postal_Characters[realm] or {}
for char, lastSeen in Postal_Characters[realm] do
if GetTime() - lastSeen > 60 * 60 * 24 * 30 then
Postal_Characters[realm][char] = nil
end
end
Postal_Characters[realm][UnitName'player'] = GetTime()
end
function self:ADDON_LOADED() function self:ADDON_LOADED()
if arg1 ~= 'Postal' then return end if arg1 ~= 'Postal' then return end
@@ -95,7 +108,7 @@ function self:ADDON_LOADED()
UIPanelWindows['FriendsFrame'].pushable = 2 UIPanelWindows['FriendsFrame'].pushable = 2
MailItem1:SetPoint('TOPLEFT', 'InboxFrame', 'TOPLEFT', 48, -80) MailItem1:SetPoint('TOPLEFT', 'InboxFrame', 'TOPLEFT', 48, -80)
for i=1,7 do for i = 1, 7 do
getglobal('MailItem' .. i .. 'ExpireTime'):SetPoint('TOPRIGHT', 'MailItem' .. i, 'TOPRIGHT', 10, -4) getglobal('MailItem' .. i .. 'ExpireTime'):SetPoint('TOPRIGHT', 'MailItem' .. i, 'TOPRIGHT', 10, -4)
getglobal('MailItem' .. i):SetWidth(280) getglobal('MailItem' .. i):SetWidth(280)
end end
@@ -126,15 +139,15 @@ function self:ADDON_LOADED()
SendMailMoney:ClearAllPoints() SendMailMoney:ClearAllPoints()
SendMailMoney:SetPoint('TOPLEFT', SendMailMoneyText, 'BOTTOMLEFT', 5, -5) SendMailMoney:SetPoint('TOPLEFT', SendMailMoneyText, 'BOTTOMLEFT', 5, -5)
SendMailMoneyGoldRight:SetPoint('RIGHT', 20, 0) SendMailMoneyGoldRight:SetPoint('RIGHT', 20, 0)
;({SendMailMoneyGold:GetRegions()})[9]:SetDrawLayer('BORDER') do ({ SendMailMoneyGold:GetRegions() })[9]:SetDrawLayer('BORDER') end
SendMailMoneyGold:SetMaxLetters(7) SendMailMoneyGold:SetMaxLetters(7)
SendMailMoneyGold:SetWidth(50) SendMailMoneyGold:SetWidth(50)
SendMailMoneySilverRight:SetPoint('RIGHT', 10, 0) SendMailMoneySilverRight:SetPoint('RIGHT', 10, 0)
;({SendMailMoneySilver:GetRegions()})[9]:SetDrawLayer('BORDER') do ({ SendMailMoneySilver:GetRegions() })[9]:SetDrawLayer('BORDER') end
SendMailMoneySilver:SetWidth(28) SendMailMoneySilver:SetWidth(28)
SendMailMoneySilver:SetPoint('LEFT', SendMailMoneyGold, 'RIGHT', 30, 0) SendMailMoneySilver:SetPoint('LEFT', SendMailMoneyGold, 'RIGHT', 30, 0)
SendMailMoneyCopperRight:SetPoint('RIGHT', 10, 0) SendMailMoneyCopperRight:SetPoint('RIGHT', 10, 0)
;({SendMailMoneyCopper:GetRegions()})[9]:SetDrawLayer('BORDER') do ({ SendMailMoneyCopper:GetRegions() })[9]:SetDrawLayer('BORDER') end
SendMailMoneyCopper:SetWidth(28) SendMailMoneyCopper:SetWidth(28)
SendMailMoneyCopper:SetPoint('LEFT', SendMailMoneySilver, 'RIGHT', 20, 0) SendMailMoneyCopper:SetPoint('LEFT', SendMailMoneySilver, 'RIGHT', 20, 0)
SendMailSendMoneyButton:SetPoint('TOPLEFT', SendMailMoney, 'TOPRIGHT', 0, 12) SendMailSendMoneyButton:SetPoint('TOPLEFT', SendMailMoney, 'TOPRIGHT', 0, 12)
@@ -165,7 +178,7 @@ function self:ADDON_LOADED()
end) end)
SendMailNameEditBox:SetScript('OnChar', function() SendMailNameEditBox:SetScript('OnChar', function()
Postal_To = nil Postal_To = nil
self:GetMatches() self:GetSuggestions()
end) end)
SendMailNameEditBox:SetScript('OnTabPressed', function() SendMailNameEditBox:SetScript('OnTabPressed', function()
if AutoCompleteBox:IsVisible() then if AutoCompleteBox:IsVisible() then
@@ -220,6 +233,7 @@ function self:ADDON_LOADED()
end end
end end
self:UpdateCharacters()
self.Inbox_selectedItems = {} self.Inbox_selectedItems = {}
self.SendMail_ready = true self.SendMail_ready = true
end end
@@ -259,7 +273,7 @@ end
function self.hook.InboxFrame_Update() function self.hook.InboxFrame_Update()
self.orig.InboxFrame_Update() self.orig.InboxFrame_Update()
for i=1,7 do for i = 1, 7 do
local index = (i + (InboxFrame.pageNum - 1) * 7) local index = (i + (InboxFrame.pageNum - 1) * 7)
if index > GetInboxNumItems() then if index > GetInboxNumItems() then
getglobal('PostalBoxItem' .. i .. 'CB'):Hide() getglobal('PostalBoxItem' .. i .. 'CB'):Hide()
@@ -353,7 +367,7 @@ function self:Inbox_OpenItem(i, inboxCount, selected)
self.Inbox_skip = false self.Inbox_skip = false
tremove(selected, 1) tremove(selected, 1)
if newInboxCount < inboxCount then if newInboxCount < inboxCount then
for j, _ in selected do for j in selected do
selected[j] = selected[j] - 1 selected[j] = selected[j] - 1
end end
end end
@@ -755,25 +769,28 @@ do
SendMailNameEditBox:HighlightText(0, 0) SendMailNameEditBox:HighlightText(0, 0)
end end
function self:GetMatches() function self:GetSuggestions()
local input = SendMailNameEditBox:GetText() local input = SendMailNameEditBox:GetText()
inputLength = strlen(input) inputLength = strlen(input)
table.setn(matches, 0) table.setn(matches, 0)
index = nil index = nil
local name local ignore = { [UnitName'player']=true }
for i = 1, GetNumFriends() do local function process(name)
name = GetFriendInfo(i) if not ignore[name] and strfind(strupper(name), strupper(input), nil, true) == 1 then
if strfind(strupper(name), strupper(input), nil, true) == 1 then
tinsert(matches, name) tinsert(matches, name)
end end
ignore[name] = true
end
for character in Postal_Characters[GetCVar'realmName'] do
process(character)
end
for i = 1, GetNumFriends() do
process(GetFriendInfo(i))
end end
for i = 1, GetNumGuildMembers(true) do for i = 1, GetNumGuildMembers(true) do
name = GetGuildRosterInfo(i) process(GetGuildRosterInfo(i))
if strfind(strupper(name), strupper(input), nil, true) == 1 then
tinsert(matches, name)
end
end end
table.setn(matches, min(getn(matches), AUTOCOMPLETE_MAX_BUTTONS)) table.setn(matches, min(getn(matches), AUTOCOMPLETE_MAX_BUTTONS))
+1 -1
View File
@@ -4,4 +4,4 @@
## Author: shirsig ## Author: shirsig
## SavedVariablesPerCharacter: Postal_To ## SavedVariablesPerCharacter: Postal_To
## SavedVariables: Postal_Characters ## SavedVariables: Postal_Characters
Postal.xml Postal.xml