pixi-rainman-game-engine 0.1.16 → 0.1.18

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.
@@ -6,7 +6,7 @@ import React, { useEffect, useState } from "react";
6
6
  import { COMPONENTS } from "../../../components";
7
7
  import { UI_ITEMS } from "../../../utils";
8
8
  import { useStores } from "../../hooks";
9
- import { closeModal, CloseModalButton } from "../CloseModalButton";
9
+ import { CloseModalButton } from "../CloseModalButton";
10
10
  import { RichLimitingSlider } from "../RichLimitingSlider";
11
11
  import { SpeedButtonWithHeader, SwitchWithHeader } from "../SwitchWithHeader";
12
12
  export const AutoplaySettings = observer(() => {
@@ -109,11 +109,11 @@ export const AutoplaySettings = observer(() => {
109
109
  <div className="autoplay-settings__confirmation-button" onClick={() => {
110
110
  resetAutoplaySettings();
111
111
  updateLimitsBounds(initialAutoSpinCount);
112
- closeModal(UI_ITEMS.autoplay);
112
+ settingStore.handleModalInvocation?.(UI_ITEMS.autoplay);
113
113
  }}>
114
114
  <p>{i18next.t("cancel")}</p>
115
115
  </div>
116
- <div id={COMPONENTS.autoSpinConfirm} className="autoplay-settings__confirmation-button" onClick={() => closeModal(UI_ITEMS.autoplay)}>
116
+ <div id={COMPONENTS.autoSpinConfirm} className="autoplay-settings__confirmation-button" onClick={() => settingStore.handleModalInvocation?.(UI_ITEMS.autoplay)}>
117
117
  <p>{i18next.t("confirm")}</p>
118
118
  </div>
119
119
  </div>
@@ -4,5 +4,4 @@ export type CloseModalButtonProps = {
4
4
  layerId: string;
5
5
  afterClose?: () => void;
6
6
  };
7
- export declare const closeModal: (modalID: string, afterCloseCallBack?: () => void) => void;
8
7
  export declare const CloseModalButton: ({ layerId, afterClose }: CloseModalButtonProps) => JSX.Element;
@@ -1,13 +1,13 @@
1
1
  import "./closeModalButton.css";
2
2
  import React from "react";
3
- export const closeModal = (modalID, afterCloseCallBack) => {
4
- const gameRulesModal = window.document.getElementById(modalID);
5
- if (gameRulesModal !== null)
6
- gameRulesModal.style.display = "none";
7
- afterCloseCallBack && afterCloseCallBack();
8
- };
3
+ import { useStores } from "../../hooks";
9
4
  export const CloseModalButton = ({ layerId, afterClose }) => {
10
- return (<button className="close-modal-button" onClick={() => closeModal(layerId, afterClose)}>
5
+ const { settingStore } = useStores();
6
+ const onClose = () => {
7
+ settingStore.handleModalInvocation?.(layerId);
8
+ afterClose?.();
9
+ };
10
+ return (<button className="close-modal-button" onClick={onClose}>
11
11
  x
12
12
  </button>);
13
13
  };
@@ -5,9 +5,11 @@ import { observer } from "mobx-react-lite";
5
5
  import React, { useState } from "react";
6
6
  import CustomScroll from "react-custom-scroll";
7
7
  import { UI_ITEMS } from "../../../utils";
8
- import { closeModal, CloseModalButton } from "../CloseModalButton";
8
+ import { useStores } from "../../hooks";
9
+ import { CloseModalButton } from "../CloseModalButton";
9
10
  import { gameRulesContent } from "./data";
10
11
  export const GameRules = observer(() => {
12
+ const { settingStore } = useStores();
11
13
  const [pageNumber, setPageNumber] = useState(0);
12
14
  const changePage = (incrementor) => {
13
15
  const numberOfPages = gameRulesContent.pages.length;
@@ -34,7 +36,7 @@ export const GameRules = observer(() => {
34
36
  </div>
35
37
  <div className="game-rules__page-control">
36
38
  <div className="page-left" onClick={() => changePage(-1)}></div>
37
- <div className="page-middle" onClick={() => closeModal(UI_ITEMS.gameRules)}></div>
39
+ <div className="page-middle" onClick={() => settingStore.handleModalInvocation?.(UI_ITEMS.gameRules)}></div>
38
40
  <div className="page-right" onClick={() => changePage(1)}></div>
39
41
  </div>
40
42
  </div>);
@@ -4,7 +4,6 @@ import React from "react";
4
4
  import { RainMan } from "../../../Rainman";
5
5
  import { UI_ITEMS } from "../../../utils";
6
6
  import { useStores } from "../../hooks";
7
- import { closeModal } from "../CloseModalButton";
8
7
  export const OptionButton = ({ option, currency, setMessage }) => {
9
8
  const { settingStore } = useStores();
10
9
  const onButtonClick = async (option) => {
@@ -24,7 +23,7 @@ export const OptionButton = ({ option, currency, setMessage }) => {
24
23
  settingStore.setRoundNumber(data.getRawData().round_number);
25
24
  settingStore.setFreeSpinNumberBought(option.amount);
26
25
  RainMan.globals.throttledSpin?.();
27
- closeModal(UI_ITEMS.freeSpin);
26
+ settingStore.handleModalInvocation?.(UI_ITEMS.freeSpin);
28
27
  }
29
28
  catch (err) {
30
29
  setMessage(err.message);
@@ -18,6 +18,7 @@ export declare class ButtonsEventManager {
18
18
  private setButtonAvailability;
19
19
  enableButtons: () => void;
20
20
  disableButtons: () => void;
21
+ constructor();
21
22
  /**
22
23
  * Method for initializing events in Settings UI
23
24
  *
@@ -27,6 +27,9 @@ export class ButtonsEventManager {
27
27
  };
28
28
  enableButtons = this.setButtonAvailability(false);
29
29
  disableButtons = this.setButtonAvailability(true);
30
+ constructor() {
31
+ RainMan.settingsStore.handleModalInvocation = this.handleModalInvocation.bind(this);
32
+ }
30
33
  /**
31
34
  * Method for initializing events in Settings UI
32
35
  *
@@ -25,6 +25,7 @@ export class AnimatedBackground extends ResumableContainer {
25
25
  this.mobileSpineName = mobileSpineName;
26
26
  this.name = AnimatedBackground.registryName;
27
27
  this.parentLayer = BackgroundLayer;
28
+ RainMan.settingsStore.containersWithSpines.push(this);
28
29
  }
29
30
  resize() {
30
31
  this.changeSpineForOrientation();
@@ -40,6 +40,7 @@ export declare class SettingsStore {
40
40
  currentSpeed: SpeedLevel;
41
41
  popupPaytableRepositionCallback?: () => void;
42
42
  updateVolumeButtonTexture?: () => void;
43
+ handleModalInvocation?: (layerId: string) => void;
43
44
  private readonly initialAutoplaySettingsState;
44
45
  private modalsAvailable;
45
46
  private paytableMap;
@@ -46,6 +46,7 @@ export class SettingsStore {
46
46
  currentSpeed = "slow";
47
47
  popupPaytableRepositionCallback;
48
48
  updateVolumeButtonTexture;
49
+ handleModalInvocation;
49
50
  initialAutoplaySettingsState = {
50
51
  infinitySpinsEnabled: false,
51
52
  onAnyWin: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixi-rainman-game-engine",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "This repository contains all of the mechanics that used in rainman games.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",