forked from FlipskiZ/BaseMod
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #177 whatmod purple color code not working in Chinese
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...va/basemod/patches/com/megacrit/cardcrawl/helpers/FontHelper/FixChineseNoPurpleColor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package basemod.patches.com.megacrit.cardcrawl.helpers.FontHelper; | ||
|
||
import com.badlogic.gdx.graphics.Color; | ||
import com.badlogic.gdx.graphics.g2d.BitmapFont; | ||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.evacipated.cardcrawl.modthespire.lib.*; | ||
import com.megacrit.cardcrawl.core.Settings; | ||
import com.megacrit.cardcrawl.helpers.FontHelper; | ||
import javassist.CtBehavior; | ||
|
||
@SpirePatch( | ||
clz=FontHelper.class, | ||
method="exampleNonWordWrappedText" | ||
) | ||
public class FixChineseNoPurpleColor | ||
{ | ||
@SpireInsertPatch( | ||
locator=Locator.class, | ||
localvars={"word"} | ||
) | ||
public static void Insert(SpriteBatch sb, BitmapFont font, String msg, float x, float y, Color c, float widthMax, @ByRef String[] word) | ||
{ | ||
if (word[0].charAt(1) == 'p') { | ||
word[0] = "[#" + Settings.PURPLE_COLOR.toString() + "]" + word[0].substring(2) + "[]"; | ||
} | ||
} | ||
|
||
private static class Locator extends SpireInsertLocator | ||
{ | ||
@Override | ||
public int[] Locate(CtBehavior ctBehavior) throws Exception | ||
{ | ||
Matcher matcher = new Matcher.MethodCallMatcher(String.class, "substring"); | ||
int[] found = LineFinder.findInOrder(ctBehavior, matcher); | ||
return new int[]{found[0]+1}; | ||
} | ||
} | ||
} |