@flashist/flibs 0.0.232 → 0.0.233
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/package.json +1 -1
- package/sounds/abstract/AbstractSoundsManager.d.ts +13 -8
- package/sounds/abstract/AbstractSoundsManager.js +47 -36
- package/sounds/abstract/AbstractSoundsManager.js.map +1 -1
- package/sounds/abstract/SoundsManagerEvent.js +1 -1
- package/sounds/abstract/SoundsManagerEvent.js.map +1 -1
package/package.json
CHANGED
|
@@ -2,24 +2,29 @@ import { AssociativeArray, BaseObject, Lock } from "@flashist/fcore";
|
|
|
2
2
|
import { Sound } from "../../index";
|
|
3
3
|
export declare abstract class AbstractSoundsManager extends BaseObject {
|
|
4
4
|
protected soundsToIdMap: AssociativeArray<Sound>;
|
|
5
|
-
protected
|
|
6
|
-
protected muteLock: Lock;
|
|
7
|
-
private _isMuted;
|
|
5
|
+
protected disableLock: Lock;
|
|
8
6
|
private _enabled;
|
|
7
|
+
private _isActivated;
|
|
8
|
+
private _isMuted;
|
|
9
9
|
private _tweenVolumeValue;
|
|
10
10
|
defaultTweenTime: number;
|
|
11
11
|
protected volume: number;
|
|
12
12
|
protected construction(...args: any[]): void;
|
|
13
13
|
registerSound(id: string, sound: Sound): void;
|
|
14
14
|
getSound(id: string): Sound;
|
|
15
|
+
/**
|
|
16
|
+
* Used to disable (aka mute) Sounds Manager (e.g. when focus is lost / tab is switched).
|
|
17
|
+
* It's different from the mute value, because the mute value will be controlled by the sound control buttons
|
|
18
|
+
* and saved / restored from the local storage (aka save system)
|
|
19
|
+
*/
|
|
20
|
+
get enabled(): boolean;
|
|
21
|
+
protected calculateEnabled(): void;
|
|
15
22
|
addDisableLock(locker: any): void;
|
|
16
23
|
removeDisableLock(locker: any): void;
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
get isActivated(): boolean;
|
|
25
|
+
activate(): void;
|
|
19
26
|
get isMuted(): boolean;
|
|
20
|
-
|
|
21
|
-
get enabled(): boolean;
|
|
22
|
-
protected calculateEnabled(): void;
|
|
27
|
+
set isMuted(value: boolean);
|
|
23
28
|
protected commitData(): void;
|
|
24
29
|
getVolume(): number;
|
|
25
30
|
setVolume(value: number): void;
|
|
@@ -21,10 +21,8 @@ var AbstractSoundsManager = /** @class */ (function (_super) {
|
|
|
21
21
|
function AbstractSoundsManager() {
|
|
22
22
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
23
23
|
_this.soundsToIdMap = new AssociativeArray();
|
|
24
|
-
_this.
|
|
25
|
-
_this.
|
|
26
|
-
_this._isMuted = false;
|
|
27
|
-
_this._enabled = true;
|
|
24
|
+
_this.disableLock = new Lock();
|
|
25
|
+
_this._enabled = false;
|
|
28
26
|
_this.defaultTweenTime = 0.5;
|
|
29
27
|
_this.volume = 1;
|
|
30
28
|
return _this;
|
|
@@ -35,7 +33,7 @@ var AbstractSoundsManager = /** @class */ (function (_super) {
|
|
|
35
33
|
args[_i] = arguments[_i];
|
|
36
34
|
}
|
|
37
35
|
_super.prototype.construction.apply(this, args);
|
|
38
|
-
this.
|
|
36
|
+
this.disableLock = new Lock();
|
|
39
37
|
this.setVolume(this.volume);
|
|
40
38
|
};
|
|
41
39
|
AbstractSoundsManager.prototype.registerSound = function (id, sound) {
|
|
@@ -44,66 +42,79 @@ var AbstractSoundsManager = /** @class */ (function (_super) {
|
|
|
44
42
|
AbstractSoundsManager.prototype.getSound = function (id) {
|
|
45
43
|
return this.soundsToIdMap.getItem(id);
|
|
46
44
|
};
|
|
45
|
+
Object.defineProperty(AbstractSoundsManager.prototype, "enabled", {
|
|
46
|
+
// ENABLED: START
|
|
47
|
+
/**
|
|
48
|
+
* Used to disable (aka mute) Sounds Manager (e.g. when focus is lost / tab is switched).
|
|
49
|
+
* It's different from the mute value, because the mute value will be controlled by the sound control buttons
|
|
50
|
+
* and saved / restored from the local storage (aka save system)
|
|
51
|
+
*/
|
|
52
|
+
get: function () {
|
|
53
|
+
return this._enabled;
|
|
54
|
+
},
|
|
55
|
+
enumerable: false,
|
|
56
|
+
configurable: true
|
|
57
|
+
});
|
|
58
|
+
AbstractSoundsManager.prototype.calculateEnabled = function () {
|
|
59
|
+
var prevIsMuted = this.enabled;
|
|
60
|
+
var newIsMuted = !this.disableLock.enabled;
|
|
61
|
+
this._enabled = newIsMuted;
|
|
62
|
+
if (newIsMuted !== prevIsMuted) {
|
|
63
|
+
this.dispatchEvent(SoundsManagerEvent.ENABLED_CHANGE);
|
|
64
|
+
}
|
|
65
|
+
this.commitData();
|
|
66
|
+
};
|
|
47
67
|
AbstractSoundsManager.prototype.addDisableLock = function (locker) {
|
|
48
|
-
this.
|
|
68
|
+
this.disableLock.add(locker);
|
|
49
69
|
this.calculateEnabled();
|
|
50
70
|
};
|
|
51
71
|
AbstractSoundsManager.prototype.removeDisableLock = function (locker) {
|
|
52
|
-
this.
|
|
72
|
+
this.disableLock.remove(locker);
|
|
53
73
|
this.calculateEnabled();
|
|
54
74
|
};
|
|
55
|
-
AbstractSoundsManager.prototype
|
|
56
|
-
|
|
57
|
-
this.calculateMuted();
|
|
58
|
-
};
|
|
59
|
-
AbstractSoundsManager.prototype.removeMuteLock = function (locker) {
|
|
60
|
-
this.muteLock.remove(locker);
|
|
61
|
-
this.calculateMuted();
|
|
62
|
-
};
|
|
63
|
-
Object.defineProperty(AbstractSoundsManager.prototype, "isMuted", {
|
|
75
|
+
Object.defineProperty(AbstractSoundsManager.prototype, "isActivated", {
|
|
76
|
+
// ENABLED: END
|
|
64
77
|
get: function () {
|
|
65
|
-
return this.
|
|
78
|
+
return this._isActivated;
|
|
66
79
|
},
|
|
67
80
|
enumerable: false,
|
|
68
81
|
configurable: true
|
|
69
82
|
});
|
|
70
|
-
AbstractSoundsManager.prototype.
|
|
71
|
-
|
|
72
|
-
var newIsMuted = !this.mutedLock.enabled;
|
|
73
|
-
this._isMuted = newIsMuted;
|
|
74
|
-
if (this.enabled !== prevIsMuted) {
|
|
75
|
-
this.dispatchEvent(SoundsManagerEvent.IS_MUTED_CHANGE);
|
|
76
|
-
}
|
|
83
|
+
AbstractSoundsManager.prototype.activate = function () {
|
|
84
|
+
this._isActivated = true;
|
|
77
85
|
this.commitData();
|
|
78
86
|
};
|
|
79
|
-
Object.defineProperty(AbstractSoundsManager.prototype, "
|
|
87
|
+
Object.defineProperty(AbstractSoundsManager.prototype, "isMuted", {
|
|
80
88
|
get: function () {
|
|
81
|
-
return this.
|
|
89
|
+
return this._isMuted;
|
|
90
|
+
},
|
|
91
|
+
set: function (value) {
|
|
92
|
+
if (value === this.isMuted) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this._isMuted = value;
|
|
96
|
+
this.dispatchEvent(SoundsManagerEvent.IS_MUTED_CHANGE);
|
|
97
|
+
this.commitData();
|
|
82
98
|
},
|
|
83
99
|
enumerable: false,
|
|
84
100
|
configurable: true
|
|
85
101
|
});
|
|
86
|
-
AbstractSoundsManager.prototype.calculateEnabled = function () {
|
|
87
|
-
var prevEnabled = this.enabled;
|
|
88
|
-
var newEnabled = !this.mutedLock.enabled;
|
|
89
|
-
this._enabled = newEnabled;
|
|
90
|
-
if (this.enabled !== prevEnabled) {
|
|
91
|
-
this.dispatchEvent(SoundsManagerEvent.ENABLED_CHANGE);
|
|
92
|
-
}
|
|
93
|
-
this.commitData();
|
|
94
|
-
};
|
|
95
102
|
AbstractSoundsManager.prototype.commitData = function () {
|
|
96
103
|
_super.prototype.commitData.call(this);
|
|
97
|
-
if (!this.
|
|
104
|
+
if (!this.isActivated) {
|
|
98
105
|
return;
|
|
99
106
|
}
|
|
100
107
|
var newVolume = this.getVolume();
|
|
101
108
|
if (this.isMuted) {
|
|
102
109
|
newVolume = 0;
|
|
103
110
|
}
|
|
111
|
+
if (!this.enabled) {
|
|
112
|
+
newVolume = 0;
|
|
113
|
+
}
|
|
104
114
|
// this.internalSetVolume(newVolume);
|
|
105
115
|
this.internalSetVolume(newVolume);
|
|
106
116
|
};
|
|
117
|
+
// VOLUME: START
|
|
107
118
|
AbstractSoundsManager.prototype.getVolume = function () {
|
|
108
119
|
return this.volume;
|
|
109
120
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractSoundsManager.js","sourceRoot":"","sources":["../../../src/sounds/abstract/AbstractSoundsManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAC,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAExD;IAAoD,yCAAU;IAA9D;QAAA,
|
|
1
|
+
{"version":3,"file":"AbstractSoundsManager.js","sourceRoot":"","sources":["../../../src/sounds/abstract/AbstractSoundsManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAC,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAExD;IAAoD,yCAAU;IAA9D;QAAA,qEAoKC;QAlKa,mBAAa,GAA4B,IAAI,gBAAgB,EAAS,CAAC;QAEvE,iBAAW,GAAS,IAAI,IAAI,EAAE,CAAC;QACjC,cAAQ,GAAY,KAAK,CAAC;QAO3B,sBAAgB,GAAW,GAAG,CAAC;QAE5B,YAAM,GAAW,CAAC,CAAC;;IAsJjC,CAAC;IApJa,4CAAY,GAAtB;QAAuB,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QAC1B,iBAAM,YAAY,aAAI,IAAI,EAAE;QAE5B,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;QAE9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAEM,6C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AC,CAAC;QAC7B,SAAS,CAAC,EAAE,CACR,IAAI,EACJ,IAAI,EACJ;YACI,gBAAgB,EAAE,MAAM;YAExB,UAAU,EAAE;gBACR,IAAI,UAAU,EAAE;oBACZ,UAAU,EAAE,CAAC;iBAChB;YACL,CAAC;SACJ,CACJ,CAAC;IACN,CAAC;IAED,sBAAc,mDAAgB;aAA9B;YACI,OAAO,IAAI,CAAC,iBAAiB,CAAC;QAClC,CAAC;aACD,UAA+B,KAAa;YACxC,IAAI,KAAK,KAAK,IAAI,CAAC,iBAAiB,EAAE;gBAClC,OAAO;aACV;YAED,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC3C,CAAC;;;OARA;IAUL,4BAAC;AAAD,CAAC,AApKD,CAAoD,UAAU,GAoK7D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export var SoundsManagerEvent = {
|
|
2
2
|
VOLUME_CHANGE: "SoundsManagerEvent.VOLUME_CHANGE",
|
|
3
3
|
ENABLED_CHANGE: "SoundsManagerEvent.ENABLED_CHANGE",
|
|
4
|
-
IS_MUTED_CHANGE: "SoundsManagerEvent.
|
|
4
|
+
IS_MUTED_CHANGE: "SoundsManagerEvent.MUTED_CHANGE"
|
|
5
5
|
};
|
|
6
6
|
//# sourceMappingURL=SoundsManagerEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SoundsManagerEvent.js","sourceRoot":"","sources":["../../../src/sounds/abstract/SoundsManagerEvent.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,kBAAkB,GAAG;IAC9B,aAAa,EAAE,kCAAkC;IACjD,cAAc,EAAE,mCAAmC;IACnD,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"SoundsManagerEvent.js","sourceRoot":"","sources":["../../../src/sounds/abstract/SoundsManagerEvent.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,kBAAkB,GAAG;IAC9B,aAAa,EAAE,kCAAkC;IACjD,cAAc,EAAE,mCAAmC;IACnD,eAAe,EAAE,iCAAiC;CACrD,CAAC"}
|