Fixed pause-related bug. Lord forgive me for mucking about in here so much,
but now I've cleaned up the code that dicks with mouse listeners while paused and moved it into an inner class so that it's easier to understand. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3002 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: PuzzleController.java,v 1.8 2004/04/30 00:02:21 ray Exp $
|
// $Id: PuzzleController.java,v 1.9 2004/05/05 02:38:22 ray Exp $
|
||||||
|
|
||||||
package com.threerings.puzzle.client;
|
package com.threerings.puzzle.client;
|
||||||
|
|
||||||
@@ -10,7 +10,6 @@ import java.awt.event.KeyListener;
|
|||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -155,27 +154,16 @@ public abstract class PuzzleController extends GameController
|
|||||||
|
|
||||||
// if we're moving focus to chat..
|
// if we're moving focus to chat..
|
||||||
if (chatting) {
|
if (chatting) {
|
||||||
// don't let mouse clicks land on the board
|
if (_unpauser != null) {
|
||||||
final MouseHijacker jack = new MouseHijacker(_panel.getBoardView());
|
Log.warning("Huh? Already have a mouse unpauser?");
|
||||||
|
_unpauser.release();
|
||||||
// ...enable "click to unchat" mode in the puzzle board view
|
}
|
||||||
MouseAdapter unpauser = new MouseAdapter() {
|
_unpauser = new Unpauser(_panel);
|
||||||
public void mousePressed (MouseEvent event) {
|
|
||||||
_panel.removeMouseListener(this);
|
|
||||||
_panel.getBoardView().removeMouseListener(this);
|
|
||||||
jack.release();
|
|
||||||
setChatting(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
_panel.addMouseListener(unpauser);
|
|
||||||
_panel.getBoardView().addMouseListener(unpauser);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// if we were unpaused with a key event, blow away the hijacker
|
if (_unpauser != null) {
|
||||||
// business
|
_unpauser.release();
|
||||||
MouseListener[] mousers = _panel.getMouseListeners();
|
_unpauser = null;
|
||||||
if (mousers.length == 1) {
|
|
||||||
mousers[0].mousePressed(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,6 +880,39 @@ public abstract class PuzzleController extends GameController
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Catches clicks an unpauses, without passing the click through
|
||||||
|
* to the puzzle.
|
||||||
|
*/
|
||||||
|
class Unpauser extends MouseHijacker
|
||||||
|
{
|
||||||
|
public Unpauser (PuzzlePanel panel)
|
||||||
|
{
|
||||||
|
super(panel.getBoardView());
|
||||||
|
_panel = panel;
|
||||||
|
panel.addMouseListener(_clicker);
|
||||||
|
panel.getBoardView().addMouseListener(_clicker);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component release ()
|
||||||
|
{
|
||||||
|
_panel.removeMouseListener(_clicker);
|
||||||
|
_panel.getBoardView().removeMouseListener(_clicker);
|
||||||
|
return super.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MouseAdapter _clicker = new MouseAdapter() {
|
||||||
|
public void mousePressed (MouseEvent event) {
|
||||||
|
setChatting(false); // this will call release
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
protected PuzzlePanel _panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The mouse jockey for unpausing our puzzles. */
|
||||||
|
protected Unpauser _unpauser;
|
||||||
|
|
||||||
/** Handles the sending of puzzle progress updates. We can't just
|
/** Handles the sending of puzzle progress updates. We can't just
|
||||||
* register an interval for this because sometimes the clock goes
|
* register an interval for this because sometimes the clock goes
|
||||||
* backwards in time in windows and our intervals don't get called for
|
* backwards in time in windows and our intervals don't get called for
|
||||||
|
|||||||
Reference in New Issue
Block a user