mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Add Theme submenu to Layout menu
This commit is contained in:
@@ -219,19 +219,13 @@ public enum CSubmenuPreferences implements ICDoc {
|
|||||||
private void initializeSkinsComboBox() {
|
private void initializeSkinsComboBox() {
|
||||||
FPref userSetting = FPref.UI_SKIN;
|
FPref userSetting = FPref.UI_SKIN;
|
||||||
FComboBoxPanel<String> panel = this.view.getSkinsComboBoxPanel();
|
FComboBoxPanel<String> panel = this.view.getSkinsComboBoxPanel();
|
||||||
String[] installedSkins = getSortedListOfInstalledSkins();
|
String[] installedSkins = FSkin.getSkinNamesArray(true);
|
||||||
validatePreferredSkinName(installedSkins);
|
validatePreferredSkinName(installedSkins);
|
||||||
JComboBox<String> comboBox = createComboBox(installedSkins, userSetting);
|
JComboBox<String> comboBox = createComboBox(installedSkins, userSetting);
|
||||||
String selectedItem = this.prefs.getPref(userSetting);
|
String selectedItem = this.prefs.getPref(userSetting);
|
||||||
panel.setComboBox(comboBox, selectedItem);
|
panel.setComboBox(comboBox, selectedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getSortedListOfInstalledSkins() {
|
|
||||||
String[] skins = FSkin.getSkinNamesArray();
|
|
||||||
java.util.Arrays.sort(skins);
|
|
||||||
return skins;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validatePreferredSkinName(String[] installedSkins) {
|
private void validatePreferredSkinName(String[] installedSkins) {
|
||||||
String preferredSkin = this.prefs.getPref(FPref.UI_SKIN);
|
String preferredSkin = this.prefs.getPref(FPref.UI_SKIN);
|
||||||
if (!Arrays.asList(installedSkins).contains(preferredSkin)) {
|
if (!Arrays.asList(installedSkins).contains(preferredSkin)) {
|
||||||
|
|||||||
@@ -5,11 +5,15 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
|
import javax.swing.ButtonGroup;
|
||||||
import javax.swing.JCheckBoxMenuItem;
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JRadioButtonMenuItem;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
|
import forge.control.RestartUtil;
|
||||||
import forge.control.FControl.Screens;
|
import forge.control.FControl.Screens;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
import forge.gui.match.controllers.CDock;
|
import forge.gui.match.controllers.CDock;
|
||||||
@@ -40,8 +44,9 @@ public final class LayoutMenu {
|
|||||||
if (currentScreen != Screens.HOME_SCREEN) {
|
if (currentScreen != Screens.HOME_SCREEN) {
|
||||||
menu.add(getMenu_ViewOptions());
|
menu.add(getMenu_ViewOptions());
|
||||||
menu.add(getMenu_FileOptions());
|
menu.add(getMenu_FileOptions());
|
||||||
menu.addSeparator();
|
|
||||||
}
|
}
|
||||||
|
menu.add(getMenu_ThemeOptions());
|
||||||
|
menu.addSeparator();
|
||||||
menu.add(getMenuItem_SetWindowSize());
|
menu.add(getMenuItem_SetWindowSize());
|
||||||
if (currentScreen != Screens.HOME_SCREEN) {
|
if (currentScreen != Screens.HOME_SCREEN) {
|
||||||
menu.add(getMenuItem_RevertLayout());
|
menu.add(getMenuItem_RevertLayout());
|
||||||
@@ -65,6 +70,49 @@ public final class LayoutMenu {
|
|||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static JMenu getMenu_ThemeOptions() {
|
||||||
|
JMenu menu = new JMenu("Theme");
|
||||||
|
JRadioButtonMenuItem menuItem;
|
||||||
|
ButtonGroup group = new ButtonGroup();
|
||||||
|
String currentSkin = prefs.getPref(FPref.UI_SKIN);
|
||||||
|
String[] skins = FSkin.getSkinNamesArray(true);
|
||||||
|
for (String skin : skins) {
|
||||||
|
menuItem = new JRadioButtonMenuItem(skin);
|
||||||
|
group.add(menuItem);
|
||||||
|
if (skin.equals(currentSkin)) {
|
||||||
|
menuItem.setSelected(true);
|
||||||
|
}
|
||||||
|
menuItem.setActionCommand(skin);
|
||||||
|
menuItem.addActionListener(changeSkin);
|
||||||
|
menu.add(menuItem);
|
||||||
|
}
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ActionListener changeSkin = new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
String skin = e.getActionCommand();
|
||||||
|
if (!skin.equals(prefs.getPref(FPref.UI_SKIN))) {
|
||||||
|
prefs.setPref(FPref.UI_SKIN, skin);
|
||||||
|
prefs.save();
|
||||||
|
|
||||||
|
Object[] options = {"Restart Now", "Restart Later"};
|
||||||
|
int reply = JOptionPane.showOptionDialog(
|
||||||
|
null,
|
||||||
|
"You must restart Forge for " + skin + " theme to take effect.",
|
||||||
|
"Change Theme",
|
||||||
|
JOptionPane.YES_NO_OPTION,
|
||||||
|
JOptionPane.INFORMATION_MESSAGE,
|
||||||
|
null,
|
||||||
|
options,
|
||||||
|
options[0]);
|
||||||
|
if (reply == JOptionPane.YES_OPTION) {
|
||||||
|
RestartUtil.restartApplication(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private static JMenuItem getMenuItem_ShowBackgroundImage() {
|
private static JMenuItem getMenuItem_ShowBackgroundImage() {
|
||||||
final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem("Background Image");
|
final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem("Background Image");
|
||||||
|
|||||||
@@ -786,12 +786,15 @@ public enum FSkin {
|
|||||||
return mySkins;
|
return mySkins;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getSkinNamesArray() {
|
public static String[] getSkinNamesArray(boolean sorted) {
|
||||||
ArrayList<String> skinDirectoryNames = getSkinDirectoryNames();
|
ArrayList<String> skinDirectoryNames = getSkinDirectoryNames();
|
||||||
String[] prettySkinNames = new String[skinDirectoryNames.size()];
|
String[] prettySkinNames = new String[skinDirectoryNames.size()];
|
||||||
for (int i = 0; i < skinDirectoryNames.size(); i++) {
|
for (int i = 0; i < skinDirectoryNames.size(); i++) {
|
||||||
prettySkinNames[i] = WordUtils.capitalize(skinDirectoryNames.get(i).replace('_', ' '));
|
prettySkinNames[i] = WordUtils.capitalize(skinDirectoryNames.get(i).replace('_', ' '));
|
||||||
}
|
}
|
||||||
|
if (sorted) {
|
||||||
|
java.util.Arrays.sort(prettySkinNames);
|
||||||
|
}
|
||||||
return prettySkinNames;
|
return prettySkinNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user