Back to Home

ESO Lua File v100035

ingame/crafting/keyboard/provisioner.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
ZO_Provisioner = ZO_SharedProvisioner:Subclass()
ZO_PROVISIONER_SLOT_ROW_WIDTH = 260
ZO_PROVISIONER_SLOT_ROW_HEIGHT = 58
ZO_PROVISIONER_SLOT_ICON_SIZE = 48
ZO_PROVISIONER_SLOT_PADDING_X = 5
function ZO_Provisioner:New(...)
    return ZO_SharedProvisioner.New(self, ...)
end
function ZO_Provisioner:Initialize(control)
    self.mainSceneName = "provisioner"
    ZO_SharedProvisioner.Initialize(self, control)
    self.resultTooltip = self.control:GetNamedChild("Tooltip")
        local function OnTooltipMouseUp(control, button, upInside)
            if upInside and button == MOUSE_BUTTON_INDEX_RIGHT then
                ClearMenu()
                    
                local function AddLink()
                    local recipeListIndex, recipeIndex = self:GetSelectedRecipeListIndex(), self:GetSelectedRecipeIndex()
                    local link = ZO_LinkHandler_CreateChatLink(GetRecipeResultItemLink, recipeListIndex, recipeIndex)
                    ZO_LinkHandler_InsertLink(zo_strformat(SI_TOOLTIP_ITEM_NAME, link))
                end
                AddMenuItem(GetString(SI_ITEM_ACTION_LINK_TO_CHAT), AddLink)
                ShowMenu(self)
            end
        end
        self.resultTooltip:SetHandler("OnMouseUp", OnTooltipMouseUp)
        self.resultTooltip:GetNamedChild("Icon"):SetHandler("OnMouseUp", OnTooltipMouseUp)
    end
    self.currentTabs = {}
    self.multiCraftContainer = self.control:GetNamedChild("MultiCraftContainer")
    self.multiCraftSpinner = ZO_MultiCraftSpinner:New(self.multiCraftContainer:GetNamedChild("Spinner"))
    self.multiCraftSpinner:RegisterCallback("OnValueChanged", function()
        self:RefreshRecipeDetails()
    end)
    self:InitializeTabs()
    
    local function OnAddOnLoaded(event, name)
        if name == "ZO_Ingame" then
            local defaults =
            {
                haveIngredientsChecked = true,
                haveSkillsChecked = true,
                questsOnlyChecked = false,
            }
            self.savedVars = ZO_SavedVars:New("ZO_Ingame_SavedVariables", 2, "Provisioner", defaults)
            ZO_CheckButton_SetCheckState(self.haveIngredientsCheckBox, self.savedVars.haveIngredientsChecked)
            ZO_CheckButton_SetCheckState(self.haveSkillsCheckBox, self.savedVars.haveSkillsChecked)
            ZO_CheckButton_SetCheckState(self.isQuestItemCheckbox, self.savedVars.questsOnlyChecked)
            self:DirtyRecipeList()
            
            self.control:UnregisterForEvent(EVENT_ADD_ON_LOADED)
        end
    end
    self.control:RegisterForEvent(EVENT_ADD_ON_LOADED, OnAddOnLoaded)
    PROVISIONER_FRAGMENT = ZO_FadeSceneFragment:New(control)
    PROVISIONER_FRAGMENT:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_FRAGMENT_SHOWING then
            self:ResetMultiCraftNumIterations()
            SYSTEMS:GetObject("craftingResults"):SetCraftingTooltip(self.resultTooltip)
            KEYBIND_STRIP:AddKeybindButtonGroup(self.mainKeybindStripDescriptor)
        elseif newState == SCENE_FRAGMENT_HIDDEN then
            SYSTEMS:GetObject("craftingResults"):SetCraftingTooltip(nil)
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.mainKeybindStripDescriptor)
            -- when we hide this fragment make sure to end the preview and toggle the camera back to normal,
            -- since we may still be staying in the crafting scene
            if ITEM_PREVIEW_KEYBOARD:IsInteractionCameraPreviewEnabled() then
                self:TogglePreviewMode()
            end
        end
    end)
    PROVISIONER_SCENE = self:CreateInteractScene(self.mainSceneName)
    PROVISIONER_SCENE:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_SHOWING then
            self:ConfigureFromSettings(ZO_Provisioner.PROVISIONING_SETTINGS)
            TriggerTutorial(TUTORIAL_TRIGGER_PROVISIONING_OPENED)
            if CRAFT_ADVISOR_MANAGER:HasActiveWrits() then
                SCENE_MANAGER:AddFragmentGroup(WRIT_ADVISOR_KEYBOARD_FRAGMENT_GROUP)
            end
        elseif newState == SCENE_HIDDEN then
            SCENE_MANAGER:RemoveFragmentGroup(WRIT_ADVISOR_KEYBOARD_FRAGMENT_GROUP)
        end
    end)
    self.skillInfoHeader = self.control:GetNamedChild("SkillInfo")
    ZO_Skills_TieSkillInfoHeaderToCraftingSkill(self.skillInfoHeader, CRAFTING_TYPE_PROVISIONING)
end
--Settings
ZO_Provisioner.PROVISIONING_SETTINGS =
{
    tabsOffsetY = 10,
    selectedTabLabelFont = "ZoFontHeader4",
    selectedTabLabelOffsetY = 7,
    showProvisionerSkillLevel = true,
}
ZO_Provisioner.EMBEDDED_SETTINGS =
{
    tabsOffsetY = 58,
    selectedTabLabelFont = "ZoFontHeader2",
    selectedTabLabelOffsetY = 0,
    showProvisionerSkillLevel = false,
}
function ZO_Provisioner:InitializeSettings()
    local function GenerateTab(filterType, normal, pressed, highlight, disabled)
        local name = GetString("SI_PROVISIONERSPECIALINGREDIENTTYPE", filterType) 
        return {
            activeTabText = name,
            categoryName = name,
            descriptor = filterType,
            normal = normal,
            pressed = pressed,
            highlight = highlight,
            disabled = disabled,
            callback = function(tabData) self:OnTabFilterChanged(tabData) end,
        }
    end
    local provisioningSettings = ZO_Provisioner.PROVISIONING_SETTINGS
    local foodTab = GenerateTab(PROVISIONER_SPECIAL_INGREDIENT_TYPE_SPICES, "EsoUI/Art/Crafting/provisioner_indexIcon_meat_up.dds", "EsoUI/Art/Crafting/provisioner_indexIcon_meat_down.dds", "EsoUI/Art/Crafting/provisioner_indexIcon_meat_over.dds", "EsoUI/Art/Crafting/provisioner_indexIcon_meat_disabled.dds")
    local drinkTab = GenerateTab(PROVISIONER_SPECIAL_INGREDIENT_TYPE_FLAVORING, "EsoUI/Art/Crafting/provisioner_indexIcon_beer_up.dds", "EsoUI/Art/Crafting/provisioner_indexIcon_beer_down.dds", "EsoUI/Art/Crafting/provisioner_indexIcon_beer_over.dds", "EsoUI/Art/Crafting/provisioner_indexIcon_beer_disabled.dds")
    local furnishingsTab = GenerateTab(PROVISIONER_SPECIAL_INGREDIENT_TYPE_FURNISHING, "EsoUI/Art/Crafting/provisioner_indexIcon_furnishings_up.dds", "EsoUI/Art/Crafting/provisioner_indexIcon_furnishings_down.dds", "EsoUI/Art/Crafting/provisioner_indexIcon_furnishings_over.dds", "EsoUI/Art/Crafting/provisioner_indexIcon_furnishings_disabled.dds")
    provisioningSettings.tabs = {}
    table.insert(provisioningSettings.tabs, foodTab)
    table.insert(provisioningSettings.tabs, drinkTab)
    table.insert(provisioningSettings.tabs, furnishingsTab)
    local embeddedSettings = ZO_Provisioner.EMBEDDED_SETTINGS
    embeddedSettings.tabs = {}
    table.insert(embeddedSettings.tabs, furnishingsTab)
end
function ZO_Provisioner:ConfigureFromSettings(settings)
    if self.settings ~= settings then
        self.settings = settings
        self.skillInfoHeader:SetHidden(not settings.showProvisionerSkillLevel)
        self.tabs:SetAnchor(TOPRIGHT, ZO_SharedRightPanelBackground, TOPRIGHT, -33, settings.tabsOffsetY)
        local selectedTabLabel = self.tabs:GetNamedChild("Label")
        selectedTabLabel:SetFont(settings.selectedTabLabelFont)
        selectedTabLabel:SetAnchor(RIGHT, nil, LEFT, -25, settings.selectedTabLabelOffsetY)
        ZO_MenuBar_ClearButtons(self.tabs)
        ZO_ClearTable(self.currentTabs)
        for _, tab in ipairs(settings.tabs) do
            table.insert(self.currentTabs, ZO_MenuBar_AddButton(self.tabs, tab))
        end
        ZO_MenuBar_SelectDescriptor(self.tabs, settings.tabs[1].descriptor)
    end
end
function ZO_Provisioner:EmbedInCraftingScene()
    self:ConfigureFromSettings(ZO_Provisioner.EMBEDDED_SETTINGS)
    SCENE_MANAGER:AddFragment(PROVISIONER_FRAGMENT)
end
function ZO_Provisioner:RemoveFromCraftingScene()
    SCENE_MANAGER:RemoveFragment(PROVISIONER_FRAGMENT)
end
function ZO_Provisioner:ShouldShowForControlScheme()
    return not IsInGamepadPreferredMode()
end
function ZO_Provisioner:InitializeTabs()
    self.tabs = self.control:GetNamedChild("Tabs")
    self.activeTab = self.control:GetNamedChild("TabsLabel")
end
function ZO_Provisioner:OnTabFilterChanged(filterData)
    -- we are switching from the furnishing tab to another tab, make sure the end the preview if there is one
    if self.filterType == PROVISIONER_SPECIAL_INGREDIENT_TYPE_FURNISHING then
        if SYSTEMS:GetObject("itemPreview"):IsInteractionCameraPreviewEnabled() then
            self:TogglePreviewMode()
        end
    end
    self.activeTab:SetText(filterData.activeTabText)
    self.filterType = filterData.descriptor
    if self.savedVars then
        ZO_CheckButton_SetCheckState(self.haveIngredientsCheckBox, self.savedVars.haveIngredientsChecked)
        ZO_CheckButton_SetCheckState(self.haveSkillsCheckBox, self.savedVars.haveSkillsChecked)
        ZO_CheckButton_SetCheckState(self.isQuestItemCheckbox, self.savedVars.questsOnlyChecked)
    end
end
function ZO_Provisioner:InitializeFilters()
    self.haveIngredientsCheckBox = self.control:GetNamedChild("HaveIngredients")
    self.haveSkillsCheckBox = self.control:GetNamedChild("HaveSkills")
    self.isQuestItemCheckbox = self.control:GetNamedChild("IsQuestItem")
    local function OnFilterChanged()
        self.savedVars.haveIngredientsChecked = ZO_CheckButton_IsChecked(self.haveIngredientsCheckBox)
        self.savedVars.haveSkillsChecked = ZO_CheckButton_IsChecked(self.haveSkillsCheckBox)
        self.savedVars.questsOnlyChecked = ZO_CheckButton_IsChecked(self.isQuestItemCheckbox)
        self:DirtyRecipeList()
    end
    ZO_CheckButton_SetToggleFunction(self.haveIngredientsCheckBox, OnFilterChanged)
    ZO_CheckButton_SetToggleFunction(self.isQuestItemCheckbox, OnFilterChanged)
    ZO_CheckButton_SetLabelText(self.haveIngredientsCheckBox, GetString(SI_PROVISIONER_HAVE_INGREDIENTS))
    local FILTER_SPACING = 20
    self.haveSkillsCheckBox:SetAnchor(LEFT, self.haveIngredientsCheckBox.label, RIGHT, FILTER_SPACING, 0)
    ZO_CheckButton_SetLabelText(self.haveSkillsCheckBox, GetString(SI_PROVISIONER_HAVE_SKILLS))
    self.isQuestItemCheckbox:SetAnchor(LEFT, self.haveSkillsCheckBox.label, RIGHT, FILTER_SPACING, 0)
    ZO_CheckButton_SetLabelText(self.isQuestItemCheckbox, GetString(SI_SMITHING_IS_QUEST_ITEM))
end
function ZO_Provisioner:InitializeKeybindStripDescriptors()
    self.mainKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_CENTER,
        -- Perform craft
        {
            name = function()
                local cost = GetCostToCraftProvisionerItem(self:GetSelectedRecipeListIndex(), self:GetSelectedRecipeIndex())
                return ZO_CraftingUtils_GetCostToCraftString(cost)
            end,
            keybind = "UI_SHORTCUT_SECONDARY",
        
            callback = function()
            end,
            enabled = function()
                return self:ShouldCraftButtonBeEnabled()
            end,
        },
        --Toggle Preview
        {
            name = function()
                if not ITEM_PREVIEW_KEYBOARD:IsInteractionCameraPreviewEnabled() then
                    return GetString(SI_CRAFTING_ENTER_PREVIEW_MODE)
                else
                    return GetString(SI_CRAFTING_EXIT_PREVIEW_MODE)
                end
            end,
            keybind = "UI_SHORTCUT_QUATERNARY",
            callback = function()
                self:TogglePreviewMode()
            end,
            visible = function()
                return self:CanPreviewRecipe(self:GetRecipeData())
            end,
        },
    }
end
function ZO_Provisioner:InitializeRecipeTree()
    local navigationContainer = self.control:GetNamedChild("NavigationContainer")
    self.recipeTree = ZO_Tree:New(navigationContainer:GetNamedChild("ScrollChild"), 74, -10, 535)
    local function TreeHeaderSetup(node, control, data, open, userRequested, enabled)
        control.text:SetModifyTextType(MODIFY_TEXT_TYPE_UPPERCASE)
        control.text:SetDimensionConstraints(0, 0, 260, 0)
        control.text:SetText(data.name)
        local shouldHide = self.questRecipeLists[data.recipeListIndex] ~= true
        control.questPin:SetHidden(shouldHide)
        if not enabled then
            control.icon:SetDesaturation(1)
            control.icon:SetTexture(data.upIcon)
        elseif open then
            control.icon:SetDesaturation(0)
            control.icon:SetTexture(data.downIcon)
        else
            control.icon:SetDesaturation(0)
            control.icon:SetTexture(data.upIcon)
        end
        control.iconHighlight:SetTexture(data.overIcon)
        ZO_IconHeader_Setup(control, open, enabled)
    end
    local function TreeHeaderEquality(left, right)
        return left.recipeListIndex == right.recipeListIndex
    end
    self.recipeTree:AddTemplate("ZO_ProvisionerNavigationHeader", TreeHeaderSetup, nil, TreeHeaderEquality, nil, 0)
    local function TreeEntrySetup(node, control, data, open, userRequested, enabled)
        control.data = data
        control.meetsLevelReq = self:PassesTradeskillLevelReqs(data.tradeskillsLevelReqs)
        control.meetsQualityReq = self:PassesQualityLevelReq(data.qualityReq)
        control.enabled = enabled
        local shouldHideQuestPin = self.questRecipes[data.resultItemId] ~= true
        control.questPin:SetHidden(shouldHideQuestPin)
        if data.maxIterationsForIngredients > 0 and enabled then
            control:SetText(zo_strformat(SI_PROVISIONER_RECIPE_NAME_COUNT, data.name, data.maxIterationsForIngredients))
        else
            control:SetText(zo_strformat(SI_PROVISIONER_RECIPE_NAME_COUNT_NONE, data.name))
        end
        
        control:SetEnabled(enabled)
        control:SetSelected(node:IsSelected())
        if WINDOW_MANAGER:GetMouseOverControl() == control then
            zo_callHandler(control, enabled and "OnMouseEnter" or "OnMouseExit")
        end
    end
    local function TreeEntryOnSelected(control, data, selected, reselectingDuringRebuild)
        control:SetSelected(selected)
        if selected then
            self:RefreshRecipeDetails()
        end
    end
    local function TreeEntryEquality(left, right)
        return left.recipeListIndex == right.recipeListIndex and left.recipeIndex == right.recipeIndex and left.name == right.name
    end
    self.recipeTree:AddTemplate("ZO_ProvisionerNavigationEntry", TreeEntrySetup, TreeEntryOnSelected, TreeEntryEquality)
    self.recipeTree:SetExclusive(true)
    self.recipeTree:SetOpenAnimation("ZO_TreeOpenAnimation")
    self.noRecipesLabel = navigationContainer:GetNamedChild("NoRecipesLabel")
    
end
function ZO_Provisioner:InitializeDetails()
    self.detailsPane = self.control:GetNamedChild("Details")
    self.ingredientRowsContainer = self.detailsPane:GetNamedChild("Ingredients")
    self.ingredientRows = {}
    
    local ingredientAnchor = ZO_Anchor:New(TOPLEFT, self.ingredientRowsContainer, TOPLEFT, 0, 0)
    local NUM_INGREDIENTS_PER_ROW = 2
    local INGREDIENT_PAD_X = 15
    local INGREDIENT_PAD_Y = 15
    local INGREDIENT_INITIAL_OFFSET_X = 0
    local INGREDIENT_INITIAL_OFFSET_Y = 0
    for i = 1, GetMaxRecipeIngredients() do
        local control = CreateControlFromVirtual("$(parent)Slot", self.ingredientRowsContainer, "ZO_ProvisionerSlotRow", i)
        table.insert(self.ingredientRows, ZO_ProvisionerRow:New(self, control))
        ZO_Anchor_BoxLayout(ingredientAnchor, control, i - 1, NUM_INGREDIENTS_PER_ROW,
            INGREDIENT_PAD_X, INGREDIENT_PAD_Y,
            ZO_PROVISIONER_SLOT_ROW_WIDTH, ZO_PROVISIONER_SLOT_ROW_HEIGHT,
            INGREDIENT_INITIAL_OFFSET_X, INGREDIENT_INITIAL_OFFSET_Y)
    end
end
function ZO_Provisioner:ResetSelectedTab()
    self.settings = nil
end
function ZO_Provisioner:SetDetailsEnabled(enabled)
    for ingredientIndex, ingredientSlot in ipairs(self.ingredientRows) do
        ingredientSlot:SetEnabled(enabled)
    end
end
function ZO_Provisioner:RefreshRecipeList()
    self.recipeTree:Reset()
    local knowAnyRecipesInTab = false
    local hasRecipesWithFilter = false
    local requireIngredients = ZO_CheckButton_IsChecked(self.haveIngredientsCheckBox)
    local requireSkills = ZO_CheckButton_IsChecked(self.haveSkillsCheckBox)
    local requireQuests = ZO_CheckButton_IsChecked(self.isQuestItemCheckbox)
    local craftingInteractionType = GetCraftingInteractionType()
    local recipeLists = PROVISIONER_MANAGER:GetRecipeListData(craftingInteractionType)
    for _, recipeList in pairs(recipeLists) do
        local parent
        for _, recipe in ipairs(recipeList.recipes) do
            if recipe.requiredCraftingStationType == craftingInteractionType and self.filterType == recipe.specialIngredientType then
                knowAnyRecipesInTab = true
                if self:DoesRecipePassFilter(recipe.specialIngredientType, requireIngredients, recipe.maxIterationsForIngredients, requireSkills, recipe.tradeskillsLevelReqs, recipe.qualityReq, craftingInteractionType, recipe.requiredCraftingStationType, requireQuests, recipe.resultItemId) then
                    parent = parent or self.recipeTree:AddNode("ZO_ProvisionerNavigationHeader", {
                        recipeListIndex = recipeList.recipeListIndex,
                        name = recipeList.recipeListName,
                        upIcon = recipeList.upIcon,
                        downIcon = recipeList.downIcon,
                        overIcon = recipeList.overIcon,
                        })
                    self.recipeTree:AddNode("ZO_ProvisionerNavigationEntry", recipe, parent)
                    hasRecipesWithFilter = true
                end
            end
        end
    end
    self.recipeTree:Commit()
    self.noRecipesLabel:SetHidden(hasRecipesWithFilter)
    if not hasRecipesWithFilter then
        if knowAnyRecipesInTab then
            self.noRecipesLabel:SetText(GetString(SI_PROVISIONER_NONE_MATCHING_FILTER))
        else
            --If there are no recipes all the types show the same message.
            self.noRecipesLabel:SetText(GetString(SI_PROVISIONER_NO_RECIPES))
            ZO_CheckButton_SetChecked(self.haveIngredientsCheckBox)
            ZO_CheckButton_SetChecked(self.haveSkillsCheckBox)
            ZO_CheckButton_SetUnchecked(self.isQuestItemCheckbox)
        end
        self:RefreshRecipeDetails()
    end
    ZO_CheckButton_SetEnableState(self.haveIngredientsCheckBox, knowAnyRecipesInTab)
    ZO_CheckButton_SetEnableState(self.haveSkillsCheckBox, knowAnyRecipesInTab)
    ZO_CheckButton_SetEnableState(self.isQuestItemCheckbox, knowAnyRecipesInTab)
end
function ZO_Provisioner:GetRecipeData()
    return self.recipeTree:GetSelectedData()
end
function ZO_Provisioner:GetSelectedRecipeListIndex()
    local recipeData = self:GetRecipeData()
    if recipeData then
        return recipeData.recipeListIndex
    end
end
function ZO_Provisioner:GetSelectedRecipeIndex()
    local recipeData = self:GetRecipeData()
    if recipeData then
        return recipeData.recipeIndex
    end
end
function ZO_Provisioner:RefreshRecipeDetails()
    local recipeData = self:GetRecipeData()
    if recipeData then
        if not ITEM_PREVIEW_KEYBOARD:IsInteractionCameraPreviewEnabled() then
            self.resultTooltip:SetHidden(false)
        end
        local recipeListIndex, recipeIndex = self:GetSelectedRecipeListIndex(), self:GetSelectedRecipeIndex()
        self.resultTooltip:ClearLines()
        self.resultTooltip:SetProvisionerResultItem(recipeListIndex, recipeIndex)
        local numIngredients = recipeData.numIngredients 
        for ingredientIndex, ingredientSlot in ipairs(self.ingredientRows) do
            if ingredientIndex > numIngredients then
                ingredientSlot:ClearItem()
            else
                local name, icon, requiredQuantity, _, displayQuality = GetRecipeIngredientItemInfo(recipeListIndex, recipeIndex, ingredientIndex)
                -- Scale the recipe ingredients to what will actually be used when you hit craft.
                -- If numIterations is 0 we should just show what ingredients you would need to craft once, instead.
                local numIterations = self:GetMultiCraftNumIterations()
                if numIterations > 1 then
                    requiredQuantity = requiredQuantity * numIterations
                end
                local ingredientCount = GetCurrentRecipeIngredientCount(recipeListIndex, recipeIndex, ingredientIndex)
                ingredientSlot:SetItem(name, icon, ingredientCount, displayQuality, requiredQuantity)
                ingredientSlot:SetItemIndices(recipeListIndex, recipeIndex, ingredientIndex)
            end
        end
        CRAFTING_RESULTS:SetTooltipAnimationSounds(recipeData.createSound)
        if ITEM_PREVIEW_KEYBOARD:IsInteractionCameraPreviewEnabled() and self:CanPreviewRecipe(recipeData) then
            self:PreviewRecipe(recipeData)
        end
    else
        self.resultTooltip:SetHidden(true)
        for ingredientIndex, ingredientSlot in ipairs(self.ingredientRows) do
            ingredientSlot:ClearItem()
        end
    end
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.mainKeybindStripDescriptor)
end
function ZO_Provisioner:UpdateQuestPins()
    --Determine whether or not we need quest pins on each tab
    for _, tab in ipairs(self.currentTabs) do
        local data = tab.m_object.m_buttonData
        local shouldHide = self.questCategories[data.descriptor] ~= true
        tab.questPin:SetHidden(shouldHide)
    end
end
function ZO_Provisioner:TogglePreviewMode()
    ITEM_PREVIEW_KEYBOARD:ToggleInteractionCameraPreview(FRAME_TARGET_CRAFTING_FRAGMENT, FRAME_PLAYER_ON_SCENE_HIDDEN_FRAGMENT, CRAFTING_PREVIEW_OPTIONS_FRAGMENT)
    if ITEM_PREVIEW_KEYBOARD:IsInteractionCameraPreviewEnabled() then
        self.resultTooltip:SetHidden(true)
        self:SetMultiCraftHidden(true)
        self:PreviewRecipe(self:GetRecipeData())
    else
        self.resultTooltip:SetHidden(false)
        self:SetMultiCraftHidden(false)
    end
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.mainKeybindStripDescriptor)
end
function ZO_Provisioner:SetMultiCraftHidden(shouldBeHidden)
    self.multiCraftContainer:SetHidden(shouldBeHidden)
end
function ZO_Provisioner:GetMultiCraftNumIterations()
    -- while spinner is hidden, hard cap the iteration count at 1, so the player doesn't accidentally perform a multicraft without a visual cue that it will happen
    if self.multiCraftContainer:IsControlHidden() then
        return 1
    end
    return self.multiCraftSpinner:GetValue()
end
function ZO_Provisioner:ResetMultiCraftNumIterations()
    self.multiCraftSpinner:SetValue(1)
end
function ZO_Provisioner:UpdateMultiCraft()
    self.multiCraftSpinner:SetMinMax(1, self:GetMultiCraftMaxIterations())
    self.multiCraftSpinner:UpdateButtons()
end
ZO_ProvisionerRow = ZO_Object:Subclass()
function ZO_ProvisionerRow:New(...)
    local provisionerSlot = ZO_Object.New(self)
    provisionerSlot:Initialize(...)
    return provisionerSlot
end
function ZO_ProvisionerRow:Initialize(owner, control)
    self.owner = owner
    self.control = control
    self.enabled = true
    self.icon = control:GetNamedChild("Icon")
    self.nameLabel = control:GetNamedChild("Name")
    self.countControl = control:GetNamedChild("Count")
    local DIVIDER_THICKNESS = 2
    self.countFractionDisplay = ZO_FractionDisplay:New(self.countControl, "ZoFontWinH4", DIVIDER_THICKNESS)
    self.countFractionDisplay:SetHorizontalAlignment(TEXT_ALIGN_RIGHT)
    self.countDividerTexture = self.countControl:GetNamedChild("Divider")
end
function ZO_ProvisionerRow:SetItemIndices(recipeListIndex, recipeIndex, ingredientIndex)
    self.control.recipeListIndex = recipeListIndex
    self.control.recipeIndex = recipeIndex
    self.control.ingredientIndex = ingredientIndex
end
function ZO_ProvisionerRow:SetItem(name, icon, ingredientCount, displayQuality, requiredQuantity)
    self.ingredientCount = ingredientCount
    self.requiredQuantity = requiredQuantity
    self.displayQuality = displayQuality
    -- self.quality is deprecated, included here for addon backwards compatibility
    self.quality = displayQuality
    self.nameLabel:SetText(zo_strformat(SI_TOOLTIP_ITEM_NAME, name))
    self.icon:SetTexture(icon)
    self.countFractionDisplay:SetValues(ingredientCount, requiredQuantity)
    --The name label takes the remaining width which is the full row minus padding, icon, padding, padding, count, padding.
    self.nameLabel:SetWidth(ZO_PROVISIONER_SLOT_ROW_WIDTH - ZO_PROVISIONER_SLOT_ICON_SIZE - ZO_PROVISIONER_SLOT_PADDING_X * 4 - self.countControl:GetWidth())
    self:UpdateColors()
    self:SetHidden(false)
    self.hasItem = true
end
function ZO_ProvisionerRow:ClearItem()
    self.control.recipeListIndex = nil
    self.control.recipeIndex = nil
    self.control.ingredientIndex = nil
    self:SetHidden(true)
    self.hasItem = false
end
function ZO_ProvisionerRow:SetHidden(hidden)
    self.nameLabel:SetHidden(hidden)
    self.icon:SetHidden(hidden)
    self.countControl:SetHidden(hidden)
end
function ZO_ProvisionerRow:SetEnabled(enabled)
    if self.enabled ~= enabled then
        self.enabled = enabled
        self:UpdateEnabledState()
    end
end
function ZO_ProvisionerRow:UpdateColors()
    local ingredientCount = self.ingredientCount
    local requiredQuantity = self.requiredQuantity
    if ingredientCount >= requiredQuantity then
        -- self.quality is deprecated, included here for addon backwards compatibility
        local displayQuality = self.displayQuality or self.quality
        local r, g, b = GetInterfaceColor(INTERFACE_COLOR_TYPE_ITEM_QUALITY_COLORS, displayQuality)
        self.nameLabel:SetColor(r, g, b, 1)
    else
        self.nameLabel:SetColor(ZO_ERROR_COLOR:UnpackRGBA())
    end
    if self.enabled then
        if ingredientCount >= requiredQuantity then
            self.icon:SetColor(ZO_SELECTED_TEXT:UnpackRGBA())
        else
            self.icon:SetColor(ZO_ERROR_COLOR:UnpackRGBA())
        end
    else
        local DISABLED = true
        ZO_ItemSlot_SetupIconUsableAndLockedColor(self.icon, MEETS_USAGE_REQUIREMENTS, DISABLED)
    end
    --Despite the name these only touch the label alpha
    local MEETS_USAGE_REQUIREMENTS = true
    ZO_ItemSlot_SetupTextUsableAndLockedColor(self.nameLabel, MEETS_USAGE_REQUIREMENTS, not self.enabled)
    ZO_ItemSlot_SetupTextUsableAndLockedColor(self.haveLabel, MEETS_USAGE_REQUIREMENTS, not self.enabled)
    ZO_ItemSlot_SetupTextUsableAndLockedColor(self.countControl, MEETS_USAGE_REQUIREMENTS, not self.enabled)
end
function ZO_ProvisionerRow:UpdateEnabledState()
    if self.hasItem then
        self:UpdateColors()
    end
end
    PROVISIONER = ZO_Provisioner:New(control)
end
    InitializeTooltip(InformationTooltip, control, BOTTOM, 0, -10)
    SetTooltipText(InformationTooltip, GetString(SI_CRAFTING_HAVE_INGREDIENTS_TOOLTIP))
end
    InitializeTooltip(InformationTooltip, control, BOTTOM, 0, -10)
    SetTooltipText(InformationTooltip, GetString(SI_CRAFTING_HAVE_SKILLS_TOOLTIP))
end
    InitializeTooltip(InformationTooltip, control, BOTTOM, 0, -10)
    SetTooltipText(InformationTooltip, GetString(SI_CRAFTING_IS_QUEST_ITEM_TOOLTIP))
end
    ClearTooltip(InformationTooltip)
end
    if not self.enabled then
        return GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_DISABLED)
    elseif self.selected then
        return GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_SELECTED)
    elseif self.mouseover then
        return GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_HIGHLIGHT)
    elseif self.meetsLevelReq and self.meetsQualityReq then
        return GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_NORMAL)
    end
    return ZO_ERROR_COLOR:UnpackRGBA()
end
    if self.enabled and (not self.meetsLevelReq or not self.meetsQualityReq) then
        InitializeTooltip(InformationTooltip, self, RIGHT, -15, 0)
        --loop over tradeskills
        if not self.meetsLevelReq then
             for tradeskill, levelReq in pairs(self.data.tradeskillsLevelReqs) do
                local level = GetNonCombatBonus(GetNonCombatBonusLevelTypeForTradeskillType(tradeskill))
                if level < levelReq then
                    local levelPassiveAbilityId = GetTradeskillLevelPassiveAbilityId(tradeskill)
                    local levelPassiveAbilityName = GetAbilityName(levelPassiveAbilityId)
                    InformationTooltip:AddLine(zo_strformat(SI_RECIPE_REQUIRES_LEVEL_PASSIVE, levelPassiveAbilityName, levelReq), "", ZO_ERROR_COLOR:UnpackRGBA())
                end
            end
        end
        if not self.meetsQualityReq then
            InformationTooltip:AddLine(zo_strformat(SI_PROVISIONER_REQUIRES_RECIPE_QUALITY, self.data.qualityReq), "", ZO_ERROR_COLOR:UnpackRGBA())
        end
    end
end
    ClearTooltip(InformationTooltip)
end
    local barData =
    {
        buttonPadding = 20,
        normalSize = 51,
        downSize = 64,
        animationDuration = DEFAULT_SCENE_TRANSITION_TIME,
        buttonTemplate = "ZO_ProvisionerTabButton",
    }
    ZO_MenuBar_SetData(control, barData)
end