mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
[UI] Param for starting in fullscreen mode (osx only)
This commit is contained in:
parent
0e2255f71f
commit
eb6dc10faa
2 changed files with 27 additions and 0 deletions
|
@ -104,6 +104,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
private static final Logger logger = Logger.getLogger(MageFrame.class);
|
||||
private static final String liteModeArg = "-lite";
|
||||
private static final String grayModeArg = "-gray";
|
||||
private static final String fullscreenArg = "-fullscreen";
|
||||
|
||||
private static MageFrame instance;
|
||||
|
||||
|
@ -120,6 +121,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
private static boolean liteMode = false;
|
||||
//TODO: make gray theme, implement theme selector in preferences dialog
|
||||
private static boolean grayMode = false;
|
||||
private static boolean fullscreenMode = false;
|
||||
|
||||
private static final Map<UUID, ChatPanel> chats = new HashMap<>();
|
||||
private static final Map<UUID, GamePanel> games = new HashMap<>();
|
||||
|
@ -317,6 +319,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
|
||||
if (SystemUtil.isMacOSX()) {
|
||||
SystemUtil.enableMacOSFullScreenMode(this);
|
||||
if (fullscreenMode) {
|
||||
SystemUtil.toggleMacOSFullScreenMode(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1103,6 +1108,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
if (arg.startsWith(grayModeArg)) {
|
||||
grayMode = true;
|
||||
}
|
||||
if (arg.startsWith(fullscreenArg)) {
|
||||
fullscreenMode = true;
|
||||
}
|
||||
}
|
||||
if (!liteMode) {
|
||||
final SplashScreen splash = SplashScreen.getSplashScreen();
|
||||
|
|
|
@ -32,6 +32,25 @@ public class SystemUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static void toggleMacOSFullScreenMode(Window window) {
|
||||
String className = "com.apple.eawt.Application";
|
||||
String methodName = "getApplication";
|
||||
String methodName2 = "requestToggleFullScreen";
|
||||
|
||||
try {
|
||||
Class<?> clazz = Class.forName(className);
|
||||
Method method = clazz.getMethod(methodName);
|
||||
Object appInstance = method.invoke(clazz);
|
||||
|
||||
Class params[] = new Class[]{Window.class};
|
||||
method = clazz.getMethod(methodName2, params);
|
||||
method.invoke(appInstance, window);
|
||||
} catch (Throwable t) {
|
||||
System.err.println("Full screen mode is not supported");
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String... args) {
|
||||
System.out.println(isMacOSX());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue