Update v0.6.1.8; Add a player list
parent
8895016b45
commit
bdde9e5ad5
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
15
build.js
15
build.js
|
@ -34,6 +34,7 @@ let dictionary = {};
|
||||||
// this one broke in 1.91.3 /{\w+===(?<playerId>\w+)\?\w+\(175," Message to "/g,
|
// this one broke in 1.91.3 /{\w+===(?<playerId>\w+)\?\w+\(175," Message to "/g,
|
||||||
/\w+\.\w+\((\w+)\)\?\w+\.\w+\(\1\)\?(\w+)=(\w+\.\w+)\(13,\[\2\]\):\(\w+=\w+\.\w+\(\1\),\2=\3\(14,\[(?<playerNames>\w+)\[(\w+)\],(\w+\.\w+\.\w+\()(?<playerBalances>\w+)\[\5\]\),\6(?<playerTerritories>\w+)\[\5\]\),\2\]\),\w+=!0\):\2=/g,
|
/\w+\.\w+\((\w+)\)\?\w+\.\w+\(\1\)\?(\w+)=(\w+\.\w+)\(13,\[\2\]\):\(\w+=\w+\.\w+\(\1\),\2=\3\(14,\[(?<playerNames>\w+)\[(\w+)\],(\w+\.\w+\.\w+\()(?<playerBalances>\w+)\[\5\]\),\6(?<playerTerritories>\w+)\[\5\]\),\2\]\),\w+=!0\):\2=/g,
|
||||||
// this one also broke in 1.91.3 /,\w+="Player: "\+(?<playerNames>\w+)\[\w+\],\w+=\(\w\+=" Balance: "\+\w+\.\w+\((?<playerBalances>\w+)\[\w+\]\)\)\+\(" Territory: "\+\w+\.\w+\((?<playerTerritories>\w+)\[\w+\]\)\)\+\(" Coords: "/g,
|
// this one also broke in 1.91.3 /,\w+="Player: "\+(?<playerNames>\w+)\[\w+\],\w+=\(\w\+=" Balance: "\+\w+\.\w+\((?<playerBalances>\w+)\[\w+\]\)\)\+\(" Territory: "\+\w+\.\w+\((?<playerTerritories>\w+)\[\w+\]\)\)\+\(" Coords: "/g,
|
||||||
|
/\((?<uiOffset>\w+)=Math\.floor\(\(\w+\?\.0114:\.01296\)\*\w+\)\)/g,
|
||||||
].forEach(expression => {
|
].forEach(expression => {
|
||||||
result = expression.exec(script);
|
result = expression.exec(script);
|
||||||
if (result === null) throw new Error("no match for ") + expression;
|
if (result === null) throw new Error("no match for ") + expression;
|
||||||
|
@ -142,6 +143,20 @@ replaceOne(/,(0!==\w+\[(\w+)\]\)&&\w+\.\w+\(\2,800,!1,0\),)/g,
|
||||||
// Reset donation history when a new game is started
|
// Reset donation history when a new game is started
|
||||||
replaceOne(new RegExp(`,${dictionary.playerBalances}=new Uint32Array\\(\\w+\\),`, "g"), "$& donationsTracker.reset(), ");
|
replaceOne(new RegExp(`,${dictionary.playerBalances}=new Uint32Array\\(\\w+\\),`, "g"), "$& donationsTracker.reset(), ");
|
||||||
|
|
||||||
|
{ // Player list
|
||||||
|
// Draw player list button
|
||||||
|
const { groups: { drawFunction, topBarHeight } } = replaceOne(/(=1;function (?<drawFunction>\w+)\(\){[^}]+?(?<canvas>\w+)\.fillRect\(0,(?<topBarHeight>\w+),\w+,1\),(?:\3\.fillRect\([^()]+\),)+\3\.font=\w+,\3\.textBaseline=\w+,\3\.textAlign=\w+,\3\.fillText\(\w+,Math\.floor\()(\w+)\/2\),(Math\.floor\(\w+\+\w+\/2\)\));/g,
|
||||||
|
"$1($5 + $<topBarHeight> - 22) / 2), $6; playerList.drawButton($<canvas>, 12, 12, $<topBarHeight> - 22);");
|
||||||
|
const buttonBoundsCheck = `utils.isPointInRectangle($<x>, $<y>, ${dictionary.uiOffset} + 12, ${dictionary.uiOffset} + 12, ${topBarHeight} - 22, ${topBarHeight} - 22)`
|
||||||
|
// Handle player list button mouseDown
|
||||||
|
replaceOne(/(this\.\w+=function\((?<x>\w+),(?<y>\w+)\){return!!\w+\(\2,\3\))&&(\(\w+=\w+\.\w+,)/g,
|
||||||
|
`$1 && (${buttonBoundsCheck} && playerList.display(${dictionary.playerNames}), true) && $4`);
|
||||||
|
// Handle player list button hover
|
||||||
|
replaceOne(/(this\.\w+=function\((?<x>\w+),(?<y>\w+)\){)(var \w+,\w+=\w+\(\3\);return \w+\?\(\w+=(\w+),\(\5=\w+\(0,\5\+=(?:[^}]+,(?<setRepaintNeeded>\w+\.\w+=!0)){2})/g,
|
||||||
|
`$1 if (${buttonBoundsCheck}) { playerList.hoveringOverButton === false && (playerList.hoveringOverButton = true, ${drawFunction}(), $<setRepaintNeeded>); } `
|
||||||
|
+ ` else { playerList.hoveringOverButton === true && (playerList.hoveringOverButton = false, ${drawFunction}(), $<setRepaintNeeded>); } $4`);
|
||||||
|
}
|
||||||
|
|
||||||
// Disable built-in Territorial.io error reporting
|
// Disable built-in Territorial.io error reporting
|
||||||
replaceOne(/window\.addEventListener\("error",function (\w+)\((\w+)\){/g,
|
replaceOne(/window\.addEventListener\("error",function (\w+)\((\w+)\){/g,
|
||||||
'$& window.removeEventListener("error", $1); return alert("Error:\\n" + $2.filename + " " + $2.lineno + " " + $2.colno + " " + $2.message);');
|
'$& window.removeEventListener("error", $1); return alert("Error:\\n" + $2.filename + " " + $2.lineno + " " + $2.colno + " " + $2.message);');
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const fx_version = '0.6.1.7'; // FX Client Version
|
const fx_version = '0.6.1.8'; // FX Client Version
|
||||||
const fx_update = 'Mar 1'; // FX Client Last Updated
|
const fx_update = 'Mar 5'; // 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;
|
||||||
|
@ -210,12 +210,40 @@ WindowManager.add({
|
||||||
document.getElementById("donationhistory_note").style.display = ((true || settings.showBotDonations || /*getVarByName("dt")*/ isSingleplayer) ? "none" : "block");
|
document.getElementById("donationhistory_note").style.display = ((true || settings.showBotDonations || /*getVarByName("dt")*/ isSingleplayer) ? "none" : "block");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
WindowManager.add({
|
||||||
|
name: "playerList",
|
||||||
|
element: document.getElementById("playerlist"),
|
||||||
|
beforeOpen: function() {}
|
||||||
|
});
|
||||||
document.getElementById("canvasA").addEventListener("mousedown", WindowManager.closeAll);
|
document.getElementById("canvasA").addEventListener("mousedown", WindowManager.closeAll);
|
||||||
document.getElementById("canvasA").addEventListener("touchstart", WindowManager.closeAll);
|
document.getElementById("canvasA").addEventListener("touchstart", WindowManager.closeAll);
|
||||||
document.addEventListener("keydown", event => { if (event.key === "Escape") WindowManager.closeAll(); });
|
document.addEventListener("keydown", event => { if (event.key === "Escape") WindowManager.closeAll(); });
|
||||||
var settingsGearIcon = document.createElement('img');
|
var settingsGearIcon = document.createElement('img');
|
||||||
settingsGearIcon.setAttribute('src', 'geari_white.png');
|
settingsGearIcon.setAttribute('src', 'assets/geari_white.png');
|
||||||
|
|
||||||
|
const playerList = new (function () {
|
||||||
|
const playersIcon = document.createElement('img');
|
||||||
|
playersIcon.setAttribute('src', 'assets/players_icon.png');
|
||||||
|
this.display = function displayPlayerList(playerNames) {
|
||||||
|
let listContent = "";
|
||||||
|
for (let i = 0; i < playerNames.length; i++) {
|
||||||
|
listContent += `<span class="color-light-gray">${i}.</span> ${playerNames[i]}<br>`
|
||||||
|
}
|
||||||
|
document.getElementById("playerlist_text").innerHTML = listContent;
|
||||||
|
WindowManager.openWindow("playerList");
|
||||||
|
}
|
||||||
|
this.hoveringOverButton = false;
|
||||||
|
this.drawButton = (canvas, x, y, size) => {
|
||||||
|
canvas.fillRect(x, y, size, size);
|
||||||
|
canvas.fillStyle = this.hoveringOverButton ? "#aaaaaaaa" : "#000000aa";
|
||||||
|
canvas.clearRect(x + 1, y + 1, size - 2, size - 2);
|
||||||
|
canvas.fillRect(x + 1, y + 1, size - 2, size - 2);
|
||||||
|
canvas.fillStyle = "#ffffff";
|
||||||
|
canvas.imageSmoothingEnabled = true;
|
||||||
|
canvas.drawImage(playersIcon, x + 2, y + 2, size - 4, size - 4);
|
||||||
|
canvas.imageSmoothingEnabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
var donationsTracker = new (function(){
|
var donationsTracker = new (function(){
|
||||||
this.donationHistory = Array(512);
|
this.donationHistory = Array(512);
|
||||||
// fill the array with empty arrays with length of 3
|
// fill the array with empty arrays with length of 3
|
||||||
|
@ -257,6 +285,9 @@ var utils = new (function() {
|
||||||
if (settings.densityDisplayStyle === "percentage") return (((playerBalances[playerID] / ((playerTerritories[playerID] === 0 ? 1 : playerTerritories[playerID]) * 150)) * 100).toFixed(1) + "%");
|
if (settings.densityDisplayStyle === "percentage") return (((playerBalances[playerID] / ((playerTerritories[playerID] === 0 ? 1 : playerTerritories[playerID]) * 150)) * 100).toFixed(1) + "%");
|
||||||
else return (playerBalances[playerID] / (playerTerritories[playerID] === 0 ? 1 : playerTerritories[playerID])).toFixed(1);
|
else return (playerBalances[playerID] / (playerTerritories[playerID] === 0 ? 1 : playerTerritories[playerID])).toFixed(1);
|
||||||
};
|
};
|
||||||
|
this.isPointInRectangle = function(x, y, rectangleStartX, rectangleStartY, width, height) {
|
||||||
|
return x >= rectangleStartX && x <= rectangleStartX + width && y >= rectangleStartY && y <= rectangleStartY + height;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const keybindFunctions = { setAbsolute: () => {}, setRelative: () => {} };
|
const keybindFunctions = { setAbsolute: () => {}, setRelative: () => {} };
|
||||||
|
|
|
@ -106,7 +106,11 @@
|
||||||
<button onclick="settingsManager.save()">Save Settings</button>
|
<button onclick="settingsManager.save()">Save Settings</button>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<div class="window scrollable" id="donationhistory" style="display:none">
|
<div class="window scrollable selectable" id="playerlist" style="display: none;">
|
||||||
|
<h1>Player List</h1>
|
||||||
|
<p id="playerlist_text"></p>
|
||||||
|
</div>
|
||||||
|
<div class="window scrollable selectable" id="donationhistory" style="display:none">
|
||||||
<h1>Donation history for </h1>
|
<h1>Donation history for </h1>
|
||||||
<p id="donationhistory_note">Note: donations from bots are not shown here</p>
|
<p id="donationhistory_note">Note: donations from bots are not shown here</p>
|
||||||
<p id="donationhistory_text"></p>
|
<p id="donationhistory_text"></p>
|
||||||
|
|
|
@ -84,7 +84,7 @@ input#inputfilebtn {
|
||||||
transition: 0.2s
|
transition: 0.2s
|
||||||
}
|
}
|
||||||
|
|
||||||
.window#donationhistory {
|
.selectable {
|
||||||
user-select: text;
|
user-select: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue