Moving touch buttons in tetr.js

title

27.01.2020 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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"]();
}



    });
})();