- Converted Skins list to themed combo and added to new Visual Themes section.

This commit is contained in:
spr
2013-07-15 18:56:39 +00:00
parent dd34b9bf0f
commit 70c2d18abe
3 changed files with 1041 additions and 1080 deletions

View File

@@ -12,7 +12,6 @@ import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang3.text.WordUtils;
import org.apache.commons.lang3.tuple.Pair;
import forge.Command;
@@ -56,13 +55,6 @@ public enum CSubmenuPreferences implements ICDoc {
this.view = VSubmenuPreferences.SINGLETON_INSTANCE;
this.prefs = Singletons.getModel().getPreferences();
view.getLstChooseSkin().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
updateSkin();
}
});
view.getLstChooseAIProfile().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
@@ -135,6 +127,7 @@ public enum CSubmenuPreferences implements ICDoc {
});
initializeGameLogVerbosityComboBox();
initializeSkinsComboBox();
}
@@ -145,7 +138,6 @@ public enum CSubmenuPreferences implements ICDoc {
public void update() {
this.view = VSubmenuPreferences.SINGLETON_INSTANCE;
this.prefs = Singletons.getModel().getPreferences();
updateSkinNames();
updateAIProfiles();
view.getCbDevMode().setSelected(prefs.getPrefBoolean(FPref.DEV_MODE_ENABLED));
@@ -212,6 +204,13 @@ public enum CSubmenuPreferences implements ICDoc {
GameLogEntryType selectedItem = GameLogEntryType.valueOf(this.prefs.getPref(userSetting));
panel.setComboBox(comboBox, selectedItem);
}
private void initializeSkinsComboBox() {
FPref userSetting = FPref.UI_SKIN;
FComboBoxPanel<String> panel = this.view.getSkinsComboBoxPanel();
JComboBox<String> comboBox = createComboBox(FSkin.getSkinNamesArray(), userSetting);
String selectedItem = this.prefs.getPref(userSetting);
panel.setComboBox(comboBox, selectedItem);
}
private <E> JComboBox<E> createComboBox(E[] items, final ForgePreferences.FPref setting) {
final JComboBox<E> comboBox = new JComboBox<E>(items);
@@ -230,24 +229,7 @@ public enum CSubmenuPreferences implements ICDoc {
}
});
}
private void updateSkinNames() {
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
final String[] uglyNames = FSkin.getSkins().toArray(ArrayUtils.EMPTY_STRING_ARRAY);
final String[] prettyNames = new String[uglyNames.length];
final String currentName = Singletons.getModel().getPreferences().getPref(FPref.UI_SKIN);
int currentIndex = 0;
for (int i = 0; i < uglyNames.length; i++) {
prettyNames[i] = WordUtils.capitalize(uglyNames[i].replace('_', ' '));
if (currentName.equalsIgnoreCase(prettyNames[i])) { currentIndex = i; }
}
view.getLstChooseSkin().setListData(prettyNames);
view.getLstChooseSkin().setSelectedIndex(currentIndex);
view.getLstChooseSkin().ensureIndexIsVisible(view.getLstChooseSkin().getSelectedIndex());
}
private void updateAIProfiles() {
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
final List<String> profileNames = AiProfileUtil.getProfilesDisplayList();
@@ -262,23 +244,6 @@ public enum CSubmenuPreferences implements ICDoc {
view.getLstChooseAIProfile().setSelectedIndex(currentIndex);
view.getLstChooseAIProfile().ensureIndexIsVisible(view.getLstChooseAIProfile().getSelectedIndex());
}
@SuppressWarnings("serial")
private void updateSkin() {
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
final String name = view.getLstChooseSkin().getSelectedValue().toString();
final ForgePreferences prefs = Singletons.getModel().getPreferences();
if (name.equals(prefs.getPref(FPref.UI_SKIN))) { return; }
view.getScrChooseSkin().setVisible(false);
view.getLblChooseSkin().setText("Please restart Forge (click here to close).");
view.getLblChooseSkin().setHoverable(true);
view.getLblChooseSkin().setCommand(new Command() { @Override
public void run() { RestartUtil.restartApplication(null); } });
prefs.setPref(FPref.UI_SKIN, name);
prefs.save();
}
private void updateAIProfile() {
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;

View File

@@ -66,15 +66,6 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
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()
.text("Choose Skin").fontStyle(Font.BOLD).fontSize(14).build();
private final JList<String> lstChooseSkin = new FList<String>();
private final FLabel lblChooseSkin = new FLabel.Builder().fontSize(12).fontStyle(Font.ITALIC)
.text("Various user-created themes for Forge backgrounds, fonts, and colors.")
.fontAlign(SwingConstants.LEFT).build();
private final JScrollPane scrChooseSkin = new FScrollPane(lstChooseSkin);
private final FLabel lblTitleAIProfile = new FLabel.Builder()
.text("Choose AI Personality").fontStyle(Font.BOLD).fontSize(14).build();
@@ -107,6 +98,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final Map<FPref, KeyboardShortcutField> shortcutFields = new HashMap<FPref, KeyboardShortcutField>();
private final FComboBoxPanel<String> cbpSkin = new FComboBoxPanel<String>("Choose Skin:");
private final FComboBoxPanel<GameLogEntryType> cbpGameLogEntryType =
new FComboBoxPanel<GameLogEntryType>("Game Log Verbosity:");
@@ -181,8 +173,14 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbpGameLogEntryType, "w 80%!, gap 10% 0 0 10px, span 2 1");
pnlPrefs.add(new NoteLabel("Changes how much information is displayed in the game log. Sorted by least to most verbose."), regularConstraints);
// AI Personality Profile Options
// Themes
pnlPrefs.add(new SectionLabel("Visual Themes"), sectionConstraints + ", gaptop 2%");
pnlPrefs.add(cbpSkin, "w 80%!, gap 10% 0 0 10px, span 2 1");
pnlPrefs.add(new NoteLabel("Change the overall look and feel of Forge (RESTART REQUIRED)."), regularConstraints);
// AI Personality Profile Options
pnlPrefs.add(new SectionLabel("AI Options"), sectionConstraints + ", gaptop 2%");
pnlPrefs.add(lblTitleAIProfile, regularConstraints);
@@ -192,9 +190,6 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
// Graphic Options
pnlPrefs.add(new SectionLabel("Graphic Options"), sectionConstraints);
pnlPrefs.add(lblTitleSkin, regularConstraints);
pnlPrefs.add(lblChooseSkin, regularConstraints);
pnlPrefs.add(scrChooseSkin, "h 200px!, w 200px!, gap 10% 0 0 2%, wrap");
pnlPrefs.add(cbRandomFoil, regularConstraints);
pnlPrefs.add(new NoteLabel("Adds foiled effects to random cards."), regularConstraints);
@@ -401,21 +396,6 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
}
}
/** @return {@link javax.swing.JList} */
public final JList<String> getLstChooseSkin() {
return lstChooseSkin;
}
/** @return {@link forge.gui.toolbox.FLabel} */
public final FLabel getLblChooseSkin() {
return lblChooseSkin;
}
/** @return {@link javax.swing.JScrollPane} */
public final JScrollPane getScrChooseSkin() {
return scrChooseSkin;
}
/** @return {@link javax.swing.JList} */
public final JList<String> getLstChooseAIProfile() {
return lstChooseAIProfile;
@@ -539,6 +519,11 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
return cbpGameLogEntryType;
}
public FComboBoxPanel<String> getSkinsComboBoxPanel() {
return cbpSkin;
}
//========== Overridden from IVDoc
public final FLabel getBtnDeleteMatchUI() {

File diff suppressed because it is too large Load Diff