pixi-rainman-game-engine 0.2.22 → 0.2.23
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/dist/SettingsUI/components/UXSettings/index.jsx +2 -2
- package/dist/SettingsUI/components/VolumeSettings/index.jsx +8 -5
- package/dist/application/ButtonsEventManager/ButtonsEventManager.js +5 -1
- package/dist/application/SoundManager/SoundManager.js +3 -3
- package/dist/components/AbstractMainContainer/AbstractMainContainer.js +3 -2
- package/dist/stores/SettingsStore.d.ts +6 -5
- package/dist/stores/SettingsStore.js +21 -20
- package/package.json +1 -1
|
@@ -14,10 +14,10 @@ export const UXSettings = observer(() => {
|
|
|
14
14
|
<SwitchWithHeader header="Battery saver" description="Safe battery life by reducing animation speed" flag={settingStore.batterySaverFlag} setFlag={settingStore.setBatteryFlag}/>
|
|
15
15
|
</div>
|
|
16
16
|
<div className="ux-settings__switch">
|
|
17
|
-
<SwitchWithHeader header="Ambient music" description="Turn on or off the game music" flag={settingStore.
|
|
17
|
+
<SwitchWithHeader header="Ambient music" description="Turn on or off the game music" flag={settingStore.shouldPlayAmbientMusic} setFlag={settingStore.setShouldPlayAmbientMusic}/>
|
|
18
18
|
</div>
|
|
19
19
|
<div className="ux-settings__switch">
|
|
20
|
-
<SwitchWithHeader header="Sound fx" description="Turn on or off the game sounds" flag={settingStore.
|
|
20
|
+
<SwitchWithHeader header="Sound fx" description="Turn on or off the game sounds" flag={settingStore.shouldPlayFxSounds} setFlag={settingStore.setShouldPlayFxSounds}/>
|
|
21
21
|
</div>
|
|
22
22
|
<div className="ux-settings__switch">
|
|
23
23
|
<SwitchWithHeader header="Full screen mode" description="Turn on or off game fullscreen" flag={settingStore.fullScreenFlag} setFlag={settingStore.setFullScreenFlag}/>
|
|
@@ -14,7 +14,10 @@ const onChange = (newVolumeLevel) => {
|
|
|
14
14
|
};
|
|
15
15
|
const onAfterChange = (newVolumeLevel) => {
|
|
16
16
|
RainMan.settingsStore.flipSoundsEnabled(newVolumeLevel);
|
|
17
|
-
if (RainMan.settingsStore.isSoundEnabled()) {
|
|
17
|
+
if (!RainMan.settingsStore.isSoundEnabled()) {
|
|
18
|
+
SoundManager.pauseAll();
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
18
21
|
SoundManager.resumeAll();
|
|
19
22
|
}
|
|
20
23
|
};
|
|
@@ -29,16 +32,16 @@ export const VolumeSettings = observer(() => {
|
|
|
29
32
|
width: "7px",
|
|
30
33
|
height: "24px",
|
|
31
34
|
bottom: "-6px",
|
|
32
|
-
borderRadius: "4px"
|
|
35
|
+
borderRadius: "4px"
|
|
33
36
|
}} railStyle={{
|
|
34
|
-
backgroundColor: "#fff"
|
|
37
|
+
backgroundColor: "#fff"
|
|
35
38
|
}} trackStyle={{
|
|
36
39
|
backgroundColor: COLOR,
|
|
37
40
|
height: "5px",
|
|
38
|
-
borderRadius: "1px"
|
|
41
|
+
borderRadius: "1px"
|
|
39
42
|
}} onBeforeChange={onBeforeChange} onChange={onChange} onAfterChange={onAfterChange}/>
|
|
40
43
|
<p className="volume-control__text" style={{
|
|
41
|
-
color: COLOR
|
|
44
|
+
color: COLOR
|
|
42
45
|
}}>
|
|
43
46
|
{settingStore.volumeLevel}
|
|
44
47
|
</p>
|
|
@@ -196,8 +196,12 @@ export class ButtonsEventManager {
|
|
|
196
196
|
RainMan.settingsStore.setUpdateVolumeButtonTexture(() => RainMan.componentRegistry.get(VolumeButton.registryName).changeTextureDependOnVolume());
|
|
197
197
|
RainMan.componentRegistry.get(VolumeButton.registryName).setOnClick(() => {
|
|
198
198
|
RainMan.settingsStore.flipSoundsEnabled();
|
|
199
|
-
if (RainMan.settingsStore.isSoundEnabled())
|
|
199
|
+
if (RainMan.settingsStore.isSoundEnabled()) {
|
|
200
200
|
SoundManager.resumeAll();
|
|
201
|
+
if (RainMan.settingsStore.shouldPlayAmbientMusic) {
|
|
202
|
+
SoundManager.setPlayStatus("music", RainMan.settingsStore.shouldPlayAmbientMusic);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
201
205
|
RainMan.componentRegistry.get(VolumeButton.registryName).changeTextureDependOnVolume();
|
|
202
206
|
this.handleModalInvocation(UI_ITEMS.volume);
|
|
203
207
|
});
|
|
@@ -86,7 +86,7 @@ export class SoundManagerInstance {
|
|
|
86
86
|
* @param {SoundTrack} soundName - name of the sound
|
|
87
87
|
*/
|
|
88
88
|
play(soundName) {
|
|
89
|
-
if (!RainMan.settingsStore.
|
|
89
|
+
if (!RainMan.settingsStore.shouldPlayFxSounds)
|
|
90
90
|
return;
|
|
91
91
|
const overrideSoundName = this.overrides[soundName];
|
|
92
92
|
const sound = overrideSoundName
|
|
@@ -94,7 +94,7 @@ export class SoundManagerInstance {
|
|
|
94
94
|
: this.musicCatalogue.get(soundName);
|
|
95
95
|
if (!sound)
|
|
96
96
|
return;
|
|
97
|
-
if (soundName === "music" && sound.isPlaying && !RainMan.settingsStore.
|
|
97
|
+
if (soundName === "music" && sound.isPlaying && !RainMan.settingsStore.shouldPlayAmbientMusic)
|
|
98
98
|
return;
|
|
99
99
|
sound.play({
|
|
100
100
|
loop: soundsToLoop.includes(soundName),
|
|
@@ -110,7 +110,7 @@ export class SoundManagerInstance {
|
|
|
110
110
|
this.musicCatalogue.forEach((sound, soundName) => {
|
|
111
111
|
if (sound.paused && sound.isPlaying)
|
|
112
112
|
sound.resume();
|
|
113
|
-
if (RainMan.settingsStore.
|
|
113
|
+
if (RainMan.settingsStore.shouldPlayAmbientMusic && soundName === SoundTracks.music && sound.paused) {
|
|
114
114
|
sound.resume();
|
|
115
115
|
}
|
|
116
116
|
});
|
|
@@ -57,8 +57,9 @@ export class AbstractMainContainer extends Container {
|
|
|
57
57
|
this.messageBox = new MessageBox();
|
|
58
58
|
if (RainMan.settingsStore.isSoundEnabled()) {
|
|
59
59
|
SoundManager.resumeAll();
|
|
60
|
-
if (RainMan.settingsStore.
|
|
61
|
-
SoundManager.
|
|
60
|
+
if (RainMan.settingsStore.shouldPlayAmbientMusic) {
|
|
61
|
+
SoundManager.setPlayStatus(SoundTracks.music, RainMan.settingsStore.shouldPlayAmbientMusic);
|
|
62
|
+
}
|
|
62
63
|
}
|
|
63
64
|
RainMan.app.renderer.on("resize", () => this.resize());
|
|
64
65
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SpeedLevel, SymbolId } from "../application";
|
|
2
2
|
import { ResumableContainer, SpineWithResumableContainer, SpriteWithResumableContainer } from "../components";
|
|
3
3
|
import { InitDataInterface, Point, RangeQuantityValue, SpinData } from "../connectivity";
|
|
4
|
+
import { Nullable } from "../utils";
|
|
4
5
|
import { PaytableData } from "./types";
|
|
5
6
|
/**
|
|
6
7
|
* This class represents global state of pixi and react application
|
|
@@ -12,8 +13,8 @@ export declare class SettingsStore {
|
|
|
12
13
|
betChangeDisabled: boolean;
|
|
13
14
|
bet: number;
|
|
14
15
|
betText: string;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
shouldPlayAmbientMusic: boolean;
|
|
17
|
+
shouldPlayFxSounds: boolean;
|
|
17
18
|
fullScreenFlag: boolean;
|
|
18
19
|
onAnyWin: boolean;
|
|
19
20
|
totalNumberOfFreeSpins: number;
|
|
@@ -75,14 +76,14 @@ export declare class SettingsStore {
|
|
|
75
76
|
* @param {boolean} flag - new value for ambient music flag
|
|
76
77
|
* @param {boolean} saveToLocalStorage - default {@link true}, if true the flag will be saved to localStorage
|
|
77
78
|
*/
|
|
78
|
-
|
|
79
|
+
setShouldPlayAmbientMusic(flag: boolean, saveToLocalStorage?: boolean): void;
|
|
79
80
|
/**
|
|
80
81
|
* Sets flag for effect sounds
|
|
81
82
|
* @param {boolean} flag - new value for sound fx flag
|
|
82
83
|
* @param {boolean} saveToLocalStorage - default {@link true}, if true the flag will be saved to localStorage
|
|
83
84
|
*/
|
|
84
|
-
|
|
85
|
-
flipSoundsEnabled(volumeLevel?: number
|
|
85
|
+
setShouldPlayFxSounds(flag: boolean, saveToLocalStorage?: boolean): void;
|
|
86
|
+
flipSoundsEnabled(volumeLevel?: Nullable<number>): void;
|
|
86
87
|
isSoundEnabled(): boolean;
|
|
87
88
|
setFullScreenFlag(flag: boolean): void;
|
|
88
89
|
setHiResolutionFlag(flag: boolean): void;
|
|
@@ -16,10 +16,8 @@ export class SettingsStore {
|
|
|
16
16
|
betChangeDisabled = false;
|
|
17
17
|
bet = 0;
|
|
18
18
|
betText = "";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
soundFxFlag = getFromLocalStorage(LOCAL_STORAGE.isSoundFxEnabled) ??
|
|
22
|
-
getFromLocalStorage(LOCAL_STORAGE.isSoundEnabled, true);
|
|
19
|
+
shouldPlayAmbientMusic = getFromLocalStorage(LOCAL_STORAGE.isAmbientMusicEnabled, false);
|
|
20
|
+
shouldPlayFxSounds = getFromLocalStorage(LOCAL_STORAGE.isSoundFxEnabled, false);
|
|
23
21
|
fullScreenFlag = false;
|
|
24
22
|
onAnyWin = false;
|
|
25
23
|
totalNumberOfFreeSpins = 0;
|
|
@@ -74,8 +72,8 @@ export class SettingsStore {
|
|
|
74
72
|
}
|
|
75
73
|
makeAutoObservable(this, {
|
|
76
74
|
setBatteryFlag: action.bound,
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
setShouldPlayAmbientMusic: action.bound,
|
|
76
|
+
setShouldPlayFxSounds: action.bound,
|
|
79
77
|
setFullScreenFlag: action.bound,
|
|
80
78
|
setHiResolutionFlag: action.bound,
|
|
81
79
|
setSpeedLevel: action.bound,
|
|
@@ -154,8 +152,8 @@ export class SettingsStore {
|
|
|
154
152
|
* @param {boolean} flag - new value for ambient music flag
|
|
155
153
|
* @param {boolean} saveToLocalStorage - default {@link true}, if true the flag will be saved to localStorage
|
|
156
154
|
*/
|
|
157
|
-
|
|
158
|
-
this.
|
|
155
|
+
setShouldPlayAmbientMusic(flag, saveToLocalStorage = true) {
|
|
156
|
+
this.shouldPlayAmbientMusic = flag;
|
|
159
157
|
SoundManager.setPlayStatus(SoundTracks.music, flag);
|
|
160
158
|
this.updateVolumeButtonTexture?.();
|
|
161
159
|
if (saveToLocalStorage) {
|
|
@@ -168,8 +166,8 @@ export class SettingsStore {
|
|
|
168
166
|
* @param {boolean} flag - new value for sound fx flag
|
|
169
167
|
* @param {boolean} saveToLocalStorage - default {@link true}, if true the flag will be saved to localStorage
|
|
170
168
|
*/
|
|
171
|
-
|
|
172
|
-
this.
|
|
169
|
+
setShouldPlayFxSounds(flag, saveToLocalStorage = true) {
|
|
170
|
+
this.shouldPlayFxSounds = flag;
|
|
173
171
|
if (!flag)
|
|
174
172
|
SoundManager.stopPlayingFxSounds();
|
|
175
173
|
this.updateVolumeButtonTexture?.();
|
|
@@ -179,23 +177,26 @@ export class SettingsStore {
|
|
|
179
177
|
}
|
|
180
178
|
}
|
|
181
179
|
flipSoundsEnabled(volumeLevel = null) {
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
let ambientMusicFlag =
|
|
186
|
-
let soundFxFlag =
|
|
187
|
-
|
|
180
|
+
let shouldEnableSound = volumeLevel !== null ? volumeLevel > 0 : !this.isSoundEnabled();
|
|
181
|
+
const ambientEnabledInStorage = getFromLocalStorage(LOCAL_STORAGE.isAmbientMusicEnabled, true);
|
|
182
|
+
const fxEnabledInStorage = getFromLocalStorage(LOCAL_STORAGE.isSoundFxEnabled, true);
|
|
183
|
+
let ambientMusicFlag = shouldEnableSound && ambientEnabledInStorage;
|
|
184
|
+
let soundFxFlag = shouldEnableSound && fxEnabledInStorage;
|
|
185
|
+
const bothDisabledInStorage = !ambientEnabledInStorage && !fxEnabledInStorage;
|
|
186
|
+
if (bothDisabledInStorage) {
|
|
188
187
|
ambientMusicFlag = true;
|
|
189
188
|
soundFxFlag = true;
|
|
189
|
+
shouldEnableSound = true;
|
|
190
190
|
removeFromLocalStorage(LOCAL_STORAGE.isAmbientMusicEnabled);
|
|
191
191
|
removeFromLocalStorage(LOCAL_STORAGE.isSoundFxEnabled);
|
|
192
|
+
removeFromLocalStorage(LOCAL_STORAGE.isSoundEnabled);
|
|
192
193
|
}
|
|
193
|
-
this.
|
|
194
|
-
this.
|
|
195
|
-
setToLocalStorage(LOCAL_STORAGE.isSoundEnabled,
|
|
194
|
+
this.setShouldPlayAmbientMusic(ambientMusicFlag, true);
|
|
195
|
+
this.setShouldPlayFxSounds(soundFxFlag, true);
|
|
196
|
+
setToLocalStorage(LOCAL_STORAGE.isSoundEnabled, shouldEnableSound);
|
|
196
197
|
}
|
|
197
198
|
isSoundEnabled() {
|
|
198
|
-
return this.
|
|
199
|
+
return this.shouldPlayFxSounds || this.shouldPlayAmbientMusic;
|
|
199
200
|
}
|
|
200
201
|
setFullScreenFlag(flag) {
|
|
201
202
|
this.fullScreenFlag = flag;
|
package/package.json
CHANGED