mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
add Choose Skin button to New Gui Home > Settings and hook it up.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -10754,6 +10754,7 @@ src/main/java/forge/control/ControlMatchUI.java -text
|
|||||||
src/main/java/forge/control/ControlWinLose.java -text
|
src/main/java/forge/control/ControlWinLose.java -text
|
||||||
src/main/java/forge/control/home/ControlConstructed.java -text
|
src/main/java/forge/control/home/ControlConstructed.java -text
|
||||||
src/main/java/forge/control/home/ControlQuest.java -text
|
src/main/java/forge/control/home/ControlQuest.java -text
|
||||||
|
src/main/java/forge/control/home/ControlSettings.java -text
|
||||||
src/main/java/forge/control/home/package-info.java -text svneol=native#text/plain
|
src/main/java/forge/control/home/package-info.java -text svneol=native#text/plain
|
||||||
src/main/java/forge/control/match/ControlDetail.java -text
|
src/main/java/forge/control/match/ControlDetail.java -text
|
||||||
src/main/java/forge/control/match/ControlDock.java -text
|
src/main/java/forge/control/match/ControlDock.java -text
|
||||||
|
|||||||
67
src/main/java/forge/control/home/ControlSettings.java
Normal file
67
src/main/java/forge/control/home/ControlSettings.java
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
package forge.control.home;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import forge.AllZone;
|
||||||
|
import forge.Singletons;
|
||||||
|
import forge.error.ErrorViewer;
|
||||||
|
import forge.gui.ListChooser;
|
||||||
|
import forge.properties.ForgePreferences;
|
||||||
|
import forge.view.home.ViewSettings;
|
||||||
|
import forge.view.toolbox.FSkin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls logic and listeners for Settings panel of the home screen.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ControlSettings {
|
||||||
|
private ViewSettings view;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Controls logic and listeners for Settings panel of the home screen.
|
||||||
|
*
|
||||||
|
* @param v0   ViewSettings
|
||||||
|
*/
|
||||||
|
public ControlSettings(ViewSettings v0) {
|
||||||
|
this.view = v0;
|
||||||
|
addListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return ViewSettings */
|
||||||
|
public ViewSettings getView() {
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public void addListeners() {
|
||||||
|
this.view.getBtnChooseSkin().addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(final ActionEvent arg0) {
|
||||||
|
doChooseSkin();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doChooseSkin() {
|
||||||
|
final ListChooser<String> ch = new ListChooser<String>("Choose a skin", 0, 1, FSkin.getSkins());
|
||||||
|
if (ch.show()) {
|
||||||
|
try {
|
||||||
|
final String name = ch.getSelectedValue();
|
||||||
|
final int index = ch.getSelectedIndex();
|
||||||
|
if (index == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ForgePreferences preferences = Singletons.getModel().getPreferences();
|
||||||
|
preferences.setSkin(name);
|
||||||
|
final FSkin skin = new FSkin(name);
|
||||||
|
AllZone.setSkin(skin);
|
||||||
|
preferences.save();
|
||||||
|
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
ErrorViewer.showError(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import javax.swing.border.MatteBorder;
|
|||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
|
import forge.control.home.ControlSettings;
|
||||||
import forge.view.toolbox.FSkin;
|
import forge.view.toolbox.FSkin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,8 +22,11 @@ import forge.view.toolbox.FSkin;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ViewSettings extends JScrollPane {
|
public class ViewSettings extends JScrollPane {
|
||||||
|
private ControlSettings control;
|
||||||
private FSkin skin;
|
private FSkin skin;
|
||||||
private JPanel viewport;
|
private JPanel viewport;
|
||||||
|
|
||||||
|
SubButton btnChooseSkin;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* TODO: Write javadoc for Constructor.
|
* TODO: Write javadoc for Constructor.
|
||||||
@@ -110,6 +114,9 @@ public class ViewSettings extends JScrollPane {
|
|||||||
lblTitleGraphics.setForeground(skin.getColor("text"));
|
lblTitleGraphics.setForeground(skin.getColor("text"));
|
||||||
viewport.add(lblTitleGraphics, constraints2);
|
viewport.add(lblTitleGraphics, constraints2);
|
||||||
|
|
||||||
|
btnChooseSkin = new SubButton("Choose Skin");
|
||||||
|
viewport.add(btnChooseSkin, "gapleft 10%, h 25px!, w 150px!, gapbottom 2px");
|
||||||
|
|
||||||
OptionsCheckBox cbRandomFoil = new OptionsCheckBox("Random Foil");
|
OptionsCheckBox cbRandomFoil = new OptionsCheckBox("Random Foil");
|
||||||
NoteLabel lblRandomFoil = new NoteLabel("Adds foiled effects to random cards.");
|
NoteLabel lblRandomFoil = new NoteLabel("Adds foiled effects to random cards.");
|
||||||
viewport.add(cbRandomFoil, constraints);
|
viewport.add(cbRandomFoil, constraints);
|
||||||
@@ -124,6 +131,8 @@ public class ViewSettings extends JScrollPane {
|
|||||||
NoteLabel lblTextMana = new NoteLabel("Overlays each card with basic card-specific information.");
|
NoteLabel lblTextMana = new NoteLabel("Overlays each card with basic card-specific information.");
|
||||||
viewport.add(cbTextMana, constraints);
|
viewport.add(cbTextMana, constraints);
|
||||||
viewport.add(lblTextMana, constraints2);
|
viewport.add(lblTextMana, constraints2);
|
||||||
|
|
||||||
|
ViewSettings.this.control = new ControlSettings(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Consolidates checkbox styling in one place. */
|
/** Consolidates checkbox styling in one place. */
|
||||||
@@ -157,4 +166,12 @@ public class ViewSettings extends JScrollPane {
|
|||||||
setForeground(skin.getColor("text"));
|
setForeground(skin.getColor("text"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SubButton getBtnChooseSkin() {
|
||||||
|
return btnChooseSkin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControlSettings getController() {
|
||||||
|
return ViewSettings.this.control;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user