mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Prevent multiple thread queues for loading custom achievement images on startup
This commit is contained in:
@@ -77,7 +77,7 @@ public abstract class Achievement {
|
||||
return customImage;
|
||||
}
|
||||
|
||||
private void updateCustomImage() {
|
||||
public void updateCustomImage() {
|
||||
int suffix;
|
||||
if (earnedGold()) {
|
||||
suffix = 3;
|
||||
@@ -94,12 +94,7 @@ public abstract class Achievement {
|
||||
}
|
||||
final String filename = ForgeConstants.CACHE_ACHIEVEMENT_PICS_DIR + imagePrefix + "_" + suffix + ".png";
|
||||
if (FileUtil.doesFileExist(filename)) {
|
||||
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
customImage = GuiBase.getInterface().getUnskinnedIcon(filename);
|
||||
}
|
||||
});
|
||||
customImage = GuiBase.getInterface().getUnskinnedIcon(filename);
|
||||
return;
|
||||
}
|
||||
customImage = null;
|
||||
@@ -156,7 +151,12 @@ public abstract class Achievement {
|
||||
}
|
||||
}
|
||||
if (type != null) {
|
||||
updateCustomImage();
|
||||
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateCustomImage();
|
||||
}
|
||||
});
|
||||
SOptionPane.showMessageDialog(gui, "You've earned a " + type + " trophy!\n\n" +
|
||||
displayName + " - " + desc, "Achievement Earned", image);
|
||||
}
|
||||
@@ -174,7 +174,6 @@ public abstract class Achievement {
|
||||
public void loadFromXml(Element el) {
|
||||
best = getIntAttribute(el, "best");
|
||||
current = getIntAttribute(el, "current");
|
||||
updateCustomImage();
|
||||
}
|
||||
|
||||
private int getIntAttribute(Element el, String name) {
|
||||
|
||||
@@ -20,7 +20,9 @@ package forge.model;
|
||||
import forge.CardStorageReader;
|
||||
import forge.CardStorageReader.ProgressObserver;
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.StaticData;
|
||||
import forge.achievement.Achievement;
|
||||
import forge.achievement.AchievementCollection;
|
||||
import forge.achievement.ConstructedAchievements;
|
||||
import forge.achievement.DraftAchievements;
|
||||
@@ -174,6 +176,20 @@ public class FModel {
|
||||
achievements.put(GameType.Sealed, new SealedAchievements());
|
||||
achievements.put(GameType.Quest, new QuestAchievements());
|
||||
|
||||
//as long as custom achievement pics directory exists, queue up load for those images
|
||||
if (FileUtil.doesFileExist(ForgeConstants.CACHE_ACHIEVEMENT_PICS_DIR)) {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (AchievementCollection achievementCol : achievements.values()) {
|
||||
for (Achievement achievement : achievementCol) {
|
||||
achievement.updateCustomImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//preload AI profiles
|
||||
AiProfileUtil.loadAllProfiles(ForgeConstants.AI_PROFILE_DIR);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user