"Pretty names" for skin names in settings submenu.

This commit is contained in:
Doublestrike
2012-02-16 05:38:15 +00:00
parent 9bace55ddd
commit dd91eb2c66
3 changed files with 21 additions and 5 deletions

View File

@@ -40,6 +40,8 @@ public class ControlSettings {
*/ */
public ControlSettings(ViewSettings v0) { public ControlSettings(ViewSettings v0) {
this.view = v0; this.view = v0;
view.updateSkinNames();
addListeners(); addListeners();
prefs = Singletons.getModel().getPreferences(); prefs = Singletons.getModel().getPreferences();

View File

@@ -27,6 +27,7 @@ import javax.swing.border.MatteBorder;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.text.WordUtils;
import forge.PlayerType; import forge.PlayerType;
import forge.Singletons; import forge.Singletons;
@@ -130,6 +131,20 @@ public class ViewSettings extends JPanel {
showPrefsTab(); showPrefsTab();
} }
/** */
public void updateSkinNames() {
String[] uglyNames = FSkin.getSkins().toArray(new String[0]);
String[] prettyNames = new String[uglyNames.length];
for (int i = 0; i < uglyNames.length; i++) {
prettyNames[i] = WordUtils.capitalize(uglyNames[i].replace('_', ' '));
}
lstChooseSkin.setListData(prettyNames);
lstChooseSkin.setSelectedValue(Singletons.getModel().getPreferences().getPref(FPref.UI_SKIN), true);
lstChooseSkin.ensureIndexIsVisible(lstChooseSkin.getSelectedIndex());
}
private void populateTabber() { private void populateTabber() {
tabPrefs.setToolTipText("Global preference options"); tabPrefs.setToolTipText("Global preference options");
tabAvatars.setToolTipText("Human and AI avatar select"); tabAvatars.setToolTipText("Human and AI avatar select");
@@ -181,10 +196,7 @@ public class ViewSettings extends JPanel {
pnlPrefs.add(lblTitleSkin, regularConstraints); pnlPrefs.add(lblTitleSkin, regularConstraints);
pnlPrefs.add(new NoteLabel("Various user-created themes for Forge backgrounds, fonts, and colors."), regularConstraints); pnlPrefs.add(new NoteLabel("Various user-created themes for Forge backgrounds, fonts, and colors."), regularConstraints);
pnlPrefs.add(new FScrollPane(lstChooseSkin), "h 60px!, w 150px!, gap 10% 0 0 2%, wrap"); pnlPrefs.add(new FScrollPane(lstChooseSkin), "h 120px!, w 150px!, gap 10% 0 0 2%, wrap");
lstChooseSkin.setListData(FSkin.getSkins().toArray(new String[0]));
lstChooseSkin.setSelectedValue(Singletons.getModel().getPreferences().getPref(FPref.UI_SKIN), true);
lstChooseSkin.ensureIndexIsVisible(lstChooseSkin.getSelectedIndex());
pnlPrefs.add(new FLabel.Builder().text("Card Size").fontStyle(Font.BOLD).build(), regularConstraints); pnlPrefs.add(new FLabel.Builder().text("Card Size").fontStyle(Font.BOLD).build(), regularConstraints);
pnlPrefs.add(new NoteLabel("Size of cards in hand and playing field, when possible"), regularConstraints); pnlPrefs.add(new NoteLabel("Size of cards in hand and playing field, when possible"), regularConstraints);

View File

@@ -353,7 +353,7 @@ public enum FSkin {
GuiUtils.checkEDT("FSkin$constructor", false); GuiUtils.checkEDT("FSkin$constructor", false);
// Non-default (preferred) skin name and dir. // Non-default (preferred) skin name and dir.
FSkin.preferredName = skinName; FSkin.preferredName = skinName.toLowerCase().replace(' ', '_');
FSkin.preferredDir = FILE_SKINS_DIR + preferredName + "/"; FSkin.preferredDir = FILE_SKINS_DIR + preferredName + "/";
if (FSkin.icons != null) { FSkin.icons.clear(); } if (FSkin.icons != null) { FSkin.icons.clear(); }
@@ -763,6 +763,8 @@ public enum FSkin {
h0 = tempCoords[3]; h0 = tempCoords[3];
BufferedImage img = testPreferredSprite(s0); BufferedImage img = testPreferredSprite(s0);
if (s0 == Backgrounds.BG_TEXTURE) { System.out.println("asdf found it"); }
FSkin.icons.put(s0, new ImageIcon(img.getSubimage(x0, y0, w0, h0))); FSkin.icons.put(s0, new ImageIcon(img.getSubimage(x0, y0, w0, h0)));
} }