Skip to content

Commit bb9b0b3

Browse files
authored
Concentration Toggle (#374)
1 parent 97acaf8 commit bb9b0b3

File tree

5 files changed

+43
-11
lines changed

5 files changed

+43
-11
lines changed

CraftSim.toc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## Title: CraftSim
55
## Notes: Calculates the average profit based on your profession stats and other tools for dragonflight gold making
66
## Author: genju
7-
## Version: 17.0.10
7+
## Version: 17.1.0
88
## X-Curse-Project-ID: 705015
99
## X-Wago-ID: 0mNwaPKo
1010
## X-WoWI-ID: 26519

Data/News.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ function CraftSim.NEWS:GET_NEWS(itemMap)
1515
local news = {
1616
f.bb(" Hello and thank you for using CraftSim!\n"),
1717
f.bb(" ( You are awesome! )"),
18-
newP("17.0.10"),
18+
newP("17.1.0"),
19+
f.P .. f.bb("RecipeScan") .. " now has a " .. f.gold("Concentration ") .. "Toggle",
1920
f.p .. "Fixed " .. f.bb("OptionalReagents") .. " difficulty in simulation mode",
2021
newP("17.0.9"),
2122
f.p .. "Fixed " .. f.bb("TSM Price Expression ") .. "for Results used for Materials",

Modules/AverageProfit/AverageProfit.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ end
6969
---@param recipeData CraftSim.RecipeData
7070
---@param baseAverageProfit number
7171
---@return number statWeight
72+
---@return number averageProfitConcentration
7273
function CraftSim.AVERAGEPROFIT:GetConcentrationWeight(recipeData, baseAverageProfit)
7374
if not recipeData.supportsQualities or recipeData.concentrating or recipeData.concentrationCost <= 0 then
7475
return 0
@@ -81,7 +82,7 @@ function CraftSim.AVERAGEPROFIT:GetConcentrationWeight(recipeData, baseAveragePr
8182
local profitDiff = averageProfitConcentration - baseAverageProfit
8283
local statWeight = profitDiff / recipeData.concentrationCost
8384
recipeData.concentrating = false
84-
return statWeight
85+
return statWeight, averageProfitConcentration
8586
end
8687

8788
---@param recipeData CraftSim.RecipeData

Modules/RecipeScan/UI.lua

+36-8
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,16 @@ function CraftSim.RECIPE_SCAN.UI:CreateProfessionTabContent(row, content)
340340
end
341341
})
342342

343+
content.concentrationToggleCB = GGUI.Checkbox {
344+
parent = content, anchorParent = content.cancelScanButton.frame, anchorA = "LEFT", anchorB = "RIGHT",
345+
labelOptions = { text = GUTIL:IconToText(CraftSim.CONST.CONCENTRATION_ICON, 20, 20) .. " Concentration" },
346+
tooltip = "Toggle Concentration",
347+
initialValue = CraftSim.DB.OPTIONS:Get("RECIPESCAN_ENABLE_CONCENTRATION"),
348+
clickCallback = function(_, checked)
349+
CraftSim.DB.OPTIONS:Save("RECIPESCAN_ENABLE_CONCENTRATION", checked)
350+
end
351+
}
352+
343353
content.resultAmount = GGUI.Text {
344354
parent = content, anchorParent = content.scanButton.frame, anchorA = "RIGHT", anchorB = "LEFT",
345355
offsetX = -15, justifyOptions = { type = "H", align = "RIGHT" }, text = "",
@@ -477,12 +487,16 @@ function CraftSim.RECIPE_SCAN.UI:CreateProfessionTabContent(row, content)
477487
parent = concentrationCostColumn,
478488
anchorParent = concentrationCostColumn,
479489
anchorA = "LEFT",
480-
anchorB = "LEFT"
490+
anchorB = "LEFT",
491+
scale = 0.95,
481492
})
482493

483-
---@type GGUI.Text
484494
averageProfitColumn.text = GGUI.Text({
485-
parent = averageProfitColumn, anchorParent = averageProfitColumn, anchorA = "LEFT", anchorB = "LEFT"
495+
parent = averageProfitColumn,
496+
anchorParent = averageProfitColumn,
497+
anchorA = "LEFT",
498+
anchorB = "LEFT",
499+
scale = 0.95,
486500
})
487501

488502
topGearColumn.gear2Icon = GGUI.Icon({
@@ -800,6 +814,8 @@ function CraftSim.RECIPE_SCAN.UI:AddRecipe(row, recipeData)
800814

801815
row.recipeData = recipeData
802816

817+
local enableConcentration = CraftSim.DB.OPTIONS:Get("RECIPESCAN_ENABLE_CONCENTRATION")
818+
803819
local recipeRarity = recipeData.resultData.expectedItem:GetItemQualityColor()
804820

805821
local cooldownInfoText = ""
@@ -811,27 +827,39 @@ function CraftSim.RECIPE_SCAN.UI:AddRecipe(row, recipeData)
811827
"(" .. currentCharges .. "/" .. cooldownData.maxCharges .. ")"
812828
end
813829

814-
815830
recipeColumn.text:SetText(recipeRarity.hex .. recipeData.recipeName .. "|r" .. cooldownInfoText)
816831

817832
learnedColumn:SetLearned(recipeData.learned)
818833

819-
expectedResultColumn.itemIcon:SetItem(recipeData.resultData.expectedItem)
834+
if enableConcentration then
835+
expectedResultColumn.itemIcon:SetItem(recipeData.resultData.expectedItemConcentration)
836+
else
837+
expectedResultColumn.itemIcon:SetItem(recipeData.resultData.expectedItem)
838+
end
839+
820840

821-
local averageProfit = recipeData:GetAverageProfit()
822841
local relativeTo = nil
823842
if showProfit then
824843
relativeTo = recipeData.priceData.craftingCosts
825844
end
826-
averageProfitColumn.text:SetText(GUTIL:FormatMoney(averageProfit, true, relativeTo, true))
845+
846+
local averageProfit = recipeData:GetAverageProfit()
847+
row.concentrationWeight, row.concentrationProfit = CraftSim.AVERAGEPROFIT:GetConcentrationWeight(recipeData,
848+
averageProfit)
849+
850+
if enableConcentration and row.concentrationProfit then
851+
averageProfit = row.concentrationProfit
852+
end
853+
827854
row.averageProfit = averageProfit
828855
row.relativeProfit = GUTIL:GetPercentRelativeTo(averageProfit, recipeData.priceData.craftingCosts)
829-
row.concentrationWeight = CraftSim.AVERAGEPROFIT:GetConcentrationWeight(recipeData, averageProfit)
830856
recipeData.resultData:Update() -- switch back
831857
row.concentrationCost = recipeData.concentrationCost
832858
concentrationCostColumn.text:SetText(row.concentrationCost)
833859
concentrationValueColumn.text:SetText(GUTIL:FormatMoney(row.concentrationWeight, true))
834860

861+
averageProfitColumn.text:SetText(GUTIL:FormatMoney(averageProfit, true, relativeTo, true))
862+
835863
if CraftSim.DB.OPTIONS:Get("RECIPESCAN_OPTIMIZE_PROFESSION_TOOLS") then
836864
if recipeData.professionGearSet:IsEquipped() then
837865
topGearColumn.equippedText:Show()

Util/Const.lua

+2
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ CraftSim.CONST.GENERAL_OPTIONS = {
348348
RECIPESCAN_OPTIMIZE_SUBRECIPES = "RECIPESCAN_OPTIMIZE_SUBRECIPES",
349349
RECIPESCAN_USE_INSIGHT = "RECIPESCAN_USE_INSIGHT",
350350
RECIPESCAN_INCLUDED_PROFESSIONS = "RECIPESCAN_INCLUDED_PROFESSIONS",
351+
RECIPESCAN_ENABLE_CONCENTRATION = "RECIPESCAN_ENABLE_CONCENTRATION",
351352

352353
-- PROFIT CALCULATION
353354
PROFIT_CALCULATION_MULTICRAFT_CONSTANT = "PROFIT_CALCULATION_MULTICRAFT_CONSTANT",
@@ -436,6 +437,7 @@ CraftSim.CONST.GENERAL_OPTIONS_DEFAULTS = {
436437
[CraftSim.CONST.GENERAL_OPTIONS.RECIPESCAN_OPTIMIZE_SUBRECIPES] = false,
437438
[CraftSim.CONST.GENERAL_OPTIONS.RECIPESCAN_USE_INSIGHT] = false,
438439
[CraftSim.CONST.GENERAL_OPTIONS.RECIPESCAN_INCLUDED_PROFESSIONS] = {},
440+
[CraftSim.CONST.GENERAL_OPTIONS.RECIPESCAN_ENABLE_CONCENTRATION] = true,
439441

440442
-- PROFIT CALCULATION
441443
[CraftSim.CONST.GENERAL_OPTIONS.PROFIT_CALCULATION_MULTICRAFT_CONSTANT] = CraftSim.CONST.MULTICRAFT_CONSTANT,

0 commit comments

Comments
 (0)