1. #1

    Struggling with textures during addon creation

    Greetings everyone,

    the past few days I've been keeping myself busy with revamping my addon's UI. I want to expand my addon with a scrollframe, so I found this very helpful post (which I am apparently not allowed to link) that I have based my code on. Currently this looks like a blatant copy/paste in my code, but only after it is fully working will I integrate it cleanly into the rest of the code. I do want this list to look nice, of course, so I started looking around for nice button templates that I could use. After some more research, I found a list of templates and tried all options, and I liked "OptionsListButtonTemplate" the most. I tested it on a button outside of the FauxScrollFrame, and everything worked just fine. However, when adding it to the FauxScrollFrame, my game freezes for about 0.2 seconds when hovering over the button. This is only when hovering over the button - scrolling through the list while still hovering over the same button does not cause any lag whatsoever. If I change to a different template, this lag no longer occurs. I have absolutely no idea what is causing this seemingly absurd behaviour, so if anyone could explain this, it would be greatly appreciated.

    After having hit this blockade, I decided to try it differently: I wanted to create the button myself from scratch (no templates), and simply use the same texture as the template when hovering over the button. This should, in theory, completely bypass the issue of lag. After some messing about with some print()s, I discovered that the texture URI was "Inferface\\QuestFrame\\UI-QuestLogTitleHighlight". However, when I try to create a texture with that resource location, it cannot find said resource. I have tried all sorts of different URI notations (single backslash, forward slash, etc.), but none helped. I have tried extracting the game's artwork, I have tried pasting the file into my addon folder (and of course changing the resource path), I have even found a GitHub repository where the file was uploaded in a different extension, but to no avail. All of these attempts had the same result: a neon-green texture, indicating that the texture could not be found. Even worse than that, when I attempt to use SetTexture(r,g,b,a), it doesn't work either! I am, once again, at a loss and have no idea what to do at this point. I'm probably overlooking something extremely obvious that will make me facepalm as soon as I see it, but could someone please help me out? Cheers!

    This is the code in question:
    Code:
    	-- Test ScrollFrame
    	local NUM_BUTTONS = 4
    	local BUTTON_HEIGHT = 20
    
    	local list = {"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9"} -- put contents of the scroll frame here, for example item names
    	local buttons = {}
    
    	local function update(self)
    		local numItems = #list
    		FauxScrollFrame_Update(self, numItems, NUM_BUTTONS, BUTTON_HEIGHT)
    		local offset = FauxScrollFrame_GetOffset(self)
    		for line = 1, NUM_BUTTONS do
    			local lineplusoffset = line + offset
    			local button = buttons[line]
    			if lineplusoffset > numItems then
    				button:Hide()
    			else
    				button:SetText(list[lineplusoffset])
    				button:Show()
    			end
    		end
    	end
    
    	local scrollFrame = CreateFrame("ScrollFrame", "MyFirstNotReallyScrollFrame", panel, "FauxScrollFrameTemplate")
    	scrollFrame:SetPoint("TOPLEFT", 20, -460)
    	scrollFrame:SetSize(50,BUTTON_HEIGHT*NUM_BUTTONS)
    	scrollFrame:SetScript("OnVerticalScroll", function(self, offset)
    		FauxScrollFrame_OnVerticalScroll(self, offset, BUTTON_HEIGHT, update)
    	end)
    
    	for i = 1, NUM_BUTTONS do
    		local button = CreateFrame("Button", nil, panel)
    		--, "OptionsListButtonTemplate"
    		button:SetNormalFontObject("GameFontNormalSmall")
    		--local texture = button:CreateTexture(nil, "ARTWORK")
    		--texture:SetTexture(1,1,1,1)
    		--texture:SetAllPoints(button)
    		--texture:SetSize(20,BUTTON_HEIGHT)
    		--button:SetHighlightTexture(texture)
    		button:SetHighlightTexture("interface/addons/ClutterCleaner/UI-QuestLogTitleHighlight.PNG")
    		if i == 1 then
    			button:SetPoint("TOP", scrollFrame)
    		else
    			button:SetPoint("TOP", buttons[i - 1], "BOTTOM")
    		end
    		button:SetSize(50, BUTTON_HEIGHT)
    		buttons[i] = button
    	end
    	
    	update(scrollFrame)
    As stated, this code is a work in progress and will be more integrated into the code as soon as it works. Apologies for the blatant copy-pasting in this part of the code.

    P.S.: Any and all feedback on the rest of my code is greatly appreciated as well. I am not allowed to post any links, but it can be found on GitHub under the author name RevelatedDestiny, with the addon name ClutterCleaner.

  2. #2
    Try:

    Code:
    button:SetHighlightTexture([[Interface\QUESTFRAME\UI-QuestLogTitleHighlight.blp]])
    Note that textures are .blp files. I prefer the string syntax of [[ ]] when using file paths.

  3. #3
    High Overlord Ironi's Avatar
    15+ Year Old Account
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    114
    in your current code you are trying to use png file (doesn't work), and on your previus try ("Inferface\\QuestFrame\\UI-QuestLogTitleHighlight") you have a typo, it should be "Interface\\QuestFrame\\UI-QuestLogTitleHighlight", works just fine with that
    Abandon the search for Truth; settle for a good fantasy.
    iKeystones, iLFRDescription, iEncounterEventTracker

  4. #4
    Quote Originally Posted by Flexie View Post
    Try:

    Code:
    button:SetHighlightTexture([[Interface\QUESTFRAME\UI-QuestLogTitleHighlight.blp]])
    Note that textures are .blp files. I prefer the string syntax of [[ ]] when using file paths.
    I did know that indeed, but seeing as that didn't work, I tried using a .png instead (from the GitHub repository) as a last resort. Thank you for the advice regarding the syntax of double square brackets, it's a helpful tip!

    Quote Originally Posted by Ironi View Post
    in your current code you are trying to use png file (doesn't work), and on your previus try ("Inferface\\QuestFrame\\UI-QuestLogTitleHighlight") you have a typo, it should be "Interface\\QuestFrame\\UI-QuestLogTitleHighlight", works just fine with that
    I feel like the dumbest person in the world right now, because that was indeed the issue. How on earth did I miss that...? I'm terribly embarrassed, thank you for spotting that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •