mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Merge remote-tracking branch 'upstream/master' into deck-importer-decks-file-format
This commit is contained in:
@@ -1,3 +1,52 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
# returns the JDK version.
|
||||
# 8 for 1.8.0_nn, 9 for 9-ea etc, and "no_java" for undetected
|
||||
# Based on the code from this source: https://eed3si9n.com/detecting-java-version-bash
|
||||
jdk_version() {
|
||||
local result
|
||||
local java_cmd
|
||||
if [[ -n $(type -p java) ]]
|
||||
then
|
||||
java_cmd=java
|
||||
elif [[ (-n "$JAVA_HOME") && (-x "$JAVA_HOME/bin/java") ]]
|
||||
then
|
||||
java_cmd="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
local IFS=$'\n'
|
||||
# remove \r for Cygwin
|
||||
local lines=$("$java_cmd" -Xms32M -Xmx32M -version 2>&1 | tr '\r' '\n')
|
||||
if [[ -z $java_cmd ]]
|
||||
then
|
||||
result=no_java
|
||||
else
|
||||
for line in $lines; do
|
||||
if [[ (-z $result) && ($line = *"version \""*) ]]
|
||||
then
|
||||
local ver=$(echo $line | sed -e 's/.*version "\(.*\)"\(.*\)/\1/; 1q')
|
||||
# on macOS, sed doesn't support '?'
|
||||
if [[ $ver = "1."* ]]
|
||||
then
|
||||
result=$(echo $ver | sed -e 's/1\.\([0-9]*\)\(.*\)/\1/; 1q')
|
||||
else
|
||||
result=$(echo $ver | sed -e 's/\([0-9]*\)\(.*\)/\1/; 1q')
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
echo "$result"
|
||||
}
|
||||
v="$(jdk_version)"
|
||||
|
||||
SHAREDPARAMS='-Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$'
|
||||
cd $(dirname "${0}")
|
||||
java -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
|
||||
if [[ $v -ge 17 ]]
|
||||
then
|
||||
java --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED $SHAREDPARAMS
|
||||
elif [[ $v -ge 11 ]]
|
||||
then
|
||||
java --illegal-access=permit $SHAREDPARAMS
|
||||
else
|
||||
java $SHAREDPARAMS
|
||||
fi
|
||||
|
||||
@@ -371,7 +371,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
@Override
|
||||
public void deckTypeSelected(final DecksComboBoxEvent ev) {
|
||||
if (ev.getDeckType() == DeckType.NET_ARCHIVE_STANDARD_DECK && !refreshingDeckType) {
|
||||
if(lstDecks.getGameType() != GameType.Constructed)
|
||||
if (lstDecks.getGameType() != GameType.Constructed)
|
||||
return;
|
||||
FThreads.invokeInBackgroundThread(new Runnable() { //needed for loading net decks
|
||||
@Override
|
||||
@@ -398,7 +398,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
return;
|
||||
|
||||
} else if (ev.getDeckType() == DeckType.NET_ARCHIVE_PIONEER_DECK && !refreshingDeckType) {
|
||||
if(lstDecks.getGameType() != GameType.Constructed)
|
||||
if (lstDecks.getGameType() != GameType.Constructed)
|
||||
return;
|
||||
FThreads.invokeInBackgroundThread(new Runnable() { //needed for loading net decks
|
||||
@Override
|
||||
@@ -424,7 +424,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
return;
|
||||
|
||||
} else if (ev.getDeckType() == DeckType.NET_ARCHIVE_MODERN_DECK && !refreshingDeckType) {
|
||||
if(lstDecks.getGameType() != GameType.Constructed)
|
||||
if (lstDecks.getGameType() != GameType.Constructed)
|
||||
return;
|
||||
FThreads.invokeInBackgroundThread(new Runnable() { //needed for loading net decks
|
||||
@Override
|
||||
@@ -450,7 +450,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
return;
|
||||
|
||||
} else if (ev.getDeckType() == DeckType.NET_ARCHIVE_PAUPER_DECK && !refreshingDeckType) {
|
||||
if(lstDecks.getGameType() != GameType.Constructed)
|
||||
if (lstDecks.getGameType() != GameType.Constructed)
|
||||
return;
|
||||
FThreads.invokeInBackgroundThread(new Runnable() { //needed for loading net decks
|
||||
@Override
|
||||
@@ -476,7 +476,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
return;
|
||||
|
||||
} else if (ev.getDeckType() == DeckType.NET_ARCHIVE_LEGACY_DECK && !refreshingDeckType) {
|
||||
if(lstDecks.getGameType() != GameType.Constructed)
|
||||
if (lstDecks.getGameType() != GameType.Constructed)
|
||||
return;
|
||||
FThreads.invokeInBackgroundThread(new Runnable() { //needed for loading net decks
|
||||
@Override
|
||||
@@ -502,7 +502,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
return;
|
||||
|
||||
} else if (ev.getDeckType() == DeckType.NET_ARCHIVE_VINTAGE_DECK && !refreshingDeckType) {
|
||||
if(lstDecks.getGameType() != GameType.Constructed)
|
||||
if (lstDecks.getGameType() != GameType.Constructed)
|
||||
return;
|
||||
FThreads.invokeInBackgroundThread(new Runnable() { //needed for loading net decks
|
||||
@Override
|
||||
@@ -528,7 +528,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
return;
|
||||
|
||||
} else if (ev.getDeckType() == DeckType.NET_ARCHIVE_BLOCK_DECK && !refreshingDeckType) {
|
||||
if(lstDecks.getGameType() != GameType.Constructed)
|
||||
if (lstDecks.getGameType() != GameType.Constructed)
|
||||
return;
|
||||
FThreads.invokeInBackgroundThread(new Runnable() { //needed for loading net decks
|
||||
@Override
|
||||
@@ -712,7 +712,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
prefs.save();
|
||||
}
|
||||
|
||||
|
||||
private String getState() {
|
||||
final StringBuilder state = new StringBuilder();
|
||||
DeckType selectedDeckType = this.selectedDeckType; // decksComboBox.getDeckType()
|
||||
@@ -827,7 +826,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<String> getSelectedDecksFromSavedState(final String savedState) {
|
||||
try {
|
||||
if (StringUtils.isBlank(savedState)) {
|
||||
|
||||
@@ -216,7 +216,6 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
}
|
||||
|
||||
for (final Entry<TItem, Integer> itemEntry : itemsToAdd) {
|
||||
|
||||
final TItem item = itemEntry.getKey();
|
||||
final PaperCard card = item instanceof PaperCard ? (PaperCard)item : null;
|
||||
int qty = itemEntry.getValue();
|
||||
@@ -224,8 +223,7 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
int max;
|
||||
if (deck == null || card == null || limit == CardLimit.None || DeckFormat.canHaveAnyNumberOf(card)) {
|
||||
max = Integer.MAX_VALUE;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
max = (limit == CardLimit.Singleton ? 1 : FModel.getPreferences().getPrefInt(FPref.DECK_DEFAULT_CARD_LIMIT));
|
||||
|
||||
Integer cardCopies = DeckFormat.canHaveSpecificNumberInDeck(card);
|
||||
@@ -538,16 +536,16 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
CardManager cardManager = (CardManager) CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController().getDeckManager();
|
||||
PaperCard existingCard = cardManager.getSelectedItem();
|
||||
// make a foiled version based on the original
|
||||
PaperCard foiledCard = existingCard.getFoiled();
|
||||
PaperCard foiledCard = existingCard.isFoil() ? existingCard.getUnFoiled() : existingCard.getFoiled();
|
||||
// remove *quantity* instances of existing card
|
||||
CDeckEditorUI.SINGLETON_INSTANCE.removeSelectedCards(false, quantity);
|
||||
// add *quantity* into the deck and set them as selected
|
||||
cardManager.addItem(foiledCard, quantity);
|
||||
cardManager.setSelectedItem(foiledCard);
|
||||
}
|
||||
}, true, true);
|
||||
}, true, true);
|
||||
}
|
||||
//TODO: need to translate getItemDisplayString
|
||||
//TODO: need to translate getItemDisplayString
|
||||
private void addItem(final String verb, final String dest, final boolean toAlternate, final int qty, final int shortcutModifiers) {
|
||||
String label = verb + " " + SItemManagerUtil.getItemDisplayString(getItemManager().getSelectedItems(), qty, false);
|
||||
if (dest != null && !dest.isEmpty()) {
|
||||
@@ -563,8 +561,7 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
}
|
||||
if (isAddContextMenu) {
|
||||
CDeckEditorUI.SINGLETON_INSTANCE.addSelectedCards(toAlternate, quantity);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
CDeckEditorUI.SINGLETON_INSTANCE.removeSelectedCards(toAlternate, quantity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import forge.gui.framework.FScreen;
|
||||
import forge.item.PaperCard;
|
||||
import forge.itemmanager.CardManager;
|
||||
import forge.itemmanager.ItemManagerConfig;
|
||||
import forge.itemmanager.filters.DeckSetFilter;
|
||||
import forge.localinstance.properties.ForgePreferences.FPref;
|
||||
import forge.model.FModel;
|
||||
import forge.screens.deckeditor.AddBasicLandsDialog;
|
||||
|
||||
@@ -86,10 +86,9 @@ public class DeckController<T extends DeckBase> {
|
||||
/**
|
||||
* Load deck from file or clipboard
|
||||
*/
|
||||
public void loadDeck(Deck deck){
|
||||
public void loadDeck(Deck deck) {
|
||||
this.loadDeck(deck, true);
|
||||
}
|
||||
|
||||
public void loadDeck(Deck deck, boolean substituteCurrentDeck) {
|
||||
boolean isStored;
|
||||
if (view.getCatalogManager().isInfinite()) {
|
||||
@@ -159,7 +158,6 @@ public class DeckController<T extends DeckBase> {
|
||||
}
|
||||
|
||||
private void pickFromCatalog(Map<String, Integer> countByName, CardPool catalog, CardPool targetSection) {
|
||||
|
||||
CardPool catalogClone = new CardPool(catalog); // clone to iterate modified collection
|
||||
for (Map.Entry<PaperCard, Integer> entry : catalogClone) {
|
||||
PaperCard availableCard = entry.getKey();
|
||||
@@ -218,7 +216,6 @@ public class DeckController<T extends DeckBase> {
|
||||
public void setModel(final T document) {
|
||||
setModel(document, false);
|
||||
}
|
||||
|
||||
private void setModel(final T document, final boolean isStored) {
|
||||
model = document;
|
||||
onModelChanged(isStored);
|
||||
@@ -234,8 +231,7 @@ public class DeckController<T extends DeckBase> {
|
||||
if (isStored) {
|
||||
if (isModelInSyncWithFolder()) {
|
||||
setSaved(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
notifyModelChanged();
|
||||
}
|
||||
} else { //TODO: Make this smarter
|
||||
@@ -317,8 +313,7 @@ public class DeckController<T extends DeckBase> {
|
||||
final T newModel = currentFolder.get(name);
|
||||
if (newModel != null) {
|
||||
setModel((T) newModel.copyTo(name), true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setSaved(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -96,7 +95,6 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
pnlContent.setOpaque(false);
|
||||
|
||||
if (javaRecentEnough()) {
|
||||
|
||||
// With Blacksmith we would upload the releases and the /latest would redirect to the right URL
|
||||
// That currently doesn't happen so lets comment out this button for now
|
||||
// pnlContent.add(btnCheckForUpdates, constraintsBTN);
|
||||
@@ -122,9 +120,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
|
||||
pnlContent.add(btnDownloadSkins, constraintsBTN);
|
||||
pnlContent.add(_makeLabel(localizer.getMessage("lblDownloadSkins")), constraintsLBL);
|
||||
|
||||
} else {
|
||||
|
||||
String text = localizer.getMessage("lblYourVersionOfJavaIsTooOld");
|
||||
FLabel label = new FLabel.Builder().fontAlign(SwingConstants.CENTER).text(text).fontStyle(Font.BOLD).fontSize(18).build();
|
||||
pnlContent.add(label, "w 90%!, h 25px!, center, gap 0 0 30px 3px");
|
||||
@@ -137,7 +133,6 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
text = text + " . " + localizer.getMessage("lblYouNeedAtLeastJavaVersion") ;
|
||||
label = new FLabel.Builder().fontAlign(SwingConstants.CENTER).text(text).fontStyle(Font.BOLD).fontSize(18).build();
|
||||
pnlContent.add(label, "w 90%!, h 25px!, center, gap 0 0 0 36px");
|
||||
|
||||
}
|
||||
|
||||
pnlContent.add(btnListImageData, constraintsBTN);
|
||||
@@ -154,15 +149,12 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
|
||||
pnlContent.add(btnLicensing, constraintsBTN);
|
||||
pnlContent.add(_makeLabel(localizer.getMessage("lblLicensing")), constraintsLBL);
|
||||
|
||||
}
|
||||
|
||||
private boolean javaRecentEnough() {
|
||||
|
||||
RuntimeVersion javaVersion = RuntimeVersion.of(System.getProperty("java.version"));
|
||||
|
||||
return javaVersion.getMajor() >= 9 || (javaVersion.getMajor() >= 1 && (javaVersion.getMinor() > 8 || (javaVersion.getMinor() == 8 && javaVersion.getUpdate() >= 101)));
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -199,7 +191,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
public void setHowToPlayCommand(UiCommand command) { btnHowToPlay.setCommand(command); }
|
||||
public void setDownloadPricesCommand(UiCommand command) { btnDownloadPrices.setCommand(command); }
|
||||
public void setLicensingCommand(UiCommand command) { btnLicensing.setCommand(command); }
|
||||
public void setDownloadSkinsCommand(UiCommand command) { btnDownloadSkins.setCommand(command); }
|
||||
public void setDownloadSkinsCommand(UiCommand command) { btnDownloadSkins.setCommand(command); }
|
||||
|
||||
public void focusTopButton() {
|
||||
btnDownloadPics.requestFocusInWindow();
|
||||
@@ -269,7 +261,6 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
|
||||
String imagePath;
|
||||
int artIndex = 1;
|
||||
ArrayList<String> cis = new ArrayList<>();
|
||||
|
||||
HashMap<String, Pair<Boolean, Integer>> cardCount = new HashMap<>();
|
||||
for (CardInSet c : e.getAllCardsInSet()) {
|
||||
@@ -302,10 +293,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// check the front image
|
||||
//
|
||||
imagePath = ImageUtil.getImageRelativePath(cp, false, true, false);
|
||||
if (imagePath != null) {
|
||||
File file = ImageKeys.getImageFile(imagePath);
|
||||
@@ -319,9 +307,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// check the back face
|
||||
//
|
||||
if (cp.hasBackFace()) {
|
||||
imagePath = ImageUtil.getImageRelativePath(cp, true, true, false);
|
||||
if (imagePath != null) {
|
||||
@@ -372,7 +358,6 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
nifSB.append("\n");
|
||||
}
|
||||
|
||||
|
||||
String totalStats = "Missing images: " + missingCount + "\nUnimplemented cards: " + notImplementedCount + "\n";
|
||||
cniSB.append("\n-----------\n");
|
||||
cniSB.append(totalStats);
|
||||
@@ -424,7 +409,6 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void showLicensing() {
|
||||
String license = "<html>Forge License Information<br><br>"
|
||||
|
||||
@@ -23,7 +23,7 @@ public class IntegerConstraint {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if( min == max ) {
|
||||
if (min == max) {
|
||||
return String.valueOf( min );
|
||||
}
|
||||
return "between " + min + " and " + max;
|
||||
|
||||
Reference in New Issue
Block a user