WoWInterface SVN Exonumist

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 46 to Rev 45
    Reverse comparison

Rev 46 → Rev 45

trunk/Exonumist.lua New file
0,0 → 1,265
--[[--------------------------------------------------------------------
Exonumist
A World of Warcraft user interface addon
Copyright (c) 2010-2014 Phanx <addons@phanx.net>. All rights reserved.
See the accompanying README and LICENSE files for more information.
http://www.wowinterface.com/downloads/info16452-Exonumist.html
http://www.curse.com/addons/wow/exonumist
----------------------------------------------------------------------]]
 
local realmDB, charDB
 
local playerList = {}
local classColor = {}
 
local nameToID = {} -- maps localized currency names to IDs
 
local function debug(str, ...)
local f = DEBUG_CHAT_FRAME or ChatFrame3
f:AddMessage("|cffff9f7fExonumist:|r " .. strjoin(" ", tostringall(str, ...)))
end
 
------------------------------------------------------------------------
 
local collapsed, scanning = {}
local function UpdateData()
if scanning then return end
--debug("UpdateData")
scanning = true
local i, limit = 1, GetCurrencyListSize()
while i <= limit do
local name, isHeader, isExpanded, isUnused, isWatched, count, icon = GetCurrencyListInfo(i)
if isHeader then
if not isExpanded then
collapsed[name] = true
ExpandCurrencyList(i, 1)
limit = GetCurrencyListSize()
end
else
local link = GetCurrencyListLink(i)
local id = tonumber(strmatch(link, "currency:(%d+)"))
nameToID[name] = id
--debug(name, "=>", id)
if count > 0 then
charDB[id] = count
else
charDB[id] = nil
end
end
i = i + 1
end
while i > 0 do
local name, isHeader, isExpanded, isUnused, isWatched, count, icon = GetCurrencyListInfo(i)
if isHeader and isExpanded and collapsed[name] then
ExpandCurrencyList(i, 0)
end
i = i - 1
end
wipe(collapsed)
scanning = nil
end
 
------------------------------------------------------------------------
 
local function AddTooltipInfo(tooltip, currency, includePlayer)
if not currency then return end
--debug("AddTooltipInfo", currency, includePlayer)
local spaced
for i = (includePlayer and 1 or 2), #playerList do
local name = playerList[i]
local n = realmDB[name][currency]
if n then
if not spaced then
tooltip:AddLine(" ")
spaced = true
end
local r, g, b
local class = realmDB[name].class
if class then
r, g, b = unpack(classColor[class])
else
r, g, b = 0.5, 0.5, 0.5
end
tooltip:AddDoubleLine(name, n, r, g, b, r, g, b)
end
end
if spaced then
tooltip:Show()
end
end
 
------------------------------------------------------------------------
 
local f = CreateFrame("Frame")
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", function(self, event, addon)
if event == "ADDON_LOADED" then
if addon ~= "Exonumist" then return end
 
local faction = UnitFactionGroup("player")
if faction ~= "Alliance" and faction ~= "Horde" then return end
 
local realm = GetRealmName()
local player = UnitName("player")
 
ExonumistDB = ExonumistDB or { }
ExonumistDB[realm] = ExonumistDB[realm] or { }
ExonumistDB[realm][faction] = ExonumistDB[realm][faction] or { }
ExonumistDB[realm][faction][player] = ExonumistDB[realm][faction][player] or { }
 
realmDB = ExonumistDB[realm][faction]
if not realmDB then return end -- probably low level Pandaren
 
charDB = realmDB[player]
 
local now = time()
charDB.class = select(2, UnitClass("player"))
charDB.lastSeen = now
 
local cutoff = now - (60 * 60 * 24 * 30) -- 30 days
for name, data in pairs(realmDB) do
if data.lastSeen and data.lastSeen < cutoff then
realmDB[name] = nil
elseif name ~= player then
tinsert(playerList, name)
end
end
sort(playerList)
tinsert(playerList, 1, player)
 
self:UnregisterEvent("ADDON_LOADED")
 
if IsLoggedIn() then
self:GetScript("OnEvent")(self, "PLAYER_LOGIN")
else
self:RegisterEvent("PLAYER_LOGIN")
end
elseif event == "PLAYER_LOGIN" then
for k, v in pairs(CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS) do
classColor[k] = { v.r, v.g, v.b }
end
if CUSTOM_CLASS_COLORS then
CUSTOM_CLASS_COLORS:RegisterCallback(function()
for k, v in pairs(CUSTOM_CLASS_COLORS) do
classColor[k][1] = v.r
classColor[k][2] = v.g
classColor[k][3] = v.b
end
end)
end
 
self:UnregisterEvent("PLAYER_LOGIN")
 
self:RegisterEvent("PLAYER_LOGOUT")
 
hooksecurefunc("BackpackTokenFrame_Update", UpdateData)
hooksecurefunc("TokenFrame_Update", UpdateData)
UpdateData()
 
hooksecurefunc(GameTooltip, "SetCurrencyByID", function(tooltip, id)
--debug("SetCurrencyByID", id)
AddTooltipInfo(tooltip, id, not MerchantMoneyInset:IsMouseOver())
end)
 
hooksecurefunc(GameTooltip, "SetCurrencyToken", function(tooltip, i)
--debug("SetCurrencyToken", i)
local name, isHeader, isExpanded, isUnused, isWatched, count, icon = GetCurrencyListInfo(i)
AddTooltipInfo(tooltip, nameToID[name], not TokenFrame:IsMouseOver())
end)
 
hooksecurefunc(GameTooltip, "SetHyperlink", function(tooltip, link)
--debug("SetHyperlink", link)
local id = strmatch(link, "currency:(%d+)")
if id then
AddTooltipInfo(tooltip, tonumber(id), true)
end
end)
 
hooksecurefunc(ItemRefTooltip, "SetHyperlink", function(tooltip, link)
--debug("SetHyperlink", link)
local id = strmatch(link, "currency:(%d+)")
if id then
AddTooltipInfo(tooltip, tonumber(id), true)
end
end)
 
----------------------
-- Merchant costs
----------------------
 
hooksecurefunc(GameTooltip, "SetMerchantCostItem", function(tooltip, item, currency)
--debug("SetMerchantCostItem", item, currency)
local icon, _, _, name = GetMerchantItemCostItem(item, currency)
AddTooltipInfo(tooltip, nameToID[name], true)
end)
 
------------------------------
-- Dungeon finder rewards
------------------------------
 
hooksecurefunc(GameTooltip, "SetLFGDungeonReward", function(tooltip, dungeonID, rewardIndex)
--debug("SetLFGDungeonReward", dungeonID, rewardIndex)
local name = GetLFGDungeonRewardInfo(dungeonID, rewardIndex)
if name then
AddTooltipInfo(tooltip, nameToID[name], true)
end
end)
 
hooksecurefunc(GameTooltip, "SetLFGDungeonShortageReward", function(tooltip, dungeonID, shortageIndex, rewardIndex)
--debug("SetLFGDungeonShortageReward", dungeonID, shortageIndex, rewardIndex)
local name = GetLFGDungeonShortageRewardInfo(dungeonID, shortageIndex, rewardIndex)
if name then
AddTooltipInfo(tooltip, nameToID[name], true)
end
end)
 
---------------------
-- Quest rewards
---------------------
 
hooksecurefunc(GameTooltip, "SetQuestCurrency", function(tooltip, type, id)
local name = GetQuestCurrencyInfo(type, id)
--debug("SetQuestCurrency", type, id, name)
if name then
AddTooltipInfo(tooltip, nameToID[name], true)
end
end)
 
hooksecurefunc(GameTooltip, "SetQuestLogCurrency", function(tooltip, type, id)
--debug("SetQuestLogCurrency", type, id)
local name = GetQuestLogRewardCurrencyInfo(id)
if name then
AddTooltipInfo(tooltip, nameToID[name], true)
end
end)
 
-----------------
-- xMerchant
-----------------
 
if xMerchantFrame then
local function xMerchantTooltip(self)
--debug("xMerchant", self.pointType, self.itemLink)
if self.pointType == "Beta" then
local id = nameToID[self.itemLink]
--debug("Found currency:", id)
if id then
self.UpdateTooltip = nil
return GameTooltip:SetCurrencyByID(id)
end
end
self.UpdateTooltip = self.origUpdateTooltip
end
 
for i = 1, 10 do
for j = 1, MAX_ITEM_COST do
local item = _G["xMerchantFrame"..i.."Item"..j]
item:HookScript("OnEnter", xMerchantTooltip)
item.origUpdateTooltip = item.UpdateTooltip
end
end
end
elseif event == "PLAYER_LOGOUT" then
UpdateData()
end
end)
\ No newline at end of file Property changes : Added: svn:eol-style + native
trunk/README.txt New file
0,0 → 1,61
Exonumist
============
 
Adds currency counts for all of your characters in currency tooltips.
 
For example, tooltips for Justice Points will show you how many Justice
Points each of your characters on the same realm and faction has.
 
There are no options; it “just works”. You must log into a character
at least once with Exonumist enabled before information about that
character’s currency tokens will appear in the tooltips. Data for
characters not seen in the last 30 days is removed automatically.
 
 
Download
-----------
 
* [WoWInterface](http://www.wowinterface.com/downloads/info13993-Exonumist.html)
* [Curse](http://www.curse.com/addons/wow/exonumist)
 
 
Localization
---------------
 
Compatible with English, Deutsch, Español, Français, Italiano,
Português, Русский, 한국어, 简体中文 and 繁體中文 game clients.
 
Does not require translations.
 
 
Colophon
-----------
 
In case you were curious about the name:
 
> exonumist /ek-suh-NOO-mist/
> –noun
> a person who collects items, as tokens or medals, that resemble
> money but are not intended to circulate as money.
 
 
Feedback
-----------
 
Post a ticket on either download site, or a comment on WoWInterface.
 
If you are reporting a bug, please include directions I can follow to
reproduce the bug, whether it still happens when all other addons are
disabled, and the exact text of the related error message (if any) from
[Bugger](http://www.wowinterface.com/downloads/info23144-Bugger.html).
 
If you need to contact me privately, you can send me a private message
on either download site, or email me at <addons@phanx.net>.
 
 
License
----------
 
Copyright (c) 2010-2014 Phanx <addons@phanx.net>. All rights reserved.
See the accompanying LICENSE file for information about the conditions
under which redistribution and modification may be allowed.
Property changes : Added: svn:eol-style + native
trunk/Exonumist.toc New file
0,0 → 1,22
## Interface: 60000
## Version: 6.0.2.wowi:revision
 
## Title: Exonumist
## Notes: Shows currency counts for all your characters in currency tooltips.
## Notes-deDE: Zeigt im Abzeichentooltips die Abzeichenanzahlen von jeden Euer Charaktere.
## Notes-esES: Muestra las cuentas de monedas de todos tus personajes en las descripciones de monedas.
## Notes-esMX: Muestra las cuentas de monedas de todos tus personajes en las descripciones de monedas.
 
## Author: Phanx
## X-Email: addons@phanx.net
## X-Copyright: Copyright (c) 2010-2014 Phanx. All rights reserved.
## X-License: See the accompanying LICENSE file for details.
## X-CompatibleLocales: enUS, deDE, esES, esMX, frFR, itIT, ptBR, ruRU, koKR, zhCN, zhTW
## X-Website: http://www.wowinterface.com/downloads/info13993-Exonumist.html
## X-Curse-Project-ID: exonumist
## X-WoWI-ID: 16452
 
## LoadsWith: Blizzard_TokenUI
## SavedVariables: ExonumistDB
 
Exonumist.lua
\ No newline at end of file Property changes : Added: svn:eol-style + native
trunk/LICENSE.txt New file
0,0 → 1,33
Copyright (c) 2010-2014 Phanx. All rights reserved.
 
Permission is granted for anyone to use, read, or otherwise interpret
this software for any purpose, without any restrictions.
 
Permission is granted for anyone to modify this software or sample from
it, and to distribute such modified versions or derivative works as long
as neither the names of this software nor its authors are used in the
name or title of the work or in any other way that may cause it to be
confused with or interfere with the simultaneous use of this software.
 
Permission is granted for anyone to aggregate this software with other
works not derived from this software for the purpose of creating a user
interface replacement (also commonly known as a "compilation" or "addon
pack") for the "World of Warcraft" game client, and to distribute such
collective works as long as the software is not modified in any way,
including by modifying or removing any files.
 
This software may not be distributed standalone or in any other way, in
whole or in part, modified or unmodified, without specific prior written
permission from the authors of this software.
 
The names of this software and/or its authors may not be used to
promote or endorse works derived from this software without specific
prior written permission from the authors of this software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.