diff --git a/static/geari_white.png b/assets/geari_white.png similarity index 100% rename from static/geari_white.png rename to assets/geari_white.png diff --git a/assets/players_icon.png b/assets/players_icon.png new file mode 100644 index 0000000..40a813a Binary files /dev/null and b/assets/players_icon.png differ diff --git a/build.js b/build.js index 2eec240..76e1137 100644 --- a/build.js +++ b/build.js @@ -34,6 +34,7 @@ let dictionary = {}; // this one broke in 1.91.3 /{\w+===(?\w+)\?\w+\(175," Message to "/g, /\w+\.\w+\((\w+)\)\?\w+\.\w+\(\1\)\?(\w+)=(\w+\.\w+)\(13,\[\2\]\):\(\w+=\w+\.\w+\(\1\),\2=\3\(14,\[(?\w+)\[(\w+)\],(\w+\.\w+\.\w+\()(?\w+)\[\5\]\),\6(?\w+)\[\5\]\),\2\]\),\w+=!0\):\2=/g, // this one also broke in 1.91.3 /,\w+="Player: "\+(?\w+)\[\w+\],\w+=\(\w\+=" Balance: "\+\w+\.\w+\((?\w+)\[\w+\]\)\)\+\(" Territory: "\+\w+\.\w+\((?\w+)\[\w+\]\)\)\+\(" Coords: "/g, + /\((?\w+)=Math\.floor\(\(\w+\?\.0114:\.01296\)\*\w+\)\)/g, ].forEach(expression => { result = expression.exec(script); 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 replaceOne(new RegExp(`,${dictionary.playerBalances}=new Uint32Array\\(\\w+\\),`, "g"), "$& donationsTracker.reset(), "); +{ // Player list + // Draw player list button + const { groups: { drawFunction, topBarHeight } } = replaceOne(/(=1;function (?\w+)\(\){[^}]+?(?\w+)\.fillRect\(0,(?\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 + $ - 22) / 2), $6; playerList.drawButton($, 12, 12, $ - 22);"); + const buttonBoundsCheck = `utils.isPointInRectangle($, $, ${dictionary.uiOffset} + 12, ${dictionary.uiOffset} + 12, ${topBarHeight} - 22, ${topBarHeight} - 22)` + // Handle player list button mouseDown + replaceOne(/(this\.\w+=function\((?\w+),(?\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\((?\w+),(?\w+)\){)(var \w+,\w+=\w+\(\3\);return \w+\?\(\w+=(\w+),\(\5=\w+\(0,\5\+=(?:[^}]+,(?\w+\.\w+=!0)){2})/g, + `$1 if (${buttonBoundsCheck}) { playerList.hoveringOverButton === false && (playerList.hoveringOverButton = true, ${drawFunction}(), $); } ` + + ` else { playerList.hoveringOverButton === true && (playerList.hoveringOverButton = false, ${drawFunction}(), $); } $4`); +} + // Disable built-in Territorial.io error reporting replaceOne(/window\.addEventListener\("error",function (\w+)\((\w+)\){/g, '$& window.removeEventListener("error", $1); return alert("Error:\\n" + $2.filename + " " + $2.lineno + " " + $2.colno + " " + $2.message);'); diff --git a/static/fx_core.js b/static/fx_core.js index 17d18c5..59755ad 100644 --- a/static/fx_core.js +++ b/static/fx_core.js @@ -1,5 +1,5 @@ -const fx_version = '0.6.1.7'; // FX Client Version -const fx_update = 'Mar 1'; // FX Client Last Updated +const fx_version = '0.6.1.8'; // FX Client Version +const fx_update = 'Mar 5'; // FX Client Last Updated if (localStorage.getItem("fx_winCount") == undefined || localStorage.getItem("fx_winCount") == null) { var wins_counter = 0; @@ -210,12 +210,40 @@ WindowManager.add({ 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("touchstart", WindowManager.closeAll); document.addEventListener("keydown", event => { if (event.key === "Escape") WindowManager.closeAll(); }); 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 += `${i}. ${playerNames[i]}
` + } + 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(){ this.donationHistory = Array(512); // 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) + "%"); 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: () => {} }; diff --git a/static/index.html b/static/index.html index e1f785a..2163d95 100644 --- a/static/index.html +++ b/static/index.html @@ -106,7 +106,11 @@ -