mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Improve plane monitor display
This commit is contained in:
@@ -11,6 +11,7 @@ import forge.card.CardRenderer;
|
|||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.planarconquest.ConquestPlane;
|
import forge.planarconquest.ConquestPlane;
|
||||||
import forge.toolbox.FDisplayObject;
|
import forge.toolbox.FDisplayObject;
|
||||||
|
import forge.toolbox.FOptionPane;
|
||||||
import forge.toolbox.FTimer;
|
import forge.toolbox.FTimer;
|
||||||
import forge.util.collect.FCollectionView;
|
import forge.util.collect.FCollectionView;
|
||||||
|
|
||||||
@@ -70,26 +71,29 @@ public class ConquestPlaneSelector extends FDisplayObject {
|
|||||||
|
|
||||||
//determine monitor position
|
//determine monitor position
|
||||||
FImage monitor = FSkinImage.PLANE_MONITOR;
|
FImage monitor = FSkinImage.PLANE_MONITOR;
|
||||||
float monitorHeight = w * monitor.getHeight() / monitor.getWidth();
|
float monitorLeft = FOptionPane.PADDING / 2;
|
||||||
float monitorTop = (h - monitorHeight) / 2;
|
float monitorWidth = w - 2 * monitorLeft;
|
||||||
|
float monitorHeight = monitorWidth * monitor.getHeight() / monitor.getWidth();
|
||||||
|
float monitorLeftOffset = monitorWidth * MONITOR_LEFT_MULTIPLIER;
|
||||||
|
float monitorTopOffset = monitorHeight * MONITOR_TOP_MULTIPLIER;
|
||||||
|
float monitorBottomOffset = monitorHeight * MONITOR_BOTTOM_MULTIPLIER;
|
||||||
|
float monitorTop = monitorLeft + monitorLeftOffset - monitorTopOffset;
|
||||||
|
|
||||||
//draw plane art inside monitor
|
//draw plane art inside monitor
|
||||||
if (currentArt != null) {
|
if (currentArt != null) {
|
||||||
float monitorTopOffset = monitorHeight * MONITOR_TOP_MULTIPLIER;
|
float x = monitorLeft + monitorLeftOffset - 1; //-1 to account for rounding error
|
||||||
float monitorBottomOffset = monitorHeight * MONITOR_BOTTOM_MULTIPLIER;
|
float y = monitorTop + monitorTopOffset - 1;
|
||||||
float x = w * MONITOR_LEFT_MULTIPLIER;
|
float artWidth = monitorWidth - 2 * monitorLeftOffset + 2;
|
||||||
float y = monitorTop + monitorTopOffset;
|
float artHeight = monitorHeight - monitorTopOffset - monitorBottomOffset + 2;
|
||||||
float artWidth = w - 2 * x;
|
|
||||||
float artHeight = monitorHeight - monitorTopOffset - monitorBottomOffset;
|
|
||||||
|
|
||||||
//scale up art to fill height of monitor while retain aspect ratio
|
//scale up art to fill height of monitor while retain aspect ratio
|
||||||
float fullArtWidth = artHeight * currentArt.getWidth() / currentArt.getHeight();
|
float fullArtWidth = artHeight * currentArt.getWidth() / currentArt.getHeight();
|
||||||
g.startClip(x, y, artWidth, artHeight);
|
g.startClip(x, y, artWidth, artHeight);
|
||||||
g.drawImage(currentArt, x + (w - fullArtWidth) / 2, y, fullArtWidth, artHeight);
|
g.drawImage(currentArt, x + (monitorWidth - fullArtWidth) / 2, y, fullArtWidth, artHeight);
|
||||||
g.endClip();
|
g.endClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw monitor so plane art remains within it
|
//draw monitor so plane art remains within it
|
||||||
g.drawImage(monitor, 0, monitorTop, w, monitorHeight);
|
g.drawImage(monitor, monitorLeft, monitorTop, monitorWidth, monitorHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user