Thread Tools Display Modes
10-19-16, 05:48 AM   #1
Aadä
A Murloc Raider
Join Date: Oct 2016
Posts: 7
Adding a new tab / General add on questions

Hi,
sorry to create a topic for this but I really could not find any documentation on how to do that.
I have basic knowledge on php/html/sql, noob knowledge on javascript/css, no knowledge on xml, none either on lua but successfully custom some add ons as needed.

I'd like to add a tab in the collection frame, through an add on I would do, for my own needs first, might release it if I find it useful and if I actually do it.

I thought I could find, somewhere, the actual UI code that defines the other tabs, the Blizzard ones, Mount and Wardrobe for instance, and that I could actually copy paste the exact same tabs, and edit it as needed.
1)is it possible ?

2)Where exactly can I find this code ? Also should this be stored in my add on in a .lua file, or should it be a .xml file ?

Lastly, if I need to use the same look as the other tabs, I should obviously use the same backgrounds for instance, and those backgrounds are located somewhere, I guess you should find the right name and call that name in the code.
3)Where are they ? I extracted BlizzardInterfaceArt and BlizzardInterfaceCode, but I'm not sure what I'm supposed to do with all that mess of folders and files...furthermore the base Blizzard UI have to be somewhere so I really don't get why some guides tell to extract those folders.

can anyone help me understanding how it should be done properly ?

thanks

Last edited by Aadä : 10-19-16 at 05:52 AM.
  Reply With Quote
10-19-16, 10:31 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Sure, there should not be any problems doing this. When tampering with the default UI you have to be careful not to taint sensitive stuff, but I don't know if the collection UI is in the danger zone.

You can find the collection UI source in the Blizzard_Collections folder in your extracted BlizzardInterfaceCode. Everything in that folder is exactly what the default UI is.

XML is used for structure (well, technically you could use OnLoad scripts to do everything), while Lua is used for functionality. You can, however, use Lua for structure as well, and most people do due to the excessive verbosity of XML.

There will be templates for the actual tabs, so you don't have to find all the right textures and stuff manually.

First try to find the template that's used for the collection tabs (look in the previously mentioned folder), check how they're created and positioned, and look up their OnClick script to see what happens when you click on them, then try to copy that and replace stuff with your own.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-19-16, 01:18 PM   #3
Aadä
A Murloc Raider
Join Date: Oct 2016
Posts: 7
Thanks, found the source code.
What does that mean, danger zone ? What risks ? I always thought add ons were safe to use.

I found Blizzard_Collections.lua, in it there is

Code:
elseif (selected == 4 ) then
CollectionsJournalTitleText:SetText(HEIRLOOMS);
and I suppose I'll add
Code:
elseif (selected == 5 ) then
CollectionsJournalTitleText:SetText(MYTAB);
but how to actually edit Blizzard's UI in a 3rd party add on, meaning, the codes are not really connected ? Blizzard UI is somewhere, while my code will be in my add on folder; still can't find anything in the guides.
  Reply With Quote
10-19-16, 01:44 PM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Yes, they are safe. Don't worry. Tainting refers to addon code affecting the default UI code, which may break things in your UI. For example if you try to do stuff with your unit frames you may end up tainting them so that you can't click them to target. This only concerns protected actions, which essentially means spell casting and targeting. Tainting may seem rather complex as it can spread a long way to an area you thought completely unrelated. Sometimes it is easy to avoid, but for now it's probably easier if you don't worry about it until you notice that something isn't working.

So to "edit" the default UI you have a few choices. You're not editing as in replacing the Blizzard_Collections.lua file, instead you need to redefine the code in your addon. In this case you would probably want to replace the function that you found that code in.

So make a new CollectionsJournal_UpdateSelectedTab function in your addon, copy the original body, and edit as you like. You might need to do it differently ultimately, but you can try this out for starters.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-19-16, 01:59 PM   #5
Aadä
A Murloc Raider
Join Date: Oct 2016
Posts: 7
alright, I'll try. thanks again.

as for the "risks", anyway, it can ONLY be client side right ? no risk to edit a value server side that you could have trouble reverting ? (not counting the options var since there is a button to set all server side vars of an account to default)
  Reply With Quote
10-19-16, 02:22 PM   #6
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Yes. It only affects the actual UI. If something breaks, just undo the last thing you changed in the addon or disable the addon, then reload UI and everything will be fine again! There's no real harm in things breaking either, though. If it doesn't bother you, you may proceed if you wish, but that would probably not be a good idea. If anything, chances are it will bother someone else, should you choose to release the addon.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
11-16-16, 06:56 PM   #7
Aadä
A Murloc Raider
Join Date: Oct 2016
Posts: 7
Hi, been busy, but tried your solution to make a new CollectionsJournal_UpdateSelectedTab function in my lua file, including that file in the .toc register, and it doesn't do anything at all; I could write anything in the CollectionsJournal_UpdateSelectedTab function, add tabs, change names, it can trigger errors, but nothing happens on the actual tabs, tried to change order, to add another tab, nothing happening.

Is there another way to add a tab that we could entirely edit, based on Blizzard base template ?

thanks : )
  Reply With Quote
11-17-16, 12:22 PM   #8
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Your function is probably getting overwritten by the default collections addon, considering that addon is loaded on demand. If you want to overwrite a function that doesn't exist yet, you need to declare a required dependency in your TOC file first. You want your addon to be loaded after Blizzard_Collections:
Lua Code:
  1. ## RequiredDeps: Blizzard_Collections

I should also mention that generally speaking, replacing official code instead of hooking it is dangerous territory. You can easily spread taint this way, because as soon as your code changes a value on something that is then traced in the execution path to a secure action, you'll get the big ugly blocked action popup.
__________________

Last edited by MunkDev : 11-17-16 at 12:32 PM.
  Reply With Quote
11-17-16, 01:24 PM   #9
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,308
Not sure if RequiredDeps is the right tag to use when the target is a LoD addon. You should use LoadWith instead.

Code:
## LoadOnDemand: 1
## LoadWith: Blizzard_Collections


Also, the specific way CollectionsJournal_UpdateSelectedTab() is written, you don't need to replace it. You can secure hook it and add your own code to show your own tab.

Here's an example:
Lua Code:
  1. local TabName="MyNewTab";
  2.  
  3. local TabID=CollectionsJournal.numTabs+1;
  4. local Tab=CreateFrame("Button","$parentTab"..TabID,CollectionsJournal,"CollectionsJournalTab",TabID);
  5. PanelTemplates_SetNumTabs(CollectionsJournal,TabID);
  6. Tab:SetPoint("LEFT","$parentTab"..(TabID-1),"RIGHT",-16,0);
  7. Tab:SetText(TabName);
  8.  
  9. local Panel=CreateFrame("Frame",nil,CollectionsJournal);
  10. Panel:SetAllPoints(CollectionsJournal);
  11.  
  12. hooksecurefunc("CollectionsJournal_UpdateSelectedTab",function(self)
  13.     local selected=PanelTemplates_GetSelectedTab(self);
  14.     if selected==TabID then CollectionsJournalTitleText:SetText(TabName); end
  15.     Panel:SetShown(selected==TabID);
  16. end);

Panel is the frame you'll want to build your UI on and it also plays nice with any other addon that wants to create their own tab on the CollectionsJournal.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-17-16 at 01:45 PM.
  Reply With Quote
11-17-16, 01:38 PM   #10
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Originally Posted by SDPhantom View Post
Not sure if RequiredDeps is the right tag to use when the target is a LoD addon. You should use LoadWith instead.
You are correct.
__________________
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Adding a new tab / General add on questions

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