@quenty/inputmode 7.17.0 → 7.18.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,22 @@
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
+ # [7.18.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/inputmode@7.17.0...@quenty/inputmode@7.18.0) (2023-05-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * InputModeServiceClient now works in Hoarcekat stories ([ad31c5f](https://github.com/Quenty/NevermoreEngine/commit/ad31c5fe78ba888063a2c9f736803706309d7279))
12
+
13
+
14
+ ### Features
15
+
16
+ * Add InputModeTypeSelector:ObserveIsActive(inputModeType) and InputModeTypeSelector:IsActive(inputModeType) ([83ad0ea](https://github.com/Quenty/NevermoreEngine/commit/83ad0ea6903bc1970e6020f85e76cfda2a025927))
17
+
18
+
19
+
20
+
21
+
6
22
  # [7.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/inputmode@7.16.0...@quenty/inputmode@7.17.0) (2023-04-24)
7
23
 
8
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/inputmode",
3
- "version": "7.17.0",
3
+ "version": "7.18.0",
4
4
  "description": "Trace input mode state and trigger changes correctly",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -30,10 +30,10 @@
30
30
  "@quenty/servicebag": "^6.6.1",
31
31
  "@quenty/signal": "^2.3.0",
32
32
  "@quenty/table": "^3.2.0",
33
- "@quenty/valueobject": "^7.12.0"
33
+ "@quenty/valueobject": "^7.13.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "a8a760988c8fd88c2581c5c496a8bad845de104c"
38
+ "gitHead": "2ad8cea7dd3ad79a39afd7d7b785b489b90553fd"
39
39
  }
@@ -52,7 +52,19 @@ function InputModeServiceClient:GetInputMode(inputModeType)
52
52
  if not RunService:IsRunning() then
53
53
  if not self._inputModes then
54
54
  -- fake it till we make it!
55
- return InputMode.new(inputModeType)
55
+ local inputMode = InputMode.new(inputModeType)
56
+ local lastInputType = UserInputService:GetLastInputType()
57
+
58
+ -- Hack processing
59
+ if inputModeType:IsValid(lastInputType) then
60
+ inputMode:Enable()
61
+ end
62
+
63
+ if inputModeType == InputModeTypes.Keyboard or inputModeType == InputModeTypes.KeyboardAndMouse then
64
+ inputMode:Enable()
65
+ end
66
+
67
+ return inputMode
56
68
  end
57
69
  end
58
70
 
@@ -10,6 +10,8 @@ local Maid = require("Maid")
10
10
  local ValueObject = require("ValueObject")
11
11
  local InputModeServiceClient = require("InputModeServiceClient")
12
12
  local ServiceBag = require("ServiceBag")
13
+ local Rx = require("Rx")
14
+ local InputModeType = require("InputModeType")
13
15
 
14
16
  local InputModeTypeSelector = {}
15
17
  InputModeTypeSelector.ClassName = "InputModeTypeSelector"
@@ -102,6 +104,35 @@ function InputModeTypeSelector:ObserveActiveInputType()
102
104
  return rawget(self, "_activeModeType"):Observe()
103
105
  end
104
106
 
107
+ --[=[
108
+ Returns true if the input mode is the most recently activated one
109
+
110
+ @param inputModeType InputModeType
111
+ @return boolean
112
+ ]=]
113
+ function InputModeTypeSelector:IsActive(inputModeType)
114
+ assert(InputModeType.isInputModeType(inputModeType), "Bad inputModeType")
115
+
116
+ return rawget(self, "_activeModeType").Value == inputModeType
117
+ end
118
+
119
+ --[=[
120
+ Observes if the input mode is the most recently activated one
121
+
122
+ @param inputModeType InputModeType
123
+ @return Observable<boolean>
124
+ ]=]
125
+ function InputModeTypeSelector:ObserveIsActive(inputModeType)
126
+ assert(InputModeType.isInputModeType(inputModeType), "Bad inputModeType")
127
+
128
+ return self:ObserveActiveInputType():Pipe({
129
+ Rx.map(function(inputType)
130
+ return inputType == inputModeType
131
+ end);
132
+ Rx.distinct();
133
+ })
134
+ end
135
+
105
136
  --[=[
106
137
  The current active input mode
107
138
  @prop Value InputModeType?
@@ -174,6 +205,8 @@ end
174
205
  @param inputModeType InputModeType
175
206
  ]=]
176
207
  function InputModeTypeSelector:RemoveInputModeType(inputModeType)
208
+ assert(InputModeType.isInputModeType(inputModeType), "Bad inputModeType")
209
+
177
210
  if not self._maid[inputModeType] then
178
211
  return
179
212
  end
@@ -197,6 +230,8 @@ end
197
230
  @param inputModeType InputModeType
198
231
  ]=]
199
232
  function InputModeTypeSelector:AddInputModeType(inputModeType)
233
+ assert(InputModeType.isInputModeType(inputModeType), "Bad inputModeType")
234
+
200
235
  if self._maid[inputModeType] then
201
236
  return
202
237
  end