Compare commits
4 Commits
401499fa0e
...
73ce8d88bb
Author | SHA1 | Date |
---|---|---|
|
73ce8d88bb | |
|
c26a11fba7 | |
|
77fea785f1 | |
|
594baa7546 |
14
build.js
14
build.js
|
@ -62,6 +62,19 @@ async function patchGameCode() {
|
||||||
|
|
||||||
const modUtils = new ModUtils(minifyCode(script));
|
const modUtils = new ModUtils(minifyCode(script));
|
||||||
|
|
||||||
|
/** @type {{ code: string, addToDictionary: string[] }[]} */
|
||||||
|
const codeSegments = [{
|
||||||
|
code: `player = aQ.eF(eR);
|
||||||
|
if (game.gIsReplay) { game.playerId = player; }
|
||||||
|
str = L(58, /* Player: {0} */ [b0.context.truncateAndFillText(playerData.rawPlayerNames[player], b0.qZ.sN(0, 10), 150)]) + " ";
|
||||||
|
str += L(59, /* Strength: {10} */ [b0.rY.formatNumber(playerData.playerBalances[player])]) + " ";
|
||||||
|
str += L(60, /* Territory: {10} */ [b0.rY.formatNumber(playerData.playerTerritories[player])]) + " ";
|
||||||
|
`, addToDictionary: ["game", "gIsReplay", "playerData", "rawPlayerNames", "playerBalances", "playerTerritories"]
|
||||||
|
}];
|
||||||
|
codeSegments.forEach(({ code, addToDictionary }) => {
|
||||||
|
modUtils.matchCode(code, { addToDictionary })
|
||||||
|
});
|
||||||
|
|
||||||
const { default: applyPatches } = await import('./patches/main.js');
|
const { default: applyPatches } = await import('./patches/main.js');
|
||||||
console.log("Applying patches...");
|
console.log("Applying patches...");
|
||||||
applyPatches(modUtils);
|
applyPatches(modUtils);
|
||||||
|
@ -93,7 +106,6 @@ async function patchGameCode() {
|
||||||
].forEach(matchDictionaryExpression);
|
].forEach(matchDictionaryExpression);
|
||||||
|
|
||||||
const rawCodeSegments = [
|
const rawCodeSegments = [
|
||||||
`aQ.eI(e0)?aQ.eE(e0)?a38=__L([a38]):(player=aQ.eF(e0),oq=__L([b0.uS.zG(@playerData.@rawPlayerNames[player],b0.p9.qQ(0,10),150)])+" ",oq=(oq+=__L([b0.wx.a07(playerData.@playerBalances[player])])+" ")+__L([b0.wx.a07(playerData.@playerTerritories[player])])+" ",`,
|
|
||||||
"1===a.b?this.@gLobbyMaxJoin=this.@gHumans:this.gLobbyMaxJoin=this.@data.@playerCount,this.tZ=this.gLobbyMaxJoin,this.@gBots=this.gLobbyMaxJoin-this.gHumans,this.sg=0,",
|
"1===a.b?this.@gLobbyMaxJoin=this.@gHumans:this.gLobbyMaxJoin=this.@data.@playerCount,this.tZ=this.gLobbyMaxJoin,this.@gBots=this.gLobbyMaxJoin-this.gHumans,this.sg=0,",
|
||||||
"[0]=__L(),@strs[1]=@game.@gIsSingleplayer?__L():__L(),",
|
"[0]=__L(),@strs[1]=@game.@gIsSingleplayer?__L():__L(),",
|
||||||
"?(this.gB=Math.floor(.066*aK.fw),g5=aK.g5-4*@uiSizes.@gap-this.gB):",
|
"?(this.gB=Math.floor(.066*aK.fw),g5=aK.g5-4*@uiSizes.@gap-this.gB):",
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
import ModUtils from "../modUtils.js"
|
||||||
|
|
||||||
|
export default (/** @type {ModUtils} */ { insertCode, replaceRawCode, waitForMinification }) => {
|
||||||
|
|
||||||
|
insertCode(`/* here */
|
||||||
|
this.click = function(lK, lL, a1m) {
|
||||||
|
var gy = bL.gz(lK);
|
||||||
|
var h0 = bL.h1(lL);
|
||||||
|
var eV = bL.f7(gy, h0);
|
||||||
|
var eN = bL.eZ(eV);
|
||||||
|
if (!bL.isInMapBounds(gy, h0)) { return false; }
|
||||||
|
var a5C = (Device.a1.largeUIEnabled() ? 0.025 : 0.0144) * h___.hu;
|
||||||
|
var dp = performance.now();
|
||||||
|
if (Math.abs(lK - a4t) > a5C || Math.abs(lL - a4u) > a5C || dp > time + 500) { return false; }
|
||||||
|
time = dp;
|
||||||
|
if (a1m) { a5D(lK, lL, eN); return false; }
|
||||||
|
/*...*/}`,
|
||||||
|
`__fx.hoveringTooltip.display = function(mouseX, mouseY) {
|
||||||
|
var coordX = bL.gz(mouseX), coordY = bL.h1(mouseY),
|
||||||
|
coord = bL.f7(coordX, coordY), point = bL.eZ(coord);
|
||||||
|
// if (coordX < 0 || coordY < 0) return;
|
||||||
|
if (bL.isInMapBounds(coordX, coordY)) (function(lK, lL, eN) {
|
||||||
|
a5D(lK, lL, eN)
|
||||||
|
}(mouseX, mouseY, point))
|
||||||
|
}`)
|
||||||
|
insertCode(`player = aQ.eF(eR);
|
||||||
|
if (game.gIsReplay /* here */) { game.playerId = player; }
|
||||||
|
str = L(58, /* Player: {0} */ [b0.context.truncateAndFillText(playerData.rawPlayerNames[player], b0.qZ.sN(0, 10), 150)]) + " ";
|
||||||
|
str += L(59, /* Strength: {10} */ [b0.rY.formatNumber(playerData.playerBalances[player])]) + " ";
|
||||||
|
str += L(60, /* Territory: {10} */ [b0.rY.formatNumber(playerData.playerTerritories[player])]) + " ";`,
|
||||||
|
`&& __fx.hoveringTooltip.active === false`)
|
||||||
|
|
||||||
|
waitForMinification(() => {
|
||||||
|
replaceRawCode("aK.nH=(window.devicePixelRatio||1)*aEr,",
|
||||||
|
`aK.nH = (window.devicePixelRatio || 1) * aEr, __fx.hoveringTooltip.canvasPixelScale = aK.nH,`)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
|
@ -11,29 +11,6 @@ export default (/** @type {ModUtils} */ modUtils) => {
|
||||||
return alert("Error:\\n" + e.filename + " " + e.lineno + " " + e.colno + " " + e.message);`
|
return alert("Error:\\n" + e.filename + " " + e.lineno + " " + e.colno + " " + e.message);`
|
||||||
)
|
)
|
||||||
|
|
||||||
// Hovering tooltip
|
|
||||||
modUtils.insertCode(`/* here */
|
|
||||||
this.click = function(lK, lL, a1m) {
|
|
||||||
var gy = bL.gz(lK);
|
|
||||||
var h0 = bL.h1(lL);
|
|
||||||
var eV = bL.f7(gy, h0);
|
|
||||||
var eN = bL.eZ(eV);
|
|
||||||
if (!bL.isInMapBounds(gy, h0)) { return false; }
|
|
||||||
var a5C = (Device.a1.largeUIEnabled() ? 0.025 : 0.0144) * h___.hu;
|
|
||||||
var dp = performance.now();
|
|
||||||
if (Math.abs(lK - a4t) > a5C || Math.abs(lL - a4u) > a5C || dp > time + 500) { return false; }
|
|
||||||
time = dp;
|
|
||||||
if (a1m) { a5D(lK, lL, eN); return false; }
|
|
||||||
/*...*/}`,
|
|
||||||
`__fx.hoveringTooltip.display = function(mouseX, mouseY) {
|
|
||||||
var coordX = bL.gz(mouseX), coordY = bL.h1(mouseY),
|
|
||||||
coord = bL.f7(coordX, coordY), point = bL.eZ(coord);
|
|
||||||
// if (coordX < 0 || coordY < 0) return;
|
|
||||||
if (bL.isInMapBounds(coordX, coordY)) (function(lK, lL, eN) {
|
|
||||||
a5D(lK, lL, eN)
|
|
||||||
}(mouseX, mouseY, point))
|
|
||||||
}`)
|
|
||||||
|
|
||||||
modUtils.waitForMinification(() => applyPatches(modUtils))
|
modUtils.waitForMinification(() => applyPatches(modUtils))
|
||||||
}
|
}
|
||||||
//export const requiredVariables = ["game", "playerId", "playerData", "rawPlayerNames", "gIsSingleplayer", "playerTerritories"];
|
//export const requiredVariables = ["game", "playerId", "playerData", "rawPlayerNames", "gIsSingleplayer", "playerTerritories"];
|
||||||
|
@ -309,11 +286,6 @@ canvas.font=aY.g0.g1(1,fontSize),canvas.fillStyle="rgba("+gR+","+tD+","+hj+",0.6
|
||||||
`this.uI=function(username){var uK,uJ=username.indexOf("[");return!(uJ<0)&&1<(uK=username.indexOf("]"))-uJ&&uK-uJ<=8?username.substring(uJ+1,uK).toUpperCase().trim():null}, __fx.leaderboardFilter.parseClanFromPlayerName = this.uI;`);
|
`this.uI=function(username){var uK,uJ=username.indexOf("[");return!(uJ<0)&&1<(uK=username.indexOf("]"))-uJ&&uK-uJ<=8?username.substring(uJ+1,uK).toUpperCase().trim():null}, __fx.leaderboardFilter.parseClanFromPlayerName = this.uI;`);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Hovering tooltip
|
|
||||||
replaceRawCode("aK.nH=(window.devicePixelRatio||1)*aEr,",
|
|
||||||
`aK.nH = (window.devicePixelRatio || 1) * aEr, __fx.hoveringTooltip.canvasPixelScale = aK.nH,`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detailed team pie chart percentage
|
// Detailed team pie chart percentage
|
||||||
replaceRawCode(`qr=Math.floor(100*f0+.5)+"%"`,
|
replaceRawCode(`qr=Math.floor(100*f0+.5)+"%"`,
|
||||||
`qr = (__fx.settings.detailedTeamPercentage ? (100*f0).toFixed(2) : Math.floor(100*f0+.5)) + "%"`)
|
`qr = (__fx.settings.detailedTeamPercentage ? (100*f0).toFixed(2) : Math.floor(100*f0+.5)) + "%"`)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { getVar } from "./gameInterface.js";
|
||||||
const hoveringTooltip = new (function() {
|
const hoveringTooltip = new (function() {
|
||||||
let recentlyShown = false;
|
let recentlyShown = false;
|
||||||
this.display = () => {}; // this gets populated by the modified game script
|
this.display = () => {}; // this gets populated by the modified game script
|
||||||
|
this.active = false;
|
||||||
this.canvasPixelScale = 1;
|
this.canvasPixelScale = 1;
|
||||||
function handler(e) {
|
function handler(e) {
|
||||||
if (!getSettings().hoveringTooltip || !getVar("gameState") || recentlyShown) return;
|
if (!getSettings().hoveringTooltip || !getVar("gameState") || recentlyShown) return;
|
||||||
|
@ -21,7 +22,9 @@ const hoveringTooltip = new (function() {
|
||||||
|
|
||||||
recentlyShown = true;
|
recentlyShown = true;
|
||||||
try {
|
try {
|
||||||
|
this.active = true;
|
||||||
this.display(this.canvasPixelScale * x, this.canvasPixelScale * y);
|
this.display(this.canvasPixelScale * x, this.canvasPixelScale * y);
|
||||||
|
this.active = false;
|
||||||
} catch (e) { console.error(e) }
|
} catch (e) { console.error(e) }
|
||||||
// for better performance, reduce the tooltip display frequency to no more than once every 100 ms
|
// for better performance, reduce the tooltip display frequency to no more than once every 100 ms
|
||||||
setTimeout(() => recentlyShown = false, 100);
|
setTimeout(() => recentlyShown = false, 100);
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"version": "0.6.12",
|
"version": "0.6.13",
|
||||||
"lastUpdated": "Jul 15",
|
"lastUpdated": "Jul 22",
|
||||||
"changes": [
|
"changes": [
|
||||||
"Refactored the service worker code to (hopefully) fix a ton of relatively rare errors related to how the client's files are loaded (for example, code from earlier versions would sometimes be loaded along with code from newer versions, causing all kinds of issues). FX Client should be much more stable after this change."
|
"Fix for game update 2.09.9",
|
||||||
|
"Fix to prevent the hovering tooltip from causing perspective switching during replays (a new feature was added to the base game where, in replays, you can switch to a different player/bot by right clicking on them)"
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Reference in New Issue