WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Help with Devloping a "One Bag Addon" (https://www.wowinterface.com/forums/showthread.php?t=54944)

Aftermathhqt 12-21-16 09:26 AM

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!

SDPhantom 12-21-16 11:51 AM

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.

Banknorris 12-21-16 12:38 PM

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.

p3lim 12-21-16 05:06 PM

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.

Aftermathhqt 12-22-16 03:49 AM

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 :)

d87 12-22-16 04:42 AM

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

Aftermathhqt 12-22-16 05:08 AM

Quote:

Originally Posted by d87 (Post 321429)
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.

tonyis3l33t 12-22-16 07:37 PM

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.

Aftermathhqt 12-23-16 05:04 AM

Quote:

Originally Posted by tonyis3l33t (Post 321433)
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

SDPhantom 12-23-16 06:29 AM

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.


All times are GMT -6. The time now is 12:44 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI