mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Refactor shared parts of certain descriptions into separate field so it can be displayed on its own line
This commit is contained in:
@@ -263,15 +263,19 @@ public class AchievementsPage extends TabPage<SettingsScreen> {
|
|||||||
//draw tooltip for selected achievement if needed
|
//draw tooltip for selected achievement if needed
|
||||||
if (selectRect != null) {
|
if (selectRect != null) {
|
||||||
String subTitle = selectedAchievement.getSubTitle();
|
String subTitle = selectedAchievement.getSubTitle();
|
||||||
String goldDesc = selectedAchievement.getGoldDesc() == null ? null : "(Gold) " + selectedAchievement.getGoldDesc();
|
String sharedDesc = selectedAchievement.getSharedDesc();
|
||||||
String silverDesc = selectedAchievement.getSilverDesc() == null ? null : "(Silver) " + selectedAchievement.getSilverDesc();
|
String goldDesc = selectedAchievement.getGoldDesc();
|
||||||
String bronzeDesc = selectedAchievement.getBronzeDesc() == null ? null : "(Bronze) " + selectedAchievement.getBronzeDesc();
|
String silverDesc = selectedAchievement.getSilverDesc();
|
||||||
|
String bronzeDesc = selectedAchievement.getBronzeDesc();
|
||||||
|
|
||||||
w = getWidth() - 2 * PADDING;
|
w = getWidth() - 2 * PADDING;
|
||||||
float h = NAME_FONT.getLineHeight() + 2.5f * PADDING;
|
float h = NAME_FONT.getLineHeight() + 2.5f * PADDING;
|
||||||
if (subTitle != null) {
|
if (subTitle != null) {
|
||||||
h += DESC_FONT.getLineHeight();
|
h += DESC_FONT.getLineHeight();
|
||||||
}
|
}
|
||||||
|
if (sharedDesc != null) {
|
||||||
|
h += DESC_FONT.getLineHeight();
|
||||||
|
}
|
||||||
if (goldDesc != null) {
|
if (goldDesc != null) {
|
||||||
h += DESC_FONT.getLineHeight();
|
h += DESC_FONT.getLineHeight();
|
||||||
}
|
}
|
||||||
@@ -308,20 +312,25 @@ public class AchievementsPage extends TabPage<SettingsScreen> {
|
|||||||
y += DESC_FONT.getLineHeight();
|
y += DESC_FONT.getLineHeight();
|
||||||
}
|
}
|
||||||
y += PADDING;
|
y += PADDING;
|
||||||
|
if (sharedDesc != null) {
|
||||||
|
g.drawText(sharedDesc + "...", DESC_FONT, TEXT_COLOR,
|
||||||
|
x, y, w, h, false, HAlignment.LEFT, false);
|
||||||
|
y += DESC_FONT.getLineHeight();
|
||||||
|
}
|
||||||
if (goldDesc != null) {
|
if (goldDesc != null) {
|
||||||
g.drawText(goldDesc, DESC_FONT,
|
g.drawText("(Gold) " + goldDesc, DESC_FONT,
|
||||||
selectedAchievement.earnedGold() ? TEXT_COLOR : NOT_EARNED_COLOR,
|
selectedAchievement.earnedGold() ? TEXT_COLOR : NOT_EARNED_COLOR,
|
||||||
x, y, w, h, false, HAlignment.LEFT, false);
|
x, y, w, h, false, HAlignment.LEFT, false);
|
||||||
y += DESC_FONT.getLineHeight();
|
y += DESC_FONT.getLineHeight();
|
||||||
}
|
}
|
||||||
if (silverDesc != null) {
|
if (silverDesc != null) {
|
||||||
g.drawText(silverDesc, DESC_FONT,
|
g.drawText("(Silver) " + silverDesc, DESC_FONT,
|
||||||
selectedAchievement.earnedSilver() ? TEXT_COLOR : NOT_EARNED_COLOR,
|
selectedAchievement.earnedSilver() ? TEXT_COLOR : NOT_EARNED_COLOR,
|
||||||
x, y, w, h, false, HAlignment.LEFT, false);
|
x, y, w, h, false, HAlignment.LEFT, false);
|
||||||
y += DESC_FONT.getLineHeight();
|
y += DESC_FONT.getLineHeight();
|
||||||
}
|
}
|
||||||
if (bronzeDesc != null) {
|
if (bronzeDesc != null) {
|
||||||
g.drawText(bronzeDesc, DESC_FONT,
|
g.drawText("(Bronze) " + bronzeDesc, DESC_FONT,
|
||||||
selectedAchievement.earnedBronze() ? TEXT_COLOR : NOT_EARNED_COLOR,
|
selectedAchievement.earnedBronze() ? TEXT_COLOR : NOT_EARNED_COLOR,
|
||||||
x, y, w, h, false, HAlignment.LEFT, false);
|
x, y, w, h, false, HAlignment.LEFT, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,18 +14,19 @@ import forge.util.FileUtil;
|
|||||||
import forge.util.gui.SOptionPane;
|
import forge.util.gui.SOptionPane;
|
||||||
|
|
||||||
public abstract class Achievement {
|
public abstract class Achievement {
|
||||||
private final String displayName, bronzeDesc, silverDesc, goldDesc;
|
private final String displayName, sharedDesc, bronzeDesc, silverDesc, goldDesc;
|
||||||
private final int bronzeThreshold, silverThreshold, goldThreshold;
|
private final int bronzeThreshold, silverThreshold, goldThreshold;
|
||||||
private final boolean checkGreaterThan;
|
private final boolean checkGreaterThan;
|
||||||
private String imagePrefix;
|
private String imagePrefix;
|
||||||
private ISkinImage customImage;
|
private ISkinImage customImage;
|
||||||
protected int best, current;
|
protected int best, current;
|
||||||
|
|
||||||
public Achievement(String displayName0,
|
public Achievement(String displayName0, String sharedDesc0,
|
||||||
String bronzeDesc0, int bronzeThreshold0,
|
String bronzeDesc0, int bronzeThreshold0,
|
||||||
String silverDesc0, int silverThreshold0,
|
String silverDesc0, int silverThreshold0,
|
||||||
String goldDesc0, int goldThreshold0) {
|
String goldDesc0, int goldThreshold0) {
|
||||||
displayName = displayName0;
|
displayName = displayName0;
|
||||||
|
sharedDesc = sharedDesc0;
|
||||||
bronzeDesc = bronzeDesc0;
|
bronzeDesc = bronzeDesc0;
|
||||||
bronzeThreshold = bronzeThreshold0;
|
bronzeThreshold = bronzeThreshold0;
|
||||||
silverDesc = silverDesc0;
|
silverDesc = silverDesc0;
|
||||||
@@ -38,6 +39,9 @@ public abstract class Achievement {
|
|||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
public String getSharedDesc() {
|
||||||
|
return sharedDesc;
|
||||||
|
}
|
||||||
public String getBronzeDesc() {
|
public String getBronzeDesc() {
|
||||||
return bronzeDesc;
|
return bronzeDesc;
|
||||||
}
|
}
|
||||||
@@ -157,8 +161,11 @@ public abstract class Achievement {
|
|||||||
updateCustomImage();
|
updateCustomImage();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (sharedDesc != null) {
|
||||||
|
desc = sharedDesc + " " + desc;
|
||||||
|
}
|
||||||
SOptionPane.showMessageDialog(gui, "You've earned a " + type + " trophy!\n\n" +
|
SOptionPane.showMessageDialog(gui, "You've earned a " + type + " trophy!\n\n" +
|
||||||
displayName + " - " + desc, "Achievement Earned", image);
|
displayName + "\n" + desc + ".", "Achievement Earned", image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ public class Blackjack extends Achievement {
|
|||||||
private static final int THRESHOLD = 21;
|
private static final int THRESHOLD = 21;
|
||||||
|
|
||||||
public Blackjack(int silver0, int gold0) {
|
public Blackjack(int silver0, int gold0) {
|
||||||
super("Blackjack",
|
super("Blackjack", "Win a game from your commander dealing",
|
||||||
String.format("Win a game by dealing %d combat damage with your commander.", THRESHOLD), THRESHOLD,
|
String.format("%d combat damage", THRESHOLD), THRESHOLD,
|
||||||
String.format("Win a game by dealing %d combat damage with your commander.", silver0), silver0,
|
String.format("%d combat damage", silver0), silver0,
|
||||||
String.format("Win a game by dealing %d combat damage with your commander.", gold0), gold0);
|
String.format("%d combat damage", gold0), gold0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import forge.game.player.Player;
|
|||||||
|
|
||||||
public class DeckedOut extends Achievement {
|
public class DeckedOut extends Achievement {
|
||||||
public DeckedOut(int silver0, int gold0) {
|
public DeckedOut(int silver0, int gold0) {
|
||||||
super("Decked Out",
|
super("Decked Out", "Win a game from opponent",
|
||||||
"Win a game from opponent drawing into an empty library.", Integer.MAX_VALUE - 1,
|
"drawing into an empty library", Integer.MAX_VALUE - 1,
|
||||||
String.format("Win a game this way by turn %d.", silver0), silver0,
|
String.format("drawing into an empty library by turn %d", silver0), silver0,
|
||||||
String.format("Win a game this way by turn %d.", gold0), gold0);
|
String.format("drawing into an empty library by turn %d", gold0), gold0);
|
||||||
best = Integer.MAX_VALUE;
|
best = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import forge.game.player.Player;
|
|||||||
|
|
||||||
public class GameWinStreak extends Achievement {
|
public class GameWinStreak extends Achievement {
|
||||||
public GameWinStreak(int bronze0, int silver0, int gold0) {
|
public GameWinStreak(int bronze0, int silver0, int gold0) {
|
||||||
super("Game Win Streak",
|
super("Game Win Streak", null,
|
||||||
String.format("Win %d games in a row.", bronze0), bronze0,
|
String.format("Win %d games in a row", bronze0), bronze0,
|
||||||
String.format("Win %d games in a row.", silver0), silver0,
|
String.format("Win %d games in a row", silver0), silver0,
|
||||||
String.format("Win %d games in a row.", gold0), gold0);
|
String.format("Win %d games in a row", gold0), gold0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import forge.game.zone.ZoneType;
|
|||||||
|
|
||||||
public class Hellbent extends Achievement {
|
public class Hellbent extends Achievement {
|
||||||
public Hellbent() {
|
public Hellbent() {
|
||||||
super("Hellbent",
|
super("Hellbent", "Win a game with no cards",
|
||||||
"Win game with no cards in hand.", 1,
|
"in your hand", 1,
|
||||||
"Win game with no cards in hand or library.", 2,
|
"in your hand or library", 2,
|
||||||
"Win game with no cards in hand, library, or graveyard.", 3);
|
"in your hand, library, or graveyard", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import forge.game.player.Player;
|
|||||||
|
|
||||||
public class LifeToSpare extends Achievement {
|
public class LifeToSpare extends Achievement {
|
||||||
public LifeToSpare(int bronze0, int silver0, int gold0) {
|
public LifeToSpare(int bronze0, int silver0, int gold0) {
|
||||||
super("Life to Spare",
|
super("Life to Spare", "Win a game with",
|
||||||
String.format("Win game with %d life more than you started with.", bronze0), bronze0,
|
String.format("%d life more than you started with", bronze0), bronze0,
|
||||||
String.format("Win game with %d life more than you started with.", silver0), silver0,
|
String.format("%d life more than you started with", silver0), silver0,
|
||||||
String.format("Win game with %d life more than you started with.", gold0), gold0);
|
String.format("%d life more than you started with", gold0), gold0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import forge.game.player.Player;
|
|||||||
|
|
||||||
public class MatchWinStreak extends Achievement {
|
public class MatchWinStreak extends Achievement {
|
||||||
public MatchWinStreak(int bronze0, int silver0, int gold0) {
|
public MatchWinStreak(int bronze0, int silver0, int gold0) {
|
||||||
super("Match Win Streak",
|
super("Match Win Streak", null,
|
||||||
String.format("Win %d matches in a row.", bronze0), bronze0,
|
String.format("Win %d matches in a row", bronze0), bronze0,
|
||||||
String.format("Win %d matches in a row.", silver0), silver0,
|
String.format("Win %d matches in a row", silver0), silver0,
|
||||||
String.format("Win %d matches in a row.", gold0), gold0);
|
String.format("Win %d matches in a row", gold0), gold0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import forge.game.player.Player;
|
|||||||
|
|
||||||
public class NeedForSpeed extends Achievement {
|
public class NeedForSpeed extends Achievement {
|
||||||
public NeedForSpeed(int bronze0, int silver0, int gold0) {
|
public NeedForSpeed(int bronze0, int silver0, int gold0) {
|
||||||
super("Need for Speed",
|
super("Need for Speed", null,
|
||||||
String.format("Win a game by turn %d.", bronze0), bronze0,
|
String.format("Win a game by turn %d", bronze0), bronze0,
|
||||||
String.format("Win a game by turn %d.", silver0), silver0,
|
String.format("Win a game by turn %d", silver0), silver0,
|
||||||
String.format("Win a game by turn %d.", gold0), gold0);
|
String.format("Win a game by turn %d", gold0), gold0);
|
||||||
best = Integer.MAX_VALUE; //initialize best to max value so any
|
best = Integer.MAX_VALUE; //initialize best to max value so any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import forge.game.player.Player;
|
|||||||
|
|
||||||
public class Overkill extends Achievement {
|
public class Overkill extends Achievement {
|
||||||
public Overkill(int bronze0, int silver0, int gold0) {
|
public Overkill(int bronze0, int silver0, int gold0) {
|
||||||
super("Overkill",
|
super("Overkill", "Win a game with opponent at",
|
||||||
String.format("Win game with opponent at %d life or less.", bronze0), bronze0,
|
String.format("%d life.", bronze0), bronze0,
|
||||||
String.format("Win game with opponent at %d life or less.", silver0), silver0,
|
String.format("%d life", silver0), silver0,
|
||||||
String.format("Win game with opponent at %d life or less.", gold0), gold0);
|
String.format("%d life", gold0), gold0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ public class Poisoned extends Achievement {
|
|||||||
private static final int THRESHOLD = 10;
|
private static final int THRESHOLD = 10;
|
||||||
|
|
||||||
public Poisoned(int silver0, int gold0) {
|
public Poisoned(int silver0, int gold0) {
|
||||||
super("Poisoned",
|
super("Poisoned", "Win a game by giving opponent",
|
||||||
String.format("Win a game by giving opponent %d poison counters.", THRESHOLD), THRESHOLD,
|
String.format("%d poison counters", THRESHOLD), THRESHOLD,
|
||||||
String.format("Win a game by giving opponent %d poison counters.", silver0), silver0,
|
String.format("%d poison counters", silver0), silver0,
|
||||||
String.format("Win a game by giving opponent %d poison counters.", gold0), gold0);
|
String.format("%d poison counters", gold0), gold0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import forge.game.player.Player;
|
|||||||
|
|
||||||
public class TotalGameWins extends Achievement {
|
public class TotalGameWins extends Achievement {
|
||||||
public TotalGameWins(int bronze0, int silver0, int gold0) {
|
public TotalGameWins(int bronze0, int silver0, int gold0) {
|
||||||
super("Total Game Wins",
|
super("Total Game Wins", null,
|
||||||
String.format("Win %d games.", bronze0), bronze0,
|
String.format("Win %d games", bronze0), bronze0,
|
||||||
String.format("Win %d games.", silver0), silver0,
|
String.format("Win %d games", silver0), silver0,
|
||||||
String.format("Win %d games.", gold0), gold0);
|
String.format("Win %d games", gold0), gold0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import forge.game.player.Player;
|
|||||||
|
|
||||||
public class TotalMatchWins extends Achievement {
|
public class TotalMatchWins extends Achievement {
|
||||||
public TotalMatchWins(int bronze0, int silver0, int gold0) {
|
public TotalMatchWins(int bronze0, int silver0, int gold0) {
|
||||||
super("Total Match Wins",
|
super("Total Match Wins", null,
|
||||||
String.format("Win %d matches.", bronze0), bronze0,
|
String.format("Win %d matches", bronze0), bronze0,
|
||||||
String.format("Win %d matches.", silver0), silver0,
|
String.format("Win %d matches", silver0), silver0,
|
||||||
String.format("Win %d matches.", gold0), gold0);
|
String.format("Win %d matches", gold0), gold0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ public class VariantWins extends Achievement {
|
|||||||
private GameType variant;
|
private GameType variant;
|
||||||
|
|
||||||
public VariantWins(GameType variant0, int silver0, int gold0) {
|
public VariantWins(GameType variant0, int silver0, int gold0) {
|
||||||
super(variant0.toString(),
|
super(variant0.toString(), null,
|
||||||
String.format("Win a %s game.", variant0.toString()), 1,
|
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", silver0, variant0.toString()), silver0,
|
||||||
String.format("Win %d %s games.", gold0, variant0.toString()), gold0);
|
String.format("Win %d %s games", gold0, variant0.toString()), gold0);
|
||||||
variant = variant0;
|
variant = variant0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user