mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Fix so font shrunk more appropriately
This commit is contained in:
@@ -132,11 +132,6 @@ public class VField implements IVDoc<CField> {
|
|||||||
updateDetails();
|
updateDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
//========= Overridden methods
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.IVDoc#populate()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void populate() {
|
public void populate() {
|
||||||
final JPanel pnl = parentCell.getBody();
|
final JPanel pnl = parentCell.getBody();
|
||||||
@@ -148,98 +143,55 @@ public class VField implements IVDoc<CField> {
|
|||||||
pnl.add(detailsPanel, "w 10%!, h 64%!, gapleft 1px");
|
pnl.add(detailsPanel, "w 10%!, h 64%!, gapleft 1px");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.IVDoc#getDocumentID()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public EDocID getDocumentID() {
|
public EDocID getDocumentID() {
|
||||||
return docID;
|
return docID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.IVDoc#getTabLabel()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public DragTab getTabLabel() {
|
public DragTab getTabLabel() {
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.IVDoc#getLayoutControl()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public CField getLayoutControl() {
|
public CField getLayoutControl() {
|
||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.IVDoc#setParentCell()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentCell(final DragCell cell0) {
|
public void setParentCell(final DragCell cell0) {
|
||||||
this.parentCell = cell0;
|
this.parentCell = cell0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.IVDoc#getParentCell()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public DragCell getParentCell() {
|
public DragCell getParentCell() {
|
||||||
return this.parentCell;
|
return this.parentCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
//========= Populate helper methods
|
|
||||||
|
|
||||||
|
|
||||||
// ========== Observer update methods
|
|
||||||
|
|
||||||
//========= Retrieval methods
|
|
||||||
/**
|
|
||||||
* Gets the player currently associated with this field.
|
|
||||||
* @return {@link forge.game.player.Player}
|
|
||||||
*/
|
|
||||||
public PlayerView getPlayer() {
|
public PlayerView getPlayer() {
|
||||||
return this.player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the tabletop.
|
|
||||||
*
|
|
||||||
* @return PlayArea where cards for this field are in play
|
|
||||||
*/
|
|
||||||
public PlayArea getTabletop() {
|
public PlayArea getTabletop() {
|
||||||
return this.tabletop;
|
return this.tabletop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the avatar area.
|
|
||||||
*
|
|
||||||
* @return JPanel containing avatar pic and life label
|
|
||||||
*/
|
|
||||||
public JPanel getAvatarArea() {
|
public JPanel getAvatarArea() {
|
||||||
return this.avatarArea;
|
return this.avatarArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link javax.swing.JLabel} */
|
|
||||||
public FLabel getLblAvatar() {
|
public FLabel getLblAvatar() {
|
||||||
return this.lblAvatar;
|
return this.lblAvatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link javax.swing.JLabel} */
|
|
||||||
public FLabel getLblLife() {
|
public FLabel getLblLife() {
|
||||||
return this.lblLife;
|
return this.lblLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the phase indicator
|
|
||||||
*/
|
|
||||||
public PhaseIndicator getPhaseIndicator() {
|
public PhaseIndicator getPhaseIndicator() {
|
||||||
return phaseIndicator;
|
return phaseIndicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the detailsPanel
|
|
||||||
*/
|
|
||||||
public PlayerDetailsPanel getDetailsPanel() {
|
public PlayerDetailsPanel getDetailsPanel() {
|
||||||
return detailsPanel;
|
return detailsPanel;
|
||||||
}
|
}
|
||||||
@@ -248,10 +200,6 @@ public class VField implements IVDoc<CField> {
|
|||||||
return MatchUtil.isHighlighted(player);
|
return MatchUtil.isHighlighted(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this method.
|
|
||||||
* @param player2
|
|
||||||
*/
|
|
||||||
public void updateDetails() {
|
public void updateDetails() {
|
||||||
detailsPanel.updateDetails();
|
detailsPanel.updateDetails();
|
||||||
|
|
||||||
|
|||||||
@@ -452,6 +452,14 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint, IButton {
|
|||||||
return this.cmdRightClick;
|
return this.cmdRightClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getMaxTextWidth() {
|
||||||
|
int w = getWidth();
|
||||||
|
int h = getHeight();
|
||||||
|
int sh = (int) (h * iconScaleFactor);
|
||||||
|
int sw = (int) (sh * iar);
|
||||||
|
return w - sw;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// Must be public.
|
// Must be public.
|
||||||
public void setIcon(final Icon i0) {
|
public void setIcon(final Icon i0) {
|
||||||
@@ -619,7 +627,7 @@ public class FLabel extends SkinnedLabel implements ILocalRepaint, IButton {
|
|||||||
g.drawRect(1, 1, w - 4, h - 4);
|
g.drawRect(1, 1, w - 4, h - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetIcon() {
|
protected void resetIcon() {
|
||||||
// Non-background icon
|
// Non-background icon
|
||||||
if (img != null && iconScaleAuto && !iconInBackground) {
|
if (img != null && iconScaleAuto && !iconInBackground) {
|
||||||
int h = (int) (getHeight() * iconScaleFactor);
|
int h = (int) (getHeight() * iconScaleFactor);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.toolbox.special;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -12,6 +13,7 @@ import javax.swing.SwingConstants;
|
|||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
@@ -23,6 +25,7 @@ import forge.gui.ForgeAction;
|
|||||||
import forge.screens.match.controllers.CPlayers;
|
import forge.screens.match.controllers.CPlayers;
|
||||||
import forge.toolbox.FLabel;
|
import forge.toolbox.FLabel;
|
||||||
import forge.toolbox.FSkin;
|
import forge.toolbox.FSkin;
|
||||||
|
import forge.toolbox.FSkin.SkinFont;
|
||||||
import forge.toolbox.FSkin.SkinnedPanel;
|
import forge.toolbox.FSkin.SkinnedPanel;
|
||||||
|
|
||||||
public class PlayerDetailsPanel extends JPanel {
|
public class PlayerDetailsPanel extends JPanel {
|
||||||
@@ -39,8 +42,8 @@ public class PlayerDetailsPanel extends JPanel {
|
|||||||
private FLabel lblPoison = new DetailLabel(FSkinProp.IMG_ZONE_POISON, "99", "Poison counters");
|
private FLabel lblPoison = new DetailLabel(FSkinProp.IMG_ZONE_POISON, "99", "Poison counters");
|
||||||
private final List<Pair<DetailLabel, Byte>> manaLabels = new ArrayList<Pair<DetailLabel, Byte>>();
|
private final List<Pair<DetailLabel, Byte>> manaLabels = new ArrayList<Pair<DetailLabel, Byte>>();
|
||||||
|
|
||||||
public PlayerDetailsPanel(final PlayerView player) {
|
public PlayerDetailsPanel(final PlayerView player0) {
|
||||||
this.player = player;
|
player = player0;
|
||||||
|
|
||||||
manaLabels.add(Pair.of(new DetailLabel(FSkinProp.IMG_MANA_B, "99", "Black mana"), MagicColor.BLACK));
|
manaLabels.add(Pair.of(new DetailLabel(FSkinProp.IMG_MANA_B, "99", "Black mana"), MagicColor.BLACK));
|
||||||
manaLabels.add(Pair.of(new DetailLabel(FSkinProp.IMG_MANA_U, "99", "Blue mana"), MagicColor.BLUE));
|
manaLabels.add(Pair.of(new DetailLabel(FSkinProp.IMG_MANA_U, "99", "Blue mana"), MagicColor.BLUE));
|
||||||
@@ -55,7 +58,6 @@ public class PlayerDetailsPanel extends JPanel {
|
|||||||
|
|
||||||
updateZones();
|
updateZones();
|
||||||
updateManaPool();
|
updateManaPool();
|
||||||
//updateDetails();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds various labels to pool area JPanel container. */
|
/** Adds various labels to pool area JPanel container. */
|
||||||
@@ -96,12 +98,12 @@ public class PlayerDetailsPanel extends JPanel {
|
|||||||
row6.add(manaLabels.get(5).getLeft(), constraintsCell);
|
row6.add(manaLabels.get(5).getLeft(), constraintsCell);
|
||||||
|
|
||||||
final String constraintsRow = "w 100%!, h 16%!";
|
final String constraintsRow = "w 100%!, h 16%!";
|
||||||
this.add(row1, constraintsRow + ", gap 0 0 2% 0");
|
add(row1, constraintsRow + ", gap 0 0 2% 0");
|
||||||
this.add(row2, constraintsRow);
|
add(row2, constraintsRow);
|
||||||
this.add(row3, constraintsRow);
|
add(row3, constraintsRow);
|
||||||
this.add(row4, constraintsRow);
|
add(row4, constraintsRow);
|
||||||
this.add(row5, constraintsRow);
|
add(row5, constraintsRow);
|
||||||
this.add(row6, constraintsRow);
|
add(row6, constraintsRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,14 +112,14 @@ public class PlayerDetailsPanel extends JPanel {
|
|||||||
* @param p0   {@link forge.game.player.Player}
|
* @param p0   {@link forge.game.player.Player}
|
||||||
*/
|
*/
|
||||||
public void updateZones() {
|
public void updateZones() {
|
||||||
this.getLblHand().setText("" + player.getHandSize());
|
getLblHand().setText("" + player.getHandSize());
|
||||||
final String handMaxToolTip = player.hasUnlimitedHandSize()
|
final String handMaxToolTip = player.hasUnlimitedHandSize()
|
||||||
? "no maximum hand size" : String.valueOf(player.getMaxHandSize());
|
? "no maximum hand size" : String.valueOf(player.getMaxHandSize());
|
||||||
this.getLblHand().setToolTipText("Cards in hand (max: " + handMaxToolTip + ")");
|
getLblHand().setToolTipText("Cards in hand (max: " + handMaxToolTip + ")");
|
||||||
this.getLblGraveyard().setText("" + player.getGraveyardSize());
|
getLblGraveyard().setText("" + player.getGraveyardSize());
|
||||||
this.getLblLibrary().setText("" + player.getLibrarySize());
|
getLblLibrary().setText("" + player.getLibrarySize());
|
||||||
this.getLblFlashback().setText("" + player.getFlashbackSize());
|
getLblFlashback().setText("" + player.getFlashbackSize());
|
||||||
this.getLblExile().setText("" + player.getExileSize());
|
getLblExile().setText("" + player.getExileSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,12 +133,12 @@ public class PlayerDetailsPanel extends JPanel {
|
|||||||
CPlayers.SINGLETON_INSTANCE.update();
|
CPlayers.SINGLETON_INSTANCE.update();
|
||||||
|
|
||||||
// Poison/life
|
// Poison/life
|
||||||
this.getLblPoison().setText("" + player.getPoisonCounters());
|
getLblPoison().setText("" + player.getPoisonCounters());
|
||||||
if (player.getPoisonCounters() < 8) {
|
if (player.getPoisonCounters() < 8) {
|
||||||
this.getLblPoison().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
getLblPoison().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.getLblPoison().setForeground(Color.red);
|
getLblPoison().setForeground(Color.red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,27 +154,27 @@ public class PlayerDetailsPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FLabel getLblHand() {
|
public FLabel getLblHand() {
|
||||||
return this.lblHand;
|
return lblHand;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLabel getLblLibrary() {
|
public FLabel getLblLibrary() {
|
||||||
return this.lblLibrary;
|
return lblLibrary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLabel getLblGraveyard() {
|
public FLabel getLblGraveyard() {
|
||||||
return this.lblGraveyard;
|
return lblGraveyard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLabel getLblExile() {
|
public FLabel getLblExile() {
|
||||||
return this.lblExile;
|
return lblExile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLabel getLblFlashback() {
|
public FLabel getLblFlashback() {
|
||||||
return this.lblFlashback;
|
return lblFlashback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLabel getLblPoison() {
|
public FLabel getLblPoison() {
|
||||||
return this.lblPoison;
|
return lblPoison;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupMouseActions(final ForgeAction handAction, final ForgeAction libraryAction, final ForgeAction exileAction,
|
public void setupMouseActions(final ForgeAction handAction, final ForgeAction libraryAction, final ForgeAction exileAction,
|
||||||
@@ -201,21 +203,34 @@ public class PlayerDetailsPanel extends JPanel {
|
|||||||
.text(s0).tooltip(s1).fontAlign(SwingConstants.RIGHT));
|
.text(s0).tooltip(s1).fontAlign(SwingConstants.RIGHT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setText(String text0) {
|
public void setText(String text0) {
|
||||||
super.setText(text0);
|
super.setText(text0);
|
||||||
|
autoSizeFont();
|
||||||
|
}
|
||||||
|
|
||||||
//adjust font size based on the text length to prevent it overlapping icon
|
protected void resetIcon() {
|
||||||
switch (text0.length()) {
|
super.resetIcon();
|
||||||
case 1:
|
autoSizeFont();
|
||||||
setFontSize(14);
|
}
|
||||||
break;
|
|
||||||
case 2:
|
private void autoSizeFont() {
|
||||||
setFontSize(10);
|
String text = getText();
|
||||||
break;
|
if (StringUtils.isEmpty(text)) { return; }
|
||||||
case 3:
|
|
||||||
setFontSize(8);
|
Graphics g = getGraphics();
|
||||||
break;
|
if (g == null) { return; }
|
||||||
|
|
||||||
|
int max = getMaxTextWidth();
|
||||||
|
|
||||||
|
SkinFont font = null;
|
||||||
|
for (int fontSize = 14; fontSize > 5; fontSize--) {
|
||||||
|
font = FSkin.getBoldFont(fontSize);
|
||||||
|
if (font.measureTextWidth(g, text) <= max) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (font != null) {
|
||||||
|
setFont(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user