This commit is contained in:
Robin 2021-01-13 16:16:52 +01:00
commit 912a95d494
7 changed files with 184 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Common"]
path = Common
url = https://git.grml.de/rilgamon/Common.git

1
Common Submodule

@ -0,0 +1 @@
Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed

159
core.lua Normal file
View File

@ -0,0 +1,159 @@
local name, addon = ...
local parentName = addon['parentName'] or "BrokerPack"
local childName = "zz_Mailbox"
local defaults = {
}
local options = {
}
local db
local scanned = false
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
local function OnClick(self, button)
if(IsShiftKeyDown() and button == "LeftButton") then
addon['db']['global']['ldbicons'][childName]['hide'] = not addon['db']['global']['ldbicons'][childName]['hide']
if(ldbicon) then
if(addon['db']['global']['ldbicons'][childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
else
if(InterfaceOptionsFrame:IsVisible() and not InCombatLockdown()) then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory(childName)
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
end
end
end
local function OnText(message)
addon:OnText(childName, message)
end
local character = UnitName("player")
local realm = GetRealmName()
local faction,_ = UnitFactionGroup('player')
local function mailupdate()
if(not scanned) then
return db[faction][realm][character]['mailunread'],db[faction][realm][character]['mail']
else
local cur,tot = GetInboxNumItems()
db[faction][realm][character]['mail'] = tot
return db[faction][realm][character]['mailunread'], tot
end
end
local function mail()
local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned, textCreated, canReply, isGM
local index,newunread = 0,0
local unread, tot = mailupdate()
subject = "start"
while(subject) do
index = index + 1
packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned, textCreated, canReply, isGM = GetInboxHeaderInfo(index)
if(subject and not wasRead) then
newunread = newunread + 1
if(GetInboxNumItems() == 0 and scanned) then
newunread = 0
end
end
end
if(not(db[faction][realm][character]['mail'] > 0 and GetInboxNumItems() == 0)) then
db[faction][realm][character]['mailunread'] = newunread
end
if(db[faction][realm][character]['newmail']) then
if(HasNewMail() and tot == 0) then
tot = #{GetLatestThreeSenders()}
if(scanned and select(2,GetInboxNumItems()) == 0) then
tot = 0
end
end
if(db[faction][realm][character]['mailunread'] == 0) then
db[faction][realm][character]['mailunread'] = 1
end
if(tot == 0) then
return tot
else
return (db[faction][realm][character]['mailunread'] .. "/" .. tot)
end
else
return tot
end
end
local function iterateMail()
for i = 1, GetInboxNumItems() do
if(not select(9,GetInboxHeaderInfo(i))) then
return 1
end
end
return nil
end
local function updateText(self, event)
db[faction][realm][character]['newmail'] = HasNewMail()
if(MailFrame:IsVisible() and GetInboxNumItems() > 0) then
db[faction][realm][character]['newmail'] = iterateMail()
end
OnText(addon:colorize(mail(),db[faction][realm][character]['newmail'] and "00ff00" or "ffffff"))
if(event == "MAIL_SHOW") then
scanned = true
elseif(event == "UPDATE_PENDING_MAIL") then
scanned = false
end
end
local function OnTooltip(tip)
tip:AddLine(childName)
local senderlist = {GetLatestThreeSenders()}
for _,v in ipairs(senderlist) do
tip:AddLine(addon:colorize(v,"ffffff"))
end
updateText()
end
local origME
local function hideMapMail()
origME = MiniMapMailFrame:GetScript("OnEvent")
MiniMapMailFrame:Hide()
MiniMapMailFrame:SetScript("OnEvent", nil)
end
local function showMapMail()
MiniMapMailFrame:Show()
MiniMapMailFrame:SetScript("OnEvent", origME)
origME = nil
end
local function getPref(info)
return db[info[#info]]
end
local function setPref(info,value)
db[info[#info]] = value
if(not db['showOrgMail'] and not origME) then
hideMapMail()
elseif(db['showOrgMail']) then
showMapMail()
end
end
local function init()
addon:RegisterFunc({'MAIL_SHOW',"MAIL_INBOX_UPDATE","UPDATE_PENDING_MAIL"},"OnEvent", updateText)
options = addon:InitConfig(childName, true, {
['name'] = childName,
['type'] = "data source",
['OnClick'] = OnClick,
['OnTooltipShow'] = OnTooltip,
}, getPref, setPref)
db = addon['db']['profile'][childName]
db[faction] = db[faction] or {}
db[faction][realm] = db[faction][realm] or {}
db[faction][realm][character] = db[faction][realm][character] or {}
db[faction][realm][character]['mail'] = db[faction][realm][character]['mail'] or 0
db[faction][realm][character]['mailunread'] = db[faction][realm][character]['mailunread'] or 0
addon:AddConfigEntry(childName, "toggle","showOrgMail",'Show Mail','Show original Minimap Symbol',1,nil,nil,nil,nil,options['args'][childName])
if(not db['showOrgMail']) then hideMapMail() end
end
addon:startup(name, childName, init, true, defaults)

BIN
icon2.tga Normal file

Binary file not shown.

6
license.txt Normal file
View File

@ -0,0 +1,6 @@
The following license excludes the libraries (Libs) included. See the libraries directory or website.
This AddOn is public domain. That means you can change it, rename it or paint it yellow.
My name (Rilgamon) is valid only for WoWInterface.com and curse.com.
If you use/offer this addon on another website please remove my name.
If you want to give me credit you can replace it with a link to my profile on WoWInterface.com.

3
pack.xml Normal file
View File

@ -0,0 +1,3 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="core.lua"/>
</Ui>

12
zz_Mailbox.toc Normal file
View File

@ -0,0 +1,12 @@
## Interface: 90002
## X-Repository: https://svn.grml.de/zz_Mailbox
## X-WoWI-ID: 20501
## X-Curse-Project-ID: 39073
## X-TOC-Classic: 11302
## Title: Mailbox
## Notes: You've got mail
## Author: Rilgamon
## SavedVariables: zz_MailboxDB
## OptionalDeps: Ace3, BrokerPack, zzLibCommon
Common\common.xml
pack.xml