summaryrefslogtreecommitdiffstats
path: root/src/jrummikub
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub')
-rw-r--r--src/jrummikub/control/ApplicationControl.java53
-rw-r--r--src/jrummikub/view/impl/QuitWarningPanel.java2
-rw-r--r--src/jrummikub/view/impl/View.java37
3 files changed, 55 insertions, 37 deletions
diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java
index f4e5a23..0e62ed9 100644
--- a/src/jrummikub/control/ApplicationControl.java
+++ b/src/jrummikub/control/ApplicationControl.java
@@ -32,7 +32,7 @@ public class ApplicationControl {
* Creates a new application control
*
* @param view
- * the view to use
+ * the view to use
*/
public ApplicationControl(final IView view) {
this.view = view;
@@ -51,11 +51,12 @@ public class ApplicationControl {
startApplication();
view.showQuitWarningPanel(false);
tempConnection.remove();
+ tempConnection = null;
}
});
}
});
- view.getMenuQuitEvent().add(new IListener() {
+ IListener quitListener = new IListener() {
@Override
public void handle() {
if (gameControl == null) {
@@ -63,38 +64,28 @@ public class ApplicationControl {
} else {
view.getQuitWarningPanel().setMode(QuitMode.QUIT_PROCESS);
view.showQuitWarningPanel(true);
- view.getQuitWarningPanel().getQuitEvent().add(new IListener() {
- @Override
- public void handle() {
- System.exit(0);
- }
- });
+ tempConnection = view.getQuitWarningPanel().getQuitEvent()
+ .add(new IListener() {
+ @Override
+ public void handle() {
+ System.exit(0);
+ }
+ });
}
}
- });
+ };
+ view.getMenuQuitEvent().add(quitListener);
- view.getQuitEvent().add(new IListener() {
- @Override
- public void handle() {
- if (gameControl == null) {
- System.exit(0);
- } else {
- view.getQuitWarningPanel().setMode(QuitMode.QUIT_PROCESS);
- view.showQuitWarningPanel(true);
- view.getQuitWarningPanel().getQuitEvent().add(new IListener() {
- @Override
- public void handle() {
- System.exit(0);
- }
- });
- }
- }
- });
+ view.getQuitEvent().add(quitListener);
view.getQuitWarningPanel().getCancelEvent().add(new IListener() {
@Override
public void handle() {
view.showQuitWarningPanel(false);
+ if (tempConnection != null) {
+ tempConnection.remove();
+ tempConnection = null;
+ }
}
});
@@ -110,10 +101,11 @@ public class ApplicationControl {
saveControl.getLoadEvent().add(
new IListener3<GameSettings, GameState, IRoundState>() {
@Override
- public void handle(GameSettings settings, GameState gameState,
- IRoundState roundState) {
+ public void handle(GameSettings settings,
+ GameState gameState, IRoundState roundState) {
abortControls();
- gameControl = new GameControl(settings, saveControl, view);
+ gameControl = new GameControl(settings, saveControl,
+ view);
addGameControlListeners(gameControl);
gameControl.continueGame(gameState, roundState);
}
@@ -206,7 +198,8 @@ public class ApplicationControl {
private void createNetworkControl(LoginData loginData) {
ConnectionControl connectionControl = new ConnectionControl(loginData);
- networkControl = new NetworkControl(loginData, connectionControl, saveControl, view);
+ networkControl = new NetworkControl(loginData, connectionControl,
+ saveControl, view);
networkControl.getStopNetworkEvent().add(new IListener() {
@Override
diff --git a/src/jrummikub/view/impl/QuitWarningPanel.java b/src/jrummikub/view/impl/QuitWarningPanel.java
index f00ef8a..ce4f560 100644
--- a/src/jrummikub/view/impl/QuitWarningPanel.java
+++ b/src/jrummikub/view/impl/QuitWarningPanel.java
@@ -51,7 +51,7 @@ public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
c.gridy = 1;
c.gridwidth = 1;
- quitButton = createButton("Beenden", quitEvent);
+ quitButton = createButton("Fortfahren", quitEvent);
cancelButton = createButton("Abbrechen", cancelEvent);
add(cancelButton, c);
c.gridx = 1;
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index 5cc1a85..a9dc46f 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -86,6 +86,7 @@ public class View extends JFrame implements IView {
private Event1<File> loadFileEvent = new Event1<File>();
private Event1<File> saveEvent = new Event1<File>();
private Event quitEvent = new Event();
+ private JFrame quitWarningFrame;
private static int even(double d) {
return 2 * (int) (d / 2);
@@ -296,7 +297,9 @@ public class View extends JFrame implements IView {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
- quitEvent.emit();
+ if (isEnabled()) {
+ quitEvent.emit();
+ }
}
});
@@ -318,6 +321,10 @@ public class View extends JFrame implements IView {
public void componentResized(ComponentEvent e) {
rescale();
}
+ @Override
+ public void componentMoved(ComponentEvent e) {
+ quitWarningFrame.setLocationRelativeTo(View.this);
+ }
});
setVisible(true);
@@ -343,10 +350,15 @@ public class View extends JFrame implements IView {
layeredPane.add(connectPanel);
quitWarningPanel = new QuitWarningPanel();
- quitWarningPanel.setVisible(false);
- layeredPane.setLayer(quitWarningPanel, JLayeredPane.POPUP_LAYER);
- layeredPane.add(quitWarningPanel);
-
+ quitWarningFrame = new JFrame();
+ quitWarningFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
+ quitWarningFrame.add(quitWarningPanel);
+ quitWarningFrame.setAlwaysOnTop(true);
+ quitWarningFrame.setUndecorated(true);
+
+ //layeredPane.setLayer(quitWarningPanel, JLayeredPane.POPUP_LAYER);
+ //layeredPane.add(quitWarningPanel);
+ //quitWarningPanel.setVisible(true);
scorePanel = new ScorePanel();
scorePanel.setVisible(false);
layeredPane.setLayer(scorePanel, JLayeredPane.POPUP_LAYER);
@@ -446,6 +458,9 @@ public class View extends JFrame implements IView {
rescaleSubpanel(loginPanel, 1 / 3.0, 1 / 3.0, 200, 200);
rescaleSubpanel(gameListPanel, 1 / 2.0, 1 / 2.0, 475, 300);
rescaleSubpanel(quitWarningPanel, 1 / 2.0, 1 / 6.0, 400, 150);
+ quitWarningPanel.setLocation(0, 0);
+ quitWarningFrame.setSize(quitWarningPanel.getSize());
+ quitWarningFrame.setLocationRelativeTo(this);
rescaleSubpanel(connectPanel, 1 / 2.0, 1 / 6.0, 400, 150);
}
@@ -508,7 +523,17 @@ public class View extends JFrame implements IView {
}
public void showQuitWarningPanel(boolean show) {
- quitWarningPanel.setVisible(show);
+ quitWarningFrame.setLocationRelativeTo(this);
+ quitWarningFrame.setVisible(show);
+
+ setEnabled(!show);
+ /*mainLayer.setEnabled(!show);
+ menuBar.setEnabled(!show);
+ settingsPanel.setEnabled(!show);
+ loginPanel.setEnabled(!show);
+ scorePanel.setEnabled(!show);
+ gameListPanel.setEnabled(!show);
+ connectPanel.setEnabled(!show);*/
}
@Override