Merge remote-tracking branch 'origin/master' into code-cleanup

# Conflicts:
#	forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java
#	forge-ai/src/main/java/forge/ai/ability/ScryAi.java
#	forge-core/src/main/java/forge/card/DeckHints.java
#	forge-core/src/main/java/forge/util/TextUtil.java
#	forge-gui-mobile/src/forge/itemmanager/ItemManager.java
#	forge-gui/src/main/java/forge/download/AutoUpdater.java
#	forge-gui/src/main/java/forge/player/HumanCostDecision.java
This commit is contained in:
Jetz
2024-11-08 18:37:02 -05:00
788 changed files with 18855 additions and 5648 deletions

View File

@@ -9,17 +9,16 @@ java -version 1>nul 2>nul || (
)
for /f tokens^=2^ delims^=.-_^+^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j"
if %jver% LEQ 16 (
echo unsupported java
popd
exit /b 2
)
if %jver% GEQ 17 (
java --add-opens java.desktop/java.beans=ALL-UNNAMED --add-opens java.desktop/javax.swing.border=ALL-UNNAMED --add-opens java.desktop/javax.swing.event=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/java.awt.image=ALL-UNNAMED --add-opens java.desktop/java.awt.color=ALL-UNNAMED --add-opens java.desktop/sun.awt.image=ALL-UNNAMED --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=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 --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
java -Xmx4096m $mandatory.java.args$ -jar $project.build.finalName$
popd
exit /b 0
)
if %jver% GEQ 11 (
java --illegal-access=permit -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
popd
exit /b 0
)
java -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
popd

View File

@@ -1,3 +1,3 @@
#!/bin/sh
cd $(dirname "${0}")
java -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
java -Xmx4096m $mandatory.java.args$ -jar $project.build.finalName$

View File

@@ -1,52 +1,3 @@
#!/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$ '"$@"
#!/bin/sh
cd $(dirname "${0}")
if [[ $v -ge 17 ]]
then
java --add-opens java.desktop/java.beans=ALL-UNNAMED --add-opens java.desktop/java.awt.color=ALL-UNNAMED --add-opens java.desktop/javax.swing.border=ALL-UNNAMED --add-opens java.desktop/javax.swing.event=ALL-UNNAMED --add-opens java.desktop/sun.awt.image=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=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 --add-opens java.desktop/java.awt.image=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true $SHAREDPARAMS
elif [[ $v -ge 11 ]]
then
java --illegal-access=permit $SHAREDPARAMS
else
java $SHAREDPARAMS
fi
java -Xmx4096m $mandatory.java.args$ -jar $project.build.finalName$

View File

@@ -26,7 +26,10 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import javax.swing.ImageIcon;
@@ -61,11 +64,16 @@ import forge.player.GamePlayerUtil;
import forge.screens.deckeditor.CDeckEditorUI;
import forge.toolbox.FOptionPane;
import forge.toolbox.FSkin;
import forge.util.BuildInfo;
import forge.util.FileUtil;
import forge.util.Localizer;
import forge.util.RestartUtil;
import forge.util.TextUtil;
import forge.view.FFrame;
import forge.view.FView;
import static forge.localinstance.properties.ForgeConstants.DAILY_SNAPSHOT_URL;
/**
* <p>
* FControl.
@@ -83,6 +91,10 @@ public enum FControl implements KeyEventDispatcher {
private boolean altKeyLastDown;
private CloseAction closeAction;
private final List<HostedMatch> currentMatches = Lists.newArrayList();
private String snapsVersion = "", currentVersion = "";
private Date snapsTimestamp = null, buildTimeStamp = null;
private boolean isSnapshot, hasSnapsUpdate;
private Localizer localizer;
public enum CloseAction {
NONE,
@@ -90,6 +102,12 @@ public enum FControl implements KeyEventDispatcher {
EXIT_FORGE
}
public Localizer getLocalizer() {
if (localizer == null)
localizer = Localizer.getInstance();
return localizer;
}
private boolean hasCurrentMatches() {
cleanMatches();
return !currentMatches.isEmpty();
@@ -122,36 +140,37 @@ public enum FControl implements KeyEventDispatcher {
* instantiated separately by each screen's top level view class.
*/
FControl() {
final Localizer localizer = Localizer.getInstance();
Singletons.getView().getFrame().addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent e) {
switch (closeAction) {
case NONE: //prompt user for close action if not previously specified
final List<String> options = ImmutableList.of(localizer.getMessage("lblCloseScreen"), localizer.getMessage("lblExitForge"), localizer.getMessage("lblCancel"));
final int reply = FOptionPane.showOptionDialog(
localizer.getMessage("txCloseAction1") + "\n\n" + localizer.getMessage("txCloseAction2"),
localizer.getMessage("titCloseAction"),
FOptionPane.INFORMATION_ICON,
options,
2);
switch (reply) {
case 0: //Close Screen
setCloseAction(CloseAction.CLOSE_SCREEN);
windowClosing(e); //call again to apply chosen close action
return;
case 1: //Exit Forge
setCloseAction(CloseAction.EXIT_FORGE);
windowClosing(e); //call again to apply chosen close action
return;
}
break;
case CLOSE_SCREEN:
Singletons.getView().getNavigationBar().closeSelectedTab();
break;
case EXIT_FORGE:
if (exitForge()) { return; }
break;
case NONE: //prompt user for close action if not previously specified
final List<String> options = ImmutableList.of(getLocalizer().getMessage("lblCloseScreen"), getLocalizer().getMessage("lblExitForge"), getLocalizer().getMessage("lblCancel"));
final int reply = FOptionPane.showOptionDialog(
getLocalizer().getMessage("txCloseAction1") + "\n\n" + getLocalizer().getMessage("txCloseAction2"),
getLocalizer().getMessage("titCloseAction"),
FOptionPane.INFORMATION_ICON,
options,
2);
switch (reply) {
case 0: //Close Screen
setCloseAction(CloseAction.CLOSE_SCREEN);
windowClosing(e); //call again to apply chosen close action
return;
case 1: //Exit Forge
setCloseAction(CloseAction.EXIT_FORGE);
windowClosing(e); //call again to apply chosen close action
return;
}
break;
case CLOSE_SCREEN:
Singletons.getView().getNavigationBar().closeSelectedTab();
break;
case EXIT_FORGE:
if (exitForge()) {
return;
}
break;
}
//prevent closing Forge if we reached this point
Singletons.getView().getFrame().setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
@@ -159,12 +178,22 @@ public enum FControl implements KeyEventDispatcher {
});
}
public Date getBuildTimeStamp() {
return buildTimeStamp;
}
public Date getSnapsTimestamp() {
return snapsTimestamp;
}
public CloseAction getCloseAction() {
return closeAction;
}
public void setCloseAction(final CloseAction closeAction0) {
if (closeAction == closeAction0) { return; }
if (closeAction == closeAction0) {
return;
}
closeAction = closeAction0;
Singletons.getView().getNavigationBar().updateBtnCloseTooltip();
@@ -174,14 +203,13 @@ public enum FControl implements KeyEventDispatcher {
}
public boolean canExitForge(final boolean forRestart) {
final Localizer localizer = Localizer.getInstance();
final String action = (forRestart ? localizer.getMessage("lblRestart") : localizer.getMessage("lblExit"));
String userPrompt =(forRestart ? localizer.getMessage("lblAreYouSureYouWishRestartForge") : localizer.getMessage("lblAreYouSureYouWishExitForge"));
final String action = (forRestart ? getLocalizer().getMessage("lblRestart") : getLocalizer().getMessage("lblExit"));
String userPrompt = (forRestart ? getLocalizer().getMessage("lblAreYouSureYouWishRestartForge") : getLocalizer().getMessage("lblAreYouSureYouWishExitForge"));
final boolean hasCurrentMatches = hasCurrentMatches();
if (hasCurrentMatches) {
userPrompt = localizer.getMessage("lblOneOrMoreGamesActive") + ". " + userPrompt;
userPrompt = getLocalizer().getMessage("lblOneOrMoreGamesActive") + ". " + userPrompt;
}
if (!FOptionPane.showConfirmDialog(userPrompt, action + " Forge", action, localizer.getMessage("lblCancel"), !hasCurrentMatches)) { //default Yes if no game active
if (!FOptionPane.showConfirmDialog(userPrompt, action + " Forge", action, getLocalizer().getMessage("lblCancel"), !hasCurrentMatches)) { //default Yes if no game active
return false;
}
return CDeckEditorUI.SINGLETON_INSTANCE.canSwitchAway(true);
@@ -208,23 +236,39 @@ public enum FControl implements KeyEventDispatcher {
return true;
}
/** After view and model have been initialized, control can start.*/
/**
* After view and model have been initialized, control can start.
*/
public void initialize() {
final ForgePreferences prefs = FModel.getPreferences();
currentVersion = BuildInfo.getVersionString();
isSnapshot = currentVersion.contains("SNAPSHOT");
//get version string
try {
if (isSnapshot && prefs.getPrefBoolean(FPref.CHECK_SNAPSHOT_AT_STARTUP)) {
URL url = new URL(DAILY_SNAPSHOT_URL + "version.txt");
snapsVersion = FileUtil.readFileToString(url);
url = new URL(DAILY_SNAPSHOT_URL + "build.txt");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
snapsTimestamp = simpleDateFormat.parse(FileUtil.readFileToString(url));
buildTimeStamp = BuildInfo.getTimestamp();
hasSnapsUpdate = BuildInfo.verifyTimestamp(snapsTimestamp);
}
} catch (Exception ignored) {
}
// Preloads skin components (using progress bar).
FSkin.loadFull(true);
display = FView.SINGLETON_INSTANCE.getLpnDocument();
final ForgePreferences prefs = FModel.getPreferences();
//set ExperimentalNetworkOption from preference
boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT);
GuiBase.enablePropertyConfig(propertyConfig);
closeAction = CloseAction.valueOf(prefs.getPref(FPref.UI_CLOSE_ACTION));
final Localizer localizer = Localizer.getInstance();
FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(localizer.getMessage("lblLoadingQuest"));
FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(getLocalizer().getMessage("lblLoadingQuest"));
// Preload quest data if present
final File dirQuests = new File(ForgeConstants.QUEST_SAVE_DIR);
final String questname = FModel.getQuestPreferences().getPref(QPref.CURRENT_QUEST);
@@ -232,12 +276,16 @@ public enum FControl implements KeyEventDispatcher {
if (data.exists()) {
try {
FModel.getQuest().load(QuestDataIO.loadData(data));
} catch(IOException ex) {
} catch (IOException ex) {
ex.printStackTrace();
System.err.printf("Error loading quest data (%s).. skipping for now..%n", questname);
}
}
// format release notes upon loading
try {
TextUtil.getFormattedChangelog(new File(FileUtil.pathCombine(System.getProperty("user.dir"), ForgeConstants.CHANGES_FILE_NO_RELEASE)), "");
} catch (Exception e) {
}
// Handles resizing in null layouts of layers in JLayeredPane as well as saving window layout
final FFrame window = Singletons.getView().getFrame();
window.addComponentListener(new ComponentAdapter() {
@@ -259,10 +307,20 @@ public enum FControl implements KeyEventDispatcher {
FView.SINGLETON_INSTANCE.getLpnDocument().addComponentListener(SResizingUtil.getWindowResizeListener());
setGlobalKeyboardHandler();
FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(localizer.getMessage("lblOpeningMainWindow"));
FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(getLocalizer().getMessage("lblOpeningMainWindow"));
SwingUtilities.invokeLater(() -> Singletons.getView().initialize());
}
public boolean isSnapshot() {
return isSnapshot;
}
public String getSnapshotNotification() {
if (!isSnapshot || !hasSnapsUpdate || snapsVersion.isEmpty())
return "";
return getLocalizer().getMessage("lblNewSnapshotVersion", snapsVersion);
}
private void setGlobalKeyboardHandler() {
final KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
manager.addKeyEventDispatcher(this);
@@ -285,6 +343,7 @@ public enum FControl implements KeyEventDispatcher {
public boolean setCurrentScreen(final FScreen screen) {
return setCurrentScreen(screen, false);
}
public boolean setCurrentScreen(final FScreen screen, final boolean previousScreenClosed) {
//TODO: Uncomment the line below if this function stops being used to refresh
//the current screen in some places (such as Continue and Restart in the match screen)
@@ -313,8 +372,7 @@ public enum FControl implements KeyEventDispatcher {
try {
SLayoutIO.loadLayout(null);
} catch (final InvalidLayoutFileException ex) {
final Localizer localizer = Localizer.getInstance();
SOptionPane.showMessageDialog(String.format(localizer.getMessage("lblerrLoadingLayoutFile"), screen.getTabCaption()), "Warning!");
SOptionPane.showMessageDialog(String.format(getLocalizer().getMessage("lblerrLoadingLayoutFile"), screen.getTabCaption()), "Warning!");
if (screen.deleteLayoutFile()) {
SLayoutIO.loadLayout(null); //try again
}
@@ -334,11 +392,11 @@ public enum FControl implements KeyEventDispatcher {
FView.SINGLETON_INSTANCE.getPnlInsets().setForegroundImage(FSkin.getIcon(FSkinProp.BG_NIGHT), true);
}
} else {
FView.SINGLETON_INSTANCE.getPnlInsets().setForegroundImage((Image)null);
FView.SINGLETON_INSTANCE.getPnlInsets().setForegroundImage((Image) null);
}
//SOverlayUtils.showTargetingOverlay();
} else {
FView.SINGLETON_INSTANCE.getPnlInsets().setForegroundImage((Image)null);
FView.SINGLETON_INSTANCE.getPnlInsets().setForegroundImage((Image) null);
}
Singletons.getView().getNavigationBar().updateSelectedTab();
@@ -350,12 +408,16 @@ public enum FControl implements KeyEventDispatcher {
}
public boolean ensureScreenActive(final FScreen screen) {
if (currentScreen == screen) { return true; }
if (currentScreen == screen) {
return true;
}
return setCurrentScreen(screen);
}
/** Remove all children from a specified layer. */
/**
* Remove all children from a specified layer.
*/
private void clearChildren(final int layer0) {
final Component[] children = FView.SINGLETON_INSTANCE.getLpnDocument().getComponentsInLayer(layer0);
@@ -364,16 +426,24 @@ public enum FControl implements KeyEventDispatcher {
}
}
/** Sizes children of JLayeredPane to fully fit their layers. */
/**
* Sizes children of JLayeredPane to fully fit their layers.
*/
private void sizeChildren() {
Component[] children = display.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
if (children.length != 0) { children[0].setSize(display.getSize()); }
if (children.length != 0) {
children[0].setSize(display.getSize());
}
children = display.getComponentsInLayer(FView.TARGETING_LAYER);
if (children.length != 0) { children[0].setSize(display.getSize()); }
if (children.length != 0) {
children[0].setSize(display.getSize());
}
children = display.getComponentsInLayer(JLayeredPane.MODAL_LAYER);
if (children.length != 0) { children[0].setSize(display.getSize()); }
if (children.length != 0) {
children[0].setSize(display.getSize());
}
}
public Dimension getDisplaySize() {
@@ -392,18 +462,15 @@ public enum FControl implements KeyEventDispatcher {
forgeMenu.show(true);
return true;
}
}
else if (e.getID() == KeyEvent.KEY_PRESSED && e.getModifiersEx() == InputEvent.ALT_DOWN_MASK) {
} else if (e.getID() == KeyEvent.KEY_PRESSED && e.getModifiersEx() == InputEvent.ALT_DOWN_MASK) {
altKeyLastDown = true;
}
}
else {
} else {
altKeyLastDown = false;
if (e.getID() == KeyEvent.KEY_PRESSED) {
//give Forge menu the chance to handle the key event
return forgeMenu.handleKeyEvent(e);
}
else if (e.getID() == KeyEvent.KEY_RELEASED) {
} else if (e.getID() == KeyEvent.KEY_RELEASED) {
if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) {
forgeMenu.show();
}

View File

@@ -16,6 +16,8 @@ import forge.util.BuildInfo;
import forge.util.FileUtil;
import forge.util.Localizer;
import static forge.localinstance.properties.ForgeConstants.GITHUB_FORGE_URL;
public final class HelpMenu {
private HelpMenu() { }
@@ -71,8 +73,8 @@ public final class HelpMenu {
JMenu mnu = new JMenu(localizer.getMessage("lblGettingStarted"));
mnu.add(getMenuItem_HowToPlayFile());
mnu.addSeparator();
mnu.add(getMenuItem_UrlLink("Forge Wiki", "https://github.com/Card-Forge/forge/wiki", KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)));
mnu.add(getMenuItem_UrlLink("What is Forge?", "https://github.com/Card-Forge/forge/wiki#what-is-forge"));
mnu.add(getMenuItem_UrlLink("Forge Wiki", GITHUB_FORGE_URL + "wiki", KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)));
mnu.add(getMenuItem_UrlLink("What is Forge?", GITHUB_FORGE_URL + "wiki#what-is-forge"));
return mnu;
}
@@ -143,6 +145,8 @@ public final class HelpMenu {
* @see http://stackoverflow.com/questions/6273221/open-a-text-file-in-the-default-text-editor-via-java
*/
private static void openFile(File file) throws IOException {
if (file == null)
return;
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
String cmd = "rundll32 url.dll,FileProtocolHandler " + file.getCanonicalPath();
Runtime.getRuntime().exec(cmd);

View File

@@ -2,6 +2,7 @@ package forge.screens.home.settings;
import javax.swing.SwingUtilities;
import forge.control.FControl;
import forge.download.AutoUpdater;
import forge.download.GuiDownloader;
import forge.gui.ImportDialog;
@@ -15,6 +16,11 @@ import forge.gui.download.GuiDownloadSetPicturesLQ;
import forge.gui.download.GuiDownloadSkins;
import forge.gui.error.BugReporter;
import forge.gui.framework.ICDoc;
import forge.util.RSSReader;
import java.util.concurrent.CompletableFuture;
import static forge.localinstance.properties.ForgeConstants.GITHUB_COMMITS_ATOM;
/**
* Controls the utilities submenu in the home UI.
@@ -27,7 +33,7 @@ public enum CSubmenuDownloaders implements ICDoc {
SINGLETON_INSTANCE;
private final UiCommand cmdLicensing = VSubmenuDownloaders.SINGLETON_INSTANCE::showLicensing;
private final UiCommand cmdCheckForUpdates = () -> new AutoUpdater(false).attemptToUpdate();
private final UiCommand cmdCheckForUpdates = () -> new AutoUpdater(false).attemptToUpdate(CompletableFuture.supplyAsync(() -> RSSReader.getCommitLog(GITHUB_COMMITS_ATOM, FControl.instance.getBuildTimeStamp(), FControl.instance.getSnapsTimestamp())));
private final UiCommand cmdPicDownload = () -> new GuiDownloader(new GuiDownloadPicturesLQ()).show();
private final UiCommand cmdPicDownloadHQ = () -> new GuiDownloader(new GuiDownloadPicturesHQ()).show();

View File

@@ -107,6 +107,7 @@ public enum CSubmenuPreferences implements ICDoc {
lstControls.add(Pair.of(view.getCbAnte(), FPref.UI_ANTE));
lstControls.add(Pair.of(view.getCbAnteMatchRarity(), FPref.UI_ANTE_MATCH_RARITY));
lstControls.add(Pair.of(view.getCbManaBurn(), FPref.UI_MANABURN));
lstControls.add(Pair.of(view.getCbOrderCombatants(), FPref.LEGACY_ORDER_COMBATANTS));
lstControls.add(Pair.of(view.getCbScaleLarger(), FPref.UI_SCALE_LARGER));
lstControls.add(Pair.of(view.getCbRenderBlackCardBorders(), FPref.UI_RENDER_BLACK_BORDERS));
lstControls.add(Pair.of(view.getCbLargeCardViewers(), FPref.UI_LARGE_CARD_VIEWERS));
@@ -137,6 +138,7 @@ public enum CSubmenuPreferences implements ICDoc {
lstControls.add(Pair.of(view.getCbTimedTargOverlay(), FPref.UI_TIMED_TARGETING_OVERLAY_UPDATES));
lstControls.add(Pair.of(view.getCbCompactMainMenu(), FPref.UI_COMPACT_MAIN_MENU));
lstControls.add(Pair.of(view.getCbUseSentry(), FPref.USE_SENTRY));
lstControls.add(Pair.of(view.getCbCheckSnapshot(), FPref.CHECK_SNAPSHOT_AT_STARTUP));
lstControls.add(Pair.of(view.getCbPromptFreeBlocks(), FPref.MATCHPREF_PROMPT_FREE_BLOCKS));
lstControls.add(Pair.of(view.getCbPauseWhileMinimized(), FPref.UI_PAUSE_WHILE_MINIMIZED));
lstControls.add(Pair.of(view.getCbWorkshopSyntax(), FPref.DEV_WORKSHOP_SYNTAX));
@@ -192,13 +194,11 @@ public enum CSubmenuPreferences implements ICDoc {
view.getBtnTokenPreviewer().setCommand((UiCommand) CSubmenuPreferences.this::openTokenPreviewer);
view.getBtnResetJavaFutureCompatibilityWarnings().setCommand((UiCommand) () -> {
prefs.setPref(FPref.DISABLE_DISPLAY_JAVA_8_UPDATE_WARNING, false);
prefs.save();
FOptionPane.showMessageDialog(localizer.getMessage("CompatibilityWarningsReEnabled"));
});
view.getBtnContentDirectoryUI().setCommand((UiCommand) CSubmenuPreferences.this::openContentDirectory);
view.getCbCheckSnapshot().addItemListener(e -> {
Singletons.getView().getNavigationBar().setUpdaterVisibility();
prefs.save();
});
initializeGameLogVerbosityComboBox();
initializeCloseActionComboBox();

View File

@@ -20,7 +20,11 @@ package forge.screens.home.settings;
import forge.gui.framework.ICDoc;
import forge.localinstance.properties.ForgeConstants;
import forge.util.BuildInfo;
import forge.util.FileUtil;
import forge.util.TextUtil;
import java.io.File;
/**
* Controller for VSubmenuReleaseNotes submenu in the home UI.
@@ -80,7 +84,8 @@ public enum CSubmenuReleaseNotes implements ICDoc {
String notes;
if (FileUtil.doesFileExist(filePath)) {
notes = filePath + "\n\n" + FileUtil.readFileToString(filePath);
// get release notes
notes = BuildInfo.getVersionString() +" Changelog:\n\n" + TextUtil.getFormattedChangelog(new File(filePath), ForgeConstants.CHANGES_FILE_NO_RELEASE);
} else if (FileUtil.doesFileExist(filePathRelease)) {
notes = filePathRelease + "\n\n" + FileUtil.readFileToString(filePathRelease);
} else {

View File

@@ -1,5 +1,6 @@
package forge.screens.home.settings;
import forge.control.FControl;
import forge.control.FControl.CloseAction;
import forge.control.KeyboardShortcuts;
import forge.control.KeyboardShortcuts.Shortcut;
@@ -55,7 +56,6 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final FLabel btnDeleteWorkshopUI = new FLabel.Builder().opaque(true).hoverable(true).text(localizer.getMessage("btnDeleteWorkshopUI")).build();
private final FLabel btnUserProfileUI = new FLabel.Builder().opaque(true).hoverable(true).text(localizer.getMessage("btnUserProfileUI")).build();
private final FLabel btnContentDirectoryUI = new FLabel.Builder().opaque(true).hoverable(true).text(localizer.getMessage("btnContentDirectoryUI")).build();
private final FLabel btnResetJavaFutureCompatibilityWarnings = new FLabel.Builder().opaque(true).hoverable(true).text(localizer.getMessage("btnResetJavaFutureCompatibilityWarnings")).build();
private final FLabel btnClearImageCache = new FLabel.Builder().opaque(true).hoverable(true).text(localizer.getMessage("btnClearImageCache")).build();
private final FLabel btnTokenPreviewer = new FLabel.Builder().opaque(true).hoverable(true).text(localizer.getMessage("btnTokenPreviewer")).build();
@@ -69,6 +69,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final JCheckBox cbAnteMatchRarity = new OptionsCheckBox(localizer.getMessage("cbAnteMatchRarity"));
private final JCheckBox cbEnableAICheats = new OptionsCheckBox(localizer.getMessage("cbEnableAICheats"));
private final JCheckBox cbManaBurn = new OptionsCheckBox(localizer.getMessage("cbManaBurn"));
private final JCheckBox cbOrderCombatants = new OptionsCheckBox(localizer.getMessage("cbOrderCombatants"));
private final JCheckBox cbManaLostPrompt = new OptionsCheckBox(localizer.getMessage("cbManaLostPrompt"));
private final JCheckBox cbDevMode = new OptionsCheckBox(localizer.getMessage("cbDevMode"));
private final JCheckBox cbLoadCardsLazily = new OptionsCheckBox(localizer.getMessage("cbLoadCardsLazily"));
@@ -112,6 +113,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final JCheckBox cbShowStormCount = new OptionsCheckBox(localizer.getMessage("cbShowStormCount"));
private final JCheckBox cbRemindOnPriority = new OptionsCheckBox(localizer.getMessage("cbRemindOnPriority"));
private final JCheckBox cbUseSentry = new OptionsCheckBox(localizer.getMessage("cbUseSentry"));
private final JCheckBox cbCheckSnapshot = new OptionsCheckBox(localizer.getMessage("cbSnapshotUpdate"));
private final JCheckBox cbEnableUnknownCards = new OptionsCheckBox(localizer.getMessage("lblEnableUnknownCards"));
private final JCheckBox cbEnableNonLegalCards = new OptionsCheckBox(localizer.getMessage("lblEnableNonLegalCards"));
private final JCheckBox cbAllowCustomCardsDeckConformance = new OptionsCheckBox(localizer.getMessage("lblAllowCustomCardsInDecks"));
@@ -193,7 +195,10 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbUseSentry, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlUseSentry")), descriptionConstraints);
pnlPrefs.add(btnResetJavaFutureCompatibilityWarnings, "w 300px!, h 30px!, gap 27px 0 0 20px, span 2 1");
if (FControl.instance.isSnapshot()) {
pnlPrefs.add(cbCheckSnapshot, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlSnapshotUpdate")), descriptionConstraints);
}
// Gameplay Options
pnlPrefs.add(new SectionLabel(localizer.getMessage("GamePlay")), sectionConstraints);
@@ -216,6 +221,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbManaBurn, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlManaBurn")), descriptionConstraints);
pnlPrefs.add(cbOrderCombatants, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlOrderCombatants")), descriptionConstraints);
pnlPrefs.add(cbManaLostPrompt, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlManaLostPrompt")), descriptionConstraints);
@@ -625,6 +633,11 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
return cbUseSentry;
}
/** @return {@link javax.swing.JCheckBox} */
public final JCheckBox getCbCheckSnapshot() {
return cbCheckSnapshot;
}
/** @return {@link javax.swing.JCheckBox} */
public final JCheckBox getCbRemoveSmall() {
return cbRemoveSmall;
@@ -709,6 +722,10 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
return cbManaBurn;
}
public JCheckBox getCbOrderCombatants() {
return cbOrderCombatants;
}
/** @return {@link javax.swing.JCheckBox} */
public JCheckBox getCbScaleLarger() {
return cbScaleLarger;
@@ -985,10 +1002,6 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
public final FLabel getBtnClearImageCache() { return btnClearImageCache; }
public final FLabel getBtnTokenPreviewer() { return btnTokenPreviewer; }
public final FLabel getBtnResetJavaFutureCompatibilityWarnings() {
return btnResetJavaFutureCompatibilityWarnings;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getDocumentID()
*/

View File

@@ -77,13 +77,19 @@ public class CCombat implements ICDoc {
}
display.append("\n");
PlayerView controller = null;
if (defender instanceof CardView) {
final PlayerView controller = ((CardView) defender).getController();
display.append(Lang.getInstance().getPossesive(controller.getName())).append(" ");
controller = ((CardView) defender).getController();
if (controller == null)
//shouldn't be null but display card's + controller ie Black Knight's controller
display.append(Lang.getInstance().getPossesive(defender.getName())).append(" controller");
else
display.append(Lang.getInstance().getPossesive(controller.getName())).append(" ");
}
display.append(defender).append(" is attacked by:\n");
if (controller == null)
display.append(" is attacked by:\n");
else
display.append(defender).append(" is attacked by:\n");
// Associate Bands, Attackers Blockers
boolean previousBand = false;

View File

@@ -699,7 +699,8 @@ public class FCardImageRenderer {
}
} else {
fillColorBackground(g, colors, x, y, w, h);
SkinIcon icon = FSkin.getIcon(FSkinProp.ICO_LOGO);
//Card Art Logo
SkinIcon icon = FSkin.getIcon(FSkinProp.ICO_CARDART);
float artWidth = (float)icon.getSizeForPaint(g).getWidth();
float artHeight = (float)icon.getSizeForPaint(g).getHeight();
if (artWidth / artHeight >= (float)w / (float)h) {

View File

@@ -12,10 +12,13 @@ import java.awt.Window;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.util.concurrent.CompletableFuture;
import javax.swing.SpringLayout;
import javax.swing.SwingUtilities;
import forge.control.FControl;
import forge.download.AutoUpdater;
import forge.gui.framework.ILocalRepaint;
import forge.toolbox.FSkin;
import forge.toolbox.FSkin.Colors;
@@ -23,6 +26,9 @@ import forge.toolbox.FSkin.SkinColor;
import forge.toolbox.FSkin.SkinnedLabel;
import forge.toolbox.FSkin.SkinnedMenuBar;
import forge.util.Localizer;
import forge.util.RSSReader;
import static forge.localinstance.properties.ForgeConstants.GITHUB_COMMITS_ATOM;
@SuppressWarnings("serial")
public abstract class FTitleBarBase extends SkinnedMenuBar {
@@ -42,6 +48,7 @@ public abstract class FTitleBarBase extends SkinnedMenuBar {
protected final FullScreenButton btnFullScreen = new FullScreenButton();
protected final MaximizeButton btnMaximize = new MaximizeButton();
protected final CloseButton btnClose = new CloseButton();
protected final UpdaterButton btnUpdateShortcut = new UpdaterButton();
protected FTitleBarBase(ITitleBarOwner owner0) {
this.owner = owner0;
@@ -71,6 +78,11 @@ public abstract class FTitleBarBase extends SkinnedMenuBar {
add(btnLockTitleBar);
layout.putConstraint(SpringLayout.EAST, btnLockTitleBar, 0, SpringLayout.WEST, btnMinimize);
layout.putConstraint(SpringLayout.SOUTH, btnLockTitleBar, 0, SpringLayout.SOUTH, btnMinimize);
add(btnUpdateShortcut);
layout.putConstraint(SpringLayout.EAST, btnUpdateShortcut, 0, SpringLayout.WEST, btnMinimize);
layout.putConstraint(SpringLayout.SOUTH, btnUpdateShortcut, 0, SpringLayout.SOUTH, btnMinimize);
}
else {
int offset = owner instanceof FDialog && ((FDialog)owner).allowResize() ? 0 : -1;
@@ -82,7 +94,10 @@ public abstract class FTitleBarBase extends SkinnedMenuBar {
public abstract void setTitle(String title);
public abstract void setIconImage(Image image);
public void setUpdaterVisibility() {
if (btnUpdateShortcut != null)
btnUpdateShortcut.updateVisibility();
}
public void updateButtons() {
boolean fullScreen = owner.isFullScreen();
btnLockTitleBar.setVisible(fullScreen);
@@ -408,4 +423,43 @@ public abstract class FTitleBarBase extends SkinnedMenuBar {
g2d.drawLine(x2, y1, x1, y2);
}
}
public class UpdaterButton extends TitleBarButton {
final int MARQUEE_SPEED_DIV = 50;
final int REPAINT_WITHIN_MS = 50;
final int wMod = 60;
final String displayText = FControl.instance.getSnapshotNotification();
public UpdaterButton() {
setToolTipText(Localizer.getInstance().getMessage("btnCheckForUpdates"));
setPreferredSize(new Dimension(160, 25));
updateVisibility();
}
@Override
protected void onClick() {
if (!displayText.isEmpty()) {
try {
new AutoUpdater(false).attemptToUpdate(CompletableFuture.supplyAsync(() -> RSSReader.getCommitLog(GITHUB_COMMITS_ATOM, FControl.instance.getBuildTimeStamp(), FControl.instance.getSnapsTimestamp())));
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public void paintComponent(Graphics g) {
if (displayText.isEmpty())
return;
g.translate(-((int)((System.currentTimeMillis() / MARQUEE_SPEED_DIV) % ((getWidth() + wMod) * 2)) - (getWidth() + wMod)), 0);
super.paintComponent(g);
int thickness = 2;
Graphics2D g2d = (Graphics2D) g;
FSkin.setGraphicsColor(g2d, foreColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setStroke(new BasicStroke(thickness));
g2d.drawString(displayText, 0, 17);
repaint(REPAINT_WITHIN_MS);
}
private void updateVisibility() {
setVisible(!isVisible());
}
}
}

View File

@@ -2,14 +2,10 @@ package forge.view;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashSet;
@@ -21,15 +17,10 @@ import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.text.BadLocationException;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import org.apache.commons.lang3.StringUtils;
@@ -38,7 +29,6 @@ import com.google.common.collect.Lists;
import forge.Singletons;
import forge.gui.ImportDialog;
import forge.gui.SOverlayUtils;
import forge.gui.UiCommand;
import forge.gui.framework.DragCell;
import forge.gui.framework.EDocID;
import forge.gui.framework.FScreen;
@@ -47,9 +37,7 @@ import forge.gui.framework.IVDoc;
import forge.gui.framework.SLayoutConstants;
import forge.gui.framework.SLayoutIO;
import forge.localinstance.properties.ForgeConstants;
import forge.localinstance.properties.ForgePreferences;
import forge.localinstance.skin.FSkinProp;
import forge.model.FModel;
import forge.screens.bazaar.VBazaarUI;
import forge.screens.deckeditor.VDeckEditorUI;
import forge.screens.home.VHomeUI;
@@ -59,7 +47,6 @@ import forge.toolbox.CardFaceSymbols;
import forge.toolbox.FAbsolutePositioner;
import forge.toolbox.FButton;
import forge.toolbox.FLabel;
import forge.toolbox.FOptionPane;
import forge.toolbox.FOverlay;
import forge.toolbox.FPanel;
import forge.toolbox.FProgressBar;
@@ -67,7 +54,6 @@ import forge.toolbox.FScrollPane;
import forge.toolbox.FSkin;
import forge.toolbox.FSkin.SkinnedLayeredPane;
import forge.util.BuildInfo;
import forge.util.RuntimeVersion;
import net.miginfocom.swing.MigLayout;
public enum FView {
@@ -250,113 +236,6 @@ public enum FView {
}
}
RuntimeVersion javaVersion = RuntimeVersion.of(System.getProperty("java.version"));
if (javaVersion.getMajor() < 9 && javaVersion.getMinor() < 8 && !FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.DISABLE_DISPLAY_JAVA_8_UPDATE_WARNING)) {
JPanel updateWarningOverlay = FOverlay.SINGLETON_INSTANCE.getPanel();
updateWarningOverlay.setLayout(new GridBagLayout());
FPanel updateWarningContentPanel = new FPanel(new MigLayout("insets 20, wrap 3"));
JTextPane textPane = new JTextPane();
StyledDocument text = textPane.getStyledDocument();
Style normalStyle = text.addStyle("normal", null);
Style boldStyle = text.addStyle("bold", null);
StyleConstants.setBold(normalStyle, false);
StyleConstants.setBold(boldStyle, true);
try {
text.insertString(text.getLength(), "The next version of Forge will require ", normalStyle);
text.insertString(text.getLength(), "Java 1.8", boldStyle);
text.insertString(text.getLength(), " and will ", normalStyle);
text.insertString(text.getLength(), "no longer run", boldStyle);
text.insertString(text.getLength(), " on Java 1.7. You appear to be running Forge with version ", normalStyle);
text.insertString(text.getLength(), javaVersion.toString(), boldStyle);
text.insertString(text.getLength(), ".\n\nPlease upgrade to the latest version of Java if you plan to update Forge in the future.", normalStyle);
} catch (BadLocationException e) {
e.printStackTrace();
}
textPane.setEditable(false);
textPane.setOpaque(false);
textPane.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT).getColor());
textPane.setBorder(null);
textPane.setFont(FSkin.getRelativeFont(14).getBaseFont());
final FLabel btnRemindMeLater = new FLabel.Builder().text("Remind Me Later").hoverable().opaque().build();
final FLabel btnDoNotRemindMe = new FLabel.Builder().text("Don't Remind Me Again").hoverable().opaque().build();
final FLabel btnDownloadLatestJava = new FLabel.Builder().text("Download Latest Java").hoverable().opaque().build();
String buttonConstraints = "w 200px!, h 30px!";
updateWarningContentPanel.add(textPane, "w 600px!, h 100px!, span 3 1");
updateWarningContentPanel.add(btnRemindMeLater, buttonConstraints);
updateWarningContentPanel.add(btnDoNotRemindMe, buttonConstraints + ", gap 10px 10px 0 0");
final Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
updateWarningContentPanel.add(btnDownloadLatestJava, buttonConstraints);
}
GridBagConstraints constraints = new GridBagConstraints();
constraints.weightx = constraints.weighty = 1;
updateWarningOverlay.add(updateWarningContentPanel, constraints);
btnRemindMeLater.setCommand(new UiCommand() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void run() {
SOverlayUtils.hideOverlay();
}
});
btnDoNotRemindMe.setCommand(new UiCommand() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void run() {
if (FOptionPane.showConfirmDialog("Are you sure? You can re-enable this warning in Forge's general preferences.")) {
FModel.getPreferences().setPref(ForgePreferences.FPref.DISABLE_DISPLAY_JAVA_8_UPDATE_WARNING, true);
FModel.getPreferences().save();
SOverlayUtils.hideOverlay();
}
}
});
btnDownloadLatestJava.setCommand(new UiCommand() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void run() {
try {
assert desktop != null;
desktop.browse(new URI("http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html"));
} catch (Exception e) {
e.printStackTrace();
}
}
});
SwingUtilities.invokeLater(() -> {
SOverlayUtils.showOverlay();
SwingUtilities.invokeLater(btnRemindMeLater::requestFocusInWindow);
});
}
//start background music
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);

View File

@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -33,12 +33,15 @@ public final class Main {
* Main entry point for Forge
*/
public static void main(final String[] args) {
Sentry.init(options -> {
options.setEnableExternalConfiguration(true);
options.setRelease(BuildInfo.getVersionString());
options.setEnvironment(System.getProperty("os.name"));
options.setTag("Java Version", System.getProperty("java.version"));
options.setShutdownTimeoutMillis(5000);
// these belong to sentry.properties, but somehow some OS/Zip tool discards it?
if (options.getDsn() == null || options.getDsn().isEmpty())
options.setDsn("https://87bc8d329e49441895502737c069067b@sentry.cardforge.org//3");
}, true);
// HACK - temporary solution to "Comparison method violates it's general contract!" crash
@@ -46,7 +49,7 @@ public final class Main {
//Turn off the Java 2D system's use of Direct3D to improve rendering speed (particularly when Full Screen)
System.setProperty("sun.java2d.d3d", "false");
//Turn on OpenGl acceleration to improve performance
//System.setProperty("sun.java2d.opengl", "True");
@@ -67,30 +70,30 @@ public final class Main {
// command line startup here
String mode = args[0].toLowerCase();
switch(mode) {
switch (mode) {
case "sim":
SimulateMatch.simulate(args);
break;
case "parse":
CardReaderExperiments.parseAllCards(args);
CardReaderExperiments.parseAllCards(args);
break;
case "server":
System.out.println("Dedicated server mode.\nNot implemented.");
break;
default:
System.out.println("Unknown mode.\nKnown mode is 'sim', 'parse' ");
break;
}
System.exit(0);
}
@SuppressWarnings("deprecation")
@Override
@Override
protected void finalize() throws Throwable {
try {
ExceptionHandler.unregisterErrorHandling();
@@ -100,5 +103,6 @@ public final class Main {
}
// disallow instantiation
private Main() { }
private Main() {
}
}

View File

@@ -48,6 +48,7 @@ import javax.swing.SwingUtilities;
import forge.CachedCardImage;
import forge.StaticData;
import forge.card.CardEdition;
import forge.card.CardStateName;
import forge.card.mana.ManaCost;
import forge.game.card.Card;
import forge.game.card.CardView;
@@ -62,9 +63,11 @@ import forge.item.PaperCard;
import forge.localinstance.properties.ForgeConstants;
import forge.localinstance.properties.ForgeConstants.CounterDisplayType;
import forge.localinstance.properties.ForgePreferences.FPref;
import forge.localinstance.skin.FSkinProp;
import forge.model.FModel;
import forge.screens.match.CMatchUI;
import forge.toolbox.CardFaceSymbols;
import forge.toolbox.FSkin;
import forge.toolbox.FSkin.SkinnedPanel;
import forge.toolbox.IDisposable;
import forge.util.CardTranslation;
@@ -365,6 +368,22 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
}
final boolean canShow = matchUI.mayView(card);
if (canShow && ZoneType.Battlefield.equals(card.getZone())) {
CardStateView cardStateView = card.getCurrentState();
if (card.isSplitCard() && card.hasAlternateState() && !card.isFaceDown() && !CardStateName.Original.equals(cardStateView.getState())) {
switch (cardStateView.getState()) {
case EmptyRoom -> {
FSkin.drawImage(g, FSkin.getIcon(FSkinProp.ICO_PADLOCK), cardXOffset, cardYOffset + cardHeight / 2, cardWidth, cardHeight);
FSkin.drawImage(g, FSkin.getIcon(FSkinProp.ICO_PADLOCK), cardXOffset, cardYOffset, cardWidth, cardHeight);
}
case RightSplit ->
FSkin.drawImage(g, FSkin.getIcon(FSkinProp.ICO_PADLOCK), cardXOffset, cardYOffset + cardHeight / 2, cardWidth, cardHeight);
case LeftSplit ->
FSkin.drawImage(g, FSkin.getIcon(FSkinProp.ICO_PADLOCK), cardXOffset, cardYOffset, cardWidth, cardHeight);
}
}
}
displayIconOverlay(g, canShow);
if (canShow) {
drawFoilEffect(g, card, cardXOffset, cardYOffset,

View File

@@ -16,9 +16,9 @@ import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.testng.PowerMockTestCase;
import org.testng.IObjectFactory;
//import org.testng.IObjectFactory;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.ObjectFactory;
//import org.testng.annotations.ObjectFactory;
import forge.ImageCache;
import forge.ImageKeys;
@@ -184,8 +184,8 @@ public class CardMockTestCase extends PowerMockTestCase {
PowerMockito.when(FModel.getMagicDb()).thenReturn(data);
}
@ObjectFactory
/*@ObjectFactory
public IObjectFactory getObjectFactory() {
return new org.powermock.modules.testng.PowerMockObjectFactory();
}
}*/
}

View File

@@ -1,19 +1,7 @@
package forge.gamesimulationtests.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import forge.deck.Deck;
import forge.game.Game;
import forge.game.GameLog;
import forge.game.GameLogEntry;
import forge.game.GameLogEntryType;
import forge.game.GameRules;
import forge.game.GameStage;
import forge.game.GameType;
import forge.game.Match;
import forge.game.*;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.event.GameEventGameFinished;
@@ -34,6 +22,11 @@ import forge.item.PaperCard;
import forge.localinstance.properties.ForgePreferences.FPref;
import forge.model.FModel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class GameWrapper {
private final List<PlayerSpecification> players;
private final GameStateSpecification initialGameStateSpecification;
@@ -77,6 +70,7 @@ public class GameWrapper {
rules.setPlayForAnte(FModel.getPreferences().getPrefBoolean(FPref.UI_ANTE));
rules.setMatchAnteRarity(FModel.getPreferences().getPrefBoolean(FPref.UI_ANTE_MATCH_RARITY));
rules.setManaBurn(FModel.getPreferences().getPrefBoolean(FPref.UI_MANABURN));
rules.setOrderCombatants(FModel.getPreferences().getPrefBoolean(FPref.LEGACY_ORDER_COMBATANTS));
rules.setUseGrayText(FModel.getPreferences().getPrefBoolean(FPref.UI_GRAY_INACTIVE_TEXT));
Match match = new Match(rules, registeredPlayers, "Test");
game = match.createGame();