mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Add counters to mobile Forge and adjust desktop counters
This commit is contained in:
@@ -195,6 +195,7 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
initializeColorIdentityCombobox();
|
||||
initializeAutoYieldModeComboBox();
|
||||
initializeCounterDisplayTypeComboBox();
|
||||
initializeCounterDisplayLocationComboBox();
|
||||
initializePlayerNameButton();
|
||||
}
|
||||
|
||||
@@ -360,6 +361,25 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
|
||||
}
|
||||
|
||||
private void initializeCounterDisplayLocationComboBox() {
|
||||
|
||||
final String[] elements = new String[ForgeConstants.CounterDisplayLocation.values().length];
|
||||
|
||||
ForgeConstants.CounterDisplayLocation[] values = ForgeConstants.CounterDisplayLocation.values();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
elements[i] = values[i].getName();
|
||||
}
|
||||
|
||||
final FPref userSetting = FPref.UI_CARD_COUNTER_DISPLAY_LOCATION;
|
||||
final FComboBoxPanel<String> panel = this.view.getCounterDisplayLocationComboBoxPanel();
|
||||
|
||||
final FComboBox<String> comboBox = createComboBox(elements, userSetting);
|
||||
final String selectedItem = this.prefs.getPref(userSetting);
|
||||
|
||||
panel.setComboBox(comboBox, selectedItem);
|
||||
|
||||
}
|
||||
|
||||
private <E> FComboBox<E> createComboBox(final E[] items, final ForgePreferences.FPref setting) {
|
||||
final FComboBox<E> comboBox = new FComboBox<>(items);
|
||||
addComboBoxListener(comboBox, setting);
|
||||
|
||||
@@ -103,6 +103,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
private final FComboBoxPanel<String> cbpDisplayCurrentCardColors = new FComboBoxPanel<>("Show Detailed Card Color:");
|
||||
private final FComboBoxPanel<String> cbpAutoYieldMode = new FComboBoxPanel<>("Auto-Yield:");
|
||||
private final FComboBoxPanel<String> cbpCounterDisplayType = new FComboBoxPanel<>("Counter Display Type:");
|
||||
private final FComboBoxPanel<String> cbpCounterDisplayLocation = new FComboBoxPanel<>("Counter Display Location:");
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -280,6 +281,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
pnlPrefs.add(cbpCounterDisplayType, comboBoxConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Selects the style of the in-game counter display for cards. Text-based is a new tab-like display on the cards. Image-based is the old counter image. Hybrid displays both at once."), descriptionConstraints);
|
||||
|
||||
pnlPrefs.add(cbpCounterDisplayLocation, comboBoxConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Determines where to position the text-based counters on the card: close to the top or close to the bottom."), descriptionConstraints);
|
||||
|
||||
pnlPrefs.add(cbpDisplayCurrentCardColors, comboBoxConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Displays the breakdown of the current color of cards in the card detail information panel."), descriptionConstraints);
|
||||
|
||||
@@ -593,6 +597,10 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
return cbpCounterDisplayType;
|
||||
}
|
||||
|
||||
public FComboBoxPanel<String> getCounterDisplayLocationComboBoxPanel() {
|
||||
return cbpCounterDisplayLocation;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbEnforceDeckLegality() {
|
||||
return cbEnforceDeckLegality;
|
||||
|
||||
@@ -29,6 +29,7 @@ import forge.game.card.CounterType;
|
||||
import forge.gui.CardContainer;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.properties.ForgeConstants.CounterDisplayType;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.CMatchUI;
|
||||
@@ -45,6 +46,7 @@ import java.awt.font.TextAttribute;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -99,7 +101,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
|
||||
try {
|
||||
|
||||
Font roboto = Font.createFont(Font.TRUETYPE_FONT, CardPanel.class.getClassLoader().getResourceAsStream("Roboto-Bold.ttf"));
|
||||
Font roboto = Font.createFont(Font.TRUETYPE_FONT, Paths.get(ForgeConstants.COMMON_FONTS_DIR, "Roboto-Bold.ttf").toFile());
|
||||
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
ge.registerFont(roboto);
|
||||
@@ -108,7 +110,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
|
||||
attributes.put(TextAttribute.FAMILY, "Roboto Bold");
|
||||
attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
|
||||
attributes.put(TextAttribute.SIZE, 10);
|
||||
attributes.put(TextAttribute.SIZE, 11);
|
||||
attributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
|
||||
|
||||
smallCounterFont = Font.getFont(attributes);
|
||||
@@ -437,7 +439,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
|
||||
if (card.getCounters() != null) {
|
||||
if (card.getCounters() != null && !card.getCounters().isEmpty()) {
|
||||
|
||||
switch (CounterDisplayType.from(FModel.getPreferences().getPref(FPref.UI_CARD_COUNTER_DISPLAY_TYPE))) {
|
||||
case OLD_WHEN_SMALL:
|
||||
@@ -517,7 +519,13 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
final int numberOfCounters = counterEntry.getValue();
|
||||
final int counterBoxRealWidth = counterBoxBaseWidth + largeFontMetrics.stringWidth(String.valueOf(numberOfCounters));
|
||||
|
||||
final int counterYOffset = cardYOffset + spaceFromTopOfCard - counterBoxHeight + currentCounter++ * (counterBoxHeight + counterBoxSpacing);
|
||||
final int counterYOffset;
|
||||
|
||||
if (ForgeConstants.CounterDisplayLocation.from(FModel.getPreferences().getPref(FPref.UI_CARD_COUNTER_DISPLAY_LOCATION)) == ForgeConstants.CounterDisplayLocation.TOP) {
|
||||
counterYOffset = cardYOffset + spaceFromTopOfCard - counterBoxHeight + currentCounter++ * (counterBoxHeight + counterBoxSpacing);
|
||||
} else {
|
||||
counterYOffset = cardYOffset + cardHeight - spaceFromTopOfCard / 2 - counterBoxHeight + currentCounter++ * (counterBoxHeight + counterBoxSpacing);
|
||||
}
|
||||
|
||||
if (isSelected) {
|
||||
g.setColor(new Color(0, 0, 0, 255));
|
||||
@@ -537,7 +545,8 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
Rectangle nameBounds = counterArea.getBounds();
|
||||
nameBounds.x += 12;
|
||||
nameBounds.x += 8;
|
||||
nameBounds.y -= 1;
|
||||
nameBounds.width = 43;
|
||||
drawVerticallyCenteredString(g, counter.getCounterOnCardDisplayName(), nameBounds, smallCounterFont, smallFontMetrics);
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user