ESO Lua File v100015

libraries/zo_gamepadslider/zo_gamepadslider.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
--[[ Gamepad Options Slider ]]--
ZO_GamepadSlider = {}
function ZO_GamepadSlider:Initialize()
    self.movementController = ZO_MovementController:New(MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL)
    self.movementController:SetAllowAcceleration(true)
end
function ZO_GamepadSlider:Activate()
    self:SetActive(true)
end
function ZO_GamepadSlider:Deactivate()
    self:SetActive(false)
end
function ZO_GamepadSlider:SetActive(active)
    if self.active ~= active then
        self.active= active
        if self.active then
            DIRECTIONAL_INPUT:Activate(self, self)
        else
            DIRECTIONAL_INPUT:Deactivate(self)
        end
    end
end
function ZO_GamepadSlider:UpdateDirectionalInput()
    local result = self.movementController:CheckMovement()
    if result == MOVEMENT_CONTROLLER_MOVE_NEXT then
        self:MoveRight()
    elseif result == MOVEMENT_CONTROLLER_MOVE_PREVIOUS then
        self:MoveLeft()
    end
end
function ZO_GamepadSlider:MoveLeft()
    local oldValue = self:GetValue()
    local prevValue = oldValue - self:GetValueStep()
    self:SetValue(prevValue)
    local newValue = self:GetValue()
    if oldValue ~= newValue then
        PlaySound(SOUNDS.DEFAULT_CLICK)
    end
end
function ZO_GamepadSlider:MoveRight()
    local oldValue = self:GetValue()
    local nextValue = oldValue + self:GetValueStep()
    self:SetValue(nextValue)
    local newValue = self:GetValue()
    if oldValue ~= newValue then
        PlaySound(SOUNDS.DEFAULT_CLICK)
    end
end
    zo_mixin(control, ZO_GamepadSlider)
    control:Initialize()
end
    if control.valueChangedCallback then
    end
end
--[[ Paired Slider ]]--
-- Adds functionality that blocks the slider from setting values outside of a specific paired slider's range.
-- This is useful when having two sliders such as for min/max values, and not wanting them to
-- Be able to push beyond the other slider's value (Min slider blocks max slider from going to low and vice versa)
ZO_GamepadPairedSlider = {}
function ZO_GamepadPairedSlider:SetMinPair(slider)
    self.minSlider = slider
end
function ZO_GamepadPairedSlider:SetMaxPair(slider)
    self.maxSlider = slider
end
function ZO_GamepadPairedSlider:MoveLeft()
    local prevValue = self:GetValue() - self:GetValueStep()
    if self.minSlider then
        if prevValue < self.minSlider:GetValue() then return end
    end
    
    self:SetValue(prevValue)
end
function ZO_GamepadPairedSlider:MoveRight()
    local nextValue = self:GetValue() + self:GetValueStep()
    
    if self.maxSlider then
        if nextValue > self.maxSlider:GetValue() then return end
    end
    
    self:SetValue(nextValue)
end
    zo_mixin(control, ZO_GamepadSlider)
    zo_mixin(control, ZO_GamepadPairedSlider)
    control:Initialize()
end