WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   PTR API and Graphics Changes (https://www.wowinterface.com/forums/forumdisplay.php?f=175)
-   -   SetBackdropBorderColor removed in 9.0? (https://www.wowinterface.com/forums/showthread.php?t=58109)

Zax 07-19-20 08:43 AM

SetBackdropBorderColor removed in 9.0?
 
Hello,
While testing one of my addons on the PTR server, I got this error:
Code:

attempt to call method 'SetBackdropBorderColor' (a nil value)
It's in a frame script, from an XML document:
Code:

                <Scripts>
                        <OnLoad>
                                self.SetText=function(self,arg)
                                        self:SetBackdropBorderColor(0.5,0.5,0.5);
                                        self:SetBackdropColor(0.3,0.3,0.3,0.5);
                                end;
                        </OnLoad>
                </Scripts>

SetBackdropBorderColor is removed in Shadowlands? Is there an equivalent?

Thanks.

Rilgamon 07-19-20 08:48 AM

Might be related to this ... https://us.forums.blizzard.com/en/wo...beta/586355/11

"One of the major changes in 9.0 is a change to SetBackdrop. The TL/DR, on live, 100% of frames support backdrops, whether they are used or not. 1000s of frames between every addon and default UI, even frames that never see such as event frames have backdrops. UI team realized this is a serious performance issue. so effective in 9.0, no frames have backdrops unless the addon imports/inherits the backdrop template.
this means addons that aren’t importing them now throw nil errors with method “Setbackdrop”. This issue affects a large number of addons."

Zax 07-19-20 09:42 AM

Thank you very much.

sezz 07-19-20 01:27 PM

Quote:

Originally Posted by Zax (Post 336409)
testing one of my addons on the PTR server

PTR is on 9.x or do you mean Beta?

Xrystal 07-19-20 04:14 PM

Quote:

Originally Posted by sezz (Post 336413)
PTR is on 9.x or do you mean Beta?


Retail PTR is showing as 8.3.7 to me .. so I assume they are talking about the Beta which has the Backdrop changes in place.

Zax 07-19-20 11:53 PM

Sorry, I'm talking about the beta (9.x).

myrroddin 07-20-20 05:56 PM

How does one import or inherit the SetBackdrop template? Preferably in Lua. I dislike XML.

Fizzlemizz 07-20-20 06:21 PM

Code:

local f = CreateFrame("Frame", nil, self, BackdropTemplateMixin and "BackdropTemplate")
Testing for BackdropTemplateMixin is to differentiate between 9 and pre 9.

Then use as normal:
Code:

f:SetBackdrop({ ... })
This is from people that are in the Beta.

myrroddin 07-20-20 07:11 PM

Cool, thanks. Do the mixin and template exist on 8.3.x? I'm guessing no.

Xrystal 07-20-20 07:28 PM

Quote:

Originally Posted by myrroddin (Post 336421)
Cool, thanks. Do the mixin and template exist on 8.3.x? I'm guessing no.

Nope new to 9.0.1

https://www.townlong-yak.com/framexml/beta
Backdrop.lua / Backdrop.xml

Fizzlemizz 07-20-20 08:22 PM

Using:
Code:

BackdropTemplateMixin and "BackdropTemplate"
Allows the same code to exist/run in both 8.x and 9+ versions ie. if the mixin doesn't exist, don't use the template and if it does, magic it in.

Zax 07-28-20 09:03 AM

I don't understand how could I apply alpha to a texture/background using this new syntax:
Code:

f.Backdrop = _G[name.."Backdrop"] or CreateFrame("Frame", name.."Backdrop", f, "BackdropTemplate")
f.Backdrop:SetAllPoints()
f.Backdrop.backdropInfo = {
        bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark",
        edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
        tile = true,
        tileSize = 32,
        edgeSize = 32,
        insets = { left = 11, right = 12, top = 12, bottom = 9, },
}
f.Backdrop:ApplyBackdrop()

Thank you.

Fizzlemizz 07-28-20 10:18 AM

Same as normal. The Mixin that is applied when using the template applies all the pre 9x backdrop methods to the frame. Nothing really changes once you've inherited the template.

Lua Code:
  1. if not f.Backdrop then
  2.     f.Backdrop = CreateFrame("Frame", name.."Backdrop", f, "BackdropTemplate")
  3.     f.Backdrop:SetAllPoints()
  4.     f.Backdrop.backdropInfo = {
  5.         bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark",
  6.         edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
  7.         tile = true,
  8.         tileSize = 32,
  9.         edgeSize = 32,
  10.         insets = { left = 11, right = 12, top = 12, bottom = 9, },
  11.     }
  12.     f.Backdrop:SetBackdrop(f.Backdrop.backdropInfo)
  13.     f.Backdrop:SetBackdropColor(r, g, b, a)
  14.     f.Backdrop:SetBackdropBorderColor(r, g, b, a)
  15. end
f could just have easily inherited the backdrop template negating the need for a separate frame unless the backdrop is applied after the frame is created eg. something like KGPanels where a backdrop can be added/removed at runtime.

Example

Zax 07-28-20 12:26 PM

Quote:

Originally Posted by Fizzlemizz (Post 336472)
Same as normal. The Mixin that is applied when using the template applies all the pre 9x backdrop methods to the frame. Nothing really changes once you've inherited the template.

Nice, I didn't understand this point.

Thank you very much :)

Zax 08-02-20 04:43 AM

Quote:

Originally Posted by Fizzlemizz (Post 336419)
Code:

local f = CreateFrame("Frame", nil, self, BackdropTemplateMixin and "BackdropTemplate")
Testing for BackdropTemplateMixin is to differentiate between 9 and pre 9.

And what about Classic? Is Blizzard planning to change SetBackdrop() in Classic also?

As I am actually in the process of update my addons to 9.x, I would like some of them to work in Classic.
The problem is many of my frames are defined in XML, and of course inherits="BackdropTemplate" raises an error in Classic.

So, if Classic will not use BackdropTemplate, is there a way to dynamically modify an inheritance defined in XML?

Thanks.

Fizzlemizz 08-02-20 10:08 AM

Test and add a backdrop frame in the OnLoad script:

This adds an extra frame for the backdrop rather than just inheriting the template.
Code:

<Frame>
  <Scripts>
    <OnLoad>
            if BackdropTemplateMixin then
                self.background = CreateFrame("Frame", nil, self, "BackdropTemplate")
                self.background:SetAllPoints()
                self.background:SetBackdrop({ ... })
                      self.background:SetFrameLevel(self:GetFrameLevel())
              end
    </OnLoad>
  </Scripts>
</Frame>

Blizzard are not concerned with making addons compatible between Classic and Retail. Addon authors have to decide how far they are willing to go if that's what they want to do.

Zax 08-03-20 12:54 AM

Nice trick, thank you :)

Fizzlemizz 08-03-20 01:10 AM

Once again, not mine. I don't have beta access.

This would need to add some "pass-through" methods to the parent frame if you are modifying the backdrop during play and want to maintain the single code base for retail and classic.

p3lim 08-04-20 08:55 AM

Adding this since it's probably useful:

If you want to add a backdrop to a frame you don't control the creation of (e.g. from another addon), you can mix in the mixin:
Lua Code:
  1. Mixin(yourFrame, BackdropTemplateMixin)

Then you should be able to use :SetBackdrop and the likes on that frame.

Zax 08-04-20 11:36 AM

Quote:

Originally Posted by p3lim (Post 336518)
Lua Code:
  1. Mixin(yourFrame, BackdropTemplateMixin)

Great!

Now I just have to use this code on OnLoad of my old frames, without inherits="BackdropTemplate" and it works on both 8.x and 9.0 versions:
Code:

---------------------------------- testing WoW version
local wowversion, wowbuild, wowdate, wowtocversion = GetBuildInfo()
if (wowtocversion > 90000) then Mixin(self, BackdropTemplateMixin)
---------------------------------- same code for 8.x and 9.x
self:SetBackdrop({
        bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
        edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
        tile = true,
        tileSize = 32,
        edgeSize = 32,
        insets = {left = 12, right = 12, top = 12, bottom = 11},
})
----------------------------------


liquidbase 08-06-20 02:46 AM

Quote:

Originally Posted by p3lim (Post 336518)
Lua Code:
  1. Mixin(yourFrame, BackdropTemplateMixin)

One question about this, can I also adapt it so that I have a table with all frames where I needed the backdrop template and add it here automatically with a for-loop?

Something like that?
Lua Code:
  1. AddOn.BackdropFrames = {
  2.     "frame1",
  3.     "frame2",
  4. }
  5. for i = 1, getn(AddOn.BackdropFrames) do
  6.     local BackdropFrames = AddOn.BackdropFrames[i]
  7.     if BackdropFrames then
  8.         Mixin(BackdropFrames, BackdropTemplateMixin)
  9.     end
  10. end

Fizzlemizz 08-06-20 11:45 AM

It would be
Code:

local BackdropFrames = _G[AddOn.BackdropFrames[i]]
unless the table stored the reference to the created frame rather than its name.

It would depend on whether the template (common method for adding a mixin) adds any frame elements required by the mixin. If all it's doing is applying a bunch of methods to an already existing (or created in the process) frame then that would work. Or you could add the template frame elements "manually" when you apply the mixin if you weren't responsible for creating the frame(s).

p3lim's post seems to indicate, for backdrops, that it's just applying the mixin methods.

You just need to make sure you've applied the mixin before any of your code calls any of the methods on the frames.

liquidbase 08-07-20 12:53 AM

Thanks for the explanation.
In my UI I work with a set template function that controls the appearance of the frames. That's where I've added the mixin. Works well so far and so far there were no problems when testing.

Drudatz 08-17-20 04:49 AM

Can someone explain the SetBackdrop-fuckup for a dummie like me and how to fix LibQTip (https://www.wowace.com/projects/libqtip-1-0/) as an example?

I tried replacing line 364
tooltip = CreateFrame("Frame", nil, UIParent)
with
tooltip = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")

and as this didnt worked I added ', "BackdropTemplate"' to every CreateFrame which doesnt work either.

What am I doing wrong?

TIA!

Rilgamon 08-17-20 07:56 AM

I've tested it with a simple tooltip and it works with only the line 364 changed.
Make sure you load your altered version and no other older version is available.

Edit: My test was too simple. Had no release implemented. There is more to it.
Edit2: Function in Line 179 (only clear backdrop if the frame has it implemented)

Lua Code:
  1. local function ReleaseFrame(frame)
  2.     frame:Hide()
  3.     frame:SetParent(nil)
  4.     frame:ClearAllPoints()
  5.     if(frame.SetBackdrop) then
  6.         frame:SetBackdrop(nil)
  7.     end
  8.     ClearFrameScripts(frame)
  9.  
  10.     tinsert(frameHeap, frame)
  11.     --[===[@debug@
  12.     usedFrames = usedFrames - 1
  13.     --@end-debug@]===]
  14. end

Line 226

Lua Code:
  1. cell = setmetatable(CreateFrame("Frame", nil, UIParent, "BackdropTemplate"), self.cellMetatable)

Fizzlemizz 08-17-20 08:45 AM

There a several places the library would need to be updated depending on which parts you are using.

Things like around line 517 in InitializeTooltip(tooltip, key)
Code:

local backdrop = GameTooltip:GetBackdrop()
would be followed by
Code:

if not tooltip.SetBackdrop then
        Mixin(tooltip, BackdropTemplateMixin)
end
tooltip:SetBackdrop(backdrop)


Drudatz 08-17-20 12:00 PM

@Rilgamon and @Fizzlemizz
thank you both very much :banana:

@Fizzlemizz:
yes I noticed and did so following your example
end result here: https://pastebin.com/DxRyHy9C

Fizzlemizz 08-17-20 01:19 PM

A side note for future travelers, applying the Mixin directly would primarily be used for frames you didn't create but wanted to set a backdrop on (as p3lim pointed out earlier in the thread).

In the library, because lines are created by it, instead of applying the Mixin at
Code:

tipPrototype:AddSeparator(height, r, g, b, a)
you could inherit the template where the line is created

Code:

local function AcquireFrame(parent)
        local frame = tremove(frameHeap) or CreateFrame("Frame", nil, nil, "BackdropTemplate")

Both methods work but the second might save some code if after frame creation, you branch into different functions that also apply backdrops but possibly using different styles etc. (the template does the job of applying the mixin without extra lines of code)

Drudatz 09-02-20 08:48 PM

Sorry for another dumb question but how do I get the BackdropTemplate when the frame is created in an xml?

Code:

<Frame name="PTFrameTemplate" frameStrata="LOW" enablemouse="true" movable="true" clampedtoscreen="true" hidden="true" virtual="true" ???="BackdropTemplate">
I need to know what to write in place of the ???.

TIA

Ketho 09-02-20 09:16 PM

Code:

inherits="BackdropTemplate"
https://github.com/Stanzilla/WoWUIBu...es#xml-changes

Alysh 10-15-20 07:13 AM

Sorry if I intrude .. Could someone help me understand how to fix the LUA errors resulting from the "backdrop" on the Stuf Unit Frames addon? (https://www.wowinterface.com/downloa...?id=11182#info)
Thanks a lot..

Xrystal 10-15-20 01:43 PM

Did everyone else get a darkened frame after applying the new backdrop template ?

If you did, where did you find the issue was ?


Edit:
Nevermind, it appears the addition of the backdrops to certain frames on nUI affected the current alpha state visual. Simply changing them from 0.75 to 0.35 allowed the text to display easier.

Spyro 10-15-20 04:21 PM

I have noticed that SetBackdrop() now creates 9 textures instead of the typical 8 (4 edges + 4 borders). I have no idea what the last texture is.

I have noticed this because I use backdrops to create 1px borders on casting bars, and I need to access those textures to change the backdrop's Layer (so it doesn't get covered by the StatusBar filling texture).

MunkDev 10-15-20 05:23 PM

Quote:

Originally Posted by Spyro (Post 337182)
I have noticed that SetBackdrop() now creates 9 textures instead of the typical 8 (4 edges + 4 borders). I have no idea what the last texture is.

8 textures for edges, 9th for background.

Xrystal 10-15-20 05:38 PM

Quote:

Originally Posted by MunkDev (Post 337184)
8 textures for edges, 9th for background.

Maybe the background is the texture messing up some of nUI's click buttons. Thankfully so far thats all that is affected but I wouldn't be surprised if something appears sooner or later.

Zorcan 10-18-20 02:31 AM

When using the addon ItemRack https://www.curseforge.com/wow/addons/itemrack I am getting the following error:

Message: ..\AddOns\ItemRack\ItemRack.lua line 1733:
attempt to call method 'SetBackdropBorderColor' (a nil value)

I tried updating ItemRack.lua but I've had no success whatsoever. Is there some kind soul out there who could take a quick look and see what might possibly have to be changed to get this addon working correctly once more?

Thanks in advance!

---------------------

Never mind, I managed to figure it out myself.

XeeLiao 11-13-20 02:18 PM

Hi,

is there anyway to fix the Backdrop for (https://www.curseforge.com/wow/addon...alui-bossskins)?
Since the 9.0.1 update the Background for Bars and Icons with this DBM skin is gone

jeffy162 11-13-20 04:19 PM

First thing is is your installation of RealUI up to date? The second thing is that addon hasn't been updated since 2016, so, it's probably a bit out of date by now (what with the updates to the game (9.0.1 changedthebackdrop coding so...)).

XeeLiao 11-13-20 04:35 PM

This Addon always ran without RealUI, wich i dont use, also it ran perfectly fine until the 9.0 update, it still works perfect actually, only the background of the bar and icon is missing now

jeffy162 11-13-20 09:47 PM

Quote:

Originally Posted by jeffy162 (Post 337580)
(9.0.1 changedthebackdrop coding so...)).

Like I said ^^^^... I'm sorry that I can't help you with code, but if you search around a little I'm sure you'll find the information. I know there's a thread here for backdrop problems, I just don't know where it is. :o In fact ... this is one of the threads for backdrop problems. DOH!!!

lorce 01-04-24 06:46 AM

Have you successfully resolved the issue with SetBackdropBorderColor in your addon on the PTR server? Also, have you considered exploring the suggestions from the WoW forums, like the changes to SetBackdrop in version 9.0?

Fizzlemizz 01-04-24 09:45 AM

I'm not sure if this is asking an actual question or not.

Backdrops are now optional for frames where they used to be rolled into every frame by default.

A frame can get back all the old backdrop functionality by either inheriting the "BackdropTemplate" when it created or for an existing frame you can do something like
Lua Code:
  1. if not frame.SetBackdrop then
  2.     Mixin(frame, BackdropTemplateMixin)
  3. end
  4. frame:SetBackdrop(...)


All times are GMT -6. The time now is 03:31 PM.

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