mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
- Converted Skins list to themed combo and added to new Visual Themes section.
This commit is contained in:
@@ -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);
|
||||
@@ -231,23 +230,6 @@ 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();
|
||||
@@ -263,23 +245,6 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
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;
|
||||
final String name = view.getLstChooseAIProfile().getSelectedValue().toString();
|
||||
|
||||
@@ -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:");
|
||||
|
||||
@@ -182,7 +174,13 @@ 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() {
|
||||
|
||||
@@ -37,6 +37,8 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.view.FView;
|
||||
@@ -739,7 +741,7 @@ public enum FSkin {
|
||||
*
|
||||
* @return the skins
|
||||
*/
|
||||
public static ArrayList<String> getSkins() {
|
||||
public static ArrayList<String> getSkinDirectoryNames() {
|
||||
final ArrayList<String> mySkins = new ArrayList<String>();
|
||||
|
||||
final File dir = new File(FILE_SKINS_DIR);
|
||||
@@ -757,6 +759,15 @@ public enum FSkin {
|
||||
return mySkins;
|
||||
}
|
||||
|
||||
public static String[] getSkinNamesArray() {
|
||||
ArrayList<String> skinDirectoryNames = getSkinDirectoryNames();
|
||||
String[] prettySkinNames = new String[skinDirectoryNames.size()];
|
||||
for (int i = 0; i < skinDirectoryNames.size(); i++) {
|
||||
prettySkinNames[i] = WordUtils.capitalize(skinDirectoryNames.get(i).replace('_', ' '));
|
||||
}
|
||||
return prettySkinNames;
|
||||
}
|
||||
|
||||
/** @return Map<Integer, Image> */
|
||||
public static Map<Integer, Image> getAvatars() {
|
||||
return avatars;
|
||||
|
||||
Reference in New Issue
Block a user