Skip to content

Commit 197328e

Browse files
committed
enhancements
1 parent 6eca589 commit 197328e

File tree

6 files changed

+219
-53
lines changed

6 files changed

+219
-53
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 the war within gold making
66
## Author: genju
7-
## Version: 18.2.5.1
7+
## Version: 18.2.6
88
## X-Curse-Project-ID: 705015
99
## X-Wago-ID: 0mNwaPKo
1010
## X-WoWI-ID: 26519

Data/News.lua

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ function CraftSim.NEWS:GET_NEWS(itemMap)
1717
local news = {
1818
f.bb(" Hello and thank you for using CraftSim!\n"),
1919
f.bb(" ( You are awesome! )"),
20+
newP("18.2.6"),
21+
f.s .. "Testing new MenuUtil Context Menu and more",
22+
f.s .. f.g("Queue Patron Orders") .. " Options added",
23+
f.a .. "- Ignore " .. f.e("Spark") .. " Recipes",
24+
f.a .. "- " .. f.bb("Knowledge Point Rewards") .. " only",
2025
newP("18.2.5"),
2126
f.s .. "Filter Buttons now use the new Menu Style",
2227
f.p .. "Fixed some button interactions",

Locals/enUS.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,9 @@ function CraftSim.LOCAL_EN:GetData()
576576
[CraftSim.CONST.TEXT.CRAFT_QUEUE_CRAFT_BUTTON_ROW_LABEL] = "Craft",
577577
[CraftSim.CONST.TEXT.CRAFT_QUEUE_CRAFT_BUTTON_ROW_LABEL_WRONG_GEAR] = "Wrong Tools",
578578
[CraftSim.CONST.TEXT.CRAFT_QUEUE_CRAFT_BUTTON_ROW_LABEL_NO_REAGENTS] = "No Reagents",
579-
[CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_OPEN_RECIPE_BUTTON_LABEL] = "Add Open Recipe",
580-
[CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_FIRST_CRAFTS_BUTTON_LABEL] = "Add First Crafts",
581-
[CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_PATRON_ORDERS_BUTTON_LABEL] = "Add Patron Orders",
579+
[CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_OPEN_RECIPE_BUTTON_LABEL] = "Queue Open Recipe",
580+
[CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_FIRST_CRAFTS_BUTTON_LABEL] = "Queue First Crafts",
581+
[CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_PATRON_ORDERS_BUTTON_LABEL] = "Queue Patron Orders",
582582
[CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_PATRON_ORDERS_ALLOW_CONCENTRATION_CHECKBOX] = "Allow Concentration",
583583
[CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_PATRON_ORDERS_ALLOW_CONCENTRATION_TOOLTIP] =
584584
"If minimum quality cannot be reached, use " .. f.l("Concentration") .. " if possible",

Modules/CraftQueue/CraftQueue.lua

+50-10
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,35 @@ function CraftSim.CRAFTQ:AddPatronOrders()
173173
local recipeInfo = C_TradeSkillUI.GetRecipeInfo(order.spellID)
174174
if recipeInfo and recipeInfo.learned then
175175
local recipeData = CraftSim.RecipeData({ recipeID = order.spellID })
176+
177+
if CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_PATRON_ORDERS_IGNORE_SPARK_RECIPES") then
178+
if recipeData.reagentData:HasSparkSlot() then
179+
if recipeData.reagentData.sparkReagentSlot.activeReagent then
180+
if not recipeData.reagentData.sparkReagentSlot.activeReagent:IsOrderReagentIn(recipeData) then
181+
distributor:Continue()
182+
return
183+
end
184+
end
185+
end
186+
end
187+
176188
recipeData:SetOrder(order)
177189

190+
if CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_PATRON_ORDERS_KNOWLEDGE_POINTS_ONLY") then
191+
if recipeData.orderData and recipeData.orderData.npcOrderRewards then
192+
local hasKnowledgeReward = GUTIL:Some(recipeData.orderData.npcOrderRewards,
193+
function(reward)
194+
local itemID = GUTIL:GetItemIDByLink(reward.itemLink)
195+
return tContains(CraftSim.CONST.PATRON_ORDERS_KNOWLEDGE_REWARD_ITEMS,
196+
itemID)
197+
end)
198+
if not hasKnowledgeReward then
199+
distributor:Continue()
200+
return
201+
end
202+
end
203+
end
204+
178205
recipeData:SetCheapestQualityReagentsMax() -- considers patron reagents
179206
recipeData:Update()
180207

@@ -812,17 +839,30 @@ function CraftSim.CRAFTQ:AddFirstCrafts()
812839
return nil
813840
end)
814841

815-
GUTIL:FrameDistributedIteration(firstCraftRecipeIDs, function(_, recipeID, counter)
816-
local recipeData = CraftSim.RecipeData({ recipeID = recipeID })
817-
local isSkillLine = recipeData.professionData.skillLineID == currentSkillLineID
818-
local ignoreAcuity = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_ACUITY_RECIPES")
819-
local usesAcuity = recipeData.reagentData:HasOneOfReagents({ CraftSim.CONST.ITEM_IDS.CURRENCY.ARTISANS_ACUITY })
820-
local queueRecipe = isSkillLine and (not ignoreAcuity or not usesAcuity)
821-
if queueRecipe then
822-
recipeData.reagentData:SetReagentsMaxByQuality(1)
823-
self:AddRecipe({ recipeData = recipeData })
842+
GUTIL.FrameDistributor {
843+
iterationsPerFrame = 2,
844+
iterationTable = firstCraftRecipeIDs,
845+
continue = function(frameDistributor, _, recipeID, _, _)
846+
local recipeData = CraftSim.RecipeData({ recipeID = recipeID })
847+
local isSkillLine = recipeData.professionData.skillLineID == currentSkillLineID
848+
local ignoreAcuity = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_ACUITY_RECIPES")
849+
local usesAcuity = recipeData.reagentData:HasOneOfReagents({ CraftSim.CONST.ITEM_IDS.CURRENCY
850+
.ARTISANS_ACUITY })
851+
local queueRecipe = isSkillLine and (not ignoreAcuity or not usesAcuity)
852+
if queueRecipe then
853+
if CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_SPARK_RECIPES") then
854+
if recipeData.reagentData:HasSparkSlot() then
855+
frameDistributor:Continue()
856+
return
857+
end
858+
end
859+
860+
recipeData.reagentData:SetReagentsMaxByQuality(1)
861+
self:AddRecipe({ recipeData = recipeData })
862+
frameDistributor:Continue()
863+
end
824864
end
825-
end)
865+
}:Continue()
826866
end
827867

828868
function CraftSim.CRAFTQ:OnRecipeEditSave()

Modules/CraftQueue/UI.lua

+122-39
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ function CraftSim.CRAFTQ.UI:Init()
460460
})
461461

462462
local craftQueueButtonsOffsetY = -5
463-
463+
local fixedButtonWidth = 180
464464
---@type GGUI.Button
465465
queueTab.content.importRecipeScanButton = GGUI.Button({
466466
parent = queueTab.content,
@@ -469,7 +469,7 @@ function CraftSim.CRAFTQ.UI:Init()
469469
anchorB = "BOTTOMLEFT",
470470
offsetY = craftQueueButtonsOffsetY,
471471
offsetX = 0,
472-
adjustWidth = true,
472+
sizeX = fixedButtonWidth,
473473
label = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_IMPORT_RECIPE_SCAN_BUTTON_LABEL),
474474
initialStatusID = "Ready",
475475
clickCallback = function()
@@ -481,21 +481,34 @@ function CraftSim.CRAFTQ.UI:Init()
481481
{
482482
statusID = "Ready",
483483
enabled = true,
484-
adjustWidth = true,
485-
sizeX = 15,
484+
sizeX = fixedButtonWidth,
486485
label = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_IMPORT_RECIPE_SCAN_BUTTON_LABEL),
487486
},
488487
}
489488

490-
queueTab.content.importAllProfessionsCB = GGUI.Checkbox {
491-
parent = queueTab.content, anchorParent = queueTab.content.importRecipeScanButton.frame,
492-
label = L(CraftSim.CONST.TEXT.RECIPE_SCAN_IMPORT_ALL_PROFESSIONS_CHECKBOX_LABEL),
493-
offsetX = 5, anchorA = "LEFT", anchorB = "RIGHT",
494-
initialValue = CraftSim.DB.OPTIONS:Get("RECIPESCAN_IMPORT_ALL_PROFESSIONS"),
495-
clickCallback = function(_, checked)
496-
CraftSim.DB.OPTIONS:Save("RECIPESCAN_IMPORT_ALL_PROFESSIONS", checked)
497-
end,
498-
tooltip = L(CraftSim.CONST.TEXT.RECIPE_SCAN_IMPORT_ALL_PROFESSIONS_CHECKBOX_TOOLTIP)
489+
queueTab.content.importRecipeScanOptionsButton = GGUI.Button {
490+
parent = queueTab.content,
491+
anchorPoints = { { anchorParent = queueTab.content.importRecipeScanButton.frame, anchorA = "LEFT", anchorB = "RIGHT", offsetX = 5 } },
492+
cleanTemplate = true,
493+
buttonTextureOptions = CraftSim.CONST.BUTTON_TEXTURE_OPTIONS.OPTIONS,
494+
sizeX = 20, sizeY = 20,
495+
clickCallback = function(_, _)
496+
MenuUtil.CreateContextMenu(UIParent, function(ownerRegion, rootDescription)
497+
local concentrationCB = rootDescription:CreateCheckbox(
498+
L("RECIPE_SCAN_IMPORT_ALL_PROFESSIONS_CHECKBOX_LABEL"),
499+
function()
500+
return CraftSim.DB.OPTIONS:Get("RECIPESCAN_IMPORT_ALL_PROFESSIONS")
501+
end, function()
502+
local value = CraftSim.DB.OPTIONS:Get("RECIPESCAN_IMPORT_ALL_PROFESSIONS")
503+
CraftSim.DB.OPTIONS:Save("RECIPESCAN_IMPORT_ALL_PROFESSIONS", not value)
504+
end)
505+
506+
concentrationCB:SetTooltip(function(tooltip, elementDescription)
507+
GameTooltip_AddInstructionLine(tooltip,
508+
L("RECIPE_SCAN_IMPORT_ALL_PROFESSIONS_CHECKBOX_TOOLTIP"));
509+
end);
510+
end)
511+
end
499512
}
500513

501514
queueTab.content.addAllFirstCraftsButton = GGUI.Button({
@@ -504,47 +517,119 @@ function CraftSim.CRAFTQ.UI:Init()
504517
anchorA = "TOPLEFT",
505518
anchorB = "BOTTOMLEFT",
506519
offsetY = 0,
507-
adjustWidth = true,
520+
sizeX = fixedButtonWidth,
508521
label = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_FIRST_CRAFTS_BUTTON_LABEL),
509522
clickCallback = function()
510523
CraftSim.CRAFTQ:AddFirstCrafts()
511524
end
512525
})
513526

527+
queueTab.content.addAllFirstCraftsOptions = GGUI.Button {
528+
parent = queueTab.content,
529+
anchorPoints = { { anchorParent = queueTab.content.addAllFirstCraftsButton.frame, anchorA = "LEFT", anchorB = "RIGHT", offsetX = 5 } },
530+
cleanTemplate = true,
531+
buttonTextureOptions = CraftSim.CONST.BUTTON_TEXTURE_OPTIONS.OPTIONS,
532+
sizeX = 20, sizeY = 20,
533+
clickCallback = function(_, _)
534+
MenuUtil.CreateContextMenu(UIParent, function(ownerRegion, rootDescription)
535+
local acuityCB = rootDescription:CreateCheckbox(
536+
L(CraftSim.CONST.TEXT.CRAFT_QUEUE_IGNORE_ACUITY_RECIPES_CHECKBOX_LABEL),
537+
function()
538+
return CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_ACUITY_RECIPES")
539+
end, function()
540+
local value = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_ACUITY_RECIPES")
541+
CraftSim.DB.OPTIONS:Save("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_ACUITY_RECIPES", not value)
542+
end)
543+
544+
acuityCB:SetTooltip(function(tooltip, elementDescription)
545+
--GameTooltip_SetTitle(tooltip, MenuUtil.GetElementText(elementDescription));
546+
GameTooltip_AddInstructionLine(tooltip,
547+
L("CRAFT_QUEUE_IGNORE_ACUITY_RECIPES_CHECKBOX_TOOLTIP"));
548+
--GameTooltip_AddNormalLine(tooltip, "Test Tooltip Normal Line");
549+
--GameTooltip_AddErrorLine(tooltip, "Test Tooltip Colored Line");
550+
end);
551+
552+
local sparksCB = rootDescription:CreateCheckbox(
553+
"Ignore " .. f.e("Spark") .. " Recipes",
554+
function()
555+
return CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_SPARK_RECIPES")
556+
end, function()
557+
local value = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_SPARK_RECIPES")
558+
CraftSim.DB.OPTIONS:Save("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_SPARK_RECIPES", not value)
559+
end)
560+
561+
sparksCB:SetTooltip(function(tooltip, elementDescription)
562+
GameTooltip_AddInstructionLine(tooltip,
563+
"Ignore recipes that require a spark reagent");
564+
end);
565+
end)
566+
end
567+
}
568+
514569
queueTab.content.addPatronOrdersButton = GGUI.Button({
515570
parent = queueTab.content,
516571
anchorParent = queueTab.content.addAllFirstCraftsButton.frame,
517572
anchorA = "TOPLEFT",
518573
anchorB = "BOTTOMLEFT",
519574
offsetY = 0,
520-
adjustWidth = true,
575+
sizeX = fixedButtonWidth,
521576
label = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_PATRON_ORDERS_BUTTON_LABEL),
522577
clickCallback = function()
523578
CraftSim.CRAFTQ:AddPatronOrders()
524579
end
525580
})
526581

527-
queueTab.content.allowConcentrationForPatronQueuingCB = GGUI.Checkbox {
582+
queueTab.content.addPatronOrdersOptions = GGUI.Button {
528583
parent = queueTab.content,
529-
anchorParent = queueTab.content.addPatronOrdersButton.frame,
530-
scale = 0.9, anchorA = "LEFT", anchorB = "RIGHT", labelOptions = { text = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_PATRON_ORDERS_ALLOW_CONCENTRATION_CHECKBOX) },
531-
initialValue = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_PATRON_ORDERS_ALLOW_CONCENTRATION"),
532-
clickCallback = function(_, checked)
533-
CraftSim.DB.OPTIONS:Save("CRAFTQUEUE_PATRON_ORDERS_ALLOW_CONCENTRATION", checked)
534-
end,
535-
tooltip = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_ADD_PATRON_ORDERS_ALLOW_CONCENTRATION_TOOLTIP),
536-
offsetX = 5,
537-
}
538-
539-
queueTab.content.ignoreAcuityRecipesCB = GGUI.Checkbox {
540-
parent = queueTab.content, anchorParent = queueTab.content.addAllFirstCraftsButton.frame,
541-
scale = 0.9, anchorA = "LEFT", anchorB = "RIGHT", labelOptions = { text = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_IGNORE_ACUITY_RECIPES_CHECKBOX_LABEL) },
542-
offsetX = 5,
543-
initialValue = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_ACUITY_RECIPES"),
544-
clickCallback = function(_, checked)
545-
CraftSim.DB.OPTIONS:Save("CRAFTQUEUE_FIRST_CRAFTS_IGNORE_ACUITY_RECIPES", checked)
546-
end,
547-
tooltip = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_IGNORE_ACUITY_RECIPES_CHECKBOX_TOOLTIP),
584+
anchorPoints = { { anchorParent = queueTab.content.addPatronOrdersButton.frame, anchorA = "LEFT", anchorB = "RIGHT", offsetX = 5 } },
585+
cleanTemplate = true,
586+
buttonTextureOptions = CraftSim.CONST.BUTTON_TEXTURE_OPTIONS.OPTIONS,
587+
sizeX = 20, sizeY = 20,
588+
clickCallback = function(_, _)
589+
MenuUtil.CreateContextMenu(UIParent, function(ownerRegion, rootDescription)
590+
local concentrationCB = rootDescription:CreateCheckbox("Allow " .. f.gold("Concentration"),
591+
function()
592+
return CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_PATRON_ORDERS_ALLOW_CONCENTRATION")
593+
end, function()
594+
local value = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_PATRON_ORDERS_ALLOW_CONCENTRATION")
595+
CraftSim.DB.OPTIONS:Save("CRAFTQUEUE_PATRON_ORDERS_ALLOW_CONCENTRATION", not value)
596+
end)
597+
598+
concentrationCB:SetTooltip(function(tooltip, elementDescription)
599+
--GameTooltip_SetTitle(tooltip, MenuUtil.GetElementText(elementDescription));
600+
GameTooltip_AddInstructionLine(tooltip,
601+
L("CRAFT_QUEUE_ADD_PATRON_ORDERS_ALLOW_CONCENTRATION_TOOLTIP"));
602+
--GameTooltip_AddNormalLine(tooltip, "Test Tooltip Normal Line");
603+
--GameTooltip_AddErrorLine(tooltip, "Test Tooltip Colored Line");
604+
end);
605+
606+
local sparkCB = rootDescription:CreateCheckbox("Ignore " .. f.e("Spark") .. " Recipes",
607+
function()
608+
return CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_PATRON_ORDERS_IGNORE_SPARK_RECIPES")
609+
end, function()
610+
local value = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_PATRON_ORDERS_IGNORE_SPARK_RECIPES")
611+
CraftSim.DB.OPTIONS:Save("CRAFTQUEUE_PATRON_ORDERS_IGNORE_SPARK_RECIPES", not value)
612+
end)
613+
614+
sparkCB:SetTooltip(function(tooltip, elementDescription)
615+
GameTooltip_AddInstructionLine(tooltip,
616+
"Ignore recipes that require a spark reagent");
617+
end);
618+
619+
local knowledgeCB = rootDescription:CreateCheckbox(f.bb("Knowledge Points") .. " only",
620+
function()
621+
return CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_PATRON_ORDERS_KNOWLEDGE_POINTS_ONLY")
622+
end, function()
623+
local value = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_PATRON_ORDERS_KNOWLEDGE_POINTS_ONLY")
624+
CraftSim.DB.OPTIONS:Save("CRAFTQUEUE_PATRON_ORDERS_KNOWLEDGE_POINTS_ONLY", not value)
625+
end)
626+
627+
knowledgeCB:SetTooltip(function(tooltip, elementDescription)
628+
GameTooltip_AddInstructionLine(tooltip,
629+
"Only try to queue patron orders rewarding knowledge points");
630+
end);
631+
end)
632+
end
548633
}
549634

550635
---@type GGUI.Button
@@ -554,8 +639,8 @@ function CraftSim.CRAFTQ.UI:Init()
554639
anchorA = "TOPLEFT",
555640
anchorB = "BOTTOMLEFT",
556641
offsetY = 0,
557-
adjustWidth = true,
558-
label = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_CLEAR_ALL_BUTTON_LABEL),
642+
sizeX = fixedButtonWidth,
643+
label = f.l(L(CraftSim.CONST.TEXT.CRAFT_QUEUE_CLEAR_ALL_BUTTON_LABEL)),
559644
clickCallback = function()
560645
CraftSim.CRAFTQ:ClearAll()
561646
end
@@ -1876,8 +1961,6 @@ function CraftSim.CRAFTQ.UI:UpdateCraftQueueRowByCraftQueueItem(row, craftQueueI
18761961

18771962
-- if we got npcOrderRewards than we need to delay the tooltip display data
18781963

1879-
1880-
18811964
if recipeData.orderData and recipeData.orderData.npcOrderRewards then
18821965
craftOrderInfoText = craftOrderInfoText .. L(CraftSim.CONST.TEXT.CRAFT_QUEUE_ORDER_REWARDS)
18831966
local craftOrderWarning = L(CraftSim.CONST.TEXT.CRAFT_QUEUE_ORDER_INFO_REAGENTS_IN_YOUR_INVENTORY)

0 commit comments

Comments
 (0)