forked from SkyeStarfall/BaseMod
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
309 additions
and
117 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
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
31 changes: 31 additions & 0 deletions
31
src/main/java/basemod/patches/com/megacrit/cardcrawl/cards/CardGroup/ModalExhaustFix.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,31 @@ | ||
package basemod.patches.com.megacrit.cardcrawl.cards.CardGroup; | ||
|
||
import basemod.BaseMod; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch; | ||
import com.megacrit.cardcrawl.cards.AbstractCard; | ||
import com.megacrit.cardcrawl.cards.CardGroup; | ||
import javassist.CannotCompileException; | ||
import javassist.CtBehavior; | ||
|
||
@SpirePatch( | ||
cls="com.megacrit.cardcrawl.cards.CardGroup", | ||
method="moveToExhaustPile" | ||
) | ||
public class ModalExhaustFix | ||
{ | ||
public static void Raw(CtBehavior ctMethodToPatch) throws CannotCompileException | ||
{ | ||
String src = | ||
"if (basemod.BaseMod.modalChoiceScreen.isOpen) {" + | ||
"basemod.patches.com.megacrit.cardcrawl.cards.CardGroup.ModalExhaustFix.Nested.Delay($0, $1);" + | ||
"return;" + | ||
"}"; | ||
ctMethodToPatch.insertBefore(src); | ||
} | ||
|
||
public static class Nested { | ||
public static void Delay(CardGroup __instance, AbstractCard card) { | ||
BaseMod.modalChoiceScreen.delayExhaust(__instance, card); | ||
} | ||
} | ||
} |
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
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
222 changes: 111 additions & 111 deletions
222
...Menu/CardLibraryScreen/EverythingFix.java → ...dium/CardLibraryScreen/EverythingFix.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,112 +1,112 @@ | ||
package basemod.patches.com.megacrit.cardcrawl.screens.mainMenu.CardLibraryScreen; | ||
|
||
import basemod.patches.com.megacrit.cardcrawl.screens.mainMenu.ColorTabBar.ColorTabBarFix; | ||
import com.evacipated.cardcrawl.modthespire.lib.*; | ||
import com.evacipated.cardcrawl.modthespire.patcher.PatchingException; | ||
import com.megacrit.cardcrawl.cards.AbstractCard; | ||
import com.megacrit.cardcrawl.cards.CardGroup; | ||
import com.megacrit.cardcrawl.helpers.CardLibrary; | ||
import com.megacrit.cardcrawl.screens.mainMenu.CardLibraryScreen; | ||
import com.megacrit.cardcrawl.screens.mainMenu.ColorTabBar; | ||
import javassist.CannotCompileException; | ||
import javassist.CtBehavior; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* | ||
* @author kioeeht from branch custom-content on ModTheSpire | ||
* https://github.com/kiooeht/ModTheSpire/tree/custom-content | ||
* | ||
*/ | ||
public class EverythingFix | ||
{ | ||
public static class Fields | ||
{ | ||
public static Map<AbstractCard.CardColor, CardGroup> cardGroupMap = new HashMap<>(); | ||
} | ||
|
||
@SpirePatch( | ||
cls="com.megacrit.cardcrawl.screens.mainMenu.CardLibraryScreen", | ||
method="initialize" | ||
) | ||
public static class Initialize | ||
{ | ||
@SpireInsertPatch | ||
public static void Insert(Object __obj_instance) | ||
{ | ||
try { | ||
AbstractCard.CardColor[] colors = AbstractCard.CardColor.values(); | ||
for (int icolor = AbstractCard.CardColor.CURSE.ordinal() + 1; icolor < colors.length; ++icolor) { | ||
CardGroup group = new CardGroup(CardGroup.CardGroupType.UNSPECIFIED); | ||
group.group = CardLibrary.getCardList(CardLibrary.LibraryType.valueOf(colors[icolor].name())); | ||
Fields.cardGroupMap.put(colors[icolor], group); | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
public static class Locator extends SpireInsertLocator | ||
{ | ||
@Override | ||
public int[] Locate(CtBehavior ctMethodToPatch) throws CannotCompileException, PatchingException | ||
{ | ||
Matcher finalMatcher = new Matcher.MethodCallMatcher("com.megacrit.cardcrawl.screens.mainMenu.CardLibraryScreen", "calculateScrollBounds"); | ||
|
||
return LineFinder.findInOrder(ctMethodToPatch, new ArrayList<Matcher>(), finalMatcher); | ||
} | ||
} | ||
} | ||
@SpirePatch( | ||
cls="com.megacrit.cardcrawl.screens.mainMenu.CardLibraryScreen", | ||
method="setLockStatus" | ||
) | ||
public static class setLockStatus | ||
{ | ||
public static void Postfix(Object __obj_instance) | ||
{ | ||
try { | ||
CardLibraryScreen screen = (CardLibraryScreen) __obj_instance; | ||
|
||
AbstractCard.CardColor[] colors = AbstractCard.CardColor.values(); | ||
for (int icolor = AbstractCard.CardColor.CURSE.ordinal() + 1; icolor < colors.length; ++icolor) { | ||
CardGroup group = new CardGroup(CardGroup.CardGroupType.UNSPECIFIED); | ||
group.group = CardLibrary.getCardList(CardLibrary.LibraryType.valueOf(colors[icolor].name())); | ||
@SuppressWarnings("rawtypes") | ||
Class[] cArg = new Class[1]; | ||
cArg[0] = CardGroup.class; | ||
Method lockStatusHelper = screen.getClass().getDeclaredMethod("lockStatusHelper", cArg); | ||
lockStatusHelper.setAccessible(true); | ||
lockStatusHelper.invoke(screen, group); | ||
} | ||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
@SpirePatch( | ||
cls="com.megacrit.cardcrawl.screens.mainMenu.CardLibraryScreen", | ||
method="didChangeTab" | ||
) | ||
public static class DidChangeTab | ||
{ | ||
@SpireInsertPatch( | ||
rloc=1, | ||
localvars={"visibleCards"} | ||
) | ||
public static void Insert(CardLibraryScreen __instance, ColorTabBar tabBar, ColorTabBar.CurrentTab newSelection, @ByRef CardGroup[] visibleCards) | ||
{ | ||
if (newSelection == ColorTabBarFix.Enums.MOD) { | ||
visibleCards[0] = Fields.cardGroupMap.get(AbstractCard.CardColor.values()[AbstractCard.CardColor.CURSE.ordinal() + 1 + ColorTabBarFix.Fields.modTabIndex]); | ||
} | ||
} | ||
} | ||
package basemod.patches.com.megacrit.cardcrawl.screens.compendium.CardLibraryScreen; | ||
|
||
import basemod.patches.com.megacrit.cardcrawl.screens.mainMenu.ColorTabBar.ColorTabBarFix; | ||
import com.evacipated.cardcrawl.modthespire.lib.*; | ||
import com.evacipated.cardcrawl.modthespire.patcher.PatchingException; | ||
import com.megacrit.cardcrawl.cards.AbstractCard; | ||
import com.megacrit.cardcrawl.cards.CardGroup; | ||
import com.megacrit.cardcrawl.helpers.CardLibrary; | ||
import com.megacrit.cardcrawl.screens.compendium.CardLibraryScreen; | ||
import com.megacrit.cardcrawl.screens.mainMenu.ColorTabBar; | ||
import javassist.CannotCompileException; | ||
import javassist.CtBehavior; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* | ||
* @author kioeeht from branch custom-content on ModTheSpire | ||
* https://github.com/kiooeht/ModTheSpire/tree/custom-content | ||
* | ||
*/ | ||
public class EverythingFix | ||
{ | ||
public static class Fields | ||
{ | ||
public static Map<AbstractCard.CardColor, CardGroup> cardGroupMap = new HashMap<>(); | ||
} | ||
|
||
@SpirePatch( | ||
cls="com.megacrit.cardcrawl.screens.compendium.CardLibraryScreen", | ||
method="initialize" | ||
) | ||
public static class Initialize | ||
{ | ||
@SpireInsertPatch | ||
public static void Insert(Object __obj_instance) | ||
{ | ||
try { | ||
AbstractCard.CardColor[] colors = AbstractCard.CardColor.values(); | ||
for (int icolor = AbstractCard.CardColor.CURSE.ordinal() + 1; icolor < colors.length; ++icolor) { | ||
CardGroup group = new CardGroup(CardGroup.CardGroupType.UNSPECIFIED); | ||
group.group = CardLibrary.getCardList(CardLibrary.LibraryType.valueOf(colors[icolor].name())); | ||
Fields.cardGroupMap.put(colors[icolor], group); | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static class Locator extends SpireInsertLocator | ||
{ | ||
@Override | ||
public int[] Locate(CtBehavior ctMethodToPatch) throws CannotCompileException, PatchingException | ||
{ | ||
Matcher finalMatcher = new Matcher.MethodCallMatcher("com.megacrit.cardcrawl.screens.compendium.CardLibraryScreen", "calculateScrollBounds"); | ||
|
||
return LineFinder.findInOrder(ctMethodToPatch, new ArrayList<Matcher>(), finalMatcher); | ||
} | ||
} | ||
} | ||
|
||
@SpirePatch( | ||
cls="com.megacrit.cardcrawl.screens.compendium.CardLibraryScreen", | ||
method="setLockStatus" | ||
) | ||
public static class setLockStatus | ||
{ | ||
public static void Postfix(Object __obj_instance) | ||
{ | ||
try { | ||
CardLibraryScreen screen = (CardLibraryScreen) __obj_instance; | ||
|
||
AbstractCard.CardColor[] colors = AbstractCard.CardColor.values(); | ||
for (int icolor = AbstractCard.CardColor.CURSE.ordinal() + 1; icolor < colors.length; ++icolor) { | ||
CardGroup group = new CardGroup(CardGroup.CardGroupType.UNSPECIFIED); | ||
group.group = CardLibrary.getCardList(CardLibrary.LibraryType.valueOf(colors[icolor].name())); | ||
|
||
@SuppressWarnings("rawtypes") | ||
Class[] cArg = new Class[1]; | ||
cArg[0] = CardGroup.class; | ||
Method lockStatusHelper = screen.getClass().getDeclaredMethod("lockStatusHelper", cArg); | ||
lockStatusHelper.setAccessible(true); | ||
lockStatusHelper.invoke(screen, group); | ||
} | ||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
@SpirePatch( | ||
cls="com.megacrit.cardcrawl.screens.compendium.CardLibraryScreen", | ||
method="didChangeTab" | ||
) | ||
public static class DidChangeTab | ||
{ | ||
@SpireInsertPatch( | ||
rloc=1, | ||
localvars={"visibleCards"} | ||
) | ||
public static void Insert(CardLibraryScreen __instance, ColorTabBar tabBar, ColorTabBar.CurrentTab newSelection, @ByRef CardGroup[] visibleCards) | ||
{ | ||
if (newSelection == ColorTabBarFix.Enums.MOD) { | ||
visibleCards[0] = Fields.cardGroupMap.get(AbstractCard.CardColor.values()[AbstractCard.CardColor.CURSE.ordinal() + 1 + ColorTabBarFix.Fields.modTabIndex]); | ||
} | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...d/patches/com/megacrit/cardcrawl/screens/custom/CustomModeCharacterButton/CtorSwitch.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,60 @@ | ||
package basemod.patches.com.megacrit.cardcrawl.screens.custom.CustomModeCharacterButton; | ||
|
||
import basemod.BaseMod; | ||
import com.badlogic.gdx.graphics.Texture; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch; | ||
import com.megacrit.cardcrawl.characters.AbstractPlayer; | ||
import com.megacrit.cardcrawl.localization.CharacterStrings; | ||
import com.megacrit.cardcrawl.screens.CharSelectInfo; | ||
import com.megacrit.cardcrawl.screens.charSelect.CharacterOption; | ||
import com.megacrit.cardcrawl.screens.custom.CustomModeCharacterButton; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
|
||
@SpirePatch( | ||
cls="com.megacrit.cardcrawl.screens.custom.CustomModeCharacterButton", | ||
method=SpirePatch.CONSTRUCTOR | ||
) | ||
public class CtorSwitch | ||
{ | ||
public static final Logger logger = LogManager.getLogger(BaseMod.class.getName()); | ||
|
||
public static void Postfix(CustomModeCharacterButton __instance, AbstractPlayer.PlayerClass c, boolean locked) | ||
{ | ||
if (!BaseMod.isBaseGameCharacter(c)) { | ||
try { | ||
Field charStringsField = CustomModeCharacterButton.class.getDeclaredField("charStrings"); | ||
charStringsField.setAccessible(true); | ||
|
||
Class characterClass = BaseMod.getPlayerClass(c.toString()); | ||
Method getLoadout = characterClass.getMethod("getLoadout"); | ||
CharSelectInfo charInfo = (CharSelectInfo) getLoadout.invoke(null); | ||
|
||
CharacterStrings charStrings = new CharacterStrings(); | ||
charStrings.NAMES = new String[]{charInfo.name}; | ||
charStrings.TEXT = new String[]{charInfo.flavorText}; | ||
|
||
charStringsField.set(__instance, charStrings); | ||
} catch (NoSuchFieldException | SecurityException | NoSuchMethodException | IllegalArgumentException | IllegalAccessException | InvocationTargetException e) { | ||
logger.error("could not create character loadout for " + c.toString()); | ||
logger.error("with exception: " + e.getMessage()); | ||
e.printStackTrace(); | ||
} | ||
|
||
try { | ||
// fix texture loading | ||
Field buttonImgField = CustomModeCharacterButton.class.getDeclaredField("buttonImg"); | ||
buttonImgField.setAccessible(true); | ||
buttonImgField.set(__instance, new Texture(BaseMod.getPlayerButton(c.toString()))); | ||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { | ||
logger.error("could not create character select button for " + c.toString()); | ||
logger.error("with exception: " + e.getMessage()); | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.