mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Added "reset to default" on prefs settings
This commit is contained in:
@@ -53,7 +53,7 @@ public class ControlQuest {
|
||||
private final MouseAdapter madStartGame, madDuels, madChallenges,
|
||||
madQuests, madDecks, madPreferences;
|
||||
private final ActionListener actPetSelect, actPlantSelect,
|
||||
actSpellShop, actBazaar, actEmbark, actNewDeck, actCurrentDeck;
|
||||
actSpellShop, actBazaar, actEmbark, actNewDeck, actCurrentDeck, actResetPrefs;
|
||||
private final Command cmdDeckExit, cmdDeckDelete, cmdDeckSelect,
|
||||
cmdQuestSelect, cmdQuestDelete;
|
||||
private Deck currentDeck;
|
||||
@@ -147,6 +147,15 @@ public class ControlQuest {
|
||||
}
|
||||
};
|
||||
|
||||
actResetPrefs = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
qPrefs.reset();
|
||||
qPrefs.save();
|
||||
view.resetPrefs();
|
||||
}
|
||||
};
|
||||
|
||||
cmdDeckExit = new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
@@ -243,6 +252,9 @@ public class ControlQuest {
|
||||
view.getLstQuests().setEditCommand(cmdQuestDelete);
|
||||
view.getLstQuests().setDeleteCommand(cmdQuestDelete);
|
||||
|
||||
view.getBtnResetPrefs().removeActionListener(actResetPrefs);
|
||||
view.getBtnResetPrefs().addActionListener(actResetPrefs);
|
||||
|
||||
if (this.qem != null) {
|
||||
view.getBtnStart().removeMouseListener(madStartGame);
|
||||
view.getBtnStart().addMouseListener(madStartGame);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ControlSettings {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (e.getValueIsAdjusting()) { return; }
|
||||
try { updateSkin(); } catch (Exception e1) { e1.printStackTrace(); }
|
||||
updateSkin();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ControlSettings {
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
final boolean toggle = ControlSettings.this.view.getCbAnte().isSelected();
|
||||
prefs.setPref(FPref.UI_ANTE, String.valueOf(toggle));
|
||||
try { prefs.save(); } catch (Exception e) { e.printStackTrace(); }
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ControlSettings {
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
final boolean toggle = ControlSettings.this.view.getCbScaleLarger().isSelected();
|
||||
prefs.setPref(FPref.UI_SCALE_LARGER, String.valueOf(toggle));
|
||||
try { prefs.save(); } catch (Exception e) { e.printStackTrace(); }
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ControlSettings {
|
||||
final boolean toggle = ControlSettings.this.view.getCbDevMode().isSelected();
|
||||
prefs.setPref(FPref.DEV_MODE_ENABLED, String.valueOf(toggle));
|
||||
Constant.Runtime.DEV_MODE[0] = toggle;
|
||||
try { prefs.save(); } catch (Exception e) { e.printStackTrace(); }
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ControlSettings {
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
final boolean toggle = ControlSettings.this.view.getCbRemoveSmall().isSelected();
|
||||
prefs.setPref(FPref.DECKGEN_NOSMALL, String.valueOf(toggle));
|
||||
try { prefs.save(); } catch (Exception e) { e.printStackTrace(); }
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ControlSettings {
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
final boolean toggle = ControlSettings.this.view.getCbRemoveArtifacts().isSelected();
|
||||
prefs.setPref(FPref.DECKGEN_ARTIFACTS, String.valueOf(toggle));
|
||||
try { prefs.save(); } catch (Exception e) { e.printStackTrace(); }
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ControlSettings {
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
final boolean toggle = ControlSettings.this.view.getCbSingletons().isSelected();
|
||||
prefs.setPref(FPref.DECKGEN_SINGLETONS, String.valueOf(toggle));
|
||||
try { prefs.save(); } catch (Exception e) { e.printStackTrace(); }
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -116,7 +116,7 @@ public class ControlSettings {
|
||||
final boolean toggle = ControlSettings.this.view.getCbUploadDraft().isSelected();
|
||||
prefs.setPref(FPref.UI_UPLOAD_DRAFT , String.valueOf(toggle));
|
||||
Constant.Runtime.UPLOAD_DRAFT[0] = toggle;
|
||||
try { prefs.save(); } catch (Exception e) { e.printStackTrace(); }
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -126,7 +126,7 @@ public class ControlSettings {
|
||||
final boolean toggle = ControlSettings.this.view.getCbStackLand().isSelected();
|
||||
prefs.setPref(FPref.UI_SMOOTH_LAND, String.valueOf(toggle));
|
||||
Constant.Runtime.SMOOTH[0] = toggle;
|
||||
try { prefs.save(); } catch (Exception e) { e.printStackTrace(); }
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -136,7 +136,7 @@ public class ControlSettings {
|
||||
final boolean toggle = ControlSettings.this.view.getCbRandomFoil().isSelected();
|
||||
prefs.setPref(FPref.UI_RANDOM_FOIL, String.valueOf(toggle));
|
||||
Constant.Runtime.RANDOM_FOIL[0] = toggle;
|
||||
try { prefs.save(); } catch (Exception e) { e.printStackTrace(); }
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -145,7 +145,15 @@ public class ControlSettings {
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
final boolean toggle = ControlSettings.this.view.getCbTextMana().isSelected();
|
||||
prefs.setPref(FPref.UI_CARD_OVERLAY, String.valueOf(toggle));
|
||||
try { prefs.save(); } catch (Exception e) { e.printStackTrace(); }
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
this.view.getBtnReset().addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
Singletons.getModel().getPreferences().reset();
|
||||
view.getParentView().resetSettings();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -177,6 +177,11 @@ public class ForgePreferences {
|
||||
}
|
||||
}
|
||||
|
||||
/** */
|
||||
public void reset() {
|
||||
this.preferenceValues.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* DUE TO BE DEPRECATED:
|
||||
* Transition code between preference manager for v1.2.2 and v1.2.3.
|
||||
|
||||
@@ -186,6 +186,11 @@ public class QuestPreferences implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
/** */
|
||||
public void reset() {
|
||||
this.preferenceValues.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* DUE TO BE DEPRECATED:
|
||||
* Transition code between preference manager for v1.2.2 and v1.2.3.
|
||||
|
||||
@@ -26,6 +26,7 @@ import javax.swing.AbstractAction;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.Singletons;
|
||||
@@ -236,9 +237,6 @@ public class HomeTopLevel extends FPanel {
|
||||
/** Opens menu for quest mode. */
|
||||
public void showQuestMenu() {
|
||||
clearToggles();
|
||||
btnQuest.setToggled(true);
|
||||
btnQuest.grabFocus();
|
||||
|
||||
pnlContent.removeAll();
|
||||
pnlContent.add(quest, "w 99%!, h 95%!, gaptop 2.5%, gapleft 0.5%");
|
||||
pnlContent.revalidate();
|
||||
@@ -247,13 +245,18 @@ public class HomeTopLevel extends FPanel {
|
||||
Singletons.getModel().getPreferences().setPref(FPref.UI_HOMEMENU,
|
||||
ForgePreferences.HomeMenus.quest.toString());
|
||||
Singletons.getModel().getPreferences().save();
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() { @Override
|
||||
public void run() {
|
||||
btnQuest.setToggled(true);
|
||||
btnQuest.grabFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Opens menu for settings. */
|
||||
public void showSettingsMenu() {
|
||||
clearToggles();
|
||||
btnSettings.setToggled(true);
|
||||
btnSettings.grabFocus();
|
||||
|
||||
pnlContent.removeAll();
|
||||
pnlContent.add(settings, "w 99%!, h 95%!, gaptop 2.5%, gapleft 0.5%");
|
||||
@@ -263,6 +266,13 @@ public class HomeTopLevel extends FPanel {
|
||||
Singletons.getModel().getPreferences().setPref(FPref.UI_HOMEMENU,
|
||||
ForgePreferences.HomeMenus.settings.toString());
|
||||
Singletons.getModel().getPreferences().save();
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() { @Override
|
||||
public void run() {
|
||||
btnSettings.setToggled(true);
|
||||
btnSettings.grabFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Opens menu for utilities. */
|
||||
@@ -317,6 +327,12 @@ public class HomeTopLevel extends FPanel {
|
||||
showQuestMenu();
|
||||
}
|
||||
|
||||
/** */
|
||||
public void resetSettings() {
|
||||
settings = new ViewSettings(this);
|
||||
showSettingsMenu();
|
||||
}
|
||||
|
||||
/** @return ControlHomeUI */
|
||||
public ControlHomeUI getController() {
|
||||
return control;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.view.home;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
@@ -17,6 +16,7 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.MatteBorder;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
@@ -57,7 +57,8 @@ public class ViewQuest extends JScrollPane {
|
||||
private final JLabel lblTitle, lblLife, lblCredits,
|
||||
lblWins, lblLosses, lblNextChallengeInWins, lblWinStreak;
|
||||
|
||||
private final JButton btnBazaar, btnSpellShop, btnStart, btnEmbark, btnNewDeck, btnCurrentDeck;
|
||||
private final JButton btnBazaar, btnSpellShop, btnStart, btnEmbark,
|
||||
btnResetPrefs, btnNewDeck, btnCurrentDeck;
|
||||
|
||||
private final JCheckBox cbPlant, cbZep, cbStandardStart;
|
||||
private final JComboBox cbxPet;
|
||||
@@ -126,6 +127,7 @@ public class ViewQuest extends JScrollPane {
|
||||
btnStart = new StartButton(parentView);
|
||||
btnEmbark = new SubButton("Embark!");
|
||||
btnNewDeck = new SubButton("Build a New Deck");
|
||||
btnResetPrefs = new SubButton("Reset to Defaults");
|
||||
cbxPet = new JComboBox();
|
||||
cbStandardStart = new FCheckBox("Standard (Type 2) Starting Pool");
|
||||
cbPlant = new FCheckBox("Summon Plant");
|
||||
@@ -167,7 +169,11 @@ public class ViewQuest extends JScrollPane {
|
||||
populateNewQuest();
|
||||
populatePrefs();
|
||||
|
||||
// Init controller, select quest and deck, then start in duels tab.
|
||||
// If start when quest submenu is shown,
|
||||
// it will need a few cycles to read the quest datas.
|
||||
hideAllPanels();
|
||||
|
||||
// Init controller, select quest and deck.
|
||||
this.control = new ControlQuest(this);
|
||||
control.refreshQuests();
|
||||
control.refreshDecks();
|
||||
@@ -322,8 +328,10 @@ public class ViewQuest extends JScrollPane {
|
||||
/** Layout permanent parts of prefs panel. */
|
||||
private void populatePrefs() {
|
||||
pnlPrefs.setOpaque(false);
|
||||
pnlPrefs.setLayout(new MigLayout("insets 0, gap 0"));
|
||||
pnlPrefs.setLayout(new MigLayout("insets 0, gap 0, wrap"));
|
||||
|
||||
pnlPrefs.add(new QuestPreferencesHandler(), "w 100%!");
|
||||
pnlPrefs.add(btnResetPrefs, " w 60%!, h 30px!, gap 20% 0 20px 20px");
|
||||
}
|
||||
|
||||
private void hideAllPanels() {
|
||||
@@ -396,6 +404,14 @@ public class ViewQuest extends JScrollPane {
|
||||
}
|
||||
}
|
||||
|
||||
/** */
|
||||
public void resetPrefs() {
|
||||
pnlPrefs.removeAll();
|
||||
populatePrefs();
|
||||
pnlPrefs.revalidate();
|
||||
this.getParentView().getBtnQuest().grabFocus();
|
||||
}
|
||||
|
||||
//========= TAB SHOW METHODS
|
||||
/** Display handler for duel tab click. */
|
||||
public void showDuelsTab() {
|
||||
@@ -412,8 +428,6 @@ public class ViewQuest extends JScrollPane {
|
||||
updateDuels();
|
||||
updateStats();
|
||||
lblTitle.setText("Duels: " + control.getRankString());
|
||||
pnlStats.setVisible(true);
|
||||
pnlDuels.setVisible(true);
|
||||
|
||||
if (control.getCurrentDeck() != null) {
|
||||
pnlStart.setVisible(true);
|
||||
@@ -422,6 +436,14 @@ public class ViewQuest extends JScrollPane {
|
||||
selectedOpponent = (SelectablePanel) pnlDuels.getComponent(0);
|
||||
selectedOpponent.setBackground(skin.getColor(FSkin.Colors.CLR_ACTIVE));
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pnlStats.setVisible(true);
|
||||
pnlDuels.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Display handler for duel tab click. */
|
||||
@@ -439,8 +461,6 @@ public class ViewQuest extends JScrollPane {
|
||||
updateChallenges();
|
||||
updateStats();
|
||||
lblTitle.setText("Challenges: " + control.getRankString());
|
||||
pnlStats.setVisible(true);
|
||||
pnlChallenges.setVisible(true);
|
||||
|
||||
// Select first event.
|
||||
if (pnlChallenges.getComponentCount() > 0) {
|
||||
@@ -449,7 +469,13 @@ public class ViewQuest extends JScrollPane {
|
||||
selectedOpponent.setBackground(skin.getColor(FSkin.Colors.CLR_ACTIVE));
|
||||
}
|
||||
|
||||
this.getViewport().setViewPosition(new Point(0, 0));
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pnlStats.setVisible(true);
|
||||
pnlChallenges.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Display handler for decks tab click. */
|
||||
@@ -707,6 +733,11 @@ public class ViewQuest extends JScrollPane {
|
||||
return btnEmbark;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JButton} */
|
||||
public JButton getBtnResetPrefs() {
|
||||
return btnResetPrefs;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JButton} */
|
||||
public JButton getBtnNewDeck() {
|
||||
return btnNewDeck;
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
@@ -52,6 +53,7 @@ public class ViewSettings extends JScrollPane {
|
||||
private final ControlSettings control;
|
||||
private final FSkin skin;
|
||||
private final JPanel viewport;
|
||||
private final JButton btnReset;
|
||||
private HomeTopLevel parentView;
|
||||
|
||||
private JList lstChooseSkin;
|
||||
@@ -190,10 +192,17 @@ public class ViewSettings extends JScrollPane {
|
||||
for (Shortcut s : shortcuts) {
|
||||
lblTemp = new FLabel(s.getDescription());
|
||||
KeyboardShortcutField ksf = new KeyboardShortcutField(s);
|
||||
viewport.add(lblTemp, "w 40%!, gap 10%! 0 0 1%");
|
||||
viewport.add(lblTemp, "w 40%!, h 22px!, gap 10%! 0 0 1%");
|
||||
viewport.add(ksf, "w 25%!");
|
||||
}
|
||||
|
||||
// Reset button
|
||||
final JLabel lblReset = new SectionLabel(" ");
|
||||
viewport.add(lblReset, sectionConstraints);
|
||||
|
||||
btnReset = new SubButton("Reset to defaults");
|
||||
viewport.add(btnReset, sectionConstraints);
|
||||
|
||||
this.control = new ControlSettings(this);
|
||||
}
|
||||
|
||||
@@ -457,4 +466,9 @@ public class ViewSettings extends JScrollPane {
|
||||
public HomeTopLevel getParentView() {
|
||||
return parentView;
|
||||
}
|
||||
|
||||
/** @return {@link forge.view.home.HomeTopLevel} */
|
||||
public JButton getBtnReset() {
|
||||
return btnReset;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ public class ViewWinLose {
|
||||
|
||||
// Assemble game log scroller.
|
||||
txtLog = new FTextArea();
|
||||
txtLog.setBorder(null);
|
||||
txtLog.setText(AllZone.getGameLog().getLogText());
|
||||
txtLog.setFont(skin.getFont(14));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user