From a4cd83fff081e48a8ad2559c614642c024834bf2 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 2 Feb 2020 12:02:28 +0000 Subject: [PATCH] Fix typo in the Portuguese translation of 'loading textures' --- .../main/java/dev/openrs2/bundler/Bundler.kt | 4 +- .../bundler/transform/TypoTransformer.kt | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt diff --git a/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt b/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt index 5dfc8975..89805f06 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt @@ -13,6 +13,7 @@ import dev.openrs2.bundler.transform.PlatformDetectionTransformer import dev.openrs2.bundler.transform.PublicKeyTransformer import dev.openrs2.bundler.transform.ResourceTransformer import dev.openrs2.bundler.transform.RightClickTransformer +import dev.openrs2.bundler.transform.TypoTransformer import dev.openrs2.common.crypto.Pkcs12KeyStore import java.nio.file.Path import java.nio.file.Paths @@ -132,7 +133,8 @@ class Bundler @Inject constructor(publicKeyTransformer: PublicKeyTransformer) { MacResizeTransformer(), RightClickTransformer(), LoadLibraryTransformer(), - PlatformDetectionTransformer() + PlatformDetectionTransformer(), + TypoTransformer() ) private val unsignedManifest = Manifest() diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt new file mode 100644 index 00000000..7fd2e74b --- /dev/null +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt @@ -0,0 +1,40 @@ +package dev.openrs2.bundler.transform + +import com.github.michaelbull.logging.InlineLogger +import dev.openrs2.asm.classpath.ClassPath +import dev.openrs2.asm.classpath.Library +import dev.openrs2.asm.transform.Transformer +import org.objectweb.asm.tree.ClassNode +import org.objectweb.asm.tree.LdcInsnNode +import org.objectweb.asm.tree.MethodNode + +class TypoTransformer : Transformer() { + private var errorsFixed = 0 + + override fun preTransform(classPath: ClassPath) { + errorsFixed = 0 + } + + override fun transformCode(classPath: ClassPath, library: Library, clazz: ClassNode, method: MethodNode): Boolean { + for (insn in method.instructions) { + if (insn !is LdcInsnNode) { + continue + } + + if (insn.cst == "Carregando /secure/libs_v4s/RCras - ") { + insn.cst = "Carregando texturas - " + errorsFixed++ + } + } + + return false + } + + override fun postTransform(classPath: ClassPath) { + logger.info { "Fixed $errorsFixed typographical errors" } + } + + companion object { + private val logger = InlineLogger() + } +}