- Updated FSkin with comments and finished TODOs.

- Simplified color palette for skins
- Added support for alpha channel in skin colors
- Updated files affected by color palette change
This commit is contained in:
Doublestrike
2011-11-04 12:56:39 +00:00
parent 28f3a434b3
commit 7a62c0cdbc
5 changed files with 282 additions and 187 deletions

View File

@@ -40,7 +40,7 @@ public class FButton extends JButton {
super(msg); super(msg);
this.skin = AllZone.getSkin(); this.skin = AllZone.getSkin();
this.setOpaque(false); this.setOpaque(false);
this.setForeground(this.skin.getTxt1a()); this.setForeground(this.skin.getClrText());
this.setBackground(Color.red); this.setBackground(Color.red);
this.setContentAreaFilled(false); this.setContentAreaFilled(false);
this.setMargin(new Insets(0, 25, 0, 25)); this.setMargin(new Insets(0, 25, 0, 25));

View File

@@ -1,5 +1,6 @@
package forge.gui.skin; package forge.gui.skin;
import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.LayoutManager; import java.awt.LayoutManager;
@@ -77,4 +78,16 @@ public class FPanel extends JPanel {
this.setOpaque(false); this.setOpaque(false);
} }
} }
public void setPreferredSize(int w, int h) {
setPreferredSize(new Dimension(w,h));
}
public void setMaximumSize(int w, int h) {
setMaximumSize(new Dimension(w,h));
}
public void setMinimumSize(int w, int h) {
setMinimumSize(new Dimension(w,h));
}
} }

View File

@@ -19,97 +19,74 @@ import forge.gui.GuiUtils;
public class FSkin { public class FSkin {
// ===== Public fields // ===== Public fields
/** The font1. */ /** Primary font used in titles and buttons and most text output. */
private Font font1 = null; private Font font1 = null;
/** The font2. */ /** Secondary font used where a sub-block of text needs it. */
private Font font2 = null; private Font font2 = null;
/** The texture1. */ /** Primary texture used in skin. */
private ImageIcon texture1 = null; private ImageIcon texture1 = null;
/** The texture2. */ /** Left side of button, up state. */
private ImageIcon texture2 = null;
/** The texture3. */
private ImageIcon texture3 = null;
/** The btn lup. */
private ImageIcon btnLup = null; private ImageIcon btnLup = null;
/** The btn mup. */ /** Middle of button, up state. */
private ImageIcon btnMup = null; private ImageIcon btnMup = null;
/** The btn rup. */ /** Right side of button, up state. */
private ImageIcon btnRup = null; private ImageIcon btnRup = null;
/** The btn lover. */ /** Button, left side, over state. */
private ImageIcon btnLover = null; private ImageIcon btnLover = null;
/** The btn mover. */ /** Button, middle, over state. */
private ImageIcon btnMover = null; private ImageIcon btnMover = null;
/** The btn rover. */ /** Button, right side, over state. */
private ImageIcon btnRover = null; private ImageIcon btnRover = null;
/** The btn ldown. */ /** Button, left side, down state. */
private ImageIcon btnLdown = null; private ImageIcon btnLdown = null;
/** The btn mdown. */ /** Button, middle, down state. */
private ImageIcon btnMdown = null; private ImageIcon btnMdown = null;
/** The btn rdown. */ /** Button, right side, down state. */
private ImageIcon btnRdown = null; private ImageIcon btnRdown = null;
/** The splash. */ /** Splash screen image. */
private ImageIcon splash = null; private ImageIcon splash = null;
/** The bg1a. */ /** Base color used in skin. */
private Color bg1a = Color.red; private Color clrTheme = Color.red;
/** The bg1b. */ /** Border color. */
private Color bg1b = Color.red; private Color clrBorders = Color.red;
/** The bg2a. */ /** Color of zebra striping in grid displays. */
private Color bg2a = Color.red; private Color clrZebra = Color.red;
/** The bg2b. */ /** Color of elements in mouseover state. */
private Color bg2b = Color.red; private Color clrHover = Color.red;
/** The bg3a. */ /** Color of active (currently selected) elements. */
private Color bg3a = Color.red; private Color clrActive = Color.red;
/** The bg3b. */ /** Color of inactive (not currently selected) elements. */
private Color bg3b = Color.red; private Color clrInactive = Color.red;
/** The txt1a. */ /** Color of text in skin. */
private Color txt1a = Color.red; private Color clrText = Color.red;
/** The txt1b. */ /** Name of skin. */
private Color txt1b = Color.red;
/** The txt2a. */
private Color txt2a = Color.red;
/** The txt2b. */
private Color txt2b = Color.red;
/** The txt3a. */
private Color txt3a = Color.red;
/** The txt3b. */
private Color txt3b = Color.red;
/** The name. */
private String name = "default"; private String name = "default";
// ===== Private fields // ===== Private fields
private final String paletteFile = "palette.jpg"; private final String paletteFile = "palette.png";
private final String font1file = "font1.ttf"; private final String font1file = "font1.ttf";
private final String font2file = "font2.ttf"; private final String font2file = "font2.ttf";
private final String texture1file = "texture1.jpg"; private final String texture1file = "texture1.jpg";
private final String texture2file = "texture2.jpg";
private final String texture3file = "texture3.jpg";
private final String btnLupfile = "btnLup.png"; private final String btnLupfile = "btnLup.png";
private final String btnMupfile = "btnMup.png"; private final String btnMupfile = "btnMup.png";
private final String btnRupfile = "btnRup.png"; private final String btnRupfile = "btnRup.png";
@@ -168,8 +145,6 @@ public class FSkin {
// Images // Images
this.setTexture1(this.retrieveImage(dirName + this.texture1file)); this.setTexture1(this.retrieveImage(dirName + this.texture1file));
this.texture2 = this.retrieveImage(dirName + this.texture2file);
this.texture3 = this.retrieveImage(dirName + this.texture3file);
this.setBtnLup(this.retrieveImage(dirName + this.btnLupfile)); this.setBtnLup(this.retrieveImage(dirName + this.btnLupfile));
this.setBtnMup(this.retrieveImage(dirName + this.btnMupfile)); this.setBtnMup(this.retrieveImage(dirName + this.btnMupfile));
this.setBtnRup(this.retrieveImage(dirName + this.btnRupfile)); this.setBtnRup(this.retrieveImage(dirName + this.btnRupfile));
@@ -186,19 +161,13 @@ public class FSkin {
BufferedImage image; BufferedImage image;
try { try {
image = ImageIO.read(file); image = ImageIO.read(file);
this.setBg1a(this.getColorFromPixel(image.getRGB(10, 30))); this.setClrTheme(this.getColorFromPixel(image.getRGB(60, 10)));
this.setBg1b(this.getColorFromPixel(image.getRGB(30, 30))); this.setClrBorders(this.getColorFromPixel(image.getRGB(60, 30)));
this.bg2a = this.getColorFromPixel(image.getRGB(50, 30)); this.setClrZebra(this.getColorFromPixel(image.getRGB(60, 50)));
this.bg2b = this.getColorFromPixel(image.getRGB(70, 30)); this.setClrHover(this.getColorFromPixel(image.getRGB(60, 70)));
this.bg3a = this.getColorFromPixel(image.getRGB(90, 30)); this.setClrActive(this.getColorFromPixel(image.getRGB(60, 90)));
this.bg3b = this.getColorFromPixel(image.getRGB(110, 30)); this.setClrInactive(this.getColorFromPixel(image.getRGB(60, 110)));
this.setClrText(this.getColorFromPixel(image.getRGB(60, 130)));
this.setTxt1a(this.getColorFromPixel(image.getRGB(10, 70)));
this.txt1b = this.getColorFromPixel(image.getRGB(30, 70));
this.txt2a = this.getColorFromPixel(image.getRGB(50, 70));
this.txt2b = this.getColorFromPixel(image.getRGB(70, 70));
this.txt3a = this.getColorFromPixel(image.getRGB(90, 70));
this.txt3b = this.getColorFromPixel(image.getRGB(110, 70));
} catch (final IOException e) { } catch (final IOException e) {
System.err.println(this.notfound + this.paletteFile); System.err.println(this.notfound + this.paletteFile);
} }
@@ -229,8 +198,7 @@ public class FSkin {
* retrieveFont. * retrieveFont.
* </p> * </p>
* Uses GuiUtils to grab a font file at an address. Error will be reported * Uses GuiUtils to grab a font file at an address. Error will be reported
* by GuiUtils if not found. Error also reported by this method if not * by GuiUtils if not found.
* found.
* *
* @param {@link java.lang.String} address * @param {@link java.lang.String} address
* @return a Font * @return a Font
@@ -249,230 +217,340 @@ public class FSkin {
* @param {@link java.lang.Integer} pixel information * @param {@link java.lang.Integer} pixel information
*/ */
private Color getColorFromPixel(final int pixel) { private Color getColorFromPixel(final int pixel) {
return new Color((pixel & 0x00ff0000) >> 16, (pixel & 0x0000ff00) >> 8, (pixel & 0x000000ff)); int r, g, b, a;
a = (pixel >> 24) & 0x000000ff;
r = (pixel >> 16) & 0x000000ff;
g = (pixel >> 8) & 0x000000ff;
b = (pixel) & 0x000000ff;
return new Color(r,g,b,a);
} }
/** /**
* @return the font1 * Primary font used in titles and buttons and most text output.
* @return {@link java.awt.font} font1
*/ */
public Font getFont1() { public Font getFont1() {
return font1; return font1;
} }
/** /**
* @param font1 the font1 to set * Primary font used in titles and buttons and most text output.
* @param {@link java.awt.font} font1
*/ */
public void setFont1(Font font1) { public void setFont1(Font font10) {
this.font1 = font1; // TODO: Add 0 to parameter's name. this.font1 = font10;
} }
/** /**
* @return the font2 * Secondary font used where a sub-block of text needs it.
* @return {@link java.awt.Font} font2
*/ */
public Font getFont2() { public Font getFont2() {
return font2; return font2;
} }
/** /**
* @param font2 the font2 to set * Secondary font used where a sub-block of text needs it.
* @param {@link java.awt.Font} font2
*/ */
public void setFont2(Font font2) { public void setFont2(Font font20) {
this.font2 = font2; // TODO: Add 0 to parameter's name. this.font2 = font20;
} }
/** /**
* @return the bg1a * Splash screen image.
*/ * @return {@link javax.swing.ImageIcon} splash
public Color getBg1a() {
return bg1a;
}
/**
* @param bg1a the bg1a to set
*/
public void setBg1a(Color bg1a) {
this.bg1a = bg1a; // TODO: Add 0 to parameter's name.
}
/**
* @return the splash
*/ */
public ImageIcon getSplash() { public ImageIcon getSplash() {
return splash; return splash;
} }
/** /**
* @param splash the splash to set * Splash screen image.
* @param {@link javax.swing.ImageIcon} splash
*/ */
public void setSplash(ImageIcon splash) { public void setSplash(ImageIcon splash0) {
this.splash = splash; // TODO: Add 0 to parameter's name. this.splash = splash0;
} }
/** /**
* @return the btnRdown * Base color used in skin.
* @return {@link java.awt.Color} clrTheme
*/ */
public ImageIcon getBtnRdown() { public Color getClrTheme() {
return btnRdown; return clrTheme;
} }
/** /**
* @param btnRdown the btnRdown to set * Base color used in skin.
* @param {@link java.awt.Color} clrTheme
*/ */
public void setBtnRdown(ImageIcon btnRdown) { public void setClrTheme(Color clrTheme0) {
this.btnRdown = btnRdown; // TODO: Add 0 to parameter's name. this.clrTheme = clrTheme0;
} }
/** /**
* @return the bg1b * Border color.
* @return {@link java.awt.Color} clrBorders
*/ */
public Color getBg1b() { public Color getClrBorders() {
return bg1b; return clrBorders;
} }
/** /**
* @param bg1b the bg1b to set * Border color.
* @param {@link java.awt.Color} clrBorders
*/ */
public void setBg1b(Color bg1b) { public void setClrBorders(Color clrBorders0) {
this.bg1b = bg1b; // TODO: Add 0 to parameter's name. this.clrBorders = clrBorders0;
} }
/** /**
* @return the texture1 * Primary texture used in skin.
* @return {@link javax.swing.ImageIcon} texture1
*/ */
public ImageIcon getTexture1() { public ImageIcon getTexture1() {
return texture1; return texture1;
} }
/** /**
* @param texture1 the texture1 to set * Primary texture used in skin.
* @param {@link javax.swing.ImageIcon} texture1
*/ */
public void setTexture1(ImageIcon texture1) { public void setTexture1(ImageIcon texture10) {
this.texture1 = texture1; // TODO: Add 0 to parameter's name. this.texture1 = texture10;
} }
/** /**
* @return the txt1a * Color of zebra striping in grid displays.
* @return {@link java.awt.Color} clrZebra
*/ */
public Color getTxt1a() { public Color getClrZebra() {
return txt1a; return clrZebra;
} }
/** /**
* @param txt1a the txt1a to set * Color of zebra striping in grid displays.
* @param {@link java.awt.Color} clrZebra
*/ */
public void setTxt1a(Color txt1a) { public void setClrZebra(Color clrZebra0) {
this.txt1a = txt1a; // TODO: Add 0 to parameter's name. this.clrZebra = clrZebra0;
} }
/** /**
* @return the btnLup * Color of elements in mouseover state.
* @return {@link java.awt.Color} clrHover
*/
public Color getClrHover() {
return clrHover;
}
/**
* Color of elements in mouseover state.
* @param {@link java.awt.Color} clrHover
*/
public void setClrHover(Color clrHover0) {
this.clrHover = clrHover0;
}
/**
* Color of active (currently selected) elements.
* @return {@link java.awt.Color} clrActive
*/
public Color getClrActive() {
return clrActive;
}
/**
* Color of active (currently selected) elements.
* @param {@link java.awt.Color} clrActive
*/
public void setClrActive(Color clrActive0) {
this.clrActive = clrActive0;
}
/**
* Color of inactive (not currently selected) elements.
* @return {@link java.awt.Color} clrHover
*/
public Color getClrInactive() {
return clrInactive;
}
/**
* Color of inactive (not currently selected) elements.
* @param {@link java.awt.Color} clrHover
*/
public void setClrInactive(Color clrInactive0) {
this.clrInactive = clrInactive0;
}
/**
* Color of text in skin.
* @return {@link java.awt.Color} clrText
*/
public Color getClrText() {
return clrText;
}
/**
* Color of text in skin.
* @param {@link java.awt.Color} clrHover
*/
public void setClrText(Color clrText0) {
this.clrText = clrText0;
}
/**
* Left side of button, up state.
* @return {@link javax.swing.ImageIcon} btnLup
*/ */
public ImageIcon getBtnLup() { public ImageIcon getBtnLup() {
return btnLup; return btnLup;
} }
/** /**
* @param btnLup the btnLup to set * Left side of button, up state.
* @param {@link javax.swing.ImageIcon} btnLup
*/ */
public void setBtnLup(ImageIcon btnLup) { public void setBtnLup(ImageIcon btnLup0) {
this.btnLup = btnLup; // TODO: Add 0 to parameter's name. this.btnLup = btnLup0;
} }
/** /**
* @return the btnMup * Middle of button, up state.
* @return {@link javax.swing.ImageIcon} btnMup
*/ */
public ImageIcon getBtnMup() { public ImageIcon getBtnMup() {
return btnMup; return btnMup;
} }
/** /**
* @param btnMup the btnMup to set * Middle of button, up state.
* @param {@link javax.swing.ImageIcon} btnMup
*/ */
public void setBtnMup(ImageIcon btnMup) { public void setBtnMup(ImageIcon btnMup0) {
this.btnMup = btnMup; // TODO: Add 0 to parameter's name. this.btnMup = btnMup0;
} }
/** /**
* @return the btnLover * Right side of button, up state.
*/ * @return {@link javax.swing.ImageIcon} btnRup
public ImageIcon getBtnLover() {
return btnLover;
}
/**
* @param btnLover the btnLover to set
*/
public void setBtnLover(ImageIcon btnLover) {
this.btnLover = btnLover; // TODO: Add 0 to parameter's name.
}
/**
* @return the btnRup
*/ */
public ImageIcon getBtnRup() { public ImageIcon getBtnRup() {
return btnRup; return btnRup;
} }
/** /**
* @param btnRup the btnRup to set * Right side of button, up state.
* @param {@link javax.swing.ImageIcon} btnRup
*/ */
public void setBtnRup(ImageIcon btnRup) { public void setBtnRup(ImageIcon btnRup0) {
this.btnRup = btnRup; // TODO: Add 0 to parameter's name. this.btnRup = btnRup0;
} }
/** /**
* @return the btnMover * Left side of button, over state.
* @return {@link javax.swing.ImageIcon} btnLover
*/
public ImageIcon getBtnLover() {
return btnLover;
}
/**
* Left side of button, over state.
* @param {@link javax.swing.ImageIcon} btnLover
*/
public void setBtnLover(ImageIcon btnLover0) {
this.btnLover = btnLover0;
}
/**
* Middle of button, over state.
* @return {@link javax.swing.ImageIcon} btnMover
*/ */
public ImageIcon getBtnMover() { public ImageIcon getBtnMover() {
return btnMover; return btnMover;
} }
/** /**
* @param btnMover the btnMover to set * Middle of button, over state.
* @param {@link javax.swing.ImageIcon} btnMover
*/ */
public void setBtnMover(ImageIcon btnMover) { public void setBtnMover(ImageIcon btnMover0) {
this.btnMover = btnMover; // TODO: Add 0 to parameter's name. this.btnMover = btnMover0;
} }
/** /**
* @return the btnRover * Right side of button, over state.
* @return {@link javax.swing.ImageIcon} btnRover
*/ */
public ImageIcon getBtnRover() { public ImageIcon getBtnRover() {
return btnRover; return btnRover;
} }
/** /**
* @param btnRover the btnRover to set * Right side of button, over state.
* @param {@link javax.swing.ImageIcon} btnRover
*/ */
public void setBtnRover(ImageIcon btnRover) { public void setBtnRover(ImageIcon btnRover0) {
this.btnRover = btnRover; // TODO: Add 0 to parameter's name. this.btnRover = btnRover0;
} }
/** /**
* @return the btnLdown * Left side of button, down state.
* @return {@link javax.swing.ImageIcon} btnLdown
*/ */
public ImageIcon getBtnLdown() { public ImageIcon getBtnLdown() {
return btnLdown; return btnLdown;
} }
/** /**
* @param btnLdown the btnLdown to set * Left side of button, down state.
* @param {@link javax.swing.ImageIcon} btnLdown
*/ */
public void setBtnLdown(ImageIcon btnLdown) { public void setBtnLdown(ImageIcon btnLdown0) {
this.btnLdown = btnLdown; // TODO: Add 0 to parameter's name. this.btnLdown = btnLdown0;
} }
/** /**
* @return the btnMdown * Right side of button, down state.
* @return {@link javax.swing.ImageIcon} btnRdown
*/
public ImageIcon getBtnRdown() {
return btnRdown;
}
/**
* Right side of button, down state.
* @param {@link javax.swing.ImageIcon} btnRdown
*/
public void setBtnRdown(ImageIcon btnRdown0) {
this.btnRdown = btnRdown0;
}
/**
* Middle of button, down state.
* @return {@link javax.swing.ImageIcon} btnMdown
*/ */
public ImageIcon getBtnMdown() { public ImageIcon getBtnMdown() {
return btnMdown; return btnMdown;
} }
/** /**
* @param btnMdown the btnMdown to set * Middle of button, down state.
* @param {@link javax.swing.ImageIcon} btnMdown
*/ */
public void setBtnMdown(ImageIcon btnMdown) { public void setBtnMdown(ImageIcon btnMdown0) {
this.btnMdown = btnMdown; // TODO: Add 0 to parameter's name. this.btnMdown = btnMdown0;
}
/**
* Name of skin.
* @return {@link java.lang.String} name
*/
public String getName() {
return name;
} }
} }

View File

@@ -129,8 +129,8 @@ public class SplashFrame extends JFrame {
contentPane.getActionMap().put("escAction", new CloseAction()); contentPane.getActionMap().put("escAction", new CloseAction());
// Set UI to color splash bar fill with theme colors // Set UI to color splash bar fill with theme colors
UIManager.put("ProgressBar.foreground", skin.getBg1b()); // Filled UIManager.put("ProgressBar.foreground", skin.getClrTheme()); // When filled
UIManager.put("ProgressBar.selectionForeground", skin.getTxt1a()); // Filled UIManager.put("ProgressBar.selectionForeground", skin.getClrText()); // When filled
// Instantiate model and view and tie together. // Instantiate model and view and tie together.
this.monitorModel = new SplashProgressModel(); this.monitorModel = new SplashProgressModel();

View File

@@ -207,7 +207,7 @@ public class WinLoseFrame extends JFrame {
bounds.y = (screen.height - bounds.height) / 2; bounds.y = (screen.height - bounds.height) / 2;
} }
this.setBackground(AllZone.getSkin().getBg1a()); this.setBackground(AllZone.getSkin().getClrTheme());
this.setBounds(bounds); this.setBounds(bounds);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setUndecorated(true); this.setUndecorated(true);
@@ -280,68 +280,72 @@ public class WinLoseFrame extends JFrame {
} }
/** /**
* @return the btnContinue * @return {@link forge.gui.skin.FButton} btnContinue
*/ */
public FButton getBtnContinue() { public FButton getBtnContinue() {
return btnContinue; return btnContinue;
} }
/** /**
* @param btnContinue the btnContinue to set * @param {@link forge.gui.skin.FButton} btnContinue
*/ */
public void setBtnContinue(FButton btnContinue) { public void setBtnContinue(FButton btnContinue0) {
this.btnContinue = btnContinue; // TODO: Add 0 to parameter's name. this.btnContinue = btnContinue0;
} }
/** /**
* @return the btnRestart * @return {@link forge.gui.skin.FButton} btnRestart
*/ */
public FButton getBtnRestart() { public FButton getBtnRestart() {
return btnRestart; return btnRestart;
} }
/** /**
* @param btnRestart the btnRestart to set * @param {@link forge.gui.skin.FButton} btnRestart
*/ */
public void setBtnRestart(FButton btnRestart) { public void setBtnRestart(FButton btnRestart0) {
this.btnRestart = btnRestart; // TODO: Add 0 to parameter's name. this.btnRestart = btnRestart0;
} }
/** /**
* @return the btnQuit * @return {@link forge.gui.skin.FButton} btnQuit
*/ */
public FButton getBtnQuit() { public FButton getBtnQuit() {
return btnQuit; return btnQuit;
} }
/** /**
* @param btnQuit the btnQuit to set * @param {@link forge.gui.skin.FButton} btnQuit
*/ */
public void setBtnQuit(FButton btnQuit) { public void setBtnQuit(FButton btnQuit0) {
this.btnQuit = btnQuit; // TODO: Add 0 to parameter's name. this.btnQuit = btnQuit0;
} }
/** /**
* @return the pnlCustom * The central panel in the win/lose screen, used for
* presenting customized messages and rewards.
* @return {@link javax.swing.JPanel} pnlCustom
*/ */
public JPanel getPnlCustom() { public JPanel getPnlCustom() {
return pnlCustom; return pnlCustom;
} }
/** /**
* @param pnlCustom the pnlCustom to set * The central panel in the win/lose screen, used for
* presenting customized messages and rewards.
* @param {@link javax.swing.JPanel} pnlCustom
*/ */
public void setPnlCustom(JPanel pnlCustom) { public void setPnlCustom(JPanel pnlCustom0) {
this.pnlCustom = pnlCustom; // TODO: Add 0 to parameter's name. this.pnlCustom = pnlCustom0;
} }
private class WinLoseBorder extends AbstractBorder { private class WinLoseBorder extends AbstractBorder {
@Override @Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width,
final int height) { final int height) {
g.setColor(AllZone.getSkin().getTxt1a()); g.setColor(AllZone.getSkin().getClrText());
g.drawRect(x + 1, y + 1, width - 3, height - 3); g.drawRect(x + 1, y + 1, width - 3, height - 3);
g.setColor(AllZone.getSkin().getBg1a()); g.setColor(AllZone.getSkin().getClrTheme());
g.drawRect(x + 3, y + 3, width - 7, height - 7); g.drawRect(x + 3, y + 3, width - 7, height - 7);
} }
} }