Compare commits

...

10 Commits

Author SHA1 Message Date
Robin Hüskes 4fcacb8701 Update Libs 2022-12-15 20:41:33 +01:00
Robin Hüskes 66196c9ba6 [zzAddOn] Fix copy&paste error, bumb lib version 2022-12-03 23:33:15 +01:00
Robin Hüskes 8fee33869c Update LibDBIcon 2022-12-03 17:20:26 +01:00
Robin Hüskes 0924683f58 [zzAddOn] Fix to make sure ManagerFrameEvent is fired only once 2022-12-03 16:14:52 +01:00
Robin Hüskes f508e01f0d Update ReadMe 2022-12-03 15:13:15 +01:00
Robin Hüskes 0ebf6dc71f Add pref for SellGrey 2022-12-03 15:08:41 +01:00
Robin Hüskes b5c389c61f Add strings for SellGrey 2022-12-03 15:08:11 +01:00
Robin Hüskes b581b96d72 Add SellGrey functionality
Switch from MERCHANT_SHOW to MANAGER_FRAME
2022-12-03 15:07:48 +01:00
Robin Hüskes 2a87c943cd [zzAddOn] Cleanup RegisterOpen, RegisterClose 2022-12-02 16:13:17 +01:00
Robin Hüskes b1dc280012 [zzAddOn] Add RegisterOpen, RegisterClose 2022-12-02 16:00:04 +01:00
8 changed files with 170 additions and 45 deletions

View File

@ -1,5 +1,5 @@
--[[ $Id: CallbackHandler-1.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ ]]
local MAJOR, MINOR = "CallbackHandler-1.0", 7
--[[ $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
@ -7,21 +7,16 @@ if not CallbackHandler then return end -- No upgrade needed
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
-- Lua APIs
local error = error
local securecallfunction, error = securecallfunction, error
local setmetatable, rawget = setmetatable, rawget
local next, select, pairs, type, tostring = next, select, pairs, type, tostring
local xpcall = xpcall
local function errorhandler(err)
return geterrorhandler()(err)
end
local function Dispatch(handlers, ...)
local index, method = next(handlers)
if not method then return end
repeat
xpcall(method, errorhandler, ...)
securecallfunction(method, ...)
index, method = next(handlers, index)
until not method
end

View File

@ -1,4 +1,4 @@
--@curseforge-project-slug: libdbicon-1-0@
-----------------------------------------------------------------------
-- LibDBIcon-1.0
--
@ -6,7 +6,7 @@
--
local DBICON10 = "LibDBIcon-1.0"
local DBICON10_MINOR = 44 -- Bump on changes
local DBICON10_MINOR = 45 -- Bump on changes
if not LibStub then error(DBICON10 .. " requires LibStub.") end
local ldb = LibStub("LibDataBroker-1.1", true)
if not ldb then error(DBICON10 .. " requires LibDataBroker-1.1.") end
@ -218,37 +218,49 @@ local function createButton(name, object, db)
button.dataObject = object
button.db = db
button:SetFrameStrata("MEDIUM")
if button.SetFixedFrameStrata then -- Classic support
button:SetFixedFrameStrata(true)
end
button:SetFixedFrameStrata(true)
button:SetFrameLevel(8)
if button.SetFixedFrameLevel then -- Classic support
button:SetFixedFrameLevel(true)
end
button:SetFixedFrameLevel(true)
button:SetSize(31, 31)
button:RegisterForClicks("anyUp")
button:RegisterForDrag("LeftButton")
button:SetHighlightTexture(136477) --"Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight"
local overlay = button:CreateTexture(nil, "OVERLAY")
overlay:SetSize(53, 53)
overlay:SetTexture(136430) --"Interface\\Minimap\\MiniMap-TrackingBorder"
overlay:SetPoint("TOPLEFT")
local background = button:CreateTexture(nil, "BACKGROUND")
background:SetSize(20, 20)
background:SetTexture(136467) --"Interface\\Minimap\\UI-Minimap-Background"
background:SetPoint("TOPLEFT", 7, -5)
local icon = button:CreateTexture(nil, "ARTWORK")
icon:SetSize(17, 17)
icon:SetTexture(object.icon)
icon:SetPoint("TOPLEFT", 7, -6)
button.icon = icon
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
local overlay = button:CreateTexture(nil, "OVERLAY")
overlay:SetSize(50, 50)
overlay:SetTexture(136430) --"Interface\\Minimap\\MiniMap-TrackingBorder"
overlay:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0)
local background = button:CreateTexture(nil, "BACKGROUND")
background:SetSize(24, 24)
background:SetTexture(136467) --"Interface\\Minimap\\UI-Minimap-Background"
background:SetPoint("CENTER", button, "CENTER", 0, 1)
local icon = button:CreateTexture(nil, "ARTWORK")
icon:SetSize(18, 18)
icon:SetTexture(object.icon)
icon:SetPoint("CENTER", button, "CENTER", 0, 1)
button.icon = icon
else
local overlay = button:CreateTexture(nil, "OVERLAY")
overlay:SetSize(53, 53)
overlay:SetTexture(136430) --"Interface\\Minimap\\MiniMap-TrackingBorder"
overlay:SetPoint("TOPLEFT")
local background = button:CreateTexture(nil, "BACKGROUND")
background:SetSize(20, 20)
background:SetTexture(136467) --"Interface\\Minimap\\UI-Minimap-Background"
background:SetPoint("TOPLEFT", 7, -5)
local icon = button:CreateTexture(nil, "ARTWORK")
icon:SetSize(17, 17)
icon:SetTexture(object.icon)
icon:SetPoint("TOPLEFT", 7, -6)
button.icon = icon
end
button.isMouseDown = false
local r, g, b = button.icon:GetVertexColor()
button.icon:SetVertexColor(object.iconR or r, object.iconG or g, object.iconB or b)
local r, g, b = icon:GetVertexColor()
icon:SetVertexColor(object.iconR or r, object.iconG or g, object.iconB or b)
icon.UpdateCoord = updateCoord
icon:UpdateCoord()
button.icon.UpdateCoord = updateCoord
button.icon:UpdateCoord()
button:SetScript("OnEnter", onEnter)
button:SetScript("OnLeave", onLeave)

View File

@ -1,13 +1,14 @@
local lib = LibStub:NewLibrary("zzAddOn", 10)
local lib = LibStub:NewLibrary("zzAddOn", 12)
if not lib then return end
local config = LibStub:GetLibrary("zzConfig")
lib['callbacks'] = lib['callbacks'] or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
lib['addons'] = lib['addons'] or {}
lib['managerframe'] = lib['managerframe'] or CreateFrame("FRAME")
lib['events'] = lib['events'] or CreateFrame("FRAME")
local function errormsg(err)
print(format("|cffff0000Error:|r %s",err))
end
local mixins = {'NewAddOn', 'GetAddOn', 'AddChild', 'HasChild', 'IsChild', 'HasParent', 'GetParent', 'GetOptions', 'RegisterEvent','UnregisterEvent','IsClassic','IsBCC','IsRetail', 'GetSpecs', 'Fire'}
local mixins = {'NewAddOn', 'GetAddOn', 'AddChild', 'HasChild', 'IsChild', 'HasParent', 'GetParent', 'GetOptions', 'RegisterEvent','UnregisterEvent','IsClassic','IsBCC','IsRetail', 'GetSpecs', 'Fire', 'RegisterOpen', 'RegisterClose'}
function lib:Fire(...)
lib['callbacks']:Fire(...)
end
@ -103,6 +104,44 @@ end
function lib:IsRetail()
return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
end
local function handleManagerFrame(self, event, num)
if(event == "PLAYER_INTERACTION_MANAGER_FRAME_SHOW") then
lib['callbacks']:Fire(format("show-%i", num))
else
lib['callbacks']:Fire(format("hide-%i", num))
end
end
local function addManagerFrame(self, mode, num, globalfunc)
if(type(num) == 'table') then
for k, v in pairs(num) do
local n = k
local func = v
if(type(v) == 'number') then
n = v
func = globalfunc
end
addManagerFrame(self, mode, n, func)
end
elseif(type(num) == 'number') then
lib.RegisterCallback(self, format("%s-%i", mode, num), globalfunc)
end
end
function lib:RegisterOpen(num, func)
if(not num) then return end
if(not lib['managerframe']:IsEventRegistered("PLAYER_INTERACTION_MANAGER_FRAME_SHOW")) then
lib['managerframe']:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_SHOW")
lib['managerframe']:SetScript("OnEvent", handleManagerFrame)
end
addManagerFrame(self, 'show', num, func)
end
function lib:RegisterClose(num, func)
if(not num) then return end
if(not lib['managerframe']:IsEventRegistered("PLAYER_INTERACTION_MANAGER_FRAME_HIDE")) then
lib['managerframe']:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_HIDE")
lib['managerframe']:SetScript("OnEvent", handleManagerFrame)
end
addManagerFrame(self, 'hide', num, func)
end
function lib:NewAddOn(addonName, addonTable)
local specs = self['specs']
local childName = specs['name']

View File

@ -1,7 +1,7 @@
# zz_Repair
zz_Repair is a broker to display durability.
Optionally it can automaticly repair at a vendor.
Optionally it can automaticly repair at a vendor and sell grey items.
#### Links
[Releases](https://git.grml.de/rilgamon/zz_Repair/releases "Releases") | [Source](https://git.grml.de/rilgamon/zz_Repair "Source") | [Bugs&Comments](https://git.grml.de/rilgamon/zz_Repair/issues "Bugs&Comments") | [Donate](https://liberapay.com/bundesloser "Donate") | [Contact](https://mastodon.grml.de/@robin "Contact")

View File

@ -5,7 +5,11 @@ local events = child['events']
local db, player
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
LibStub("zzHelper"):Embed(child)
child['statusItem'] = {}
child['statusItem'] = {}
local NUM_BAG_SLOTS = NUM_BAG_SLOTS
local GetContainerItemLink = GetContainerItemLink
local GetContainerItemInfo = GetContainerItemInfo
local function prepareDB()
db = addon['db']['profile'][childName]
child['db'] = db
@ -28,7 +32,68 @@ local function getGBLimit()
end
return amount
end
function events:MERCHANT_SHOW()
local function itemInfo(id)
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(id)
if(itemName) then
return {
['itemId'] = id,
['itemName'] = itemName,
['itemLink'] = itemLink,
['itemRarity'] = itemRarity,
['itemLevel'] = itemLevel,
['itemMinLevel'] = itemMinLevel,
['itemType'] = itemType,
['itemSubType'] = itemSubType,
['itemStackCount'] = itemStackCount,
['itemEquipLoc'] = itemEquipLoc,
['itemTexture'] = itemTexture,
['itemSellPrice'] = itemSellPrice
}
end
end
local function CheckGrey(dont)
local info,i = {},{}
local a = 0
local numberOfSlots,link,id
local earnedMoney = 0
while(a<=NUM_BAG_SLOTS) do
numberOfSlots = C_Container.GetContainerNumSlots(a)
local b = 1
while(b<=numberOfSlots) do
local item = ItemLocation:CreateFromBagAndSlot(a, b)
if(item:IsValid()) then
-- link = C_Container.GetContainerItemLink(a, b)
id = C_Item.GetItemID(item)
info = itemInfo(id)
if(info) then
if(info['itemRarity'] == 0) then
if(info['itemSellPrice'] and info['itemSellPrice'] > 0) then
local cinfo = C_Container.GetContainerItemInfo(a, b)
if(cinfo['stackCount']) then
if(not dont) then
print(L['solditem'](C_Item.GetItemLink(item), info['itemSellPrice']))
end
earnedMoney = earnedMoney + info['itemSellPrice'] * cinfo['stackCount']
C_Container.PickupContainerItem(a, b)
PickupMerchantItem()
end
end
end
end
end
b = b + 1
end
a = a + 1
end
if(earnedMoney > 0 and not dont) then
print(L['earnedmoney'](earnedMoney))
end
if(earnedMoney>0 and not dont) then
C_Timer.After(1,function() CheckGrey(true) end)
end
end
local function MERCHANT_SHOW()
if(CanMerchantRepair()) then
local m = GetMoney()
local r = GetRepairAllCost()
@ -60,6 +125,9 @@ function events:MERCHANT_SHOW()
db['repairstats'][player] = db['repairstats'][player] + r
end
end
if(db['sellgrey']) then
CheckGrey()
end
end
function child:pickColor(v)
local col = 'ffffff'
@ -102,6 +170,9 @@ function events:UPDATE_INVENTORY_DURABILITY()
end
events.UPDATE_INVENTORY_ALERTS = events.UPDATE_INVENTORY_DURABILITY
events.UNIT_INVENTORY_CHANGED = events.UPDATE_INVENTORY_DURABILITY
local function MFOpen(...)
MERCHANT_SHOW()
end
child['specs'] = {
['name'] = childName,
['sv'] = true,
@ -122,5 +193,6 @@ function events:PLAYER_ENTERING_WORLD(event)
child:UnregisterEvent('PLAYER_ENTERING_WORLD')
player = format("%s-%s", UnitFullName("player"))
events.UPDATE_INVENTORY_DURABILITY()
child:RegisterOpen(5, MFOpen)
end
child:NewAddOn(...)

View File

@ -40,10 +40,13 @@ if L then
L['Allow Guildbank Repair'] = "Repariere aus Gildenbank"
L['Money low'] = "Nicht genug Geld f\195\188r Reparatur!"
L['HINT3'] = "|c0000ff00Shift-Linksklick|r |c00ffffffschaltet Minimapicon an/aus|r"
L["SellGrey"] = "Verkaufe graue Gegenst\195\164nde"
L['solditem'] = function(link, price) return format("%s verkauft f\195\188r %s", link, child:MoneyString(price, true)) end
L['earnedmoney'] = function(earnedMoney) return format ("%s verdient.", child:MoneyString(earnedMoney, true)) end
end
-- <20> \195\182 <20> \195\159
-- <20> \195\188 <20> \195\164
-- <20> \195\132
-- <20> \195\182
-- <20> \195\156
-- <20> \195\182 <20> \195\159
-- <20> \195\188 <20> \195\164
-- <20> \195\132
-- <20> \195\182
-- <20> \195\156

View File

@ -40,4 +40,7 @@ if L then
L['Allow Guildbank Repair'] = true
L['Money low'] = "No fund for repair!"
L['HINT3'] = "|c0000ff00Shift-Leftclick|r |c00fffffftoggles minimap icon|r"
L["SellGrey"] = "Sell grey items"
L['solditem'] = function(link, price) return format("%s sold for %s", link, child:MoneyString(price, true)) end
L['earnedmoney'] = function(earnedMoney) return format ("Earned %s.", child:MoneyString(earnedMoney, true)) end
end

View File

@ -12,6 +12,7 @@ local init = {
local main = options['args'][childName]
-- print("setup prefs", childName)
config:AddConfigEntry(main, "autorepair", "toggle", L['Autorepair'], nil, 1)
config:AddConfigEntry(main, "sellgrey", "toggle", L['SellGrey'], nil, 1)
config:AddConfigEntry(main, "showlowest", "toggle", L['Show lowest'], L['Show durability of your lowest item only'], 1)
config:AddConfigEntry(main, "listall", "toggle", L['Show all slots'], L['Show all slots in the tooltip instead of damaged only'], 1)
config:AddConfigEntry(main, "guildbankrepair", "toggle", L['Allow Guildbank Repair'], nil, 1)