Back to Home

ESO Lua File v100021

ingame/restyle/keyboard/restyle_keyboard.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
ZO_RESTYLE_MODE_CATEGORY_DATA =
{
    [RESTYLE_MODE_EQUIPMENT] =
    {
        specializedCollectibleCategory = nil,
        allowsDyeing = true,
    },
    [RESTYLE_MODE_COLLECTIBLE] =
    {
        specializedCollectibleCategory = nil,
        allowsDyeing = true,
    },
}
ZO_Restyle_Keyboard = ZO_Object:Subclass()
function ZO_Restyle_Keyboard:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_Restyle_Keyboard:Initialize(control)
    self.control = control
    self.rightPanel = control:GetNamedChild("RightPanel")
    self.sheetsContainer = control:GetNamedChild("Sheets")
    self.contentSearchEditBox = self.rightPanel:GetNamedChild("SearchBox")
    self.mode = RESTYLE_MODE_EQUIPMENT
    self.sheetsByMode = {}
    self:InitializeTabs()
    local function OnBlockingSceneActivated()
        self:AttemptExit()
    end
    RESTYLE_SCENE = ZO_InteractScene:New("restyle_keyboard", SCENE_MANAGER, ZO_DYEING_STATION_INTERACTION)
    SYSTEMS:RegisterKeyboardRootScene("restyle", RESTYLE_SCENE)
    RESTYLE_SCENE:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_SHOWING then
            MAIN_MENU_MANAGER:SetBlockingScene("restyle_keyboard", OnBlockingSceneActivated)
            SetRestylePreviewMode(self.mode)
            KEYBIND_STRIP:RemoveDefaultExit()
            KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
            
            local currentSheet = self.sheetsByMode[self.mode]
            SCENE_MANAGER:AddFragment(currentSheet:GetFragment())
            local IS_ENABLED = true
            if CanUseCollectibleDyeing() then
                ZO_MenuBar_SetDescriptorEnabled(self.tabs, RESTYLE_MODE_COLLECTIBLE, IS_ENABLED)
            else
                -- if we have the collectible tab selected, switch tabs it before disabling it
                -- so the highlights setup correctly
                local selectedTabType = ZO_MenuBar_GetSelectedDescriptor(self.tabs)
                if selectedTabType == RESTYLE_MODE_COLLECTIBLE then
                    ZO_MenuBar_SelectDescriptor(self.tabs, RESTYLE_MODE_EQUIPMENT)
                end
                ZO_MenuBar_SetDescriptorEnabled(self.tabs, RESTYLE_MODE_COLLECTIBLE, not IS_ENABLED)
            end
            self:RefreshCategoryContent()
            self:InitializeSearch()
        elseif newState == SCENE_HIDDEN then
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
            KEYBIND_STRIP:RestoreDefaultExit()
            MAIN_MENU_MANAGER:ClearBlockingScene(OnBlockingSceneActivated)
        end
    end)
        if RESTYLE_SCENE:IsShowing() then
            self:BuildCategories()
        end
    end
end
function ZO_Restyle_Keyboard:OnTabFilterChanged(tabData)
    self.activeTab:SetText(GetString(tabData.activeTabText))
end
function ZO_Restyle_Keyboard:SetMode(mode)
    if self.mode ~= mode then
        self.mode = mode
        for sheetRestyleMode, sheet in pairs(self.sheetsByMode) do
            if mode == sheetRestyleMode then
                SCENE_MANAGER:AddFragment(sheet:GetFragment())
            else
                SCENE_MANAGER:RemoveFragment(sheet:GetFragment())
            end
        end
        -- make sure the current sheet has the latest dye data for its slots
        SetRestylePreviewMode(mode)
        self:InitializeSearch()
        self:BuildCategories()
    end
end
function ZO_Restyle_Keyboard:HandleTabChange(tabData, nextMode)
    if ZO_Dyeing_AreTherePendingDyes(self.mode) then
        self.pendingTabData = tabData
        self.pendingMode = nextMode
        if ZO_Dyeing_AreAllItemsBound(self.mode) then
            ZO_Dialogs_ShowDialog("SWTICH_DYE_MODE")
        else
            ZO_Dialogs_ShowDialog("SWTICH_DYE_MODE_BIND")
        end
    else
        self:OnTabFilterChanged(tabData)
        self:SetMode(nextMode)
    end
end
function ZO_Restyle_Keyboard:InitializeTabs()
    local function GenerateTab(name, mode, normal, pressed, highlight, disabled, customTooltip)
        return {
            activeTabText = name,
            categoryName = name,
            descriptor = mode,
            normal = normal,
            pressed = pressed,
            highlight = highlight,
            disabled = disabled,
            CustomTooltipFunction = customTooltip,
            alwaysShowTooltip = true,
            callback = function(tabData, playerDriven) 
                            if playerDriven then 
                                self:HandleTabChange(tabData, mode) 
                            end 
                       end,
        }
    end
    self.tabs = self.rightPanel:GetNamedChild("Tabs")
    self.activeTab = self.rightPanel:GetNamedChild("TabsLabel")
    ZO_MenuBar_AddButton(self.tabs, GenerateTab(SI_DYEING_DYE_EQUIPMENT_TAB, RESTYLE_MODE_EQUIPMENT, "EsoUI/Art/Dye/dyes_tabIcon_dye_up.dds", "EsoUI/Art/Dye/dyes_tabIcon_dye_down.dds", "EsoUI/Art/Dye/dyes_tabIcon_dye_over.dds", "EsoUI/Art/Dye/dyes_tabIcon_dye_disabled.dds"))
    ZO_MenuBar_AddButton(self.tabs, GenerateTab(SI_DYEING_DYE_COLLECTIBLE_TAB, RESTYLE_MODE_COLLECTIBLE, "EsoUI/Art/Dye/dyes_tabIcon_costumeDye_up.dds", "EsoUI/Art/Dye/dyes_tabIcon_costumeDye_down.dds", "EsoUI/Art/Dye/dyes_tabIcon_costumeDye_over.dds", "EsoUI/Art/Dye/dyes_tabIcon_costumeDye_disabled.dds", function(...) self:LayoutCollectionAppearanceTooltip(...) end))
    ZO_MenuBar_SelectDescriptor(self.tabs, RESTYLE_MODE_EQUIPMENT)
    self.activeTab:SetText(GetString(SI_DYEING_DYE_EQUIPMENT_TAB))
end
function ZO_Restyle_Keyboard:LayoutCollectionAppearanceTooltip(tooltip)
    local description
    local title
    if CanUseCollectibleDyeing() then
        title = zo_strformat(SI_DYEING_COLLECTIBLE_STATUS, ZO_DEFAULT_ENABLED_COLOR:Colorize(GetString(SI_ESO_PLUS_STATUS_UNLOCKED)))
        description = GetString(SI_DYEING_COLLECTIBLE_TAB_DESCRIPTION_UNLOCKED)
    else
        title = zo_strformat(SI_DYEING_COLLECTIBLE_STATUS, ZO_DEFAULT_ENABLED_COLOR:Colorize(GetString(SI_ESO_PLUS_STATUS_LOCKED)))
        description = GetString(SI_DYEING_COLLECTIBLE_TAB_DESCRIPTION_LOCKED)
    end
    SetTooltipText(tooltip, title)
    local r, g, b = ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB()
    tooltip:AddLine(description, "", r, g, b)
end
function ZO_Restyle_Keyboard:InitializeCategories()
    self.categories = self.rightPanel:GetNamedChild("Categories")
    self.categoryTree = ZO_Tree:New(self.categories:GetNamedChild("ScrollChild"), 60, -10, 300)
    local function BaseTreeHeaderIconSetup(control, data, open)
        local iconTexture = (open and data.pressedIcon or data.normalIcon) or ZO_NO_TEXTURE_FILE
        local mouseoverTexture = data.mouseoverIcon or ZO_NO_TEXTURE_FILE
        
        control.icon:SetTexture(iconTexture)
        control.iconHighlight:SetTexture(mouseoverTexture)
        ZO_IconHeader_Setup(control, open)
    end
    local function BaseTreeHeaderSetup(node, control, data, open)
        control.text:SetModifyTextType(MODIFY_TEXT_TYPE_UPPERCASE)
        control.text:SetText(data.name)
        BaseTreeHeaderIconSetup(control, data, open)
    end
    local function TreeHeaderSetup_Child(node, control, data, open, userRequested)
        BaseTreeHeaderSetup(node, control, data, open)
        if open and userRequested then
            self.categoryTree:SelectFirstChild(node)
        end
    end
    local function TreeHeaderSetup_Childless(node, control, data, open)
        BaseTreeHeaderSetup(node, control, data, open)
    end
    local function TreeEntryOnSelected(control, data, selected, reselectingDuringRebuild)
        control:SetSelected(selected)
        if selected and not reselectingDuringRebuild then
            self:RefreshCategoryContent()
        end
    end
    local function TreeEntryOnSelected_Childless(control, data, selected, reselectingDuringRebuild)
        TreeEntryOnSelected(control, data, selected, reselectingDuringRebuild)
        BaseTreeHeaderIconSetup(control, data, selected)
    end
    local function TreeEntrySetup(node, control, data, open)
        control:SetSelected(false)
        control:SetText(data.name)
    end
    local function EqualityFunction(leftData, rightData)
        local leftReferenceData = leftData.referenceData
        local rightReferenceData = rightData.referenceData
        if leftReferenceData and rightReferenceData then
            if leftReferenceData.isDyesCategory == rightReferenceData.isDyesCategory and
               leftReferenceData.collectibleCategoryIndex == rightReferenceData.collectibleCategoryIndex and
               leftReferenceData.collectibleSubcategoryIndex == rightReferenceData.collectibleSubcategoryIndex then
                return true
            end
        end
        return false
    end
    local CHILD_INDENT = 76
    local CHILD_SPACING = 0
    local NO_SELECTED_CALLBACK = nil
    self.categoryTree:AddTemplate("ZO_IconHeader", TreeHeaderSetup_Child, NO_SELECTED_CALLBACK, EqualityFunction, CHILD_INDENT, CHILD_SPACING)
    self.categoryTree:AddTemplate("ZO_IconChildlessHeader", TreeHeaderSetup_Childless, TreeEntryOnSelected_Childless, EqualityFunction)
    self.categoryTree:AddTemplate("ZO_TreeLabelSubCategory", TreeEntrySetup, TreeEntryOnSelected, EqualityFunction)
    self.categoryTree:SetExclusive(true)
    self.categoryTree:SetOpenAnimation("ZO_TreeOpenAnimation")
end
function ZO_Restyle_Keyboard:BuildCategories()
    self.categoryTree:Reset()
    local restyleModeCategoryData = ZO_RESTYLE_MODE_CATEGORY_DATA[self.mode]
    if restyleModeCategoryData.specializedCollectibleCategory then
        self:AddCollectibleCategories(restyleModeCategoryData.specializedCollectibleCategory)
    end
    if restyleModeCategoryData.allowsDyeing then
        self:AddDyeCategory()
    end
    
    self.categoryTree:Commit()
end
function ZO_Restyle_Keyboard:InitializeSearch()
    local restyleModeCategoryData = ZO_RESTYLE_MODE_CATEGORY_DATA[self.mode]
    if restyleModeCategoryData then
        if restyleModeCategoryData.specializedCollectibleCategory then
            COLLECTIONS_BOOK_SINGLETON:SetSearchString(self.contentSearchEditBox:GetText())
            COLLECTIONS_BOOK_SINGLETON:SetSearchCategorySpecializationFilters(restyleModeCategoryData.specializedCollectibleCategory)
            COLLECTIONS_BOOK_SINGLETON:RegisterCallback("UpdateSearchResults", self.onUpdateCollectionsSearchResultsCallback)
        else
            COLLECTIONS_BOOK_SINGLETON:UnregisterCallback("UpdateSearchResults", self.onUpdateCollectionsSearchResultsCallback)
        end
        if restyleModeCategoryData.allowsDyeing then
            ZO_DYEING_MANAGER:SetSearchString(self.contentSearchEditBox:GetText())
        end
    end
end
do
    local NO_PARENT = nil
    function ZO_Restyle_Keyboard:AddCollectibleCategories(specializedCollectibleCategory)
        local function AddCategory(categoryIndex)
            local categoryName = GetCollectibleCategoryInfo(categoryIndex)
            local normalIcon, pressedIcon, mouseoverIcon = GetCollectibleCategoryKeyboardIcons(categoryIndex)
            local categoryData = { collectibleCategoryIndex = categoryIndex }
            return self:AddCategory("ZO_IconHeader", NO_PARENT, categoryName, categoryData, normalIcon, pressedIcon, mouseoverIcon)
        end
        local function AddSubcategory(categoryIndex, subcategoryIndex, parentNode)
            local subcategoryName, numCollectibles = GetCollectibleSubCategoryInfo(categoryIndex, subcategoryIndex)
            local subcategoryData = 
            {
                collectibleCategoryIndex = categoryIndex,
                collectibleSubcategoryIndex = subcategoryIndex,
                numCollectibles = numCollectibles,
            }
            self:AddCategory("ZO_TreeLabelSubCategory", parentNode, subcategoryName, subcategoryData)
        end
        local searchResults = COLLECTIONS_BOOK_SINGLETON:GetSearchResults()
        if searchResults then
            for categoryIndex, categorySearchResults in pairs(searchResults) do
                local numValidSubCategories = NonContiguousCount(categorySearchResults)
                if categorySearchResults[ZO_COLLECTIONS_SEARCH_ROOT] then
                    numValidSubCategories = numValidSubCategories - 1
                end
                if numValidSubCategories > 0 then
                    local categoryNode = AddCategory(categoryIndex)
                    for subcategoryIndex, subcategorySearchResults in pairs(categorySearchResults) do
                        if subcategoryIndex ~= ZO_COLLECTIONS_SEARCH_ROOT then
                            AddSubcategory(categoryIndex, subcategoryIndex, categoryNode)
                        end
                    end
                end
            end
        else
            for categoryIndex = 1, GetNumCollectibleCategories() do
                if GetCollectibleCategorySpecialization(categoryIndex) == specializedCollectibleCategory then
                    local categoryName, numSubcategories = GetCollectibleCategoryInfo(categoryIndex)
                    if numSubcategories > 0 then --No support for non-subcategorized collectibles in restyle
                        local categoryNode = AddCategory(categoryIndex)
                        for subcategoryIndex = 1, numSubcategories do
                            AddSubcategory(categoryIndex, subcategoryIndex, categoryNode)
                        end
                    end
                end
            end
        end
    end
    local DYE_REFERENCE_DATA = { isDyesCategory = true }
    function ZO_Restyle_Keyboard:AddDyeCategory(attemptReselectReferenceData)
        self.dyeCategoryNode = self:AddCategory("ZO_IconChildlessHeader", NO_PARENT, GetString(SI_RESTYLE_DYES_CATEGORY_NAME), DYE_REFERENCE_DATA, "EsoUI/Art/Dye/dyes_categoryIcon_up.dds", "EsoUI/Art/Dye/dyes_categoryIcon_down.dds", "EsoUI/Art/Dye/dyes_categoryIcon_over.dds")
    end
end
function ZO_Restyle_Keyboard:AddCategory(nodeTemplate, parent, name, referenceData, normalIcon, pressedIcon, mouseoverIcon)
    local entryData = 
    {
        referenceData = referenceData, 
        name = name,
        parentData = parent and parent.data or nil,
        normalIcon = normalIcon, 
        pressedIcon = pressedIcon, 
        mouseoverIcon = mouseoverIcon,
    }
    local soundId = parent and SOUNDS.JOURNAL_PROGRESS_SUB_CATEGORY_SELECTED or SOUNDS.JOURNAL_PROGRESS_CATEGORY_SELECTED
    local node = self.categoryTree:AddNode(nodeTemplate, entryData, parent, soundId)
    entryData.node = node
    return node
end
function ZO_Restyle_Keyboard:RefreshCategoryContent()
    if SCENE_MANAGER:IsShowing("restyle_keyboard") then
        local categoryData = self.categoryTree:GetSelectedData()
        local referenceData = categoryData.referenceData
        if referenceData.isDyesCategory then
            SCENE_MANAGER:AddFragment(KEYBOARD_DYEING_FRAGMENT)
            --TODO: Remove the collectible grid fragment
        elseif referenceData.collectibleCategoryIndex then
            SCENE_MANAGER:RemoveFragment(KEYBOARD_DYEING_FRAGMENT)
            --TODO: Add the collectible grid fragment
        end
    end
end
function ZO_Restyle_Keyboard:InitializeSheet(sheetClassTemplate, slotGridData)
    local function OnDyeSlotClicked(...)
        self:OnDyeSlotClicked(...)
    end
    local function OnDyeSlotEnter(...)
        self:OnDyeSlotEnter(...)
    end
    local function OnDyeSlotExit(...)
        self:OnDyeSlotExit(...)
    end
    local sheet = sheetClassTemplate:New(self.sheetsContainer, slotGridData)
    self.sheetsByMode[sheet:GetRestyleMode()] = sheet
end
function ZO_Restyle_Keyboard:InitializeEquipmentSheet()
    local slotGridData =
    {
        [ZO_RESTYLE_SHEET_CONTAINER.PRIMARY] = 
        {
            [EQUIP_SLOT_HEAD] = { row = 1, column = 1, controlName = "Head" }, [EQUIP_SLOT_OFF_HAND] = { row = 1, column = 2, controlName = "Shield" }, [EQUIP_SLOT_BACKUP_OFF] = { row = 1, column = 2, controlName = "BackupShield" }, -- Switches with Shield on show based on ActiveWeaponPair
            [EQUIP_SLOT_SHOULDERS] = { row = 2, column = 1, controlName = "Shoulders" }, [EQUIP_SLOT_CHEST] = { row = 2, column = 2, controlName = "Chest" },
            [EQUIP_SLOT_HAND] = { row = 3, column = 1, controlName = "Hand" }, [EQUIP_SLOT_WAIST] = { row = 3, column = 2, controlName = "Waist" },
            [EQUIP_SLOT_LEGS] = { row = 4, column = 1, controlName = "Legs" }, [EQUIP_SLOT_FEET] = { row = 4, column = 2, controlName = "Feet" },
        },
    }
    self:InitializeSheet(ZO_RestyleEquipmentSlotsSheet, slotGridData)
end
function ZO_Restyle_Keyboard:InitializeCollectibleSheet()
    local slotGridData =
    {
        [ZO_RESTYLE_SHEET_CONTAINER.PRIMARY] = 
        {
            [COLLECTIBLE_CATEGORY_TYPE_HAT] = { row = 1, column = 1, controlName = "Hat" }, [COLLECTIBLE_CATEGORY_TYPE_COSTUME] = { row = 1, column = 2, controlName = "Costume" },
        },
    }
    self:InitializeSheet(ZO_RestyleCollectibleSlotsSheet, slotGridData)
end
function ZO_Restyle_Keyboard:InitializeKeybindStripDescriptors()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_CENTER,
        -- Apply dye
        {
            name = GetString(SI_DYEING_COMMIT),
            keybind = "UI_SHORTCUT_SECONDARY",
            visible = function() return ZO_Dyeing_AreTherePendingDyes(self.mode) end,
            callback = function() self:CommitSelection() end,
        },
        -- Uniform Randomize
        {
            name = GetString(SI_DYEING_RANDOMIZE),
            keybind = "UI_SHORTCUT_TERTIARY",
            callback = function() self:UniformRandomize() end,
        },
        -- Undo
        {
            name = GetString(SI_DYEING_UNDO),
            keybind = "UI_SHORTCUT_NEGATIVE",
            visible = function() return ZO_Dyeing_AreTherePendingDyes(self.mode) end,
            callback = function() self:UndoPendingChanges() end,
        },
        -- Special exit button
        {
            alignment = KEYBIND_STRIP_ALIGN_RIGHT,
            name = GetString(SI_EXIT_BUTTON),
            keybind = "UI_SHORTCUT_EXIT",
            callback = function() self:AttemptExit() end,
        },
    }
end
function ZO_Restyle_Keyboard:OnDyeSlotClicked(restyleSlotData, dyeChannel, button)
    ZO_DYEING_KEYBOARD:OnDyeSlotClicked(restyleSlotData, dyeChannel, button)
end
do
    local UNKNOWN_DYE = false
    local IS_NON_PLAYER_DYE = true
    local IS_LEFT_ANCHORED = false
    function ZO_Restyle_Keyboard:OnDyeSlotEnter(restyleSlotData, dyeChannel, dyeControl)
        local activeTool = ZO_DYEING_KEYBOARD:GetActiveTool()
        if activeTool then
            local highlightSlot, highlightDyeChannel = activeTool:GetHighlightRules(restyleSlotData:GetRestyleSlotType(), dyeChannel)
            self:GetCurrentSheet():ToggleDyeableSlotHightlight(highlightSlot, true, highlightDyeChannel)
            WINDOW_MANAGER:SetMouseCursor(activeTool:GetCursorType())
        end
        local dyeId = select(dyeChannel, restyleSlotData:GetPendingDyes())
        local swatch = ZO_DYEING_KEYBOARD:GetSwatchControlFromDyeId(dyeId)
        if swatch then
            if KEYBOARD_DYEING_FRAGMENT:IsShowing() then
                ZO_Dyeing_CreateTooltipOnMouseEnter(swatch, swatch.dyeName, swatch.known, swatch.achievementId)
            else
                ZO_Dyeing_CreateTooltipOnMouseEnter(dyeControl, swatch.dyeName, swatch.known, swatch.achievementId, not IS_NON_PLAYER_DYE, IS_LEFT_ANCHORED)
            end
        else
            local dyeName, _, _, _, achievementId = GetDyeInfoById(dyeId)
            if dyeName ~= "" then
                ZO_Dyeing_CreateTooltipOnMouseEnter(dyeControl, dyeName, UNKNOWN_DYE, achievementId, IS_NON_PLAYER_DYE, IS_LEFT_ANCHORED)
            end
        end
    end
end
do
    local NO_SLOT = nil
    local NO_CHANNEL = nil
    function ZO_Restyle_Keyboard:OnDyeSlotExit(restyleSlotData, dyeChannel)
        self:GetCurrentSheet():ToggleDyeableSlotHightlight(NO_SLOT, false, NO_CHANNEL)
        WINDOW_MANAGER:SetMouseCursor(MOUSE_CURSOR_DO_NOT_CARE)
    end
end
function ZO_Restyle_Keyboard:OnPendingDyesChanged(restyleSlotData)
    local currentSheet = self:GetCurrentSheet()
    if restyleSlotData then
        currentSheet:RefreshDyeableSlotDyes(restyleSlotData)
    else
        currentSheet:MarkViewDirty()
    end
    if SCENE_MANAGER:IsShowing("restyle_keyboard") then
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    end
end
function ZO_Restyle_Keyboard:AttemptExit(exitingToAchievementId)
    self.exitingToAchievementId = exitingToAchievementId
    if ZO_Dyeing_AreTherePendingDyes(self.mode) then
        if ZO_Dyeing_AreAllItemsBound(self.mode) then
            if self.exitingToAchievementId then
                ZO_Dialogs_ShowDialog("EXIT_DYE_UI_TO_ACHIEVEMENT")
            else
                ZO_Dialogs_ShowDialog("EXIT_DYE_UI")
            end
        else
            if self.exitingToAchievementId then
                ZO_Dialogs_ShowDialog("EXIT_DYE_UI_TO_ACHIEVEMENT_BIND")
            else
                ZO_Dialogs_ShowDialog("EXIT_DYE_UI_BIND")
            end
        end
    else
        self:ConfirmExit()
    end
end
function ZO_Restyle_Keyboard:ConfirmExit(applyChanges)
    if applyChanges then
        self:ConfirmCommitSelection()
        PlaySound(SOUNDS.DYEING_APPLY_CHANGES_FROM_DIALOGUE)
    end
    if self.exitingToAchievementId then
        SYSTEMS:GetObject("achievements"):ShowAchievement(self.exitingToAchievementId)
        self.exitingToAchievementId = nil
    else
        SCENE_MANAGER:ShowBaseScene()
    end
end
function ZO_Restyle_Keyboard:ConfirmSwitchMode(applyChanges)
    if applyChanges then
        self:ConfirmCommitSelection()
        PlaySound(SOUNDS.DYEING_APPLY_CHANGES_FROM_DIALOGUE)
    else
        self:UndoPendingChanges()
    end
    self:OnTabFilterChanged(self.pendingTabData)
    self:SetMode(self.pendingMode)
    self.pendingTabData = nil
    self.pendingMode = nil
end
function ZO_Restyle_Keyboard:CommitSelection()
    if ZO_Dyeing_AreAllItemsBound(self.mode) then
        self:ConfirmCommitSelection()
        PlaySound(SOUNDS.DYEING_APPLY_CHANGES)
    else
        ZO_Dialogs_ShowDialog("CONFIRM_APPLY_DYE")
    end
end
function ZO_Restyle_Keyboard:ConfirmCommitSelection()
    ApplyPendingDyes()
end
function ZO_Restyle_Keyboard:CancelExitToAchievements()
    self.exitingToAchievementId = nil
end
function ZO_Restyle_Keyboard:CancelExit()
    MAIN_MENU_MANAGER:CancelBlockingSceneNextScene()
end
function ZO_Restyle_Keyboard:UniformRandomize()
    ZO_Dyeing_UniformRandomize(self.mode, function() return ZO_DYEING_KEYBOARD:GetRandomUnlockedDyeId() end)
end
function ZO_Restyle_Keyboard:UndoPendingChanges()
    PlaySound(SOUNDS.DYEING_UNDO_CHANGES)
end
function ZO_Restyle_Keyboard:GetCurrentSheet()
    return self.sheetsByMode[self.mode]
end
function ZO_Restyle_Keyboard:GetMode()
    return self.mode
end
function ZO_Restyle_Keyboard:OnSearchTextChanged()
    local restyleModeCategoryData = ZO_RESTYLE_MODE_CATEGORY_DATA[self.mode]
    local editText = self.contentSearchEditBox:GetText()
    if restyleModeCategoryData.specializedCollectibleCategory then
        COLLECTIONS_BOOK_SINGLETON:SetSearchString(editText)
    end
    if restyleModeCategoryData.allowsDyeing then
        ZO_DYEING_MANAGER:SetSearchString(editText)
    end
end
    ZO_RESTYLE_KEYBOARD:OnSearchTextChanged()
end
    ZO_RESTYLE_KEYBOARD = ZO_Restyle_Keyboard:New(control)
    SYSTEMS:RegisterKeyboardObject("restyle", ZO_RESTYLE_KEYBOARD)
end