ESO Lua File v100012

ingame/dyeing/gamepad/dyeing_saved_gamepad.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
ZO_Dyeing_Saved_Gamepad = ZO_Dyeing_RadialMenu_Gamepad:Subclass()
    control.multiFocusControl = control:GetNamedChild("Dyes")
    control.dyeControls = control.multiFocusControl.dyeControls
    control.singleFocusControl = control.dyeControls[1]
    control.highlight = control:GetNamedChild("SharedHighlight")
    control.switchIcon = control:GetNamedChild("SwitchIcon")
    control.dyeSelector = ZO_GamepadFocus:New(control, nil, MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL)
    control.dyeSelector:SetFocusChangedCallback(function(entry) ZO_Dyeing_Gamepad_Highlight(control, entry and entry.control) end)
    for i=1, #control.dyeControls do
        local dyeControl = control.dyeControls[i]
        local entry = {
                        control = dyeControl,
                        slotIndex = i,
                    }
        control.dyeSelector:AddEntry(entry)
    end
    control.Activate = function(control, ...)
                control.dyeSelector:SetFocusByIndex(1)
                control.dyeSelector:Activate(...)
            end
    control.Deactivate = function(control, ...)
                control.dyeSelector:Deactivate(...)
            end
end
function ZO_Dyeing_Saved_Gamepad:New(control, sharedHighlight)
    local savedSlots = ZO_Dyeing_RadialMenu_Gamepad.New(self, control, "ZO_DyeingSaved_Gamepad", sharedHighlight)
    savedSlots.controlsBySlot = {}
    savedSlots.savedSlotSetupFunction = function(...) savedSlots:SetupSavedSlot(...) end
    savedSlots.switchSetupFunction = function(...) savedSlots:SetupSwitchControl(...) end
    return savedSlots
end
function ZO_Dyeing_Saved_Gamepad:SetupSavedSlot(control, data)
    local savedSlotIndex = data.savedSlotIndex
    self.controlsBySlot[savedSlotIndex] = control
    control.shouldHighlight = true
    for dyeChannel, dyeControl in ipairs(control.dyeControls) do
        local currentDyeIndex = select(dyeChannel, GetSavedDyeSetDyes(savedSlotIndex))
        ZO_DyeingUtils_SetSlotDyeSwatchDyeIndex(dyeChannel, dyeControl, currentDyeIndex)
    end
end
function ZO_Dyeing_Saved_Gamepad:SetupSwitchControl(control, data)
    control:GetNamedChild("SwitchIcon"):SetHidden(false)
    control:GetNamedChild("Dyes"):SetHidden(true)
    control.shouldHighlight = false
end
function ZO_Dyeing_Saved_Gamepad:Populate()
    self:ResetData()
    for i=1, GetNumSavedDyeSets() do
        local data = {
                    savedSlotIndex = i,
                    setupFunc = self.savedSlotSetupFunction,
                }
        self:AddEntry(nil, nil, nil, nil, data)
    end
    local data = {
                setupFunc = self.switchSetupFunction,
            }
    self:AddEntry(nil, nil, nil, nil, data)
    self:Refresh()
end