Skip to content

Commit

Permalink
Relic Large Images (daviscook477#327)
Browse files Browse the repository at this point in the history
* turn start hook

* Add general support for relics overriding loadLargeImage

* Revert "turn start hook"

This reverts commit d43f798.

* no pointless error if large image method isn't set up
  • Loading branch information
Alchyr authored Apr 18, 2023
1 parent 7078d79 commit dab2956
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
11 changes: 11 additions & 0 deletions mod/src/main/java/basemod/abstracts/CustomRelic.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package basemod.abstracts;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.relics.AbstractRelic;

public abstract class CustomRelic extends AbstractRelic
Expand Down Expand Up @@ -37,6 +39,15 @@ public void setTextureOutline(Texture t, Texture o)
outlineImg = o;
}

@Override
public void loadLargeImg() {
if (this.largeImg == null) {
String path = "images/largeRelics/" + this.imgUrl;
if (Gdx.files.internal(path).exists())
this.largeImg = ImageMaster.loadImage(path);
}
}

@Override
public AbstractRelic makeCopy() {
try{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package basemod.patches.com.megacrit.cardcrawl.screens.SingleRelicViewPopup;

import basemod.abstracts.CustomRelic;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.glutils.FileTextureData;
Expand All @@ -17,10 +18,19 @@ public class FixLargeRelicArt
{
public static void Postfix(SingleRelicViewPopup __instance, AbstractRelic ___relic, @ByRef Texture[] ___largeImg)
{
if (___largeImg[0] == null && ___relic.largeImg != null) {
TextureData textureData = ___relic.largeImg.getTextureData();
if (textureData instanceof FileTextureData) {
___largeImg[0] = ImageMaster.loadImage(((FileTextureData) textureData).getFileHandle().path());
if (___largeImg[0] == null) {
if (___relic.largeImg != null) {
TextureData textureData = ___relic.largeImg.getTextureData();
if (textureData instanceof FileTextureData) {
___largeImg[0] = ImageMaster.loadImage(((FileTextureData) textureData).getFileHandle().path());
}
}
else if (___relic instanceof CustomRelic) {
___relic.loadLargeImg();
if (___relic.largeImg != null) {
___largeImg[0] = ___relic.largeImg;
___relic.largeImg = null;
}
}
}
}
Expand Down

0 comments on commit dab2956

Please sign in to comment.