ok, yeah that seems like a good idea, it's not like I'm using the Frame specifically for anything other than to define a space/anchor for everything else, right? So making it a button would allow me to use the OnClick and continue to do everything I'm already using it for.
edit:. ok..... i'm stupid..... damn....
After trying a million things before and after Lombra's post and not getting any results I realized it was actually working, what wasn't working was what I made it do, I made it open the artifact weapon window and that wasn't working, but the click was being registered and working, I just added a chat message to test (yes I should have done this in the first place xD) and the chat message shows.
edit:. ok, making the frame a button like Lombra first suggested and then doing
Lua Code:
frame:SetScript("OnMouseUp", function(self, button)
if button == "LeftButton" then
ArtifactFrame_LoadUI()
if (ArtifactFrame:IsVisible()) then
HideUIPanel(ArtifactFrame)
else
SocketInventoryItem(16);
end
end
end);
Seems to be enough, didn't even need the registerforclicks, tries with and without, seems to be the same.
Here's my full code so far.
Lua Code:
local akMulti = {
25, 50, 90, 140, 200,
275, 375, 500, 650, 850,
1100, 1400, 1775, 2250, 2850,
3600, 4550, 5700, 7200, 9000,
11300, 14200, 17800, 22300, 24900
};
local frame = CreateFrame("Button", "m4xArtifactFrame", UIParent);
local text = frame:CreateFontString(nil, "ARTWORK");
text:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE");
text:SetJustifyH("LEFT");
text:SetTextColor(1, 0.82, 0);
text:SetPoint("TOPLEFT", UIParent, "TOPLEFT");
frame:SetAllPoints(text);
frame:RegisterEvent("PLAYER_LOGIN");
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
frame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED");
frame:RegisterEvent("ARTIFACT_CLOSE");
frame:RegisterEvent("ARTIFACT_RESPEC_PROMPT");
frame:RegisterEvent("ARTIFACT_XP_UPDATE");
frame:SetScript("OnEvent", function(self, event, ...)
local itemID, _, _, _, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
if itemID then
local pointsFree, xpToNextPoint = 0, C_ArtifactUI.GetCostForPointAtRank(pointsSpent);
while totalXP >= xpToNextPoint do
totalXP, pointsSpent, pointsFree, xpToNextPoint = totalXP - xpToNextPoint, pointsSpent + 1, pointsFree + 1, C_ArtifactUI.GetCostForPointAtRank(pointsSpent + 1);
end
text:SetFormattedText("AP |cff00ff00%d/%d (%.1f%%)|r" .. (pointsFree > 0 and " (+%d)" or ""), totalXP, xpToNextPoint, 100 * totalXP / xpToNextPoint, pointsFree);
end
frame:SetShown(itemID and true or false);
end);
local function OnEnter(self)
local _, akLevel = GetCurrencyInfo(1171);
local _, _, itemName, itemIcon, _, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
local _, effectiveStat = UnitStat("player", 3);
GameTooltip:SetOwner(self, "ANCHOR_BOTTOM");
GameTooltip:SetText(string.format("|T%d:0|t %s", itemIcon, itemName));
GameTooltip:AddLine(" ");
GameTooltip:AddLine(string.format("Artifact Knowledge Level: |cff00ff00%d (+%d%%)|r", akLevel, akMulti[akLevel] or 0));
GameTooltip:AddLine(string.format("Next Artifact Knowledge: |cff00ff00%d (+%d%%)|r", akLevel + 1, akMulti[akLevel + 1]));
GameTooltip:AddLine(" ");
GameTooltip:AddLine(string.format("Stamina from points: |cff00ff00+%g%% (+%d)|r", pointsSpent * 0.75, effectiveStat - (effectiveStat / ((pointsSpent * 0.75 / 100) + 1))));
GameTooltip:Show();
end
local function OnLeave(self)
GameTooltip:Hide();
end
frame:SetScript("OnMouseUp", function(self, button)
if button == "LeftButton" then
if ArtifactFrame and ArtifactFrame:IsVisible() then
HideUIPanel(ArtifactFrame);
else
SocketInventoryItem(16);
end
end
end);
frame:SetScript("OnEnter", OnEnter);
frame:SetScript("OnLeave", OnLeave);
I'm still trying out events for the initial load, because I have a few times that the text wasn't becoming visible with PLAYER_ENTERING_WORLD, we talked about this, I think it was SDPhantom that said the addon didn't have the artifact info available at that point.
I donno, is there any other events that happen once at start bu after that one? The PLAYER_LOGIN one is probably not doing anything tbh.
I just need to get this to load at start every time and for some reason, some times it doesn't, it IS rare but it happens.