TagPro Checkered Teamtiles

Replace the yellow teamtiles by checkered Red and Blue tiles.

当前为 2019-02-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name TagPro Checkered Teamtiles
  3. // @version 2.0
  4. // @description Replace the yellow teamtiles by checkered Red and Blue tiles.
  5. // @author Ko
  6. // @include http://tagpro-*.koalabeast.com:*
  7. // @include http://*.newcompte.fr:*
  8. // @include http://tangent.jukejuice.com:*
  9. // @include http://tagpro-*.koalabeast.com/game
  10. // @supportURL https://www.reddit.com/message/compose/?to=Wilcooo
  11. // @license MIT
  12. // @namespace https://greasyfork.org/users/152992
  13. // ==/UserScript==
  14.  
  15. const blue_first = false;
  16. // change this to true if you want the top-left tile to be blue
  17.  
  18. tagpro.ready(function(){
  19.  
  20. var ctt_cached = false;
  21.  
  22. var org_getTexture = tagpro.tiles.getTexture;
  23.  
  24. tagpro.tiles.getTexture = function (tile_code, tile, spread) {
  25. if (tile_code != 23 || (PIXI.utils.TextureCache[tile_code] && ctt_cached) ) {
  26. return org_getTexture(tile_code, tile, spread);
  27. }else{
  28. var canvas = document.createElement("canvas");
  29. canvas.width = 40;
  30. canvas.height = 40;
  31. var context = canvas.getContext("2d"),
  32. source = tagpro.tiles.image,
  33. red_teamtile = tagpro.tiles[11],
  34. blue_teamtile = tagpro.tiles[12],
  35. red = {x: red_teamtile.x * 40, y: red_teamtile.y * 40},
  36. blue = {x: blue_teamtile.x * 40, y: blue_teamtile.y * 40};
  37. context.drawImage(source, red.x, red.y, 40, 40, 0 + blue_first*20, 0, 20 + blue_first*20, 20);
  38. context.drawImage(source, blue.x, blue.y, 40, 40, 20 - blue_first*20, 0, 40 - blue_first*20, 20);
  39. context.drawImage(source, blue.x, blue.y, 40, 40, 0 + blue_first*20, 20, 20 + blue_first*20, 40);
  40. context.drawImage(source, red.x, red.y, 40, 40, 20 - blue_first*20, 20, 40 - blue_first*20, 40);
  41. PIXI.utils.TextureCache[tile_code] = PIXI.Texture.fromCanvas(canvas);
  42. ctt_cached = true;
  43. return PIXI.utils.TextureCache[tile_code];
  44. }
  45. };
  46. });