// ==UserScript==

// @name Zoom

// @description Adjust your zoom

// @include http://tagpro-*.koalabeast.com:*

// @include http://*.jukejuice.com:*

// @include http://*.newcompte.fr:*

// @include http://justletme.be:*

// @author D'n Pilzer

// @version 0.1

// ==/UserScript==

//USE THE -_ OR NUMPAD - BUTTON TO ZOOM OUT

//USE THE =+ OR NUMPAD + BUTTON TO ZOOM IN

//USE NUMPAD 6 OR NUMPAD * TO CENTER OR 'UNCENTER' YOUR VIEW

var timer = new Date().getTime();

function center_screen(){

if (tagpro.viewPort.followPlayer) {

var columnCount=0;

var rowCount=0;

var tileCount=0;

var centerX=0;

var centerY=0;

for(column in tagpro.map){

for(tile in tagpro.map[column]){

tileCount++;

}

columnCount++;

}

rowCount = tileCount/columnCount;

centerX = columnCount/2*40;

centerY = rowCount/2*40;

tagpro.viewPort.followPlayer = false;

tagpro.viewPort.source = {};

tagpro.viewPort.source.x = centerX;

tagpro.viewPort.source.y = centerY;

tagpro.zoom = 3;

}

else {

tagpro.viewPort.source = {};

tagpro.viewPort.followPlayer = true;

tagpro.zoom = 1;

}

}

function rectangle(){

var proxied_drawWithZoom = tagpro.tiles.drawWithZoom;

tagpro.tiles.drawWithZoom = function(e, t, n, r, i, s) {

if (t == 'redball' || t == 'blueball') {

if (new Date().getTime() - timer >= 5) {

timer = new Date().getTime();

e.globalAlpha = 1 ;

player = {x: 0, y: 0};

player.x = ((tagpro.players[tagpro.playerId].x - tagpro.viewPort.source.x) / tagpro.zoom) + ($('#viewPort').width() / 2);

player.y = ((tagpro.players[tagpro.playerId].y - tagpro.viewPort.source.y) / tagpro.zoom) + ($('#viewPort').height() / 2);

e.fillStyle = e.strokeStyle = (tagpro.players[tagpro.playerId].team == 1) ? '#FF0000' : '#0000FF';

e.strokeRect(player.x - (640 / tagpro.zoom), player.y - (400 / tagpro.zoom), 1280 / tagpro.zoom, 800 / tagpro.zoom);

}

}

return proxied_drawWithZoom.apply(this, arguments);

};

}

function doc_keyDown(e) {

switch (e.keyCode) {

case 187: //_-

tagpro.zoom = tagpro.zoom / 1.1;

rectangle();

break;

case 107: //numpad-

tagpro.zoom = tagpro.zoom / 1.1;

rectangle();

break;

case 52: //4

tagpro.zoom = tagpro.zoom / 1.1;

rectangle();

break;

case 189: //=+

tagpro.zoom = tagpro.zoom * 1.1;

rectangle();

break;

case 109: //numpad+

tagpro.zoom = tagpro.zoom * 1.1;

rectangle();

break;

case 53: //5

tagpro.zoom = tagpro.zoom * 1.1;

rectangle();

break;

case 102: //numpad 6

center_screen();

rectangle();

break;

case 106: //numpad *

center_screen();

rectangle();

break;

}

}