WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   PTR API and Graphics Changes (https://www.wowinterface.com/forums/forumdisplay.php?f=175)
-   -   New/changed in build 26522. (https://www.wowinterface.com/forums/showthread.php?t=56196)

thomasjohnshannon 04-30-18 08:18 PM

New/changed in build 26522.
 
I was looking over the code from the patch and here are a few of the things I noticed.

Old loot code has been removed. RIP Master Loot

New functions and table info added to C_TaxiMap.

Updated cancelaura macro command function. Now uses CancelSpellByName(name) instead of CancelUnitBuff(unit, spell, [filter or rank]).

New leave vehicle slash function.

Lua Code:
  1. SECURE_ACTIONS.leavevehicle =
  2. function (self, unit, button)
  3.    VehicleExit();
  4. end;

Small change to ITEM_QUALITY_COLORS.

Lua Code:
  1. local r, g, b = GetItemQualityColor(i);
  2. local color = CreateColor(r, g, b, 1);
  3. ITEM_QUALITY_COLORS[i] = { r = r, g = g, b = b, hex = color:GenerateHexColorMarkup(), color = color };
With related new function GenerateHexColorMarkup.

Lua Code:
  1. function ColorMixin:GenerateHexColorMarkup()
  2.   return "|c"..self:GenerateHexColor();
  3. end

New map function.
Lua Code:
  1. {
  2.   Name = "GetPlayerMapPosition",
  3.   Type = "Function",
  4.   Documentation = { "Only works for the player and party members." },
  5.  
  6.   Arguments =
  7.   {
  8.     { Name = "uiMapID", Type = "number", Nilable = false },
  9.     { Name = "unitToken", Type = "string", Nilable = false },
  10.   },
  11.  
  12.   Returns =
  13.   {
  14.     { Name = "position", Type = "table", Mixin = "Vector2DMixin", Nilable = true },
  15.   },
  16. },

New GameTooltip functions.

Lua Code:
  1. function GameTooltip_SetTitle(tooltip, text, overrideColor, wrap)
  2.   local titleColor = overrideColor or HIGHLIGHT_FONT_COLOR;
  3.   local r, g, b, a = titleColor:GetRGBA();
  4.   tooltip:SetText(text, r, g, b, a, wrap);
  5. end
  6.  
  7. function GameTooltip_AddNormalLine(tooltip, text, wrap)
  8.   GameTooltip_AddColoredLine(tooltip, text, NORMAL_FONT_COLOR, wrap);
  9. end
  10.  
  11. function GameTooltip_AddInstructionLine(tooltip, text, wrap)
  12.   GameTooltip_AddColoredLine(tooltip, text, GREEN_FONT_COLOR, wrap);
  13. end
  14.  
  15. function GameTooltip_AddColoredLine(tooltip, text, color, wrap)
  16.   local r, g, b, a = color:GetRGBA();
  17.   tooltip:AddLine(text, r, g, b, a, wrap);
  18. end
  19.  
  20. function EmbeddedItemTooltip_SetSpellByQuestReward(self, rewardIndex, questID)
  21.   local texture, name, isTradeskillSpell, isSpellLearned, hideSpellLearnText, isBoostSpell, garrFollowerID, genericUnlock, spellID = GetQuestLogRewardSpell(rewardIndex, questID);
  22.   if garrFollowerID then
  23.     EmbeddedItemTooltip_PrepareForFollower(self);
  24.     local data = GarrisonFollowerTooltipTemplate_BuildDefaultDataForID(garrFollowerID);
  25.     GarrisonFollowerTooltipTemplate_SetGarrisonFollower(self.FollowerTooltip, data);
  26.     EmbeddedItemTooltip_UpdateSize(self);
  27.     return true;
  28.   elseif name and texture then
  29.     self.itemID = nil;
  30.     self.spellID = spellID;
  31.  
  32.     self:Show();
  33.     EmbeddedItemTooltip_PrepareForSpell(self);
  34.     self.Tooltip:SetOwner(self, "ANCHOR_NONE");
  35.     self.Tooltip:SetQuestLogRewardSpell(rewardIndex, questID);
  36.     SetItemButtonQuality(self, LE_ITEM_QUALITY_COMMON);
  37.     SetItemButtonCount(self, 0);
  38.     self.Icon:SetTexture(texture);
  39.     self.Tooltip:SetPoint("TOPLEFT", self.Icon, "TOPRIGHT", 0, 10);
  40.     EmbeddedItemTooltip_UpdateSize(self);
  41.     return true;
  42.   end
  43.   return false;
  44. end

New Achievement function.

Lua Code:
  1. function OpenAchievementFrameToAchievement(achievementID)
  2.   if ( not AchievementFrame ) then
  3.     AchievementFrame_LoadUI();
  4.   end
  5.   if ( not AchievementFrame:IsShown() ) then
  6.     AchievementFrame_ToggleAchievementFrame();
  7.   end
  8.   AchievementFrame_SelectAchievement(achievementID);
  9. end

New util function.

Lua Code:
  1. function CallMethodOnNearestAncestor(self, methodName, ...)
  2.   local ancestor = self:GetParent();
  3.   while ancestor and not ancestor[methodName] do
  4.     ancestor = ancestor:GetParent();
  5.   end
  6.  
  7.   if ancestor then
  8.     ancestor[methodName](ancestor, ...);
  9.     return true;
  10.   end
  11.  
  12.   return false;
  13. end

VincentSDSH 05-01-18 09:44 PM

:eek: Wow...this seems like a lot to get coords, am I doing this right?
Lua Code:
  1. local x, y = C_Map.GetPlayerMapPosition(  C_Map.GetBestMapForUnit("player") , "player" ):GetXY()

Rilgamon 05-02-18 02:22 AM

I dont understand why they did not make uiMapId the second parameter and optional,
defaulting to C_Map.GetBestMapForUnit(unit).

VincentSDSH 05-02-18 02:47 AM

Quote:

Originally Posted by Rilgamon (Post 327856)
I dont understand why they did not make uiMapId the second parameter and optional,
defaulting to C_Map.GetBestMapForUnit(unit).

Convention of uiMapID being the first parameter? I can't explain it. It's not like you're going to

x, y = C_Map.GetPlayerMapPosition( C_Map.GetBestMapForUnit("player"), "party1"):GetXY()

That'd be a damned weird way to ask "is party1 in the same zone I am?"

Seerah 05-02-18 01:15 PM

Quote:

Originally Posted by VincentSDSH (Post 327853)
:eek: Wow...this seems like a lot to get coords, am I doing this right?
Lua Code:
  1. local x, y = C_Map.GetPlayerMapPosition(  C_Map.GetBestMapForUnit("player") , "player" ):GetXY()

Or you could just do this:
Lua Code:
  1. local positionData = C_Map.GetPlayerMapPosition(C_Map.GetBestMapForUnit("player"), "player")
And then use positionData.x and positionData.y


/edited because GetCurrentMapID is tied to the world map display

Seerah 05-02-18 01:20 PM

Quote:

Originally Posted by VincentSDSH (Post 327857)
Convention of uiMapID being the first parameter? I can't explain it. It's not like you're going to

x, y = C_Map.GetPlayerMapPosition( C_Map.GetBestMapForUnit("player"), "party1"):GetXY()

That'd be a damned weird way to ask "is party1 in the same zone I am?"

Can't you just do this?
Lua Code:
  1. if C_Map.GetBestMapForUnit("player") == C_Map.GetBestMapForUnit("party1") then
  2. .......

VincentSDSH 05-02-18 04:54 PM

Quote:

Originally Posted by Seerah (Post 327862)
Can't you just do this?
Lua Code:
  1. if C_Map.GetBestMapForUnit("player") == C_Map.GetBestMapForUnit("party1") then
  2. .......

Yes, that was sorta my point: there's no logical reason to pass in different units.

The method to get x, y coords...feels like congress designed it. It works, but I cringe every time I see the code, even with pointers into C_Map.

JDoubleU00 05-02-18 05:20 PM

Quote:

Originally Posted by VincentSDSH (Post 327869)
Yes, that was sorta my point: there's no logical reason to pass in different units.

The method to get x, y coords...feels like congress designed it. It works, but I cringe every time I see the code, even with pointers into C_Map.

Congress? lol You're giving them way to much credit.

Seerah 05-02-18 07:35 PM

Some people might like the actual coordinates of their party members. You could set waypoints to them, etc.

Rilgamon 05-03-18 01:24 AM

Quote:

Originally Posted by Seerah (Post 327873)
Some people might like the actual coordinates of their party members. You could set waypoints to them, etc.

Sure, thats totally ok.
But in 99% you will use C_Map.GetBestMapForUnit to find the units uiMapId.
You'll alway pass the same unit to both functions.
Coords are updated frequently so I guess its quite an impact if I query
the uiMapId through C_Map.GetBestMapForUnit or if C_Map.GetPlayerMapPosition would do it itself (if I could skip it).

VincentSDSH 05-03-18 01:40 AM

Quote:

Originally Posted by Seerah (Post 327873)
Some people might like the actual coordinates of their party members. You could set waypoints to them, etc.

I didn't see anyone argue against coords for party members. If you were setting waypoints, you'd also set them off your current map, so you're still doing a double lookup. Otherwise, it's back to what I said before: a nil result from ..."player", "party3"... is a weird way to ask if you're on the same map or not (i.e., you'd never want to do it that way).

Tbh, if you were going to send back an array, why not have mapID as part of the array along with x and y rather than multiple queries?

Lua Code:
  1. local pos = C_Map.GetPlayerMapPosition("party2")
  2. print( "party2 is at "..tostring(pos.x)..", "..tostring(pos.y) )
  3. print( "party2 is on mapID: "..tostring(pos.mapID) )

I think Rilgamon has the right of it, and this method of getting x,y for addons feels like an afterthought in their overall rebuild of the mapping system.

TOM_RUS 05-03-18 02:15 AM

Quote:

Originally Posted by Seerah (Post 327873)
Some people might like the actual coordinates of their party members. You could set waypoints to them, etc.

You better be using UnitPosition() if you ever need such things. Works cross zones out of the box, no need to care about uimapid's and works much faster than all that C_Map stuff.

Nevcairiel 05-03-18 04:03 AM

The entire point of the new map API is to remove behind the scenes "magic", it now does exactly what it says on the tin and what you ask it to do. No ambiguity, no magic, no hidden C state. If you don't pass a zone, then you don't know which zone it choose to represent the coordinates in - and without that information, you can't use them properly.

Passing a uiMapID to GetPlayerZonePosition is certainly useful, since maps are an overlay on top of the real world, there is never just one map that applies to you, at least there is like the world map, the continent map, the zone map, and if you're anywhere deeper there is even more on top of that.

If you're worried about the overhead of asking for the map everytime, you could just track zone changes and update it only then (although there is a bunch of events one needs to take care of) - but generally, don't worry about micro-optimizations like this.

Rilgamon 05-03-18 04:53 AM

Dont get me wrong,Nevcairiel. I really love seeing a rewrite of the engine. When the cataclysm brought so many not working elements into our world and the expected repairs did not happen in pandaria (thats the reason for my tagline ;) ) I pretty much lost the fun in trying new things with addons.
With the documentation included it's really a new enabler for many great things I'm sure.
Still a few shortcuts could help :)

VincentSDSH 05-03-18 01:25 PM

What Rilgamon said. Many long-delayed optimizations and expansive refactors create certain areas of (fairly unavoidable) usage-weaknesses. At a framework level, after refactors/redesigns, in a hand-shake environment there is a usage-optimization pass, looking at clustered function usage to create efficient (to use Rilgamon's term) 'shortcuts' which aid in coding, debugging, and long-term (and multi-person) maintenance -- the reason we write so many libraries -- but when there is a distinct performance issue (Lua vs C) there is an incentive to provide some of them at the most optimized layer; those helper-functions are a very minimal expense on the framework developer and improve the overall quality of products using the framework.

I mean, I can't believe someone looked at this and said "Yeah, that's a great idea! Huge usage improvement!"
Lua Code:
  1. C_Map.GetPlayerMapPosition(  C_Map.GetBestMapForUnit("player") , "player" )
Whatever other awesome things the mapping system might do (and I'm bloody grateful for the rewrite of the poor thing), this is a bit pants. ;)

As the sage says:
Quote:

Originally Posted by Rilgamon (Post 327882)
Still a few shortcuts could help :)


Seerah 05-03-18 03:16 PM

Well, the new system does allow you to get your player's (or party members') coordinates based on any map, not just your current zone. There may be some use for that, either in the default UI or for addon devs who feel they can utilize it. Either now or in the future.

If they made the uiMapID an optional second argument, defaulting to the "best map for unit", the API would still need to check which map that is before returning coordinates and location data. And if they gave you a shortcut function, it may very well still do C_Map.GetPlayerMapPosition( C_Map.GetBestMapForUnit("player"), "player") on the back-end.

It's like Nev says:
Quote:

Originally Posted by Nevcairel
If you don't pass a zone, then you don't know which zone it choose to represent the coordinates in - and without that information, you can't use them properly.


Rilgamon 05-03-18 03:46 PM

Quote:

Originally Posted by Seerah (Post 327885)
It's like Nev says:

If I call C_Map.GetBestMapForUnit(unit) in Lua or C_Map.GetPlayerMapPosition(unit) would call it in C the result will be the same just quicker and with less code written in Lua.

thomasjohnshannon 05-08-18 06:32 PM

More Map API Changes (26567)
 
Removed

SetMap was removed but it could just be RequestPreloadMap. Both excisted in the last patch but now we only have RequestPreloadMap.

Lua Code:
  1. {
  2.   Name = "GetCurrentMapID",
  3.   Type = "Function",
  4.  
  5.   Returns =
  6.   {
  7.     { Name = "uiMapID", Type = "number", Nilable = false },
  8.   },
  9. },

New Functions

Lua Code:
  1. {
  2.   Name = "GetMapBannersForMap",
  3.   Type = "Function",
  4.  
  5.   Arguments =
  6.   {
  7.     { Name = "uiMapID", Type = "number", Nilable = false },
  8.   },
  9.  
  10.   Returns =
  11.   {
  12.     { Name = "mapBanners", Type = "table", InnerType = "MapBannerInfo", Nilable = false },
  13.   },
  14. },
  15. {
  16.   Name = "GetMapLinksForMap",
  17.   Type = "Function",
  18.  
  19.   Arguments =
  20.   {
  21.     { Name = "uiMapID", Type = "number", Nilable = false },
  22.   },
  23.  
  24.   Returns =
  25.   {
  26.     { Name = "mapLinks", Type = "table", InnerType = "MapLinkInfo", Nilable = false },
  27.   },
  28. },
  29. {
  30.   Name = "GetMapPosFromWorldPos",
  31.   Type = "Function",
  32.  
  33.   Arguments =
  34.   {
  35.     { Name = "continentID", Type = "number", Nilable = false },
  36.     { Name = "worldPosition", Type = "table", Mixin = "Vector2DMixin", Nilable = false },
  37.     { Name = "overrideUiMapID", Type = "number", Nilable = true },
  38.   },
  39.  
  40.   Returns =
  41.   {
  42.     { Name = "uiMapID", Type = "number", Nilable = false },
  43.     { Name = "mapPosition", Type = "table", Mixin = "Vector2DMixin", Nilable = false },
  44.   },
  45. },
  46. {
  47.   Name = "GetWorldPosFromMapPos",
  48.   Type = "Function",
  49.  
  50.   Arguments =
  51.   {
  52.     { Name = "uiMapID", Type = "number", Nilable = false },
  53.     { Name = "mapPosition", Type = "table", Mixin = "Vector2DMixin", Nilable = false },
  54.   },
  55.  
  56.   Returns =
  57.   {
  58.     { Name = "continentID", Type = "number", Nilable = false },
  59.     { Name = "worldPosition", Type = "table", Mixin = "Vector2DMixin", Nilable = false },
  60.   },
  61. },

Map event info added.

Lua Code:
  1. Events =
  2. {
  3. {
  4.   Name = "NewWmoChunk",
  5.   Type = "Event",
  6.   LiteralName = "NEW_WMO_CHUNK",
  7. },
  8. {
  9.   Name = "ZoneChanged",
  10.   Type = "Event",
  11.   LiteralName = "ZONE_CHANGED",
  12. },
  13. {
  14.   Name = "ZoneChangedIndoors",
  15.   Type = "Event",
  16.   LiteralName = "ZONE_CHANGED_INDOORS",
  17. },
  18. {
  19.   Name = "ZoneChangedNewArea",
  20.   Type = "Event",
  21.   LiteralName = "ZONE_CHANGED_NEW_AREA",
  22. },
  23. },

thomasjohnshannon 05-08-18 07:30 PM

More (26567) Changes
 
IsWarModeEnabled was renamed to IsWarModeFeatureEnabled.
ShowUIPanel(WorldMapFrame); replaced with OpenWorldMap();

Quest Tag constants changed.

Lua Code:
  1. {
  2.   Name = "QuestTag",
  3.   Type = "Enumeration",
  4.   NumValues = 10,
  5.   MinValue = 0,
  6.   MaxValue = 102,
  7.   Fields =
  8.   {
  9.     { Name = "Group", Type = "QuestTag", EnumValue = 1 },
  10.     { Name = "Pvp", Type = "QuestTag", EnumValue = 41 },
  11.     { Name = "Raid", Type = "QuestTag", EnumValue = 62 },
  12.     { Name = "Dungeon", Type = "QuestTag", EnumValue = 81 },
  13.     { Name = "Legendary", Type = "QuestTag", EnumValue = 83 },
  14.     { Name = "Heroic", Type = "QuestTag", EnumValue = 85 },
  15.     { Name = "Raid10", Type = "QuestTag", EnumValue = 88 },
  16.     { Name = "Raid25", Type = "QuestTag", EnumValue = 89 },
  17.     { Name = "Scenario", Type = "QuestTag", EnumValue = 98 },
  18.     { Name = "Account", Type = "QuestTag", EnumValue = 102 },
  19.   },
  20. },
  21.  
  22. [Enum.QuestTag.Dungeon] = { 0.421875, 0.5625, 0, 0.28125 },
  23. [Enum.QuestTag.Scenario] = { 0.5625, 0.703125, 0, 0.28125 },
  24. [Enum.QuestTag.Account] = { 0.84375, 0.984375, 0, 0.28125 },
  25. [Enum.QuestTag.Legendary] = { 0, 0.140625, 0.28125, 0.5625 },
  26. [Enum.QuestTag.Group] = { 0.140625, 0.28125, 0.28125, 0.5625 },
  27. [Enum.QuestTag.Pvp] = { 0.28125, 0.421875, 0.28125, 0.5625 },
  28. [Enum.QuestTag.Heroic] = { 0, 0.140625, 0.5625, 0.84375 },
  29. -- same texture for all raids
  30. [Enum.QuestTag.Raid] = { 0.703125, 0.84375, 0, 0.28125 },
  31. [Enum.QuestTag.Raid10] = { 0.703125, 0.84375, 0, 0.28125 },
  32. [Enum.QuestTag.Raid25] = { 0.703125, 0.84375, 0, 0.28125 },

New Functions

Lua Code:
  1. {
  2.   Name = "GetStaggerPercentage",
  3.   Type = "Function",
  4.  
  5.   Arguments =
  6.   {
  7.     { Name = "unit", Type = "string", Nilable = false },
  8.   },
  9.  
  10.   Returns =
  11.   {
  12.     { Name = "stagger", Type = "number", Nilable = false },
  13.     { Name = "staggerAgainstTarget", Type = "number", Nilable = true },
  14.   },
  15. },
  16.  
  17. {
  18.   Name = "GetHonorRewardInfo",
  19.   Type = "Function",
  20.  
  21.   Arguments =
  22.   {
  23.     { Name = "honorLevel", Type = "number", Nilable = false },
  24.   },
  25.  
  26.   Returns =
  27.   {
  28.     { Name = "info", Type = "HonorRewardInfo", Nilable = true },
  29.   },
  30. },
  31. {
  32.   Name = "GetNextHonorLevelForReward",
  33.   Type = "Function",
  34.  
  35.   Arguments =
  36.   {
  37.     { Name = "honorLevel", Type = "number", Nilable = false },
  38.   },
  39.  
  40.   Returns =
  41.   {
  42.     { Name = "nextHonorLevelWithReward", Type = "number", Nilable = true },
  43.   },
  44. },
  45. {
  46.   Name = "GetPvpTierInfo",
  47.   Type = "Function",
  48.  
  49.   Arguments =
  50.   {
  51.     { Name = "tierID", Type = "number", Nilable = false },
  52.   },
  53.  
  54.   Returns =
  55.   {
  56.     { Name = "pvpTierInfo", Type = "PvpTierInfo", Nilable = true },
  57.   },
  58. },
  59.  
  60. {
  61.   Name = "GetSpellsDisplay",
  62.   Type = "Function",
  63.  
  64.   Arguments =
  65.   {
  66.     { Name = "specializationID", Type = "number", Nilable = false },
  67.   },
  68.  
  69.   Returns =
  70.   {
  71.     { Name = "spellID", Type = "table", InnerType = "number", Nilable = false },
  72.   },
  73. },

Nevcairiel 05-09-18 05:21 PM

Quote:

Originally Posted by thomasjohnshannon (Post 327926)
SetMap was removed but it could just be RequestPreloadMap. Both excisted in the last patch but now we only have RequestPreloadMap.

Both SetMap and GetCurrentMapID have been removed because there finally is absolutely no stateful map API anymore. There is no concept of a global "current map" anymore - its now tracked by any map frame on its own. Similarly, the WORLD_MAP_UPDATE event has been removed, because it no longer applies. If you want to be notified when the world map changes the map its showing, hook into WorldMapFrame.OnMapChanged

If you want to know which map the World Map is looking at, call WorldMapFrame:GetMapID(), or call WorldMapFrame:NavigateToMap() to change it.

This allows you to implement other map-things without messing with the World Map, like the new BattlefieldMap that returned in the recent build. It uses much of the same logic of the World Map, but it could show a different map if you wanted to.


All times are GMT -6. The time now is 02:56 PM.

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