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 @@
-
diff --git a/OutfitterLDB.lua b/OutfitterLDB.lua
index 5c017c2..79554b5 100644
--- a/OutfitterLDB.lua
+++ b/OutfitterLDB.lua
@@ -15,6 +15,20 @@ function Outfitter.LDB:Initialize()
Outfitter:RegisterOutfitEvent("OUTFITTER_INIT", function (...) self:OutfitEvent(...) end)
end
+function Outfitter.LDB:CreateIcon(hideMinimapButton)
+ self.icon = LibStub("LibDBIcon-1.0")
+
+ self.icon:Register(Outfitter.cTitle, self.DataObj, { hide = hideMinimapButton })
+end
+
+function Outfitter.LDB:ShowIcon()
+ self.icon:Show(Outfitter.cTitle)
+end
+
+function Outfitter.LDB:HideIcon()
+ self.icon:Hide(Outfitter.cTitle)
+end
+
function Outfitter.LDB:OnClick(pFrame, pButton)
if pButton == "LeftButton" then
self:ToggleMenu()
diff --git a/OutfitterMinimapButton.lua b/OutfitterMinimapButton.lua
index 71edc14..11b7c33 100644
--- a/OutfitterMinimapButton.lua
+++ b/OutfitterMinimapButton.lua
@@ -1,130 +1,3 @@
-Outfitter._MinimapButton = {}
-
-function Outfitter._MinimapButton:Construct()
- self:RegisterForDrag("LeftButton")
- self.CurrentOutfitTexture = self:CreateTexture(nil, "BACKGROUND")
- self.CurrentOutfitTexture:SetWidth(22)
- self.CurrentOutfitTexture:SetHeight(22)
- self.CurrentOutfitTexture:SetPoint("TOPLEFT", self, "TOPLEFT", 5, -4)
- SetPortraitToTexture(self.CurrentOutfitTexture, "Interface\\Icons\\INV_Chest_Cloth_21")
-end
-
-function Outfitter._MinimapButton:MouseDown()
- -- Remember where the cursor was in case the user drags
-
- local vCursorX, vCursorY = GetCursorPosition()
-
- vCursorX = vCursorX / self:GetEffectiveScale()
- vCursorY = vCursorY / self:GetEffectiveScale()
-
- OutfitterMinimapButton.CursorStartX = vCursorX
- OutfitterMinimapButton.CursorStartY = vCursorY
-
- local vCenterX, vCenterY = OutfitterMinimapButton:GetCenter()
- local vMinimapCenterX, vMinimapCenterY = Minimap:GetCenter()
-
- OutfitterMinimapButton.CenterStartX = vCenterX - vMinimapCenterX
- OutfitterMinimapButton.CenterStartY = vCenterY - vMinimapCenterY
-
- OutfitterMinimapButton.EnableFreeDrag = IsModifierKeyDown()
-end
-
-function Outfitter._MinimapButton:DragStart()
- Outfitter.SchedulerLib:ScheduleUniqueRepeatingTask(0, self.UpdateDragPosition, self)
-end
-
-function Outfitter._MinimapButton:DragEnd()
- Outfitter.SchedulerLib:UnscheduleTask(self.UpdateDragPosition, self)
-end
-
-function Outfitter._MinimapButton:UpdateDragPosition()
- -- Remember where the cursor was in case the user drags
-
- local vCursorX, vCursorY = GetCursorPosition()
-
- vCursorX = vCursorX / self:GetEffectiveScale()
- vCursorY = vCursorY / self:GetEffectiveScale()
-
- local vCursorDeltaX = vCursorX - OutfitterMinimapButton.CursorStartX
- local vCursorDeltaY = vCursorY - OutfitterMinimapButton.CursorStartY
-
- --
-
- local vCenterX = OutfitterMinimapButton.CenterStartX + vCursorDeltaX
- local vCenterY = OutfitterMinimapButton.CenterStartY + vCursorDeltaY
-
- if OutfitterMinimapButton.EnableFreeDrag then
- self:SetPosition(vCenterX, vCenterY)
- else
- -- Calculate the angle and set the new position
-
- local vAngle = math.atan2(vCenterX, vCenterY)
-
- self:SetPositionAngle(vAngle)
- end
-end
-
-function Outfitter:RestrictAngle(pAngle, pRestrictStart, pRestrictEnd)
- if pAngle <= pRestrictStart
- or pAngle >= pRestrictEnd then
- return pAngle
- end
-
- local vDistance = (pAngle - pRestrictStart) / (pRestrictEnd - pRestrictStart)
-
- if vDistance > 0.5 then
- return pRestrictEnd
- else
- return pRestrictStart
- end
-end
-
-function Outfitter._MinimapButton:SetPosition(pX, pY)
- gOutfitter_Settings.Options.MinimapButtonAngle = nil
- gOutfitter_Settings.Options.MinimapButtonX = pX
- gOutfitter_Settings.Options.MinimapButtonY = pY
-
- OutfitterMinimapButton:SetPoint("CENTER", Minimap, "CENTER", pX, pY)
-end
-
-function Outfitter._MinimapButton:SetPositionAngle(pAngle)
- local vAngle = pAngle
-
- -- Restrict the angle from going over the date/time icon or the zoom in/out icons
- --[[
- local vRestrictedStartAngle = nil
- local vRestrictedEndAngle = nil
-
- if GameTimeFrame:IsVisible() then
- if MinimapZoomIn:IsVisible()
- or MinimapZoomOut:IsVisible() then
- vAngle = Outfitter:RestrictAngle(vAngle, 0.4302272732931596, 2.930420793963121)
- else
- vAngle = Outfitter:RestrictAngle(vAngle, 0.4302272732931596, 1.720531504573905)
- end
-
- elseif MinimapZoomIn:IsVisible()
- or MinimapZoomOut:IsVisible() then
- vAngle = Outfitter:RestrictAngle(vAngle, 1.720531504573905, 2.930420793963121)
- end
-
- -- Restrict it from the tracking icon area
-
- vAngle = Outfitter:RestrictAngle(vAngle, -1.290357134304173, -0.4918423429923585)
- ]]--
-
- --
-
- local vRadius = 100
-
- local vCenterX = math.sin(vAngle) * vRadius
- local vCenterY = math.cos(vAngle) * vRadius
-
- OutfitterMinimapButton:SetPoint("CENTER", Minimap, "CENTER", vCenterX - 1, vCenterY - 1)
-
- gOutfitter_Settings.Options.MinimapButtonAngle = vAngle
-end
-
function Outfitter:GetMinimapDropdownItems(items)
-- Just return if not initialized yet
if not self.Initialized then
@@ -207,70 +80,4 @@ function Outfitter:GetMinimapOutfitItems(items)
end
end
end
-end
-
-function Outfitter._MinimapButton:HideMenu()
- if not self.dropDownMenu then
- return
- end
-
- self.dropDownMenu:Hide()
- self.dropDownMenu = nil
-end
-
-function Outfitter._MinimapButton:ShowMenu()
- assert(not self.dropDownMenu, "can't show the minimap menu while it's already up")
-
- -- Create the items
- local items = Outfitter:New(Outfitter.UIElementsLib._DropDownMenuItems, function ()
-
- -- Close the menu after a short delay when a menu item is selected
- Outfitter.SchedulerLib:ScheduleTask(0.1, function ()
- self:HideMenu()
- end)
- end)
-
- -- Get the items
- Outfitter:GetMinimapDropdownItems(items)
-
- -- Show the menu
- self.dropDownMenu = Outfitter:New(Outfitter.UIElementsLib._DropDownMenu)
- self.dropDownMenu:Show(items, "TOPRIGHT", self, "TOPRIGHT", -20, -20)
- self.dropDownMenu.cleanup = function ()
- self.dropDownMenu = nil
- end
-end
-
-function Outfitter._MinimapButton:ToggleMenu()
- -- Play a sound
- PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
-
- -- Hide the menu if it's showing
- if self.dropDownMenu then
- self.dropDownMenu:Hide()
- return
- end
-
- -- Get the items
- items = Outfitter:New(Outfitter.UIElementsLib._DropDownMenuItems, function ()
- Outfitter.SchedulerLib:ScheduleTask(0.1, function ()
- if not self.dropDownMenu then
- return
- end
-
- self.dropDownMenu:Hide()
- end)
- end)
- Outfitter:GetMinimapDropdownItems(items)
-
- -- Show the menu
- self.dropDownMenu = Outfitter:New(Outfitter.UIElementsLib._DropDownMenu)
- self.dropDownMenu:Show(items, "TOPRIGHT", self, "TOPRIGHT", -20, -20)
- self.dropDownMenu.cleanup = function ()
- self.dropDownMenu = nil
- end
-end
-
-function Outfitter_OnAddonCompartmentClick(addonName, buttonName)
- Outfitter:OpenUI()
-end
+end
\ No newline at end of file