Skip to content

Commit

Permalink
edit recipe changes (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
derfloh205 authored Oct 4, 2024
1 parent 197328e commit ea1a344
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CraftSim.toc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Title: CraftSim
## Notes: Calculates the average profit based on your profession stats and other tools for the war within gold making
## Author: genju
## Version: 18.2.6
## Version: 18.2.7
## X-Curse-Project-ID: 705015
## X-Wago-ID: 0mNwaPKo
## X-WoWI-ID: 26519
Expand Down
3 changes: 3 additions & 0 deletions Data/News.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function CraftSim.NEWS:GET_NEWS(itemMap)
local news = {
f.bb(" Hello and thank you for using CraftSim!\n"),
f.bb(" ( You are awesome! )"),
newP("18.2.7"),
f.s .. f.bb("Craft Queue - Edit Recipe"),
f.a .. "Fixed and reworked the " .. f.gold("Optimize") .. " Button",
newP("18.2.6"),
f.s .. "Testing new MenuUtil Context Menu and more",
f.s .. f.g("Queue Patron Orders") .. " Options added",
Expand Down
2 changes: 1 addition & 1 deletion Locals/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ greater or equal the configured sale rate threshold.
[CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_FINISHING_REAGENTS_LABEL] = "Finishing Reagents",
[CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_SPARK_LABEL] = "Spark",
[CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_PROFESSION_GEAR_LABEL] = "Profession Gear",
[CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_OPTIMIZE_PROFIT_BUTTON] = "Optimize Profit",
[CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_OPTIMIZE_PROFIT_BUTTON] = "Optimize",
[CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_CRAFTING_COSTS_LABEL] = "Crafting Costs: ",
[CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_AVERAGE_PROFIT_LABEL] = "Average Profit: ",
[CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_RESULTS_LABEL] = "Results",
Expand Down
96 changes: 86 additions & 10 deletions Modules/CraftQueue/UI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ end
---@return CraftSim.CRAFTQ.EditRecipeFrame editRecipeFrame
function CraftSim.CRAFTQ.UI:InitEditRecipeFrame(parent, anchorParent)
local editFrameX = 600
local editFrameY = 330
local editFrameY = 350
---@class CraftSim.CRAFTQ.EditRecipeFrame : GGUI.Frame
local editRecipeFrame = GGUI.Frame {
parent = parent, anchorParent = anchorParent,
Expand Down Expand Up @@ -1301,22 +1301,87 @@ function CraftSim.CRAFTQ.UI:InitEditRecipeFrame(parent, anchorParent)

editRecipeFrame.content.optimizeProfitButton = GGUI.Button {
parent = editRecipeFrame.content, anchorParent = editRecipeFrame.content.professionGearTitle.frame, anchorA = "TOPLEFT", anchorB = "BOTTOMLEFT", offsetY = -50,
label = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_OPTIMIZE_PROFIT_BUTTON), adjustWidth = true,
clickCallback = function()
label = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_OPTIMIZE_PROFIT_BUTTON), sizeX = 150,
clickCallback = function(optimizeButton)
if editRecipeFrame.craftQueueItem and editRecipeFrame.craftQueueItem.recipeData then
editRecipeFrame.craftQueueItem.recipeData:OptimizeProfit({
optimizeGear = true,
optimizeReagents = true,
})
CraftSim.CRAFTQ.UI:UpdateFrameListByCraftQueue()
CraftSim.CRAFTQ.UI:UpdateEditRecipeFrameDisplay(editRecipeFrame.craftQueueItem)
local recipeData = editRecipeFrame.craftQueueItem.recipeData
local optimizeProfessionGear = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_PROFESSION_GEAR")
local optimizeConcentration = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_CONCENTRATION")

if optimizeProfessionGear then
recipeData:OptimizeGear(CraftSim.TOPGEAR:GetSimMode(CraftSim.TOPGEAR.SIM_MODES.PROFIT))
end

RunNextFrame(function()
recipeData:OptimizeReagents {
highestProfit = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_TOP_PROFIT_QUALITY"),
}

if recipeData.supportsQualities and optimizeConcentration then
optimizeButton:SetEnabled(false)
recipeData:OptimizeConcentration {
frameDistributedCallback = function()
CraftSim.CRAFTQ.UI:UpdateFrameListByCraftQueue()
CraftSim.CRAFTQ.UI:UpdateEditRecipeFrameDisplay(editRecipeFrame.craftQueueItem)
optimizeButton:SetEnabled(true)
optimizeButton:SetText(L(CraftSim.CONST.TEXT
.CRAFT_QUEUE_EDIT_RECIPE_OPTIMIZE_PROFIT_BUTTON))
end,
progressUpdateCallback = function(progress)
optimizeButton:SetText(string.format("%.0f%%", progress))
end
}
else
CraftSim.CRAFTQ.UI:UpdateFrameListByCraftQueue()
CraftSim.CRAFTQ.UI:UpdateEditRecipeFrameDisplay(editRecipeFrame.craftQueueItem)
end
end)
end
end
}

editRecipeFrame.content.optimizeProfitButtonOptions = GGUI.Button {
parent = editRecipeFrame.content, anchorPoints = { { anchorParent = editRecipeFrame.content.optimizeProfitButton.frame, anchorA = "LEFT", anchorB = "RIGHT", offsetX = 5 } },
buttonTextureOptions = CraftSim.CONST.BUTTON_TEXTURE_OPTIONS.OPTIONS, sizeX = 20, sizeY = 20,
cleanTemplate = true,
clickCallback = function(_, _)
MenuUtil.CreateContextMenu(UIParent, function(ownerRegion, rootDescription)
local recipeData = editRecipeFrame.craftQueueItem.recipeData
if recipeData.supportsQualities then
rootDescription:CreateCheckbox(
"Optimize " .. f.g("Top Profit Quality"),
function()
return CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_TOP_PROFIT_QUALITY")
end, function()
local value = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_TOP_PROFIT_QUALITY")
CraftSim.DB.OPTIONS:Save("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_TOP_PROFIT_QUALITY", not value)
end)
end
rootDescription:CreateCheckbox(
"Optimize " .. f.bb("Profession Gear"),
function()
return CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_PROFESSION_GEAR")
end, function()
local value = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_PROFESSION_GEAR")
CraftSim.DB.OPTIONS:Save("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_PROFESSION_GEAR", not value)
end)
if recipeData.supportsQualities then
rootDescription:CreateCheckbox(
"Optimize " .. f.gold("Concentration"),
function()
return CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_CONCENTRATION")
end, function()
local value = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_CONCENTRATION")
CraftSim.DB.OPTIONS:Save("CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_CONCENTRATION", not value)
end)
end
end)
end
}

editRecipeFrame.content.craftingCostsTitle = GGUI.Text {
parent = editRecipeFrame.content, anchorParent = editRecipeFrame.content, anchorA = "BOTTOM", anchorB = "BOTTOM", offsetX = -30,
offsetY = 40, text = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_CRAFTING_COSTS_LABEL),
offsetY = 60, text = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_EDIT_RECIPE_CRAFTING_COSTS_LABEL),
}
editRecipeFrame.content.craftingCostsValue = GGUI.Text {
parent = editRecipeFrame.content, anchorParent = editRecipeFrame.content.craftingCostsTitle.frame, anchorA = "LEFT", anchorB = "RIGHT", offsetX = 5,
Expand All @@ -1330,6 +1395,14 @@ function CraftSim.CRAFTQ.UI:InitEditRecipeFrame(parent, anchorParent)
parent = editRecipeFrame.content, anchorParent = editRecipeFrame.content.averageProfitTitle.frame, anchorA = "LEFT", anchorB = "RIGHT", offsetX = 5,
text = CraftSim.UTIL:FormatMoney(0, true), justifyOptions = { type = "H", align = "LEFT" }, scale = 0.9, offsetY = -1,
}
editRecipeFrame.content.concentrationValueTitle = GGUI.Text {
parent = editRecipeFrame.content, anchorParent = editRecipeFrame.content.averageProfitTitle.frame, anchorA = "TOPRIGHT", anchorB = "BOTTOMRIGHT",
offsetY = -5, text = "Concentration Value:",
}
editRecipeFrame.content.concentrationValue = GGUI.Text {
parent = editRecipeFrame.content, anchorParent = editRecipeFrame.content.concentrationValueTitle.frame, anchorA = "LEFT", anchorB = "RIGHT", offsetX = 5,
text = CraftSim.UTIL:FormatMoney(0, true), justifyOptions = { type = "H", align = "LEFT" }, scale = 0.9, offsetY = -1,
}



Expand Down Expand Up @@ -1633,6 +1706,9 @@ function CraftSim.CRAFTQ.UI:UpdateEditRecipeFrameDisplay(craftQueueItem)
end
editRecipeFrame.content.craftingCostsValue:SetText(GUTIL:ColorizeText(
CraftSim.UTIL:FormatMoney(recipeData.priceData.craftingCosts), GUTIL.COLORS.RED) .. concentrationCostText)
local concentrationValue = CraftSim.AVERAGEPROFIT:GetConcentrationWeight(recipeData,
recipeData.averageProfitCached)
editRecipeFrame.content.concentrationValue:SetText(CraftSim.UTIL:FormatMoney(concentrationValue, true))

local reagentFrames = editRecipeFrame.content.reagentFrames

Expand Down
6 changes: 6 additions & 0 deletions Util/Const.lua
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ CraftSim.CONST.GENERAL_OPTIONS = {
CRAFTQUEUE_PATRON_ORDERS_IGNORE_SPARK_RECIPES = "CRAFTQUEUE_PATRON_ORDERS_IGNORE_SPARK_RECIPES",
CRAFTQUEUE_PATRON_ORDERS_KNOWLEDGE_POINTS_ONLY = "CRAFTQUEUE_PATRON_ORDERS_KNOWLEDGE_POINTS_ONLY",
CRAFTQUEUE_PATRON_ORDERS_ALLOW_CONCENTRATION = "CRAFTQUEUE_PATRON_ORDERS_ALLOW_CONCENTRATION",
CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_PROFESSION_GEAR = "CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_PROFESSION_GEAR",
CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_CONCENTRATION = "CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_CONCENTRATION",
CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_TOP_PROFIT_QUALITY = "CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_TOP_PROFIT_QUALITY",

-- COST OPTIMIZATION
COST_OPTIMIZATION_AUTOMATIC_SUB_RECIPE_OPTIMIZATION = "COST_OPTIMIZATION_AUTOMATIC_SUB_RECIPE_OPTIMIZATION",
Expand Down Expand Up @@ -502,6 +505,9 @@ CraftSim.CONST.GENERAL_OPTIONS_DEFAULTS = {
[CraftSim.CONST.GENERAL_OPTIONS.CRAFTQUEUE_PATRON_ORDERS_IGNORE_SPARK_RECIPES] = true,
[CraftSim.CONST.GENERAL_OPTIONS.CRAFTQUEUE_PATRON_ORDERS_KNOWLEDGE_POINTS_ONLY] = false,
[CraftSim.CONST.GENERAL_OPTIONS.CRAFTQUEUE_PATRON_ORDERS_ALLOW_CONCENTRATION] = true,
[CraftSim.CONST.GENERAL_OPTIONS.CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_PROFESSION_GEAR] = true,
[CraftSim.CONST.GENERAL_OPTIONS.CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_CONCENTRATION] = true,
[CraftSim.CONST.GENERAL_OPTIONS.CRAFTQUEUE_EDIT_RECIPE_OPTIMIZE_TOP_PROFIT_QUALITY] = true,

-- COST OPTIMIZATION
[CraftSim.CONST.GENERAL_OPTIONS.COST_OPTIMIZATION_AUTOMATIC_SUB_RECIPE_OPTIMIZATION] = false,
Expand Down

0 comments on commit ea1a344

Please sign in to comment.