@quenty/sprites 13.16.0 → 13.16.1
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
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
## [13.16.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sprites@13.16.0...@quenty/sprites@13.16.1) (2025-04-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [13.16.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sprites@13.15.2...@quenty/sprites@13.16.0) (2025-04-02)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/sprites
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/sprites",
|
|
3
|
-
"version": "13.16.
|
|
3
|
+
"version": "13.16.1",
|
|
4
4
|
"description": "Spritesheet utility for Roblox including a built-in InputImageLibrary",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/baseobject": "^10.8.
|
|
30
|
-
"@quenty/loader": "^10.8.
|
|
31
|
-
"@quenty/maid": "^3.4.
|
|
32
|
-
"@quenty/uiobjectutils": "^6.16.
|
|
29
|
+
"@quenty/baseobject": "^10.8.1",
|
|
30
|
+
"@quenty/loader": "^10.8.1",
|
|
31
|
+
"@quenty/maid": "^3.4.1",
|
|
32
|
+
"@quenty/uiobjectutils": "^6.16.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@quenty/string": "^3.3.
|
|
35
|
+
"@quenty/string": "^3.3.2"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
|
|
41
41
|
}
|
|
@@ -157,7 +157,7 @@ local function makeSection(keycodes, theme, platform, parent)
|
|
|
157
157
|
uiGridLayout.CellSize = UDim2.new(0, 100, 0, 130)
|
|
158
158
|
uiGridLayout.Parent = container
|
|
159
159
|
|
|
160
|
-
for _, item in
|
|
160
|
+
for _, item in keycodes do
|
|
161
161
|
createInputKey(item, theme, platform, container)
|
|
162
162
|
end
|
|
163
163
|
|
|
@@ -29,22 +29,22 @@ end
|
|
|
29
29
|
|
|
30
30
|
@return { string }
|
|
31
31
|
]=]
|
|
32
|
-
function InputImageLibrary:GetPreloadAssetIds()
|
|
32
|
+
function InputImageLibrary:GetPreloadAssetIds(): { string }
|
|
33
33
|
local assets = {}
|
|
34
|
-
for _, platformSheets in
|
|
35
|
-
for _, sheet in
|
|
34
|
+
for _, platformSheets in self._spritesheets do
|
|
35
|
+
for _, sheet in platformSheets do
|
|
36
36
|
table.insert(assets, sheet:GetPreloadAssetId())
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
return assets
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
function InputImageLibrary:_loadSpriteSheets(parentFolder)
|
|
42
|
+
function InputImageLibrary:_loadSpriteSheets(parentFolder: Instance)
|
|
43
43
|
assert(typeof(parentFolder) == "Instance", "Bad parentFolder")
|
|
44
44
|
|
|
45
|
-
for _, platform in
|
|
45
|
+
for _, platform in parentFolder:GetChildren() do
|
|
46
46
|
self._spritesheets[platform.Name] = {}
|
|
47
|
-
for _, style in
|
|
47
|
+
for _, style in platform:GetChildren() do
|
|
48
48
|
if style:IsA("ModuleScript") then
|
|
49
49
|
self._spritesheets[platform.Name][style.Name] = require(style).new()
|
|
50
50
|
end
|
|
@@ -56,11 +56,11 @@ end
|
|
|
56
56
|
Retrieves a sprite from the library
|
|
57
57
|
|
|
58
58
|
@param keyCode any -- The sprite keyCode to get
|
|
59
|
-
@param preferredStyle string -- The preferred style type to retrieve this in
|
|
60
|
-
@param preferredPlatform string -- The preferred platform to get the sprite for
|
|
59
|
+
@param preferredStyle string? -- The preferred style type to retrieve this in
|
|
60
|
+
@param preferredPlatform string? -- The preferred platform to get the sprite for
|
|
61
61
|
@return Sprite
|
|
62
62
|
]=]
|
|
63
|
-
function InputImageLibrary:GetSprite(keyCode, preferredStyle
|
|
63
|
+
function InputImageLibrary:GetSprite(keyCode, preferredStyle: string?, preferredPlatform: string?)
|
|
64
64
|
assert(keyCode ~= nil, "Bad keyCode")
|
|
65
65
|
assert(type(preferredStyle) == "string" or preferredStyle == nil, "Bad preferredStyle")
|
|
66
66
|
assert(type(preferredPlatform) == "string" or preferredPlatform == nil, "Bad preferredPlatform")
|
|
@@ -83,11 +83,11 @@ end
|
|
|
83
83
|
|
|
84
84
|
@param gui ImageLabel | ImageButton
|
|
85
85
|
@param keyCode any -- The sprite keyCode to get
|
|
86
|
-
@param preferredStyle string -- The preferred style type to retrieve this in
|
|
87
|
-
@param preferredPlatform string -- The preferred platform to get the sprite for
|
|
86
|
+
@param preferredStyle string? -- The preferred style type to retrieve this in
|
|
87
|
+
@param preferredPlatform string? -- The preferred platform to get the sprite for
|
|
88
88
|
@return Sprite
|
|
89
89
|
]=]
|
|
90
|
-
function InputImageLibrary:StyleImage(gui, keyCode, preferredStyle
|
|
90
|
+
function InputImageLibrary:StyleImage(gui, keyCode, preferredStyle: string?, preferredPlatform: string?)
|
|
91
91
|
assert(typeof(gui) == "Instance" and (gui:IsA("ImageLabel") or gui:IsA("ImageButton")), "Bad gui")
|
|
92
92
|
assert(keyCode ~= nil, "Bad keyCode")
|
|
93
93
|
assert(type(preferredStyle) == "string" or preferredStyle == nil, "Bad preferredStyle")
|
|
@@ -118,7 +118,7 @@ function InputImageLibrary:_getDefaultPreferredPlatform()
|
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
-
function InputImageLibrary:GetScaledImageLabel(keyCode, preferredStyle
|
|
121
|
+
function InputImageLibrary:GetScaledImageLabel(keyCode, preferredStyle: string?, preferredPlatform: string?)
|
|
122
122
|
assert(keyCode ~= nil, "Bad keyCode")
|
|
123
123
|
assert(type(preferredStyle) == "string" or preferredStyle == nil, "Bad preferredStyle")
|
|
124
124
|
assert(type(preferredPlatform) == "string" or preferredPlatform == nil, "Bad preferredPlatform")
|
|
@@ -129,7 +129,7 @@ function InputImageLibrary:GetScaledImageLabel(keyCode, preferredStyle, preferre
|
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
local size = image.Size
|
|
132
|
-
local ratio = size.Y.Offset/size.X.Offset
|
|
132
|
+
local ratio = size.Y.Offset / size.X.Offset
|
|
133
133
|
|
|
134
134
|
local uiAspectRatio = Instance.new("UIAspectRatioConstraint")
|
|
135
135
|
uiAspectRatio.DominantAxis = Enum.DominantAxis.Height
|
|
@@ -141,7 +141,7 @@ function InputImageLibrary:GetScaledImageLabel(keyCode, preferredStyle, preferre
|
|
|
141
141
|
return image
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
-
function InputImageLibrary:PickSheet(keyCode, preferredStyle
|
|
144
|
+
function InputImageLibrary:PickSheet(keyCode, preferredStyle: string?, preferredPlatform: string?)
|
|
145
145
|
assert(keyCode ~= nil, "Bad keyCode")
|
|
146
146
|
assert(type(preferredStyle) == "string" or preferredStyle == nil, "Bad preferredStyle")
|
|
147
147
|
assert(type(preferredPlatform) == "string" or preferredPlatform == nil, "Bad preferredPlatform")
|
|
@@ -153,11 +153,13 @@ function InputImageLibrary:PickSheet(keyCode, preferredStyle, preferredPlatform)
|
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
-- otherwise search (yes, we double hit a sheet)
|
|
156
|
-
for _, sheet in
|
|
156
|
+
for _, sheet in platformSheets do
|
|
157
157
|
if sheet:HasSprite(keyCode) then
|
|
158
158
|
return sheet
|
|
159
159
|
end
|
|
160
160
|
end
|
|
161
|
+
|
|
162
|
+
return nil
|
|
161
163
|
end
|
|
162
164
|
|
|
163
165
|
preferredPlatform = preferredPlatform or self:_getDefaultPreferredPlatform()
|
|
@@ -171,7 +173,7 @@ function InputImageLibrary:PickSheet(keyCode, preferredStyle, preferredPlatform)
|
|
|
171
173
|
end
|
|
172
174
|
|
|
173
175
|
-- otherwise search (repeats preferred :/ )
|
|
174
|
-
for _, platformSheets in
|
|
176
|
+
for _, platformSheets in self._spritesheets do
|
|
175
177
|
local foundSheet = findSheet(platformSheets)
|
|
176
178
|
if foundSheet then
|
|
177
179
|
return foundSheet
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
A single image on a spritesheet.
|
|
3
4
|
@class Sprite
|
|
@@ -7,6 +8,16 @@ local Sprite = {}
|
|
|
7
8
|
Sprite.ClassName = "Sprite"
|
|
8
9
|
Sprite.__index = Sprite
|
|
9
10
|
|
|
11
|
+
export type Sprite = typeof(setmetatable(
|
|
12
|
+
{} :: {
|
|
13
|
+
Texture: string,
|
|
14
|
+
Size: Vector2,
|
|
15
|
+
Position: Vector2,
|
|
16
|
+
Name: string,
|
|
17
|
+
},
|
|
18
|
+
Sprite
|
|
19
|
+
))
|
|
20
|
+
|
|
10
21
|
--[=[
|
|
11
22
|
Data used to construct a sprite.
|
|
12
23
|
@interface SpriteData
|
|
@@ -16,13 +27,19 @@ Sprite.__index = Sprite
|
|
|
16
27
|
.Name string
|
|
17
28
|
@within Sprite
|
|
18
29
|
]=]
|
|
30
|
+
export type SpriteData = {
|
|
31
|
+
Texture: string,
|
|
32
|
+
Size: Vector2,
|
|
33
|
+
Position: Vector2,
|
|
34
|
+
Name: string,
|
|
35
|
+
}
|
|
19
36
|
|
|
20
37
|
--[=[
|
|
21
38
|
Constructs a new sprite
|
|
22
39
|
@param data SpriteData
|
|
23
40
|
@return Sprite
|
|
24
41
|
]=]
|
|
25
|
-
function Sprite.new(data)
|
|
42
|
+
function Sprite.new(data: SpriteData): Sprite
|
|
26
43
|
assert(data.Texture, "Bad data")
|
|
27
44
|
assert(data.Size, "Bad data")
|
|
28
45
|
assert(data.Position, "Bad data")
|
|
@@ -38,12 +55,11 @@ end
|
|
|
38
55
|
@param gui ImageLabel | ImageButton
|
|
39
56
|
@return Instance
|
|
40
57
|
]=]
|
|
41
|
-
function Sprite:Style(gui)
|
|
42
|
-
assert(typeof(gui) == "Instance" and (gui:IsA("ImageLabel") or gui:IsA("ImageButton")), "Bad gui")
|
|
43
|
-
|
|
44
|
-
gui.
|
|
45
|
-
gui.
|
|
46
|
-
gui.ImageRectSize = self.Size
|
|
58
|
+
function Sprite:Style(gui: ImageLabel | ImageButton)
|
|
59
|
+
assert(typeof(gui) == "Instance" and (gui:IsA("ImageLabel") or gui:IsA("ImageButton")), "Bad gui");
|
|
60
|
+
(gui :: ImageLabel).Image = self.Texture;
|
|
61
|
+
(gui :: ImageLabel).ImageRectOffset = self.Position;
|
|
62
|
+
(gui :: ImageLabel).ImageRectSize = self.Size
|
|
47
63
|
|
|
48
64
|
return gui
|
|
49
65
|
end
|
|
@@ -53,10 +69,10 @@ end
|
|
|
53
69
|
@param instanceType "ImageLabel" | "ImageButton"
|
|
54
70
|
@return ImageLabel | ImageButton
|
|
55
71
|
]=]
|
|
56
|
-
function Sprite:Get(instanceType)
|
|
72
|
+
function Sprite:Get(instanceType: "ImageLabel" | "ImageButton"): ImageLabel | ImageButton
|
|
57
73
|
assert(type(instanceType) == "string", "Bad instanceType")
|
|
58
74
|
|
|
59
|
-
local gui = Instance.new(instanceType)
|
|
75
|
+
local gui: any = Instance.new(instanceType)
|
|
60
76
|
gui.Size = UDim2.new(0, self.Size.X, 0, self.Size.Y)
|
|
61
77
|
gui.Name = self.Name
|
|
62
78
|
gui.BackgroundTransparency = 1
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Data model for sprite sheets
|
|
3
4
|
@class Spritesheet
|
|
@@ -11,12 +12,20 @@ local Spritesheet = {}
|
|
|
11
12
|
Spritesheet.ClassName = "Spritesheet"
|
|
12
13
|
Spritesheet.__index = Spritesheet
|
|
13
14
|
|
|
15
|
+
export type Spritesheet = typeof(setmetatable(
|
|
16
|
+
{} :: {
|
|
17
|
+
_texture: string,
|
|
18
|
+
_sprites: { [any]: Sprite.Sprite },
|
|
19
|
+
},
|
|
20
|
+
Spritesheet
|
|
21
|
+
))
|
|
22
|
+
|
|
14
23
|
--[=[
|
|
15
24
|
Constructs a new Spritesheet
|
|
16
25
|
@param texture string
|
|
17
26
|
@return Spritesheet
|
|
18
27
|
]=]
|
|
19
|
-
function Spritesheet.new(texture)
|
|
28
|
+
function Spritesheet.new(texture: string): Spritesheet
|
|
20
29
|
local self = setmetatable({}, Spritesheet)
|
|
21
30
|
|
|
22
31
|
self._texture = texture or error("no texture")
|
|
@@ -29,7 +38,7 @@ end
|
|
|
29
38
|
Retrieves the preload asset ids to use
|
|
30
39
|
@return string
|
|
31
40
|
]=]
|
|
32
|
-
function Spritesheet:GetPreloadAssetId()
|
|
41
|
+
function Spritesheet:GetPreloadAssetId(): string
|
|
33
42
|
return self._texture
|
|
34
43
|
end
|
|
35
44
|
|
|
@@ -40,17 +49,18 @@ end
|
|
|
40
49
|
|
|
41
50
|
Adds a named sprite at the given keyCode
|
|
42
51
|
]=]
|
|
43
|
-
function Spritesheet:AddSprite(keyCode, position, size)
|
|
52
|
+
function Spritesheet:AddSprite(keyCode: any, position: Vector2, size: Vector2): Sprite.Sprite
|
|
44
53
|
assert(not self._sprites[keyCode], "Already exists")
|
|
45
54
|
|
|
46
55
|
local sprite = Sprite.new({
|
|
47
|
-
Texture = self._texture
|
|
48
|
-
Position = position
|
|
49
|
-
Size = size
|
|
50
|
-
Name = tostring(keyCode)
|
|
56
|
+
Texture = self._texture,
|
|
57
|
+
Position = position,
|
|
58
|
+
Size = size,
|
|
59
|
+
Name = tostring(keyCode),
|
|
51
60
|
})
|
|
52
61
|
|
|
53
62
|
self._sprites[keyCode] = sprite
|
|
63
|
+
return sprite
|
|
54
64
|
end
|
|
55
65
|
|
|
56
66
|
--[=[
|
|
@@ -58,7 +68,7 @@ end
|
|
|
58
68
|
@param keyCode any | EnumItem
|
|
59
69
|
@return Sprite?
|
|
60
70
|
]=]
|
|
61
|
-
function Spritesheet:GetSprite(keyCode)
|
|
71
|
+
function Spritesheet:GetSprite(keyCode: any): Sprite.Sprite?
|
|
62
72
|
if not keyCode then
|
|
63
73
|
warn("[Spritesheet.GetSprite] - Image name cannot be nil")
|
|
64
74
|
return nil
|
|
@@ -81,7 +91,7 @@ end
|
|
|
81
91
|
@param keyCode any | EnumItem
|
|
82
92
|
@return boolean
|
|
83
93
|
]=]
|
|
84
|
-
function Spritesheet:HasSprite(keyCode)
|
|
94
|
+
function Spritesheet:HasSprite(keyCode: any): boolean
|
|
85
95
|
return self:GetSprite(keyCode) ~= nil
|
|
86
96
|
end
|
|
87
97
|
|