mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Fix crash when opening up Nursery or Pet tabs of Bazaar
This commit is contained in:
@@ -79,18 +79,12 @@ public class ViewItem extends FPanel {
|
||||
|
||||
SkinImage i;
|
||||
try {
|
||||
final FSkinProp f = FSkinProp.valueOf(FSkinProp.class, bazaarItem.getIcon(qA));
|
||||
i = (SkinImage) GuiBase.getInterface().getSkinIcon(f);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Failed to parse FSkinProp
|
||||
try {
|
||||
i = (SkinImage) GuiBase.getInterface().getUnskinnedIcon(bazaarItem.getIcon(qA));
|
||||
i = (SkinImage) bazaarItem.getIcon(qA);
|
||||
} catch (final Exception e1) {
|
||||
// give up, icon unknown
|
||||
e1.printStackTrace();
|
||||
i = (SkinImage) GuiBase.getInterface().getSkinIcon(FSkinProp.ICO_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
ViewItem.this.lblIcon.setIcon(i);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import forge.GuiBase;
|
||||
import forge.assets.FImage;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.QuestController;
|
||||
import forge.quest.QuestUtil;
|
||||
@@ -159,8 +158,7 @@ public class QuestBazaarScreen extends TabPageScreen<QuestBazaarScreen> {
|
||||
|
||||
lblName.setText(item.getPurchaseName());
|
||||
lblDesc.setText(item.getPurchaseDescription(assets));
|
||||
final FSkinProp f = FSkinProp.valueOf(FSkinProp.class, item.getIcon(assets));
|
||||
lblIcon.setIcon((FImage) GuiBase.getInterface().getSkinIcon(f));
|
||||
lblIcon.setIcon((FImage)item.getIcon(assets));
|
||||
lblCost.setText(String.valueOf(buyingPrice));
|
||||
|
||||
lblDesc.setFont(FSkinFont.get(12));
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package forge.quest.bazaar;
|
||||
|
||||
import forge.assets.ISkinImage;
|
||||
import forge.quest.QuestController;
|
||||
import forge.quest.data.QuestAssets;
|
||||
|
||||
@@ -52,7 +53,7 @@ public interface IQuestBazaarItem extends Comparable<Object> {
|
||||
*
|
||||
* @return the image that is dispslayed in the bazaar
|
||||
*/
|
||||
String getIcon(QuestAssets qA);
|
||||
ISkinImage getIcon(QuestAssets qA);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@@ -21,7 +21,9 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.assets.ISkinImage;
|
||||
import forge.quest.QuestController;
|
||||
import forge.quest.data.QuestAssets;
|
||||
|
||||
@@ -171,8 +173,8 @@ public class QuestItemBasic implements IQuestBazaarItem {
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String getIcon(final QuestAssets qA) {
|
||||
return icon.name();
|
||||
public ISkinImage getIcon(final QuestAssets qA) {
|
||||
return GuiBase.getInterface().getSkinIcon(icon);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,9 @@ import java.util.List;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.assets.ISkinImage;
|
||||
import forge.item.PaperToken;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgeConstants;
|
||||
@@ -120,10 +123,22 @@ public class QuestPetController implements IQuestBazaarItem {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
@Override
|
||||
public final String getIcon(final QuestAssets qA) {
|
||||
public final ISkinImage getIcon(final QuestAssets qA) {
|
||||
final String path = ForgeConstants.CACHE_TOKEN_PICS_DIR;
|
||||
final int level = this.getPetLevel(qA);
|
||||
return path + this.levels.get(level < this.maxLevel ? level + 1 : level).getPicture() + ".jpg";
|
||||
try {
|
||||
return GuiBase.getInterface().getUnskinnedIcon(path + this.levels.get(level < this.maxLevel ? level + 1 : level).getPicture() + ".jpg");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
return GuiBase.getInterface().getUnskinnedIcon(ForgeConstants.NO_CARD_FILE);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return GuiBase.getInterface().getSkinIcon(FSkinProp.ICO_UNKNOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user