diff --git a/Source_Classic/CraftingInfo/Main.lua b/Source_Classic/CraftingInfo/Main.lua index 086380768..b6cccae2d 100644 --- a/Source_Classic/CraftingInfo/Main.lua +++ b/Source_Classic/CraftingInfo/Main.lua @@ -144,15 +144,28 @@ local function CraftCostString() end local function ProfitString(profit) - local price + local toCraft = GetSkillReagentsTotal() + + local percentageValue = 0 + if toCraft > 0 then + percentageValue = math.floor((profit / toCraft) * 100 * 100 + 0.5) / 100 + end + + local priceText if profit >= 0 then - price = WHITE_FONT_COLOR:WrapTextInColorCode(GetMoneyString(profit, true)) + priceText = WHITE_FONT_COLOR:WrapTextInColorCode(GetMoneyString(profit, true)) else - price = RED_FONT_COLOR:WrapTextInColorCode("-" .. GetMoneyString(-profit, true)) + priceText = RED_FONT_COLOR:WrapTextInColorCode("-" .. GetMoneyString(-profit, true)) end - - return AUCTIONATOR_L_PROFIT_COLON .. " " .. price - + + local percentageText + if percentageValue >= 0 then + percentageText = WHITE_FONT_COLOR:WrapTextInColorCode(percentageValue .. "%") + else + percentageText = RED_FONT_COLOR:WrapTextInColorCode(percentageValue .. "%") + end + + return AUCTIONATOR_L_PROFIT_COLON .. " " .. priceText .. " (" .. percentageText .. ")" end function Auctionator.CraftingInfo.GetInfoText() diff --git a/Source_Mainline/CraftingInfo/Professions.lua b/Source_Mainline/CraftingInfo/Professions.lua index ee1ba2933..3bc40ad29 100644 --- a/Source_Mainline/CraftingInfo/Professions.lua +++ b/Source_Mainline/CraftingInfo/Professions.lua @@ -208,15 +208,28 @@ local function CheapestQualityCostString(schematicForm) end local function ProfitString(profit) - local price + local toCraft = GetSkillReagentsTotal() + + local percentageValue = 0 + if toCraft > 0 then + percentageValue = math.floor((profit / toCraft) * 100 * 100 + 0.5) / 100 + end + + local priceText if profit >= 0 then - price = WHITE_FONT_COLOR:WrapTextInColorCode(GetMoneyString(profit, true)) + priceText = WHITE_FONT_COLOR:WrapTextInColorCode(GetMoneyString(profit, true)) else - price = RED_FONT_COLOR:WrapTextInColorCode("-" .. GetMoneyString(-profit, true)) + priceText = RED_FONT_COLOR:WrapTextInColorCode("-" .. GetMoneyString(-profit, true)) end - - return AUCTIONATOR_L_PROFIT_COLON .. " " .. price - + + local percentageText + if percentageValue >= 0 then + percentageText = WHITE_FONT_COLOR:WrapTextInColorCode(percentageValue .. "%") + else + percentageText = RED_FONT_COLOR:WrapTextInColorCode(percentageValue .. "%") + end + + return AUCTIONATOR_L_PROFIT_COLON .. " " .. priceText .. " (" .. percentageText .. ")" end function Auctionator.CraftingInfo.GetInfoText(schematicForm, showProfit)