Quantcast
Upgrading old addon for BCC Backdrop change. - WoWInterface
Thread Tools Display Modes
05-30-21, 08:13 AM   #1
ramma
A Kobold Labourer
Join Date: Aug 2019
Posts: 1
Upgrading old addon for BCC Backdrop change.

I've been trying to get sRaidFrames working on BCC for a bit now, but not being great at LUA I'm having trouble getting the suggestions in other threads about this working.

Since the addon had an outdated Ace3 version I swapped in the most recent version of that first which seems to have worked fine. Then based on this and some of the posts here, I edited the lines with CreateFrame that I could see how to easily, adding the BackdropTemplateMixin and "BackdropTemplate" part, but I'm still seeing these errors

Code:
Message: Interface\AddOns\sRaidFrames\sRaidFrames.lua:1451: attempt to call method 'SetBackdrop' (a nil value)
Code:
Message: Interface\AddOns\sRaidFrames\sRaidFrames.lua:1705: attempt to call global 'UnitHasVehicleUI' (a nil value)
Curseforge is down so I can't link there for a download of the code. The full initial commit on my github repo is the original code, and the current version has the edits I've made. They're just in the sRaidFrames.lua as the above error implies.

As to not crowd this post with code blocks, here's the code around the first error I'm seeing, but there's more not throwing errors (yet), or ones that I couldn't figure out how to edit looking at examples, so checking the full source is probably best.

This code corresponds to

Lua Code:
  1. [code]
  2. -- Adapts frames created by Secure Headers
  3. function sRaidFrames:CreateUnitFrame(...)
  4.     local f = select("#", ...) > 1 and CreateFrame(...) or select(1, ...)
  5.     --f:EnableMouse(true)
  6.     f:RegisterForClicks("AnyUp")
  7.  
  8.     --f:SetAttribute("allowVehicleTarget", true)
  9.     f:HookScript("OnAttributeChanged", sRaidFrames_OnAttributeChanged)
  10.  
  11.     f:SetScript("OnEnter", function(this)
  12.         if sRaidFrames:QueryTooltipDisplay(sRaidFrames.opt.UnitTooltipMethod) then
  13.             sRaidFrames:UnitTooltip(this)
  14.         end
  15.     end)
  16.     f:SetScript("OnLeave", function(this)
  17.         GameTooltip:Hide()
  18.     end)
  19.  
  20.     f.title = f:CreateFontString(nil, "ARTWORK")
  21.     f.title:SetFontObject(GameFontNormalSmall)
  22.     f.title:SetJustifyH("LEFT")
  23.  
  24.     f.auraFrames = {}
  25.  
  26.     for i = 1, 3 do
  27.         local auraFrame = CreateFrame("Button", nil, f, BackdropTemplateMixin and "BackdropTemplate")
  28.         auraFrame.texture = auraFrame:CreateTexture(nil, "ARTWORK")
  29.         auraFrame.texture:SetAllPoints(auraFrame);
  30.         auraFrame.count = auraFrame:CreateFontString(nil, "OVERLAY")
  31.         auraFrame.count:SetFontObject(GameFontHighlightSmallOutline)
  32.         auraFrame.count:SetJustifyH("CENTER")
  33.         auraFrame.count:SetPoint("CENTER", auraFrame, "CENTER", 0, 0);
  34.         auraFrame:SetScript("OnEnter", function (this)
  35.             if sRaidFrames:QueryTooltipDisplay(sRaidFrames.opt.DebuffTooltipMethod) then
  36.                 GameTooltip:SetOwner(this)
  37.                 GameTooltip:SetUnitAura(this.unitid, this.auraid, this.filter)
  38.             end
  39.         end)
  40.  
  41.         auraFrame:SetScript("OnClick", function (this)
  42.             if IsAltKeyDown() then
  43.                 -- TODO: Blacklist
  44.             end
  45.         end)
  46.  
  47.         auraFrame:SetScript("OnLeave", function(this)
  48.                 GameTooltip:Hide()
  49.         end)
  50.  
  51.         auraFrame:Hide()
  52.  
  53.         local debuffTimer = auraFrame:CreateFontString(nil, "ARTWORK")
  54.         debuffTimer:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
  55.         debuffTimer.fontsize = 12
  56.         debuffTimer:SetTextColor(0.7, 0.7, 0)
  57.         debuffTimer:ClearAllPoints()
  58.         debuffTimer:SetAllPoints(auraFrame)
  59.  
  60.         tinsert(f.auraFrames, auraFrame)
  61.         f["aura"..i] = auraFrame
  62.     end
  63.    
  64.     local texture = Media:Fetch("statusbar", self.opt.Texture)
  65.  
  66.     f.hpbar = CreateFrame("StatusBar", nil, f, BackdropTemplateMixin and "BackdropTemplate")
  67.     f.hpbar:SetStatusBarTexture(texture)
  68.     f.hpbar:SetMinMaxValues(0,100)
  69.     f.hpbar:SetValue(0)
  70.  
  71.     f.hpbar.text = f.hpbar:CreateFontString(nil, "ARTWORK")
  72.     f.hpbar.text:SetFontObject(GameFontHighlightSmall)
  73.     f.hpbar.text:SetJustifyH("CENTER")
  74.  
  75.     local color = self.opt.HealthTextColor
  76.     f.hpbar.text:SetTextColor(color.r, color.g, color.b, color.a)
  77.  
  78.     f.mpbar = CreateFrame("StatusBar", nil, f, BackdropTemplateMixin and "BackdropTemplate")
  79.     f.mpbar:SetStatusBarTexture(texture)
  80.     f.mpbar:SetMinMaxValues(0,100)
  81.     f.mpbar:SetValue(0)
  82.  
  83.     f.statustext = f.mpbar:CreateFontString(nil, "ARTWORK")
  84.     f.statustext:SetFontObject(GameFontHighlightSmall)
  85.     f.statustext:SetJustifyH("CENTER")
  86.  
  87.     --f:ClearAllPoints()
  88.     self:SetWHP(f, 80, 34)
  89.     self:SetWHP(f.title, f:GetWidth() - 6, 13, "TOPLEFT", f, "TOPLEFT",  3, -3)
  90.     self:SetWHP(f.aura1, 13, 13, "TOPRIGHT", f, "TOPRIGHT", -3, -3)
  91.     self:SetWHP(f.aura2, 13, 13, "RIGHT", f.aura1, "LEFT", 0, 0)
  92.     self:SetWHP(f.aura3, 13, 13, "RIGHT", f.aura2, "LEFT", 0, 0)
  93.     self:SetWHP(f.hpbar, f.title:GetWidth(), 12, "TOPLEFT", f.title, "BOTTOMLEFT", 0, 0)
  94.     self:SetWHP(f.mpbar, f.title:GetWidth(), 4, "TOPLEFT", f.hpbar, "BOTTOMLEFT", 0, 0)
  95.  
  96.     self:SetWHP(f.hpbar.text, f.hpbar:GetWidth(), f.hpbar:GetHeight(), "CENTER", f.hpbar, "CENTER", 0, 0)
  97.     self:SetWHP(f.statustext, f.mpbar:GetWidth(), f.mpbar:GetHeight(), "CENTER", f.mpbar, "CENTER", 0, 0)
  98.  
  99.     f:SetBackdrop({
  100.         bgFile = Media:Fetch("background", sRaidFrames.opt.BackgroundTexture),
  101.         tile = true,
  102.         tileSize = 8,
  103.         edgeFile = Media:Fetch("border", sRaidFrames.opt.BorderTexture),
  104.         edgeSize = 8,
  105.         insets = { left = 2, right = 2, top = 2, bottom = 2 }
  106.     })
  107.                            
  108.     f:SetBackdropColor(self.opt.BackgroundColor.r, self.opt.BackgroundColor.g, self.opt.BackgroundColor.b, self.opt.BackgroundColor.a)
  109.     f:SetBackdropBorderColor(self.opt.BorderColor.r, self.opt.BorderColor.g, self.opt.BorderColor.b, self.opt.BorderColor.a)
  110.     f.hpbar.text:SetTextColor(self.opt.HealthTextColor.r, self.opt.HealthTextColor.g, self.opt.HealthTextColor.b, self.opt.HealthTextColor.a)
  111.  
  112.     --f:Hide();
  113.  
  114.     tinsert(self.frames, f)
  115.     ShouldUpdateFrameCache = true
  116.  
  117.     ClickCastFrames = ClickCastFrames or {}
  118.     ClickCastFrames[f] = true
  119. end[/code]

It's line 98 in that which causes the first error, but there are more examples in the full code.

Any advice or pointing in the right direction is greatly appreciated. Thanks!
  Reply With Quote
05-30-21, 09:22 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,418
In every version of the game up to Classic Vanilla, frames were created with a backdrop by default. Since then (Shadowlands/Classic TBC), backdrops are optional and you have to "add" them to your frame(s) if you want one.

This is done by either inheriting the BackdropTemplate when the frame is created or via a Mixin after the frame is created. The template/mixin adds all the regions and methods originaly gained by default like :SetBackdrop(), :SetBackdropColor() etc.

The following allows your code to be use in all versions by detecting if the mixin or one of the backdrop methods exist.

To add on during creation:

Code:
local = CreateFrame("Frame", "name", parent, BackdropTemplateMixin and "BackdropTemplate")
if BackdropTemplateMixin exists then you're playing a version of the game where backdrops are optional so add in the template.

After creation.
Code:
if not frame.SetBackdrop then
    Mixin(frame, BackdropTemplateMixin)
end
Apply the backdrop regions and methods to a frame we want to apply a backdrop too that hasn't already been set up for it ei. do this before frame:SetBackdrop(...).
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-30-21 at 01:42 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Upgrading old addon for BCC Backdrop change.

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