Update v0.6.3.1; Add colored density

dev
peshomir 2024-03-30 15:51:15 +02:00
parent 8d6b1f7ef8
commit 4b45939ce7
3 changed files with 10 additions and 7 deletions

Binary file not shown.

View File

@ -231,10 +231,10 @@ replaceOne(new RegExp(`,${dictionary.playerBalances}=new Uint32Array\\(\\w+\\),`
{ // Display density of other players { // Display density of other players
// Applies when the "Reverse Name/Balance" setting is off // Applies when the "Reverse Name/Balance" setting is off
const { groups: { settingsSwitchNameAndBalance } } = replaceOne(/(,(?<settingsSwitchNameAndBalance>\w+\.\w+\.\w+\[7\]\.\w+)\?(?<nameDrawingFunction>\w+)\(\w+,\w+,(?<x>\w+),(?<y>\w+)\+\.78\*(?<fontSize>\w+),(?<canvas>\w+)\)):(\7\.fillText\(\w+\.\w+\.\w+\(\w+\[(\w+)\]\),\4,\5\+\.78\*\6\))\)\)/g, const { groups: { settingsSwitchNameAndBalance } } = replaceOne(/(,(?<settingsSwitchNameAndBalance>\w+\.\w+\.\w+\[7\]\.\w+)\?(?<nameDrawingFunction>\w+)\(\w+,\w+,(?<x>\w+),(?<y>\w+)\+\.78\*(?<fontSize>\w+),(?<canvas>\w+)\)):(\7\.fillText\(\w+\.\w+\.\w+\(\w+\[(\w+)\]\),\4,\5\+\.78\*\6\))\)\)/g,
`$1 : ($8, settings.showPlayerDensity && ($<canvas>.fillStyle = utils.textStyleBasedOnDensity(utils.getDensity($9)), $<canvas>.fillText(utils.getDensity($9), $<x>, $<y> + $<fontSize> * 1.5) ) ) )`); `$1 : ($8, settings.showPlayerDensity && (settings.coloredDensity && ($<canvas>.fillStyle = utils.textStyleBasedOnDensity($9)), $<canvas>.fillText(utils.getDensity($9), $<x>, $<y> + $<fontSize> * 1.5)) ) ) )`);
// Applies when the "Reverse Name/Balance" setting is on (default) // Applies when the "Reverse Name/Balance" setting is on (default)
replaceOne(/(function \w+\((\w+),(?<fontSize>\w+),(?<x>\w+),(?<y>\w+),(?<canvas>\w+)\){\6\.fillText\((?<playerNames>\w+)\[\2\],\4,\5\)),(\2<(?<gHumans>\w+)&&2!==(?<playerStates>\w+)\[)/g, replaceOne(/(function \w+\((\w+),(?<fontSize>\w+),(?<x>\w+),(?<y>\w+),(?<canvas>\w+)\){)(\6\.fillText\((?<playerNames>\w+)\[\2\],\4,\5\)),(\2<(?<gHumans>\w+)&&2!==(?<playerStates>\w+)\[[^}]+)}/g,
`$1, ${settingsSwitchNameAndBalance} && settings.showPlayerDensity && $<canvas>.fillText(utils.getDensity($2)), $<x>, $<y> + $<fontSize>), $8`); `$1 var ___id = $2; $7, $9; ${settingsSwitchNameAndBalance} && settings.showPlayerDensity && (settings.coloredDensity && ($<canvas>.fillStyle = utils.textStyleBasedOnDensity(___id)), $<canvas>.fillText(utils.getDensity(___id), $<x>, $<y> + $<fontSize>)); }`);
} }
// Disable built-in Territorial.io error reporting // Disable built-in Territorial.io error reporting

View File

@ -1,5 +1,5 @@
const fx_version = '0.6.3'; // FX Client Version const fx_version = '0.6.3.1'; // FX Client Version
const fx_update = 'Mar 26'; // FX Client Last Updated const fx_update = 'Mar 30'; // FX Client Last Updated
if (localStorage.getItem("fx_winCount") == undefined || localStorage.getItem("fx_winCount") == null) { if (localStorage.getItem("fx_winCount") == undefined || localStorage.getItem("fx_winCount") == null) {
var wins_counter = 0; var wins_counter = 0;
@ -107,6 +107,7 @@ var settings = {
//"hideAllLinks": false, //"hideAllLinks": false,
"realisticNames": false, "realisticNames": false,
"showPlayerDensity": true, "showPlayerDensity": true,
"coloredDensity": true,
"densityDisplayStyle": "percentage", "densityDisplayStyle": "percentage",
//"customMapFileBtn": true //"customMapFileBtn": true
"customBackgroundUrl": "", "customBackgroundUrl": "",
@ -123,6 +124,7 @@ var settingsManager = new (function() {
//{ for: "hideAllLinks", type: "checkbox", label: "Hide Links option also hides app store links" }, //{ for: "hideAllLinks", type: "checkbox", label: "Hide Links option also hides app store links" },
{ for: "realisticNames", type: "checkbox", label: "Realistic Bot Names" }, { for: "realisticNames", type: "checkbox", label: "Realistic Bot Names" },
{ for: "showPlayerDensity", type: "checkbox", label: "Show player density" }, { for: "showPlayerDensity", type: "checkbox", label: "Show player density" },
{ for: "coloredDensity", type: "checkbox", label: "Colored density", note: "Display the density with a color between red and green depending on the density value" },
{ for: "densityDisplayStyle", type: "selectMenu", label: "Density value display style:", tooltip: "Controls how the territorial density value should be rendered", options: [ { for: "densityDisplayStyle", type: "selectMenu", label: "Density value display style:", tooltip: "Controls how the territorial density value should be rendered", options: [
{ value: "percentage", label: "Percentage" }, { value: "percentage", label: "Percentage" },
{ value: "absoluteQuotient", label: "Value from 0 to 150 (BetterTT style)" } { value: "absoluteQuotient", label: "Value from 0 to 150 (BetterTT style)" }
@ -378,8 +380,9 @@ var utils = new (function() {
const lineHeight = parseInt(canvas.font.split(" ").find(part => part.endsWith("px")).slice(0, -2)); const lineHeight = parseInt(canvas.font.split(" ").find(part => part.endsWith("px")).slice(0, -2));
text.split("\n").forEach((line, index) => canvas.fillText(line, x, y + index * lineHeight, maxWidth)); text.split("\n").forEach((line, index) => canvas.fillText(line, x, y + index * lineHeight, maxWidth));
} }
this.textStyleBasedOnDensity = function(density) { this.textStyleBasedOnDensity = function(playerID) {
retrun `hsl(${Math.floor(density.substr(0,3)).toFixed(0)}, 100%, 50%, 1)`; const playerBalances = getVar("playerBalances"), playerTerritories = getVar("playerTerritories");
return `hsl(${playerBalances[playerID] / (playerTerritories[playerID] * 1.5)}, 100%, 50%, 1)`;
} }
}); });