mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Fix so music is properly paused when minimized
Fix so music isn't paused when dialog opened
This commit is contained in:
@@ -27,7 +27,7 @@ public class FFrame extends SkinnedFrame implements ITitleBarOwner {
|
|||||||
private boolean moveInProgress;
|
private boolean moveInProgress;
|
||||||
private int resizeCursor;
|
private int resizeCursor;
|
||||||
private FTitleBarBase titleBar;
|
private FTitleBarBase titleBar;
|
||||||
private boolean minimized, maximized, fullScreen, hideBorder, lockTitleBar, hideTitleBar, isMainFrame;
|
private boolean minimized, maximized, fullScreen, hideBorder, lockTitleBar, hideTitleBar, isMainFrame, paused;
|
||||||
private Rectangle normalBounds;
|
private Rectangle normalBounds;
|
||||||
|
|
||||||
public FFrame() {
|
public FFrame() {
|
||||||
@@ -49,26 +49,24 @@ public class FFrame extends SkinnedFrame implements ITitleBarOwner {
|
|||||||
this.addWindowListener(new WindowAdapter() {
|
this.addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowActivated(WindowEvent e) {
|
public void windowActivated(WindowEvent e) {
|
||||||
if (isMainFrame) { //resume music when main frame regains focus
|
resume(); //resume music when main frame regains focus
|
||||||
Singletons.getControl().getSoundSystem().resume();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowDeactivated(WindowEvent arg0) {
|
public void windowDeactivated(WindowEvent e) {
|
||||||
if (isMainFrame) { //pause music when main frame loses focus
|
if (e.getOppositeWindow() == null) {
|
||||||
Singletons.getControl().getSoundSystem().pause();
|
pause(); //pause music when main frame loses focus to outside application
|
||||||
}
|
|
||||||
|
|
||||||
if (fullScreen && arg0.getOppositeWindow() == null) {
|
if (fullScreen) {
|
||||||
setMinimized(true); //minimize if switching from Full Screen Forge to outside application window
|
setMinimized(true); //minimize if switching from Full Screen Forge to outside application window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.addWindowStateListener(new WindowStateListener() {
|
this.addWindowStateListener(new WindowStateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void windowStateChanged(WindowEvent arg0) {
|
public void windowStateChanged(WindowEvent e) {
|
||||||
setState(arg0.getNewState());
|
setState(e.getNewState());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -77,6 +75,20 @@ public class FFrame extends SkinnedFrame implements ITitleBarOwner {
|
|||||||
addMoveSupport();
|
addMoveSupport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void pause() {
|
||||||
|
if (paused || !isMainFrame) { return; }
|
||||||
|
|
||||||
|
Singletons.getControl().getSoundSystem().pause();
|
||||||
|
paused = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resume() {
|
||||||
|
if (!paused || !isMainFrame) { return; }
|
||||||
|
|
||||||
|
Singletons.getControl().getSoundSystem().resume();
|
||||||
|
paused = false;
|
||||||
|
}
|
||||||
|
|
||||||
public FTitleBarBase getTitleBar() {
|
public FTitleBarBase getTitleBar() {
|
||||||
return this.titleBar;
|
return this.titleBar;
|
||||||
}
|
}
|
||||||
@@ -188,6 +200,14 @@ public class FFrame extends SkinnedFrame implements ITitleBarOwner {
|
|||||||
if (this.minimized == minimized0) { return; }
|
if (this.minimized == minimized0) { return; }
|
||||||
this.minimized = minimized0;
|
this.minimized = minimized0;
|
||||||
updateState();
|
updateState();
|
||||||
|
|
||||||
|
//pause or resume when minimized changes
|
||||||
|
if (minimized0) {
|
||||||
|
pause();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resume();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMaximized() {
|
public boolean isMaximized() {
|
||||||
|
|||||||
Reference in New Issue
Block a user