WoWInterface SVN LootTracker

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk/LootTracker/libs
    from Rev 53 to Rev 55
    Reverse comparison

Rev 53 → Rev 55

Dongle.lua
155,7 → 155,7
---------------------------------------------------------------------------]]
 
local major = "Dongle-1.0"
local minor = tonumber(string.match("$Revision: 371 $", "(%d+)") or 1) + 500
local minor = tonumber(string.match("$Revision: 629 $", "(%d+)") or 1) + 500
-- ** IMPORTANT NOTE **
-- Due to some issues we had previously with Dongle revision numbers
-- we need to artificially inflate the minor revision number, to ensure
898,7 → 898,7
end
 
function Dongle.GetCurrentProfile(db)
assert(e, databases[db], string.format(L["MUST_CALLFROM_DBOBJECT"], "GetCurrentProfile"))
assert(3, databases[db], string.format(L["MUST_CALLFROM_DBOBJECT"], "GetCurrentProfile"))
return db.keys.profile
end
 
1147,44 → 1147,41
end
end
 
local function PLAYER_LOGIN()
Dongle.initialized = true
for i=1, #loadorder do
local obj = loadorder[i]
if type(obj.Enable) == "function" then
safecall(obj.Enable, obj)
local PLAYER_LOGIN
do
local lockPlayerLogin = false
 
function PLAYER_LOGIN()
if lockPlayerLogin then return end
 
lockPlayerLogin = true
 
local obj = table.remove(loadorder, 1)
while obj do
if type(obj.Enable) == "function" then
safecall(obj.Enable, obj)
end
obj = table.remove(loadorder, 1)
end
loadorder[i] = nil
 
lockPlayerLogin = false
end
end
 
local function ADDON_LOADED(event, ...)
for i=1, #loadqueue do
local obj = loadqueue[i]
local obj = table.remove(loadqueue, 1)
while obj do
table.insert(loadorder, obj)
 
 
if type(obj.Initialize) == "function" then
safecall(obj.Initialize, obj)
end
loadqueue[i] = nil
end
 
if not Dongle.initialized then
if type(IsLoggedIn) == "function" then
Dongle.initialized = IsLoggedIn()
else
Dongle.initialized = ChatFrame1.defaultLanguage
end
obj = table.remove(loadqueue, 1)
end
 
if Dongle.initialized then
for i=1, #loadorder do
local obj = loadorder[i]
if type(obj.Enable) == "function" then
safecall(obj.Enable, obj)
end
loadorder[i] = nil
end
if IsLoggedIn() then
PLAYER_LOGIN()
end
end
 
OptionHouse.lua
1,5 → 1,90
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
-- LibStub is hereby placed in the Public Domain
-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
local LibStub = _G[LIBSTUB_MAJOR]
 
-- Check to see is this version of the stub is obsolete
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR
 
-- LibStub:NewLibrary(major, minor)
-- major (string) - the major version of the library
-- minor (string or number ) - the minor version of the library
--
-- returns nil if a newer or same version of the lib is already present
-- returns empty library object or old library object if upgrade is needed
function LibStub:NewLibrary(major, minor)
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
 
local oldminor = self.minors[major]
if oldminor and oldminor >= minor then return nil end
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
return self.libs[major], oldminor
end
 
-- LibStub:GetLibrary(major, [silent])
-- major (string) - the major version of the library
-- silent (boolean) - if true, library is optional, silently return nil if its not found
--
-- throws an error if the library can not be found (except silent is set)
-- returns the library object if found
function LibStub:GetLibrary(major, silent)
if not self.libs[major] and not silent then
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
end
return self.libs[major], self.minors[major]
end
 
-- LibStub:IterateLibraries()
--
-- Returns an iterator for the currently registered libraries
function LibStub:IterateLibraries()
return pairs(self.libs)
end
 
setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
 
--[[-------------------------------------------------------------------------
Copyright (c) 2006-2007, Dongle Development Team
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
 
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the Dongle Development Team nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------]]
 
--[[-------------------------------------------------------------------------
Begin Library Implementation
---------------------------------------------------------------------------]]
local major = "OptionHouse-1.1"
local minor = tonumber(string.match("$Revision: 619 $", "(%d+)") or 1)
local minor = tonumber(string.match("$Revision: 638 $", "(%d+)") or 1)
 
assert(LibStub, string.format("%s requires LibStub.", major))
 
19,8 → 104,9
["NO_PARENTCAT"] = "No parent category named '%s' exists in %s'",
["SUBCATEGORY_ALREADYREG"] = "The sub-category named '%s' already exists in the category '%s' for '%s'",
["UNKNOWN_FRAMETYPE"] = "Unknown frame type given '%s', only 'main', 'perf', 'addon', 'config' are supported.",
["OPTION_HOUSE"] = "Option House",
["ENTERED_COMBAT"] = "|cFF33FF99Option House|r: Configuration window closed due to entering combat.",
["OPTION_HOUSE"] = "OptionHouse",
["ENTERED_COMBAT"] = "|cFF33FF99OptionHouse|r: Configuration window closed due to entering combat.",
["IN_COMBAT"] = "|cFF33FF99OptionHouse|r: Configuration window cannot be opened while in combat.",
["SEARCH"] = "Search...",
["ADDON_OPTIONS"] = "Addons",
["VERSION"] = "Version: %s",
56,6 → 142,7
local methods = {"RegisterCategory", "RegisterSubCategory", "RemoveCategory", "RemoveSubCategory"}
local addons = {}
local regFrames = {}
local openedByMenu
local evtFrame
local frame
 
252,7 → 339,7
self.down:Enable()
end
 
self.updateFunc()
self.updateFunc(self.updateHandler)
end
 
local function onMouseWheel(self, offset)
322,6 → 409,7
 
frame.scroll.offset = 0
frame.scroll.displayNum = displayNum
frame.scroll.updateHandler = frame
frame.scroll.updateFunc = onScroll
 
-- Actual bar for scrolling
418,7 → 506,23
if( not b ) then
return false
end
 
local aType = type(a.data.sortID)
local bType = type(b.data.sortID)
 
-- Sort categories/sub categories
if( aType == "number" and bType == "number" ) then
if( a.data.sortID == b.data.sortID ) then
return ( a.name < b.name )
end
 
return ( a.data.sortID < b.data.sortID )
elseif( aType == "number" and bType ~= "number" ) then
return true
elseif( bType == "number" and aType ~= "number" ) then
return false
end
 
return ( a.name < b.name )
end
 
439,6 → 543,16
end
end
end
 
if( not data ) then
data = {}
end
 
if( type == "addon" ) then
data.sortID = name
elseif( not data.sortID ) then
data.sortID = 9999999
end
 
table.insert(frame.categories, {name = name, type = type, tooltip = tooltip, data = data, parent = parent, addon = addon} )
frame.resortList = true
655,7 → 769,6
button:Show()
end
 
 
local function updateConfigList(openAlso)
local frame = regFrames.addon
frame.rowID = 0
675,7 → 788,7
frame.categories[id].hide = nil
end
end
 
 
-- Resort list if needed
if( frame.resortList ) then
table.sort(frame.categories, sortCategories)
689,32 → 802,31
-- Total addons
if( addon.name == frame.selectedAddon ) then
displayCategoryRow(addon.type, addon.name, addon.data, addon.tooltip, true)
 
for _, cat in pairs(frame.categories) do
-- Show all the categories with the addon as the parent
if( not cat.hide and cat.parent == addon.name and cat.type == "category" ) then
-- Total categories of the selected addon
if( cat.name == frame.selectedCategory ) then
displayCategoryRow(cat.type, cat.name, cat.data, cat.tooltip, true)
 
local rowID
 
for _, subCat in pairs(frame.categories) do
-- We don't have to check type, because it's the only one that has .addon set
if( not subCat.hide and subCat.parent == cat.name and subCat.addon == addon.name ) then
-- Total sub categories of the selected addons selected category
displayCategoryRow(subCat.type, subCat.name, subCat.data, subCat.tooltip, subCat.name == frame.selectedSubCat)
 
lastID = frame.rowID
 
if( openAlso ) then
opened = subCat.data
end
end
end
 
-- Turns the line from straight down to a curve at the end
if( lastID ) then
frame.lines[lastID]:SetTexCoord(0.4375, 0.875, 0, 0.625)
end
 
 
-- Okay open the category then
if( not opened and openAlso ) then
opened = cat.data
829,8 → 941,7
frame:SetAllPoints(regFrames.main)
 
regFrames.addon = frame
OptionHouseFrames.addon = frame
 
 
frame.buttons = {}
frame.lines = {}
for i=1, 15 do
884,7 → 995,7
if( frame.shownFrame ) then
frame.shownFrame:Hide()
end
 
 
updateConfigList()
ShowUIPanel(frame)
end
906,15 → 1017,29
frame.tabs = {}
 
regFrames.main = frame
OptionHouseFrames.main = frame
 
-- If we don't hide it ourself, the panel layout becomes messed up
-- because dynamically created frames are created shown
frame:Hide()
 
frame:SetScript("OnHide", function()
if( openedByMenu ) then
openedByMenu = nil
 
PlaySound("gsTitleOptionExit");
ShowUIPanel(GameMenuFrame)
end
end)
frame:SetScript("OnShow", function()
if( OptionHouseDB and OptionHouseDB.position ) then
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT", nil, "BOTTOMLEFT", OptionHouseDB.position.x, OptionHouseDB.position.y)
end
end)
 
frame:SetAttribute("UIPanelLayout-defined", true)
frame:SetAttribute("UIPanelLayout-enabled", true)
--~ frame:SetAttribute("UIPanelLayout-area", "doublewide") -- This is broken in the Blizzy code >< Slouken's been sent a fix
frame:SetAttribute("UIPanelLayout-area", "left")
frame:SetAttribute("UIPanelLayout-area", "doublewide")
frame:SetAttribute("UIPanelLayout-whileDead", true)
table.insert(UISpecialFrames, name)
 
924,18 → 1049,59
title:SetPoint("TOPLEFT", 75, -15)
 
-- Embedded version wont include the icon cause authors are more whiny then users
-- Also, we want to use different methods of frame dragging
if( not IsAddOnLoaded("OptionHouse") ) then
local texture = frame:CreateTexture(nil, "OVERLAY")
texture:SetWidth(57)
texture:SetHeight(57)
texture:SetPoint("TOPLEFT", 9, -7)
SetPortraitTexture(texture, "player")
 
frame:EnableMouse(true)
else
local texture = frame:CreateTexture(nil, "OVERLAY")
texture:SetWidth(128)
texture:SetHeight(128)
texture:SetPoint("TOPLEFT", 9, -2)
texture:SetTexture("Interface\\AddOns\\OptionHouse\\GnomePortrait")
 
frame:EnableMouse(false)
frame:SetMovable(not OptionHouseDB.locked)
 
-- This goes in the entire bar where "OptionHouse" title text is
local mover = CreateFrame("Button", nil, frame)
mover:SetPoint("TOP", 25, -15)
mover:SetHeight(19)
mover:SetWidth(730)
 
mover:SetScript("OnLeave", hideTooltip)
mover:SetScript("OnEnter", showTooltip)
mover:SetScript("OnMouseUp", function(self)
if( self.isMoving ) then
local parent = self:GetParent()
parent:StopMovingOrSizing()
OptionHouseDB.position = {x = parent:GetLeft(), y = parent:GetTop()}
 
self.isMoving = nil
end
end)
 
mover:SetScript("OnMouseDown", function(self, mouse)
local parent = self:GetParent()
 
-- Start moving!
if( parent:IsMovable() and mouse == "LeftButton" ) then
self.isMoving = true
parent:StartMoving()
 
-- Reset position
elseif( mouse == "RightButton" ) then
parent:ClearAllPoints()
parent:SetPoint("TOPLEFT", 0, -104)
 
OptionHouseDB.position = nil
end
end)
end
 
local title = frame:CreateFontString(nil, "OVERLAY")
1051,7 → 1217,6
end
 
regFrames[type] = frame
OptionHouseFrames[type] = frame
end
 
-- PUBLIC API's
1059,11 → 1224,16
if( type ~= "addon" and type ~= "manage" and type ~= "perf" and type ~= "main" ) then
error(string.format(L["UNKNOWN_FRAMETYPE"], type), 3)
end
 
 
return regFrames[type]
end
 
function OptionHouse:Open(addonName, parentCat, childCat)
if( InCombatLockdown() ) then
DEFAULT_CHAT_FRAME:AddMessage(L["IN_COMBAT"])
return
end
 
argcheck(addonName, 1, "string", "nil")
argcheck(parentCat, 2, "string", "nil")
argcheck(childCat, 3, "string", "nil")
1085,10 → 1255,16
end
 
function OptionHouse:OpenTab(id)
if( InCombatLockdown() ) then
DEFAULT_CHAT_FRAME:AddMessage(L["IN_COMBAT"])
return
end
 
argcheck(id, 1, "number")
 
createOHFrame()
assert(3, #(tabfunctions) > id, string.format(L["UNKNOWN_TAB"], id, #(tabfunctions)))
 
createOHFrame()
tabOnClick(id)
ShowUIPanel(frame)
end
1116,18 → 1292,19
return addons[name].obj
end
 
function OptionHouse.RegisterCategory(addon, name, handler, func, noCache)
function OptionHouse.RegisterCategory(addon, name, handler, func, noCache, sortID)
argcheck(name, 2, "string")
argcheck(handler, 3, "string", "function", "table")
argcheck(func, 4, "string", "function", "nil")
argcheck(noCache, 5, "boolean", "number", "nil")
argcheck(sortID, 6, "number", "nil")
assert(3, handler or func, L["NO_FUNC_PASSED"])
assert(3, addons[addon.name], string.format(L["MUST_CALL"], "RegisterCategory"))
assert(3, addons[addon.name].categories, string.format(L["CATEGORY_ALREADYREG"], name, addon.name))
 
-- Category numbers are required so we know when to skip it because only one category/sub cat exists
addons[addon.name].totalCats = addons[addon.name].totalCats + 1
addons[addon.name].categories[name] = {func = func, handler = handler, noCache = noCache, sub = {}, totalSubs = 0}
addons[addon.name].categories[name] = {func = func, handler = handler, noCache = noCache, sub = {}, totalSubs = 0, sortID = sortID or 9999999}
 
if( regFrames.addon ) then
addCategoryListing(addon.name, addons[addon.name])
1135,12 → 1312,13
end
end
 
function OptionHouse.RegisterSubCategory(addon, parentCat, name, handler, func, noCache)
function OptionHouse.RegisterSubCategory(addon, parentCat, name, handler, func, noCache, sortID)
argcheck(parentCat, 2, "string")
argcheck(name, 3, "string")
argcheck(handler, 4, "string", "function", "table")
argcheck(func, 5, "string", "function", "nil")
argcheck(noCache, 6, "boolean", "number", "nil")
argcheck(sortID, 7, "number", "nil")
assert(3, handler or func, L["NO_FUNC_PASSED"])
assert(3, addons[addon.name], string.format(L["MUST_CALL"], "RegisterSubCategory"))
assert(3, addons[addon.name].categories[parentCat], string.format(L["NO_PARENTCAT"], parentCat, addon.name))
1148,7 → 1326,7
 
addons[addon.name].totalSubs = addons[addon.name].totalSubs + 1
addons[addon.name].categories[parentCat].totalSubs = addons[addon.name].categories[parentCat].totalSubs + 1
addons[addon.name].categories[parentCat].sub[name] = {handler = handler, func = func, noCache = noCache}
addons[addon.name].categories[parentCat].sub[name] = {handler = handler, func = func, noCache = noCache, sortID = sortID or 9999999}
 
if( regFrames.addon ) then
addCategoryListing(addon.name, addons[addon.name])
1227,6 → 1405,8
local menubutton = CreateFrame("Button", "GameMenuButtonOptionHouse", GameMenuFrame, "GameMenuButtonTemplate")
menubutton:SetText(L["OPTION_HOUSE"])
menubutton:SetScript("OnClick", function()
openedByMenu = true
 
PlaySound("igMainMenuOption")
HideUIPanel(GameMenuFrame)
SlashCmdList["OPTHOUSE"]()
1241,8 → 1421,6
end
end
 
OptionHouseFrames = OptionHouseFrames or {}
 
OptionHouse.addons = addons
OptionHouse.evtFrame = evtFrame
OptionHouse.tabfunctions = tabfunctions
1253,7 → 1431,7
addon.obj[method] = OptionHouse[method]
end
end
 
 
SLASH_OPTHOUSE1 = "/opthouse"
SLASH_OPTHOUSE2 = "/oh"
SlashCmdList["OPTHOUSE"] = function(...)
1270,4 → 1448,4
end
end
 
instanceLoaded()
\ No newline at end of file +instanceLoaded()