Moved menu context switching out of main cryps
This commit is contained in:
@@ -3,12 +3,7 @@ const Phaser = require('phaser');
|
||||
const Header = require('./header');
|
||||
const Menu = require('./menu');
|
||||
const Combat = require('./combat');
|
||||
const Zones = require('./zones');
|
||||
const Background = require('./background');
|
||||
const GameList = require('./game.list');
|
||||
const StatSheet = require('./statsheet');
|
||||
const SpecSheet = require('./specsheet');
|
||||
|
||||
|
||||
function renderCryps() {
|
||||
const config = {
|
||||
@@ -33,22 +28,6 @@ function renderCryps() {
|
||||
|
||||
const game = new Phaser.Game(config);
|
||||
|
||||
function newMainScene(key, scene, data) {
|
||||
let addScene = true;
|
||||
const ACTIVE_MAIN_SCENES = ['GameList', 'Zones', 'StatSheet', 'SpecSheet'];
|
||||
ACTIVE_MAIN_SCENES.forEach((sKey) => {
|
||||
if (game.scene.keys[sKey]) {
|
||||
if (key === sKey) {
|
||||
game.scene.keys[sKey].scene.restart(data);
|
||||
addScene = false;
|
||||
} else {
|
||||
game.scene.keys[sKey].cleanUp();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (addScene) game.scene.add(key, scene, true, data);
|
||||
return true;
|
||||
}
|
||||
|
||||
function changeData(parent, key, data) {
|
||||
// Don't load other scenes if you're not logged in
|
||||
@@ -63,23 +42,6 @@ function renderCryps() {
|
||||
return game.scene.add('Combat', Combat, true);
|
||||
}
|
||||
|
||||
if (key === 'zone') {
|
||||
newMainScene('Zones', Zones, data);
|
||||
}
|
||||
|
||||
if (key === 'gameList') {
|
||||
newMainScene('GameList', GameList, data);
|
||||
}
|
||||
|
||||
if (key === 'crypStats') {
|
||||
newMainScene('StatSheet', StatSheet, data);
|
||||
}
|
||||
|
||||
if (key === 'crypSpec') {
|
||||
newMainScene('SpecSheet', SpecSheet, data);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@ const Phaser = require('phaser');
|
||||
const MenuCrypList = require('./menu.cryps.list');
|
||||
const MenuNavigation = require('./menu.navigation');
|
||||
const ItemList = require('./item.list');
|
||||
const Zones = require('./zones');
|
||||
const GameList = require('./game.list');
|
||||
const StatSheet = require('./statsheet');
|
||||
const SpecSheet = require('./specsheet');
|
||||
|
||||
class Menu extends Phaser.Scene {
|
||||
constructor() {
|
||||
@@ -29,9 +33,41 @@ class Menu extends Phaser.Scene {
|
||||
if (data) return this.cleanUp();
|
||||
}
|
||||
|
||||
if (key === 'zone') {
|
||||
this.newMainScene('Zones', Zones, data);
|
||||
}
|
||||
|
||||
if (key === 'gameList') {
|
||||
this.newMainScene('GameList', GameList, data);
|
||||
}
|
||||
|
||||
if (key === 'crypStats') {
|
||||
this.newMainScene('StatSheet', StatSheet, data);
|
||||
}
|
||||
|
||||
if (key === 'crypSpec') {
|
||||
this.newMainScene('SpecSheet', SpecSheet, data);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
newMainScene(key, scene, data) {
|
||||
let addScene = true;
|
||||
const ACTIVE_MAIN_SCENES = ['GameList', 'Zones', 'StatSheet', 'SpecSheet'];
|
||||
ACTIVE_MAIN_SCENES.forEach((sKey) => {
|
||||
if (this.scene.manager.keys[sKey]) {
|
||||
if (key === sKey) {
|
||||
this.scene.manager.keys[sKey].scene.restart(data);
|
||||
addScene = false;
|
||||
} else {
|
||||
this.scene.manager.keys[sKey].cleanUp();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (addScene) this.scene.manager.add(key, scene, true, data);
|
||||
}
|
||||
|
||||
cleanUp() {
|
||||
this.registry.events.off('changedata', this.updateData, this);
|
||||
this.registry.events.off('setdata', this.updateData, this);
|
||||
|
||||
@@ -10,7 +10,7 @@ const TEXT_MARGIN = 24;
|
||||
const menuX = WIDTH / 10;
|
||||
const menuY = HEIGHT * 0.8;
|
||||
const menuWidth = WIDTH / 10;
|
||||
const menuHeight = HEIGHT * 0.3;
|
||||
const menuHeight = HEIGHT * 0.2;
|
||||
|
||||
const X_LEARN = WIDTH * 2 / 4;
|
||||
const Y_SKILLS = HEIGHT * 0.5;
|
||||
|
||||
Reference in New Issue
Block a user