mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Add support for displaying achievement earned dialog nicer
This commit is contained in:
@@ -8,7 +8,6 @@ import forge.assets.ISkinImage;
|
||||
import forge.game.Game;
|
||||
import forge.game.player.Player;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.util.gui.SOptionPane;
|
||||
|
||||
public abstract class Achievement {
|
||||
private final String displayName, sharedDesc, commonDesc, uncommonDesc, rareDesc, mythicDesc;
|
||||
@@ -147,6 +146,7 @@ public abstract class Achievement {
|
||||
}
|
||||
else if (current >= best) { return; }
|
||||
|
||||
boolean hadEarnedSpecial = earnedSpecial();
|
||||
boolean hadEarnedMythic = earnedMythic();
|
||||
boolean hadEarnedRare = earnedRare();
|
||||
boolean hadEarnedUncommon = earnedUncommon();
|
||||
@@ -154,6 +154,16 @@ public abstract class Achievement {
|
||||
|
||||
best = current;
|
||||
|
||||
if (earnedSpecial()) {
|
||||
if (!hadEarnedSpecial) {
|
||||
if (image != null) { //only update image if it has already been initialized
|
||||
updateTrophyImage();
|
||||
}
|
||||
gui.showImageDialog(image, displayName + "\n" + sharedDesc + ".", "Achievement Earned");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String type = null;
|
||||
String desc = null;
|
||||
if (earnedMythic()) {
|
||||
@@ -181,14 +191,11 @@ public abstract class Achievement {
|
||||
}
|
||||
}
|
||||
if (type != null) {
|
||||
if (image != null) { //only update image if it has already been initialized
|
||||
updateTrophyImage();
|
||||
}
|
||||
updateTrophyImage();
|
||||
if (sharedDesc != null) {
|
||||
desc = sharedDesc + " " + desc;
|
||||
}
|
||||
SOptionPane.showMessageDialog(gui, "You've earned a " + type + " trophy!\n\n" +
|
||||
displayName + "\n" + desc + ".", "Achievement Earned", overlayImage);
|
||||
gui.showImageDialog(image, displayName + " (" + type + ")\n" + desc + ".", "Achievement Earned");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,16 +4,17 @@ import forge.assets.FSkinProp;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameType;
|
||||
import forge.game.player.Player;
|
||||
import forge.util.Lang;
|
||||
|
||||
public class VariantWins extends Achievement {
|
||||
private GameType variant;
|
||||
|
||||
public VariantWins(GameType variant0, int silver0, int gold0, int mythic0, FSkinProp image0) {
|
||||
super(variant0.toString(), null,
|
||||
String.format("Win a %s game", variant0.toString()), 1,
|
||||
String.format("Win %d %s games", silver0, variant0.toString()), silver0,
|
||||
String.format("Win %d %s games", gold0, variant0.toString()), gold0,
|
||||
String.format("Win %d %s games", mythic0, variant0.toString()), mythic0,
|
||||
"Win " + Lang.nounWithAmount(1, variant0.toString() + " game"), 1,
|
||||
"Win " + Lang.nounWithAmount(silver0, variant0.toString() + " game"), silver0,
|
||||
"Win " + Lang.nounWithAmount(gold0, variant0.toString() + " game"), gold0,
|
||||
"Win " + Lang.nounWithAmount(mythic0, variant0.toString() + " game"), mythic0,
|
||||
image0);
|
||||
variant = variant0;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public interface IGuiBase {
|
||||
ISkinImage getUnskinnedIcon(String path);
|
||||
ISkinImage createLayeredImage(FSkinProp background, FSkinProp overlay, float opacity);
|
||||
void showBugReportDialog(String title, String text, boolean showExitAppBtn);
|
||||
void showImageDialog(ISkinImage image, String message, String title);
|
||||
int showOptionDialog(String message, String title, FSkinProp icon, String[] options, int defaultOption);
|
||||
int showCardOptionDialog(CardView card, String message, String title, FSkinProp icon, String[] options, int defaultOption);
|
||||
<T> T showInputDialog(String message, String title, FSkinProp icon, T initialInput, T[] inputOptions);
|
||||
|
||||
Reference in New Issue
Block a user