- Full support for skins in place.
- Default skin added. - WinLose panel styled with new skinning system. - Forge custom swing components added and available for use in Swing UI. - WinLose panel written to use forge components.
21
.gitattributes
vendored
@@ -9343,6 +9343,23 @@ res/images/deckeditor/filter_sorcery_n.png -text svneol=unset#image/png
|
|||||||
res/images/deckeditor/filter_sorcery_y.png -text svneol=unset#image/png
|
res/images/deckeditor/filter_sorcery_y.png -text svneol=unset#image/png
|
||||||
res/images/deckeditor/filter_white_n.png -text svneol=unset#image/png
|
res/images/deckeditor/filter_white_n.png -text svneol=unset#image/png
|
||||||
res/images/deckeditor/filter_white_y.png -text svneol=unset#image/png
|
res/images/deckeditor/filter_white_y.png -text svneol=unset#image/png
|
||||||
|
res/images/skins/default/bg_splash.jpg -text
|
||||||
|
res/images/skins/default/btnLdown.png -text
|
||||||
|
res/images/skins/default/btnLover.png -text
|
||||||
|
res/images/skins/default/btnLup.png -text
|
||||||
|
res/images/skins/default/btnMdown.png -text
|
||||||
|
res/images/skins/default/btnMover.png -text
|
||||||
|
res/images/skins/default/btnMup.png -text
|
||||||
|
res/images/skins/default/btnRdown.png -text
|
||||||
|
res/images/skins/default/btnRover.png -text
|
||||||
|
res/images/skins/default/btnRup.png -text
|
||||||
|
res/images/skins/default/font1.ttf -text
|
||||||
|
res/images/skins/default/font2.ttf -text
|
||||||
|
res/images/skins/default/palette.jpg -text
|
||||||
|
res/images/skins/default/settings.txt -text
|
||||||
|
res/images/skins/default/texture1.jpg -text
|
||||||
|
res/images/skins/default/texture2.jpg -text
|
||||||
|
res/images/skins/default/texture3.jpg -text
|
||||||
res/images/symbols-13/0.png -text svneol=unset#image/png
|
res/images/symbols-13/0.png -text svneol=unset#image/png
|
||||||
res/images/symbols-13/1.png -text svneol=unset#image/png
|
res/images/symbols-13/1.png -text svneol=unset#image/png
|
||||||
res/images/symbols-13/10.png -text svneol=unset#image/png
|
res/images/symbols-13/10.png -text svneol=unset#image/png
|
||||||
@@ -10259,6 +10276,10 @@ src/main/java/forge/gui/input/Input_PayManaCostUtil.java svneol=native#text/plai
|
|||||||
src/main/java/forge/gui/input/Input_PayManaCost_Ability.java svneol=native#text/plain
|
src/main/java/forge/gui/input/Input_PayManaCost_Ability.java svneol=native#text/plain
|
||||||
src/main/java/forge/gui/input/package-info.java svneol=native#text/plain
|
src/main/java/forge/gui/input/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/gui/package-info.java svneol=native#text/plain
|
src/main/java/forge/gui/package-info.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/gui/skin/FButton.java -text
|
||||||
|
src/main/java/forge/gui/skin/FPanel.java -text
|
||||||
|
src/main/java/forge/gui/skin/FRoundedPanel.java -text
|
||||||
|
src/main/java/forge/gui/skin/FSkin.java -text
|
||||||
src/main/java/forge/item/BoosterPack.java -text
|
src/main/java/forge/item/BoosterPack.java -text
|
||||||
src/main/java/forge/item/CardDb.java -text
|
src/main/java/forge/item/CardDb.java -text
|
||||||
src/main/java/forge/item/CardPrinted.java -text
|
src/main/java/forge/item/CardPrinted.java -text
|
||||||
|
|||||||
1
.gitignore
vendored
@@ -11,6 +11,7 @@ res/cardsfolder/cardsfolder.zip
|
|||||||
res/decks/AI_o1.dck
|
res/decks/AI_o1.dck
|
||||||
res/decks/o1.bdk
|
res/decks/o1.bdk
|
||||||
res/gui/display_new_layout.xml
|
res/gui/display_new_layout.xml
|
||||||
|
res/images/themes
|
||||||
res/oracleScript.log
|
res/oracleScript.log
|
||||||
res/quest/questData.dat
|
res/quest/questData.dat
|
||||||
res/quest/questData.dat.xml
|
res/quest/questData.dat.xml
|
||||||
|
|||||||
BIN
res/images/skins/default/bg_splash.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
res/images/skins/default/btnLdown.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
res/images/skins/default/btnLover.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
res/images/skins/default/btnLup.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
res/images/skins/default/btnMdown.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
res/images/skins/default/btnMover.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
res/images/skins/default/btnMup.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
res/images/skins/default/btnRdown.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
res/images/skins/default/btnRover.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
res/images/skins/default/btnRup.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
res/images/skins/default/font1.ttf
Normal file
BIN
res/images/skins/default/font2.ttf
Normal file
BIN
res/images/skins/default/palette.jpg
Normal file
|
After Width: | Height: | Size: 30 KiB |
16
res/images/skins/default/settings.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Settings are stored in a key=value format.
|
||||||
|
# Color values are stored as RR,GG,BB[,AA] values 0 to 255
|
||||||
|
# Dimension values are stored as x,y
|
||||||
|
# Incomplete settings will make the file switch to the default theme.
|
||||||
|
|
||||||
|
# Texture opacity settings, 0-100
|
||||||
|
texture1opacity=100;
|
||||||
|
texture2opacity=100;
|
||||||
|
texture3opacity=100;
|
||||||
|
|
||||||
|
# FRoundedPanel
|
||||||
|
shadowColor=150,150,150,150
|
||||||
|
borderColor=0,0,0
|
||||||
|
shadowDistance=5,5
|
||||||
|
shadowThickness=5
|
||||||
|
cornerDiameter=20
|
||||||
BIN
res/images/skins/default/texture1.jpg
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
res/images/skins/default/texture2.jpg
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
res/images/skins/default/texture3.jpg
Normal file
|
After Width: | Height: | Size: 85 KiB |
@@ -12,6 +12,7 @@ import forge.card.trigger.TriggerHandler;
|
|||||||
import forge.deck.DeckManager;
|
import forge.deck.DeckManager;
|
||||||
import forge.game.GameSummary;
|
import forge.game.GameSummary;
|
||||||
import forge.gui.input.InputControl;
|
import forge.gui.input.InputControl;
|
||||||
|
import forge.gui.skin.FSkin;
|
||||||
import forge.model.FGameState;
|
import forge.model.FGameState;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
@@ -39,6 +40,9 @@ public final class AllZone implements NewConstants {
|
|||||||
// blank
|
// blank
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Global <code>SKIN</code>. */
|
||||||
|
private static FSkin SKIN = null;
|
||||||
|
|
||||||
/** Global <code>questData</code>. */
|
/** Global <code>questData</code>. */
|
||||||
private static forge.quest.data.QuestData questData = null;
|
private static forge.quest.data.QuestData questData = null;
|
||||||
|
|
||||||
@@ -494,4 +498,26 @@ public final class AllZone implements NewConstants {
|
|||||||
public static ColorChanger getColorChanger() {
|
public static ColorChanger getColorChanger() {
|
||||||
return COLOR_CHANGER;
|
return COLOR_CHANGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>getSkin.</p>
|
||||||
|
* Gets current display skin.
|
||||||
|
*
|
||||||
|
* @return a {@link forge.gui.skin.FSkin} object.
|
||||||
|
* @since 1.0.15
|
||||||
|
*/
|
||||||
|
public static FSkin getSkin() {
|
||||||
|
return SKIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>setSkin.</p>
|
||||||
|
* Sets current display skin.
|
||||||
|
*
|
||||||
|
* @param attackers a {@link forge.gui.skin.FSkin} object.
|
||||||
|
* @since 1.0.15
|
||||||
|
*/
|
||||||
|
public static void setSkin(final FSkin fs) {
|
||||||
|
SKIN = fs;
|
||||||
|
}
|
||||||
} //AllZone
|
} //AllZone
|
||||||
|
|||||||
@@ -17,11 +17,13 @@ import net.slightlymagic.braids.util.UtilFunctions;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
import java.awt.FontFormatException;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -306,4 +308,24 @@ public final class GuiUtils {
|
|||||||
bounds.y = (screen.height - bounds.height) / 2;
|
bounds.y = (screen.height - bounds.height) / 2;
|
||||||
frame.setBounds(bounds);
|
frame.setBounds(bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to create a font from a filename. Concise error reported
|
||||||
|
* if exceptions found.
|
||||||
|
*
|
||||||
|
* @param {@link java.lang.String} filename
|
||||||
|
*/
|
||||||
|
public static Font newFont(String filename) {
|
||||||
|
File file = new File(filename);
|
||||||
|
Font ttf = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
ttf = Font.createFont(Font.TRUETYPE_FONT,file);
|
||||||
|
} catch (FontFormatException e) {
|
||||||
|
System.err.println("GuiUtils > newFont: bad font format \"" + filename + "\"");
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("GuiUtils > newFont: can't find \""+filename+"\"");
|
||||||
|
}
|
||||||
|
return ttf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
95
src/main/java/forge/gui/skin/FButton.java
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
package forge.gui.skin;
|
||||||
|
|
||||||
|
import java.awt.AlphaComposite;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import forge.AllZone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The core JButton used throughout the Forge project.
|
||||||
|
* Follows skin font and theme button styling.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class FButton extends JButton {
|
||||||
|
protected Image imgL, imgM, imgR;
|
||||||
|
private int w, h = 0;
|
||||||
|
private boolean allImagesPresent = false;
|
||||||
|
private RenderingHints rh;
|
||||||
|
private FSkin skin;
|
||||||
|
private AlphaComposite disabledComposite =
|
||||||
|
AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.25f);
|
||||||
|
|
||||||
|
public FButton(String msg) {
|
||||||
|
super(msg);
|
||||||
|
this.skin = AllZone.getSkin();
|
||||||
|
this.setOpaque(false);
|
||||||
|
this.setForeground(skin.txt1a);
|
||||||
|
this.setBackground(Color.red);
|
||||||
|
this.setContentAreaFilled(false);
|
||||||
|
this.setFont(skin.font1.deriveFont(Font.PLAIN,14));
|
||||||
|
this.imgL = skin.btnLup.getImage();
|
||||||
|
this.imgM = skin.btnMup.getImage();
|
||||||
|
this.imgR = skin.btnRup.getImage();
|
||||||
|
|
||||||
|
rh = new RenderingHints(
|
||||||
|
RenderingHints.KEY_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_ANTIALIAS_ON
|
||||||
|
);
|
||||||
|
|
||||||
|
if(this.imgL != null && this.imgM != null && this.imgR != null) {
|
||||||
|
allImagesPresent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||||
|
public void mouseEntered(java.awt.event.MouseEvent evt) {
|
||||||
|
if(isEnabled()) {
|
||||||
|
imgL = skin.btnLover.getImage();
|
||||||
|
imgM = skin.btnMover.getImage();
|
||||||
|
imgR = skin.btnRover.getImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void mouseExited(java.awt.event.MouseEvent evt) {
|
||||||
|
if(isEnabled()) {
|
||||||
|
imgL = skin.btnLup.getImage();
|
||||||
|
imgM = skin.btnMup.getImage();
|
||||||
|
imgR = skin.btnRup.getImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||||
|
if(isEnabled()) {
|
||||||
|
imgL = skin.btnLdown.getImage();
|
||||||
|
imgM = skin.btnMdown.getImage();
|
||||||
|
imgR = skin.btnRdown.getImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
if(!allImagesPresent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Graphics2D g2d = (Graphics2D)g;
|
||||||
|
g2d.setRenderingHints(rh);
|
||||||
|
|
||||||
|
if(!isEnabled()) {
|
||||||
|
g2d.setComposite(disabledComposite);
|
||||||
|
}
|
||||||
|
|
||||||
|
w = this.getWidth();
|
||||||
|
h = this.getHeight();
|
||||||
|
|
||||||
|
g2d.drawImage(imgL,0,0,h,h,null);
|
||||||
|
g2d.drawImage(imgM,h,0,w - 2*h,h,null);
|
||||||
|
g2d.drawImage(imgR,w-h,0,h,h,null);
|
||||||
|
|
||||||
|
super.paintComponent(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
55
src/main/java/forge/gui/skin/FPanel.java
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package forge.gui.skin;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.LayoutManager;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
/** <p>FPanel.</p>
|
||||||
|
* The core JPanel used throughout the Forge project.
|
||||||
|
* Allows tiled images and ...
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class FPanel extends JPanel {
|
||||||
|
private ImageIcon bgImg = null;
|
||||||
|
private int w, h, iw, ih, x, y = 0;
|
||||||
|
|
||||||
|
public FPanel() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FPanel(LayoutManager lm) {
|
||||||
|
this();
|
||||||
|
this.setLayout(lm);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
//System.out.print("\nRepainting. ");
|
||||||
|
if(this.bgImg != null) {
|
||||||
|
w = getWidth();
|
||||||
|
h = getHeight();
|
||||||
|
iw = this.bgImg.getIconWidth();
|
||||||
|
ih = this.bgImg.getIconHeight();
|
||||||
|
|
||||||
|
while(x < w) {
|
||||||
|
while(y < h) {
|
||||||
|
g.drawImage(bgImg.getImage(),x,y,null);
|
||||||
|
y += ih;
|
||||||
|
}
|
||||||
|
x += iw;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.paintComponent(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBGImg(ImageIcon icon) {
|
||||||
|
this.bgImg = icon;
|
||||||
|
if(this.bgImg != null) {
|
||||||
|
this.setOpaque(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
230
src/main/java/forge/gui/skin/FRoundedPanel.java
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
package forge.gui.skin;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.LayoutManager;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import forge.AllZone;
|
||||||
|
|
||||||
|
/** <p>FRoundedPanel.</p>
|
||||||
|
* A subclass of JPanel with optional rounded corners and
|
||||||
|
* optional drop shadow, for special cases only. FPanel recommended for regular use.
|
||||||
|
* Limitations - cannot use background image, and single line border only.
|
||||||
|
*
|
||||||
|
* Default values provided, later updated from skin settings, and can be
|
||||||
|
* set dynamically.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class FRoundedPanel extends JPanel {
|
||||||
|
private FSkin skin;
|
||||||
|
private Color shadowColor = new Color(150,150,150,150);
|
||||||
|
private Color borderColor = Color.black;
|
||||||
|
private Dimension shadowDistance = new Dimension(5,5);
|
||||||
|
private int shadowThickness = 5;
|
||||||
|
private int cornerRadius = 20; // Note: this number is actually diameter.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>FRoundedPanel.</p>
|
||||||
|
*
|
||||||
|
* Constructor, null layout manager.
|
||||||
|
*/
|
||||||
|
public FRoundedPanel() {
|
||||||
|
super();
|
||||||
|
this.setOpaque(false);
|
||||||
|
skin = AllZone.getSkin();
|
||||||
|
|
||||||
|
Color tempC;
|
||||||
|
Dimension tempD;
|
||||||
|
String tempS;
|
||||||
|
|
||||||
|
tempC = parseColorString(skin.getSetting("shadowColor"));
|
||||||
|
if(tempC != null) { shadowColor = tempC; }
|
||||||
|
|
||||||
|
tempC = parseColorString(skin.getSetting("borderColor"));
|
||||||
|
if(tempC != null) { borderColor = tempC; }
|
||||||
|
|
||||||
|
tempD = parseDimensionString(skin.getSetting("shadowDistance"));
|
||||||
|
if(tempD != null) { shadowDistance = tempD; }
|
||||||
|
|
||||||
|
tempS = skin.getSetting("shadowThickness");
|
||||||
|
if(tempS != null) { shadowThickness = Integer.parseInt(tempS); }
|
||||||
|
|
||||||
|
tempS = skin.getSetting("cornerRadius");
|
||||||
|
if(tempS != null) { cornerRadius = Integer.parseInt(tempS); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>FRoundedPanel.</p>
|
||||||
|
*
|
||||||
|
* Constructor.
|
||||||
|
* @param {@link java.awt.LayoutManager}
|
||||||
|
*/
|
||||||
|
public FRoundedPanel(LayoutManager lm) {
|
||||||
|
this();
|
||||||
|
this.setLayout(lm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>FRoundedPanel.</p>
|
||||||
|
*
|
||||||
|
* Constructor.
|
||||||
|
* @param {@link java.awt.Graphics}
|
||||||
|
*/
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
super.paintComponent(g);
|
||||||
|
int w = getWidth();
|
||||||
|
int h = getHeight();
|
||||||
|
|
||||||
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
|
// Draw shadow
|
||||||
|
g2d.setColor(shadowColor);
|
||||||
|
g2d.setStroke(new BasicStroke(shadowThickness));
|
||||||
|
g2d.drawRoundRect(
|
||||||
|
0 + (int)shadowDistance.getWidth() + (shadowThickness/2),
|
||||||
|
0 + (int)shadowDistance.getHeight() + (shadowThickness/2),
|
||||||
|
w - (int)shadowDistance.getWidth() - shadowThickness,
|
||||||
|
h - (int)shadowDistance.getHeight() - shadowThickness,
|
||||||
|
cornerRadius, cornerRadius);
|
||||||
|
|
||||||
|
// Draw content rectangle (on top of shadow)
|
||||||
|
g2d.setColor(this.getBackground());
|
||||||
|
g2d.fillRoundRect(
|
||||||
|
0, 0,
|
||||||
|
w - shadowThickness,
|
||||||
|
h - shadowThickness,
|
||||||
|
cornerRadius, cornerRadius);
|
||||||
|
|
||||||
|
// Stroke border
|
||||||
|
g2d.setColor(this.borderColor);
|
||||||
|
g2d.setStroke(new BasicStroke(1));
|
||||||
|
g2d.drawRoundRect(
|
||||||
|
0,0,
|
||||||
|
w - shadowThickness,
|
||||||
|
h - shadowThickness,
|
||||||
|
cornerRadius, cornerRadius);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>setShadowColor.</p>
|
||||||
|
* Sets color of shadow behind rounded panel.
|
||||||
|
*
|
||||||
|
* @param {@link java.awt.Color}
|
||||||
|
*/
|
||||||
|
public void setShadowColor(Color c) {
|
||||||
|
this.shadowColor = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>setBorderColor.</p>
|
||||||
|
* Sets color of border around rounded panel.
|
||||||
|
*
|
||||||
|
* @param {@link java.awt.Color}
|
||||||
|
*/
|
||||||
|
public void setBorderColor(Color c) {
|
||||||
|
this.borderColor = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>setShadowDistance.</p>
|
||||||
|
* Sets distance of shadow from rounded panel.
|
||||||
|
*
|
||||||
|
* @param {@link java.lang.Integer} side
|
||||||
|
*/
|
||||||
|
public void setShadowDistance(int side) {
|
||||||
|
this.shadowDistance = new Dimension(side,side);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>setShadowDistance.</p>
|
||||||
|
* Sets distance of shadow from rounded panel.
|
||||||
|
*
|
||||||
|
* @param {@link java.lang.Integer} x
|
||||||
|
* @param {@link java.lang.Integer} y
|
||||||
|
*/
|
||||||
|
public void setShadowDistance(int x, int y) {
|
||||||
|
this.shadowDistance = new Dimension(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>setShadowDistance.</p>
|
||||||
|
* Sets thickness of rounded panel shadow.
|
||||||
|
*
|
||||||
|
* @param {@link java.lang.Integer} t
|
||||||
|
*/
|
||||||
|
public void setShadowThickness(int t) {
|
||||||
|
this.shadowThickness = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>setCornerRadius.</p>
|
||||||
|
* Sets radius of each corner on rounded panel.
|
||||||
|
*
|
||||||
|
* @param {@link java.lang.Integer} r
|
||||||
|
*/
|
||||||
|
public void setCornerRadius(int r) {
|
||||||
|
if(r < 0) {
|
||||||
|
r = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cornerRadius = r*2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>parseColorString.</p>
|
||||||
|
* Uses string from settings file to make a new rgba color instance.
|
||||||
|
*
|
||||||
|
* @param {@link java.lang.String} s
|
||||||
|
*/
|
||||||
|
private Color parseColorString(String s) {
|
||||||
|
Color c = null;
|
||||||
|
int r,g,b,a = 0;
|
||||||
|
String[] temp = s.split(",");
|
||||||
|
|
||||||
|
if(temp.length==3 || temp.length==4) {
|
||||||
|
r = Integer.parseInt(temp[0]);
|
||||||
|
g = Integer.parseInt(temp[1]);
|
||||||
|
b = Integer.parseInt(temp[2]);
|
||||||
|
if(temp.length==4) {
|
||||||
|
a = Integer.parseInt(temp[3]);
|
||||||
|
}
|
||||||
|
c = new Color(r,g,b,a);
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>parseDimensionString.</p>
|
||||||
|
* Uses string from settings file to make a new dimension instance.
|
||||||
|
*
|
||||||
|
* @param {@link java.lang.String} s
|
||||||
|
*/
|
||||||
|
private Dimension parseDimensionString(String s) {
|
||||||
|
Dimension d = null;
|
||||||
|
int w,h = 0;
|
||||||
|
String[] temp = s.split(",");
|
||||||
|
|
||||||
|
if(temp.length==2) {
|
||||||
|
w = Integer.parseInt(temp[0]);
|
||||||
|
h = Integer.parseInt(temp[0]);
|
||||||
|
d = new Dimension(w,h);
|
||||||
|
}
|
||||||
|
else if(temp.length==1 && !temp[0].equals("")) {
|
||||||
|
w = Integer.parseInt(temp[0]);
|
||||||
|
h = w;
|
||||||
|
d = new Dimension(w,h);
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
268
src/main/java/forge/gui/skin/FSkin.java
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
package forge.gui.skin;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
import forge.gui.GuiUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assembles settings from selected or default theme as appropriate.
|
||||||
|
* Saves in a hashtable, access using .get(settingName) method.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FSkin {
|
||||||
|
//===== Public fields
|
||||||
|
public Font font1 = null;
|
||||||
|
public Font font2 = null;
|
||||||
|
public ImageIcon texture1 = null;
|
||||||
|
public ImageIcon texture2 = null;
|
||||||
|
public ImageIcon texture3 = null;
|
||||||
|
public ImageIcon btnLup = null;
|
||||||
|
public ImageIcon btnMup = null;
|
||||||
|
public ImageIcon btnRup = null;
|
||||||
|
public ImageIcon btnLover = null;
|
||||||
|
public ImageIcon btnMover = null;
|
||||||
|
public ImageIcon btnRover = null;
|
||||||
|
public ImageIcon btnLdown = null;
|
||||||
|
public ImageIcon btnMdown = null;
|
||||||
|
public ImageIcon btnRdown = null;
|
||||||
|
|
||||||
|
public Color bg1a = Color.red;
|
||||||
|
public Color bg1b = Color.red;
|
||||||
|
public Color bg2a = Color.red;
|
||||||
|
public Color bg2b = Color.red;
|
||||||
|
public Color bg3a = Color.red;
|
||||||
|
public Color bg3b = Color.red;
|
||||||
|
|
||||||
|
public Color txt1a = Color.red;
|
||||||
|
public Color txt1b = Color.red;
|
||||||
|
public Color txt2a = Color.red;
|
||||||
|
public Color txt2b = Color.red;
|
||||||
|
public Color txt3a = Color.red;
|
||||||
|
public Color txt3b = Color.red;
|
||||||
|
|
||||||
|
//===== Private fields
|
||||||
|
private final String settingsfile = "settings.txt";
|
||||||
|
private final String paletteFile = "palette.jpg";
|
||||||
|
private final String font1file = "font1.ttf";
|
||||||
|
private final String font2file = "font2.ttf";
|
||||||
|
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 btnMupfile = "btnMup.png";
|
||||||
|
private final String btnRupfile = "btnRup.png";
|
||||||
|
private final String btnLoverfile = "btnLover.png";
|
||||||
|
private final String btnMoverfile = "btnMover.png";
|
||||||
|
private final String btnRoverfile = "btnRover.png";
|
||||||
|
private final String btnLdownfile = "btnLdown.png";
|
||||||
|
private final String btnMdownfile = "btnMdown.png";
|
||||||
|
private final String btnRdownfile = "btnRdown.png";
|
||||||
|
|
||||||
|
private ImageIcon tempImg;
|
||||||
|
private Font tempFont;
|
||||||
|
private String skin;
|
||||||
|
private String notfound = "FSkin.java: \""+skin+
|
||||||
|
"\" skin can't find ";
|
||||||
|
private Hashtable<String, String> customSettings =
|
||||||
|
new Hashtable<String, String>();
|
||||||
|
private Hashtable<String, String> defaultSettings =
|
||||||
|
new Hashtable<String, String>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FSkin constructor. No arguments, will generate default skin settings,
|
||||||
|
* fonts, and backgrounds.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public FSkin() throws Exception {
|
||||||
|
this("default");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FSkin constructor, using skin name. Generates custom skin settings,
|
||||||
|
* fonts, and backgrounds.
|
||||||
|
*
|
||||||
|
* @param themeName
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public FSkin(String skinName) throws Exception {
|
||||||
|
defaultSettings = loadSettings("default");
|
||||||
|
loadFontAndImages("default");
|
||||||
|
|
||||||
|
if(!skinName.equals("default")) {
|
||||||
|
customSettings = loadSettings(skinName);
|
||||||
|
loadFontAndImages(skinName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves skin settings from file, returns in hashtable.
|
||||||
|
*
|
||||||
|
* @param skinName
|
||||||
|
* @return settings hashtable
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private Hashtable<String, String> loadSettings(String skinName) throws Exception {
|
||||||
|
String filename = "res/images/skins/"+skinName+"/"+settingsfile;
|
||||||
|
|
||||||
|
String notfound = "FSkin > load: Can't find \"" + filename + "\".";
|
||||||
|
Hashtable<String, String> settings = new Hashtable<String, String>();
|
||||||
|
|
||||||
|
File f = new File(filename);
|
||||||
|
customSettings.put("name",skinName);
|
||||||
|
|
||||||
|
if (!f.exists()) {
|
||||||
|
throw new RuntimeException(notfound);
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedReader input = new BufferedReader(new FileReader(f));
|
||||||
|
String line = null;
|
||||||
|
while ((line = input.readLine()) != null) {
|
||||||
|
String[] data = line.split("=");
|
||||||
|
if (line.startsWith("#") || line.length() == 0 || data.length != 2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.put(data[0],data[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads objects from skin folder, prints brief error if not found.
|
||||||
|
*
|
||||||
|
* @param skinName
|
||||||
|
*/
|
||||||
|
private void loadFontAndImages(String skinName) {
|
||||||
|
String dirName = "res/images/skins/"+skinName+"/";
|
||||||
|
|
||||||
|
// Fonts
|
||||||
|
font1 = retrieveFont(dirName + font1file);
|
||||||
|
font2 = retrieveFont(dirName + font2file);
|
||||||
|
|
||||||
|
// Images
|
||||||
|
texture1 = retrieveImage(dirName + texture1file);
|
||||||
|
texture2 = retrieveImage(dirName + texture2file);
|
||||||
|
texture3 = retrieveImage(dirName + texture3file);
|
||||||
|
btnLup = retrieveImage(dirName + btnLupfile);
|
||||||
|
btnMup = retrieveImage(dirName + btnMupfile);
|
||||||
|
btnRup = retrieveImage(dirName + btnRupfile);
|
||||||
|
btnLover = retrieveImage(dirName + btnLoverfile);
|
||||||
|
btnMover = retrieveImage(dirName + btnMoverfile);
|
||||||
|
btnRover = retrieveImage(dirName + btnRoverfile);
|
||||||
|
btnLdown = retrieveImage(dirName + btnLdownfile);
|
||||||
|
btnMdown = retrieveImage(dirName + btnMdownfile);
|
||||||
|
btnRdown = retrieveImage(dirName + btnRdownfile);
|
||||||
|
|
||||||
|
// Color palette
|
||||||
|
File file= new File(dirName + paletteFile);
|
||||||
|
BufferedImage image;
|
||||||
|
try {
|
||||||
|
image = ImageIO.read(file);
|
||||||
|
bg1a = getColorFromPixel(image.getRGB(10,30));
|
||||||
|
bg1b = getColorFromPixel(image.getRGB(30,30));
|
||||||
|
bg2a = getColorFromPixel(image.getRGB(50,30));
|
||||||
|
bg2b = getColorFromPixel(image.getRGB(70,30));
|
||||||
|
bg3a = getColorFromPixel(image.getRGB(90,30));
|
||||||
|
bg3b = getColorFromPixel(image.getRGB(110,30));
|
||||||
|
|
||||||
|
txt1a = getColorFromPixel(image.getRGB(10,70));
|
||||||
|
txt1b = getColorFromPixel(image.getRGB(30,70));
|
||||||
|
txt2a = getColorFromPixel(image.getRGB(50,70));
|
||||||
|
txt2b = getColorFromPixel(image.getRGB(70,70));
|
||||||
|
txt3a = getColorFromPixel(image.getRGB(90,70));
|
||||||
|
txt3b = getColorFromPixel(image.getRGB(110,70));
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println(notfound + paletteFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>retrieveImage.</p>
|
||||||
|
* Tries to instantiate an image icon from a filename.
|
||||||
|
* Error reported if not found.
|
||||||
|
*
|
||||||
|
* @param {@link java.lang.String} address
|
||||||
|
* @return a ImageIcon
|
||||||
|
*/
|
||||||
|
private ImageIcon retrieveImage(String address) {
|
||||||
|
tempImg = new ImageIcon(address);
|
||||||
|
if(tempImg.getIconWidth()==-1) {
|
||||||
|
System.err.println(notfound + address);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tempImg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>retrieveFont.</p>
|
||||||
|
* 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 found.
|
||||||
|
*
|
||||||
|
* @param {@link java.lang.String} address
|
||||||
|
* @return a Font
|
||||||
|
*/
|
||||||
|
private Font retrieveFont(String address) {
|
||||||
|
tempFont = GuiUtils.newFont(address);
|
||||||
|
|
||||||
|
return tempFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>getColorFromPixel.</p>
|
||||||
|
*
|
||||||
|
* @param {@link java.lang.Integer} pixel information
|
||||||
|
*/
|
||||||
|
private Color getColorFromPixel(int pixel) {
|
||||||
|
return new Color(
|
||||||
|
(pixel & 0x00ff0000) >> 16,
|
||||||
|
(pixel & 0x0000ff00) >> 8,
|
||||||
|
(pixel & 0x000000ff)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>getSetting.</p>
|
||||||
|
* Retrieves a specific skin setting. If skin setting is not defined,
|
||||||
|
* will attempt to use default value.
|
||||||
|
*
|
||||||
|
* @param key a {@link java.lang.String} object.
|
||||||
|
* @return a {@link java.lang.String} object.
|
||||||
|
*/
|
||||||
|
public String getSetting(String key) {
|
||||||
|
String val = null;
|
||||||
|
|
||||||
|
if(customSettings.size() > 1) {
|
||||||
|
val = customSettings.get(key);
|
||||||
|
if(val==null) {
|
||||||
|
System.err.println("FSkin > getSetting: Could not find "+key+
|
||||||
|
" setting for "+customSettings.get("name")+" skin!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(val==null) {
|
||||||
|
val = defaultSettings.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(val==null) {
|
||||||
|
System.err.println("FSkin > getSetting: Could not find "+key+
|
||||||
|
" in default settings!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ public class ForgePreferences extends Preferences {
|
|||||||
public boolean uploadDraftAI;
|
public boolean uploadDraftAI;
|
||||||
public boolean randCFoil;
|
public boolean randCFoil;
|
||||||
|
|
||||||
|
public String skin;
|
||||||
public String laf;
|
public String laf;
|
||||||
public boolean lafFonts;
|
public boolean lafFonts;
|
||||||
public StackOffsetType stackOffset;
|
public StackOffsetType stackOffset;
|
||||||
@@ -80,6 +81,7 @@ public class ForgePreferences extends Preferences {
|
|||||||
|
|
||||||
laf = get("gui.laf", "");
|
laf = get("gui.laf", "");
|
||||||
lafFonts = getBoolean("gui.laf.fonts", false);
|
lafFonts = getBoolean("gui.laf.fonts", false);
|
||||||
|
skin = get("gui.skin","default");
|
||||||
|
|
||||||
cardOverlay = getBoolean("card.overlay", true);
|
cardOverlay = getBoolean("card.overlay", true);
|
||||||
cardSize = CardSizeType.valueOf(get("card.images.size", "medium"));
|
cardSize = CardSizeType.valueOf(get("card.images.size", "medium"));
|
||||||
@@ -122,6 +124,7 @@ public class ForgePreferences extends Preferences {
|
|||||||
|
|
||||||
set("rand.C.Foil", randCFoil);
|
set("rand.C.Foil", randCFoil);
|
||||||
|
|
||||||
|
set("gui.skin", skin);
|
||||||
set("gui.laf", laf);
|
set("gui.laf", laf);
|
||||||
set("gui.laf.fonts", lafFonts);
|
set("gui.laf.fonts", lafFonts);
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,15 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
|||||||
view.btnQuit.setText("Surrender (15 Credits)");
|
view.btnQuit.setText("Surrender (15 Credits)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
view.btnContinue.setVisible(false);
|
||||||
|
if(wonMatch) {
|
||||||
|
view.btnQuit.setText("Great!");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
view.btnQuit.setText("OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Win case
|
// Win case
|
||||||
if(wonMatch) {
|
if(wonMatch) {
|
||||||
@@ -145,8 +154,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Win or lose, still a chance to win a booster, frequency set in preferences
|
// Win or lose, still a chance to win a booster, frequency set in preferences
|
||||||
int cntOutcomes = wonMatch ? model.qData.getWin() : model.qData.getLost();
|
int outcome = wonMatch ? model.qData.getWin() : model.qData.getLost();
|
||||||
if (cntOutcomes % QuestPreferences.getWinsForBooster(model.qData.getDifficultyIndex()) == 0) {
|
if (outcome % QuestPreferences.getWinsForBooster(model.qData.getDifficultyIndex()) == 0) {
|
||||||
awardBooster();
|
awardBooster();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,7 +353,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
|||||||
|
|
||||||
lblTemp2 = new JLabel(sb.toString());
|
lblTemp2 = new JLabel(sb.toString());
|
||||||
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
lblTemp2.setFont(new Font("Tahoma", Font.PLAIN, 14));
|
lblTemp2.setFont(AllZone.getSkin().font2.deriveFont(Font.PLAIN,14));
|
||||||
lblTemp2.setForeground(Color.white);
|
lblTemp2.setForeground(Color.white);
|
||||||
lblTemp2.setIcon(icoTemp);
|
lblTemp2.setIcon(icoTemp);
|
||||||
lblTemp2.setIconTextGap(50);
|
lblTemp2.setIconTextGap(50);
|
||||||
@@ -441,7 +450,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
|||||||
((QuestChallenge)model.qEvent).getTitle() + "\"");
|
((QuestChallenge)model.qEvent).getTitle() + "\"");
|
||||||
|
|
||||||
lblTemp2 = new JLabel(sb.toString());
|
lblTemp2 = new JLabel(sb.toString());
|
||||||
lblTemp2.setFont(new Font("Tahoma", Font.PLAIN, 14));
|
lblTemp2.setFont(AllZone.getSkin().font2.deriveFont(Font.PLAIN,14));
|
||||||
lblTemp2.setForeground(Color.white);
|
lblTemp2.setForeground(Color.white);
|
||||||
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
lblTemp2.setIconTextGap(50);
|
lblTemp2.setIconTextGap(50);
|
||||||
@@ -464,7 +473,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
|||||||
lblTemp1 = new TitleLabel("Gameplay Results");
|
lblTemp1 = new TitleLabel("Gameplay Results");
|
||||||
|
|
||||||
lblTemp2 = new JLabel("You lose! You have lost 15 credits.");
|
lblTemp2 = new JLabel("You lose! You have lost 15 credits.");
|
||||||
lblTemp2.setFont(new Font("Tahoma", Font.PLAIN, 14));
|
lblTemp2.setFont(AllZone.getSkin().font2.deriveFont(Font.PLAIN,14));
|
||||||
lblTemp2.setForeground(Color.white);
|
lblTemp2.setForeground(Color.white);
|
||||||
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
lblTemp2.setIconTextGap(50);
|
lblTemp2.setIconTextGap(50);
|
||||||
@@ -530,11 +539,15 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
|||||||
return credits;
|
return credits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JLabel header between reward sections.
|
||||||
|
*
|
||||||
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
private class TitleLabel extends JLabel {
|
private class TitleLabel extends JLabel {
|
||||||
TitleLabel(String msg) {
|
TitleLabel(String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
this.setFont(new Font("Tahoma", Font.ITALIC, 16));
|
this.setFont(AllZone.getSkin().font2.deriveFont(Font.ITALIC,16));
|
||||||
this.setPreferredSize(new Dimension(200,40));
|
this.setPreferredSize(new Dimension(200,40));
|
||||||
this.setHorizontalAlignment(SwingConstants.CENTER);
|
this.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
this.setForeground(Color.white);
|
this.setForeground(Color.white);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import forge.Constant;
|
|||||||
import forge.ImageCache;
|
import forge.ImageCache;
|
||||||
import forge.error.ErrorViewer;
|
import forge.error.ErrorViewer;
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
|
import forge.gui.skin.FSkin;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.properties.ForgePreferences;
|
import forge.properties.ForgePreferences;
|
||||||
import forge.view.FView;
|
import forge.view.FView;
|
||||||
@@ -98,6 +99,8 @@ public class ApplicationView implements FView {
|
|||||||
OldGuiNewGame.upldDrftCheckBox.setSelected(preferences.uploadDraftAI);
|
OldGuiNewGame.upldDrftCheckBox.setSelected(preferences.uploadDraftAI);
|
||||||
OldGuiNewGame.foilRandomCheckBox.setSelected(preferences.randCFoil);
|
OldGuiNewGame.foilRandomCheckBox.setSelected(preferences.randCFoil);
|
||||||
|
|
||||||
|
AllZone.setSkin(new FSkin(preferences.skin));
|
||||||
|
|
||||||
} catch (Exception exn) {
|
} catch (Exception exn) {
|
||||||
Log.error("Error loading preferences: " + exn);
|
Log.error("Error loading preferences: " + exn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
package forge.view.swing;
|
package forge.view.swing;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Container;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.border.AbstractBorder;
|
||||||
|
|
||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
import forge.Phase;
|
import forge.Phase;
|
||||||
import forge.Player;
|
import forge.Player;
|
||||||
|
import forge.gui.skin.FButton;
|
||||||
|
import forge.gui.skin.FPanel;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants.LANG.WinLoseFrame.WINLOSETEXT;
|
import forge.properties.NewConstants.LANG.WinLoseFrame.WINLOSETEXT;
|
||||||
import forge.quest.data.QuestMatchState;
|
import forge.quest.data.QuestMatchState;
|
||||||
@@ -24,7 +27,7 @@ import forge.quest.data.QuestMatchState;
|
|||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
/** <p>WinLoseFrame.</p>
|
/** <p>WinLoseFrame.</p>
|
||||||
* Core display for win/lose UI shown after completing a game.
|
* VIEW - Core display for win/lose UI shown after completing a game.
|
||||||
* Uses handlers to customize central panel for various game modes.
|
* Uses handlers to customize central panel for various game modes.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -34,9 +37,9 @@ public class WinLoseFrame extends JFrame {
|
|||||||
private QuestMatchState matchState;
|
private QuestMatchState matchState;
|
||||||
private WinLoseModeHandler modeHandler;
|
private WinLoseModeHandler modeHandler;
|
||||||
|
|
||||||
public JButton btnContinue;
|
public FButton btnContinue;
|
||||||
public JButton btnQuit;
|
public FButton btnQuit;
|
||||||
public JButton btnRestart;
|
public FButton btnRestart;
|
||||||
|
|
||||||
public JLabel lblTitle;
|
public JLabel lblTitle;
|
||||||
public JLabel lblStats;
|
public JLabel lblStats;
|
||||||
@@ -66,11 +69,14 @@ public class WinLoseFrame extends JFrame {
|
|||||||
modeHandler = mh;
|
modeHandler = mh;
|
||||||
modeHandler.setView(this);
|
modeHandler.setView(this);
|
||||||
matchState = AllZone.getMatchState();
|
matchState = AllZone.getMatchState();
|
||||||
Container contentPane = this.getContentPane();
|
|
||||||
contentPane.setLayout(new MigLayout("wrap, fill"));
|
|
||||||
contentPane.setBackground(new Color(16,28,50));
|
|
||||||
|
|
||||||
//This needs to be at least 150, or the quit button is off the pane on Mac OS X
|
// Place all content in FPanel
|
||||||
|
FPanel contentPanel = new FPanel(new MigLayout("wrap, fill, insets 20 0 10 10"));
|
||||||
|
contentPanel.setBGImg(AllZone.getSkin().texture1);
|
||||||
|
contentPanel.setBorder(new WinLoseBorder());
|
||||||
|
getContentPane().add(contentPanel);
|
||||||
|
|
||||||
|
//Footer should be at least 150 to keep buttons in-pane on Mac OS X
|
||||||
int HEAD_HEIGHT = 150;
|
int HEAD_HEIGHT = 150;
|
||||||
int FOOT_HEIGHT = 150;
|
int FOOT_HEIGHT = 150;
|
||||||
int FRAME_WIDTH_SMALL = 300;
|
int FRAME_WIDTH_SMALL = 300;
|
||||||
@@ -79,17 +85,17 @@ public class WinLoseFrame extends JFrame {
|
|||||||
// Head panel
|
// Head panel
|
||||||
JPanel pnlHead = new JPanel(new MigLayout("wrap, fill"));
|
JPanel pnlHead = new JPanel(new MigLayout("wrap, fill"));
|
||||||
pnlHead.setOpaque(false);
|
pnlHead.setOpaque(false);
|
||||||
this.add(pnlHead,"width " + FRAME_WIDTH_SMALL + "!, align center");
|
contentPanel.add(pnlHead,"width " + FRAME_WIDTH_SMALL + "!, align center");
|
||||||
|
|
||||||
lblTitle = new JLabel("WinLoseFrame > lblTitle is broken.");
|
lblTitle = new JLabel("WinLoseFrame > lblTitle is broken.");
|
||||||
lblTitle.setForeground(Color.white);
|
lblTitle.setForeground(Color.white);
|
||||||
lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
|
lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 26));
|
lblTitle.setFont(AllZone.getSkin().font1.deriveFont(Font.PLAIN,26));
|
||||||
|
|
||||||
lblStats = new JLabel("WinLoseFrame > lblStats is broken.");
|
lblStats = new JLabel("WinLoseFrame > lblStats is broken.");
|
||||||
lblStats.setForeground(Color.white);
|
lblStats.setForeground(Color.white);
|
||||||
lblStats.setHorizontalAlignment(SwingConstants.CENTER);
|
lblStats.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
lblStats.setFont(new Font("Tahoma", Font.ITALIC, 21));
|
lblStats.setFont(AllZone.getSkin().font1.deriveFont(Font.PLAIN,26));
|
||||||
|
|
||||||
pnlHead.add(lblTitle, "growx");
|
pnlHead.add(lblTitle, "growx");
|
||||||
pnlHead.add(lblStats, "growx");
|
pnlHead.add(lblStats, "growx");
|
||||||
@@ -99,21 +105,21 @@ public class WinLoseFrame extends JFrame {
|
|||||||
pnlCustom = new JPanel(new MigLayout("wrap, fillx"));
|
pnlCustom = new JPanel(new MigLayout("wrap, fillx"));
|
||||||
pnlCustom.setBackground(new Color(111,87,59));
|
pnlCustom.setBackground(new Color(111,87,59));
|
||||||
pnlCustom.setForeground(Color.white);
|
pnlCustom.setForeground(Color.white);
|
||||||
this.add(scroller);
|
contentPanel.add(scroller,"w 96%!, align center, gapleft 2%");
|
||||||
scroller.getViewport().add(pnlCustom);
|
scroller.getViewport().add(pnlCustom);
|
||||||
|
|
||||||
// Foot panel
|
// Foot panel
|
||||||
JPanel pnlFoot = new JPanel(new MigLayout("wrap, fill, hidemode 3"));
|
JPanel pnlFoot = new JPanel(new MigLayout("wrap, fill, hidemode 3"));
|
||||||
pnlFoot.setOpaque(false);
|
pnlFoot.setOpaque(false);
|
||||||
this.add(pnlFoot,"width " + FRAME_WIDTH_SMALL + "!, align center");
|
contentPanel.add(pnlFoot,"width " + FRAME_WIDTH_SMALL + "!, align center");
|
||||||
|
|
||||||
this.btnContinue = new WinLoseButton("Continue");
|
this.btnContinue = new FButton("Continue");
|
||||||
this.btnRestart = new WinLoseButton("Restart");
|
this.btnRestart = new FButton("Restart");
|
||||||
this.btnQuit = new WinLoseButton("Quit");
|
this.btnQuit = new FButton("Quit");
|
||||||
|
|
||||||
pnlFoot.add(btnContinue,"height 30!, gap 0 0 5 5, align center");
|
pnlFoot.add(btnContinue,"h 36:36, w 150, gap 0 0 5 5, align center");
|
||||||
pnlFoot.add(btnRestart,"height 30!, gap 0 0 5 5, align center");
|
pnlFoot.add(btnRestart,"h 36:36, w 150, gap 0 0 5 5, align center");
|
||||||
pnlFoot.add(btnQuit,"height 30!, gap 0 0 5 5, align center");
|
pnlFoot.add(btnQuit,"h 36:36, w 150, gap 0 0 5 5, align center");
|
||||||
|
|
||||||
// Button actions
|
// Button actions
|
||||||
btnQuit.addActionListener(new java.awt.event.ActionListener() {
|
btnQuit.addActionListener(new java.awt.event.ActionListener() {
|
||||||
@@ -152,14 +158,14 @@ public class WinLoseFrame extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Populate custom panel, if necessary.
|
// Populate custom panel, if necessary.
|
||||||
boolean hasStuff = modeHandler.populateCustomPanel();
|
boolean hasContents = modeHandler.populateCustomPanel();
|
||||||
if(!hasStuff) { scroller.setVisible(false); }
|
if(!hasContents) { scroller.setVisible(false); }
|
||||||
|
|
||||||
// Size and show frame
|
// Size and show frame
|
||||||
Dimension screen = this.getToolkit().getScreenSize();
|
Dimension screen = this.getToolkit().getScreenSize();
|
||||||
Rectangle bounds = this.getBounds();
|
Rectangle bounds = this.getBounds();
|
||||||
|
|
||||||
if(hasStuff) {
|
if(hasContents) {
|
||||||
bounds.height = screen.height - 150;
|
bounds.height = screen.height - 150;
|
||||||
scroller.setPreferredSize(new Dimension(FRAME_WIDTH_BIG,
|
scroller.setPreferredSize(new Dimension(FRAME_WIDTH_BIG,
|
||||||
screen.height - HEAD_HEIGHT - FOOT_HEIGHT));
|
screen.height - HEAD_HEIGHT - FOOT_HEIGHT));
|
||||||
@@ -174,6 +180,7 @@ public class WinLoseFrame extends JFrame {
|
|||||||
bounds.y = (screen.height - bounds.height)/2;
|
bounds.y = (screen.height - bounds.height)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setBackground(AllZone.getSkin().bg1a);
|
||||||
this.setBounds(bounds);
|
this.setBounds(bounds);
|
||||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
this.setUndecorated(true);
|
this.setUndecorated(true);
|
||||||
@@ -226,7 +233,7 @@ public class WinLoseFrame extends JFrame {
|
|||||||
* @return {@link javax.swing.JFrame} display frame
|
* @return {@link javax.swing.JFrame} display frame
|
||||||
*/
|
*/
|
||||||
final JFrame closeWinLoseFrame() {
|
final JFrame closeWinLoseFrame() {
|
||||||
// issue 147 - keep battlefield up following win/loss
|
// Issue 147 - keep battlefield up following win/loss
|
||||||
JFrame frame = (JFrame) AllZone.getDisplay();
|
JFrame frame = (JFrame) AllZone.getDisplay();
|
||||||
frame.dispose();
|
frame.dispose();
|
||||||
frame.setEnabled(true);
|
frame.setEnabled(true);
|
||||||
@@ -234,17 +241,14 @@ public class WinLoseFrame extends JFrame {
|
|||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private class WinLoseBorder extends AbstractBorder {
|
||||||
* <p>WinLoseButton.</p>
|
public void paintBorder(Component c,
|
||||||
* Private button class to standardize buttons.
|
Graphics g, int x, int y, int width,
|
||||||
*
|
int height) {
|
||||||
*/
|
g.setColor(AllZone.getSkin().txt1a);
|
||||||
private class WinLoseButton extends JButton {
|
g.drawRect(x+1, y+1, width-3, height-3);
|
||||||
WinLoseButton(String msg) {
|
g.setColor(AllZone.getSkin().bg1a);
|
||||||
super(msg);
|
g.drawRect(x+3, y+3, width-7, height-7);
|
||||||
this.setFont(new Font("Tahoma", Font.PLAIN, 14));
|
}
|
||||||
this.setOpaque(false);
|
|
||||||
this.setPreferredSize(new Dimension(125,30));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||