From 194de0ecc11c1fa5759ff96b36969aa8ac5dbfdb Mon Sep 17 00:00:00 2001 From: Manuel Herrmann <it@icetruck.de> Date: Mon, 7 Sep 2015 01:30:38 +0200 Subject: [PATCH] use opacity instead of display:none - bbox wont work on svgs if so; onload fix; spawn not found message --- registration-system/view/signups/game1/index.php | 9 +++++---- registration-system/view/signups/game1/js/character.js | 1 + registration-system/view/signups/game1/js/game.js | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/registration-system/view/signups/game1/index.php b/registration-system/view/signups/game1/index.php index 7b30303..e0a2698 100644 --- a/registration-system/view/signups/game1/index.php +++ b/registration-system/view/signups/game1/index.php @@ -71,18 +71,19 @@ class Game1SignupMethod extends SignupMethod { var FAPI = new FAPI(); var game = new Game({ - startMap: \'map_landing.svg\', + startMap: \'map_landing\', showEventLayers: false, pathFindingGridSize: 5, usePathFinding: true, size: [800, 600] }); - game.run(); // this following stuff is to prevent the page from scrolling, when the user // actually just wants to scroll inside the logs. // it removes the main scrollbar and adds a padding of its size to replace the space - window.onload = function() { + $(function() { + game.run(); + var scrollbarWidth = window.innerWidth - document.documentElement.clientWidth; var x = document.getElementsByClassName("sidebar-log"); for (var i = 0; i < x.length; i++) { @@ -95,7 +96,7 @@ class Game1SignupMethod extends SignupMethod { document.body.style.paddingRight = scrollbarWidth+"px"; }, false); } - }; + }); </script>'; } diff --git a/registration-system/view/signups/game1/js/character.js b/registration-system/view/signups/game1/js/character.js index 1668be6..c8ee14b 100644 --- a/registration-system/view/signups/game1/js/character.js +++ b/registration-system/view/signups/game1/js/character.js @@ -26,6 +26,7 @@ function Char(svg, options) { Char.prototype.findSpawn = function() { // [1320, svgFlipY(svg[0][0], 500)] var spawn = this.svg.select("#player_spawn"); + if (!spawn[0][0]) console.error("Could not find spawn"); var bbox = spawn[0][0].getBBox(); return Vec.add(getTranslation(this.svg[0][0], spawn[0][0]), [bbox.x, bbox.y]); }; diff --git a/registration-system/view/signups/game1/js/game.js b/registration-system/view/signups/game1/js/game.js index 47b2f61..01bf81f 100644 --- a/registration-system/view/signups/game1/js/game.js +++ b/registration-system/view/signups/game1/js/game.js @@ -58,13 +58,15 @@ Game.prototype.loadMap = function(map) { // ------------------------------------- // init event related stuff - var displayEvents = Game.config.showEventLayers ? 'block' : 'none'; + var displayEvents = Game.config.showEventLayers ? 1 : 0; svg.selectAll('g').filter(function() { return ( this.getAttribute('inkscape:groupmode') == 'layer' && Game.eventLayers.indexOf(this.getAttribute('inkscape:label')) >= 0 ); - }).style('display', displayEvents); + }) + .style('display', 'block') + .style('opacity', displayEvents); Game.eventHandler = new EventHandler(svg); -- GitLab