ZergurVorghiz

No Screen Edge Scroll

Nov 21st, 2020
856
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ControlsMode.prototype.controls = function() {
  2.   var a, j, len, numSel, ref, ref1, thing, z;
  3.   if (!commander) {
  4.     return;
  5.   }
  6.   this.keyScroll[0] *= .8;
  7.   this.keyScroll[1] *= .8;
  8.   a = 10 * this.zoom * settings.speedValue("Scroll Speed");
  9.   this.keyScroll[1] += (this.panUp + this.panDown) * a;
  10.   this.keyScroll[0] += (this.panLeft + this.panRight) * a;
  11.   v2.add(this.focus, this.keyScroll);
  12.   if (v2.mag(this.focus) > this.mapBounds) {
  13.     this.focus[0] -= this.focus[0] * .003;
  14.     this.focus[1] -= this.focus[1] * .003;
  15.   }
  16.   this.keyZoom *= .9;
  17.   z = .02;
  18.   this.keyZoom += (this.zoomIn + this.zoomOut) * z * settings.speedValue("Scroll Speed");
  19.   this.zoom += this.keyZoom;
  20.   if (this.zoom < 0.5) {
  21.     this.zoom = 0.5;
  22.   }
  23.   if (this.zoom > 10) {
  24.     this.zoom = 10;
  25.   }
  26.   numSel = (ref = commander.selection) != null ? ref.length : void 0;
  27.   if (this.centerOnUnit && numSel > 0) {
  28.     this.focus[0] = 0;
  29.     this.focus[1] = 0;
  30.     ref1 = commander.selection;
  31.     for (j = 0, len = ref1.length; j < len; j++) {
  32.       thing = ref1[j];
  33.       this.focus[0] -= thing.pos[0] / numSel;
  34.       this.focus[1] -= thing.pos[1] / numSel;
  35.     }
  36.   }
  37. };
RAW Paste Data