class SceneInfo extends Phaser.Scene
{
    constructor ()
    {
        super({ key: "SceneInfo", active: true });
    }

    init (data)
    {
        this.parentScene = data.scene;
        
        this.buyBonusEnable = data.buyBonusEnable;
        this.jackpotEnable = data.jackpotEnable;

        this.lang = data.lang;
        this.files = data.files;

        this.rtp = data.rtp;
        
        this.minBetPos = {x: 0, y:0};

        if (data.minbetpos != undefined)
        {
            let v = Number.parseFloat(data.minbetpos.x);

            if (!Number.isNaN(v))
            {
                this.minBetPos.x = v;
            }

            v = Number.parseFloat(data.minbetpos.y);

            if (!Number.isNaN(v))
            {
                this.minBetPos.y = v;
            }
        }

        this.maxBetPos = {x: 0, y:0};

        if (data.maxbetpos != undefined)
        {
            let v = Number.parseFloat(data.maxbetpos.x);

            if (!Number.isNaN(v))
            {
                this.maxBetPos.x = v;
            }

            v = Number.parseFloat(data.maxbetpos.y);

            if (!Number.isNaN(v))
            {
                this.maxBetPos.y = v;
            }
        }
        
        this.rtpPos = {x: 0, y:0};
        
        if (data.rtppos != undefined)
        {
            let v = Number.parseFloat(data.rtppos.x);

            if (!Number.isNaN(v))
            {
                this.rtpPos.x = v;
            }

            v = Number.parseFloat(data.rtppos.y);

            if (!Number.isNaN(v))
            {
                this.rtpPos.y = v;
            }
        }

        this.orientationInit = false;
    }

    preload ()
    {
        this.load.image("infoIcon", "../common/assets/info_icon.png?ver=" + VERSION);

        for (let i = 0; i < this.files.length; ++i)
        {
            this.load.image(this.files[i].key, this.files[i].path + this.lang + "/" + this.files[i].file + "?ver=" + VERSION);
        }
    }

    create ()
    {
        this.infoIcon = this.add.image(490, 76, "infoIcon");
        this.infoIcon.setScrollFactor(0);

        this.txtInfo = this.add.text(530, 50, this.parentScene.getText(GLOBAL_TXT_INFO), { fontFamily: "Arial", fontSize: 48, fontStyle: "bold", color: "#ffffff" }).setOrigin(0);
        this.txtInfo.setScrollFactor(0);

        this.y = this.parentScene.topBar.displayHeight;

        this.layer = this.add.layer();

        this.graphicsL = this.make.graphics();

        this.graphicsL.fillStyle(0xffffff);
        this.graphicsL.fillRect(0, this.y, 1080, 800);

        this.maskL = this.graphicsL.createGeometryMask();

        this.graphicsP = this.make.graphics();

        this.graphicsP.fillStyle(0xffffff);
        this.graphicsP.fillRect(0, this.y, 1080, 1466);

        this.maskP = this.graphicsP.createGeometryMask();

        this.layer.setMask(this.maskP);

        this.images = [];

        for (let i = 0; i < this.files.length; ++i)
        {
            if (this.files[i].key == "callforGame" && !this.buyBonusEnable)
            {
                continue;
            }

            if (this.files[i].key == "jackpotGame" && !this.jackpotEnable)
            {
                continue;
            }

            let img = this.add.image(0, 0, this.files[i].key);
            img.setPosition(GAME_PORTRAIT_WIDTH / 2, this.y + img.height / 2);

            this.images.push(img);

            this.layer.add(img);
            this.y += img.height;
        }

        this.yl = this.y + GAME_LANDSCAPE_HEIGHT - 934;
        this.yp = this.y + GAME_PORTRAIT_HEIGHT - (this.parentScene.infoBtn.getY() - this.parentScene.infoBtn.getOriginY());

        let config =
        {
            scene: this,
            kineticMovement: true,
            timeConstantScroll: 325,
            horizontalScroll: false,
            verticalScroll: true,
            horizontalWheel: false,
            verticalWheel: false,
            deltaWheel: 40,

            thresholdOfTapTime: 300,
            thresholdOfTapDistance: 10,

            onDown: null,
            onUp: null,
            onUpdate: null,
            //scene pointer capture rect
            xmin: 0,
            xmax: GAME_PORTRAIT_WIDTH - 30,
            ymin: this.parentScene.topBar.displayHeight,
            ymax: GAME_PORTRAIT_HEIGHT - this.parentScene.topBar.displayHeight - this.parentScene.infoBtn.getHeight(),

            scrollXMin: 0,
            scrollXMax: GAME_PORTRAIT_WIDTH,
            scrollYMin: 0,
            scrollYMax: this.yp - GAME_PORTRAIT_HEIGHT,

            cameraBoundX: 0,
            cameraBoundY: 0,
            cameraBoundW: GAME_PORTRAIT_WIDTH,
            cameraBoundH: this.yp
        }

        this.scroller = new Scroller(config);

        this.scroller.start();

        this.paytable = [];
        this.bmTexts = [];

        this.index = -1;
        this.bpl = 1;
        this.units = 1;

        this.txtMinbet = this.add.text(0, 0, "", { fontFamily: "Arial", fontSize: 48, fontStyle: "bold", color: "#ffffff" }).setOrigin(0.5);
        this.layer.add(this.txtMinbet);
        
        this.txtMaxbet = this.add.text(0, 0, "", { fontFamily: "Arial", fontSize: 48, fontStyle: "bold", color: "#ffffff" }).setOrigin(0.5);
        this.layer.add(this.txtMaxbet);

        this.txtRTP = this.add.text(0, 0, "", { fontFamily: "Arial", fontSize: 38, color: "#ffffff" }).setOrigin(0.5);
        this.layer.add(this.txtRTP);

        this.createTextPositions();

        let x = GAME_PORTRAIT_WIDTH - 10;
        let y = GAME_PORTRAIT_HEIGHT / 2 - this.parentScene.topBar.displayHeight / 2;

        let th = this.parentScene.topBar.displayHeight;
        let bh = this.parentScene.infoBtn.getHeight();

        this.scrollbar = this.scene.add("SceneScrollbarInfo", SceneScrollbar, true, { scene: this, x: x, y: y, th: th, bh: bh});

        this.sleep();
    }

    scrollChange (newValue)
    {
        if (this.parentScene.isLandscapeMode ())
        {
            this.cameras.main.setScroll(this.cameras.main.scrollX, (this.yl - GAME_LANDSCAPE_HEIGHT) * newValue);
        }
        else
        {
            this.cameras.main.setScroll(this.cameras.main.scrollX, (this.yp - GAME_PORTRAIT_HEIGHT) * newValue);
        }
    }

    onOrientationChange ()
    {
        let status = this.scene.getStatus(this.scene.key);

        if (status < Phaser.Scenes.RUNNING)
        {
            return;
        }

        if (this.parentScene.isLandscapeMode ())
        {
            this.graphicsL.setPosition(420, this.yp);

            this.infoIcon.setPosition(890, 76);
            this.txtInfo.setPosition(930, 50);

            for (let i = 0; i < this.images.length; ++i)
            {
                this.images[i].setPosition(960, this.images[i].y);
            }

            this.txtMinbet.setPosition(this.minBetPos.x + 420, this.minBetPos.y);
            this.txtMaxbet.setPosition(this.maxBetPos.x + 420, this.maxBetPos.y);
            this.txtRTP.setPosition(this.rtpPos.x + 420, this.rtpPos.y);

            this.scroller.setBounds(420, 420 + GAME_PORTRAIT_WIDTH - 30, this.parentScene.topBar.displayHeight, GAME_LANDSCAPE_HEIGHT - this.parentScene.topBar.displayHeight - 146);
            this.scroller.setScrollRange(420, 420 + GAME_PORTRAIT_WIDTH, 0, this.yl - GAME_LANDSCAPE_HEIGHT);
            this.scroller.setCameraBounds(0, 0, GAME_LANDSCAPE_WIDTH, this.yl);

            this.scrollbar.setHeight(GAME_LANDSCAPE_HEIGHT - this.parentScene.topBar.displayHeight - 95);
            this.scrollbar.setPosition(GAME_LANDSCAPE_WIDTH / 2 + GAME_PORTRAIT_WIDTH / 2 - 10, GAME_LANDSCAPE_HEIGHT / 2 + 30);

            this.layer.setMask(this.maskL);
        }
        else
        {
            this.graphicsP.setPosition(0, this.yp);

            this.infoIcon.setPosition(490, 76);
            this.txtInfo.setPosition(530, 50);

            for (let i = 0; i < this.images.length; ++i)
            {
                this.images[i].setPosition(540, this.images[i].y);
            }

            this.txtMinbet.setPosition(this.minBetPos.x, this.minBetPos.y);
            this.txtMaxbet.setPosition(this.maxBetPos.x, this.maxBetPos.y);
            this.txtRTP.setPosition(this.rtpPos.x, this.rtpPos.y);

            this.scroller.setBounds(0, GAME_PORTRAIT_WIDTH - 30, this.parentScene.topBar.displayHeight, GAME_PORTRAIT_HEIGHT - this.parentScene.topBar.displayHeight - this.parentScene.infoBtn.getHeight());
            this.scroller.setScrollRange(0, GAME_PORTRAIT_WIDTH, 0, this.yp - GAME_PORTRAIT_HEIGHT);
            this.scroller.setCameraBounds(0, 0, GAME_PORTRAIT_WIDTH, this.yp);

            this.scrollbar.setHeight (GAME_PORTRAIT_HEIGHT - 2 * this.parentScene.topBar.displayHeight - this.parentScene.infoBtn.getHeight());
            this.scrollbar.setPosition (GAME_PORTRAIT_WIDTH - 10, GAME_PORTRAIT_HEIGHT / 2 - this.parentScene.topBar.displayHeight / 2);

            this.layer.setMask(this.maskP);
        }

        if (this.bmTexts.length > 0)
        {
            let dx = 0;

            if (this.parentScene.isLandscapeMode())
            {
                dx = 420;
            }

            for (let i = 0; i < this.bmTexts.length; ++i)
            {
                this.bmTexts[i].setPosition(this.positions[i].x + dx, this.positions[i].y);
            }
        }

        if (!this.orientationInit)
        {
            this.orientationInit = true;
        }
    }

    createTextPositions ()
    {
        this.positions = [];

        this.positions[0] = { x: 762, y: 1322 + 2500 - 200 + 370 - 565};//cherry
        this.positions[1] = { x: 762, y: 1261 + 2500 - 200 + 370 - 565};
        this.positions[2] = { x: 762, y: 1198 + 2500 - 200 + 370 - 565};

        this.positions[3] = { x: 482, y: 1320 + 2190 - 185 + 370 - 565};//lemon
        this.positions[4] = { x: 482, y: 1261 + 2190 - 185 + 370 - 565};
        this.positions[5] = { x: 482, y: 1198 + 2190 - 185 + 370 - 565};

        this.positions[6] = { x: 762, y: 1320 + 1875 - 160 + 370 - 565};//orange
        this.positions[7] = { x: 762, y: 1261 + 1875 - 160 + 370 - 565};
        this.positions[8] = { x: 762, y: 1198 + 1875 - 160 + 370 - 565};

        this.positions[9] = { x: 482, y: 1320 + 1570 - 150 + 370 - 565};//plum
        this.positions[10] = { x: 482, y: 1261 + 1570 - 150 + 370 - 565};
        this.positions[11] = { x: 482, y: 1198 + 1570 - 150 + 370 - 565};

        this.positions[12] = { x: 762, y: 1320 + 1245 - 120 + 370 - 565}; //bell
        this.positions[13] = { x: 762, y: 1261 + 1245 - 120 + 370 - 565};
        this.positions[14] = { x: 762, y: 1198 + 1245 - 120 + 370 - 565};

        this.positions[15] = { x: 482, y: 1320 + 943 - 110 + 370 - 565};//grape
        this.positions[16] = { x: 482, y: 1261 + 940 - 110 + 370 - 565};
        this.positions[17] = { x: 482, y: 1198 + 940 - 110 + 370 - 565};

        this.positions[18] = { x: 762, y: 1320 + 630 - 90 + 370 - 565};//melon
        this.positions[19] = { x: 762, y: 1261 + 630 - 90 + 370 - 565};
        this.positions[20] = { x: 762, y: 1198 + 630 - 90 + 370 - 565};

        this.positions[21] = { x: 482, y: 1390 + 280 - 72 + 340 - 565};//chips
        this.positions[22] = { x: 482, y: 1320 + 283 - 67 + 340 - 565};
        this.positions[23] = { x: 482, y: 1261 + 276 - 60 + 340 - 565};

        this.positions[24] = { x: 762, y: 1379 + 292 - 565};//seven
        this.positions[25] = { x: 762, y: 1320 + 292 - 565};
        this.positions[26] = { x: 762, y: 1261 + 292 - 565};
        this.positions[27] = { x: 762, y: 1198 + 292 - 565};
    }

    getPayInfo ()
    {
        let pi = this.parentScene.getPayInfo();

        this.paytable = pi.pt;
        this.units = pi.units;
        this.bpl = pi.bpl;
        this.lines = pi.lines;
        this.currencyPrecision = pi.precision;

        this.txtMinbet.setText(formatValue(pi.minbet, this.currencyPrecision));
        this.txtMaxbet.setText(formatValue(pi.maxbet, this.currencyPrecision));

        this.createPayInfo();
    }

    createPayInfo ()
    {
        let dx = 0;

        if (this.parentScene.isLandscapeMode ())
        {
            dx = 420;
        }

        if (this.bmTexts.length > 0)
        {
            for (let i = 0; i < this.bmTexts.length; ++i)
            {
                this.bmTexts[i].destroy();
            }
        }

        this.bmTexts = [];

        this.bmTexts.push(this.add.text(this.positions[0].x + dx, this.positions[0].y, parseFloat((this.paytable[0][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));//cherry
        this.bmTexts.push(this.add.text(this.positions[1].x + dx, this.positions[1].y, parseFloat((this.paytable[0][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));
        this.bmTexts.push(this.add.text(this.positions[2].x + dx, this.positions[2].y, parseFloat((this.paytable[0][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));

        this.bmTexts.push(this.add.text(this.positions[3].x + dx, this.positions[3].y, parseFloat((this.paytable[1][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));//lemon
        this.bmTexts.push(this.add.text(this.positions[4].x + dx, this.positions[4].y, parseFloat((this.paytable[1][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));
        this.bmTexts.push(this.add.text(this.positions[5].x + dx, this.positions[5].y, parseFloat((this.paytable[1][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));

        this.bmTexts.push(this.add.text(this.positions[6].x + dx, this.positions[6].y, parseFloat((this.paytable[2][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));//orange
        this.bmTexts.push(this.add.text(this.positions[7].x + dx, this.positions[7].y, parseFloat((this.paytable[2][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));
        this.bmTexts.push(this.add.text(this.positions[8].x + dx, this.positions[8].y, parseFloat((this.paytable[2][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));

        this.bmTexts.push(this.add.text(this.positions[9].x + dx, this.positions[9].y, parseFloat((this.paytable[3][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));//plum
        this.bmTexts.push(this.add.text(this.positions[10].x + dx, this.positions[10].y, parseFloat((this.paytable[3][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));
        this.bmTexts.push(this.add.text(this.positions[11].x + dx, this.positions[11].y, parseFloat((this.paytable[3][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));

        this.bmTexts.push(this.add.text(this.positions[12].x + dx, this.positions[12].y, parseFloat((this.paytable[4][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));//bell
        this.bmTexts.push(this.add.text(this.positions[13].x + dx, this.positions[13].y, parseFloat((this.paytable[4][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));
        this.bmTexts.push(this.add.text(this.positions[14].x + dx, this.positions[14].y, parseFloat((this.paytable[4][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));

        this.bmTexts.push(this.add.text(this.positions[15].x + dx, this.positions[15].y, parseFloat((this.paytable[5][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));//grape
        this.bmTexts.push(this.add.text(this.positions[16].x + dx, this.positions[16].y, parseFloat((this.paytable[5][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));
        this.bmTexts.push(this.add.text(this.positions[17].x + dx, this.positions[17].y, parseFloat((this.paytable[5][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));

        this.bmTexts.push(this.add.text(this.positions[18].x + dx, this.positions[18].y, parseFloat((this.paytable[6][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));//melon
        this.bmTexts.push(this.add.text(this.positions[19].x + dx, this.positions[19].y, parseFloat((this.paytable[6][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));
        this.bmTexts.push(this.add.text(this.positions[20].x + dx, this.positions[20].y, parseFloat((this.paytable[6][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));

        this.bmTexts.push(this.add.text(this.positions[21].x + dx, this.positions[21].y, parseFloat((this.paytable[7][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));//chips
        this.bmTexts.push(this.add.text(this.positions[22].x + dx, this.positions[22].y, parseFloat((this.paytable[7][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));
        this.bmTexts.push(this.add.text(this.positions[23].x + dx, this.positions[23].y, parseFloat((this.paytable[7][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));

        this.bmTexts.push(this.add.text(this.positions[24].x + dx, this.positions[24].y, parseFloat((this.paytable[8][2] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));//seven
        this.bmTexts.push(this.add.text(this.positions[25].x + dx, this.positions[25].y, parseFloat((this.paytable[8][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));
        this.bmTexts.push(this.add.text(this.positions[26].x + dx, this.positions[26].y, parseFloat((this.paytable[8][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));
        this.bmTexts.push(this.add.text(this.positions[27].x + dx, this.positions[27].y, parseFloat((this.paytable[8][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision), { fontFamily: "Arial", fontSize: 62, fontStyle: "bold", color: "#e6faba" }).setOrigin(0.5));

        for (let i = 0; i < this.bmTexts.length; ++i)
        {
            this.layer.add(this.bmTexts[i]);
        }
    }

    updatePayInfo (bpl)
    {
        if (this.paytable.length == 0)
        {
            this.getPayInfo();
        }

        this.bpl = bpl;

        this.bmTexts[0].setText(parseFloat((this.paytable[0][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));//cherry
        this.bmTexts[1].setText(parseFloat((this.paytable[0][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
        this.bmTexts[2].setText(parseFloat((this.paytable[0][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));

        this.bmTexts[3].setText(parseFloat((this.paytable[1][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));//lemon
        this.bmTexts[4].setText(parseFloat((this.paytable[1][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
        this.bmTexts[5].setText(parseFloat((this.paytable[1][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));

        this.bmTexts[6].setText(parseFloat((this.paytable[2][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));//orange
        this.bmTexts[7].setText(parseFloat((this.paytable[2][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
        this.bmTexts[8].setText(parseFloat((this.paytable[2][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));

        this.bmTexts[9].setText(parseFloat((this.paytable[3][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));//plum
        this.bmTexts[10].setText(parseFloat((this.paytable[3][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
        this.bmTexts[11].setText(parseFloat((this.paytable[3][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));

        this.bmTexts[12].setText(parseFloat((this.paytable[4][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));//bell
        this.bmTexts[13].setText(parseFloat((this.paytable[4][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
        this.bmTexts[14].setText(parseFloat((this.paytable[4][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));

        this.bmTexts[15].setText(parseFloat((this.paytable[5][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));//grape
        this.bmTexts[16].setText(parseFloat((this.paytable[5][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
        this.bmTexts[17].setText(parseFloat((this.paytable[5][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));

        this.bmTexts[18].setText(parseFloat((this.paytable[6][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));//melon
        this.bmTexts[19].setText(parseFloat((this.paytable[6][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
        this.bmTexts[20].setText(parseFloat((this.paytable[6][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));

        this.bmTexts[21].setText(parseFloat((this.paytable[7][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));//melon
        this.bmTexts[22].setText(parseFloat((this.paytable[7][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
        this.bmTexts[23].setText(parseFloat((this.paytable[7][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));


        this.bmTexts[24].setText(parseFloat((this.paytable[8][2] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));//seven
        this.bmTexts[25].setText(parseFloat((this.paytable[8][3] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
        this.bmTexts[26].setText(parseFloat((this.paytable[8][4] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
        this.bmTexts[27].setText(parseFloat((this.paytable[8][5] * this.bpl * this.units) / 100).toFixed(this.currencyPrecision));
    }

    sleep ()
    {
        if (this.scene.isSleeping())
        {
            return;
        }

        this.scene.sleep();

        let status = this.scene.getStatus(this.scrollbar.scene.key);

        if (status < Phaser.Scenes.RUNNING)
        {
            return;
        }
        else if (status != Phaser.Scenes.SLEEPING)
        {
            this.scrollbar.sleep();
        }
    }

    wake ()
    {
        this.scene.wake();
        this.scene.bringToTop();

        if (this.paytable.length == 0)
        {
            this.getPayInfo();
        }

        if (!this.orientationInit)
        {
            this.onOrientationChange();
        }

        if (this.yield == undefined)
        {
            this.yield = this.parentScene.getYield();

            for (let i = 0; i < this.rtp.length; ++i)
            {
                if (this.rtp[i][0] == this.yield)
                {
                    this.txtRTP.setText(this.rtp[i][1] + " %");
                    break;
                }
            }

            if (this.txtRTP.text == "")
            {
                let a = [];
                let v;

                for (let i = 0; i < this.rtp.length; ++i)
                {
                    a.push(parseInt(this.rtp[i][0]));
                }
                 
                v = closest(parseInt(this.yield), a);

                for (let i = 0; i < this.rtp.length; ++i)
                {
                    if (parseInt(this.rtp[i][0]) == v)
                    {
                        this.txtRTP.setText(this.rtp[i][1] + " %");
                        break;
                    }
                }
            }
        }

        this.scrollbar.wake();
    }

    update ()
    {
        this.scroller.update();

        if (this.parentScene.isLandscapeMode ())
        {
            this.maskL.geometryMask.y = this.cameras.main.scrollY;
            this.scrollbar.setValue(this.cameras.main.scrollY / (this.yl - GAME_LANDSCAPE_HEIGHT));
        }
        else
        {
            this.maskP.geometryMask.y = this.cameras.main.scrollY;
            this.scrollbar.setValue(this.cameras.main.scrollY / (this.yp - GAME_PORTRAIT_HEIGHT));
        }
    }
}
