Browse Source

Revert "Remove references to devicePixelRatio"

This reverts commit a385769b87
tags/v0.8.0
Vildravn 3 years ago
parent
commit
4be2c4b87c
5 changed files with 16 additions and 11 deletions
  1. +3
    -2
      src/client/js/input.js
  2. +2
    -2
      src/client/js/misc/helpers.js
  3. +7
    -4
      src/client/js/rendering/renderer.js
  4. +3
    -2
      src/client/ui/templates/passives/input.js
  5. +1
    -1
      src/client/ui/templates/passives/passives.js

+ 3
- 2
src/client/js/input.js View File

@@ -226,8 +226,9 @@ define([
if ((!el.hasClass('ui-container')) || (el.hasClass('blocking')))
return;

this.mouse.x = e.offsetX + renderer.pos.x;
this.mouse.y = e.offsetY + renderer.pos.y;
const zoom = window.devicePixelRatio;
this.mouse.x = (e.offsetX * zoom) + renderer.pos.x;
this.mouse.y = (e.offsetY * zoom) + renderer.pos.y;
}
},



+ 2
- 2
src/client/js/misc/helpers.js View File

@@ -1,6 +1,6 @@
window.isMobile = /Mobi|Android/i.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
window.scale = isMobile ? 32 : 40;
window.scaleMult = isMobile ? 4 : 5;
window.scale = isMobile ? 32 : 40 * window.devicePixelRatio;
window.scaleMult = isMobile ? 4 : 5 * window.devicePixelRatio;

//eslint-disable-next-line no-extend-native
Array.prototype.spliceWhere = function (callback, thisArg) {


+ 7
- 4
src/client/js/rendering/renderer.js View File

@@ -82,8 +82,9 @@ define([
events.on('onToggleFullscreen', this.toggleScreen.bind(this));
events.on('onMoveSpeedChange', this.adaptCameraMoveSpeed.bind(this));

this.width = $('body').width();
this.height = $('body').height();
let zoom = isMobile ? 1 : window.devicePixelRatio;
this.width = $('body').width() * zoom;
this.height = $('body').height() * zoom;

this.showTilesW = Math.ceil((this.width / scale) / 2) + 3;
this.showTilesH = Math.ceil((this.height / scale) / 2) + 3;
@@ -179,9 +180,11 @@ define([
onResize: function () {
if (isMobile)
return;
let zoom = window.devicePixelRatio;

this.width = $('body').width();
this.height = $('body').height();
this.width = $('body').width() * zoom;
this.height = $('body').height() * zoom;

this.showTilesW = Math.ceil((this.width / scale) / 2) + 3;
this.showTilesH = Math.ceil((this.height / scale) / 2) + 3;


+ 3
- 2
src/client/ui/templates/passives/input.js View File

@@ -187,8 +187,9 @@ define([
if ((!el.hasClass('canvas')) || (el.hasClass('blocking')))
return;

this.mouse.x = e.offsetX;
this.mouse.y = e.offsetY;
const zoom = window.devicePixelRatio;
this.mouse.x = e.offsetX * zoom;
this.mouse.y = e.offsetY * zoom;

this.mouse.raw = e;



+ 1
- 1
src/client/ui/templates/passives/passives.js View File

@@ -1,4 +1,4 @@
let zoom = 1;
let zoom = window.devicePixelRatio;
if (isMobile)
zoom /= 2;



Loading…
Cancel
Save