mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
GUI: Card Viewer - added support of xmage inner images like morph, blessing, etc (look in XMAGE set, related to #11622);
This commit is contained in:
parent
f5a43d9115
commit
38c71cfeed
7 changed files with 81 additions and 17 deletions
|
|
@ -92,7 +92,7 @@ public class DeckGeneratorDialog {
|
|||
c.weightx = 0.80;
|
||||
mainPanel.add(setPanel, c);
|
||||
|
||||
cbSets = new JComboBox<>(ConstructedFormats.getTypes());
|
||||
cbSets = new JComboBox<>(ConstructedFormats.getTypes(false).toArray());
|
||||
cbSets.setSelectedIndex(0);
|
||||
cbSets.setAlignmentX(0.0F);
|
||||
setPanel.add(cbSets);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
// prepare search dialog with checkboxes
|
||||
listCodeSelected = new CheckBoxList();
|
||||
List<String> checkboxes = new ArrayList<>();
|
||||
for (String item : ConstructedFormats.getTypes()) {
|
||||
for (String item : ConstructedFormats.getTypes(false)) {
|
||||
if (!item.equals(ConstructedFormats.ALL_SETS)) {
|
||||
checkboxes.add(item);
|
||||
}
|
||||
|
|
@ -540,7 +540,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
}
|
||||
|
||||
private void reloadSetsCombobox() {
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel<>(ConstructedFormats.getTypes());
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel<>(ConstructedFormats.getTypes(false).toArray());
|
||||
cbExpansionSet.setModel(model);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
}
|
||||
|
||||
private void reloadFormatCombobox() {
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel<>(ConstructedFormats.getTypes());
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel<>(ConstructedFormats.getTypes(true).toArray());
|
||||
formats.setModel(model);
|
||||
formats.setSelectedItem(ConstructedFormats.getDefault());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import mage.cards.RateCard;
|
|||
import mage.game.permanent.PermanentToken;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.game.permanent.token.TokenImpl;
|
||||
import mage.game.permanent.token.custom.XmageToken;
|
||||
import mage.view.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
|
|
@ -230,13 +231,22 @@ public class MageBook extends JComponent {
|
|||
public List<Object> loadTokens() {
|
||||
List<Object> res = new ArrayList<>();
|
||||
|
||||
// tokens
|
||||
List<TokenInfo> allTokens = TokenRepository.instance.getByType(TokenType.TOKEN)
|
||||
.stream()
|
||||
.filter(token -> token.getSetCode().equals(currentSet))
|
||||
.collect(Collectors.toList());
|
||||
// tokens (official and xmage's inner)
|
||||
List<TokenInfo> allTokens = new ArrayList<>(TokenRepository.instance.getByType(TokenType.TOKEN));
|
||||
allTokens.addAll(TokenRepository.instance.getByType(TokenType.XMAGE));
|
||||
allTokens.removeIf(token -> !token.getSetCode().equals(currentSet));
|
||||
allTokens.forEach(token -> {
|
||||
TokenImpl newToken = TokenImpl.createTokenByClassName(token.getFullClassFileName());
|
||||
TokenImpl newToken;
|
||||
switch (token.getTokenType()) {
|
||||
case XMAGE:
|
||||
newToken = new XmageToken(token.getName());
|
||||
break;
|
||||
|
||||
case TOKEN:
|
||||
default:
|
||||
newToken = TokenImpl.createTokenByClassName(token.getFullClassFileName());
|
||||
break;
|
||||
}
|
||||
if (newToken != null) {
|
||||
newToken.setExpansionSetCode(currentSet);
|
||||
newToken.setImageNumber(token.getImageNumber());
|
||||
|
|
@ -456,15 +466,22 @@ public class MageBook extends JComponent {
|
|||
private void updateCardStats(String setCode, boolean isCardsShow) {
|
||||
// sets do not have total cards number, it's a workaround
|
||||
|
||||
// inner set
|
||||
if (setCode.equals(TokenRepository.XMAGE_TOKENS_SET_CODE)) {
|
||||
setCaption.setText("Inner Xmage images");
|
||||
setInfo.setText("");
|
||||
return;
|
||||
};
|
||||
|
||||
// normal set
|
||||
ExpansionSet set = Sets.findSet(setCode);
|
||||
if (set != null) {
|
||||
setCaption.setText(set.getCode() + " - " + set.getName());
|
||||
} else {
|
||||
if (set == null) {
|
||||
setCaption.setText("ERROR");
|
||||
setInfo.setText("ERROR");
|
||||
return;
|
||||
}
|
||||
|
||||
setCaption.setText(set.getCode() + " - " + set.getName());
|
||||
if (!isCardsShow) {
|
||||
// tokens or emblems, stats not need
|
||||
setInfo.setText("");
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package mage.client.util.sets;
|
|||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.cards.repository.RepositoryEvent;
|
||||
import mage.cards.repository.TokenRepository;
|
||||
import mage.constants.SetType;
|
||||
import mage.deck.Standard;
|
||||
import mage.game.events.Listener;
|
||||
|
|
@ -27,6 +28,7 @@ public final class ConstructedFormats {
|
|||
public static final String HISTORIC = "- Historic";
|
||||
public static final String JOKE = "- Joke Sets";
|
||||
public static final String CUSTOM = "- Custom";
|
||||
public static final String XMAGE_SETS = "- XMAGE"; // inner sets like XMAGE (special tokens)
|
||||
public static final Standard STANDARD_CARDS = new Standard();
|
||||
|
||||
// Attention -Month is 0 Based so Feb = 1 for example. //
|
||||
|
|
@ -62,8 +64,15 @@ public final class ConstructedFormats {
|
|||
private ConstructedFormats() {
|
||||
}
|
||||
|
||||
public static String[] getTypes() {
|
||||
return formats.toArray(new String[0]);
|
||||
/**
|
||||
* @param includeInnerSets add XMAGE set with inner cards/tokens like morph
|
||||
*/
|
||||
public static List<String> getTypes(boolean includeInnerSets) {
|
||||
List<String> res = new ArrayList<>(formats);
|
||||
if (!includeInnerSets) {
|
||||
res.removeIf(s -> s.equals(XMAGE_SETS));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String getDefault() {
|
||||
|
|
@ -95,6 +104,7 @@ public final class ConstructedFormats {
|
|||
underlyingSetCodesPerFormat.put(HISTORIC, new ArrayList<>());
|
||||
underlyingSetCodesPerFormat.put(JOKE, new ArrayList<>());
|
||||
underlyingSetCodesPerFormat.put(CUSTOM, new ArrayList<>());
|
||||
underlyingSetCodesPerFormat.put(XMAGE_SETS, new ArrayList<>());
|
||||
final Map<String, ExpansionInfo> expansionInfo = new HashMap<>();
|
||||
formats.clear(); // prevent NPE on sorting if this is not the first try
|
||||
|
||||
|
|
@ -104,6 +114,9 @@ public final class ConstructedFormats {
|
|||
return;
|
||||
}
|
||||
|
||||
// inner sets
|
||||
underlyingSetCodesPerFormat.get(XMAGE_SETS).add(TokenRepository.XMAGE_TOKENS_SET_CODE);
|
||||
|
||||
// build formats list for deck validators
|
||||
for (ExpansionInfo set : ExpansionRepository.instance.getAll()) {
|
||||
expansionInfo.put(set.getName(), set);
|
||||
|
|
@ -266,6 +279,7 @@ public final class ConstructedFormats {
|
|||
});
|
||||
|
||||
if (!formats.isEmpty()) {
|
||||
formats.add(0, XMAGE_SETS);
|
||||
formats.add(0, CUSTOM);
|
||||
formats.add(0, JOKE);
|
||||
formats.add(0, HISTORIC);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import mage.game.draft.DraftCube;
|
|||
import mage.game.permanent.token.Token;
|
||||
import mage.game.permanent.token.TokenImpl;
|
||||
import mage.game.permanent.token.custom.CreatureToken;
|
||||
import mage.game.permanent.token.custom.XmageToken;
|
||||
import mage.sets.TherosBeyondDeath;
|
||||
import mage.target.targetpointer.TargetPointer;
|
||||
import mage.util.CardUtil;
|
||||
|
|
@ -1315,7 +1316,7 @@ public class VerifyCardDataTest {
|
|||
// - fix error in token's constructor
|
||||
errorsList.add("Error: token must have default constructor with zero params: " + tokenClass.getName());
|
||||
} else if (tokDataNamesIndex.getOrDefault(token.getName().replace(" Token", ""), "").isEmpty()) {
|
||||
if (token instanceof CreatureToken) {
|
||||
if (token instanceof CreatureToken || token instanceof XmageToken) {
|
||||
// ignore custom token builders
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1340,7 +1341,8 @@ public class VerifyCardDataTest {
|
|||
// CHECK: tokens must have Token word in the name
|
||||
if (token.getDescription().startsWith(token.getName() + ", ")
|
||||
|| token.getDescription().contains("named " + token.getName())
|
||||
|| (token instanceof CreatureToken)) {
|
||||
|| (token instanceof CreatureToken)
|
||||
|| (token instanceof XmageToken)) {
|
||||
// ignore some names:
|
||||
// - Boo, a legendary 1/1 red Hamster creature token with trample and haste
|
||||
// - 1/1 green Insect creature token with flying named Butterfly
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package mage.game.permanent.token.custom;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.game.permanent.token.TokenImpl;
|
||||
|
||||
/**
|
||||
* GUI: inner xmage token object to show custom images (information tokens like morph, blessing, etc)
|
||||
*
|
||||
* @author JayDi85
|
||||
*/
|
||||
public final class XmageToken extends TokenImpl {
|
||||
|
||||
public XmageToken(String name) {
|
||||
super(name, "");
|
||||
this.frameStyle = FrameStyle.BFZ_FULL_ART_BASIC; // use full art for better visual in card viewer
|
||||
}
|
||||
|
||||
public XmageToken withAbility(Ability ability) {
|
||||
this.addAbility(ability);
|
||||
return this;
|
||||
}
|
||||
|
||||
private XmageToken(final XmageToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
public XmageToken copy() {
|
||||
return new XmageToken(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue