mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 18:50:06 -08:00
This commit is contained in:
parent
ba0e5a1aed
commit
a102a7d614
1 changed files with 15 additions and 1 deletions
|
|
@ -177,7 +177,7 @@ public class CardInfoWindowDialog extends MageDialog implements MageDesktopIconi
|
||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
// auto-position on first usage
|
// auto-position on first usage
|
||||||
if (positioned) {
|
if (!positioned) {
|
||||||
showAndPositionWindow();
|
showAndPositionWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -190,9 +190,23 @@ public class CardInfoWindowDialog extends MageDialog implements MageDesktopIconi
|
||||||
Point centered = SettingsManager.instance.getComponentPosition(width, height);
|
Point centered = SettingsManager.instance.getComponentPosition(width, height);
|
||||||
if (!positioned) {
|
if (!positioned) {
|
||||||
// starting position
|
// starting position
|
||||||
|
|
||||||
|
// auto-resize window, but keep it GUI friendly on too many cards (do not overlap a full screen)
|
||||||
|
int minWidth = CardInfoWindowDialog.this.getWidth();
|
||||||
|
int maxWidth = SettingsManager.instance.getScreenWidth() / 2;
|
||||||
|
int needWidth = CardInfoWindowDialog.this.cards.getPreferredSize().width;
|
||||||
|
needWidth = Math.max(needWidth, minWidth);
|
||||||
|
needWidth = Math.min(needWidth, maxWidth);
|
||||||
|
needWidth += GUISizeHelper.scrollBarSize; // more space, so no horizontal scrolls
|
||||||
|
int needHeight = CardInfoWindowDialog.this.getHeight(); // keep default height
|
||||||
|
CardInfoWindowDialog.this.setPreferredSize(new Dimension(needWidth, needHeight));
|
||||||
|
CardInfoWindowDialog.this.pack();
|
||||||
|
centered = SettingsManager.instance.getComponentPosition(needWidth, needHeight);
|
||||||
|
|
||||||
// little randomize to see multiple opened windows
|
// little randomize to see multiple opened windows
|
||||||
int xPos = centered.x / 2 + RandomUtil.nextInt(50);
|
int xPos = centered.x / 2 + RandomUtil.nextInt(50);
|
||||||
int yPos = centered.y / 2 + RandomUtil.nextInt(50);
|
int yPos = centered.y / 2 + RandomUtil.nextInt(50);
|
||||||
|
|
||||||
CardInfoWindowDialog.this.setLocation(xPos, yPos);
|
CardInfoWindowDialog.this.setLocation(xPos, yPos);
|
||||||
show();
|
show();
|
||||||
positioned = true;
|
positioned = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue