@quenty/buttonhighlightmodel 3.1.2 → 3.2.1-canary.8533eea.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/LICENSE.md +1 -1
- package/package.json +8 -7
- package/src/Client/ButtonHighlightModel.lua +89 -37
- package/src/node_modules.project.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.2.1-canary.8533eea.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/buttonhighlightmodel@3.2.0...@quenty/buttonhighlightmodel@3.2.1-canary.8533eea.0) (2021-12-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* ButtonHighlightModel can act as a model for Blend ([1aa7796](https://github.com/Quenty/NevermoreEngine/commit/1aa7796ca4f3b0397966dfd605545219172e1339))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/buttonhighlightmodel@3.1.2...@quenty/buttonhighlightmodel@3.2.0) (2021-11-20)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* Support MacOS syncing ([#225](https://github.com/Quenty/NevermoreEngine/issues/225)) ([03f9183](https://github.com/Quenty/NevermoreEngine/commit/03f918392c6a5bdd33f8a17c38de371d1e06c67a))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [3.1.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/buttonhighlightmodel@3.1.1...@quenty/buttonhighlightmodel@3.1.2) (2021-10-30)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @quenty/buttonhighlightmodel
|
package/LICENSE.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/buttonhighlightmodel",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.2.1-canary.8533eea.0",
|
|
4
4
|
"description": "Contains model information for the current button",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,14 +26,15 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/acceltween": "
|
|
30
|
-
"@quenty/baseobject": "
|
|
31
|
-
"@quenty/loader": "
|
|
32
|
-
"@quenty/maid": "
|
|
33
|
-
"@quenty/
|
|
29
|
+
"@quenty/acceltween": "2.0.0",
|
|
30
|
+
"@quenty/baseobject": "3.2.0",
|
|
31
|
+
"@quenty/loader": "3.1.1",
|
|
32
|
+
"@quenty/maid": "2.0.1",
|
|
33
|
+
"@quenty/rx": "3.4.1-canary.8533eea.0",
|
|
34
|
+
"@quenty/steputils": "3.0.0"
|
|
34
35
|
},
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public"
|
|
37
38
|
},
|
|
38
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "8533eeade3bf6835c0295785c1c326b9abee3222"
|
|
39
40
|
}
|
|
@@ -8,6 +8,8 @@ local AccelTween = require("AccelTween")
|
|
|
8
8
|
local BaseObject = require("BaseObject")
|
|
9
9
|
local StepUtils = require("StepUtils")
|
|
10
10
|
local Maid = require("Maid")
|
|
11
|
+
local Blend = require("Blend")
|
|
12
|
+
local Rx = require("Rx")
|
|
11
13
|
|
|
12
14
|
local ButtonHighlightModel = setmetatable({}, BaseObject)
|
|
13
15
|
ButtonHighlightModel.ClassName = "ButtonHighlightModel"
|
|
@@ -16,7 +18,7 @@ ButtonHighlightModel.__index = ButtonHighlightModel
|
|
|
16
18
|
function ButtonHighlightModel.new(button, onUpdate)
|
|
17
19
|
local self = setmetatable(BaseObject.new(assert(button, "Bad button")), ButtonHighlightModel)
|
|
18
20
|
|
|
19
|
-
self._onUpdate =
|
|
21
|
+
self._onUpdate = onUpdate
|
|
20
22
|
|
|
21
23
|
-- Readonly
|
|
22
24
|
self.InteractionEnabled = Instance.new("BoolValue")
|
|
@@ -33,18 +35,6 @@ function ButtonHighlightModel.new(button, onUpdate)
|
|
|
33
35
|
self.IsMouseOrTouchOver.Value = false
|
|
34
36
|
self._maid:GiveTask(self.IsMouseOrTouchOver)
|
|
35
37
|
|
|
36
|
-
self._percentHighlighted = AccelTween.new(200)
|
|
37
|
-
self._percentHighlighted.t = 0
|
|
38
|
-
self._percentHighlighted.p = 0
|
|
39
|
-
|
|
40
|
-
self._percentChoosen = AccelTween.new(200)
|
|
41
|
-
self._percentChoosen.t = 0
|
|
42
|
-
self._percentChoosen.p = 0
|
|
43
|
-
|
|
44
|
-
self._percentPress = AccelTween.new(200)
|
|
45
|
-
self._percentPress.t = 0
|
|
46
|
-
self._percentPress.p = 0
|
|
47
|
-
|
|
48
38
|
self._isMouseDown = Instance.new("BoolValue")
|
|
49
39
|
self._isMouseDown.Value = false
|
|
50
40
|
self._maid:GiveTask(self._isMouseDown)
|
|
@@ -53,9 +43,10 @@ function ButtonHighlightModel.new(button, onUpdate)
|
|
|
53
43
|
self._numFingerDown.Value = 0
|
|
54
44
|
self._maid:GiveTask(self._numFingerDown)
|
|
55
45
|
|
|
56
|
-
|
|
57
|
-
self.
|
|
58
|
-
self.
|
|
46
|
+
-- readonly
|
|
47
|
+
self.IsChoosen = Instance.new("BoolValue")
|
|
48
|
+
self.IsChoosen.Value = false
|
|
49
|
+
self._maid:GiveTask(self.IsChoosen)
|
|
59
50
|
|
|
60
51
|
self._isKeyDown = Instance.new("BoolValue")
|
|
61
52
|
self._isKeyDown.Value = false
|
|
@@ -65,7 +56,15 @@ function ButtonHighlightModel.new(button, onUpdate)
|
|
|
65
56
|
self._isMouseOver.Value = false
|
|
66
57
|
self._maid:GiveTask(self._isMouseOver)
|
|
67
58
|
|
|
68
|
-
|
|
59
|
+
-- readonly
|
|
60
|
+
self.IsHighlighted = Instance.new("BoolValue")
|
|
61
|
+
self.IsHighlighted.Value = false
|
|
62
|
+
self._maid:GiveTask(self.IsHighlighted)
|
|
63
|
+
|
|
64
|
+
-- readonly
|
|
65
|
+
self.IsPressed = Instance.new("BoolValue")
|
|
66
|
+
self.IsPressed.Value = false
|
|
67
|
+
self._maid:GiveTask(self.IsPressed)
|
|
69
68
|
|
|
70
69
|
self._maid:GiveTask(self._obj.InputEnded:Connect(function(inputObject)
|
|
71
70
|
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
|
|
@@ -103,34 +102,93 @@ function ButtonHighlightModel.new(button, onUpdate)
|
|
|
103
102
|
end
|
|
104
103
|
end))
|
|
105
104
|
|
|
105
|
+
-- Legacy update stepping mode
|
|
106
|
+
if self._onUpdate then
|
|
107
|
+
self._percentHighlightedAccelTween = AccelTween.new(200)
|
|
108
|
+
self._percentHighlightedAccelTween.t = 0
|
|
109
|
+
self._percentHighlightedAccelTween.p = 0
|
|
110
|
+
|
|
111
|
+
self._maid:GiveTask(self.IsHighlighted.Changed:Connect(function()
|
|
112
|
+
self._percentHighlightedAccelTween.t = self.IsHighlighted.Value and 1 or 0
|
|
113
|
+
self:StartAnimation()
|
|
114
|
+
end))
|
|
115
|
+
|
|
116
|
+
self._percentChoosenAccelTween = AccelTween.new(200)
|
|
117
|
+
self._percentChoosenAccelTween.t = 0
|
|
118
|
+
self._percentChoosenAccelTween.p = 0
|
|
119
|
+
|
|
120
|
+
self._maid:GiveTask(self.IsChoosen.Changed:Connect(function()
|
|
121
|
+
self._percentChoosenAccelTween.t = self.IsChoosen.Value and 1 or 0
|
|
122
|
+
self:StartAnimation()
|
|
123
|
+
end))
|
|
124
|
+
|
|
125
|
+
self._percentPressAccelTween = AccelTween.new(200)
|
|
126
|
+
self._percentPressAccelTween.t = 0
|
|
127
|
+
self._percentPressAccelTween.p = 0
|
|
128
|
+
|
|
129
|
+
self._maid:GiveTask(self.IsPressed.Changed:Connect(function()
|
|
130
|
+
self._percentPressAccelTween.t = self.IsPressed.Value and 1 or 0
|
|
131
|
+
self:StartAnimation()
|
|
132
|
+
end))
|
|
133
|
+
|
|
134
|
+
self.StartAnimation, self._maid._stop = StepUtils.bindToRenderStep(self._update)
|
|
135
|
+
self:StartAnimation()
|
|
136
|
+
end
|
|
137
|
+
|
|
106
138
|
self._maid:GiveTask(self._isMouseOver.Changed:Connect(function()
|
|
107
|
-
self:
|
|
139
|
+
self:_updateTargets()
|
|
108
140
|
end))
|
|
109
141
|
self._maid:GiveTask(self._numFingerDown.Changed:Connect(function()
|
|
110
|
-
self:
|
|
142
|
+
self:_updateTargets()
|
|
111
143
|
end))
|
|
112
144
|
|
|
113
|
-
self._maid:GiveTask(self.
|
|
114
|
-
self:
|
|
145
|
+
self._maid:GiveTask(self.IsChoosen.Changed:Connect(function()
|
|
146
|
+
self:_updateTargets()
|
|
115
147
|
end))
|
|
116
148
|
|
|
117
149
|
self._maid:GiveTask(self._isKeyDown.Changed:Connect(function()
|
|
118
|
-
self:
|
|
150
|
+
self:_updateTargets()
|
|
119
151
|
end))
|
|
120
152
|
|
|
121
153
|
self._maid:GiveTask(self.IsSelected.Changed:Connect(function()
|
|
122
|
-
self:
|
|
154
|
+
self:_updateTargets()
|
|
123
155
|
end))
|
|
124
156
|
|
|
125
157
|
self._maid:GiveTask(self._isMouseDown.Changed:Connect(function()
|
|
126
|
-
self:
|
|
158
|
+
self:_updateTargets()
|
|
127
159
|
end))
|
|
128
|
-
|
|
129
|
-
self:_updatePercentHighlighted()
|
|
160
|
+
self:_updateTargets()
|
|
130
161
|
|
|
131
162
|
return self
|
|
132
163
|
end
|
|
133
164
|
|
|
165
|
+
function ButtonHighlightModel:ObservePercentPressed()
|
|
166
|
+
return Blend.AccelTween(Blend.toPropertyObservable(self.IsPressed)
|
|
167
|
+
:Pipe({
|
|
168
|
+
Rx.map(function(value)
|
|
169
|
+
return value and 1 or 0
|
|
170
|
+
end);
|
|
171
|
+
}), 200)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
function ButtonHighlightModel:ObservePercentHiglighted()
|
|
175
|
+
return Blend.AccelTween(Blend.toPropertyObservable(self.IsHighlighted)
|
|
176
|
+
:Pipe({
|
|
177
|
+
Rx.map(function(value)
|
|
178
|
+
return value and 1 or 0
|
|
179
|
+
end);
|
|
180
|
+
}), 200)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
function ButtonHighlightModel:ObservePercentChoosen()
|
|
184
|
+
return Blend.AccelTween(Blend.toPropertyObservable(self.IsChoosen)
|
|
185
|
+
:Pipe({
|
|
186
|
+
Rx.map(function(value)
|
|
187
|
+
return value and 1 or 0
|
|
188
|
+
end);
|
|
189
|
+
}), 200)
|
|
190
|
+
end
|
|
191
|
+
|
|
134
192
|
function ButtonHighlightModel:IsInteractionEnabled()
|
|
135
193
|
return self.InteractionEnabled.Value
|
|
136
194
|
end
|
|
@@ -148,7 +206,7 @@ end
|
|
|
148
206
|
function ButtonHighlightModel:SetIsChoosen(isChoosen)
|
|
149
207
|
assert(type(isChoosen) == "boolean", "Bad isChoosen")
|
|
150
208
|
|
|
151
|
-
self.
|
|
209
|
+
self.IsChoosen.Value = isChoosen
|
|
152
210
|
end
|
|
153
211
|
|
|
154
212
|
function ButtonHighlightModel:_trackTouch(inputObject)
|
|
@@ -177,25 +235,19 @@ function ButtonHighlightModel:_stopTouchTrack(inputObject)
|
|
|
177
235
|
self._maid[inputObject] = nil
|
|
178
236
|
end
|
|
179
237
|
|
|
180
|
-
function ButtonHighlightModel:
|
|
238
|
+
function ButtonHighlightModel:_updateTargets()
|
|
181
239
|
self.IsMouseOrTouchOver.Value = self._isMouseOver.Value or self._numFingerDown.Value > 0
|
|
182
|
-
|
|
183
|
-
|
|
240
|
+
self.IsPressed.Value = (self._isMouseDown.Value or self._isKeyDown.Value or self._numFingerDown.Value > 0)
|
|
241
|
+
self.IsHighlighted.Value = self.IsChoosen.Value
|
|
184
242
|
or self.IsSelected.Value
|
|
185
243
|
or self._numFingerDown.Value > 0
|
|
186
244
|
or self._isKeyDown.Value
|
|
187
245
|
or self._isMouseOver.Value
|
|
188
246
|
or self._isMouseDown.Value
|
|
189
|
-
|
|
190
|
-
self._percentPress.t = (self._isMouseDown.Value or self._isKeyDown.Value or self._numFingerDown.Value > 0) and 1 or 0
|
|
191
|
-
self._percentChoosen.t = self._isChoosen.Value and 1 or 0
|
|
192
|
-
self._percentHighlighted.t = shouldHighlight and 1 or 0
|
|
193
|
-
|
|
194
|
-
self:StartAnimation()
|
|
195
247
|
end
|
|
196
248
|
|
|
197
249
|
function ButtonHighlightModel:_update()
|
|
198
|
-
return self._onUpdate(self.
|
|
250
|
+
return self._onUpdate(self._percentHighlightedAccelTween, self._percentChoosenAccelTween, self._percentPressAccelTween)
|
|
199
251
|
end
|
|
200
252
|
|
|
201
253
|
return ButtonHighlightModel
|