forked from External/mage
New ability picker (though not turned on yet)
This commit is contained in:
parent
d4ef4b24c3
commit
616aea619d
15 changed files with 685 additions and 17 deletions
|
|
@ -0,0 +1,68 @@
|
|||
package mage.client.util;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.dv.xs.YearMonthDV;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Contains dynamic settings for client.
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class SettingsManager {
|
||||
private static SettingsManager fInstance = new SettingsManager();
|
||||
|
||||
public static SettingsManager getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public int getScreenWidth() {
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
public void setScreenWidth(int screenWidth) {
|
||||
this.screenWidth = screenWidth;
|
||||
}
|
||||
|
||||
public int getScreenHeight() {
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
public void setScreenHeight(int screenHeight) {
|
||||
this.screenHeight = screenHeight;
|
||||
}
|
||||
|
||||
public void setScreenWidthAndHeight(int screenWidth, int screenHeight) {
|
||||
this.screenWidth = screenWidth;
|
||||
this.screenHeight = screenHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get centered component position. Depends on screen width and height.
|
||||
*
|
||||
* @param dialogWidth
|
||||
* @param dialogHeight
|
||||
* @return
|
||||
*/
|
||||
public Point getComponentPosition(int dialogWidth, int dialogHeight) {
|
||||
if (dialogWidth == 0) {
|
||||
throw new IllegalArgumentException("dialogWidth can't be 0");
|
||||
}
|
||||
if (dialogHeight == 0) {
|
||||
throw new IllegalArgumentException("dialogHeight can't be 0");
|
||||
}
|
||||
|
||||
int width = Math.max(screenWidth, dialogWidth);
|
||||
int height = Math.max(screenHeight, dialogHeight);
|
||||
|
||||
int x = ((width - dialogWidth) / 2);
|
||||
int y = ((height - dialogHeight) / 2);
|
||||
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
private int screenWidth;
|
||||
private int screenHeight;
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue