mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
-Fix bug with HQ Token.
This commit is contained in:
@@ -28,7 +28,7 @@ public class GUI_PictureHQ extends JDialog
|
||||
|
||||
|
||||
|
||||
public GUI_PictureHQ(JFrame frame, String c)
|
||||
public GUI_PictureHQ(JFrame frame, Card c)
|
||||
{
|
||||
super(frame);
|
||||
this.setUndecorated(true);
|
||||
@@ -41,16 +41,15 @@ public class GUI_PictureHQ extends JDialog
|
||||
getContentPane().add(jPanelPictureHQ, BorderLayout.CENTER);
|
||||
jPanelPictureHQ.setBorder(BorderFactory.createEtchedBorder());;
|
||||
jPanelPictureHQ.removeAll();
|
||||
jPanelPictureHQ.add(GuiDisplayUtil.getPictureHQ(c));
|
||||
jPanelPictureHQ.revalidate();
|
||||
jPanelPictureHQ.add(GuiDisplayUtil.getPictureHQ(c));
|
||||
jPanelPictureHQ.revalidate();
|
||||
jPanelPictureHQ.addMouseListener(new CustomListener());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pack();
|
||||
}
|
||||
|
||||
public void letsGo(JFrame frame, String c) throws IOException
|
||||
public void letsGo(JFrame frame, Card c) throws IOException
|
||||
{
|
||||
GUI_PictureHQ trayWindow = new GUI_PictureHQ(frame, c);
|
||||
int heightHQ = GuiDisplayUtil.getPictureHQheight(c);
|
||||
|
||||
@@ -92,8 +92,7 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon
|
||||
private Action COMPUTER_GRAVEYARD_ACTION;
|
||||
private Action COMPUTER_REMOVED_ACTION;
|
||||
private Action CONCEDE_ACTION;
|
||||
public String cardN;
|
||||
public String cOwner;
|
||||
public Card cCardHQ;
|
||||
|
||||
public GuiDisplay3() {
|
||||
setupActions();
|
||||
@@ -505,13 +504,7 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon
|
||||
else this.cdArea.setText(tokenText + counterText);
|
||||
|
||||
cdPanel.setBorder(GuiDisplayUtil.getBorder(c));
|
||||
|
||||
if(c.getOwner()=="Computer" && c.isFaceDown()==true){
|
||||
cardN = "morph";
|
||||
}else{
|
||||
cardN = c.getName();
|
||||
}
|
||||
|
||||
cCardHQ = c;
|
||||
|
||||
|
||||
//picture
|
||||
@@ -1174,37 +1167,37 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
if (picturePanel.getComponentCount()!=0){
|
||||
cardN= GuiDisplayUtil.cleanString(cardN);
|
||||
cardN = cardN+".jpg";
|
||||
|
||||
if(GuiDisplayUtil.IsPictureHQExists(cardN)){
|
||||
if(cCardHQ.isFaceDown()==true && cCardHQ.getOwner()=="Computer"){
|
||||
return;
|
||||
}else{
|
||||
if(GuiDisplayUtil.IsPictureHQExists(cCardHQ)){
|
||||
int cWidth = 0;
|
||||
try {
|
||||
cWidth = GuiDisplayUtil.getPictureHQwidth(cardN);
|
||||
cWidth = GuiDisplayUtil.getPictureHQwidth(cCardHQ);
|
||||
} catch (IOException e2) {
|
||||
|
||||
e2.printStackTrace();
|
||||
}
|
||||
int cHeight = 0;
|
||||
try {
|
||||
cHeight = GuiDisplayUtil.getPictureHQheight(cardN);
|
||||
cHeight = GuiDisplayUtil.getPictureHQheight(cCardHQ);
|
||||
} catch (IOException e2) {
|
||||
|
||||
e2.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
if(cWidth>=312 &&cHeight >=445){
|
||||
|
||||
GUI_PictureHQ hq = new GUI_PictureHQ(GuiDisplay3.this,cardN);
|
||||
GUI_PictureHQ hq = new GUI_PictureHQ(GuiDisplay3.this,cCardHQ);
|
||||
try {
|
||||
hq.letsGo(GuiDisplay3.this, cardN);
|
||||
cardN = cardN.substring(0, cardN.length()-4);
|
||||
hq.letsGo(GuiDisplay3.this, cCardHQ);
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
}}}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import javax.imageio.*;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
@@ -210,27 +211,31 @@ public class GuiDisplayUtil implements NewConstants {
|
||||
|
||||
|
||||
if(file.exists()) {
|
||||
int cWidth = 0;
|
||||
int cHeight = 0;
|
||||
try {
|
||||
cWidth = GuiDisplayUtil.getPictureHQwidth(filename);
|
||||
} catch (IOException e) {
|
||||
if(c.isFaceDown()){
|
||||
return new PicturePanel(file);
|
||||
}else{
|
||||
int cWidth = 0;
|
||||
int cHeight = 0;
|
||||
try {
|
||||
cWidth = GuiDisplayUtil.getPictureHQwidth(c);
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
cHeight = GuiDisplayUtil.getPictureHQheight(c);
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
cHeight = GuiDisplayUtil.getPictureHQheight(filename);
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(cWidth<=312 || cHeight<=445) {
|
||||
return new PicturePanel(file);
|
||||
}else{
|
||||
return new PicturePanelResize(file);
|
||||
}
|
||||
if(cWidth<=312 || cHeight<=445) {
|
||||
return new PicturePanel(file);
|
||||
}else{
|
||||
return new PicturePanelResize(file);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
JPanel p = new JPanel();
|
||||
|
||||
@@ -249,27 +254,52 @@ public class GuiDisplayUtil implements NewConstants {
|
||||
}//getPicture()
|
||||
|
||||
|
||||
public static JPanel getPictureHQ(String c) {
|
||||
File file = new File(ForgeProps.getFile(IMAGE_BASE), c);
|
||||
public static JPanel getPictureHQ(Card c) {
|
||||
|
||||
String loc = "";
|
||||
if (c.isToken()== false)
|
||||
loc = IMAGE_BASE;
|
||||
else
|
||||
loc = IMAGE_TOKEN;
|
||||
String filename = GuiDisplayUtil.cleanString(c.getImageName()) + ".jpg";
|
||||
File file = new File(ForgeProps.getFile(loc), filename);
|
||||
return new PicturePanel(file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static int getPictureHQheight(String c) throws IOException{
|
||||
File file = new File(ForgeProps.getFile(IMAGE_BASE), c);
|
||||
public static int getPictureHQheight(Card c) throws IOException{
|
||||
String loc = "";
|
||||
if (c.isToken()== false)
|
||||
loc = IMAGE_BASE;
|
||||
else
|
||||
loc = IMAGE_TOKEN;
|
||||
String filename = GuiDisplayUtil.cleanString(c.getImageName()) + ".jpg";
|
||||
File file = new File(ForgeProps.getFile(loc), filename);
|
||||
BufferedImage a = ImageIO.read(file);
|
||||
return a.getHeight();
|
||||
}
|
||||
|
||||
public static int getPictureHQwidth(String c) throws IOException{
|
||||
File file = new File(ForgeProps.getFile(IMAGE_BASE), c);
|
||||
public static int getPictureHQwidth(Card c) throws IOException{
|
||||
String loc = "";
|
||||
if (c.isToken()== false)
|
||||
loc = IMAGE_BASE;
|
||||
else
|
||||
loc = IMAGE_TOKEN;
|
||||
String filename = GuiDisplayUtil.cleanString(c.getImageName()) + ".jpg";
|
||||
File file = new File(ForgeProps.getFile(loc), filename);
|
||||
BufferedImage a = ImageIO.read(file);
|
||||
return a.getWidth();
|
||||
}
|
||||
|
||||
public static boolean IsPictureHQExists(String c) {
|
||||
File file = new File(ForgeProps.getFile(IMAGE_BASE), c);
|
||||
public static boolean IsPictureHQExists(Card c) {
|
||||
String loc = "";
|
||||
if (c.isToken()== false)
|
||||
loc = IMAGE_BASE;
|
||||
else
|
||||
loc = IMAGE_TOKEN;
|
||||
String filename = GuiDisplayUtil.cleanString(c.getImageName()) + ".jpg";
|
||||
File file = new File(ForgeProps.getFile(loc), filename);
|
||||
if(file.exists()){
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class Gui_DeckEditor extends JFrame implements CardDetail, DeckDisplay {
|
||||
|
||||
private CardList top;
|
||||
private CardList bottom;
|
||||
public String cardN;
|
||||
public Card cCardHQ;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -399,7 +399,7 @@ public class Gui_DeckEditor extends JFrame implements CardDetail, DeckDisplay {
|
||||
//change card name if needed
|
||||
c = AllZone.CardFactory.copyCard(c);
|
||||
if(AllZone.NameChanger.shouldChangeCardName()) c = AllZone.NameChanger.changeCard(c);
|
||||
cardN = c.getName();
|
||||
cCardHQ = c;
|
||||
CardDetailUtil.updateCardDetail(c, cdTextArea, cardDetailPanel, picturePanel, new JLabel[] {
|
||||
cdLabel1, cdLabel2, cdLabel3, cdLabel4, cdLabel5});
|
||||
}
|
||||
@@ -726,29 +726,28 @@ public class Gui_DeckEditor extends JFrame implements CardDetail, DeckDisplay {
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
if (picturePanel.getComponentCount()!=0){
|
||||
cardN= GuiDisplayUtil.cleanString(cardN);
|
||||
cardN = cardN+".jpg";
|
||||
if(GuiDisplayUtil.IsPictureHQExists(cardN)){
|
||||
|
||||
if(GuiDisplayUtil.IsPictureHQExists(cCardHQ)){
|
||||
int cWidth = 0;
|
||||
try {
|
||||
cWidth = GuiDisplayUtil.getPictureHQwidth(cardN);
|
||||
cWidth = GuiDisplayUtil.getPictureHQwidth(cCardHQ);
|
||||
} catch (IOException e2) {
|
||||
// TODO Auto-generated catch block
|
||||
e2.printStackTrace();
|
||||
}
|
||||
int cHeight = 0;
|
||||
try {
|
||||
cHeight = GuiDisplayUtil.getPictureHQheight(cardN);
|
||||
cHeight = GuiDisplayUtil.getPictureHQheight(cCardHQ);
|
||||
} catch (IOException e2) {
|
||||
// TODO Auto-generated catch block
|
||||
e2.printStackTrace();
|
||||
}
|
||||
|
||||
if(cWidth>=312 &&cHeight >=445){
|
||||
GUI_PictureHQ hq = new GUI_PictureHQ(Gui_DeckEditor.this,cardN);
|
||||
GUI_PictureHQ hq = new GUI_PictureHQ(Gui_DeckEditor.this,cCardHQ);
|
||||
try {
|
||||
hq.letsGo(Gui_DeckEditor.this, cardN);
|
||||
cardN = cardN.substring(0, cardN.length()-4);
|
||||
hq.letsGo(Gui_DeckEditor.this, cCardHQ);
|
||||
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -94,8 +94,8 @@ public class Gui_Quest_DeckEditor extends JFrame implements CardDetail, DeckDisp
|
||||
public boolean filterUsed;
|
||||
private CardList top;
|
||||
private CardList bottom;
|
||||
public String cardN;
|
||||
|
||||
public Card cCardHQ;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
@@ -432,7 +432,7 @@ public class Gui_Quest_DeckEditor extends JFrame implements CardDetail, DeckDisp
|
||||
//change card name if needed
|
||||
c = AllZone.CardFactory.copyCard(c);
|
||||
if(AllZone.NameChanger.shouldChangeCardName()) c = AllZone.NameChanger.changeCard(c);
|
||||
cardN = c.getName();
|
||||
cCardHQ = c;
|
||||
CardDetailUtil.updateCardDetail(c, cdTextArea, cardDetailPanel, picturePanel, new JLabel[] {
|
||||
cdLabel1, cdLabel2, cdLabel3, cdLabel4, cdLabel5});
|
||||
}
|
||||
@@ -788,20 +788,19 @@ public class Gui_Quest_DeckEditor extends JFrame implements CardDetail, DeckDisp
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
if (picturePanel.getComponentCount()!=0){
|
||||
cardN= GuiDisplayUtil.cleanString(cardN);
|
||||
cardN = cardN+".jpg";
|
||||
|
||||
|
||||
if(GuiDisplayUtil.IsPictureHQExists(cardN)){
|
||||
if(GuiDisplayUtil.IsPictureHQExists(cCardHQ)){
|
||||
int cWidth = 0;
|
||||
try {
|
||||
cWidth = GuiDisplayUtil.getPictureHQwidth(cardN);
|
||||
cWidth = GuiDisplayUtil.getPictureHQwidth(cCardHQ);
|
||||
} catch (IOException e2) {
|
||||
// TODO Auto-generated catch block
|
||||
e2.printStackTrace();
|
||||
}
|
||||
int cHeight = 0;
|
||||
try {
|
||||
cHeight = GuiDisplayUtil.getPictureHQheight(cardN);
|
||||
cHeight = GuiDisplayUtil.getPictureHQheight(cCardHQ);
|
||||
} catch (IOException e2) {
|
||||
// TODO Auto-generated catch block
|
||||
e2.printStackTrace();
|
||||
@@ -809,10 +808,9 @@ public class Gui_Quest_DeckEditor extends JFrame implements CardDetail, DeckDisp
|
||||
|
||||
if(cWidth>=312 &&cHeight >=445){
|
||||
|
||||
GUI_PictureHQ hq = new GUI_PictureHQ(Gui_Quest_DeckEditor.this,cardN);
|
||||
GUI_PictureHQ hq = new GUI_PictureHQ(Gui_Quest_DeckEditor.this,cCardHQ);
|
||||
try {
|
||||
hq.letsGo(Gui_Quest_DeckEditor.this, cardN);
|
||||
cardN = cardN.substring(0, cardN.length()-4);
|
||||
hq.letsGo(Gui_Quest_DeckEditor.this, cCardHQ);
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user