react-simple-game-engine 0.2.69 → 0.2.70
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.
@@ -2,14 +2,18 @@ import { ReactNode } from "react";
|
|
2
2
|
import { SoundType } from "../export-enums";
|
3
3
|
import { SoundManagement } from "../export-types";
|
4
4
|
import { Scene } from "./scene";
|
5
|
+
declare type SoundWatcherChildProps = {
|
6
|
+
toggle: () => void;
|
7
|
+
set: (on: boolean) => void;
|
8
|
+
};
|
5
9
|
declare type SoundOnceWatcherProps = {
|
6
10
|
scene: Scene;
|
7
|
-
children: (value: SoundManagement[SoundType.ONCE]) => ReactNode;
|
11
|
+
children: (value: SoundManagement[SoundType.ONCE] & SoundWatcherChildProps) => ReactNode;
|
8
12
|
};
|
9
13
|
export declare function SoundOnceWatcher({ scene, children }: SoundOnceWatcherProps): JSX.Element;
|
10
14
|
declare type SoundBackgroundWatcherProps = {
|
11
15
|
scene: Scene;
|
12
|
-
children: (value: SoundManagement[SoundType.BACKGROUND]) => ReactNode;
|
16
|
+
children: (value: SoundManagement[SoundType.BACKGROUND] & SoundWatcherChildProps) => ReactNode;
|
13
17
|
};
|
14
18
|
export declare function SoundBackgroundWatcher({ scene, children, }: SoundBackgroundWatcherProps): JSX.Element;
|
15
19
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sound-watcher.d.ts","sourceRoot":"","sources":["../../src/classes/sound-watcher.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
1
|
+
{"version":3,"file":"sound-watcher.d.ts","sourceRoot":"","sources":["../../src/classes/sound-watcher.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoC,MAAM,OAAO,CAAC;AACpE,OAAO,EAAiB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,aAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,GAAG,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5B,CAAC;AAEF,aAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,CACR,KAAK,EAAE,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,sBAAsB,KAC5D,SAAS,CAAC;CAChB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,qBAAqB,eAwB1E;AAED,aAAK,2BAA2B,GAAG;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,CACR,KAAK,EAAE,eAAe,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,sBAAsB,KAClE,SAAS,CAAC;CAChB,CAAC;AACF,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EACL,QAAQ,GACT,EAAE,2BAA2B,eAyB7B"}
|
@@ -10,24 +10,52 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
13
|
-
import { useEffect, useState } from "react";
|
13
|
+
import { useCallback, useEffect, useState } from "react";
|
14
|
+
import { SoundStoreKey } from "../export-enums";
|
15
|
+
import { Saver } from "./saver";
|
14
16
|
export function SoundOnceWatcher(_a) {
|
15
17
|
var scene = _a.scene, children = _a.children;
|
16
18
|
var _b = useState(scene.soundOnceOptions), values = _b[0], setValues = _b[1];
|
17
19
|
useEffect(function () {
|
18
20
|
return scene.onSoundOnceOptionsChange(function (options) {
|
19
|
-
setValues(__assign({}, options));
|
21
|
+
setValues(function (prev) { return (__assign(__assign({}, prev), options)); });
|
20
22
|
});
|
21
23
|
}, [scene]);
|
22
|
-
|
24
|
+
var toggle = useCallback(function () {
|
25
|
+
var next = !scene.soundOnceOptions.canPlay;
|
26
|
+
scene.soundOnceOptions = {
|
27
|
+
canPlay: next,
|
28
|
+
};
|
29
|
+
Saver.set(SoundStoreKey.ONCE, next);
|
30
|
+
}, []);
|
31
|
+
var set = useCallback(function (on) {
|
32
|
+
scene.soundOnceOptions = {
|
33
|
+
canPlay: on,
|
34
|
+
};
|
35
|
+
Saver.set(SoundStoreKey.ONCE, on);
|
36
|
+
}, []);
|
37
|
+
return _jsx(_Fragment, { children: children(__assign(__assign({}, values), { toggle: toggle, set: set })) });
|
23
38
|
}
|
24
39
|
export function SoundBackgroundWatcher(_a) {
|
25
40
|
var scene = _a.scene, children = _a.children;
|
26
41
|
var _b = useState(scene.soundBackgroundOptions), values = _b[0], setValues = _b[1];
|
27
42
|
useEffect(function () {
|
28
43
|
return scene.onSoundBackgroundOptionsChange(function (options) {
|
29
|
-
setValues(__assign({}, options));
|
44
|
+
setValues(function (prev) { return (__assign(__assign({}, prev), options)); });
|
30
45
|
});
|
31
46
|
}, [scene]);
|
32
|
-
|
47
|
+
var toggle = useCallback(function () {
|
48
|
+
var next = !scene.soundBackgroundOptions.canPlay;
|
49
|
+
scene.soundBackgroundOptions = {
|
50
|
+
canPlay: next,
|
51
|
+
};
|
52
|
+
Saver.set(SoundStoreKey.BACKGROUND, next);
|
53
|
+
}, []);
|
54
|
+
var set = useCallback(function (on) {
|
55
|
+
scene.soundBackgroundOptions = {
|
56
|
+
canPlay: on,
|
57
|
+
};
|
58
|
+
Saver.set(SoundStoreKey.BACKGROUND, on);
|
59
|
+
}, []);
|
60
|
+
return _jsx(_Fragment, { children: children(__assign(__assign({}, values), { toggle: toggle, set: set })) });
|
33
61
|
}
|
package/lib/export-enums.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"export-enums.d.ts","sourceRoot":"","sources":["../src/export-enums.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,IAAI,IAAA;IACJ,UAAU,IAAA;CACX;AAED,oBAAY,UAAU;IACpB,SAAS,IAAA;IACT,QAAQ,IAAA;CACT;AAED,oBAAY,kBAAkB;IAC5B,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB"}
|
1
|
+
{"version":3,"file":"export-enums.d.ts","sourceRoot":"","sources":["../src/export-enums.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,IAAI,IAAA;IACJ,UAAU,IAAA;CACX;AAED,oBAAY,UAAU;IACpB,SAAS,IAAA;IACT,QAAQ,IAAA;CACT;AAED,oBAAY,kBAAkB;IAC5B,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,oBAAY,aAAa;IACvB,IAAI,eAAe;IACnB,UAAU,qBAAqB;CAChC"}
|
package/lib/export-enums.js
CHANGED
@@ -21,3 +21,8 @@ export var JoystickDirection;
|
|
21
21
|
JoystickDirection["LEFT"] = "LEFT";
|
22
22
|
JoystickDirection["BACKWARD"] = "BACKWARD";
|
23
23
|
})(JoystickDirection || (JoystickDirection = {}));
|
24
|
+
export var SoundStoreKey;
|
25
|
+
(function (SoundStoreKey) {
|
26
|
+
SoundStoreKey["ONCE"] = "sound-once";
|
27
|
+
SoundStoreKey["BACKGROUND"] = "sound-background";
|
28
|
+
})(SoundStoreKey || (SoundStoreKey = {}));
|