Quantcast
Help with Devloping a "One Bag Addon" - WoWInterface
Thread Tools Display Modes
12-21-16, 09:26 AM   #1
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Help with Devloping a "One Bag Addon"

I've been trying to make a "One Bag Addon" for years that is lightweight and not too complicated to make, but my knowledge isn't the biggest, and i don't really know how get started for this.

So if anyone can help me out how to get started on this i will be very thankful!
  Reply With Quote
12-21-16, 11:51 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,929
I'd start with a list of everything you want the addon to do. Then figure out what events you want the addon to respond to in order to fulfill those needs, and work forward from that. When building the UI, you might want to consider design aspects like how many rows or columns do you want buttons to show up in and anything else you want shown. Planning out these things before you start coding is a major step to the development of an addon.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
12-21-16, 12:38 PM   #3
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
Not particularly helpful, but just a suggestion for a single feature that I think is important. If you have an option to hide empty bag slots (you should), it would be a good idea to always show a single empty slot. That will be handful when you want to split stacks. A text indicanting how many empty slots are left is enough.

Arkinventory, the best bag addon I know, doesn't have this feature despite having around 30k lines of code which is kinda of funny.
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill

Last edited by Banknorris : 12-21-16 at 12:40 PM.
  Reply With Quote
12-21-16, 05:06 PM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,702
Take a look at Backpack, while by default it's categorized, you can disable all the categories and you'll get a all-in-one solution (it also has that empty slot feature that Banknorris mentioned).

It's also designed as a framework, allowing you to create your own layout (and distribute it), in some way it could be considered a successor to cargBags.
  Reply With Quote
12-22-16, 03:49 AM   #5
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
I know exactly how i want it to be, I want it to have 12 buttons per row and the maxium of coloums.

I already have my "layout/skin" figure.

How it currently looks like (Nothing super fancy just simple)

I want emtpy slots to always be shown. (But can probly work on some feature to hide it later, not so important right now just wanna get this "one bag feature" first)

P3lim: I have checked it out, but i just want to build something myself. And it would take a lot of work to rebuild yours into my UI

Last edited by Aftermathhqt : 12-22-16 at 04:04 AM.
  Reply With Quote
12-22-16, 04:42 AM   #6
d87
A Chromatic Dragonspawn
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 154
You've been trying for years and don't know how to get started?
You can start by looking at https://github.com/tekkub/wow-ui-sou...ainerFrame.lua
or another inventory addons, but they could be more complicated

And still, i would just reskin Bagnon, and it's probably quite lightweight without BagBrother

Last edited by d87 : 12-22-16 at 04:54 AM.
  Reply With Quote
12-22-16, 05:08 AM   #7
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by d87 View Post
You've been trying for years and don't know how to get started?
You can start by looking at https://github.com/tekkub/wow-ui-sou...ainerFrame.lua
or another inventory addons, but they could be more complicated

And still, i would just reskin Bagnon, and it's probably quite lightweight without BagBrother
Looking at that won't get me anywhere really, i need help with building a "one bag feature" and i dont really know how do it or start or which functions i need.

Bagnon is just too big and too many features, libs, etc. But thanks anyway.
  Reply With Quote
12-22-16, 07:37 PM   #8
tonyis3l33t
A Cyclonian
 
tonyis3l33t's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 47
https://github.com/tekkub/wow-ui-sou...ainerFrame.xml
https://github.com/tekkub/wow-ui-sou...ainerFrame.lua

As d87 pointed out, these ARE exactly where you should start STUDYING. This is how Blizzard themselves make the bags. ALL the functions in the lua will be needed to simply maintain the existing features. The .xml will also be needed unless you plan to convert it all manually into .lua code.
  Reply With Quote
12-23-16, 05:04 AM   #9
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by tonyis3l33t View Post
https://github.com/tekkub/wow-ui-sou...ainerFrame.xml
https://github.com/tekkub/wow-ui-sou...ainerFrame.lua

As d87 pointed out, these ARE exactly where you should start STUDYING. This is how Blizzard themselves make the bags. ALL the functions in the lua will be needed to simply maintain the existing features. The .xml will also be needed unless you plan to convert it all manually into .lua code.
I understand, what you mean.

Anyway here is something i scrapped up.. Doesn't work really how i want it to be, i just want it be parented to ContainerFrame1 (Backpack). I want the "one bag" to act without having to use all the togglebags etc etc.

Lua Code:
  1. local function CheckSlots()
  2.     local numBags = 1
  3.     for i = 1, NUM_BAG_FRAMES do
  4.         local bagName = "ContainerFrame"..i+1
  5.         if _G[bagName]:IsShown() and not _G[bagName.."BackgroundTop"]:GetTexture():find("Bank") then
  6.             numBags = numBags + 1
  7.         end
  8.     end
  9.     return numBags
  10. end
  11.  
  12. local Spacing = 4
  13. local bu, con, bag, col, row
  14. local buttons, bankbuttons = {}, {}
  15.  
  16. local MoveButtons = function(table, frame, extraHeight)
  17.     local columns = ceil(sqrt(#table))
  18.     local iconSize = 32
  19.  
  20.     col, row = 0, 0
  21.     for i = 1, #table do
  22.         bu = table[i]
  23.         bu:ClearAllPoints()
  24.         bu:SetPoint("TOPLEFT", frame, "TOPLEFT", col * (iconSize + Spacing) + 3, -1 * row * (iconSize + Spacing) - 3)
  25.         if(col > (columns - 2)) then
  26.             col = 0
  27.             row = row + 1
  28.         else
  29.             col = col + 1
  30.         end
  31.     end
  32.  
  33.     frame:SetHeight((row + (col==0 and 0 or 1)) * (iconSize + Spacing) + 19 + (extraHeight or 0))
  34.     frame:SetWidth(columns * iconSize + Spacing * (columns - 1) + 6)
  35.     col, row = 0, 0
  36. end
  37.  
  38. local BagHolder = CreateFrame("Button", "BagsHolder", UIParent)
  39. BagHolder:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -30, 30)
  40. BagHolder:SetFrameStrata("HIGH")
  41. BagHolder:Hide()
  42.  
  43. local ReanchorButtons = function()
  44.     table.wipe(buttons)
  45.     for f = 1, CheckSlots() do
  46.         con = "ContainerFrame"..f
  47.        
  48.         for i = GetContainerNumSlots(_G[con]:GetID()), 1, -1 do
  49.             bu = _G[con.."Item"..i]
  50.             tinsert(buttons, bu)
  51.         end
  52.     end
  53.  
  54.     MoveButtons(buttons, BagHolder)
  55.  
  56.     BagHolder:Show()
  57. end
  58.  
  59. local CloseBags = function()
  60.     BagHolder:Hide()
  61.     for i = 0, 11 do
  62.         CloseBag(i)
  63.     end
  64. end
  65.  
  66. local CloseBags2 = function()
  67.     BagHolder:Hide()
  68. end
  69.  
  70. local OpenBags = function()
  71.     for i = 0, 4 do
  72.         OpenBag(i)
  73.     end
  74. end
  75.  
  76. local ToggleBags = function()
  77.     if(IsBagOpen(0)) then
  78.         CloseBags()
  79.     else
  80.         OpenBags()
  81.     end
  82. end
  83.  
  84. for i = 1, 5 do
  85.     local bag = _G["ContainerFrame"..i]
  86.     hooksecurefunc(bag, "Show", ReanchorButtons)
  87.     hooksecurefunc(bag, "Hide", CloseBags2)
  88. end
  89.  
  90. ToggleBackpack = ToggleBags
  91. ToggleBag = ToggleBags
  92. OpenAllBags = OpenBags
  93. OpenBackpack = OpenBags
  94. CloseAllBags = CloseBags
  Reply With Quote
12-23-16, 06:29 AM   #10
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,929
One major thing to keep in mind is some functions like UseContainerItem() are protected functions. Blizzard can use them freely, but we have jump through hoops to implement the same functionality.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help with Devloping a "One Bag Addon"

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off