diff --git a/Libraries/CallbackHandler-1.0.lua b/Libraries/CallbackHandler-1.0.lua index 5a495f6..44543d5 100644 --- a/Libraries/CallbackHandler-1.0.lua +++ b/Libraries/CallbackHandler-1.0.lua @@ -1,61 +1,26 @@ ---[[ $Id: CallbackHandler-1.0.lua 3 2008-09-29 16:54:20Z nevcairiel $ ]] -local MAJOR, MINOR = "CallbackHandler-1.0", 3 +--[[ $Id: CallbackHandler-1.0.lua 26 2022-12-12 15:09:39Z nevcairiel $ ]] +local MAJOR, MINOR = "CallbackHandler-1.0", 8 local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR) if not CallbackHandler then return end -- No upgrade needed local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end} -local type = type -local pcall = pcall -local pairs = pairs -local assert = assert -local concat = table.concat -local loadstring = loadstring -local next = next -local select = select -local type = type -local xpcall = xpcall - -local function errorhandler(err) - return geterrorhandler()(err) -end - -local function CreateDispatcher(argCount) - local code = [[ - local next, xpcall, eh = ... - - local method, ARGS - local function call() method(ARGS) end - - local function dispatch(handlers, ...) - local index - index, method = next(handlers) - if not method then return end - local OLD_ARGS = ARGS - ARGS = ... - repeat - xpcall(call, eh) - index, method = next(handlers, index) - until not method - ARGS = OLD_ARGS - end +-- Lua APIs +local securecallfunction, error = securecallfunction, error +local setmetatable, rawget = setmetatable, rawget +local next, select, pairs, type, tostring = next, select, pairs, type, tostring - return dispatch - ]] - local ARGS, OLD_ARGS = {}, {} - for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end - code = code:gsub("OLD_ARGS", concat(OLD_ARGS, ", ")):gsub("ARGS", concat(ARGS, ", ")) - return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler) +local function Dispatch(handlers, ...) + local index, method = next(handlers) + if not method then return end + repeat + securecallfunction(method, ...) + index, method = next(handlers, index) + until not method end -local Dispatchers = setmetatable({}, {__index=function(self, argCount) - local dispatcher = CreateDispatcher(argCount) - rawset(self, argCount, dispatcher) - return dispatcher -end}) - -------------------------------------------------------------------------- -- CallbackHandler:New -- @@ -64,9 +29,7 @@ end}) -- UnregisterName - name of the callback unregistration API, default "UnregisterCallback" -- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API. -function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName, OnUsed, OnUnused) - -- TODO: Remove this after beta has gone out - assert(not OnUsed and not OnUnused, "ACE-80: OnUsed/OnUnused are deprecated. Callbacks are now done to registry.OnUsed and registry.OnUnused") +function CallbackHandler.New(_self, target, RegisterName, UnregisterName, UnregisterAllName) RegisterName = RegisterName or "RegisterCallback" UnregisterName = UnregisterName or "UnregisterCallback" @@ -88,19 +51,19 @@ function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAll local oldrecurse = registry.recurse registry.recurse = oldrecurse + 1 - Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...) + Dispatch(events[eventname], eventname, ...) registry.recurse = oldrecurse if registry.insertQueue and oldrecurse==0 then -- Something in one of our callbacks wanted to register more callbacks; they got queued - for eventname,callbacks in pairs(registry.insertQueue) do - local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten. - for self,func in pairs(callbacks) do - events[eventname][self] = func + for event,callbacks in pairs(registry.insertQueue) do + local first = not rawget(events, event) or not next(events[event]) -- test for empty before. not test for one member after. that one member may have been overwritten. + for object,func in pairs(callbacks) do + events[event][object] = func -- fire OnUsed callback? if first and registry.OnUsed then - registry.OnUsed(registry, target, eventname) + registry.OnUsed(registry, target, event) first = nil end end @@ -146,9 +109,9 @@ function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAll regfunc = function(...) self[method](self,...) end end else - -- function ref with self=object or self="addonId" - if type(self)~="table" and type(self)~="string" then - error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string expected.", 2) + -- function ref with self=object or self="addonId" or self=thread + if type(self)~="table" and type(self)~="string" and type(self)~="thread" then + error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2) end if select("#",...)>=1 then -- this is not the same as testing for arg==nil! diff --git a/Libraries/LibStub.lua b/Libraries/LibStub.lua index cfc97de..3cf8ea0 100644 --- a/Libraries/LibStub.lua +++ b/Libraries/LibStub.lua @@ -1,30 +1,51 @@ --- 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] - -if not LibStub or LibStub.minor < LIBSTUB_MINOR then - LibStub = LibStub or {libs = {}, minors = {} } - _G[LIBSTUB_MAJOR] = LibStub - LibStub.minor = LIBSTUB_MINOR - - 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 - - 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 - - function LibStub:IterateLibraries() return pairs(self.libs) end - setmetatable(LibStub, { __call = LibStub.GetLibrary }) -end +-- $Id: LibStub.lua 76 2007-09-03 01:50:17Z mikk $ +-- 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 diff --git a/Outfitter.lua b/Outfitter.lua index 798558c..681b948 100644 --- a/Outfitter.lua +++ b/Outfitter.lua @@ -1377,7 +1377,6 @@ function Outfitter:UpdateCurrentOutfitIcon() if type(vTexture) == "number" then vTexture = self:ConvertTextureIDToPath(vTexture) end - SetPortraitToTexture(OutfitterMinimapButton.CurrentOutfitTexture, vTexture) end function Outfitter:BankFrameOpened() @@ -2338,9 +2337,9 @@ function Outfitter:SetShowMinimapButton(pShowButton) self.Settings.Options.HideMinimapButton = not pShowButton if self.Settings.Options.HideMinimapButton then - OutfitterMinimapButton:Hide() + Outfitter.LDB:HideIcon() else - OutfitterMinimapButton:Show() + Outfitter.LDB:ShowIcon() end self:Update(false) @@ -4761,23 +4760,7 @@ function Outfitter:Initialize() end end - -- Set the minimap button - if self.Settings.Options.HideMinimapButton then - OutfitterMinimapButton:Hide() - else - OutfitterMinimapButton:Show() - end - - if not self.Settings.Options.MinimapButtonAngle - and not self.Settings.Options.MinimapButtonX then - self.Settings.Options.MinimapButtonAngle = -1.5708 - end - - if self.Settings.Options.MinimapButtonAngle then - OutfitterMinimapButton:SetPositionAngle(self.Settings.Options.MinimapButtonAngle) - else - OutfitterMinimapButton:SetPosition(self.Settings.Options.MinimapButtonX, self.Settings.Options.MinimapButtonY) - end + Outfitter.LDB:CreateIcon(self.Settings.Options.HideMinimapButton) -- Move the Blizzard UI over a bit PaperDollSidebarTabs:SetPoint("BOTTOMRIGHT", CharacterFrameInsetRight, "TOPRIGHT", -30, -1) diff --git a/Outfitter.toc b/Outfitter.toc index 6b91c49..f2abf03 100644 --- a/Outfitter.toc +++ b/Outfitter.toc @@ -1,7 +1,7 @@ -## Interface: 100200 +## Interface: 100206 ## Author: John Stephen ## Title: Outfitter -## Version: 10.2.0.0 +## Version: 10.2.6.0 ## Notes: Clothing and weapon management and automated equipment changes ## OptionalDeps: ## RequiredDeps: @@ -19,6 +19,7 @@ Libraries/UTF8/utf8.lua Libraries/LibStub.lua Libraries/CallbackHandler-1.0.lua Libraries/LibDataBroker-1.1.lua +Libraries/LibDBIcon-1.0.lua Libraries/LibBabble-3.0.lua Libraries/LibBabble-SubZone-3.0.lua Libraries/LibBabble-Inventory-3.0.lua diff --git a/Outfitter.xml b/Outfitter.xml index b834d66..b78b509 100644 --- a/Outfitter.xml +++ b/Outfitter.xml @@ -1289,42 +1289,6 @@ -