Reset layout buttons

This commit is contained in:
Maxmtg
2013-06-03 20:30:45 +00:00
parent 76a012c716
commit 1001ad7ab9
5 changed files with 43 additions and 7 deletions

View File

@@ -20,7 +20,6 @@ package forge.card.mana;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;

View File

@@ -54,8 +54,8 @@ public final class SLayoutIO {
* Gets preferred layout file corresponding to current state of UI. * Gets preferred layout file corresponding to current state of UI.
* @return {@link java.lang.String} * @return {@link java.lang.String}
*/ */
public static String getFilePreferred() { public static String getFilePreferred(Screens mode) {
return SLayoutIO.getFileForState(Singletons.getControl().getState()).userPrefLoc; return SLayoutIO.getFileForState(mode).userPrefLoc;
} }
/** Publicly-accessible save method, to neatly handle exception handling. /** Publicly-accessible save method, to neatly handle exception handling.

View File

@@ -4,6 +4,7 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.File;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
@@ -14,9 +15,11 @@ import org.apache.commons.lang3.tuple.Pair;
import forge.Command; import forge.Command;
import forge.Constant.Preferences; import forge.Constant.Preferences;
import forge.Singletons; import forge.Singletons;
import forge.control.FControl.Screens;
import forge.control.RestartUtil; import forge.control.RestartUtil;
import forge.game.ai.AiProfileUtil; import forge.game.ai.AiProfileUtil;
import forge.gui.framework.ICDoc; import forge.gui.framework.ICDoc;
import forge.gui.framework.SLayoutIO;
import forge.gui.toolbox.FSkin; import forge.gui.toolbox.FSkin;
import forge.properties.ForgePreferences; import forge.properties.ForgePreferences;
import forge.properties.ForgePreferences.FPref; import forge.properties.ForgePreferences.FPref;
@@ -107,6 +110,24 @@ public enum CSubmenuPreferences implements ICDoc {
update(); update();
} }
}); });
view.getBtnDeleteEditorUI().setCommand(new Command() {
@Override
public void run() {
String fd = SLayoutIO.getFilePreferred(Screens.DECK_EDITOR_CONSTRUCTED);
File f = new File(fd);
f.delete();
}
});
view.getBtnDeleteMatchUI().setCommand(new Command() {
@Override
public void run() {
String fd = SLayoutIO.getFilePreferred(Screens.MATCH_SCREEN);
File f = new File(fd);
f.delete();
}
});
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@@ -60,8 +60,10 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final FScrollPane scrContent = new FScrollPane(pnlPrefs, private final FScrollPane scrContent = new FScrollPane(pnlPrefs,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
private final FLabel btnReset = new FLabel.Builder().opaque(true) private final FLabel btnReset = new FLabel.Builder().opaque(true).hoverable(true).text("Reset to defaults").build();
.hoverable(true).text("Reset to defaults").build();
private final FLabel btnDeleteMatchUI = new FLabel.Builder().opaque(true).hoverable(true).text("Reset Match Layout").build();
private final FLabel btnDeleteEditorUI = new FLabel.Builder().opaque(true).hoverable(true).text("Reset Editor Layout").build();
private final FLabel lblTitleSkin = new FLabel.Builder() private final FLabel lblTitleSkin = new FLabel.Builder()
.text("Choose Skin").fontStyle(Font.BOLD).fontSize(14).build(); .text("Choose Skin").fontStyle(Font.BOLD).fontSize(14).build();
@@ -148,6 +150,12 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbCloneImgSource, regularConstraints); pnlPrefs.add(cbCloneImgSource, regularConstraints);
pnlPrefs.add(new NoteLabel("When enabled clones will use their original art instead of the cloned card's art"), regularConstraints); pnlPrefs.add(new NoteLabel("When enabled clones will use their original art instead of the cloned card's art"), regularConstraints);
// Troubleshooting
pnlPrefs.add(new SectionLabel("Troubleshooting"), sectionConstraints);
final String twoButtonConstraints = "w 38%!, h 30px!, gap 10% 0 0 10px";
pnlPrefs.add(btnDeleteMatchUI, twoButtonConstraints);
pnlPrefs.add(btnDeleteEditorUI, "w 38%!, h 30px!, gap 0 0 0 10px");
// AI Personality Profile Options // AI Personality Profile Options
pnlPrefs.add(new SectionLabel("AI Options"), sectionConstraints); pnlPrefs.add(new SectionLabel("AI Options"), sectionConstraints);
@@ -488,6 +496,14 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
//========== Overridden from IVDoc //========== Overridden from IVDoc
public final FLabel getBtnDeleteMatchUI() {
return btnDeleteMatchUI;
}
public final FLabel getBtnDeleteEditorUI() {
return btnDeleteEditorUI;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getDocumentID() * @see forge.gui.framework.IVDoc#getDocumentID()
*/ */

View File

@@ -108,7 +108,7 @@ public enum CDock implements ICDoc {
private void saveLayout() { private void saveLayout() {
final SaveOpenDialog dlgSave = new SaveOpenDialog(); final SaveOpenDialog dlgSave = new SaveOpenDialog();
final File defFile = new File(SLayoutIO.getFilePreferred()); final File defFile = new File(SLayoutIO.getFilePreferred(Singletons.getControl().getState()));
final File saveFile = dlgSave.SaveDialog(defFile, Filetypes.LAYOUT); final File saveFile = dlgSave.SaveDialog(defFile, Filetypes.LAYOUT);
if (saveFile != null) { if (saveFile != null) {
SLayoutIO.saveLayout(saveFile); SLayoutIO.saveLayout(saveFile);
@@ -119,7 +119,7 @@ public enum CDock implements ICDoc {
SOverlayUtils.genericOverlay(); SOverlayUtils.genericOverlay();
final SaveOpenDialog dlgOpen = new SaveOpenDialog(); final SaveOpenDialog dlgOpen = new SaveOpenDialog();
final File defFile = new File(SLayoutIO.getFilePreferred()); final File defFile = new File(SLayoutIO.getFilePreferred(Singletons.getControl().getState()));
final File loadFile = dlgOpen.OpenDialog(defFile, Filetypes.LAYOUT); final File loadFile = dlgOpen.OpenDialog(defFile, Filetypes.LAYOUT);
FView.SINGLETON_INSTANCE.getPnlContent().removeAll(); FView.SINGLETON_INSTANCE.getPnlContent().removeAll();