forked from FlipskiZ/BaseMod
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert CardCrawlGame patches to new patching system
- Loading branch information
1 parent
937f6d8
commit ca2e7de
Showing
10 changed files
with
154 additions
and
29 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
19 changes: 18 additions & 1 deletion
19
src/main/java/basemod/patches/com/megacrit/cardcrawl/core/CardCrawlGame/PostRenderHook.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 |
---|---|---|
@@ -1,14 +1,31 @@ | ||
package basemod.patches.com.megacrit.cardcrawl.core.CardCrawlGame; | ||
|
||
import basemod.BaseMod; | ||
import javassist.CannotCompileException; | ||
import javassist.CtBehavior; | ||
|
||
import java.util.ArrayList; | ||
|
||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.evacipated.cardcrawl.modthespire.lib.LineFinder; | ||
import com.evacipated.cardcrawl.modthespire.lib.Matcher; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpireInsertPatch; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch; | ||
import com.evacipated.cardcrawl.modthespire.patcher.PatchingException; | ||
|
||
@SpirePatch(cls="com.megacrit.cardcrawl.core.CardCrawlGame", method="render") | ||
public class PostRenderHook { | ||
@SpireInsertPatch(rloc=97, localvars={"sb"}) | ||
|
||
@SpireInsertPatch(localvars={"sb"}) | ||
public static void Insert(Object __obj_instance, SpriteBatch sb) { | ||
BaseMod.publishPostRender(sb); | ||
} | ||
|
||
public static int[] Locator(CtBehavior ctMethodToPatch) throws CannotCompileException, PatchingException { | ||
Matcher finalMatcher = new Matcher.MethodCallMatcher( | ||
SpriteBatch.class.getName(), "end"); | ||
|
||
return LineFinder.findInOrder(ctMethodToPatch, new ArrayList<Matcher>(), finalMatcher); | ||
} | ||
|
||
} |
18 changes: 17 additions & 1 deletion
18
src/main/java/basemod/patches/com/megacrit/cardcrawl/core/CardCrawlGame/PostUpdateHook.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 |
---|---|---|
@@ -1,13 +1,29 @@ | ||
package basemod.patches.com.megacrit.cardcrawl.core.CardCrawlGame; | ||
|
||
import basemod.BaseMod; | ||
import javassist.CannotCompileException; | ||
import javassist.CtBehavior; | ||
|
||
import java.util.ArrayList; | ||
|
||
import com.evacipated.cardcrawl.modthespire.lib.LineFinder; | ||
import com.evacipated.cardcrawl.modthespire.lib.Matcher; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpireInsertPatch; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch; | ||
import com.evacipated.cardcrawl.modthespire.patcher.PatchingException; | ||
import com.megacrit.cardcrawl.helpers.InputHelper; | ||
|
||
@SpirePatch(cls="com.megacrit.cardcrawl.core.CardCrawlGame", method="update") | ||
public class PostUpdateHook { | ||
@SpireInsertPatch(rloc=164) | ||
|
||
@SpireInsertPatch | ||
public static void Insert(Object __obj_instance) { | ||
BaseMod.publishPostUpdate(); | ||
} | ||
|
||
public static int[] Locator(CtBehavior ctMethodToPatch) throws CannotCompileException, PatchingException { | ||
Matcher finalMatcher = new Matcher.MethodCallMatcher(InputHelper.class.getName(), "updateLast"); | ||
|
||
return LineFinder.findInOrder(ctMethodToPatch, new ArrayList<Matcher>(), finalMatcher); | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
...main/java/basemod/patches/com/megacrit/cardcrawl/core/CardCrawlGame/PreStartGameHook.java
This file was deleted.
Oops, something went wrong.
30 changes: 28 additions & 2 deletions
30
src/main/java/basemod/patches/com/megacrit/cardcrawl/core/CardCrawlGame/PreUpdateHook.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 |
---|---|---|
@@ -1,13 +1,39 @@ | ||
package basemod.patches.com.megacrit.cardcrawl.core.CardCrawlGame; | ||
|
||
import basemod.BaseMod; | ||
import java.util.ArrayList; | ||
|
||
import com.evacipated.cardcrawl.modthespire.lib.LineFinder; | ||
import com.evacipated.cardcrawl.modthespire.lib.Matcher; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpireInsertPatch; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch; | ||
import com.evacipated.cardcrawl.modthespire.patcher.PatchingException; | ||
import com.megacrit.cardcrawl.helpers.InputHelper; | ||
|
||
import basemod.BaseMod; | ||
import javassist.CannotCompileException; | ||
import javassist.CtBehavior; | ||
|
||
@SpirePatch(cls="com.megacrit.cardcrawl.core.CardCrawlGame", method="update") | ||
public class PreUpdateHook { | ||
@SpireInsertPatch(rloc=18) | ||
@SpireInsertPatch | ||
public static void Insert(Object __obj_instance) { | ||
BaseMod.publishPreUpdate(); | ||
} | ||
|
||
private static int[] offset(int[] originalArr, int offset) { | ||
int[] resultArr = new int[originalArr.length]; | ||
for (int i = 0; i < originalArr.length; i++) { | ||
resultArr[i] = originalArr[i] + offset; | ||
} | ||
return resultArr; | ||
} | ||
|
||
public static int[] Locator(CtBehavior ctMethodToPatch) throws CannotCompileException, PatchingException { | ||
Matcher finalMatcher = new Matcher.MethodCallMatcher(InputHelper.class.getName(), "updateFirst"); | ||
|
||
int[] beforeLines = LineFinder.findInOrder(ctMethodToPatch, new ArrayList<Matcher>(), finalMatcher); | ||
|
||
// offset by 1 to be called **after** the found method call | ||
return offset(beforeLines, 1); | ||
} | ||
} |
18 changes: 17 additions & 1 deletion
18
src/main/java/basemod/patches/com/megacrit/cardcrawl/core/CardCrawlGame/RenderHook.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 |
---|---|---|
@@ -1,15 +1,31 @@ | ||
package basemod.patches.com.megacrit.cardcrawl.core.CardCrawlGame; | ||
|
||
import java.util.ArrayList; | ||
|
||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.evacipated.cardcrawl.modthespire.lib.LineFinder; | ||
import com.evacipated.cardcrawl.modthespire.lib.Matcher; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpireInsertPatch; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch; | ||
import com.evacipated.cardcrawl.modthespire.patcher.PatchingException; | ||
import com.megacrit.cardcrawl.helpers.DrawMaster; | ||
|
||
import basemod.BaseMod; | ||
import javassist.CannotCompileException; | ||
import javassist.CtBehavior; | ||
|
||
@SpirePatch(cls = "com.megacrit.cardcrawl.core.CardCrawlGame", method = "render") | ||
public class RenderHook { | ||
@SpireInsertPatch(rloc = 49, localvars = { "sb" }) | ||
|
||
@SpireInsertPatch(localvars = { "sb" }) | ||
public static void Insert(Object __obj_instance, SpriteBatch sb) { | ||
BaseMod.publishRender(sb); | ||
} | ||
|
||
public static int[] Locator(CtBehavior ctMethodToPatch) throws CannotCompileException, PatchingException { | ||
Matcher finalMatcher = new Matcher.MethodCallMatcher(DrawMaster.class.getName(), "draw"); | ||
|
||
return LineFinder.findInOrder(ctMethodToPatch, new ArrayList<Matcher>(), finalMatcher); | ||
} | ||
|
||
} |
37 changes: 35 additions & 2 deletions
37
src/main/java/basemod/patches/com/megacrit/cardcrawl/core/CardCrawlGame/StartActHook.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 |
---|---|---|
@@ -1,14 +1,47 @@ | ||
package basemod.patches.com.megacrit.cardcrawl.core.CardCrawlGame; | ||
|
||
|
||
import basemod.BaseMod; | ||
import java.util.ArrayList; | ||
|
||
import com.evacipated.cardcrawl.modthespire.lib.LineFinder; | ||
import com.evacipated.cardcrawl.modthespire.lib.Matcher; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpireInsertPatch; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch; | ||
import com.evacipated.cardcrawl.modthespire.patcher.PatchingException; | ||
import com.megacrit.cardcrawl.core.CardCrawlGame; | ||
import com.megacrit.cardcrawl.screens.DungeonTransitionScreen; | ||
|
||
import basemod.BaseMod; | ||
import javassist.CannotCompileException; | ||
import javassist.CtBehavior; | ||
|
||
@SpirePatch(cls="com.megacrit.cardcrawl.core.CardCrawlGame", method="update") | ||
public class StartActHook { | ||
@SpireInsertPatch(rloc=154) | ||
|
||
@SpireInsertPatch | ||
public static void Insert(Object __obj_instance) { | ||
if (CardCrawlGame.dungeonTransitionScreen.levelName.equals("Exordium")) { | ||
BaseMod.publishPreStartGame(); | ||
} | ||
|
||
BaseMod.publishStartAct(); | ||
} | ||
|
||
private static int[] offset(int[] originalArr, int offset) { | ||
int[] resultArr = new int[originalArr.length]; | ||
for (int i = 0; i < originalArr.length; i++) { | ||
resultArr[i] = originalArr[i] + offset; | ||
} | ||
return resultArr; | ||
} | ||
|
||
public static int[] Locator(CtBehavior ctMethodToPatch) throws CannotCompileException, PatchingException { | ||
Matcher finalMatcher = new Matcher.NewExprMatcher(DungeonTransitionScreen.class.getName()); | ||
|
||
int[] beforeLines = LineFinder.findInOrder(ctMethodToPatch, new ArrayList<Matcher>(), finalMatcher); | ||
|
||
// offset by 1 to be called **after** the found method call | ||
return offset(beforeLines, 1); | ||
} | ||
|
||
} |
19 changes: 18 additions & 1 deletion
19
src/main/java/basemod/patches/com/megacrit/cardcrawl/core/CardCrawlGame/StartGameHook.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 |
---|---|---|
@@ -1,13 +1,30 @@ | ||
package basemod.patches.com.megacrit.cardcrawl.core.CardCrawlGame; | ||
|
||
import basemod.BaseMod; | ||
import javassist.CannotCompileException; | ||
import javassist.CtBehavior; | ||
|
||
import java.util.ArrayList; | ||
|
||
import com.evacipated.cardcrawl.modthespire.lib.LineFinder; | ||
import com.evacipated.cardcrawl.modthespire.lib.Matcher; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpireInsertPatch; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch; | ||
import com.evacipated.cardcrawl.modthespire.patcher.PatchingException; | ||
import com.megacrit.cardcrawl.screens.DungeonTransitionScreen; | ||
|
||
@SpirePatch(cls="com.megacrit.cardcrawl.core.CardCrawlGame", method="startNewGame") | ||
public class StartGameHook { | ||
@SpireInsertPatch(rloc=26) | ||
|
||
@SpireInsertPatch | ||
public static void Insert(Object __obj_instance) { | ||
BaseMod.publishStartGame(); | ||
} | ||
|
||
public static int[] Locator(CtBehavior ctMethodToPatch) throws CannotCompileException, PatchingException { | ||
Matcher finalMatcher = new Matcher.NewExprMatcher(DungeonTransitionScreen.class.getName()); | ||
|
||
return LineFinder.findInOrder(ctMethodToPatch, new ArrayList<Matcher>(), finalMatcher); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=Base Mod | ||
author=t-larson, test447, FlipskiZ, Haashi, Blank The Evil, kiooeht | ||
description=Unofficial modding API for Slay the Spire | ||
mts_version=2.3.0 | ||
sts_version=03-22-2018 | ||
name=Base Mod | ||
author=t-larson, test447, FlipskiZ, Haashi, Blank The Evil, kiooeht | ||
description=Unofficial modding API for Slay the Spire | ||
mts_version=2.6.0 | ||
sts_version=03-29-2018 |
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