Thread Tools Display Modes
05-22-10, 07:21 AM   #1
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Border on bag icons

Hello. I'm using a very simple bag addon called aBags. I got rid of the default border around the icons (bu:SetNormalTexture("")), and now I'm trying to add a 1-pixel border to it. This worked, however, I haven't figured out yet how to change the icon texture position, meaning the default button border/outline/whatever is still showing. In order to hide these the icon texture should be more "zoomed", so I reckon it's something to do with SetTexCoord, but I just can't figure out how.

This is how the code is currently looking.

Code:
local Spacing = 2
local Columns = 9
local NumBags = 5
local NumBankBags = 7
local BankColumns = 13

local _G = getfenv(0)
local bu, con, col, row
local buttons, bankbuttons = {}, {}
local firstopened, firstbankopened = 1, 1

--[[ Function to move buttons ]]
local MoveButtons = function(table, frame, columns)
	col, row = 0, 0
	for i = 1, #table do
		bu = table[i]
		bu:ClearAllPoints()
		bu:SetNormalTexture("")

		local bg = CreateFrame ("Frame", nil, bu)
		bg:SetBackdrop({ 
			bgFile = "", 
			edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", 
			edgeSize = 1, 
			insets = {left = 0, right = 0, top = 0, bottom = 0},
		})

		bg:SetBackdropBorderColor(0, 0, 0)
		bg:SetScale(1)
		bg:SetPoint("TOPLEFT", bu, "TOPLEFT", 1, -1)
		bg:SetPoint("BOTTOMRIGHT", bu, "BOTTOMRIGHT", -1, 1)
		bg:SetFrameStrata("HIGH")

		bu:SetPoint("TOPLEFT", frame, "TOPLEFT", col * (37 + Spacing) + 2, -1 * row * (37 + Spacing) - 1)
		bu.SetPoint = dummy
		if(col > (columns - 2)) then
			col = 0
			row = row + 1
		else
			col = col + 1
		end
	end

	frame:SetHeight((row + (col==0 and 0 or 1)) * (37 + Spacing) + 19)
	frame:SetWidth(columns * 37 + Spacing * (columns - 1) + 3)
end

--[[ Bags ]]
local holder = CreateFrame("Button", "aBagsHolder", UIParent)
holder:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -50, 50)
holder:SetFrameStrata("HIGH")
holder:Hide()

CreateBG(holder):SetTexture(0, 0, 0, .7)

local ReanchorButtons = function()
	if(firstopened==1) then
		for f = 1, NumBags do
			con = "ContainerFrame"..f
			_G[con]:EnableMouse(false)
			_G[con.."CloseButton"]:Hide()
			_G[con.."PortraitButton"]:EnableMouse(false)

			for i = 1, 7 do
				select(i, _G[con]:GetRegions()):SetAlpha(0)
			end

			for i = GetContainerNumSlots(f-1), 1, -1  do
				bu = _G[con.."Item"..i]
				bu:SetFrameStrata("HIGH")
				tinsert(buttons, bu)
			end
		end
		MoveButtons(buttons, holder, Columns)
		firstopened = 0
	end
	holder:Show()
end

local money = _G["ContainerFrame1MoneyFrame"]
money:SetFrameStrata("DIALOG")
money:SetParent(holder)
money:ClearAllPoints()
money:SetPoint("BOTTOMRIGHT", holder, "BOTTOMRIGHT", 12, 2)

--[[ Bank ]]
local bankholder = CreateFrame("Button", "aBagsBankHolder", UIParent)
bankholder:SetFrameStrata("HIGH")
bankholder:Hide()

CreateBG(bankholder):SetTexture(0, 0, 0, .7)

local ReanchorBankButtons = function()
	if(firstbankopened==1) then
		for f = 1, 28 do
			bu = _G["BankFrameItem"..f]
			bu:SetFrameStrata("HIGH")
			tinsert(bankbuttons, bu)
		end
		_G["BankFrame"]:EnableMouse(false)
		_G["BankCloseButton"]:Hide()

		for f = 1, 5 do
			select(f, _G["BankFrame"]:GetRegions()):SetAlpha(0)
		end

		for f = NumBags + 1, NumBags + NumBankBags, 1 do
			con = "ContainerFrame"..f
			_G[con]:EnableMouse(false)
			_G[con.."CloseButton"]:Hide()
			_G[con.."PortraitButton"]:EnableMouse(false)

			for i = 1, 7 do
				select(i, _G[con]:GetRegions()):SetAlpha(0)
			end

			for i = GetContainerNumSlots(f-1), 1, -1  do
				bu = _G[con.."Item"..i]
				bu:SetFrameStrata("HIGH")
				tinsert(bankbuttons, bu)
			end
		end
		MoveButtons(bankbuttons, bankholder, BankColumns)
		bankholder:SetPoint("BOTTOMRIGHT", "aBagsHolder", "BOTTOMLEFT", -10 , 0)
		firstbankopened = 0
	end
	bankholder:Show()
end

local money = _G["BankFrameMoneyFrame"]
money:SetFrameStrata("DIALOG")
money:ClearAllPoints()
money:SetPoint("BOTTOMRIGHT", bankholder, "BOTTOMRIGHT", 12, 2)

--[[ Hiding misc. frames ]]
_G["BankFramePurchaseInfo"]:Hide()
_G["BankFramePurchaseInfo"].Show = dummy

for f = 1, 7 do _G["BankFrameBag"..f]:Hide() end

--[[ Show & Hide functions etc ]]
tinsert(UISpecialFrames, bankholder)
tinsert(UISpecialFrames, holder)

local CloseBags = function()
	bankholder:Hide()
	holder:Hide()
	for i = 0, 11 do
		CloseBag(i)
	end
end

local OpenBags = function()
	for i = 0, 11 do
		OpenBag(i)
	end
end

local ToggleBags = function()
	if(IsBagOpen(0)) then
		CloseBankFrame()
		CloseBags()
	else
		OpenBags()
	end
end

hooksecurefunc(_G["ContainerFrame"..NumBags], "Show", ReanchorButtons)
hooksecurefunc(_G["ContainerFrame"..NumBags], "Hide", CloseBags)
hooksecurefunc(BankFrame, "Show", function()
	OpenBags()
	ReanchorBankButtons()
end)
hooksecurefunc(BankFrame, "Hide", CloseBags)

ToggleBackpack = ToggleBags
OpenAllBags = ToggleBags
OpenBackpack = OpenBags
CloseBackpack = CloseBags
CloseAllBags = CloseBags
And this is a screenshot (ignore the item quality glow for now, I'll figure that out later when this is sorted):

http://i46.tinypic.com/34rx7nr.jpg

Any help would be greatly appreciated.
  Reply With Quote
05-22-10, 08:32 AM   #2
nin
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 213
what happens if you do

Code:
bu:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  Reply With Quote
05-22-10, 08:42 AM   #3
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Attempt to call method 'SetTexCoord' (a nil value)
  Reply With Quote
05-22-10, 03:03 PM   #4
nin
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 213
ah right, read SetNormalTexture as SetTexture and didnt look through the code closely :P sorry.

I can't help you much here, biggest suggestion is checking how other bagmods does it.

By looking at the screenie it looks like you could sort it by just adjusting the border a little? (if it's the small white'ish pixels you wanna get rid of, hard to tell from screenie, tinypic is pretty crappy)

did you also try too add a pixel border too SetNormalTexture instead of removing it, dno how that would look with sizes but could be worth a try.

no wow installed so can't help more than with suggestions :P

good luck!
  Reply With Quote
05-22-10, 03:50 PM   #5
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Thanks for the reply. The default border thing is unfortunately too big for the 1-pixelborder to cover up. I tried looking at a lot of different bag mods, but most of them are just really complicated and either handle it in a totally different way, or just use the default icon border. And SetNormalTexture gives a similar result to what I got now. :<

It can't be impossible.
  Reply With Quote
05-23-10, 05:09 AM   #6
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Code:
local ReanchorButtons = function()
    if(firstopened==1) then
        for f = 1, NumBags do
            con = "ContainerFrame"..f
            _G[con]:EnableMouse(false)
            _G[con.."CloseButton"]:Hide()
            _G[con.."PortraitButton"]:EnableMouse(false)

            for i = 1, 7 do
                select(i, _G[con]:GetRegions()):SetAlpha(0)
            end

            for i = GetContainerNumSlots(f-1), 1, -1  do
                bu = _G[con.."Item"..i]
                bu:SetFrameStrata("HIGH")
                tinsert(buttons, bu)
                _G[con.."Item"..i.."IconTexture"]:SetTexCoord(.1,.9,.1,.9)
            end
        end
        MoveButtons(buttons, holder, Columns)
        firstopened = 0
    end
    holder:Show()
end
Try that?

Edit: Don't ask me what happens if you change your bag size..
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 05-23-10 at 05:13 AM.
  Reply With Quote
05-23-10, 05:53 AM   #7
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Nothing happens I'm afraid. No errors either.

Edit: Suddenly it's somehow working now. Thanks a lot!

Messed around with the glow script, all I need to do now is to find how to kill the default quest item glow.

http://i49.tinypic.com/6r216x.jpg
http://i48.tinypic.com/n55zlu.jpg

Last edited by Haleth : 05-23-10 at 07:05 AM.
  Reply With Quote
05-23-10, 08:06 AM   #8
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
_G[con.."Item"..i.."IconQuestTexture"]:SetTexture("")

same place.
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.
  Reply With Quote
05-23-10, 08:30 AM   #9
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Cool. Thanks a lot, you've been a great help.

Edit: They actually come back sometimes. Oh well.

Last edited by Haleth : 05-23-10 at 10:35 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Border on bag icons


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