mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-12 16:09:16 +02:00
Use findAndParseParams() in "gameCardCustomIcons" patch
This commit is contained in:
@@ -111,7 +111,7 @@ export class PatcherUtils {
|
||||
return str;
|
||||
}
|
||||
|
||||
static parseParams(str: string, index: number, maxRange: number) {
|
||||
static findAndParseParams(str: string, index: number, maxRange: number) {
|
||||
const substr = str.substring(index, index + maxRange);
|
||||
let startIndex = substr.indexOf('({');
|
||||
if (startIndex < 0) {
|
||||
@@ -127,6 +127,14 @@ export class PatcherUtils {
|
||||
|
||||
try {
|
||||
const input = substr.substring(startIndex, endIndex);
|
||||
return PatcherUtils.parseObjectVariables(input);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static parseObjectVariables(input: string) {
|
||||
try {
|
||||
const pairs = [...input.matchAll(/(\w+)\s*:\s*([a-zA-Z_$][\w$]*)/g)];
|
||||
|
||||
const result: Record<string, string> = {};
|
||||
|
@@ -399,7 +399,7 @@ if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFak
|
||||
}
|
||||
|
||||
try {
|
||||
const params = PatcherUtils.parseParams(str, index, 1000);
|
||||
const params = PatcherUtils.findAndParseParams(str, index, 1000);
|
||||
if (!params) {
|
||||
return false;
|
||||
}
|
||||
@@ -778,7 +778,7 @@ true` + text;
|
||||
return false;
|
||||
}
|
||||
|
||||
const params = PatcherUtils.parseParams(str, index - 500, 500);
|
||||
const params = PatcherUtils.findAndParseParams(str, index - 500, 500);
|
||||
if (!params || !params.id) {
|
||||
return false;
|
||||
}
|
||||
@@ -1030,12 +1030,16 @@ ${subsVar} = subs;
|
||||
return false;
|
||||
}
|
||||
|
||||
const productIdVar = PatcherUtils.getVariableNameAfter(str, productIdIndex + 11);
|
||||
const params = PatcherUtils.findAndParseParams(str, productIdIndex - 200, 400);
|
||||
if (!params || !params.productId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const productIdVar = params.productId;
|
||||
|
||||
// Find supportedInputIcons and title var names
|
||||
const supportedInputIconsVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, 'supportedInputIcons:', initialIndex, 100, true));
|
||||
|
||||
if (!productIdVar || !supportedInputIconsVar) {
|
||||
if (!supportedInputIconsVar) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user