- Fix : tab visibility now updated without using revertLayout() which could alter the state of the active layout and was possibly causing repaint artifacts.

This commit is contained in:
spr
2013-09-07 04:26:58 +00:00
parent e18b3b3537
commit 35edfd936b
3 changed files with 429 additions and 428 deletions

View File

@@ -60,18 +60,6 @@ public final class DragCell extends JPanel implements ILocalRepaint {
public DragCell() { public DragCell() {
super(new MigLayout("insets 0, gap 0, wrap 2")); super(new MigLayout("insets 0, gap 0, wrap 2"));
int borderT = SLayoutConstants.BORDER_T;
int headH = (showGameTabs() ? SLayoutConstants.HEAD_H : 0);
this.add(pnlHead,
"w 100% - " + borderT + "px!" + ", " + "h " + headH + "px!");
this.add(pnlBorderRight,
"w " + borderT + "px!" + ", " + "h 100% - " + borderT + "px!, span 1 2");
this.add(pnlBody,
"w 100% - " + borderT + "px!" + ", " + "h 100% - " + (headH + borderT) + "px!");
this.add(pnlBorderBottom,
"w 100% - " + borderT + "px!" + ", " + "h " + borderT + "px!");
this.setOpaque(false); this.setOpaque(false);
pnlHead.setOpaque(false); pnlHead.setOpaque(false);
@@ -99,6 +87,30 @@ public final class DragCell extends JPanel implements ILocalRepaint {
pnlHead.add(lblOverflow, "w 20px!, h 100%!, gap " + tabPaddingPx + "px " + tabPaddingPx + "px 0 0", -1); pnlHead.add(lblOverflow, "w 20px!, h 100%!, gap " + tabPaddingPx + "px " + tabPaddingPx + "px 0 0", -1);
pnlBody.setCornerDiameter(0); pnlBody.setCornerDiameter(0);
doCellLayout(showGameTabs());
}
/**
* Refreshes the cell layout without affecting contents.
* <p>
* Primarily used to toggle visibility of tabs.
*/
public void doCellLayout(boolean showTabs) {
this.removeAll();
int borderT = SLayoutConstants.BORDER_T;
int headH = (showTabs ? SLayoutConstants.HEAD_H : 0);
this.add(pnlHead,
"w 100% - " + borderT + "px!" + ", " + "h " + headH + "px!");
this.add(pnlBorderRight,
"w " + borderT + "px!" + ", " + "h 100% - " + borderT + "px!, span 1 2");
this.add(pnlBody,
"w 100% - " + borderT + "px!" + ", " + "h 100% - " + (headH + borderT) + "px!");
this.add(pnlBorderBottom,
"w 100% - " + borderT + "px!" + ", " + "h " + borderT + "px!");
if (this.isShowing()) {
this.validate();
}
} }
/** /**
@@ -333,24 +345,6 @@ public final class DragCell extends JPanel implements ILocalRepaint {
return docSelected; return docSelected;
} }
/**
* Removes all components in this cell and
* rebuilds it without a header bar.
*/
public void hideHead() {
this.removeAll();
// These cause the cell to be "bumped" over...hopefully can
// just slice out? Doublestrike 18-09-12
// Looks good so far... Doublestrike 09-10-12
// this.add(pnlBorderRight, "w " + SLayoutConstants.BORDER_T + "px!, "
// + "h 100% - " + SLayoutConstants.BORDER_T + "px!, span 1 2");
this.add(pnlBody, "w 100% - " + SLayoutConstants.BORDER_T + "px!, "
+ "h 100% - " + SLayoutConstants.BORDER_T + "px!");
// this.add(pnlBorderBottom, "w 100% - " + SLayoutConstants.BORDER_T + "px!, "
// + "h " + SLayoutConstants.BORDER_T + "px!");
}
/** /**
* Enable/disable resize on the X axis for this cell. * Enable/disable resize on the X axis for this cell.
* *

View File

@@ -13,8 +13,8 @@ import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem; import javax.swing.JRadioButtonMenuItem;
import forge.Singletons; import forge.Singletons;
import forge.control.RestartUtil;
import forge.control.FControl.Screens; import forge.control.FControl.Screens;
import forge.control.RestartUtil;
import forge.gui.GuiChoose; import forge.gui.GuiChoose;
import forge.gui.match.controllers.CDock; import forge.gui.match.controllers.CDock;
import forge.gui.menubar.MenuUtil; import forge.gui.menubar.MenuUtil;
@@ -99,14 +99,14 @@ public final class LayoutMenu {
Object[] options = {"Restart Now", "Restart Later"}; Object[] options = {"Restart Now", "Restart Later"};
int reply = JOptionPane.showOptionDialog( int reply = JOptionPane.showOptionDialog(
null, null,
"You must restart Forge for " + skin + " theme to take effect.", "You must restart Forge for " + skin + " theme to take effect.",
"Change Theme", "Change Theme",
JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE, JOptionPane.INFORMATION_MESSAGE,
null, null,
options, options,
options[0]); options[0]);
if (reply == JOptionPane.YES_OPTION) { if (reply == JOptionPane.YES_OPTION) {
RestartUtil.restartApplication(null); RestartUtil.restartApplication(null);
} }
@@ -148,8 +148,9 @@ public final class LayoutMenu {
return new ActionListener() { return new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
prefs.setPref(FPref.UI_HIDE_GAME_TABS, !menuItem.getState()); boolean showTabs = menuItem.getState();
controller.revertLayout(); FView.SINGLETON_INSTANCE.refreshAllCellLayouts(showTabs);
prefs.setPref(FPref.UI_HIDE_GAME_TABS, !showTabs);
} }
}; };
} }

View File

@@ -1,387 +1,393 @@
package forge.view; package forge.view;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Deque; import java.util.Deque;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLayeredPane; import javax.swing.JLayeredPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder; import javax.swing.border.LineBorder;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import forge.Singletons; import forge.Singletons;
import forge.control.FControl; import forge.control.FControl;
import forge.control.RestartUtil; import forge.control.RestartUtil;
import forge.gui.FNetOverlay; import forge.gui.FNetOverlay;
import forge.gui.ImportDialog; import forge.gui.ImportDialog;
import forge.gui.SOverlayUtils; import forge.gui.SOverlayUtils;
import forge.gui.deckeditor.VDeckEditorUI; import forge.gui.deckeditor.VDeckEditorUI;
import forge.gui.framework.DragCell; import forge.gui.framework.DragCell;
import forge.gui.framework.EDocID; import forge.gui.framework.EDocID;
import forge.gui.framework.SLayoutConstants; import forge.gui.framework.SLayoutConstants;
import forge.gui.framework.SLayoutIO; import forge.gui.framework.SLayoutIO;
import forge.gui.home.VHomeUI; import forge.gui.home.VHomeUI;
import forge.gui.match.TargetingOverlay; import forge.gui.match.TargetingOverlay;
import forge.gui.match.VMatchUI; import forge.gui.match.VMatchUI;
import forge.gui.toolbox.CardFaceSymbols; import forge.gui.toolbox.CardFaceSymbols;
import forge.gui.toolbox.FAbsolutePositioner; import forge.gui.toolbox.FAbsolutePositioner;
import forge.gui.toolbox.FButton; import forge.gui.toolbox.FButton;
import forge.gui.toolbox.FLabel; import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FOverlay; import forge.gui.toolbox.FOverlay;
import forge.gui.toolbox.FPanel; import forge.gui.toolbox.FPanel;
import forge.gui.toolbox.FSkin; import forge.gui.toolbox.FSkin;
import forge.model.BuildInfo; import forge.model.BuildInfo;
import forge.properties.NewConstants; import forge.properties.NewConstants;
/** */ /** */
public enum FView { public enum FView {
/** */ /** */
SINGLETON_INSTANCE; SINGLETON_INSTANCE;
/** */ /** */
public static final Integer TARGETING_LAYER = JLayeredPane.MODAL_LAYER - 1; public static final Integer TARGETING_LAYER = JLayeredPane.MODAL_LAYER - 1;
private final List<DragCell> allCells = new ArrayList<DragCell>(); private final List<DragCell> allCells = new ArrayList<DragCell>();
private SplashFrame frmSplash; private SplashFrame frmSplash;
// Non-singleton instances (deprecated, but not updated yet) // Non-singleton instances (deprecated, but not updated yet)
private ViewBazaarUI bazaar = null; private ViewBazaarUI bazaar = null;
// Top-level UI components; all have getters. // Top-level UI components; all have getters.
private final JFrame frmDocument = new JFrame(); private final JFrame frmDocument = new JFrame();
// A layered pane is the frame's viewport, allowing overlay effects. // A layered pane is the frame's viewport, allowing overlay effects.
private final JLayeredPane lpnDocument = new JLayeredPane(); private final JLayeredPane lpnDocument = new JLayeredPane();
// The content panel is placed in the layered pane. // The content panel is placed in the layered pane.
private final JPanel pnlContent = new JPanel(); private final JPanel pnlContent = new JPanel();
// An insets panel neatly maintains a space from the edges of the window and // An insets panel neatly maintains a space from the edges of the window and
// whatever layout is happening, without having to explicitly define a margin each time. // whatever layout is happening, without having to explicitly define a margin each time.
private FPanel pnlInsets; private FPanel pnlInsets;
// Preview panel is what is shown when a drag cell is being moved around // Preview panel is what is shown when a drag cell is being moved around
private final JPanel pnlPreview = new PreviewPanel(); private final JPanel pnlPreview = new PreviewPanel();
// Tab overflow is for the +X display for extra tabs. // Tab overflow is for the +X display for extra tabs.
private final JPanel pnlTabOverflow = new JPanel(new MigLayout("insets 0, gap 0, wrap")); private final JPanel pnlTabOverflow = new JPanel(new MigLayout("insets 0, gap 0, wrap"));
private FView() { private FView() {
frmSplash = new SplashFrame(); frmSplash = new SplashFrame();
// Insets panel has background image / texture, which // Insets panel has background image / texture, which
// must be instantiated after the skin is loaded. // must be instantiated after the skin is loaded.
pnlInsets = new FPanel(new BorderLayout()); pnlInsets = new FPanel(new BorderLayout());
} }
/** */ /** */
public void initialize() { public void initialize() {
// Frame styling // Frame styling
frmDocument.setMinimumSize(new Dimension(800, 600)); frmDocument.setMinimumSize(new Dimension(800, 600));
frmDocument.setLocationRelativeTo(null); frmDocument.setLocationRelativeTo(null);
frmDocument.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frmDocument.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frmDocument.setIconImage(FSkin.getIcon(FSkin.InterfaceIcons.ICO_FAVICON).getImage()); frmDocument.setIconImage(FSkin.getIcon(FSkin.InterfaceIcons.ICO_FAVICON).getImage());
frmDocument.setTitle("Forge: " + BuildInfo.getVersionString()); frmDocument.setTitle("Forge: " + BuildInfo.getVersionString());
// Frame components // Frame components
frmDocument.setContentPane(lpnDocument); frmDocument.setContentPane(lpnDocument);
lpnDocument.add(pnlInsets, (Integer) 1); lpnDocument.add(pnlInsets, (Integer) 1);
FAbsolutePositioner.SINGLETON_INSTANCE.initialize(lpnDocument, (Integer) 2); FAbsolutePositioner.SINGLETON_INSTANCE.initialize(lpnDocument, (Integer) 2);
lpnDocument.add(pnlPreview, (Integer) 3); lpnDocument.add(pnlPreview, (Integer) 3);
lpnDocument.add(pnlTabOverflow, (Integer) 4); lpnDocument.add(pnlTabOverflow, (Integer) 4);
lpnDocument.add(FOverlay.SINGLETON_INSTANCE.getPanel(), JLayeredPane.MODAL_LAYER); lpnDocument.add(FOverlay.SINGLETON_INSTANCE.getPanel(), JLayeredPane.MODAL_LAYER);
// Note: when adding new panels here, keep in mind that the layered pane // Note: when adding new panels here, keep in mind that the layered pane
// has a null layout, so new components will be W0 x H0 pixels - gotcha! // has a null layout, so new components will be W0 x H0 pixels - gotcha!
// FControl has a method called "sizeComponents" which will fix this. // FControl has a method called "sizeComponents" which will fix this.
lpnDocument.add(TargetingOverlay.SINGLETON_INSTANCE.getPanel(), TARGETING_LAYER); lpnDocument.add(TargetingOverlay.SINGLETON_INSTANCE.getPanel(), TARGETING_LAYER);
lpnDocument.add(FNetOverlay.SINGLETON_INSTANCE.getPanel(), TARGETING_LAYER); lpnDocument.add(FNetOverlay.SINGLETON_INSTANCE.getPanel(), TARGETING_LAYER);
pnlInsets.add(pnlContent, BorderLayout.CENTER); pnlInsets.add(pnlContent, BorderLayout.CENTER);
pnlInsets.setBackgroundTexture(FSkin.getIcon(FSkin.Backgrounds.BG_TEXTURE)); pnlInsets.setBackgroundTexture(FSkin.getIcon(FSkin.Backgrounds.BG_TEXTURE));
pnlInsets.setCornerDiameter(0); pnlInsets.setCornerDiameter(0);
pnlInsets.setBorder(new EmptyBorder( pnlInsets.setBorder(new EmptyBorder(
SLayoutConstants.BORDER_T, SLayoutConstants.BORDER_T, 0, 0)); SLayoutConstants.BORDER_T, SLayoutConstants.BORDER_T, 0, 0));
pnlContent.setOpaque(false); pnlContent.setOpaque(false);
pnlContent.setLayout(null); pnlContent.setLayout(null);
FOverlay.SINGLETON_INSTANCE.getPanel().setBackground(FSkin.getColor(FSkin.Colors.CLR_OVERLAY)); FOverlay.SINGLETON_INSTANCE.getPanel().setBackground(FSkin.getColor(FSkin.Colors.CLR_OVERLAY));
// Populate all drag tab components. // Populate all drag tab components.
this.cacheUIStates(); this.cacheUIStates();
// Does not use progress bar, due to be deprecated with battlefield refactoring. // Does not use progress bar, due to be deprecated with battlefield refactoring.
CardFaceSymbols.loadImages(); CardFaceSymbols.loadImages();
// Initialize actions on all drag tab components (which should // Initialize actions on all drag tab components (which should
// be realized / populated already). // be realized / populated already).
for (EDocID doc : EDocID.values()) { for (EDocID doc : EDocID.values()) {
doc.getDoc().getLayoutControl().initialize(); doc.getDoc().getLayoutControl().initialize();
} }
// All is ready to go - fire up home screen and discard splash frame. // All is ready to go - fire up home screen and discard splash frame.
Singletons.getControl().changeState(FControl.Screens.HOME_SCREEN); Singletons.getControl().changeState(FControl.Screens.HOME_SCREEN);
FView.this.frmSplash.dispose(); FView.this.frmSplash.dispose();
FView.this.frmSplash = null; FView.this.frmSplash = null;
SLayoutIO.loadWindowLayout(); SLayoutIO.loadWindowLayout();
frmDocument.setVisible(true); frmDocument.setVisible(true);
// remove this once our userbase has been migrated to the profile layout // remove this once our userbase has been migrated to the profile layout
{ {
// get profile directories -- if one of them is actually under the res directory, don't // get profile directories -- if one of them is actually under the res directory, don't
// count is as data to migrate // count is as data to migrate
final Set<File> profileDirs = new HashSet<File>(); final Set<File> profileDirs = new HashSet<File>();
for (String dname : NewConstants.PROFILE_DIRS) { for (String dname : NewConstants.PROFILE_DIRS) {
profileDirs.add(new File(dname)); profileDirs.add(new File(dname));
} }
final List<File> resDirs = new ArrayList<File>(); final List<File> resDirs = new ArrayList<File>();
for (String resDir : Lists.newArrayList("decks", "gauntlet", "layouts", "pics", "preferences", "quest/data")) { for (String resDir : Lists.newArrayList("decks", "gauntlet", "layouts", "pics", "preferences", "quest/data")) {
resDirs.add(new File("res", resDir)); resDirs.add(new File("res", resDir));
} }
final Set<File> doNotDeleteDirs = new HashSet<File>(); final Set<File> doNotDeleteDirs = new HashSet<File>();
for (String dir : Lists.newArrayList("decks", "decks/constructed", "decks/draft", "decks/plane", "decks/scheme", "decks/sealed", "gauntlet", "layouts", "pics", "preferences", "quest/data")) { for (String dir : Lists.newArrayList("decks", "decks/constructed", "decks/draft", "decks/plane", "decks/scheme", "decks/sealed", "gauntlet", "layouts", "pics", "preferences", "quest/data")) {
doNotDeleteDirs.add(new File("res", dir)); doNotDeleteDirs.add(new File("res", dir));
} }
// if we have any data to migrate, pop up the migration dialog // if we have any data to migrate, pop up the migration dialog
if (_addRemainingFiles(null, resDirs, profileDirs, doNotDeleteDirs)) { if (_addRemainingFiles(null, resDirs, profileDirs, doNotDeleteDirs)) {
new ImportDialog("res", new Runnable() { new ImportDialog("res", new Runnable() {
@Override public void run() { @Override public void run() {
// remove known cruft files, yes this is ugly, but it's also temporary // remove known cruft files, yes this is ugly, but it's also temporary
for (String cruftFile : Lists.newArrayList("decks/SkieraCube-cards_not_supported_yet.txt", "decks/cube/ArabianExtended.dck", "decks/cube/GtcGuildBoros.dck", "decks/cube/GtcGuildDimir.dck", "decks/cube/GtcGuildGruul.dck", "decks/cube/GtcGuildOrzhov.dck", "decks/cube/GtcGuildSimic.dck", "decks/cube/GtcPromoBoros.dck", "decks/cube/GtcPromoDimir.dck", "decks/cube/GtcPromoGruul.dck", "decks/cube/GtcPromoOrzhov.dck", "decks/cube/GtcPromoSimic.dck", "decks/cube/JuzamjediCube.dck", "decks/cube/RtRGuildAzorius.dck", "decks/cube/RtRGuildGolgari.dck", "decks/cube/RtRGuildIzzet.dck", "decks/cube/RtRGuildRakdos.dck", "decks/cube/RtRGuildSelesnya.dck", "decks/cube/RtRPromoAzorius.dck", "decks/cube/RtRPromoGolgari.dck", "decks/cube/RtRPromoIzzet.dck", "decks/cube/RtRPromoRakdos.dck", "decks/cube/RtRPromoSelesnya.dck", "decks/cube/SkieraCube.dck", "gauntlet/LOCKED_DotP Preconstructed.dat", "gauntlet/LOCKED_Swimming With Sharks.dat", "layouts/editor_default.xml", "layouts/home_default.xml", "layouts/match_default.xml", "pics/snow_covered_forest1.jpg", "pics/snow_covered_forest2.jpg", "pics/snow_covered_forest3.jpg", "pics/snow_covered_island1.jpg", "pics/snow_covered_island2.jpg", "pics/snow_covered_island3.jpg", "pics/snow_covered_mountain1.jpg", "pics/snow_covered_mountain2.jpg", "pics/snow_covered_mountain3.jpg", "pics/snow_covered_plains1.jpg", "pics/snow_covered_plains2.jpg", "pics/snow_covered_plains3.jpg", "pics/snow_covered_swamp1.jpg", "pics/snow_covered_swamp2.jpg", "pics/snow_covered_swamp3.jpg", "pics/VAN/Birds of Paradise Avatar.full.jpg", "pics/VAN/Erhnam Djinn Avatar.full.jpg", "pics/VAN/Goblin Warchief Avatar.full.jpg", "pics/VAN/Grinning Demon Avatar.full.jpg", "pics/VAN/Platinum Angel Avatar.full.jpg", "pics/VAN/Prodigal Sorcerer Avatar.full.jpg", "pics/VAN/Rith, the Awakener Avatar.full.jpg", "pics/VAN/Royal Assassin Avatar.full.jpg", "pics/VAN/Serra Angel Avatar.full.jpg", "pics/VAN/Tradewind Rider Avatar.full.jpg", "pics_product/10E.jpg", "pics_product/2ED.jpg", "pics_product/3ED.jpg", "pics_product/4ED.jpg", "pics_product/5DN.jpg", "pics_product/5ED.jpg", "pics_product/6ED.jpg", "pics_product/7ED.jpg", "pics_product/8ED.jpg", "pics_product/9ED.jpg", "pics_product/ALA.jpg", "pics_product/ALL.jpg", "pics_product/APC.jpg", "pics_product/ARB.jpg", "pics_product/ARN.jpg", "pics_product/ATQ.jpg", "pics_product/BOK.jpg", "pics_product/CFX.jpg", "pics_product/CHK.jpg", "pics_product/CHR.jpg", "pics_product/CSP.jpg", "pics_product/DIS.jpg", "pics_product/DKA.jpg", "pics_product/DRK.jpg", "pics_product/DST.jpg", "pics_product/EVE.jpg", "pics_product/EXO.jpg", "pics_product/FEM.jpg", "pics_product/FUT.jpg", "pics_product/GPT.jpg", "pics_product/HML.jpg", "pics_product/ICE.jpg", "pics_product/INV.jpg", "pics_product/ISD.jpg", "pics_product/JUD.jpg", "pics_product/LEA.jpg", "pics_product/LEB.jpg", "pics_product/LEG.jpg", "pics_product/LGN.jpg", "pics_product/LRW.jpg", "pics_product/M10.jpg", "pics_product/M11.jpg", "pics_product/M12.jpg", "pics_product/MBS.jpg", "pics_product/MIR.jpg", "pics_product/MMQ.jpg", "pics_product/MOR.jpg", "pics_product/MRD.jpg", "pics_product/NMS.jpg", "pics_product/NPH.jpg", "pics_product/ODY.jpg", "pics_product/ONS.jpg", "pics_product/PCY.jpg", "pics_product/PLC.jpg", "pics_product/PLS.jpg", "pics_product/PO2.jpg", "pics_product/POR.jpg", "pics_product/PTK.jpg", "pics_product/RAV.jpg", "pics_product/ROE.jpg", "pics_product/S99.jpg", "pics_product/SCG.jpg", "pics_product/SHM.jpg", "pics_product/SOK.jpg", "pics_product/SOM.jpg", "pics_product/STH.jpg", "pics_product/TMP.jpg", "pics_product/TOR.jpg", "pics_product/TSP.jpg", "pics_product/UDS.jpg", "pics_product/ULG.jpg", "pics_product/USG.jpg", "pics_product/VIS.jpg", "pics_product/WTH.jpg", "pics_product/WWK.jpg", "pics_product/ZEN.jpg", "pics_product/booster/7E.png", "pics_product/booster/AP.png", "pics_product/booster/DPA.png", "pics_product/booster/EX.png", "pics_product/booster/IN.png", "pics_product/booster/MI.png", "pics_product/booster/OD.png", "pics_product/booster/PS.png", "pics_product/booster/ST.png", "pics_product/booster/TE.png", "pics_product/booster/UD.png", "pics_product/booster/UL.png", "pics_product/booster/UZ.png", "pics_product/booster/VI.png", "pics_product/booster/WL.png", "preferences/.project", "preferences/editor.default.preferences", "preferences/main.properties", "quest/quest.preferences", "quest/quest.properties")) { for (String cruftFile : Lists.newArrayList("decks/SkieraCube-cards_not_supported_yet.txt", "decks/cube/ArabianExtended.dck", "decks/cube/GtcGuildBoros.dck", "decks/cube/GtcGuildDimir.dck", "decks/cube/GtcGuildGruul.dck", "decks/cube/GtcGuildOrzhov.dck", "decks/cube/GtcGuildSimic.dck", "decks/cube/GtcPromoBoros.dck", "decks/cube/GtcPromoDimir.dck", "decks/cube/GtcPromoGruul.dck", "decks/cube/GtcPromoOrzhov.dck", "decks/cube/GtcPromoSimic.dck", "decks/cube/JuzamjediCube.dck", "decks/cube/RtRGuildAzorius.dck", "decks/cube/RtRGuildGolgari.dck", "decks/cube/RtRGuildIzzet.dck", "decks/cube/RtRGuildRakdos.dck", "decks/cube/RtRGuildSelesnya.dck", "decks/cube/RtRPromoAzorius.dck", "decks/cube/RtRPromoGolgari.dck", "decks/cube/RtRPromoIzzet.dck", "decks/cube/RtRPromoRakdos.dck", "decks/cube/RtRPromoSelesnya.dck", "decks/cube/SkieraCube.dck", "gauntlet/LOCKED_DotP Preconstructed.dat", "gauntlet/LOCKED_Swimming With Sharks.dat", "layouts/editor_default.xml", "layouts/home_default.xml", "layouts/match_default.xml", "pics/snow_covered_forest1.jpg", "pics/snow_covered_forest2.jpg", "pics/snow_covered_forest3.jpg", "pics/snow_covered_island1.jpg", "pics/snow_covered_island2.jpg", "pics/snow_covered_island3.jpg", "pics/snow_covered_mountain1.jpg", "pics/snow_covered_mountain2.jpg", "pics/snow_covered_mountain3.jpg", "pics/snow_covered_plains1.jpg", "pics/snow_covered_plains2.jpg", "pics/snow_covered_plains3.jpg", "pics/snow_covered_swamp1.jpg", "pics/snow_covered_swamp2.jpg", "pics/snow_covered_swamp3.jpg", "pics/VAN/Birds of Paradise Avatar.full.jpg", "pics/VAN/Erhnam Djinn Avatar.full.jpg", "pics/VAN/Goblin Warchief Avatar.full.jpg", "pics/VAN/Grinning Demon Avatar.full.jpg", "pics/VAN/Platinum Angel Avatar.full.jpg", "pics/VAN/Prodigal Sorcerer Avatar.full.jpg", "pics/VAN/Rith, the Awakener Avatar.full.jpg", "pics/VAN/Royal Assassin Avatar.full.jpg", "pics/VAN/Serra Angel Avatar.full.jpg", "pics/VAN/Tradewind Rider Avatar.full.jpg", "pics_product/10E.jpg", "pics_product/2ED.jpg", "pics_product/3ED.jpg", "pics_product/4ED.jpg", "pics_product/5DN.jpg", "pics_product/5ED.jpg", "pics_product/6ED.jpg", "pics_product/7ED.jpg", "pics_product/8ED.jpg", "pics_product/9ED.jpg", "pics_product/ALA.jpg", "pics_product/ALL.jpg", "pics_product/APC.jpg", "pics_product/ARB.jpg", "pics_product/ARN.jpg", "pics_product/ATQ.jpg", "pics_product/BOK.jpg", "pics_product/CFX.jpg", "pics_product/CHK.jpg", "pics_product/CHR.jpg", "pics_product/CSP.jpg", "pics_product/DIS.jpg", "pics_product/DKA.jpg", "pics_product/DRK.jpg", "pics_product/DST.jpg", "pics_product/EVE.jpg", "pics_product/EXO.jpg", "pics_product/FEM.jpg", "pics_product/FUT.jpg", "pics_product/GPT.jpg", "pics_product/HML.jpg", "pics_product/ICE.jpg", "pics_product/INV.jpg", "pics_product/ISD.jpg", "pics_product/JUD.jpg", "pics_product/LEA.jpg", "pics_product/LEB.jpg", "pics_product/LEG.jpg", "pics_product/LGN.jpg", "pics_product/LRW.jpg", "pics_product/M10.jpg", "pics_product/M11.jpg", "pics_product/M12.jpg", "pics_product/MBS.jpg", "pics_product/MIR.jpg", "pics_product/MMQ.jpg", "pics_product/MOR.jpg", "pics_product/MRD.jpg", "pics_product/NMS.jpg", "pics_product/NPH.jpg", "pics_product/ODY.jpg", "pics_product/ONS.jpg", "pics_product/PCY.jpg", "pics_product/PLC.jpg", "pics_product/PLS.jpg", "pics_product/PO2.jpg", "pics_product/POR.jpg", "pics_product/PTK.jpg", "pics_product/RAV.jpg", "pics_product/ROE.jpg", "pics_product/S99.jpg", "pics_product/SCG.jpg", "pics_product/SHM.jpg", "pics_product/SOK.jpg", "pics_product/SOM.jpg", "pics_product/STH.jpg", "pics_product/TMP.jpg", "pics_product/TOR.jpg", "pics_product/TSP.jpg", "pics_product/UDS.jpg", "pics_product/ULG.jpg", "pics_product/USG.jpg", "pics_product/VIS.jpg", "pics_product/WTH.jpg", "pics_product/WWK.jpg", "pics_product/ZEN.jpg", "pics_product/booster/7E.png", "pics_product/booster/AP.png", "pics_product/booster/DPA.png", "pics_product/booster/EX.png", "pics_product/booster/IN.png", "pics_product/booster/MI.png", "pics_product/booster/OD.png", "pics_product/booster/PS.png", "pics_product/booster/ST.png", "pics_product/booster/TE.png", "pics_product/booster/UD.png", "pics_product/booster/UL.png", "pics_product/booster/UZ.png", "pics_product/booster/VI.png", "pics_product/booster/WL.png", "preferences/.project", "preferences/editor.default.preferences", "preferences/main.properties", "quest/quest.preferences", "quest/quest.properties")) {
new File("res", cruftFile).delete(); new File("res", cruftFile).delete();
} }
// assemble a list of remaining files. // assemble a list of remaining files.
final List<File> remainingFiles = new LinkedList<File>(); final List<File> remainingFiles = new LinkedList<File>();
_addRemainingFiles(remainingFiles, resDirs, profileDirs, doNotDeleteDirs); _addRemainingFiles(remainingFiles, resDirs, profileDirs, doNotDeleteDirs);
// if any files remain, display them and make clear that they should be moved or // if any files remain, display them and make clear that they should be moved or
// deleted manually or the user will continue to be prompted for migration // deleted manually or the user will continue to be prompted for migration
final FPanel p = new FPanel(new MigLayout("insets dialog, gap 10, center, wrap")); final FPanel p = new FPanel(new MigLayout("insets dialog, gap 10, center, wrap"));
p.setOpaque(false); p.setOpaque(false);
p.setBackgroundTexture(FSkin.getIcon(FSkin.Backgrounds.BG_TEXTURE)); p.setBackgroundTexture(FSkin.getIcon(FSkin.Backgrounds.BG_TEXTURE));
if (remainingFiles.isEmpty()) { if (remainingFiles.isEmpty()) {
p.add(new FLabel.Builder().text("<html>You're done! It looks like everything went smoothly." + p.add(new FLabel.Builder().text("<html>You're done! It looks like everything went smoothly." +
" Now just restart Forge to load the data from its new home! Note that there is more data available" + " Now just restart Forge to load the data from its new home! Note that there is more data available" +
" from the downloaders now. You might want to run through the content downloaders to check for new files.</html>").build()); " from the downloaders now. You might want to run through the content downloaders to check for new files.</html>").build());
} else { } else {
p.add(new FLabel.Builder().text("<html>There seem to be a few files left over in your old data" + p.add(new FLabel.Builder().text("<html>There seem to be a few files left over in your old data" +
" directories. They should be deleted or moved somewhere else to avoid having the data" + " directories. They should be deleted or moved somewhere else to avoid having the data" +
" migration prompt pop up again!</html>").build()); " migration prompt pop up again!</html>").build());
JTextArea files = new JTextArea(StringUtils.join(remainingFiles, '\n')); JTextArea files = new JTextArea(StringUtils.join(remainingFiles, '\n'));
files.setFont(new Font("Monospaced", Font.PLAIN, 10)); files.setFont(new Font("Monospaced", Font.PLAIN, 10));
files.setOpaque(false); files.setOpaque(false);
files.setWrapStyleWord(true); files.setWrapStyleWord(true);
files.setLineWrap(true); files.setLineWrap(true);
files.setEditable(false); files.setEditable(false);
JScrollPane scroller = new JScrollPane(files); JScrollPane scroller = new JScrollPane(files);
p.add(scroller, "w 600:100%:100%, h 100:100%:100%, gaptop 10"); p.add(scroller, "w 600:100%:100%, h 100:100%:100%, gaptop 10");
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
// resize the panel properly for the new log contents // resize the panel properly for the new log contents
p.getParent().validate(); p.getParent().validate();
p.getParent().invalidate(); p.getParent().invalidate();
} }
}); });
} }
final FButton btnOk = new FButton(remainingFiles.isEmpty() ? "Restart Forge" : "Close Forge"); final FButton btnOk = new FButton(remainingFiles.isEmpty() ? "Restart Forge" : "Close Forge");
btnOk.addActionListener(new ActionListener() { btnOk.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) { @Override public void actionPerformed(ActionEvent e) {
if (remainingFiles.isEmpty()) { if (remainingFiles.isEmpty()) {
RestartUtil.restartApplication(null); RestartUtil.restartApplication(null);
} else { } else {
System.exit(0); System.exit(0);
} }
} }
}); });
p.add(btnOk, "center, w pref+64!, h pref+12!, gaptop 20"); p.add(btnOk, "center, w pref+64!, h pref+12!, gaptop 20");
JPanel overlay = FOverlay.SINGLETON_INSTANCE.getPanel(); JPanel overlay = FOverlay.SINGLETON_INSTANCE.getPanel();
overlay.setLayout(new MigLayout("insets 0, gap 0, wrap, ax center, ay center")); overlay.setLayout(new MigLayout("insets 0, gap 0, wrap, ax center, ay center"));
overlay.add(p, "w 100::80%, h 50::90%"); overlay.add(p, "w 100::80%, h 50::90%");
SOverlayUtils.showOverlay(); SOverlayUtils.showOverlay();
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override public void run() { btnOk.requestFocusInWindow(); } @Override public void run() { btnOk.requestFocusInWindow(); }
}); });
} }
}); });
} }
} }
} }
// will populate remainingFiles with remaining files if not null, returns whether any files have // will populate remainingFiles with remaining files if not null, returns whether any files have
// been added to remainingFiles (or would have been added if remainingFiles is null) // been added to remainingFiles (or would have been added if remainingFiles is null)
// directories listed in profileDirs will not be searched // directories listed in profileDirs will not be searched
// removes empty directories to reduce tree conflicts // removes empty directories to reduce tree conflicts
private static boolean _addRemainingFiles(List<File> remainingFiles, List<File> dirRoots, Set<File> profileDirs, Set<File> doNotDeleteDirs) { private static boolean _addRemainingFiles(List<File> remainingFiles, List<File> dirRoots, Set<File> profileDirs, Set<File> doNotDeleteDirs) {
Deque<File> stack = new LinkedList<File>(dirRoots); Deque<File> stack = new LinkedList<File>(dirRoots);
Set<File> seenDirs = new HashSet<File>(); Set<File> seenDirs = new HashSet<File>();
boolean ret = false; boolean ret = false;
while (!stack.isEmpty()) { while (!stack.isEmpty()) {
File cur = stack.peek(); File cur = stack.peek();
if (profileDirs.contains(cur)) { if (profileDirs.contains(cur)) {
// don't touch active profile dirs // don't touch active profile dirs
stack.pop(); stack.pop();
continue; continue;
} }
if (seenDirs.contains(cur)) { if (seenDirs.contains(cur)) {
cur = stack.pop(); cur = stack.pop();
if (cur.exists() && !doNotDeleteDirs.contains(cur)) { if (cur.exists() && !doNotDeleteDirs.contains(cur)) {
// remove empty dir (will fail if not empty) // remove empty dir (will fail if not empty)
cur.delete(); cur.delete();
} }
continue; continue;
} }
seenDirs.add(cur); seenDirs.add(cur);
File[] curListing = cur.listFiles(); File[] curListing = cur.listFiles();
if (null == curListing) { if (null == curListing) {
continue; continue;
} }
for (File f : curListing) { for (File f : curListing) {
if (f.isDirectory()) { if (f.isDirectory()) {
if (!".svn".equals(f.getName())) { if (!".svn".equals(f.getName())) {
stack.push(f); stack.push(f);
} }
} else { } else {
if (null == remainingFiles) { if (null == remainingFiles) {
return true; return true;
} }
remainingFiles.add(f); remainingFiles.add(f);
ret = true; ret = true;
} }
} }
} }
return ret; return ret;
} }
/** @return {@link forge.view.SplashFrame} */ /** @return {@link forge.view.SplashFrame} */
public SplashFrame getSplash() { public SplashFrame getSplash() {
return frmSplash; return frmSplash;
} }
/** @return {@link javax.swing.JFrame} */ /** @return {@link javax.swing.JFrame} */
public JFrame getFrame() { public JFrame getFrame() {
return frmDocument; return frmDocument;
} }
/** @return {@link javax.swing.JLayeredPane} */ /** @return {@link javax.swing.JLayeredPane} */
public JLayeredPane getLpnDocument() { public JLayeredPane getLpnDocument() {
return lpnDocument; return lpnDocument;
} }
/** @return {@link forge.gui.toolbox.FPanel} */ /** @return {@link forge.gui.toolbox.FPanel} */
public FPanel getPnlInsets() { public FPanel getPnlInsets() {
return pnlInsets; return pnlInsets;
} }
/** @return {@link javax.swing.JPanel} */ /** @return {@link javax.swing.JPanel} */
public JPanel getPnlContent() { public JPanel getPnlContent() {
return pnlContent; return pnlContent;
} }
/** @return {@link javax.swing.JPanel} */ /** @return {@link javax.swing.JPanel} */
public JPanel getPnlPreview() { public JPanel getPnlPreview() {
return pnlPreview; return pnlPreview;
} }
/** @return {@link javax.swing.JPanel} */ /** @return {@link javax.swing.JPanel} */
public JPanel getPnlTabOverflow() { public JPanel getPnlTabOverflow() {
return pnlTabOverflow; return pnlTabOverflow;
} }
/** @return {@link java.util.List}<{@link forge.gui.framework.DragCell}> */ /** @return {@link java.util.List}<{@link forge.gui.framework.DragCell}> */
public List<DragCell> getDragCells() { public List<DragCell> getDragCells() {
final List<DragCell> clone = new ArrayList<DragCell>(); final List<DragCell> clone = new ArrayList<DragCell>();
clone.addAll(allCells); clone.addAll(allCells);
return clone; return clone;
} }
/** @param pnl0 &emsp; {@link forge.gui.framework.DragCell} */ /** @param pnl0 &emsp; {@link forge.gui.framework.DragCell} */
public void addDragCell(final DragCell pnl0) { public void addDragCell(final DragCell pnl0) {
allCells.add(pnl0); allCells.add(pnl0);
pnlContent.add(pnl0); pnlContent.add(pnl0);
} }
/** @param pnl0 &emsp; {@link forge.gui.framework.DragCell} */ /** @param pnl0 &emsp; {@link forge.gui.framework.DragCell} */
public void removeDragCell(final DragCell pnl0) { public void removeDragCell(final DragCell pnl0) {
allCells.remove(pnl0); allCells.remove(pnl0);
pnlContent.remove(pnl0); pnlContent.remove(pnl0);
} }
/** */ /** */
public void removeAllDragCells() { public void removeAllDragCells() {
allCells.clear(); allCells.clear();
pnlContent.removeAll(); pnlContent.removeAll();
} }
/** PreviewPanel shows where a dragged component could /** PreviewPanel shows where a dragged component could
* come to rest when the mouse is released.<br> * come to rest when the mouse is released.<br>
* This class is an unfortunate necessity to overcome * This class is an unfortunate necessity to overcome
* translucency issues for preview panel. */ * translucency issues for preview panel. */
@SuppressWarnings("serial") @SuppressWarnings("serial")
class PreviewPanel extends JPanel { class PreviewPanel extends JPanel {
/** PreviewPanel shows where a dragged component could /** PreviewPanel shows where a dragged component could
* come to rest when the mouse is released. */ * come to rest when the mouse is released. */
public PreviewPanel() { public PreviewPanel() {
super(); super();
setOpaque(false); setOpaque(false);
setVisible(false); setVisible(false);
setBorder(new LineBorder(Color.DARK_GRAY, 2)); setBorder(new LineBorder(Color.DARK_GRAY, 2));
} }
@Override @Override
public void paintComponent(final Graphics g) { public void paintComponent(final Graphics g) {
super.paintComponent(g); super.paintComponent(g);
g.setColor(new Color(0, 0, 0, 50)); g.setColor(new Color(0, 0, 0, 50));
g.fillRect(0, 0, getWidth(), getHeight()); g.fillRect(0, 0, getWidth(), getHeight());
} }
} }
/** @return {@link forge.view.ViewBazaarUI} */ /** @return {@link forge.view.ViewBazaarUI} */
public ViewBazaarUI getViewBazaar() { public ViewBazaarUI getViewBazaar() {
if (Singletons.getControl().getState() != FControl.Screens.QUEST_BAZAAR) { if (Singletons.getControl().getState() != FControl.Screens.QUEST_BAZAAR) {
throw new IllegalArgumentException("FView$getViewBazaar\n" throw new IllegalArgumentException("FView$getViewBazaar\n"
+ "may only be called while the bazaar UI is showing."); + "may only be called while the bazaar UI is showing.");
} }
bazaar.refreshLastInstance(); bazaar.refreshLastInstance();
return FView.this.bazaar; return FView.this.bazaar;
} }
/** */ /** */
private void cacheUIStates() { private void cacheUIStates() {
FView.this.bazaar = new ViewBazaarUI(Singletons.getModel().getQuest().getBazaar()); FView.this.bazaar = new ViewBazaarUI(Singletons.getModel().getQuest().getBazaar());
VMatchUI.SINGLETON_INSTANCE.instantiate(); VMatchUI.SINGLETON_INSTANCE.instantiate();
VHomeUI.SINGLETON_INSTANCE.instantiate(); VHomeUI.SINGLETON_INSTANCE.instantiate();
VDeckEditorUI.SINGLETON_INSTANCE.instantiate(); VDeckEditorUI.SINGLETON_INSTANCE.instantiate();
} }
}
public void refreshAllCellLayouts(boolean showTabs) {
for (DragCell cell : allCells) {
cell.doCellLayout(showTabs);
}
}
}