* GUI: new reworked GUI and card render engine, card icons and dozens of other fixes (see full list in related PR);

This commit is contained in:
Oleg Agafonov 2021-01-30 16:38:55 +04:00
parent df98cc3e62
commit a1da5ef437
304 changed files with 7266 additions and 5093 deletions

View file

@ -1,13 +1,30 @@
package mage.cards;
import mage.cards.action.ActionCallback;
import mage.constants.Zone;
import mage.view.CardView;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
import java.util.UUID;
import java.util.List;
public abstract class MageCard extends JPanel {
/**
* @author JayDi85
*/
public abstract class MageCard extends JLayeredPane {
private static final Logger logger = Logger.getLogger(MageCard.class);
/**
* Return real MageCard panel (example: card icons uses MageLayerCard to implement additional panels)
* <p>
* If you need callback from card then use CardEventSource from form (search for example, e.g. card clicks processing)
*
* @return
*/
public MageCard getMainPanel() {
return this;
}
private static final long serialVersionUID = 6089945326434301879L;
@ -36,11 +53,9 @@ public abstract class MageCard extends JPanel {
public abstract Image getImage();
public abstract void setZone(String zone);
public abstract void setZone(Zone zone);
public abstract String getZone();
public abstract void updateCallback(ActionCallback callback, UUID gameId);
public abstract Zone getZone();
public abstract void toggleTransformed();
@ -50,11 +65,124 @@ public abstract class MageCard extends JPanel {
public abstract void setSelected(boolean selected);
public abstract void setCardAreaRef(JPanel cardArea);
/**
* Set link to cards list panel that contains the card component (can process mouse events from the card)
*
* @param cardContainer
*/
public abstract void setCardContainerRef(Container cardContainer);
public abstract void setTopPanelRef(MageCard mageCard);
public abstract MageCard getTopPanelRef();
public abstract Container getCardContainer();
public abstract void setChoosable(boolean isChoosable);
public abstract boolean isChoosable();
public abstract void setPopupMenu(JPopupMenu popupMenu);
public abstract JPopupMenu getPopupMenu();
public abstract void cleanUp();
public abstract int getCardWidth();
public abstract int getCardHeight();
public abstract MageCardAnimationSettings getAnimationSettings(int offsetX, int offsetY, float cardBoundWidth, float cardBoundHeight);
public abstract List<MageCard> getLinks();
public abstract MageCardSpace getOuterSpace();
/**
* Return top layer component location without outer/draw space (real card)
*
* @return
*/
public MageCardLocation getCardLocation() {
return getTopPanelRef().getCardLocation();
}
/**
* Set card location (top left corner of the main card panel). All calls goes to top layer panel.
*
* @param x
* @param y
*/
public void setCardLocation(int x, int y) {
setLocation(x, y);
}
/**
* Return top layer component location without outer/draw space (real card)
*
* @return
*/
public MageCardLocation getCardLocationOnScreen() {
return getTopPanelRef().getCardLocationOnScreen();
}
@Override
@Deprecated // default getLocationOnScreen for Swing engine only, use getCardLocationOnScreen instead
public Point getLocationOnScreen() {
return super.getLocationOnScreen();
}
@Override
@Deprecated // default getLocation for Swing engine only, use getCardLocation instead
public Point getLocation() {
return super.getLocation();
}
@Override
@Deprecated // default setLocation for inner usage only, call setCardLocation instead
public void setLocation(int x, int y) {
super.setLocation(x, y);
}
@Override
@Deprecated // default setLocation for inner usage only, call setCardLocation instead
public void setLocation(Point p) {
super.setLocation(p);
}
@Override
@Deprecated // default getBounds for Swing engine only, use getCardLocation instead
public Rectangle getBounds() {
return super.getBounds();
}
@Override
@Deprecated // default setBounds for inner usage only, call setCardBounds instead
public void setBounds(Rectangle r) {
super.setBounds(r);
}
@Override
@Deprecated // default setBounds for inner usage only, call setCardBounds instead
public void setBounds(int x, int y, int width, int height) {
super.setBounds(x, y, width, height);
}
@Override
@Deprecated // default getHeight for inner usage only, call getCardLocation instead
public int getHeight() {
return super.getHeight();
}
@Override
@Deprecated // default getWidth for inner usage only, call getCardLocation instead
public int getWidth() {
return super.getWidth();
}
@Override
@Deprecated // default getSize for inner usage only, call getCardLocation.getCardWidth instead
public Dimension getSize() {
return super.getSize();
}
}