Skip to content

Instantly share code, notes, and snippets.

@nabbynz
Last active April 13, 2021 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nabbynz/b8c8d8b70a34f39d1cf5 to your computer and use it in GitHub Desktop.
Save nabbynz/b8c8d8b70a34f39d1cf5 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name TagPro Map Name Below Timer (& More!)
// @description - Show the name of the map & author below the countdown timer.
// - Show the currently playing music track.
// - Show the score difference (above the timer).
// - Show who is currently carrying the flag.
// - Show when the flags are out (a red/blue line on either side of the viewport).
// - Show a stat-line displaying which team has the advantage in that stat.
// - Modify the Timer and Scores text to look a bit sharper.
// - Match your texture pack's colors for the Red/Blue colors.
// - Show "Overtime!" when overtime starts.
// - Slow zoom out the map at the end of a game.
// - Slow zoom in the map at the start of a game.
// - & more!
// @version 1.6.0
// @include https://tagpro.koalabeast.com/game
// @include https://tagpro.koalabeast.com/game?*
// @include https://bash-tp.github.io/tagpro-vcr/game*.html
// @updateURL https://gist.github.com/nabbynz/b8c8d8b70a34f39d1cf5/raw/TagPro_Map_Name_Above_Timer.user.js
// @downloadURL https://gist.github.com/nabbynz/b8c8d8b70a34f39d1cf5/raw/TagPro_Map_Name_Above_Timer.user.js
// @grant none
// @author nabby
// ==/UserScript==
console.log('START: ' + GM_info.script.name + ' (v' + GM_info.script.version + ' by ' + GM_info.script.author + ')');
//------ Options --------
const showMapName = true; //Shows the name of the map and who made it [Default: true]
const showMusicTrackName = true; //Shows the currently playing music track [Default: true]
const showScoreDifference = true; //Shows the score differential [Default: true]
const showFlagCarriers = true; //Shows the name of the player currently holding the flag [Default: true]
const showFlagsOut = false; //Shows a left(red)/right(blue) border when either flag is out [Default: false]
const makeFlagsOutBigger = true; //Make the flags out indicator by the timer bigger (1.5x vs 0.75x default) [Default: true]
const showStatLine = false; //Shows which team is dominating this particular stat (red/blue line above the timer) [Default: false]
const statToShow = 's-powerups'; //If "showStatLine" is true this can be one of: 'score', 's-tags', 's-pops', 's-grabs', 's-drops', 's-hold', 's-captures', 's-prevent', 's-returns', 's-support', 's-powerups' [Default: 's-powerups']
const addDropShadowToTimer = true; //Adds a drop-shadow to the timer so it stands out a bit more and increase the opacity [Default: true]
const addDropShadowToScores = true; //Adds a drop-shadow to the scores so they stand out a bit more and increase the opacity [Default: true]
const slowZoomInAtSOG = true; //Slowly zooms in the map at the start of a game. [Default: true]
const slowZoomOutAtEOG = true; //Slowly zooms out the map at the end of a game. [Default: true]
const showOvertimeText = true; //Shows an "Overtime!" message when the game goes into Overtime (needs "addDropShadowToTimer" to be true too). [Default: true]
const showNextGameCountdown = true; //Shows a 25 second countdown when the game ends. [Default: true]
const showWhenUnevenTeams = false; //Makes the timer red when uneven teams and shows a message when teams are uneven/even. [Default: false]
const matchBallColors = true; //Changes the default Red/Blue colors to match your texture pack's colors (will override the below colors) [Default: true]
let redScoreColor = '#ff2222'; //Red Color for: Score, "Red Wins", Particle Splats, etc [TagPro Default: '#ff2222']
let blueScoreColor = '#2244dd'; //Blue Color for: Score, "Blue Wins", Particle Splats, etc [TagPro Default: '#2244dd']
//----- End of Options -----
tagpro.ready(function() {
tagpro.mapName = '';
tagpro.mapAuthor = '';
tagpro.socket.on('map', function(data) {
tagpro.mapName = data.info.name;
tagpro.mapAuthor = data.info.author;
});
if (slowZoomInAtSOG) {
let clearableZoom;
tagpro.socket.on('time', function(data) {
const extraTime = 4000;
if (data.state === 3 && data.time > extraTime) { //before the actual start, and if we have enough time
const zoomFrom = 3.14;
const frequency = 16;
const mapWidth = tagpro.map.length * 40;
const mapHeight = tagpro.map[0].length * 40;
const normalVPWidth = tagpro.renderer.canvas_width;
const normalVPHeight = tagpro.renderer.canvas_height;
const zoomStop = Math.max(mapWidth / normalVPWidth, mapHeight / normalVPHeight);
const interval = (Math.abs(zoomFrom - zoomStop) / ((data.time - extraTime) * 1000 / frequency / 1000)) * (zoomFrom < 1 ? -1 : 1);
setTimeout(function() { //sometimes tagpro.spectator isn't set yet, so let's wait a bit longer
if (!tagpro.spectator) {
setTimeout(function() { //same for these sprites...
if (tagpro.ui && tagpro.ui.sprites && tagpro.ui.sprites.spectatorInfo1) tagpro.ui.sprites.spectatorInfo1.alpha = 0;
if (tagpro.ui && tagpro.ui.sprites && tagpro.ui.sprites.spectatorInfo2) tagpro.ui.sprites.spectatorInfo2.alpha = 0;
}, 200);
tagpro.zoom = zoomFrom;
$('#loadingMessage').hide(0);
tagpro.viewport.followPlayer = false;
tagpro.spectator = true;
$('#viewport').show(0);
clearableZoom = setInterval(function() {
tagpro.zoom -= interval;
if ((tagpro.zoom >= zoomStop && interval <= 0) || (tagpro.zoom <= zoomStop && interval >= 0) || tagpro.state !== 3) {
clearInterval(clearableZoom);
$('#viewport').fadeOut(200, function() {
tagpro.zoom = 1;
tagpro.viewport.followPlayer = true;
tagpro.spectator = false;
$('#viewport').fadeIn(200);
});
}
}, frequency);
}
}, 250);
}
});
}
});
let start = function() {
let viewport = $("#viewport");
if (matchBallColors) {
let canvas = new OffscreenCanvas(80, 40);
let ctx = canvas.getContext("2d");
ctx.drawImage(tagpro.tiles.image, 560,0,80,40, 0,0,80,40);
let getAverageColor = function(data, asHex=false, ignoreGrey=false, pixelInterval=1) {
let rgb = { r:null, g:null, b:null };
let length = data.length;
let count = 0;
let i = -4;
while ((i += pixelInterval * 4) < length) {
//let b = data[i] * 0.299 + data[i+1] * 0.587 + data[i+2] * 0.114;
let isGrey = ignoreGrey && (Math.abs(data[i] - data[i+1]) + Math.abs(data[i+1] - data[i+2]) < 10);
if (!isGrey && data[i+3]) {
rgb.r += data[i];
rgb.g += data[i+1];
rgb.b += data[i+2];
count++;
}
}
if (count === 0) return null; //transparent or all grey
rgb.r = Math.floor(rgb.r / count);
rgb.g = Math.floor(rgb.g / count);
rgb.b = Math.floor(rgb.b / count);
if (asHex) {
return rgbToHex(rgb.r, rgb.g, rgb.b).slice(0, 7);
} else {
return rgb;
}
};
let ballPixelData = ctx.getImageData(5, 5, 30, 30).data;
redScoreColor = getAverageColor(ballPixelData, true, true) || redScoreColor;
ballPixelData = ctx.getImageData(45, 5, 30, 30).data;
blueScoreColor = getAverageColor(ballPixelData, true, true) || blueScoreColor;
let scoreboardBGColor = tinycolor.mostReadable(redScoreColor, ["#333", "#ccc"],{includeFallbackColors:true}).toHexString();
canvas = null;
let n = tagpro.renderer.layers.ui;
let t = { x:viewport.width() / 2, y:viewport.height() / 2 };
let e = { width:viewport.width(), height:viewport.height() };
tagpro.renderer.drawBallPop = function (x, y, color) {
let explosion = new PIXI.Graphics();
explosion.tagpro = {
started: performance.now(),
length: 150,
x: x - 20,
y: y - 20,
size: 1.5 * 40,
color: Number('0x' + color) //team === 1 ? 0xFF0000 : 0x0000FF
};
tagpro.renderer.layers.foreground.addChild(explosion);
tagpro.renderer.explosions.push(explosion);
};
tagpro.renderer.drawSplat = function (x, y, team, showDeath, fadeAway, scale) {
let startColor = (team === 1 ? redScoreColor.slice(1) : blueScoreColor.slice(1));
let stopColor = "ffffff";
if (showDeath) {
if (tagpro.renderer.options.disableParticles) {
tagpro.renderer.drawBallPop(x + 19, y + 19, startColor);
} else {
tagpro.renderer.startDeathEmitter(startColor, stopColor, x + 19, y + 19);
}
}
tagpro.renderer.addSplat(team, x, y, fadeAway, scale);
};
tagpro.renderer.largeText = function(text, color1='#cccccc', color2='#ffffff', size=54, dropShadowBlur=true) {
return new PIXI.Text(text, {
dropShadow: dropShadowBlur,
dropShadowAlpha: 0.6,
dropShadowAngle: 0,
dropShadowBlur: 12,
dropShadowDistance: 0,
dropShadowColor: color1,
fill: [color2, color1],
fillGradientStops: [0.1, 0.8],
fontSize: size,
fontWeight: "bold",
letterSpacing: 1,
padding: 10,
strokeThickness: 2
});
};
tagpro.ui.largeAlert = function(e, t, n, text, color1, color2='#ffffff', top=50, size=54, dropShadowBlur=true) {
let s = tagpro.renderer.largeText(text, color1, color2, size, dropShadowBlur);
s.x = Math.round(t.x - s.width / 2);
s.y = top; //50 is positioned just above the scoreboard (with 54px font)
e.addChild(s);
return s;
};
let i = false, r = false;
tagpro.ui.update = function() {
if (!tagpro.ui.enabled) return;
if (tagpro.settings.ui.spectatorInfo) tagpro.ui.spectatorInfo(n, t);
if (tagpro.settings.ui.matchState) {
tagpro.ui.scores(n, t, e);
tagpro.ui.updateFlags(n, t, e);
tagpro.ui.updatePlayerIndicators();
let s = Math.floor((tagpro.ping.loss || 0) * 100);
tagpro.ui.performanceInfo(n, t, e, s);
tagpro.ui.alignUI();
if (tagpro.state === 2) {
if (!r) {
if (tagpro.winner === "red") {
tagpro.ui.largeAlert(n, t, e, (tagpro.teamNames.redTeamName || "Red") + " Wins!", redScoreColor);
} else if (tagpro.winner === "blue") {
tagpro.ui.largeAlert(n, t, e, (tagpro.teamNames.blueTeamName || "Blue") + " Wins!", blueScoreColor);
} else if (tagpro.winner === "tie") {
tagpro.ui.largeAlert(n, t, e, "It's a tie!");
} else {
tagpro.ui.largeAlert(n, t, e, tagpro.winner);
}
r = true;
}
} else if (tagpro.state === 3 && !i) {
for (let index = 0; index < n.children.length; index++) {
if (n.children[index]._text === "Match Begins Soon...") { //remove the default one and replace with our own prettier one...
n.children[index].visible = false;
n.removeChild(n.children[index]);
break;
}
}
let o = tagpro.ui.largeAlert(n, t, e, "Match Begins Soon...", "#777777");
let p = tagpro.ui.largeAlert(n, t, e, tagpro.mapName, "#8bc34a", "#336633", 130, 40, false);
let u = function() {
if (tagpro.state !== 3) {
if (o && o.visible) {
o.visible = false;
p.visible = false;
n.removeChild(o);
n.removeChild(p);
//$('#miniContainer').fadeOut(200);
}
} else {
setTimeout(u, 50);
}
};
setTimeout(u, 20);
i = true;
}
}
};
}
function showPixiTextAlert(text, color1='#888888', color2='#ffffff', size=80, centerOffsetX=0, centerOffsetY=0, time=1000) {
let textSprite = tagpro.renderer.largeText(text, color1, color2, size);
let vp = { x:viewport.width() / 2, y:viewport.height() / 2 };
textSprite.x = Math.round(vp.x - textSprite.width / 2) + centerOffsetX;
textSprite.y = Math.round(vp.y + centerOffsetY);
requestAnimationFrame(function() {
tagpro.renderer.layers.ui.addChild(textSprite);
setTimeout(function() {
tagpro.renderer.layers.ui.removeChild(textSprite);
}, time);
});
}
if (showMapName) {
var updateMapName = function() {
let mapTitle = new PIXI.Text("Map: " + tagpro.mapName + " by " + tagpro.mapAuthor, {"dropShadow": true, "dropShadowAlpha": 0.3, "dropShadowAngle": 0, "dropShadowBlur": 1, "dropShadowDistance": 0, "letterSpacing": 1.1, "lineJoin": "round", "fill": "#ffffff", "fontSize": 11, "fontWeight": 600, "stroke": "#252525", "strokeThickness": 2 } );
mapTitle.anchor.x = 0.5;
mapTitle.x = ($("#viewport").width() / 2);
mapTitle.y = $("#viewport").height() - 12;
mapTitle.alpha = 0.7;
if (mapTitle.width % 2 !== 0) mapTitle.width++;
if (!tagpro.ui.sprites.mapTitle) {
tagpro.ui.sprites.mapTitle = new PIXI.Container();
}
tagpro.renderer.layers.ui.addChild(tagpro.ui.sprites.mapTitle);
tagpro.ui.sprites.mapTitle.removeChildren();
tagpro.ui.sprites.mapTitle.addChild(mapTitle);
};
updateMapName();
}
if (addDropShadowToScores) {
tagpro.ui.sprites.redScore.style = { dropShadow:true, dropShadowAlpha:0.8, dropShadowDistance:1, fill:redScoreColor, fontFamily:'Arial', fontSize:'50px', fontWeight:'bold' };
tagpro.ui.sprites.redScore.alpha = 0.8; //brighter - TagPro default is 0.5
tagpro.ui.sprites.blueScore.style = { dropShadow:true, dropShadowAlpha:0.8, dropShadowDistance:1, fill:blueScoreColor, fontFamily:'Arial', fontSize:'50px', fontWeight:'bold' };
tagpro.ui.sprites.blueScore.alpha = 0.8;
}
if (true) {
$('#exit').css({ 'margin':'5px', 'padding':'0 10px', 'background':'#222', 'border':'2px outset #888', 'border-radius':'5px' });
}
if (addDropShadowToTimer || showOvertimeText || showNextGameCountdown || slowZoomOutAtEOG) {
if (addDropShadowToTimer) {
tagpro.ui.sprites.timer.alpha = 0.6; //brighter - TagPro default is 0.5
tagpro.ui.sprites.timer.style = { dropShadow:true, dropShadowAlpha:0.5, dropShadowDistance:2, strokeThickness:2, fill:'#ffffff', fontFamily:'Arial', fontSize:'39px', fontWeight:'bold' };
}
let updateTimerColor = function(color='#ffffff') {
tagpro.ui.sprites.timer.style.fill = color;
}
updateTimerColor(tagpro.state === 3 ? '#3ff53f' : tagpro.state === 5 ? '#f4b942' : '#ffffff'); //pre-game : overtime : normal
tagpro.socket.on('time', function(data) {
if (showOvertimeText && data.state === 5) { //overtime
showPixiTextAlert('Overtime!', '#bb00bb', '#ffffff', 80, 0, -260, 800);
updateTimerColor('#f4b942'); //orange: #f4b942
} else { //normal game time
updateTimerColor('#ffffff');
}
});
tagpro.socket.on('end', function() {
if (!tagpro.overtimeStartedAt) updateTimerColor('#bbbbbb'); //game has ended timer color
if (showNextGameCountdown) addNextGameCountdown();
if (slowZoomOutAtEOG) {
const zoomStop = 1.25;
const zoomTime = 20 * 1000; //zoom out for 20 seconds
const timeoutInterval = 50;
const zoomStep = 1 / (zoomTime / timeoutInterval) * (zoomStop - 1);
let clearable_zoom;
let isZooming = true;
let savedZoom = tagpro.zoom;
let doZoom = function() {
tagpro.zoom += zoomStep;
savedZoom = tagpro.zoom;
clearTimeout(clearable_zoom);
if (tagpro.zoom < zoomStop) clearable_zoom = setTimeout(doZoom, timeoutInterval);
}
if (!tagpro.spectator) {
tagpro.spectator = true;
clearable_zoom = setTimeout(doZoom, 2000);
}
$(document).on('keydown', function(e) {
if (e.which === 90) {
clearTimeout(clearable_zoom);
isZooming = !isZooming;
if (isZooming) {
tagpro.zoom = savedZoom;
clearable_zoom = doZoom();
}
}
});
}
});
let addNextGameCountdown = function() {
let nextGameCountdown = new PIXI.Text("00:25", { fontFamily:'Tahoma', fontSize:'18px', fontWeight:'bold', fill:'#dd44dd', dropShadow:true, dropShadowAlpha:0.8, dropShadowDistance:1 });
let secondsLeft = 25;
let clearable;
nextGameCountdown.anchor.x = 0.5;
nextGameCountdown.x = ($("#viewport").width() / 2);
nextGameCountdown.y = $("#viewport").height() - (showStatLine ? 120 : 110);
nextGameCountdown.alpha = 0.8;
if (!tagpro.ui.sprites.nextGameCountdown) {
tagpro.ui.sprites.nextGameCountdown = new PIXI.Container();
}
tagpro.renderer.layers.ui.addChild(tagpro.ui.sprites.nextGameCountdown);
tagpro.ui.sprites.nextGameCountdown.removeChildren();
tagpro.ui.sprites.nextGameCountdown.addChild(nextGameCountdown);
clearable = setInterval(function() {
secondsLeft--;
nextGameCountdown.text = 'Next game starts in ' + (secondsLeft < 10 ? '' : '') + secondsLeft + ' seconds...';
$('#exit').text('< Exit [' + secondsLeft + ']');
if (secondsLeft === 1) $('#exit').hide();
if (secondsLeft <= 0) clearInterval(clearable);
}, 1000);
};
}
let unevenTeams = false;
var checkTeamPlayerCount = function() {
if ((tagpro.state === 1 || tagpro.state === 5) && tagpro.ui.sprites && tagpro.ui.sprites.playerIndicators) {
let redTeamCount = tagpro.ui.sprites.playerIndicators.children[0].children.length;
let blueTeamCount = tagpro.ui.sprites.playerIndicators.children[1].children.length;
if (redTeamCount !== blueTeamCount && !unevenTeams) {
updateTimerColor('#ff0000');
showPixiTextAlert('Uneven Teams - Wait!', '#dc3939', '#111111', 60, 0, -100, 800);
unevenTeams = true;
} else if (redTeamCount === blueTeamCount && unevenTeams) {
updateTimerColor('#ffffff');
showPixiTextAlert('Even Teams - Go!', '#CDDC39', '#111111', 60, 0, -100, 800);
unevenTeams = false;
}
}
}
if (showWhenUnevenTeams) {
setInterval(checkTeamPlayerCount, 1234);
tagpro.socket.on('playerLeft', function() {
checkTeamPlayerCount();
});
}
if (showScoreDifference) {
tagpro.socket.on('score', function(data) {
updateScoreDifference(data);
});
$('#switchButton').on('click', function() {
setTimeout(function() {
updateScoreDifference( { r:tagpro.score.r, b:tagpro.score.b } );
}, 1000);
});
var updateScoreDifference = function(data) {
let diffText = '=';
let color = '#ffff40';
if (data.r - data.b > 0) {
if (tagpro.playerId && tagpro.players[tagpro.playerId].team === 1) {
diffText = '+' + Math.abs(data.r - data.b);
color = '#00CC00';
} else {
diffText = '-' + Math.abs(data.r - data.b);
color = '#CC0000';
}
} else if (data.r - data.b < 0) {
if (tagpro.playerId && tagpro.players[tagpro.playerId].team === 1) {
diffText = '-' + Math.abs(data.r - data.b);
color = '#CC0000';
} else {
diffText = '+' + Math.abs(data.r - data.b);
color = '#00CC00';
}
}
let scoreDiff = new PIXI.Text(diffText, { fontFamily:'Verdana', fontSize:'32px', fontWeight:'bold', fontStyle: 'italic', fill:color, dropShadow:true, dropShadowAlpha:0.7, dropShadowDistance:1 });
scoreDiff.anchor.x = 0.5;
scoreDiff.x = ($("#viewport").width() / 2);
scoreDiff.y = $("#viewport").height() - 86;
scoreDiff.alpha = 0.7;
if (!tagpro.ui.sprites.scoreDiff) {
tagpro.ui.sprites.scoreDiff = new PIXI.Container();
}
tagpro.renderer.layers.ui.addChild(tagpro.ui.sprites.scoreDiff);
tagpro.ui.sprites.scoreDiff.removeChildren();
tagpro.ui.sprites.scoreDiff.addChild(scoreDiff);
};
updateScoreDifference( { r:tagpro.score.r, b:tagpro.score.b } );
}
if (showMusicTrackName) {
tagpro.renderer.layers.ui.y = -13; //need a bit more room
var updateMusicTrackName = function() {
if (tagpro.music && tagpro.musicPlayer.current) {
let trackName = new PIXI.Text('Music: ' + tagpro.musicPlayer.current.name + ' [by ' + tagpro.musicPlayer.current.author + ']', {"dropShadow": true, "dropShadowAlpha": 0.5, "dropShadowAngle": 0, "dropShadowBlur": 1, "dropShadowDistance": 0, "letterSpacing": 1.05, "lineJoin": "round", "fill": "#eeeeee", "fontSize": 10, "strokeThickness": 1 } );
trackName.anchor.x = 0.5;
trackName.x = ($("#viewport").width() / 2);
trackName.y = $("#viewport").height();
trackName.alpha = 0.6;
if (trackName.width % 2 !== 0) trackName.width++;
if (!tagpro.ui.sprites.trackName) {
tagpro.ui.sprites.trackName = new PIXI.Container();
}
tagpro.renderer.layers.ui.addChild(tagpro.ui.sprites.trackName);
tagpro.ui.sprites.trackName.removeChildren();
tagpro.ui.sprites.trackName.addChild(trackName);
} else {
if (tagpro.ui.sprites.trackName) {
tagpro.ui.sprites.trackName.removeChildren();
}
}
};
document.addEventListener('play', function(e) {
if (e.target.id === 'music') {
setTimeout(updateMusicTrackName, 200);
}
}, true);
$('#soundMusic').on('click', function() {
setTimeout(function() {
if (!tagpro.music) {
tagpro.ui.sprites.trackName.removeChildren();
}
}, 200);
});
}
if (showStatLine) {
var updateStatLine = function() {
let totalWidth = 500;
let startX = $("#viewport").width() / 2;
let x = startX;
let y = $("#viewport").height() - 90;
let lineWidth = 5;
let redStat=0, blueStat=0, redCount=0, blueCount=0;
for (let playerId in tagpro.players) {
if (tagpro.players[playerId].team === 1) {
redStat += tagpro.players[playerId][statToShow];
redCount++;
} else {
blueStat += tagpro.players[playerId][statToShow];
blueCount++;
}
}
if (!redStat && !blueStat) {
redStat = 1;
blueStat = 1;
}
redStat = Math.abs(redStat) / (redCount || 1);
blueStat = Math.abs(blueStat) / (blueCount || 1);
let statLine = new PIXI.Graphics();
statLine.moveTo(startX, y);
statLine.lineStyle(lineWidth, '0x' + redScoreColor.slice(1));
x = (redStat / (redStat+blueStat)) * totalWidth;
statLine.lineTo(startX + x, y);
statLine.lineStyle(lineWidth, '0x' + blueScoreColor.slice(1));
statLine.lineTo(startX + totalWidth, y);
statLine.pivot.x = totalWidth / 2;
statLine.alpha = 0.3;
if (!tagpro.ui.sprites.statLine) {
tagpro.ui.sprites.statLine = new PIXI.Container();
}
tagpro.renderer.layers.ui.addChild(tagpro.ui.sprites.statLine);
tagpro.ui.sprites.statLine.removeChildren();
tagpro.ui.sprites.statLine.addChild(statLine);
};
setInterval(updateStatLine, 3000);
}
if (showFlagCarriers || showFlagsOut) {
tagpro.socket.on('sound', function(data) {
if (data.s === 'friendlyalert' || data.s === 'alert' || data.s === 'friendlydrop' || data.s === 'drop' || data.s === 'cheering' || data.s === 'sigh') {
setTimeout(updateFlagCarriers, 150);
}
});
let redFlagHolder = new PIXI.Text('', { fontFamily:'Verdana', fontSize:'14px', fontStyle:'bold', fill:redScoreColor, dropShadow:true, dropShadowAlpha:0.7, dropShadowDistance:1 });
let blueFlagHolder = new PIXI.Text('', { fontFamily:'Verdana', fontSize:'14px', fontStyle:'bold', fill:blueScoreColor, dropShadow:true, dropShadowAlpha:0.7, dropShadowDistance:1 }); //#8686FF
var updateFlagCarriers = function() {
let redHolder = 0;
let blueHolder = 0;
for (let playerId in tagpro.players) {
if (tagpro.players[playerId].flag === 1) {
blueHolder = Number(playerId);
} else if (tagpro.players[playerId].flag === 2) {
redHolder = Number(playerId);
} else if (tagpro.players[playerId].flag === 3) {
if (tagpro.players[playerId].team === 1) {
redHolder = Number(playerId);
} else {
blueHolder = Number(playerId);
}
continue;
}
}
if (redHolder) {
if (!tagpro.renderer.layers.ui.redFlagHolder) {
redFlagHolder.anchor.x = 1;
redFlagHolder.x = $("#viewport").width() / 2 - 150;
redFlagHolder.y = tagpro.ui.sprites.redScore.y + 60;
tagpro.renderer.layers.ui.addChild(redFlagHolder);
}
redFlagHolder.text = tagpro.players[redHolder].name;
redFlagHolder.visible = true;
if (showFlagsOut) $('#viewport').css('border-left', '6px solid ' + redScoreColor);
} else {
redFlagHolder.visible = false;
if (showFlagsOut) $('#viewport').css('border-left', '6px solid transparent');
}
if (blueHolder) {
if (!tagpro.renderer.layers.ui.blueFlagHolder) {
blueFlagHolder.x = $("#viewport").width() / 2 + 150;
blueFlagHolder.y = tagpro.ui.sprites.blueScore.y + 60;
tagpro.renderer.layers.ui.addChild(blueFlagHolder);
}
blueFlagHolder.text = tagpro.players[blueHolder].name;
blueFlagHolder.visible = true;
if (showFlagsOut) $('#viewport').css('border-right', '6px solid ' + blueScoreColor);
} else {
blueFlagHolder.visible = false;
if (showFlagsOut) $('#viewport').css('border-right', '6px solid transparent');
}
};
updateFlagCarriers();
}
if (makeFlagsOutBigger) {
for (let i=0; i<tagpro.ui.flags.length; i++) {
tagpro.ui.flags[i].scale = { x:1.5, y:1.5 };
}
}
let rACV = tagpro.renderer.resizeAndCenterView;
tagpro.renderer.resizeAndCenterView = function() {
rACV();
if (showMapName) updateMapName();
if (showScoreDifference) updateScoreDifference( { r:tagpro.score.r, b:tagpro.score.b } );
if (showMusicTrackName) updateMusicTrackName();
if (showStatLine) updateStatLine();
if (showFlagCarriers || showFlagsOut) updateFlagCarriers();
};
tagpro.renderer.resizeAndCenterView();
}; //start
const timeoutInterval = 50;
const maxCounter = 500;
let startCounter = 0;
(async() => {
while ((!tagpro || !tagpro.renderer || !tagpro.renderer.layers || !tagpro.ui || !tagpro.ui.sprites || !tagpro.ui.sprites.blueScore || !tagpro.ui.sprites.timer) && (startCounter < maxCounter)) {
startCounter++;
await new Promise(resolve => setTimeout(resolve, timeoutInterval));
}
if (startCounter < maxCounter) {
console.log("MNBT is READY!", startCounter, startCounter * timeoutInterval);
start();
} else {
console.log("MNBT was NOT ready - giving up.", startCounter, startCounter * timeoutInterval);
}
})();
// Helpers...
function rgbToHex(r, g, b) {
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
// TinyColor v1.4.1
// https://github.com/bgrins/TinyColor
// 2016-07-07, Brian Grinstead, MIT License
!function(a){function b(a,d){if(a=a?a:"",d=d||{},a instanceof b)return a;if(!(this instanceof b))return new b(a,d);let e=c(a);this._originalInput=a,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=P(100*this._a)/100,this._format=d.format||e.format,this._gradientType=d.gradientType,this._r<1&&(this._r=P(this._r)),this._g<1&&(this._g=P(this._g)),this._b<1&&(this._b=P(this._b)),this._ok=e.ok,this._tc_id=O++}function c(a){let b={r:0,g:0,b:0},c=1,e=null,g=null,i=null,j=!1,k=!1;return"string"==typeof a&&(a=K(a)),"object"==typeof a&&(J(a.r)&&J(a.g)&&J(a.b)?(b=d(a.r,a.g,a.b),j=!0,k="%"===String(a.r).substr(-1)?"prgb":"rgb"):J(a.h)&&J(a.s)&&J(a.v)?(e=G(a.s),g=G(a.v),b=h(a.h,e,g),j=!0,k="hsv"):J(a.h)&&J(a.s)&&J(a.l)&&(e=G(a.s),i=G(a.l),b=f(a.h,e,i),j=!0,k="hsl"),a.hasOwnProperty("a")&&(c=a.a)),c=z(c),{ok:j,format:a.format||k,r:Q(255,R(b.r,0)),g:Q(255,R(b.g,0)),b:Q(255,R(b.b,0)),a:c}}function d(a,b,c){return{r:255*A(a,255),g:255*A(b,255),b:255*A(c,255)}}function e(a,b,c){a=A(a,255),b=A(b,255),c=A(c,255);let d,e,f=R(a,b,c),g=Q(a,b,c),h=(f+g)/2;if(f==g)d=e=0;else{let i=f-g;switch(e=h>.5?i/(2-f-g):i/(f+g),f){case a:d=(b-c)/i+(c>b?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,l:h}}function f(a,b,c){function d(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+6*(b-a)*(2/3-c):a}let e,f,g;if(a=A(a,360),b=A(b,100),c=A(c,100),0===b)e=f=g=c;else{let h=.5>c?c*(1+b):c+b-c*b,i=2*c-h;e=d(i,h,a+1/3),f=d(i,h,a),g=d(i,h,a-1/3)}return{r:255*e,g:255*f,b:255*g}}function g(a,b,c){a=A(a,255),b=A(b,255),c=A(c,255);let d,e,f=R(a,b,c),g=Q(a,b,c),h=f,i=f-g;if(e=0===f?0:i/f,f==g)d=0;else{switch(f){case a:d=(b-c)/i+(c>b?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,v:h}}function h(b,c,d){b=6*A(b,360),c=A(c,100),d=A(d,100);let e=a.floor(b),f=b-e,g=d*(1-c),h=d*(1-f*c),i=d*(1-(1-f)*c),j=e%6,k=[d,h,g,g,i,d][j],l=[i,d,d,h,g,g][j],m=[g,g,i,d,d,h][j];return{r:255*k,g:255*l,b:255*m}}function i(a,b,c,d){let e=[F(P(a).toString(16)),F(P(b).toString(16)),F(P(c).toString(16))];return d&&e[0].charAt(0)==e[0].charAt(1)&&e[1].charAt(0)==e[1].charAt(1)&&e[2].charAt(0)==e[2].charAt(1)?e[0].charAt(0)+e[1].charAt(0)+e[2].charAt(0):e.join("")}function j(a,b,c,d,e){let f=[F(P(a).toString(16)),F(P(b).toString(16)),F(P(c).toString(16)),F(H(d))];return e&&f[0].charAt(0)==f[0].charAt(1)&&f[1].charAt(0)==f[1].charAt(1)&&f[2].charAt(0)==f[2].charAt(1)&&f[3].charAt(0)==f[3].charAt(1)?f[0].charAt(0)+f[1].charAt(0)+f[2].charAt(0)+f[3].charAt(0):f.join("")}function k(a,b,c,d){let e=[F(H(d)),F(P(a).toString(16)),F(P(b).toString(16)),F(P(c).toString(16))];return e.join("")}function l(a,c){c=0===c?0:c||10;let d=b(a).toHsl();return d.s-=c/100,d.s=B(d.s),b(d)}function m(a,c){c=0===c?0:c||10;let d=b(a).toHsl();return d.s+=c/100,d.s=B(d.s),b(d)}function n(a){return b(a).desaturate(100)}function o(a,c){c=0===c?0:c||10;let d=b(a).toHsl();return d.l+=c/100,d.l=B(d.l),b(d)}function p(a,c){c=0===c?0:c||10;let d=b(a).toRgb();return d.r=R(0,Q(255,d.r-P(255*-(c/100)))),d.g=R(0,Q(255,d.g-P(255*-(c/100)))),d.b=R(0,Q(255,d.b-P(255*-(c/100)))),b(d)}function q(a,c){c=0===c?0:c||10;let d=b(a).toHsl();return d.l-=c/100,d.l=B(d.l),b(d)}function r(a,c){let d=b(a).toHsl(),e=(d.h+c)%360;return d.h=0>e?360+e:e,b(d)}function s(a){let c=b(a).toHsl();return c.h=(c.h+180)%360,b(c)}function t(a){let c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+120)%360,s:c.s,l:c.l}),b({h:(d+240)%360,s:c.s,l:c.l})]}function u(a){let c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+90)%360,s:c.s,l:c.l}),b({h:(d+180)%360,s:c.s,l:c.l}),b({h:(d+270)%360,s:c.s,l:c.l})]}function v(a){let c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+72)%360,s:c.s,l:c.l}),b({h:(d+216)%360,s:c.s,l:c.l})]}function w(a,c,d){c=c||6,d=d||30;let e=b(a).toHsl(),f=360/d,g=[b(a)];for(e.h=(e.h-(f*c>>1)+720)%360;--c;)e.h=(e.h+f)%360,g.push(b(e));return g}function x(a,c){c=c||6;for(let d=b(a).toHsv(),e=d.h,f=d.s,g=d.v,h=[],i=1/c;c--;)h.push(b({h:e,s:f,v:g})),g=(g+i)%1;return h}function y(a){let b={};for(let c in a)a.hasOwnProperty(c)&&(b[a[c]]=c);return b}function z(a){return a=parseFloat(a),(isNaN(a)||0>a||a>1)&&(a=1),a}function A(b,c){D(b)&&(b="100%");let d=E(b);return b=Q(c,R(0,parseFloat(b))),d&&(b=parseInt(b*c,10)/100),a.abs(b-c)<1e-6?1:b%c/parseFloat(c)}function B(a){return Q(1,R(0,a))}function C(a){return parseInt(a,16)}function D(a){return"string"==typeof a&&-1!=a.indexOf(".")&&1===parseFloat(a)}function E(a){return"string"==typeof a&&-1!=a.indexOf("%")}function F(a){return 1==a.length?"0"+a:""+a}function G(a){return 1>=a&&(a=100*a+"%"),a}function H(b){return a.round(255*parseFloat(b)).toString(16)}function I(a){return C(a)/255}function J(a){return!!V.CSS_UNIT.exec(a)}function K(a){a=a.replace(M,"").replace(N,"").toLowerCase();let b=!1;if(T[a])a=T[a],b=!0;else if("transparent"==a)return{r:0,g:0,b:0,a:0,format:"name"};let c;return(c=V.rgb.exec(a))?{r:c[1],g:c[2],b:c[3]}:(c=V.rgba.exec(a))?{r:c[1],g:c[2],b:c[3],a:c[4]}:(c=V.hsl.exec(a))?{h:c[1],s:c[2],l:c[3]}:(c=V.hsla.exec(a))?{h:c[1],s:c[2],l:c[3],a:c[4]}:(c=V.hsv.exec(a))?{h:c[1],s:c[2],v:c[3]}:(c=V.hsva.exec(a))?{h:c[1],s:c[2],v:c[3],a:c[4]}:(c=V.hex8.exec(a))?{r:C(c[1]),g:C(c[2]),b:C(c[3]),a:I(c[4]),format:b?"name":"hex8"}:(c=V.hex6.exec(a))?{r:C(c[1]),g:C(c[2]),b:C(c[3]),format:b?"name":"hex"}:(c=V.hex4.exec(a))?{r:C(c[1]+""+c[1]),g:C(c[2]+""+c[2]),b:C(c[3]+""+c[3]),a:I(c[4]+""+c[4]),format:b?"name":"hex8"}:(c=V.hex3.exec(a))?{r:C(c[1]+""+c[1]),g:C(c[2]+""+c[2]),b:C(c[3]+""+c[3]),format:b?"name":"hex"}:!1}function L(a){let b,c;return a=a||{level:"AA",size:"small"},b=(a.level||"AA").toUpperCase(),c=(a.size||"small").toLowerCase(),"AA"!==b&&"AAA"!==b&&(b="AA"),"small"!==c&&"large"!==c&&(c="small"),{level:b,size:c}}let M=/^\s+/,N=/\s+$/,O=0,P=a.round,Q=a.min,R=a.max,S=a.random;b.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){let a=this.toRgb();return(299*a.r+587*a.g+114*a.b)/1e3},getLuminance:function(){let b,c,d,e,f,g,h=this.toRgb();return b=h.r/255,c=h.g/255,d=h.b/255,e=.03928>=b?b/12.92:a.pow((b+.055)/1.055,2.4),f=.03928>=c?c/12.92:a.pow((c+.055)/1.055,2.4),g=.03928>=d?d/12.92:a.pow((d+.055)/1.055,2.4),.2126*e+.7152*f+.0722*g},setAlpha:function(a){return this._a=z(a),this._roundA=P(100*this._a)/100,this},toHsv:function(){let a=g(this._r,this._g,this._b);return{h:360*a.h,s:a.s,v:a.v,a:this._a}},toHsvString:function(){let a=g(this._r,this._g,this._b),b=P(360*a.h),c=P(100*a.s),d=P(100*a.v);return 1==this._a?"hsv("+b+", "+c+"%, "+d+"%)":"hsva("+b+", "+c+"%, "+d+"%, "+this._roundA+")"},toHsl:function(){let a=e(this._r,this._g,this._b);return{h:360*a.h,s:a.s,l:a.l,a:this._a}},toHslString:function(){let a=e(this._r,this._g,this._b),b=P(360*a.h),c=P(100*a.s),d=P(100*a.l);return 1==this._a?"hsl("+b+", "+c+"%, "+d+"%)":"hsla("+b+", "+c+"%, "+d+"%, "+this._roundA+")"},toHex:function(a){return i(this._r,this._g,this._b,a)},toHexString:function(a){return"#"+this.toHex(a)},toHex8:function(a){return j(this._r,this._g,this._b,this._a,a)},toHex8String:function(a){return"#"+this.toHex8(a)},toRgb:function(){return{r:P(this._r),g:P(this._g),b:P(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+P(this._r)+", "+P(this._g)+", "+P(this._b)+")":"rgba("+P(this._r)+", "+P(this._g)+", "+P(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:P(100*A(this._r,255))+"%",g:P(100*A(this._g,255))+"%",b:P(100*A(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+P(100*A(this._r,255))+"%, "+P(100*A(this._g,255))+"%, "+P(100*A(this._b,255))+"%)":"rgba("+P(100*A(this._r,255))+"%, "+P(100*A(this._g,255))+"%, "+P(100*A(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:U[i(this._r,this._g,this._b,!0)]||!1},toFilter:function(a){let c="#"+k(this._r,this._g,this._b,this._a),d=c,e=this._gradientType?"GradientType = 1, ":"";if(a){let f=b(a);d="#"+k(f._r,f._g,f._b,f._a)}return"progid:DXImageTransform.Microsoft.gradient("+e+"startColorstr="+c+",endColorstr="+d+")"},toString:function(a){let b=!!a;a=a||this._format;let c=!1,d=this._a<1&&this._a>=0,e=!b&&d&&("hex"===a||"hex6"===a||"hex3"===a||"hex4"===a||"hex8"===a||"name"===a);return e?"name"===a&&0===this._a?this.toName():this.toRgbString():("rgb"===a&&(c=this.toRgbString()),"prgb"===a&&(c=this.toPercentageRgbString()),("hex"===a||"hex6"===a)&&(c=this.toHexString()),"hex3"===a&&(c=this.toHexString(!0)),"hex4"===a&&(c=this.toHex8String(!0)),"hex8"===a&&(c=this.toHex8String()),"name"===a&&(c=this.toName()),"hsl"===a&&(c=this.toHslString()),"hsv"===a&&(c=this.toHsvString()),c||this.toHexString())},clone:function(){return b(this.toString())},_applyModification:function(a,b){let c=a.apply(null,[this].concat([].slice.call(b)));return this._r=c._r,this._g=c._g,this._b=c._b,this.setAlpha(c._a),this},lighten:function(){return this._applyModification(o,arguments)},brighten:function(){return this._applyModification(p,arguments)},darken:function(){return this._applyModification(q,arguments)},desaturate:function(){return this._applyModification(l,arguments)},saturate:function(){return this._applyModification(m,arguments)},greyscale:function(){return this._applyModification(n,arguments)},spin:function(){return this._applyModification(r,arguments)},_applyCombination:function(a,b){return a.apply(null,[this].concat([].slice.call(b)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(s,arguments)},monochromatic:function(){return this._applyCombination(x,arguments)},splitcomplement:function(){return this._applyCombination(v,arguments)},triad:function(){return this._applyCombination(t,arguments)},tetrad:function(){return this._applyCombination(u,arguments)}},b.fromRatio=function(a,c){if("object"==typeof a){let d={};for(let e in a)a.hasOwnProperty(e)&&(d[e]="a"===e?a[e]:G(a[e]));a=d}return b(a,c)},b.equals=function(a,c){return a&&c?b(a).toRgbString()==b(c).toRgbString():!1},b.random=function(){return b.fromRatio({r:S(),g:S(),b:S()})},b.mix=function(a,c,d){d=0===d?0:d||50;let e=b(a).toRgb(),f=b(c).toRgb(),g=d/100,h={r:(f.r-e.r)*g+e.r,g:(f.g-e.g)*g+e.g,b:(f.b-e.b)*g+e.b,a:(f.a-e.a)*g+e.a};return b(h)},b.readability=function(c,d){let e=b(c),f=b(d);return(a.max(e.getLuminance(),f.getLuminance())+.05)/(a.min(e.getLuminance(),f.getLuminance())+.05)},b.isReadable=function(a,c,d){let e,f,g=b.readability(a,c);switch(f=!1,e=L(d),e.level+e.size){case"AAsmall":case"AAAlarge":f=g>=4.5;break;case"AAlarge":f=g>=3;break;case"AAAsmall":f=g>=7}return f},b.mostReadable=function(a,c,d){let e,f,g,h,i=null,j=0;d=d||{},f=d.includeFallbackColors,g=d.level,h=d.size;for(let k=0;k<c.length;k++)e=b.readability(a,c[k]),e>j&&(j=e,i=b(c[k]));return b.isReadable(a,i,{level:g,size:h})||!f?i:(d.includeFallbackColors=!1,b.mostReadable(a,["#fff","#000"],d))};let T=b.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},U=b.hexNames=y(T),V=function(){let a="[-\\+]?\\d+%?",b="[-\\+]?\\d*\\.\\d+%?",c="(?:"+b+")|(?:"+a+")",d="[\\s|\\(]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")\\s*\\)?",e="[\\s|\\(]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")\\s*\\)?";return{CSS_UNIT:new RegExp(c),rgb:new RegExp("rgb"+d),rgba:new RegExp("rgba"+e),hsl:new RegExp("hsl"+d),hsla:new RegExp("hsla"+e),hsv:new RegExp("hsv"+d),hsva:new RegExp("hsva"+e),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof module&&module.exports?module.exports=b:"function"==typeof define&&define.amd?define(function(){return b}):window.tinycolor=b}(Math);
@wilcooo
Copy link

wilcooo commented Nov 17, 2017

You are rewriting tagpro.renderer.resizeAndCenterView to update the location of the mapname. But this function is not called when "Viewport Scaling" is enabled in the TP settings. You can better replace it by tagpro.ui.alignUI, as that function is called when resizing no matter if vp scaling is enabled or not. Thanks to bash# for finding this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment