mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -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();
|
||||
|
||||
// auto-position on first usage
|
||||
if (positioned) {
|
||||
if (!positioned) {
|
||||
showAndPositionWindow();
|
||||
}
|
||||
}
|
||||
|
|
@ -190,9 +190,23 @@ public class CardInfoWindowDialog extends MageDialog implements MageDesktopIconi
|
|||
Point centered = SettingsManager.instance.getComponentPosition(width, height);
|
||||
if (!positioned) {
|
||||
// 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
|
||||
int xPos = centered.x / 2 + RandomUtil.nextInt(50);
|
||||
int yPos = centered.y / 2 + RandomUtil.nextInt(50);
|
||||
|
||||
CardInfoWindowDialog.this.setLocation(xPos, yPos);
|
||||
show();
|
||||
positioned = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue