How do I make an Addon change the behavior of another one? - WoWInterface
Thread Tools Display Modes
07-14-18, 11:31 AM   #1
An Aku'mai Servant
Join Date: Oct 2016
Posts: 32
How do I make an Addon change the behavior of another one?

I want to make an addon that makes Details use a different font so I don't have to replace the font file every time the addon is updated

I know that Skinner was written to change how other addons look, so I know its kinda possible to do it

However, the only time I see specific fonts being mentioned is in these lines:

Lua Code:
  1. _detalhes.empty_function = function() end
  2.     _detalhes.empty_table = {}
  4.     --> register textures and fonts for shared media
  5.         local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
  6.         --default bars
  7.         SharedMedia:Register ("statusbar", "Details D'ictum", [[Interface\AddOns\Details\images\bar4]])
  8.         SharedMedia:Register ("statusbar", "Details Vidro", [[Interface\AddOns\Details\images\bar4_vidro]])
  9.         SharedMedia:Register ("statusbar", "Details D'ictum (reverse)", [[Interface\AddOns\Details\images\bar4_reverse]])
  10.         --flat bars
  11.         SharedMedia:Register ("statusbar", "Details Serenity", [[Interface\AddOns\Details\images\bar_serenity]])
  12.         SharedMedia:Register ("statusbar", "BantoBar", [[Interface\AddOns\Details\images\BantoBar]])
  13.         SharedMedia:Register ("statusbar", "Skyline", [[Interface\AddOns\Details\images\bar_skyline]])
  14.         SharedMedia:Register ("statusbar", "WorldState Score", [[Interface\WorldStateFrame\WORLDSTATEFINALSCORE-HIGHLIGHT]])
  15.         SharedMedia:Register ("statusbar", "DGround", [[Interface\AddOns\Details\images\bar_background]])
  17.         --window bg and bar border
  18.         SharedMedia:Register ("background", "Details Ground", [[Interface\AddOns\Details\images\background]])
  19.         SharedMedia:Register ("border", "Details BarBorder 1", [[Interface\AddOns\Details\images\border_1]])
  20.         SharedMedia:Register ("border", "Details BarBorder 2", [[Interface\AddOns\Details\images\border_2]])
  21.         SharedMedia:Register ("border", "Details BarBorder 3", [[Interface\AddOns\Details\images\border_3]])
  22.         SharedMedia:Register ("border", "1 Pixel", [[Interface\Buttons\WHITE8X8]])
  23.         --misc fonts
  24.         SharedMedia:Register ("font", "Oswald", [[Interface\Addons\Details\fonts\Oswald-Regular.otf]])
  25.         SharedMedia:Register ("font", "Nueva Std Cond", [[Interface\Addons\Details\fonts\NuevaStd-Cond.otf]])
  26.         SharedMedia:Register ("font", "Accidental Presidency", [[Interface\Addons\Details\fonts\Accidental Presidency.ttf]])
  27.         SharedMedia:Register ("font", "TrashHand", [[Interface\Addons\Details\fonts\TrashHand.TTF]])
  28.         SharedMedia:Register ("font", "Harry P", [[Interface\Addons\Details\fonts\HARRYP__.TTF]])
  29.         SharedMedia:Register ("font", "FORCED SQUARE", [[Interface\Addons\Details\fonts\FORCED SQUARE.ttf]])
  31.         SharedMedia:Register ("sound", "d_gun1", [[Interface\Addons\Details\sounds\sound_gun2.ogg]])
  32.         SharedMedia:Register ("sound", "d_gun2", [[Interface\Addons\Details\sounds\sound_gun3.ogg]])
  33.         SharedMedia:Register ("sound", "d_jedi1", [[Interface\Addons\Details\sounds\sound_jedi1.ogg]])
  34.         SharedMedia:Register ("sound", "d_whip1", [[Interface\Addons\Details\sounds\sound_whip1.ogg]])

I just wanted an addon that added the following line:

SharedMedia:Register ("font", "Proza Regular", [[Interface\Addons\NewAddon\fonts\headlines.TTF]])

So I wouldn't have to manually make changes to the fonts every time Details is updated

Another problem I'm having is that the line I pasted just above isn't working. Proza Regular doesn't show up in the font list, and my usual solution is replacing one of the font files by it. Shitty, I know.
  Reply With Quote
07-14-18, 11:39 AM   #2
Fishing Trainer
Seerah's Avatar
WoWInterface Super Mod
Join Date: Oct 2006
Posts: 10,757
Download the SharedMedia addon and read the "INSTRUCTIONS for MyMedia" file inside.
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-14-18, 12:51 PM   #3
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
Your line isn't working because your addon won't know what "SharedMedia" is unless you declare it. If you had lua errors enabled, it would give you an error telling you that you "attempted to use SharedMedia (a nil value)" or something like that (displaying lua errors may be disabled by default with no option given to enable them in the UI, thanks Blizzard.)

lua Code:
  1. local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
  2. SharedMedia:Register ("font", "Proza Regular", [[Interface\Addons\NewAddon\fonts\headlines.TTF]])

This should work as long as your addon is loaded after another addon which has LibStub and LibSharedMedia included, but if you want to be clever you could do it like this (as per SharedMedia_NoAsianFonts):

lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("ADDON_LOADED")
  3. f:SetScript("OnEvent", function()
  4.     local LSM = LibStub and LibStub("LibSharedMedia-3.0", true)
  5.     if not LSM then return end
  7.     f:UnregisterAllEvents()
  8.     f:SetScript("OnEvent", nil)
  10.     LSM:Register("font", "Proza Regular", [[Interface\Addons\NewAddon\fonts\headlines.TTF]])
  11. end)

This is more robust and should work regardless of the order in which addons are loaded. Or at least it works for me -shrugs-

Last edited by Ammako : 07-14-18 at 01:01 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » How do I make an Addon change the behavior of another one?

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