WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Carbonite Archive (https://www.wowinterface.com/forums/forumdisplay.php?f=158)
-   -   3rd Party Addon Interface to Carbonite Update? (https://www.wowinterface.com/forums/showthread.php?t=36463)

Zasurus 11-01-10 04:26 PM

3rd Party Addon Interface to Carbonite Update?
 
Hi Carbonite,
I am an AddOn author and make a few AddOn's that add icon's & area's to Carbonite's maps and although there doesn't seem to be an official interface I found an old post a while back with info from you guys on how to interface with Carbonite. Although it didn't work (it looks like the functions have long been forgotten about and are not out of date and useless) it DID point me in the correct direction and I have since managed to as I mentioned earlier add points and even area's to the Carbonite map using its own functions so they all work nice!

The problem is I have had to change a few of the Carbonite's functions to get the desired effect. I do this with hooks and you are likely to know about them due to a badly named file "Fix_ZasCarboniteFixs.lua" it has appeared on the forums with users thinking it was your fault twice now! I have tried to track these down and correct them as soon as they crop up and while I was changing the file name so it didn't lead people to you guys I figured due to the recent increase in development due to Cata you might be willing to do a few TINY code changes so I can get rid of that annoying file! ;-)
I will explain how I am adding stuff to the map first so you can see where my problems are coming from. MAYBE you know a better way! :-)
First to add icons (like waypoints etc) I use two bits of code. The first one sets up the point types etc with Carbonite and that is:

Code:

local icT;
if (Nx) then -- Carbonite exits so setup the icon types for it (Also clears any existing icons)
        ----------------------------------------------------------
        -- Setup the icon types for this addon (also wipes all old
        -- icons from the same addon)
        ----------------------------------------------------------
                local CarbMap=Nx.Map:GeM(1);
                icT = "!"..tostring(self.Name); -- Name of the addon
                local drM = "WP"; -- This specifies it's a waypoint
                local tex = ""; -- This is a texture. Don't know what this is for as it's almost always blank.
                local w = 10; -- This is the Width of the icon
                local h = 10; -- This is the Hight of the icon
                CarbMap:IIT(icT,drM,tex,w,h);
               
                CarbMap:SITA("!WorldExplorer",1); -- Set the Alpha of these points.
                CarbMap:SITAS("!WorldExplorer",0.3); -- Sets the scale these points disapears at.
        ----------------------------------------------------------
end;

This basically checks Carbonite exists and then sets up the types and wipes any points that are already on the map from earlier. I will run this at the start of any function that adds points to the map.

The next section is run for every point I want to add to the map:

Code:

if (Nx and ZoneName) then -- Carbonite exits so add the icons to that as well
        ----------------------------------------------------------
        -- Creates an icon
        ----------------------------------------------------------
                local mapName = ZoneName; -- This is the name of the zone e.g. "Tirisfal Glades"
                local zoneX = CordX * 100; -- This is how from the left to the right of the zone the icon is in %. So if this was 0 it would be the far left if it was 100 it would be far right and if it was 50 it would be half way across
                local zoneY = CordY * 100; -- This is a % of the Hight of the zone (same as the width)
                local texture = Icon.Texture; -- This is the texure that will be used for the icon(Picture)
                local iconNote = SeperatingLine.."\n"..tostring(IconNote).."\n"..SeperatingLine.."\n"..IconNoteEnd; -- This is the note text(the text that pops up when you mouse over the icon)
               
                local map2=Nx.Map:GeM(1);
                local maI=Nx.MNTI1[mapName];
                if maI then
                        local wx,wy=map2:GWP(maI,zoneX,zoneY);
                        local icon = map2:AIP(icT,wx,wy,Colour,texture);
                        map2:SIT(icon, iconNote); -- This sets the note(the text that pops up when you mouse over the icon)
                end;
        ----------------------------------------------------------
end;

Again the first thing it does is checks that Carbonite exists (it will already have added the same icon to the original map...
It then passes in the location of the point, it's texture, colour etc and links it to the "icT" setup at the start of the function...


This works great!... Apart from the Colour :( the colour is passed and stored but I guess as you never sore a need for it you hard coded the colour to white on line 17728 (in Carbonite V4.013).

To get around this I replaced line 17728 (via a really crap hook) with:

Code:

local r,g,b = 1,1,1
if (ico.Col1) then
r,g,b = c2r1(ico.Col1)
end;
f.tex1:SetVertexColor(r,g,b,v.Alp)

As you can see this stores the default of white then if the icon has a colour stored (which was stored earlier with the standard Carbonite code (used for your shapes etc)) it uses that. I can't see a reason this would cause any problems and have been using it this way without any problems for quite some time which is why I added it to my addon's release and have not had one bug report about it (I hope you guys haven't!). If there are no colours specified it will use the original code.


The second problem was with my newest version of my AddOn "WorldExplorer" that now puts shapes on the Carbonite Map. It does this using again two bits of code... the same with SLIGHT changes for shapes!

Code:

local icT_Icons;
if (Nx) then -- Carbonite exits so setup the area types for it (Also clears any existing icons)
        ----------------------------------------------------------
        -- Setup the Area(icon) values for this addon (also wipes all old
        -- icons from the same addon)
        ----------------------------------------------------------
                local CarbMap=Nx.Map:GeM(1);
                icT_Areas = "!"..tostring(self.Name).."_Areas"; -- Name of the addon
                local drM = "ZR"; -- This specifies it's a "World point"
                local tex = ""; -- This is a texture. Don't know what this is for as it's almost always blank.
                local lev = -6; -- This is the frame level this icon should have. (Setting it to -1 seems to put it behind icons)
                CarbMap:IIT(icT_Areas,drM);
               
                CarbMap:SITL(icT_Areas,lev);
                CarbMap:SITAS(icT_Areas,0.3); -- Sets the scale these points disapears at.
        ----------------------------------------------------------
end;

This is the first one and does the setup of the shapes linking to my addon and the second bit:

Code:

if (Nx and LangZoneName) then -- Carbonite exits so add the icons to that as well
        ----------------------------------------------------------
        -- Creates a coloured rectangle
        ----------------------------------------------------------
                do
                        local mapName = LangZoneName; -- This is the name of the zone e.g. "Tirisfal Glades"
                        local zoneX = Left * 100; -- This is how from the left to the right of the zone the icon is in %. So if this was 0 it would be the far left if it was 100 it would be far right and if it was 50 it would be half way across
                        local zoneY = Top * 100; -- This is a % of the Hight of the zone (same as the width)
                        local zoneX2 = Right * 100; -- This is how from the left to the right of the zone the icon is in %. So if this was 0 it would be the far left if it was 100 it would be far right and if it was 50 it would be half way across
                        local zoneY2 = Bottom * 100; -- This is a % of the Hight of the zone (same as the width)
                        local AreaNote2 = AreaNote; -- This is the note text(the text that pops up when you mouse over the icon)
                       
                        local map2=Nx.Map:GeM(1);
                        local maI=Nx.MNTI1[mapName];
                        if maI then
                                local Rectange = map2:AIR(icT_Areas,maI,zoneX,zoneY,zoneX2,zoneY2,Colour)
                                map2:SIT(Rectange, AreaNote2); -- This sets the note(the text that pops up when you mouse over the Rectange)
                        end;
                end;
        ----------------------------------------------------------
end;

This again just adds each shape to the map! It works perfectly! Thanks for making such a versitile addon!


The problem I had is that as the shapes doesn't have a "typ" Carbonite doesn't know what to do with it when you right click on it so defaults to nothing. I just wanted it to pretend the shape isn't there and you can right click "though" it

To do this I changed line 9978 from

Code:

end
to:

Code:

else
map.OMD(map.Frm,but)
end

So basically giving it an else click though... Again I can't see any problems from Carbnoites side as I didn't find any of your data displayed in this way or at least it wouldn't mind the right click working as if it isn't there!

Hope I didn't step on your toes or break any rules. :O If you have better ways of fixing this then I would love to give them a try! :-)

I know there is a lot of info there but I wanted to make sure you understood what I was trying to do any why! :D I feel that the changes are quite small so if you have read this far you have done the hard part! :cool:

Well that was a HUGE post! Glad you still here! :banana: LOL Unless you skipped to the bottom then :(

Regards,

Zas

carboniteaddon 11-01-10 05:34 PM

I read it all. ;) We have no problem with you trying to draw stuff on the map, but would like you to do it through the public API functions, so internal changes don't break your code.

These functions were added for RareSeeker a few years ago and should still work:

function Nx.MapMinimapOwned()
function Nx.MapInitIconType (iconType, drawMode)
function Nx.MapAddIconPoint (iconType, mapName, x, y, texture)
function Nx.MapAddIconRect (iconType, mapName, x, y, x2, y2, color)
function Nx.MapSetIconTip (icon, tip)

The code you are calling is similar to these functions, but appears you are using more functions and parameters.

Since I just released 4.013 yesterday and am now working on 4.03 for WoW 4.0.3, this is not a good time for me to make the changes.

If you make a simple list of all Carbonite API functions you are calling and the types of parameters you are passing each, I can modify the existing public functions and add new ones to do what you need. This would probably have to be done after all the other map changes I need to make for WoW 4.0.3.

Zasurus 11-02-10 06:38 AM

Quote:

Originally Posted by carboniteaddon (Post 215807)
I read it all. ;) We have no problem with you trying to draw stuff on the map, but would like you to do it through the public API functions, so internal changes don't break your code.

These functions were added for RareSeeker a few years ago and should still work:

function Nx.MapMinimapOwned()
function Nx.MapInitIconType (iconType, drawMode)
function Nx.MapAddIconPoint (iconType, mapName, x, y, texture)
function Nx.MapAddIconRect (iconType, mapName, x, y, x2, y2, color)
function Nx.MapSetIconTip (icon, tip)

The code you are calling is similar to these functions, but appears you are using more functions and parameters.

Since I just released 4.013 yesterday and am now working on 4.03 for WoW 4.0.3, this is not a good time for me to make the changes.

If you make a simple list of all Carbonite API functions you are calling and the types of parameters you are passing each, I can modify the existing public functions and add new ones to do what you need. This would probably have to be done after all the other map changes I need to make for WoW 4.0.3.

Yup those or the functions in was refering to and they are close to what I do for the reason I tried those first found out they didn't work anymore so I created my own to fix them! ;) I considered asking for them to be fixed at the time but figured you had enought on your plate and wasn't sure I knew what I wanted to achieve back then...

I will spend a bit of time later simplifiying it all so you know what I am doing. I may even have a go at fixing the functions mentioned above (as I did that first but didn't want to hook to replace them due to the problems already mentioned in code scruing up when you made a change.

YUP I know about the changing screwing it all up! That's the reason I wanted to approch you directly as if it's messing up for me I can fix it as soon as I notice but as "Fix_ZasCarboniteFixs.lua" shows it might come back to you and that's not something I want!

Although fixing those functions will allow a universal interface and therefore prevent most problems when you change Carbonite that won't fix the problem I was trying to bring up in my first post (the code that is replaced in "Fix_ZasCarboniteFixs.lua") as these are hardcoded limits in "Nx.Map:UpI(dNG)" and "Nx.Map:IOMD(but)".

I would be greatfull if once you get some time (IF you get time! :D ) to fix the functions you mentioned you would also consider the changes I mentioned above as until that is done my addon will always have to use hooks to replace the functions "Nx.Map:UpI(dNG)" and "Nx.Map:IOMD(but)" as I can't see another way to get the required funtionality of right clicking though coloured shapes or changing the colour of icons both of which I require for my addon (WorldExplorer). :o

To make all this clear I will create a simple example addon. I will attempt to make it as clear as posible so you don't need to spend any time on it! I will try to get that done for later today but I don't expect you will get time for quite some time after Cata is out as I know how much is requried to be done!

Thanks again,

Zas

Zasurus 11-02-10 05:09 PM

Done!
 
1 Attachment(s)
OK I have gone though the public API you mentioned and I was correct there are some small changes needed to be usable.

I have created a quick demo addon "Attachment 5159" and there is two lua files:

CarbTestAddon.lua: Is the main addon tha just puts 4 coloured icons and 4 coloured rectangles on the map.

Fixes.lua: This is my proposed changes to the public API (including adding a few simple pass-thoughs for icon level, alpha etc) and also a few small changes to functions to add colours to icons and right click though rectangles (There may be a better way to do this by using the "typ" but I couldn't work out your code for this! :p). If you comment out line 51 "local Show = true;" and reload the ui it will remove the colour and right click changes so you can see the difference. The rest is just fixes to your already existing public API. I have commented all of the changes I propose.

I have tried to keep it simple and make all the changes ovious and complete so you don't need to do much if you agree you can almost cut-n-paste! Or at most small changes.

Thanks again! It will be nice to interface with Carbonite correctly! ;)

Regards,

Zas

Zasurus 11-09-10 07:45 PM

I was just thinking. You could likely do away with the Nx.MapSetIconFrameLevel() function I surgested if the rectangles could be set to the correct level automaticly (by correct I mean the level you use for the quest area's etc). :)

I currently need it as your's disapear correctly when shift is held down and also they are behind the icons etc but when I did it without that function mine didn't work correctly. They seemed to stay infront of the map when shift was pressed and also disapeared at some zoom levels etc...

Zas

carboniteaddon 11-10-10 01:54 AM

I will look at your sample after the version for 4.0.3 is working/released, but that will probably be several weeks, since the zone changes are quite large.

If I forget and you hear nothing back after Dec 7, then bump the thread and I will notice it.

Zasurus 01-29-11 07:38 AM

Quote:

Originally Posted by carboniteaddon (Post 217161)
I will look at your sample after the version for 4.0.3 is working/released, but that will probably be several weeks, since the zone changes are quite large.

If I forget and you hear nothing back after Dec 7, then bump the thread and I will notice it.

Bump... ;) Ignore if your still busy! :p

Zas

Zasurus 10-26-11 02:17 PM

Quote:

Originally Posted by carboniteaddon (Post 217161)
I will look at your sample after the version for 4.0.3 is working/released, but that will probably be several weeks, since the zone changes are quite large.

If I forget and you hear nothing back after Dec 7, then bump the thread and I will notice it.

Hi guys... It's been a while and I haven't asked about this as I have not been playing WoW so not obviously not done much development in WoW BUT I'm back so wondered if there is any chance of getting this added! :D

Thanks in advance!

Zas


All times are GMT -6. The time now is 02:20 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI