View Single Post
11-16-16, 02:24 PM   #32
_Max_Cavalera_
A Fallenroot Satyr
 
_Max_Cavalera_'s Avatar
Join Date: Dec 2007
Posts: 28
After my "epiphany" yesterday when going to bed, I got to think that Lombra was most probably right when saying the best way in this case would be to just do those 1 or 2 lines again since it was just that pretty much.

I did this before I saw your post.

Lua Code:
  1. local akMulti = {
  2.     25, 50, 90, 140, 200,
  3.     275, 375, 500, 650, 850,
  4.     1100, 1400, 1775, 2250, 2850,
  5.     3600, 4550, 5700, 7200, 9000,
  6.     11300, 14200, 17800, 22300, 24900
  7. };
  8.  
  9. local frame = CreateFrame("Frame", "m4xArtifactFrame", UIParent);
  10. local text = frame:CreateFontString(nil, "ARTWORK");
  11. text:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE");
  12. text:SetJustifyH("LEFT");
  13. text:SetTextColor(1, 0.82, 0);
  14. text:SetPoint("TOPLEFT", UIParent, "TOPLEFT");
  15.  
  16. text:SetText("Initializing...");
  17.  
  18. frame:SetAllPoints(text);
  19.  
  20. frame:RegisterEvent("PLAYER_ENTERING_WORLD");
  21. frame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED");
  22. frame:RegisterEvent("ARTIFACT_CLOSE");
  23. frame:RegisterEvent("ARTIFACT_RESPEC_PROMPT");
  24. frame:RegisterEvent("ARTIFACT_XP_UPDATE");
  25.  
  26. frame:SetScript("OnEvent", function(self, event, ...)
  27.     local itemID, _, _, _, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  28.    
  29.     if itemID then
  30.         local pointsFree, xpToNextPoint = 0, C_ArtifactUI.GetCostForPointAtRank(pointsSpent);
  31.        
  32.         while totalXP >= xpToNextPoint do
  33.             totalXP, pointsSpent, pointsFree, xpToNextPoint = totalXP - xpToNextPoint, pointsSpent + 1, pointsFree + 1, C_ArtifactUI.GetCostForPointAtRank(pointsSpent + 1);
  34.         end
  35.  
  36.         text:SetFormattedText("AP |cff00ff00%d/%d (%.1f%%)|r" .. (pointsFree > 0 and " (+%d)" or ""), totalXP, xpToNextPoint, 100 * totalXP / xpToNextPoint, pointsFree);
  37.  
  38.     end
  39.  
  40.     frame:SetShown(itemID and true or false);
  41. end);
  42.  
  43. local function OnEnter(self)
  44.     local _, akLevel = GetCurrencyInfo(1171);
  45.     local _, _, itemName, itemIcon, _, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  46.     local _, effectiveStat = UnitStat("player", 3);
  47.  
  48.     GameTooltip:SetOwner(self, "ANCHOR_BOTTOM");
  49.     GameTooltip:SetText(itemName);
  50.     GameTooltip:AddLine(" ");
  51.     GameTooltip:AddLine(string.format("Artifact Knowledge Level: |cff00ff00%d (+%d%%)|r", akLevel, akMulti[akLevel] or 0));
  52.     GameTooltip:AddLine(string.format("Next Artifact Knowledge: |cff00ff00%d (+%d%%)|r", akLevel + 1, akMulti[akLevel + 1]));
  53.     GameTooltip:AddLine(" ");
  54.     GameTooltip:AddLine(string.format("Stamina from points: |cff00ff00+%g%% (+%d)|r", pointsSpent * 0.75, effectiveStat - (effectiveStat / ((pointsSpent * 0.75 / 100) + 1))));
  55.     GameTooltip:Show();
  56. end
  57.  
  58. local function OnLeave(self)
  59.     GameTooltip:Hide();
  60. end
  61.  
  62. frame:SetScript("OnEnter", OnEnter);
  63. frame:SetScript("OnLeave", OnLeave);

You think it's not as "correct" as your example?

It's working perfectly as it is.


This is with mouseover obviously, mouse just doesn't show on the screenshot.

Don't have that frame:EnableMouse(true), you think it's just enabled by default now or something?
  Reply With Quote