@quenty/uiobjectutils 3.4.0 → 3.5.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 CHANGED
@@ -3,6 +3,18 @@
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.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/uiobjectutils@3.4.0...@quenty/uiobjectutils@3.5.0) (2023-12-14)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add PlayerGuiUtils.findPlayerGui() and documentation ([8f6ddd7](https://github.com/Quenty/NevermoreEngine/commit/8f6ddd7186b296dfe158f66f666bc08b02d02e8a))
12
+ * Add ScrollingDirectionUtils.canScrollHorizontal(scrollingDirection) ([0b18d30](https://github.com/Quenty/NevermoreEngine/commit/0b18d30af7003ce4abb75398490d40d4afb530ac))
13
+
14
+
15
+
16
+
17
+
6
18
  # [3.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/uiobjectutils@3.3.0...@quenty/uiobjectutils@3.4.0) (2023-05-26)
7
19
 
8
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/uiobjectutils",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "UI object utils library for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -27,5 +27,9 @@
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "11058e90e51ea83d3dad6ae9abe59cc19c36b94b"
30
+ "dependencies": {
31
+ "@quenty/enumutils": "^3.1.0",
32
+ "@quenty/loader": "^7.1.0"
33
+ },
34
+ "gitHead": "2c2dbbc0cb2fbb46b4f3270c559c63890fe18b26"
31
35
  }
@@ -1,4 +1,5 @@
1
1
  --[=[
2
+ Helper methods for finding and retrieving the [PlayerGui] instance
2
3
  @class PlayerGuiUtils
3
4
  ]=]
4
5
 
@@ -6,13 +7,43 @@ local Players = game:GetService("Players")
6
7
 
7
8
  local PlayerGuiUtils = {}
8
9
 
10
+ --[=[
11
+ Finds the current player gui for the [Players.LocalPlayer] property or errors.
12
+
13
+ :::warning
14
+ This method errors if it can't find the PlayerGui. Fortunately, the PlayerGui is pretty much
15
+ guaranteed to exist in most scenarios.
16
+ :::
17
+
18
+ @return PlayerGui
19
+ ]=]
9
20
  function PlayerGuiUtils.getPlayerGui()
10
21
  local localPlayer = Players.LocalPlayer
11
22
  if not localPlayer then
12
- error("No localPlayer")
23
+ error("[PlayerGuiUtils.getPlayerGui] - No localPlayer")
24
+ end
25
+
26
+ local playerGui = localPlayer:FindFirstChildOfClass("PlayerGui")
27
+ if not playerGui then
28
+ error("[PlayerGuiUtils.getPlayerGui] - No playerGui")
29
+ end
30
+
31
+ return playerGui
32
+ end
33
+
34
+ --[=[
35
+ Finds the current player gui for the [Players.LocalPlayer] property.
36
+
37
+ @return PlayerGui | nil
38
+ ]=]
39
+ function PlayerGuiUtils.findPlayerGui()
40
+ local localPlayer = Players.LocalPlayer
41
+ if not localPlayer then
42
+ return nil
13
43
  end
14
44
 
15
- return localPlayer:FindFirstChildOfClass("PlayerGui") or error("No PlayerGui")
45
+ return localPlayer:FindFirstChildOfClass("PlayerGui")
16
46
  end
17
47
 
48
+
18
49
  return PlayerGuiUtils
@@ -0,0 +1,23 @@
1
+ --[=[
2
+ @class ScrollingDirectionUtils
3
+ ]=]
4
+
5
+ local require = require(script.Parent.loader).load(script)
6
+
7
+ local EnumUtils = require("EnumUtils")
8
+
9
+ local ScrollingDirectionUtils = {}
10
+
11
+ function ScrollingDirectionUtils.canScrollHorizontal(scrollingDirection)
12
+ assert(EnumUtils.isOfType(Enum.ScrollingDirection, scrollingDirection))
13
+
14
+ return scrollingDirection == Enum.ScrollingDirection.X or scrollingDirection == Enum.ScrollingDirection.XY
15
+ end
16
+
17
+ function ScrollingDirectionUtils.canScrollVertical(scrollingDirection)
18
+ assert(EnumUtils.isOfType(Enum.ScrollingDirection, scrollingDirection))
19
+
20
+ return scrollingDirection == Enum.ScrollingDirection.Y or scrollingDirection == Enum.ScrollingDirection.XY
21
+ end
22
+
23
+ return ScrollingDirectionUtils
@@ -0,0 +1,33 @@
1
+ --[=[
2
+ @class UIRotationUtils
3
+ ]=]
4
+
5
+ local require = require(script.Parent.loader).load(script)
6
+
7
+ local UIRotationUtils = {}
8
+
9
+ function UIRotationUtils.toUnitCircle(rotationDegrees)
10
+ assert(type(rotationDegrees) == "number", "Bad rotationDegrees")
11
+
12
+ return -rotationDegrees + 90
13
+ end
14
+
15
+ function UIRotationUtils.toUnitCircleDirection(rotationDegrees)
16
+ assert(type(rotationDegrees) == "number", "Bad rotationDegrees")
17
+
18
+ local angle = math.rad(UIRotationUtils.toUnitCircle(rotationDegrees))
19
+
20
+ local x = math.cos(angle)
21
+ local y = math.sin(angle)
22
+
23
+ return Vector2.new(x, y)
24
+ end
25
+
26
+ function UIRotationUtils.toGuiDirection(unitCircleDirection)
27
+ assert(typeof(unitCircleDirection) == "Vector2", "Bad rotationAnchorPoint")
28
+
29
+ return unitCircleDirection*Vector2.new(1, -1)
30
+ end
31
+
32
+
33
+ return UIRotationUtils
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "node_modules",
3
+ "globIgnorePaths": [ "**/.package-lock.json" ],
4
+ "tree": {
5
+ "$path": { "optional": "../node_modules" }
6
+ }
7
+ }