Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 101 additions & 7 deletions AllTheThings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4320,19 +4320,34 @@ local function GetCachedSearchResults(search, method, paramA, paramB, ...)
if #entries - containCount > 0 then
tinsert(info, { left = L["AND_"] .. (#entries - containCount) .. L["_MORE"] .. "..." });
end
if app.Settings:GetTooltipSetting("Currencies") then
local currencyCount = 0;
local calculateCurrencies, calculateReagents = app.Settings:GetTooltipSetting("Currencies"), app.Settings:GetTooltipSetting("Reagents");
if calculateCurrencies or calculateReagents then
local currencyCount, reagentCountMin, reagentCountMax = 0, 0, 0;
for i=1,#entries do
item = entries[i];
group = item.group;
if group.collectible and not group.collected then
local canBeBoughtFor = app.ItemCanBeBoughtWithCurrencyCount(group.itemID, paramB, costCollectibles);
currencyCount = currencyCount + canBeBoughtFor;
if group.collectible and not group.collected and group.itemID then
if calculateCurrencies then
local canBeBoughtFor = app.ItemCanBeBoughtWithCurrencyCount(group.itemID, paramB, costCollectibles);
currencyCount = currencyCount + canBeBoughtFor;
end
if calculateReagents then
local extraReagentMin, extraReagentMax = app.GetReagentNumToCraftItem(paramB, group.itemID, 1, {}, true)
reagentCountMin = reagentCountMin + extraReagentMin;
reagentCountMax = reagentCountMax + extraReagentMax;
end
end
end
if currencyCount > 0 then
tinsert(info, { left = L["CURRENCY_NEEDED_TO_BUY"], right = currencyCount });
end
if reagentCountMin > 0 or reagentCountMax > 0 then
if reagentCountMin == reagentCountMax then
tinsert(info, { left = L["REAGENTS_NEEDED_TO_CRAFT"], right = reagentCountMin });
else
tinsert(info, { left = L["REAGENTS_NEEDED_TO_CRAFT"], right = reagentCountMin .. '-' .. reagentCountMax });
end
end
end
end
end
Expand Down Expand Up @@ -4396,6 +4411,68 @@ app.ItemCanBeBoughtWithCurrencyCount = function(targetItemID, currencyItemID, co
end
return 0;
end
-- Calculates minimum and maximum amount of sourceItemID needed to craft targetItemID in a specific recipe (recipe is defined by list of reagents)
app.GetAbsoluteReagentNumInRecipe = function(sourceItemID, targetItemID, reagents, recipeCache, calculateNested)
local reagentMinCount, reagentMaxCount = 0, 0;

-- Doesn't make sense to handle recipes that require the item to create itself (like ore prospecting)
if #reagents == 1 and reagents[1][1] == targetItemID then
return 0, 0;
end

for i=1,#reagents do
local reagentID, quantity = unpack(reagents[i]);
if reagentID == sourceItemID then
reagentMinCount = reagentMinCount + quantity;
reagentMaxCount = reagentMaxCount + quantity;
else
if calculateNested then
local extraMin, extraMax = app.GetReagentNumToCraftItem(sourceItemID, reagentID, quantity, recipeCache, calculateNested);
reagentMinCount = reagentMinCount + extraMin;
reagentMaxCount = reagentMaxCount + extraMax;
end
end
end
return reagentMinCount, reagentMaxCount;
end
-- Calculates minimum and maximum amount of sourceItemID needed to craft targetItemID
app.GetReagentNumToCraftItem = function(sourceItemID, targetItemID, neededQuantity, recipeCache, calculateNested)
if targetItemID == nil then
return 0, 0;
end
neededQuantity = neededQuantity or 1;
recipeCache = recipeCache or {};
local reagentMinCount, reagentMaxCount = nil, nil;
local itemRecipes = app.GetDataSubMember("Recipes", targetItemID);
if itemRecipes then
for recipeID,info in pairs(itemRecipes) do
local reagents = info[1];
local producedMin, producedMax = unpack(info[2]);
local recipeResult = recipeCache[recipeID];
local recipeResultMin, recipeResultMax;

if recipeResult then
recipeResultMin, recipeResultMax = unpack(recipeResult);
else
-- This is a way to handle recursive recipes, specifically transmutations. It will return correct results.. right?
recipeCache[recipeID] = { 0, 0 };
recipeResultMin, recipeResultMax = app.GetAbsoluteReagentNumInRecipe(sourceItemID, targetItemID, reagents, recipeCache, calculateNested);
recipeCache[recipeID] = { recipeResultMin, recipeResultMax };
end

-- In some cases for multiple items the ceiling here will accumulate an error
local newMin = recipeResultMin * math.ceil(neededQuantity / producedMax);
local newMax = recipeResultMax * math.ceil(neededQuantity / producedMin);

if reagentMinCount == nil or newMin < reagentMinCount then reagentMinCount = newMin; end
if reagentMaxCount == nil or newMax > reagentMaxCount then reagentMaxCount = newMax; end
end
else
reagentMinCount = 0;
reagentMaxCount = 0;
end
return reagentMinCount, reagentMaxCount;
end
app.BuildCrafted_IncludedItems = {};
-- Appends sub-groups into the item group based on what the item is used to craft (via ReagentCache)
app.BuildCrafted = function(item)
Expand Down Expand Up @@ -18683,6 +18760,7 @@ customWindowUpdates["Tradeskills"] = function(self, force, got)
local C_TradeSkillUI_GetRecipeInfo = C_TradeSkillUI.GetRecipeInfo;
local C_TradeSkillUI_GetRecipeItemLink = C_TradeSkillUI.GetRecipeItemLink;
local C_TradeSkillUI_GetRecipeNumReagents = C_TradeSkillUI.GetRecipeNumReagents;
local C_TradeSkillUI_GetRecipeNumItemsProduced = C_TradeSkillUI.GetRecipeNumItemsProduced;
local C_TradeSkillUI_GetRecipeReagentInfo = C_TradeSkillUI.GetRecipeReagentInfo;
local C_TradeSkillUI_GetRecipeReagentItemLink = C_TradeSkillUI.GetRecipeReagentItemLink;

Expand Down Expand Up @@ -18741,6 +18819,7 @@ customWindowUpdates["Tradeskills"] = function(self, force, got)
-- Cache learned recipes
local learned, recipeID = {};
local reagentCache = app.GetDataMember("Reagents", {});
local recipesCache = app.GetDataMember("Recipes", {});
local recipeIDs = C_TradeSkillUI.GetAllRecipeIDs();
local acctSpells, charSpells = ATTAccountWideData.Spells, app.CurrentCharacter.Spells;
local skipcaching;
Expand Down Expand Up @@ -18792,8 +18871,9 @@ customWindowUpdates["Tradeskills"] = function(self, force, got)
local recipeLink = C_TradeSkillUI_GetRecipeItemLink(recipeID);
local craftedItemID = recipeLink and GetItemInfoInstant(recipeLink);
if craftedItemID then
local reagentLink, itemID, reagentCount;
for i=1,C_TradeSkillUI_GetRecipeNumReagents(recipeID) do
local reagentLink, itemID, reagentCount, minItem, maxItem;
local recipeNumReagents = C_TradeSkillUI_GetRecipeNumReagents(recipeID);
for i=1,recipeNumReagents do
reagentCount = select(3, C_TradeSkillUI_GetRecipeReagentInfo(recipeID, i));
reagentLink = C_TradeSkillUI_GetRecipeReagentItemLink(recipeID, i);
itemID = reagentLink and GetItemInfoInstant(reagentLink);
Expand All @@ -18811,11 +18891,24 @@ customWindowUpdates["Tradeskills"] = function(self, force, got)
reagentCache[itemID][1][recipeID] = nil;
reagentCache[itemID][2][craftedItemID] = nil;
end
-- TODO: no idea if this is the correct way
if recipesCache[craftedItemID] then
recipesCache[craftedItemID][recipeID] = nil;
end
else
if not reagentCache[itemID] then reagentCache[itemID] = { {}, {} }; end
if not recipesCache[craftedItemID] then recipesCache[craftedItemID] = {}; end
if not recipesCache[craftedItemID][recipeID] then recipesCache[craftedItemID][recipeID] = { {}, {} }; end
reagentCache[itemID][1][recipeID] = { craftedItemID, reagentCount };
-- if craftedItemID then reagentCache[itemID][2][craftedItemID] = reagentCount; end
reagentCache[itemID][2][craftedItemID] = reagentCount;
minItem, maxItem = C_TradeSkillUI_GetRecipeNumItemsProduced(recipeID);

-- TODO: add other WoD and similar recipes that can produce more items than what API returns
if recipeID == 171690 then maxItem = 20; end

recipesCache[craftedItemID][recipeID][1][i] = { itemID, reagentCount };
recipesCache[craftedItemID][recipeID][2] = { minItem, maxItem };
end
end
end
Expand Down Expand Up @@ -20727,6 +20820,7 @@ app.Startup = function()
"Position",
"RandomSearchFilter",
"Reagents",
"Recipes",
}) do
rawset(oldsettings, key, rawget(AllTheThingsAD, key));
end
Expand Down
35 changes: 35 additions & 0 deletions Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ local TooltipSettingsBase = {
["Warn:Difficulty"] = true,
["Warn:Removed"] = true,
["Currencies"] = true,
["Reagents"] = false,
},
};

Expand Down Expand Up @@ -3673,6 +3674,40 @@ end);
ShowCurrencyCalculationsCheckBox:SetATTTooltip(L["SHOW_CURRENCY_CALCULATIONS_CHECKBOX_TOOLTIP"]);
ShowCurrencyCalculationsCheckBox:SetPoint("TOPLEFT", ShowModelsCheckBox, "BOTTOMLEFT", 0, 4);

local ShowReagentsCalculationsCheckBox = settings:CreateCheckBox(L["SHOW_REAGENTS_CALCULATIONS_CHECKBOX"],
function(self)
self:SetChecked(settings:GetTooltipSetting("Reagents"));
if not settings:GetTooltipSetting("Enabled") then
self:Disable();
self:SetAlpha(0.2);
else
self:Enable();
self:SetAlpha(1);
end
end,
function(self)
settings:SetTooltipSetting("Reagents", self:GetChecked());
end);
ShowReagentsCalculationsCheckBox:SetATTTooltip(L["SHOW_REAGENTS_CALCULATIONS_CHECKBOX_TOOLTIP"]);
ShowReagentsCalculationsCheckBox:SetPoint("TOPLEFT", ShowCurrencyCalculationsCheckBox, "BOTTOMLEFT", 0, 4);

-- local ShowPlainReagentsCalculationsCheckBox = settings:CreateCheckBox("Display plain materialsin",
-- function(self)
-- self:SetChecked(settings:GetTooltipSetting("ShowIconOnly"));
-- if not settings:GetTooltipSetting("Enabled") or not settings:GetTooltipSetting("Progress") then
-- self:Disable();
-- self:SetAlpha(0.2);
-- else
-- self:Enable();
-- self:SetAlpha(1);
-- end
-- end,
-- function(self)
-- settings:SetTooltipSetting("ShowIconOnly", self:GetChecked());
-- end);
-- ShowPlainReagentsCalculationsCheckBox:SetATTTooltip(L["ICON_ONLY_CHECKBOX_TOOLTIP"]);
-- ShowPlainReagentsCalculationsCheckBox:SetPoint("TOPLEFT", ShowReagentsCalculationsCheckBox, "BOTTOMLEFT", 8, 4);

local ShowSharedAppearancesCheckBox = settings:CreateCheckBox(L["SHARED_APPEARANCES_CHECKBOX"],
function(self)
self:SetChecked(settings:GetTooltipSetting("SharedAppearances"));
Expand Down
3 changes: 3 additions & 0 deletions locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ app.L = {
["MAIN_LIST_REQUIRES_REFRESH"] = "[Open Main list to update progress]";
["DOES_NOT_CONTRIBUTE_TO_PROGRESS"] = "|cffe08207This group and its content do not contribute to the progress of this window!|r";
["CURRENCY_NEEDED_TO_BUY"] = "Items needed to buy not collected Things";
["REAGENTS_NEEDED_TO_CRAFT"] = "Items needed to craft not collected Things";

-- Item Filter Window
["ITEM_FILTER_TEXT"] = "Item Filters";
Expand Down Expand Up @@ -451,6 +452,8 @@ app.L = {
["SHOW_MODELS_CHECKBOX_TOOLTIP"] = "Enable this option to show models within a preview instead of the icon on the tooltip.\n\nThis option may assist you in identifying what a Rare Spawn or Vendor looks like. It might be a good idea to keep this turned on for that reason.";
["SHOW_CURRENCY_CALCULATIONS_CHECKBOX"] = "Currency calculation";
["SHOW_CURRENCY_CALCULATIONS_CHECKBOX_TOOLTIP"] = "Enable this option to show the approximate amount of items/currency required to buy Uncollected Things.\n\nOnly those collectible Things that can be directly purchased for an item/currency are counted. Containers that do not give items with a 100% chance are not counted.";
["SHOW_REAGENTS_CALCULATIONS_CHECKBOX"] = "Reagents calculation";
["SHOW_REAGENTS_CALCULATIONS_CHECKBOX_TOOLTIP"] = "Enable this option to show the approximate minimum and maximum amount of items required to craft Uncollected Things.\n\nTODO";
["SHARED_APPEARANCES_CHECKBOX"] = "Shared Appearances";
["SHARED_APPEARANCES_CHECKBOX_TOOLTIP"] = "Enable this option to see items that share a similar appearance in the tooltip.\n\nNOTE: Items that do not match the armor type are displayed in the list. This is to help you diagnose the Collection progress.\n\nIf you are ever confused by this, as of ATT v1.5.0, you can Right Click the item to open the item and its Shared Appearances into their own standalone Mini List.";
["INCLUDE_ORIGINAL_CHECKBOX"] = "Original Source";
Expand Down
3 changes: 3 additions & 0 deletions locales/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ local L = app.L;
L.MAIN_LIST_REQUIRES_REFRESH = "[Откройте Основной список, чтобы обновить прогресс]";
L.DOES_NOT_CONTRIBUTE_TO_PROGRESS = "|cffe08207Эта группа и её содержимое не влияют на прогресс данного окна!|r";
L.CURRENCY_NEEDED_TO_BUY = "Необходимо для покупки Не Собранных Штучек";
L.REAGENTS_NEEDED_TO_CRAFT = "Необходимо для создания Не Собранных Штучек";

-- Item Filter Window
L.ITEM_FILTER_TEXT = "Фильтровать предметы";
Expand Down Expand Up @@ -413,6 +414,8 @@ local L = app.L;
L.SHOW_MODELS_CHECKBOX_TOOLTIP = "Включите данную опцию, если Вы хотите видеть в подсказке модель вместо иконки.\n\nДанная настройка может помочь идентифицировать Редкого монстра или Торговца по внешнему виду. Возможно, Вы захотите оставить опцию включенной по этой причине.";
L.SHOW_CURRENCY_CALCULATIONS_CHECKBOX = "Рассчет покупок";
L.SHOW_CURRENCY_CALCULATIONS_CHECKBOX_TOOLTIP = "Включите данную опцию, если Вы хотите видеть в подсказке приблизительное количество предметов/валюты, необходимое для покупки Не Собранных Штучек.\n\nПодсчет ведется только для тех Штучек, которые можно напрямую купить за предмет/валюту. Контейнеры, дающие предмет(-ы) не с 100%-ым шансом, не учитываются.";
L.SHOW_REAGENTS_CALCULATIONS_CHECKBOX = "Расчет реагентов";
L.SHOW_REAGENTS_CALCULATIONS_CHECKBOX_TOOLTIP = "Включите данную опцию, если Вы хотите видеть в подсказке приблизительное количество предметов/валюты, необходимое для создания Не Собранных Штучек.\n\nTODO";
L.SHARED_APPEARANCES_CHECKBOX = "Общие Облики";
L.SHARED_APPEARANCES_CHECKBOX_TOOLTIP = "Включите данную опцию, если Вы хотите видеть в подсказке предметы, которые имеют общий облик.\n\nПримечание: Предметы, которые не совпадают по типу брони отображаются в списке для того, чтобы определить прогресс Коллекции.\n\nЕсли Вы путаетесь в них, начиная с ATT v1.5.0, Вы можете Правым Кликом по предмету \"открыть\" предмет и его собственный Мини Список со всеми Общими Обликами.";
L.INCLUDE_ORIGINAL_CHECKBOX = "Оригинал";
Expand Down