Back to Home

ESO Lua File v101041

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
--[[ 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:SetValueWithSound(targetValue)
    local oldValue = self:GetValue()
    self:SetValue(targetValue)
    local newValue = self:GetValue()
    if oldValue ~= newValue then
        PlaySound(SOUNDS.DEFAULT_CLICK)
    end
end
function ZO_GamepadSlider:MoveLeft()
end
function ZO_GamepadSlider:MoveRight()
end
    zo_mixin(control, ZO_GamepadSlider)
    control:Initialize()
end
    if control.valueChangedCallback then
    end
end
--[[ Gamepad Constrained Slider ]]--
-- Adds functionality that can constrain a slider from going past a specified min or max, that is independent of the min/max values of the slider itself.
-- 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_GamepadConstrainedSlider = {}
function ZO_GamepadConstrainedSlider:SetValueConstraints(minValueFunction, maxValueFunction)
end
function ZO_GamepadConstrainedSlider:MoveLeft()
    local prevValue = self:GetValue() - self:GetValueStep()
    if self.minValueFunction then
        prevValue = math.max(prevValue, self.minValueFunction())
    end
    
    self:SetValueWithSound(prevValue)
end
function ZO_GamepadConstrainedSlider:MoveRight()
    local nextValue = self:GetValue() + self:GetValueStep()
    
    if self.maxValueFunction then
        nextValue = math.min(nextValue, self.maxValueFunction())
    end
    
    self:SetValueWithSound(nextValue)
end
    zo_mixin(control, ZO_GamepadSlider)
    zo_mixin(control, ZO_GamepadConstrainedSlider)
    control:Initialize()
end