From ea1a344681afa58e2697663f43270e4e44bb4819 Mon Sep 17 00:00:00 2001 From: genjuwow Date: Fri, 4 Oct 2024 13:12:50 +0200 Subject: [PATCH] edit recipe changes (#605) --- CraftSim.toc | 2 +- Data/News.lua | 3 ++ Locals/enUS.lua | 2 +- Modules/CraftQueue/UI.lua | 96 +++++++++++++++++++++++++++++++++++---- Util/Const.lua | 6 +++ 5 files changed, 97 insertions(+), 12 deletions(-) diff --git a/CraftSim.toc b/CraftSim.toc index eb9c2888..b13de88a 100644 --- a/CraftSim.toc +++ b/CraftSim.toc @@ -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 diff --git a/Data/News.lua b/Data/News.lua index ea4039cd..5d843198 100644 --- a/Data/News.lua +++ b/Data/News.lua @@ -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", diff --git a/Locals/enUS.lua b/Locals/enUS.lua index 7634290d..a3c1e003 100644 --- a/Locals/enUS.lua +++ b/Locals/enUS.lua @@ -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", diff --git a/Modules/CraftQueue/UI.lua b/Modules/CraftQueue/UI.lua index d560f0c6..d1c3c18c 100644 --- a/Modules/CraftQueue/UI.lua +++ b/Modules/CraftQueue/UI.lua @@ -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, @@ -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, @@ -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, + } @@ -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 diff --git a/Util/Const.lua b/Util/Const.lua index 1098a817..bad9a949 100644 --- a/Util/Const.lua +++ b/Util/Const.lua @@ -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", @@ -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,