Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DJSchaffner committed Feb 12, 2024
0 parents commit aef93c1
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ['https://www.buymeacoffee.com/djschaffner']
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Lua.diagnostics.globals": [
"CreateFrame",
"print",
"UIDropDownMenu_SetWidth",
"UIDropDownMenu_SetText",
"UIDropDownMenu_Initialize",
"SlashCmdList",
"ToggleDropDownMenu",
"UIDropDownMenu_AddButton",
"UIDropDownMenu_CreateInfo",
"UnitBuff",
"DEFAULT_CHAT_FRAME",
"StaticPopupDialogs",
"StaticPopup_Show"
]
}
7 changes: 7 additions & 0 deletions BetterBags_ItemRack.toc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Interface: 11501
## Title: BetterBags - ItemRack
## Notes: Add a category to BetterBags for ItemRack sets
## Author: DJSchaffner
## Version: @1.0

main.lua
4 changes: 4 additions & 0 deletions deploy.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
echo Copying files...
cp -r ../BetterBags_ItemRack "C:\Program Files (x86)\World of Warcraft\_classic_era_\Interface\AddOns"
echo Deployed
65 changes: 65 additions & 0 deletions main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---@class BetterBags: AceAddon
local addonBetterBags = LibStub('AceAddon-3.0'):GetAddon("BetterBags")
---@class Categories: AceModule
local categories = addonBetterBags:GetModule('Categories')
---@class Localization: AceModule
local L = addonBetterBags:GetModule('Localization')

local debug = false
local frame = CreateFrame("Frame", nil)
local categoryName = "Sets"
-------------------------------------------------------
local function printChat(message)
if debug == true then
print("[BetterBags ItemRack] "..message)
end
end

local function split(s, sep)
local fields = {}

local sep = sep or " "
local pattern = string.format("([^%s]+)", sep)
string.gsub(s, pattern, function(c) fields[#fields + 1] = c end)

return fields
end

local function updateCategory()
-- Wipe category since we can't retrieve deleted set from itemRack (Except maybe store duplicate of sets and check last version of it)
categories:WipeCategory(L:G(categoryName))

-- Loop all sets
for setName, _ in pairs(ItemRackUser.Sets) do
-- Only update user sets (internals start with '~')
if not string.match(setName, "^~") then
printChat("Updating set: " .. setName)
-- Loop all items of set
for _, item in pairs(ItemRackUser.Sets[setName].equip) do
local id = tonumber(split(item, ":")[1])
--printChat(id)
--printChat(GetItemInfo(ItemRack.IRStringToItemString(item)))
categories:AddItemToCategory(id, L:G(categoryName))
printChat("Added item '" .. id .. "' to '" .. categoryName .. "' category")
end
else
printChat("Skipping internal set: " .. setName)
end
end
end

local function itemRackUpdated(event, _)
printChat(event)
updateCategory()
end
-------------------------------------------------------
frame:RegisterEvent("ADDON_LOADED")
frame:SetScript("OnEvent", function(self, event, addon, ...)
if event == "ADDON_LOADED" and addon == "ItemRack" then
ItemRack:RegisterExternalEventListener("ITEMRACK_SET_SAVED", itemRackUpdated)
ItemRack:RegisterExternalEventListener("ITEMRACK_SET_DELETED", itemRackUpdated)

printChat("ItemRack Loaded.. Initializing Category")
updateCategory()
end
end)
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## BetterBags - ItemRack
This is a filter for the World of Warcraft addon [BetterBags](https://github.com/Cidan/BetterBags) and requires both [BetterBags](https://github.com/Cidan/BetterBags) and [ItemRack](https://github.com/Rottenbeer/ItemRack)

Plugin was written for Classic SoD so it might not work for other versions of the game.

It will collect all items assigned to an ItemRack set and place them in a single category. Might add the option to split them up into seperate categories for each set later but no promises.

0 comments on commit aef93c1

Please sign in to comment.