From c6f6c7eb435236657f0760e3abadbab2af615794 Mon Sep 17 00:00:00 2001 From: Manuel Herrmann <it@icetruck.de> Date: Thu, 20 Aug 2015 19:12:57 +0200 Subject: [PATCH] toggle display of event layers --- registration-system/view/signups/game1/js/game.js | 13 ++++++++++++- registration-system/view/signups/game1/test.html | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/registration-system/view/signups/game1/js/game.js b/registration-system/view/signups/game1/js/game.js index 5f55291..397c52e 100644 --- a/registration-system/view/signups/game1/js/game.js +++ b/registration-system/view/signups/game1/js/game.js @@ -4,6 +4,7 @@ function Game(config) { Game.config = config; Game.instance = this; } +Game.eventLayers = ['CLICKABLE', 'WALK', 'NOWALK', 'EVENTS']; Game.prototype.run = function() { d3.xml('maps/'+Game.config.startMap, 'image/svg+xml', function(xml) { var gameCanvas = document.getElementById("gameCanvas"); @@ -11,10 +12,20 @@ Game.prototype.run = function() { gameCanvas.style.width = Game.config.size[0]+'px'; gameCanvas.style.height = Game.config.size[1]+'px'; gameRoot.appendChild(xml.documentElement); - + var svg = d3.select("svg"); + + var displayEvents = Game.config.showEventLayers ? 'block' : 'none'; + svg.selectAll('g').filter(function() { + return ( + this.getAttribute('inkscape:groupmode') == 'layer' + && Game.eventLayers.indexOf(this.getAttribute('inkscape:label')) >= 0 + ); + }).style('display', displayEvents); + var char = new Char(svg); var cam = new Camera(svg, char.translation); + // test animation var ship = svg.select("#shipGroup"); diff --git a/registration-system/view/signups/game1/test.html b/registration-system/view/signups/game1/test.html index ca18ffa..28ff1bd 100644 --- a/registration-system/view/signups/game1/test.html +++ b/registration-system/view/signups/game1/test.html @@ -23,6 +23,7 @@ g_smallValue = 0.000001; // fun with floats var game = new Game({ startMap: 'map_landing.svg', + showEventLayers: false, pathFindingGridSize: 5, usePathFinding: true, size: [800, 600] -- GitLab