Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonaza committed Sep 21, 2016
2 parents bd008e1 + 361f638 commit 359f5ad
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 77 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.0.10
* Attempted fix for options menu not working for some people due to some error with reputations.
* Added display of currently unspent artifact power tokens in player inventory.
* Total artifact power text now displays the spent and currently accumulated power instead of spent only.
* Fixed artifact power level up animation.
* Number of unspent trait points available for an artifact is now calculated in the total rank number.
* Honor chat message now tells remaining honor instead of percentage.

## 2.0.9
* Improvements to artifact bar text.

Expand Down
2 changes: 1 addition & 1 deletion Experiencer.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Title: Experiencer
## Notes: Simple and Advanced Experience and Reputation Progress Bar
## Author: Sonaza
## Version: 2.0.9
## Version: 2.0.10
## OptionalDeps: Ace3
## SavedVariables: ExperiencerDB, ExperiencerDB_module_experience, ExperiencerDB_module_reputation, ExperiencerDB_module_artifact, ExperiencerDB_module_honor

Expand Down
110 changes: 99 additions & 11 deletions modules/artifact.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ local module = Addon:RegisterModule("artifact", {
ShowRemaining = true,
ShowUnspentPoints = true,
ShowTotalArtifactPower = false,
UnspentInChatMessage = false,
ShowBagArtifactPower = true,
VisualizeBagArtifactPower = true,
},
},
});
Expand Down Expand Up @@ -68,7 +71,7 @@ end
function module:CalculateTotalArtifactPower()
if(not HasArtifactEquipped()) then return 0 end

local _, _, _, _, _, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo();
local _, _, _, _, currentXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo();

local totalXP = 0;

Expand All @@ -77,7 +80,7 @@ function module:CalculateTotalArtifactPower()
totalXP = totalXP + xpForNextPoint;
end

return totalXP;
return totalXP + currentXP;
end

function module:GetText()
Expand All @@ -96,7 +99,7 @@ function module:GetText()
local progressColor = Addon:GetProgressColor(progress);

tinsert(outputText,
("|cffffecB3%s|r (Rank %d):"):format(name, pointsSpent)
("|cffffecB3%s|r (Rank %d):"):format(name, pointsSpent + numPoints)
);

if(self.db.global.ShowRemaining) then
Expand All @@ -115,6 +118,15 @@ function module:GetText()
);
end

if(self.db.global.ShowBagArtifactPower) then
local totalPower = module:FindPowerItemsInInventory();
if(totalPower > 0) then
tinsert(outputText,
("%s |cffa8ff00artifact power in bags|r"):format(BreakUpLargeNumbers(totalPower))
);
end
end

if(self.db.global.ShowUnspentPoints and numPoints > 0) then
tinsert(outputText,
("|cff86ff33%d unspent point%s|r"):format(numPoints, numPoints == 1 and "" or "s")
Expand All @@ -139,7 +151,7 @@ function module:GetChatMessage()

tinsert(outputText, ("%s is currently rank %s"):format(
name,
pointsSpent
pointsSpent + numPoints
));

if(pointsSpent > 0) then
Expand All @@ -149,12 +161,12 @@ function module:GetChatMessage()
progress * 100,
remaining
));
if(numPoints > 0) then
tinsert(outputText,
("(%d unspent point%s)"):format(numPoints, numPoints == 1 and "" or "s")
);
end
end

if(self.db.global.UnspentInChatMessage and numPoints > 0) then
tinsert(outputText,
(" (%d unspent point%s)"):format(numPoints, numPoints == 1 and "" or "s")
);
end

return table.concat(outputText, " ");
Expand All @@ -173,9 +185,14 @@ function module:GetBarData()
local itemID, altItemID, name, icon, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo();
local numPoints, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP);

data.level = pointsSpent;
data.level = pointsSpent + numPoints or 0;
data.max = xpForNextPoint;
data.current = artifactXP;

if(self.db.global.VisualizeBagArtifactPower) then
local totalPower = module:FindPowerItemsInInventory();
data.visual = totalPower;
end
end

return data;
Expand Down Expand Up @@ -213,6 +230,24 @@ function module:GetOptionsMenu()
checked = function() return self.db.global.ShowUnspentPoints; end,
isNotRadio = true,
},
{
text = "Include unspent points in chat message",
func = function() self.db.global.UnspentInChatMessage = not self.db.global.UnspentInChatMessage; module:RefreshText(); end,
checked = function() return self.db.global.UnspentInChatMessage; end,
isNotRadio = true,
},
{
text = "Show unspent artifact power in bags",
func = function() self.db.global.ShowBagArtifactPower = not self.db.global.ShowBagArtifactPower; module:RefreshText(); end,
checked = function() return self.db.global.ShowBagArtifactPower; end,
isNotRadio = true,
},
{
text = "Visualize unspent artifact power in bags",
func = function() self.db.global.VisualizeBagArtifactPower = not self.db.global.VisualizeBagArtifactPower; module:RefreshText(); end,
checked = function() return self.db.global.VisualizeBagArtifactPower; end,
isNotRadio = true,
},
};

return menudata;
Expand All @@ -232,3 +267,56 @@ function module:UNIT_INVENTORY_CHANGED(event, unit)
module:Refresh(true);
end
end

local EMPOWERING_SPELL_ID = 227907;

local ExperiencerAPScannerTooltip = CreateFrame("GameTooltip", "ExperiencerAPScannerTooltip", nil, "GameTooltipTemplate");
function module:FindPowerItemsInInventory()
local powers = {};
local totalPower = 0;

local spellName = GetSpellInfo(EMPOWERING_SPELL_ID);

for container = 0, NUM_BAG_SLOTS do
local numSlots = GetContainerNumSlots(container);

for slot = 1, numSlots do
local link = GetContainerItemLink(container, slot);
if(link and GetItemSpell(link) == spellName) then
ExperiencerAPScannerTooltip:SetOwner(UIParent, "ANCHOR_NONE");
ExperiencerAPScannerTooltip:SetHyperlink(link);

local tooltipText = ExperiencerAPScannerTooltipTextLeft4:GetText();
if(not tooltipText) then return nil end

local power = tonumber(tooltipText:gsub("[,%.]", ""):match("%d.-%s"));
if(power) then
totalPower = totalPower + power;
tinsert(powers, {
link = link,
power = power,
});
end
end
end
end

return totalPower, powers;
end

function module:GetItemArtifactPower(link)
if(not link) then return nil end

ExperiencerAPScannerTooltip:SetOwner(UIParent, "ANCHOR_NONE");
ExperiencerAPScannerTooltip:SetHyperlink(link);

local tooltipText = ExperiencerAPScannerTooltipTextLeft4:GetText();
if(not tooltipText) then return nil end

local power = tooltipText:gsub("[,%.]", ""):match("%d.-%s");
if(power) then
return tonumber(power);
end

return nil;
end
6 changes: 3 additions & 3 deletions modules/honor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ function module:GetChatMessage()

local progress = honor / (honormax > 0 and honormax or 1);

local leveltext = ("Currently honor level %d"):format(level);
local leveltext = ("Currently honor rank %d"):format(level);

if(prestige > 0) then
leveltext = ("%s (%d prestige)"):format(leveltext, prestige);
end

return ("%s at %s/%s (%d%%) with %d%% to go."):format(
return ("%s at %s/%s (%d%%) with %s to go"):format(
leveltext,
BreakUpLargeNumbers(honor),
BreakUpLargeNumbers(honormax),
math.ceil(progress * 100),
math.ceil((1-progress) * 100)
BreakUpLargeNumbers(remaining)
);
end

Expand Down
123 changes: 61 additions & 62 deletions modules/reputation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -301,84 +301,83 @@ function module:GetReputationsMenu()
local depth = 0;

local numFactions = GetNumFactions();
local index = 1;
while index <= numFactions do
for index = 1, numFactions do
local name, _, standing, _, _, _, _, _, isHeader, isCollapsed, hasRep, isWatched, isChild, factionID = GetFactionInfo(index);
local friend_level = select(7, GetFriendshipReputation(factionID));
local standing_text = "";
local faction_index = index;

if(not isHeader or hasRep) then
if(friend_level) then
standing_text = friend_level;
else
standing_text = module:GetStandingColorText(standing)
if(name) then
local friend_level = select(7, GetFriendshipReputation(factionID));
local standing_text = "";
local faction_index = index;

if(not isHeader or hasRep) then
if(friend_level) then
standing_text = friend_level;
else
standing_text = module:GetStandingColorText(standing)
end
end
end

if(isHeader and isCollapsed) then
ExpandFactionHeader(index);
numFactions = GetNumFactions();
end

if(isHeader and isChild) then -- Second tier header
if(depth == 2) then
current = previous;
previous = nil;

if(isHeader and isCollapsed) then
ExpandFactionHeader(index);
numFactions = GetNumFactions();
end

if(not hasRep) then
if(isHeader and isChild) then -- Second tier header
if(depth == 2) then
current = previous;
previous = nil;
end

if(not hasRep) then
tinsert(current, {
text = name,
hasArrow = true,
notCheckable = true,
menuList = {},
})
else
tinsert(current, {
text = string.format("%s (%s)", name, standing_text),
hasArrow = true,
func = function() SetWatchedFactionIndex(faction_index); CloseMenus(); end,
checked = function() return isWatched; end,
menuList = {},
})
end

previous = current;
current = current[#current].menuList;
tinsert(current, {
text = name,
isTitle = true,
notCheckable = true,
})

depth = 2

elseif(isHeader) then -- First tier header
tinsert(factions, {
text = name,
hasArrow = true,
notCheckable = true,
menuList = {},
})
else

current = factions[#factions].menuList;
tinsert(current, {
text = name,
isTitle = true,
notCheckable = true,
})

depth = 1
elseif(not isHeader) then -- First and second tier faction
tinsert(current, {
text = string.format("%s (%s)", name, standing_text),
hasArrow = true,
func = function() SetWatchedFactionIndex(faction_index); CloseMenus(); end,
checked = function() return isWatched; end,
menuList = {},
checked = function() return isWatched end,
})
end

previous = current;
current = current[#current].menuList;
tinsert(current, {
text = name,
isTitle = true,
notCheckable = true,
})

depth = 2

elseif(isHeader) then -- First tier header
tinsert(factions, {
text = name,
hasArrow = true,
notCheckable = true,
menuList = {},
})

current = factions[#factions].menuList;
tinsert(current, {
text = name,
isTitle = true,
notCheckable = true,
})

depth = 1
elseif(not isHeader) then -- First and second tier faction
tinsert(current, {
text = string.format("%s (%s)", name, standing_text),
func = function() SetWatchedFactionIndex(faction_index); CloseMenus(); end,
checked = function() return isWatched end,
})
end

index = index + 1;
end

local recent = module:GetRecentReputationsMenu();
Expand Down

0 comments on commit 359f5ad

Please sign in to comment.