commit 912a95d494a25d395be1cd835ce84572b46b2e02 Author: Robin Date: Wed Jan 13 16:16:52 2021 +0100 Init diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..34950ac --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Common"] + path = Common + url = https://git.grml.de/rilgamon/Common.git diff --git a/Common b/Common new file mode 160000 index 0000000..762c59c --- /dev/null +++ b/Common @@ -0,0 +1 @@ +Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed diff --git a/core.lua b/core.lua new file mode 100644 index 0000000..5169e85 --- /dev/null +++ b/core.lua @@ -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) diff --git a/icon2.tga b/icon2.tga new file mode 100644 index 0000000..045a305 Binary files /dev/null and b/icon2.tga differ diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..6d2e364 --- /dev/null +++ b/license.txt @@ -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. \ No newline at end of file diff --git a/pack.xml b/pack.xml new file mode 100644 index 0000000..0f7eacc --- /dev/null +++ b/pack.xml @@ -0,0 +1,3 @@ + +