Omnibus-archive/sim-1
0
1import dat from 'dat.gui';2 3export default class debug {4 constructor (options) {5 this.scene = options.scene;6 this.globals = this.scene.globals;7 this.toggleLayer = this.toggleLayerInit();8 9 this.gui = new dat.GUI();10 this.gui.closed = false;11 12 let f1 = this.gui.addFolder('Performance');13 f1.add(this.scene.sys.game.loop, 'actualFps', 'FPS').listen();14 f1.add(this.scene.viewport, 'objectsRendered', 'Objects Rendered').listen();15 f1.open();16 17 let g1 = this.gui.addFolder('Cursor');18 g1.add(this.scene.input, 'x', 'X').listen();19 g1.add(this.scene.input, 'y', 'Y').listen();20 g1.add(this.scene.viewport.worldPoint, 'x', 'WorldPoint X').listen();21 g1.add(this.scene.viewport.worldPoint, 'y', 'WorldPoint Y').listen();22 g1.add(this.scene.city.map.selectedCell, 'x', 'Cell X').listen();23 g1.add(this.scene.city.map.selectedCell, 'y', 'Cell Y').listen();24 //g1.open();25 26 let g2 = this.gui.addFolder('Camera');27 g2.add(this.scene.cameras.main, 'scrollX', 'X').listen();28 g2.add(this.scene.cameras.main, 'scrollY', 'Y').listen();29 g2.add(this.scene.cameras.main, 'zoom', 'Zoom', 0.1, 2).step(0.1).listen();30 g2.open();31 32 let g3 = this.gui.addFolder('World');33 g3.add(this, 'sleepWakeWorld', 'Sleep / Wake');34 //g3.add(this.scene.city.load, 'open', 'Open City');35 //g3.add(this.city.save, 'saveCity', 'Save City');36 g3.add(this.toggleLayer, 'terrain', 'Toggle Terrain');37 g3.add(this.toggleLayer, 'water', 'Toggle Water');38 g3.add(this.toggleLayer, 'heightmap', 'Toggle Height Map');39 //g3.add(this.toggleLayer, 'road', 'Toggle Road');40 //g3.add(this.toggleLayer, 'power', 'Toggle Power');41 //g3.add(this.toggleLayer, 'building', 'Toggle Building');42 //g3.add(this.toggleLayer, 'zone', 'Toggle Zone');43 //g3.add(this.toggleLayer, 'rail', 'Toggle Rail');44 //g3.add(this.toggleLayer, 'highway', 'Toggle Highway');45 //g3.add(this.toggleLayer, 'subway', 'Toggle Subway');46 //g3.add(this.toggleLayer, 'pipes', 'Toggle Pipes');47 //g3.open();48 }49 50 toggleLayerInit () {51 return {52 terrain: () => {53 this.scene.city.map.layers.terrain.toggle();54 },55 heightmap: () => {56 this.scene.city.map.layers.heightmap.toggle();57 },58 water: () => {59 this.scene.city.map.layers.water.toggle();60 },61 road: () => {62 this.scene.city.map.layers.road.toggle();63 },64 power: () => {65 this.scene.city.map.layers.power.toggle();66 },67 building: () => {68 this.scene.city.map.layers.building.toggle();69 },70 zone: () => {71 this.scene.city.map.layers.zone.toggle();72 },73 rail: () => {74 this.scene.city.map.layers.rail.toggle();75 },76 highway: () => {77 this.scene.city.map.layers.highway.toggle();78 },79 subway: () => {80 this.scene.city.map.layers.subway.toggle();81 },82 pipes: () => {83 this.scene.city.map.layers.pipes.toggle();84 },85 };86 }87 88 shutdown () {89 if (this.gui)90 this.gui.destroy();91 }92 93 loadCity () {94 this.scene.city.globals.loadCity();95 }96 97 saveCity () {98 this.scene.city.globals.saveCity();99 }100 101 sleepWakeWorld () {102 if (this.scene.isSleeping)103 this.scene.wake();104 else105 this.scene.sleep();106 }107}