Moving touch buttons in tetr.js

title

Verze ze dne 27. 01. 2020. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Moving touch buttons in tetr.js
// @namespace    http://tampermonkey.net/
// @version      0.33
// @author       Oki
// @description  title
// @match        http://farter.cn/tetr.js/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('load', function(){




touchButtonsLayout = function() {
  var dpiX = 96;
  var dpiY = 96;
  var winW = window.innerWidth / dpiX;
  var winH = window.innerHeight / dpiY;
  var buttonH = 0.7, buttonW = 1, fontSize=0.55, margin=0.1, unit="in";

  var setPos = function(elem, posX, posY, sizeW, sizeH,
    alignX, alignY, offsetX, offsetY, clientW, clientH)
  {
    elem.style.width = "" + sizeW + unit;
    elem.style.height = "" + sizeH + unit;
    // border ignored, for now
    elem.style.left = "" + (offsetX + alignX * 0.5 * (clientW - sizeW) + posX * sizeW - ( (alignX-1) * margin/2 )) + unit;
    elem.style.top = "" + (offsetY + alignY * 0.5 * (clientH - sizeH) + posY * sizeH - ( (alignY-1) * margin/2 )) + unit;
    elem.style.display = "block";
    elem.style.fontSize = "" + fontSize + unit;
  }

  var layouts = { //function array
    "NONE":
    function() {
      for (var i = 0, len = touchButtons.length; i < len; i++)
        touchButtons[i].style.display = "none";
    },
    "KBD_R":
    function() {
      setPos(touchLeft,  0, -1, buttonW, buttonH, 0, 2, 0, 0, winW, winH);
      setPos(touchDrop,   0.5, -2, buttonW, buttonH, 0, 2, 0, 0, winW, winH);
      setPos(touchRotRight, 1, -1, buttonW, buttonH, 0, 2, 0, 0, winW, winH);
      setPos(touchHold,     1.5, 0, buttonW, buttonH, 0, 2, 0, 0, winW, winH);
      setPos(touchRight,    0, 0, buttonW, buttonH, 2, 2, 0, 0, winW, winH);
      setPos(touchRotLeft,     -2, 0, buttonW, buttonH, 2, 2, 0, 0, winW, winH);
      setPos(touchDown,     -1, 0, buttonW, buttonH, 2, 2, 0, 0, winW, winH);
      setPos(touchRot180,     -1, -1, buttonW, buttonH, 2, 2, 0, 0, winW, winH);
    }
  };

  setPos(touchLayout, 0, 0, buttonW*0.8, buttonH*0.8, 2, 0, 0, 0, winW, winH);
  layouts["KBD_R"]();
}



    });
})();