@quenty/highlight 1.0.1-canary.288.c2f64f9.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 +11 -0
- package/LICENSE.md +21 -0
- package/README.md +21 -0
- package/default.project.json +6 -0
- package/package.json +46 -0
- package/src/Client/AnimatedHighlight.lua +187 -0
- package/src/Client/AnimatedHighlight.story.lua +38 -0
- package/src/Client/AnimatedHighlightGroup.lua +213 -0
- package/src/Client/AnimatedHighlightGroup.story.lua +40 -0
- package/src/node_modules.project.json +7 -0
- package/test/default.project.json +11 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 1.0.1-canary.288.c2f64f9.0 (2022-09-26)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add animated highlight package ([fa70218](https://github.com/Quenty/NevermoreEngine/commit/fa702186b2cae6919fb925d5050d68c35ce6939b))
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2022 Quenty
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## Highlight
|
|
2
|
+
<div align="center">
|
|
3
|
+
<a href="http://quenty.github.io/NevermoreEngine/">
|
|
4
|
+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
|
|
5
|
+
</a>
|
|
6
|
+
<a href="https://discord.gg/mhtGUS8">
|
|
7
|
+
<img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://github.com/Quenty/NevermoreEngine/actions">
|
|
10
|
+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
|
|
11
|
+
</a>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
Animated highlight system for the Roblox highlight object
|
|
15
|
+
|
|
16
|
+
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/AnimatedHighlight">View docs →</a></div>
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
```
|
|
20
|
+
npm install @quenty/highlight --save
|
|
21
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quenty/highlight",
|
|
3
|
+
"version": "1.0.1-canary.288.c2f64f9.0",
|
|
4
|
+
"description": "Animated highlight system for the Roblox highlight object",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Roblox",
|
|
7
|
+
"Nevermore",
|
|
8
|
+
"Lua",
|
|
9
|
+
"Highlight",
|
|
10
|
+
"Blend"
|
|
11
|
+
],
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Quenty/NevermoreEngine/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/Quenty/NevermoreEngine.git",
|
|
18
|
+
"directory": "src/highlight/"
|
|
19
|
+
},
|
|
20
|
+
"funding": {
|
|
21
|
+
"type": "patreon",
|
|
22
|
+
"url": "https://www.patreon.com/quenty"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"contributors": [
|
|
26
|
+
"Quenty"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@quenty/baseobject": "5.1.2-canary.288.c2f64f9.0",
|
|
30
|
+
"@quenty/basicpane": "6.1.1-canary.288.c2f64f9.0",
|
|
31
|
+
"@quenty/blend": "5.1.1-canary.288.c2f64f9.0",
|
|
32
|
+
"@quenty/enumutils": "2.0.1-canary.288.c2f64f9.0",
|
|
33
|
+
"@quenty/instanceutils": "6.1.1-canary.288.c2f64f9.0",
|
|
34
|
+
"@quenty/loader": "5.0.2-canary.288.c2f64f9.0",
|
|
35
|
+
"@quenty/maid": "2.4.0",
|
|
36
|
+
"@quenty/math": "2.2.0",
|
|
37
|
+
"@quenty/selectionutils": "1.0.1-canary.288.c2f64f9.0",
|
|
38
|
+
"@quenty/signal": "2.3.0",
|
|
39
|
+
"@quenty/table": "3.1.0",
|
|
40
|
+
"@quenty/valueobject": "6.1.1-canary.288.c2f64f9.0"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"gitHead": "c2f64f9bb90b0e5f0e4f4bc04a58af852bac6460"
|
|
46
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@class AnimatedHighlight
|
|
3
|
+
]=]
|
|
4
|
+
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local BasicPane = require("BasicPane")
|
|
8
|
+
local BasicPaneUtils = require("BasicPaneUtils")
|
|
9
|
+
local Blend = require("Blend")
|
|
10
|
+
local SpringObject = require("SpringObject")
|
|
11
|
+
local Math = require("Math")
|
|
12
|
+
local ValueObject = require("ValueObject")
|
|
13
|
+
local EnumUtils = require("EnumUtils")
|
|
14
|
+
local Maid = require("Maid")
|
|
15
|
+
local Signal = require("Signal")
|
|
16
|
+
|
|
17
|
+
local AnimatedHighlight = setmetatable({}, BasicPane)
|
|
18
|
+
AnimatedHighlight.ClassName = "AnimatedHighlight"
|
|
19
|
+
AnimatedHighlight.__index = AnimatedHighlight
|
|
20
|
+
|
|
21
|
+
function AnimatedHighlight.new()
|
|
22
|
+
local self = setmetatable(BasicPane.new(), AnimatedHighlight)
|
|
23
|
+
|
|
24
|
+
self._adornee = Instance.new("ObjectValue")
|
|
25
|
+
self._adornee.Value = nil
|
|
26
|
+
self._maid:GiveTask(self._adornee)
|
|
27
|
+
|
|
28
|
+
self._highlightDepthMode = ValueObject.new(Enum.HighlightDepthMode.AlwaysOnTop)
|
|
29
|
+
self._maid:GiveTask(self._highlightDepthMode)
|
|
30
|
+
|
|
31
|
+
self._fillColor = Instance.new("Color3Value")
|
|
32
|
+
self._fillColor.Value = Color3.new(1, 1, 1)
|
|
33
|
+
self._maid:GiveTask(self._fillColor)
|
|
34
|
+
|
|
35
|
+
self._outlineColor = Instance.new("Color3Value")
|
|
36
|
+
self._outlineColor.Value = Color3.new(1, 1, 1)
|
|
37
|
+
self._maid:GiveTask(self._outlineColor)
|
|
38
|
+
|
|
39
|
+
self._fillTransparencySpring = SpringObject.new(0.5, 40)
|
|
40
|
+
self._maid:GiveTask(self._fillTransparencySpring)
|
|
41
|
+
|
|
42
|
+
self._outlineTransparencySpring = SpringObject.new(0, 40)
|
|
43
|
+
self._maid:GiveTask(self._outlineTransparencySpring)
|
|
44
|
+
|
|
45
|
+
self._percentVisible = SpringObject.new(BasicPaneUtils.observePercentVisible(self), 20)
|
|
46
|
+
self._maid:GiveTask(self._percentVisible)
|
|
47
|
+
|
|
48
|
+
self.Destroying = Signal.new()
|
|
49
|
+
self._maid:GiveTask(function()
|
|
50
|
+
self.Destroying:Fire()
|
|
51
|
+
self.Destroying:Destroy()
|
|
52
|
+
end)
|
|
53
|
+
|
|
54
|
+
self._maid:GiveTask(self:_render():Subscribe(function(highlight)
|
|
55
|
+
self.Gui = highlight
|
|
56
|
+
end))
|
|
57
|
+
|
|
58
|
+
return self
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
--[=[
|
|
62
|
+
Sets the depth mode. Either can be:
|
|
63
|
+
|
|
64
|
+
* Enum.HighlightDepthMode.AlwaysOnTop
|
|
65
|
+
* Enum.HighlightDepthMode.Occluded
|
|
66
|
+
|
|
67
|
+
@param depthMode Enum.HighlightDepthMode
|
|
68
|
+
]=]
|
|
69
|
+
function AnimatedHighlight:SetHighlightDepthMode(depthMode)
|
|
70
|
+
assert(EnumUtils.isOfType(Enum.HighlightDepthMode, depthMode))
|
|
71
|
+
|
|
72
|
+
self._highlightDepthMode.Value = depthMode
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
function AnimatedHighlight:SetTransparencySpeed(speed)
|
|
76
|
+
assert(type(speed) == "number", "Bad speed")
|
|
77
|
+
|
|
78
|
+
self._fillTransparencySpring.Speed = speed
|
|
79
|
+
self._outlineTransparencySpring.Speed = speed
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
function AnimatedHighlight:SetSpeed(speed)
|
|
83
|
+
assert(type(speed) == "number", "Bad speed")
|
|
84
|
+
|
|
85
|
+
self._percentVisible.Speed = speed
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
function AnimatedHighlight:Finish(doNotAnimate, callback)
|
|
89
|
+
if self._percentVisible.p == 0 and self._percentVisible.v == 0 then
|
|
90
|
+
callback()
|
|
91
|
+
|
|
92
|
+
return
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
local maid = Maid.new()
|
|
96
|
+
local done = false
|
|
97
|
+
maid:GiveTask(self._percentVisible:ObserveRenderStepped():Subscribe(function(position)
|
|
98
|
+
if position == 0 then
|
|
99
|
+
done = true
|
|
100
|
+
callback()
|
|
101
|
+
end
|
|
102
|
+
end))
|
|
103
|
+
|
|
104
|
+
self:Hide(doNotAnimate)
|
|
105
|
+
|
|
106
|
+
maid:GiveTask(function()
|
|
107
|
+
self._maid[maid] = nil
|
|
108
|
+
end)
|
|
109
|
+
self._maid[maid] = maid
|
|
110
|
+
|
|
111
|
+
if not done then
|
|
112
|
+
maid:GiveTask(self.VisibleChanged:Connect(function(isVisible)
|
|
113
|
+
if isVisible then
|
|
114
|
+
-- cancel
|
|
115
|
+
self._maid[maid]:DoCleaning()
|
|
116
|
+
end
|
|
117
|
+
end))
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
function AnimatedHighlight:SetFillColor(color)
|
|
122
|
+
assert(typeof(color) == "Color3", "Bad color")
|
|
123
|
+
|
|
124
|
+
self._fillColor.Value = color
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
function AnimatedHighlight:SetOutlineColor(color)
|
|
128
|
+
assert(typeof(color) == "Color3", "Bad color")
|
|
129
|
+
|
|
130
|
+
self._outlineColor.Value = color
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
function AnimatedHighlight:SetAdornee(adornee)
|
|
134
|
+
assert(typeof(adornee) == "Instance" or adornee == nil, "Bad adornee")
|
|
135
|
+
|
|
136
|
+
self._adornee.Value = adornee
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
function AnimatedHighlight:GetAdornee()
|
|
140
|
+
return self._adornee.Value
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
function AnimatedHighlight:SetOutlineTransparency(outlineTransparency, doNotAnimate)
|
|
144
|
+
assert(type(outlineTransparency) == "number", "Bad outlineTransparency")
|
|
145
|
+
|
|
146
|
+
self._outlineTransparencySpring.Target = outlineTransparency
|
|
147
|
+
if doNotAnimate then
|
|
148
|
+
self._outlineTransparencySpring.Position = outlineTransparency
|
|
149
|
+
self._outlineTransparencySpring.Velocity = 0
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
function AnimatedHighlight:SetFillTransparency(fillTransparency, doNotAnimate)
|
|
154
|
+
assert(type(fillTransparency) == "number", "Bad fillTransparency")
|
|
155
|
+
|
|
156
|
+
self._fillTransparencySpring.Target = fillTransparency
|
|
157
|
+
if doNotAnimate then
|
|
158
|
+
self._fillTransparencySpring.Position = fillTransparency
|
|
159
|
+
self._fillTransparencySpring.Velocity = 0
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
function AnimatedHighlight:_render()
|
|
164
|
+
return Blend.New "Highlight" {
|
|
165
|
+
Name = "AnimatedHighlight";
|
|
166
|
+
Archivable = false;
|
|
167
|
+
DepthMode = self._highlightDepthMode;
|
|
168
|
+
FillColor = self._fillColor;
|
|
169
|
+
OutlineColor = self._outlineColor;
|
|
170
|
+
FillTransparency = Blend.Computed(
|
|
171
|
+
self._fillTransparencySpring:ObserveRenderStepped(),
|
|
172
|
+
self._percentVisible:ObserveRenderStepped(),
|
|
173
|
+
function(transparency, visible)
|
|
174
|
+
return Math.map(visible, 0, 1, 1, transparency);
|
|
175
|
+
end);
|
|
176
|
+
OutlineTransparency = Blend.Computed(
|
|
177
|
+
self._outlineTransparencySpring:ObserveRenderStepped(),
|
|
178
|
+
self._percentVisible:ObserveRenderStepped(),
|
|
179
|
+
function(transparency, visible)
|
|
180
|
+
return Math.map(visible, 0, 1, 1, transparency);
|
|
181
|
+
end);
|
|
182
|
+
Adornee = self._adornee;
|
|
183
|
+
Parent = self._adornee;
|
|
184
|
+
}
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
return AnimatedHighlight
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
@class AnimatedHighlight.story
|
|
3
|
+
]]
|
|
4
|
+
|
|
5
|
+
local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).load(script)
|
|
6
|
+
|
|
7
|
+
local Maid = require("Maid")
|
|
8
|
+
local AnimatedHighlight = require("AnimatedHighlight")
|
|
9
|
+
local RxSelectionUtils = require("RxSelectionUtils")
|
|
10
|
+
|
|
11
|
+
return function(_target)
|
|
12
|
+
local maid = Maid.new()
|
|
13
|
+
|
|
14
|
+
maid:GiveTask(RxSelectionUtils.observeFirstAdornee():Subscribe(function(adornee)
|
|
15
|
+
if adornee then
|
|
16
|
+
local renderMaid = Maid.new()
|
|
17
|
+
|
|
18
|
+
local animatedHighlight = AnimatedHighlight.new()
|
|
19
|
+
animatedHighlight:SetFillColor(Color3.new(1, 0.5, 0.5))
|
|
20
|
+
animatedHighlight:SetAdornee(adornee)
|
|
21
|
+
animatedHighlight:Show()
|
|
22
|
+
|
|
23
|
+
renderMaid:GiveTask(function()
|
|
24
|
+
animatedHighlight:Finish(false, function()
|
|
25
|
+
animatedHighlight:Destroy()
|
|
26
|
+
end)
|
|
27
|
+
end)
|
|
28
|
+
|
|
29
|
+
maid._current = renderMaid
|
|
30
|
+
else
|
|
31
|
+
maid._current = nil
|
|
32
|
+
end
|
|
33
|
+
end))
|
|
34
|
+
|
|
35
|
+
return function()
|
|
36
|
+
maid:DoCleaning()
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@class AnimatedHighlightGroup
|
|
3
|
+
]=]
|
|
4
|
+
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local BaseObject = require("BaseObject")
|
|
8
|
+
local AnimatedHighlight = require("AnimatedHighlight")
|
|
9
|
+
local Maid = require("Maid")
|
|
10
|
+
local ValueObject = require("ValueObject")
|
|
11
|
+
local EnumUtils = require("EnumUtils")
|
|
12
|
+
local Set = require("Set")
|
|
13
|
+
|
|
14
|
+
local AnimatedHighlightGroup = setmetatable({}, BaseObject)
|
|
15
|
+
AnimatedHighlightGroup.ClassName = "AnimatedHighlightGroup"
|
|
16
|
+
AnimatedHighlightGroup.__index = AnimatedHighlightGroup
|
|
17
|
+
|
|
18
|
+
function AnimatedHighlightGroup.new()
|
|
19
|
+
local self = setmetatable(BaseObject.new(), AnimatedHighlightGroup)
|
|
20
|
+
|
|
21
|
+
self._highlightDepthMode = ValueObject.new(Enum.HighlightDepthMode.AlwaysOnTop)
|
|
22
|
+
self._maid:GiveTask(self._highlightDepthMode)
|
|
23
|
+
|
|
24
|
+
self._defaultFillColor = Instance.new("Color3Value")
|
|
25
|
+
self._defaultFillColor.Value = Color3.new(1, 1, 1)
|
|
26
|
+
self._maid:GiveTask(self._defaultFillColor)
|
|
27
|
+
|
|
28
|
+
self._defaultTransparencySpeed = Instance.new("NumberValue")
|
|
29
|
+
self._defaultTransparencySpeed.Value = 40
|
|
30
|
+
self._maid:GiveTask(self._defaultTransparencySpeed)
|
|
31
|
+
|
|
32
|
+
self._defaultFillTransparency = Instance.new("NumberValue")
|
|
33
|
+
self._defaultFillTransparency.Value = 0.5
|
|
34
|
+
self._maid:GiveTask(self._defaultFillTransparency)
|
|
35
|
+
|
|
36
|
+
self._defaultOutlineTransparency = Instance.new("NumberValue")
|
|
37
|
+
self._defaultOutlineTransparency.Value = 0
|
|
38
|
+
self._maid:GiveTask(self._defaultOutlineTransparency)
|
|
39
|
+
|
|
40
|
+
self._defaultSpeed = Instance.new("NumberValue")
|
|
41
|
+
self._defaultSpeed.Value = 20
|
|
42
|
+
self._maid:GiveTask(self._defaultSpeed)
|
|
43
|
+
|
|
44
|
+
self._defaultOutlineColor = Instance.new("Color3Value")
|
|
45
|
+
self._defaultOutlineColor.Value = Color3.new(1, 1, 1)
|
|
46
|
+
self._maid:GiveTask(self._defaultOutlineColor)
|
|
47
|
+
|
|
48
|
+
self._highlights = {}
|
|
49
|
+
|
|
50
|
+
return self
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
--[=[
|
|
54
|
+
Sets the depth mode. Either can be:
|
|
55
|
+
|
|
56
|
+
* Enum.HighlightDepthMode.AlwaysOnTop
|
|
57
|
+
* Enum.HighlightDepthMode.Occluded
|
|
58
|
+
|
|
59
|
+
@param depthMode Enum.HighlightDepthMode
|
|
60
|
+
]=]
|
|
61
|
+
function AnimatedHighlightGroup:SetDefaultHighlightDepthMode(depthMode)
|
|
62
|
+
assert(EnumUtils.isOfType(Enum.HighlightDepthMode, depthMode))
|
|
63
|
+
|
|
64
|
+
self._highlightDepthMode.Value = depthMode
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
function AnimatedHighlightGroup:SetDefaultFillTransparency(transparency)
|
|
68
|
+
assert(type(transparency) == "number", "Bad transparency")
|
|
69
|
+
|
|
70
|
+
self._defaultFillTransparency.Value = transparency
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
function AnimatedHighlightGroup:SetDefaultOutlineTransparency(outlineTransparency)
|
|
74
|
+
assert(type(outlineTransparency) == "number", "Bad outlineTransparency")
|
|
75
|
+
|
|
76
|
+
self._defaultFillTransparency.Value = outlineTransparency
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
function AnimatedHighlightGroup:SetDefaultFillColor(color)
|
|
80
|
+
assert(typeof(color) == "Color3", "Bad color")
|
|
81
|
+
|
|
82
|
+
self._defaultFillColor.Value = color
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
function AnimatedHighlightGroup:GetDefaultFillColor()
|
|
86
|
+
return self._defaultFillColor.Value
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
function AnimatedHighlightGroup:SetDefaultOutlineColor(color)
|
|
90
|
+
assert(typeof(color) == "Color3", "Bad color")
|
|
91
|
+
|
|
92
|
+
self._defaultOutlineColor.Value = color
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
function AnimatedHighlightGroup:SetDefaultTransparencySpeed(speed)
|
|
96
|
+
assert(type(speed) == "number", "Bad speed")
|
|
97
|
+
|
|
98
|
+
self._defaultTransparencySpeed.Value = speed
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
function AnimatedHighlightGroup:SetDefaultSpeed(speed)
|
|
102
|
+
assert(type(speed) == "number", "Bad speed")
|
|
103
|
+
|
|
104
|
+
self._defaultSpeed.Value = speed
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
function AnimatedHighlightGroup:GetDefaultOutlineColor()
|
|
108
|
+
return self._defaultOutlineColor.Value
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
function AnimatedHighlightGroup:Highlight(adornee, doNotAnimate)
|
|
112
|
+
assert(typeof(adornee) == "Instance", "Bad adornee")
|
|
113
|
+
|
|
114
|
+
local highlight = self:_getOrCreateHighlight(adornee)
|
|
115
|
+
highlight:Show(doNotAnimate)
|
|
116
|
+
return highlight
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
function AnimatedHighlightGroup:EraseAllBut(adorneeList, doNotAnimate)
|
|
120
|
+
assert(type(adorneeList) == "table", "Bad adorneeList")
|
|
121
|
+
|
|
122
|
+
local set = Set.fromList(adorneeList)
|
|
123
|
+
|
|
124
|
+
for adornee, highlight in pairs(self._highlights) do
|
|
125
|
+
if not set[adornee] then
|
|
126
|
+
highlight:Hide(doNotAnimate)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
function AnimatedHighlightGroup:EraseAll()
|
|
132
|
+
for _, highlight in pairs(self._highlights) do
|
|
133
|
+
highlight:Hide()
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
function AnimatedHighlightGroup:FindHighlight(adornee)
|
|
138
|
+
return self._highlights[adornee]
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
function AnimatedHighlightGroup:Erase(adornee)
|
|
142
|
+
assert(typeof(adornee) == "Instance", "Bad adornee")
|
|
143
|
+
|
|
144
|
+
local highlight = self:FindHighlight(adornee)
|
|
145
|
+
if highlight then
|
|
146
|
+
highlight:Hide()
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
function AnimatedHighlightGroup:ResetHighlightProperties(adornee, doNotAnimate)
|
|
151
|
+
local highlight = self:FindHighlight(adornee)
|
|
152
|
+
if highlight then
|
|
153
|
+
self:_setDefaultValues(highlight, doNotAnimate)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
function AnimatedHighlightGroup:_setDefaultValues(highlight, doNotAnimate)
|
|
158
|
+
highlight:SetHighlightDepthMode(self._highlightDepthMode.Value)
|
|
159
|
+
highlight:SetTransparencySpeed(self._defaultTransparencySpeed.Value)
|
|
160
|
+
highlight:SetSpeed(self._defaultSpeed.Value)
|
|
161
|
+
|
|
162
|
+
highlight:SetFillTransparency(self._defaultFillTransparency.Value, doNotAnimate)
|
|
163
|
+
highlight:SetOutlineTransparency(self._defaultOutlineTransparency.Value, doNotAnimate)
|
|
164
|
+
highlight:SetFillColor(self._defaultFillColor.Value)
|
|
165
|
+
highlight:SetOutlineColor(self._defaultOutlineColor.Value)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
function AnimatedHighlightGroup:_getOrCreateHighlight(adornee)
|
|
169
|
+
local foundHighlight = self._highlights[adornee]
|
|
170
|
+
if foundHighlight then
|
|
171
|
+
return foundHighlight
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
local maid = Maid.new()
|
|
175
|
+
|
|
176
|
+
local highlight = AnimatedHighlight.new()
|
|
177
|
+
self:_setDefaultValues(highlight, true)
|
|
178
|
+
highlight:SetAdornee(adornee)
|
|
179
|
+
maid:GiveTask(highlight)
|
|
180
|
+
|
|
181
|
+
maid:GiveTask(highlight.Destroying:Connect(function()
|
|
182
|
+
self:_removeHighlight(highlight)
|
|
183
|
+
end))
|
|
184
|
+
|
|
185
|
+
maid:GiveTask(highlight.VisibleChanged:Connect(function(isVisible, doNotAnimate)
|
|
186
|
+
if not isVisible then
|
|
187
|
+
highlight:Finish(doNotAnimate, function()
|
|
188
|
+
self:_removeHighlight(highlight)
|
|
189
|
+
end)
|
|
190
|
+
end
|
|
191
|
+
end))
|
|
192
|
+
|
|
193
|
+
self._highlights[adornee] = highlight
|
|
194
|
+
maid:GiveTask(function()
|
|
195
|
+
if self._highlights[adornee] == highlight then
|
|
196
|
+
self._highlights[adornee] = nil
|
|
197
|
+
end
|
|
198
|
+
end)
|
|
199
|
+
|
|
200
|
+
self._maid[highlight] = maid
|
|
201
|
+
|
|
202
|
+
return highlight
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
function AnimatedHighlightGroup:_removeHighlight(highlight)
|
|
206
|
+
self._maid[highlight] = nil
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
function AnimatedHighlightGroup:_findHighlightAdornee(adornee)
|
|
210
|
+
return self._highlights[adornee]
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
return AnimatedHighlightGroup
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
@class AnimatedHighlight.story
|
|
3
|
+
]]
|
|
4
|
+
|
|
5
|
+
local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).load(script)
|
|
6
|
+
|
|
7
|
+
local Maid = require("Maid")
|
|
8
|
+
local AnimatedHighlightGroup = require("AnimatedHighlightGroup")
|
|
9
|
+
local RxSelectionUtils = require("RxSelectionUtils")
|
|
10
|
+
|
|
11
|
+
return function(_target)
|
|
12
|
+
local maid = Maid.new()
|
|
13
|
+
|
|
14
|
+
local animatedHighlightGroup = AnimatedHighlightGroup.new()
|
|
15
|
+
animatedHighlightGroup:SetDefaultFillColor(Color3.new(0.5, 1, 0.5))
|
|
16
|
+
animatedHighlightGroup:SetDefaultSpeed(20)
|
|
17
|
+
animatedHighlightGroup:SetDefaultHighlightDepthMode(Enum.HighlightDepthMode.Occluded)
|
|
18
|
+
maid:GiveTask(animatedHighlightGroup)
|
|
19
|
+
|
|
20
|
+
maid:GiveTask(RxSelectionUtils.observeAdorneesBrio():Subscribe(function(brio)
|
|
21
|
+
if brio:IsDead() then
|
|
22
|
+
return
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
local adorneeMaid = brio:ToMaid()
|
|
26
|
+
local adornee = brio:GetValue()
|
|
27
|
+
|
|
28
|
+
animatedHighlightGroup:Highlight(adornee)
|
|
29
|
+
|
|
30
|
+
adorneeMaid:GiveTask(function()
|
|
31
|
+
if animatedHighlightGroup.Destroy then
|
|
32
|
+
animatedHighlightGroup:Erase(adornee)
|
|
33
|
+
end
|
|
34
|
+
end)
|
|
35
|
+
end))
|
|
36
|
+
|
|
37
|
+
return function()
|
|
38
|
+
maid:DoCleaning()
|
|
39
|
+
end
|
|
40
|
+
end
|