mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Add preference how to display alternate card states in deck views
This commit is contained in:
committed by
Michael Kamensky
parent
a3fc74c44e
commit
c13e379908
@@ -46,7 +46,9 @@ import forge.itemmanager.ItemManager;
|
||||
import forge.itemmanager.ItemManagerConfig;
|
||||
import forge.itemmanager.ItemManagerModel;
|
||||
import forge.itemmanager.SItemManagerUtil;
|
||||
import forge.localinstance.properties.ForgeConstants;
|
||||
import forge.localinstance.properties.ForgePreferences;
|
||||
import forge.localinstance.properties.ForgePreferences.FPref;
|
||||
import forge.localinstance.skin.FSkinProp;
|
||||
import forge.model.FModel;
|
||||
import forge.screens.deckeditor.CDeckEditorUI;
|
||||
@@ -796,6 +798,10 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
if (hoveredItem == item) { return false; }
|
||||
hoveredItem = item;
|
||||
if (item != null) {
|
||||
final CDetailPicture cDetailPicture = itemManager.getCDetailPicture();
|
||||
if (cDetailPicture != null) {
|
||||
cDetailPicture.displayAlt(item.alt);
|
||||
}
|
||||
showHoveredItem(item.item);
|
||||
}
|
||||
return true;
|
||||
@@ -999,6 +1005,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
private final T item;
|
||||
private int index;
|
||||
private boolean selected;
|
||||
private boolean alt;
|
||||
|
||||
private ItemInfo(T item0) {
|
||||
item = item0;
|
||||
@@ -1115,6 +1122,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
if (pile.getTop() >= visibleBottom) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (ItemInfo itemInfo : pile.items) {
|
||||
if (itemInfo.getBottom() < visibleTop) {
|
||||
continue;
|
||||
@@ -1122,6 +1130,28 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
if (itemInfo.getTop() >= visibleBottom) {
|
||||
break;
|
||||
}
|
||||
|
||||
InventoryItem item = itemInfo.item;
|
||||
itemInfo.alt = false;
|
||||
if (!FModel.getPreferences().getPref(FPref.UI_SWITCH_STATES_DECKVIEW).equals(ForgeConstants.SWITCH_CARDSTATES_DECK_NEVER)) {
|
||||
if ((hoveredItem == null || !hoveredItem.item.equals(item)) || (FModel.getPreferences().getPref(FPref.UI_SWITCH_STATES_DECKVIEW).equals(ForgeConstants.SWITCH_CARDSTATES_DECK_ALWAYS))) {
|
||||
if (item instanceof PaperCard) {
|
||||
if (ImageUtil.hasBackFacePicture(((PaperCard)item))) {
|
||||
if (item.equals(lastAltCard)) {
|
||||
itemInfo.alt = true;
|
||||
lastAltCard = null;
|
||||
}
|
||||
else {
|
||||
lastAltCard = item;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastAltCard = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (itemInfo != hoveredItem) { //save hovered item for last
|
||||
drawItemImage(g2d, itemInfo);
|
||||
}
|
||||
@@ -1149,12 +1179,13 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
Rectangle bounds = itemInfo.getBounds();
|
||||
final int itemWidth = bounds.width;
|
||||
final int selBorderSize = 1;
|
||||
boolean deckSelectMode = itemInfo.item instanceof DeckProxy;
|
||||
InventoryItem item = itemInfo.item;
|
||||
boolean deckSelectMode = item instanceof DeckProxy;
|
||||
|
||||
// Determine whether to render border from properties
|
||||
boolean noBorder = !isPreferenceEnabled(ForgePreferences.FPref.UI_RENDER_BLACK_BORDERS);
|
||||
if (itemInfo.item instanceof IPaperCard) {
|
||||
CardView cv = CardView.getCardForUi((IPaperCard) itemInfo.item);
|
||||
if (item instanceof IPaperCard) {
|
||||
CardView cv = CardView.getCardForUi((IPaperCard) item);
|
||||
// Amonkhet Invocations
|
||||
noBorder |= cv.getCurrentState().getSetCode().equalsIgnoreCase("MPS_AKH");
|
||||
// Unstable basic lands
|
||||
@@ -1174,27 +1205,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
g.setColor(Color.black);
|
||||
g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, cornerSize, cornerSize);
|
||||
|
||||
InventoryItem item = itemInfo.item;
|
||||
|
||||
boolean tryAltState = false;
|
||||
if (hoveredItem == null || hoveredItem.item != item) {
|
||||
if (item instanceof PaperCard) {
|
||||
if (ImageUtil.hasBackFacePicture(((PaperCard)item))) {
|
||||
if (item.equals(lastAltCard)) {
|
||||
tryAltState = true;
|
||||
lastAltCard = null;
|
||||
}
|
||||
else {
|
||||
lastAltCard = item;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastAltCard = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BufferedImage img = ImageCache.getImage(item, bounds.width - 2 * borderSize, bounds.height - 2 * borderSize, tryAltState);
|
||||
BufferedImage img = ImageCache.getImage(item, bounds.width - 2 * borderSize, bounds.height - 2 * borderSize, itemInfo.alt);
|
||||
|
||||
if (img != null) {
|
||||
g.drawImage(img, null, bounds.x + borderSize, bounds.y + borderSize);
|
||||
|
||||
@@ -257,6 +257,7 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
initializeStackAdditionsComboBox();
|
||||
initializeLandPlayedComboBox();
|
||||
initializeColorIdentityCombobox();
|
||||
initializeSwitchStatesCombobox();
|
||||
initializeAutoYieldModeComboBox();
|
||||
initializeCounterDisplayTypeComboBox();
|
||||
initializeCounterDisplayLocationComboBox();
|
||||
@@ -480,6 +481,15 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
panel.setComboBox(comboBox, selectedItem);
|
||||
}
|
||||
|
||||
private void initializeSwitchStatesCombobox() {
|
||||
final String[] elems = {ForgeConstants.SWITCH_CARDSTATES_DECK_NEVER, ForgeConstants.SWITCH_CARDSTATES_DECK_HOVER, ForgeConstants.SWITCH_CARDSTATES_DECK_ALWAYS};
|
||||
final FPref userSetting = FPref.UI_SWITCH_STATES_DECKVIEW;
|
||||
final FComboBoxPanel<String> panel = this.view.getSwitchStates();
|
||||
final FComboBox<String> comboBox = createComboBox(elems, userSetting);
|
||||
final String selectedItem = this.prefs.getPref(userSetting);
|
||||
panel.setComboBox(comboBox, selectedItem);
|
||||
}
|
||||
|
||||
private void initializeAutoYieldModeComboBox() {
|
||||
final String[] elems = {ForgeConstants.AUTO_YIELD_PER_ABILITY, ForgeConstants.AUTO_YIELD_PER_CARD};
|
||||
final FPref userSetting = FPref.UI_AUTO_YIELD_MODE;
|
||||
|
||||
@@ -143,6 +143,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
private final FComboBoxPanel<String> cbpGraveyardOrdering = new FComboBoxPanel<>(localizer.getMessage("cbpGraveyardOrdering")+":");
|
||||
private final FComboBoxPanel<String> cbpDefaultLanguage = new FComboBoxPanel<>(localizer.getMessage("cbpSelectLanguage")+":");
|
||||
private final FComboBoxPanel<String> cbpAutoUpdater = new FComboBoxPanel<>(localizer.getMessage("cbpAutoUpdater")+":");
|
||||
private final FComboBoxPanel<String> cbpSwitchStates = new FComboBoxPanel<>(localizer.getMessage("cbpSwitchStates")+":");
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -384,6 +385,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
pnlPrefs.add(cbpDisplayCurrentCardColors, comboBoxConstraints);
|
||||
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlDisplayCurrentCardColors")), descriptionConstraints);
|
||||
|
||||
pnlPrefs.add(cbpSwitchStates, comboBoxConstraints);
|
||||
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlSwitchStates")), descriptionConstraints);
|
||||
|
||||
// Sound options
|
||||
pnlPrefs.add(new SectionLabel(localizer.getMessage("SoundOptions")), sectionConstraints + ", gaptop 2%");
|
||||
|
||||
@@ -732,6 +736,10 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
return cbpDisplayCurrentCardColors;
|
||||
}
|
||||
|
||||
public FComboBoxPanel<String> getSwitchStates() {
|
||||
return cbpSwitchStates;
|
||||
}
|
||||
|
||||
public FComboBoxPanel<CloseAction> getCloseActionComboBoxPanel() {
|
||||
return cbpCloseAction;
|
||||
}
|
||||
|
||||
@@ -39,11 +39,15 @@ public class CDetailPicture {
|
||||
return cPicture;
|
||||
}
|
||||
|
||||
public void displayAlt(final boolean showAlt) {
|
||||
isDisplayAlt = showAlt;
|
||||
}
|
||||
|
||||
public void showCard(final CardView c, final boolean showAlt) {
|
||||
currentView = c;
|
||||
final boolean mayView = mayView(), mayFlip = mayView && mayFlip();
|
||||
final boolean mayFlip = mayView() && mayFlip();
|
||||
isDisplayAlt = mayFlip && showAlt;
|
||||
alwaysDisplayAlt = mayView && mayFlip && c.isFaceDown();
|
||||
alwaysDisplayAlt = mayFlip && c.isFaceDown();
|
||||
|
||||
update();
|
||||
}
|
||||
@@ -65,7 +69,7 @@ public class CDetailPicture {
|
||||
c.getCurrentState().setFoilIndexOverride(1);
|
||||
}
|
||||
}
|
||||
showCard(c, false);
|
||||
showCard(c, isDisplayAlt);
|
||||
} else {
|
||||
currentView = null;
|
||||
isDisplayAlt = false;
|
||||
|
||||
Reference in New Issue
Block a user