Allow chat displays to register themselves in a known order and to report to

one another whether they've already displayed a chat message.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4421 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-10-10 21:48:27 +00:00
parent 3c385628a1
commit 20d1e1d024
2 changed files with 25 additions and 8 deletions
@@ -169,8 +169,18 @@ public class ChatDirector extends BasicDirector
} }
/** /**
* Adds the supplied chat display to the chat display list. It will * Adds the supplied chat display to the front of the chat display list. It
* subsequently be notified of incoming chat messages as well as tell * will subsequently be notified of incoming chat messages as well as tell
* responses.
*/
public void pushChatDisplay (ChatDisplay display)
{
_displays.add(0, display);
}
/**
* Adds the supplied chat display to the end of the chat display list. It
* will subsequently be notified of incoming chat messages as well as tell
* responses. * responses.
*/ */
public void addChatDisplay (ChatDisplay display) public void addChatDisplay (ChatDisplay display)
@@ -1088,15 +1098,19 @@ public class ChatDirector extends BasicDirector
public void setMessage (ChatMessage message) public void setMessage (ChatMessage message)
{ {
_message = message; _message = message;
_displayed = false;
} }
public boolean apply (ChatDisplay observer) public boolean apply (ChatDisplay observer)
{ {
observer.displayMessage(_message); if (observer.displayMessage(_message, _displayed)) {
_displayed = true;
}
return true; return true;
} }
protected ChatMessage _message; protected ChatMessage _message;
protected boolean _displayed;
} }
/** Implements <code>/help</code>. */ /** Implements <code>/help</code>. */
@@ -1388,11 +1402,11 @@ public class ChatDirector extends BasicDirector
/** A list of registered chat displays. */ /** A list of registered chat displays. */
protected ObserverList<ChatDisplay> _displays = protected ObserverList<ChatDisplay> _displays =
new ObserverList<ChatDisplay>(ObserverList.FAST_UNSAFE_NOTIFY); new ObserverList<ChatDisplay>(ObserverList.SAFE_IN_ORDER_NOTIFY);
/** A list of registered chat filters. */ /** A list of registered chat filters. */
protected ObserverList<ChatFilter> _filters = protected ObserverList<ChatFilter> _filters =
new ObserverList<ChatFilter>(ObserverList.FAST_UNSAFE_NOTIFY); new ObserverList<ChatFilter>(ObserverList.SAFE_IN_ORDER_NOTIFY);
/** A mapping from auxiliary chat objects to the types under which /** A mapping from auxiliary chat objects to the types under which
* they are registered. */ * they are registered. */
@@ -1406,7 +1420,7 @@ public class ChatDirector extends BasicDirector
/** Observers that are watching our chatters list. */ /** Observers that are watching our chatters list. */
protected ObserverList<ChatterObserver> _chatterObservers = protected ObserverList<ChatterObserver> _chatterObservers =
new ObserverList<ChatterObserver>(ObserverList.FAST_UNSAFE_NOTIFY); new ObserverList<ChatterObserver>(ObserverList.SAFE_IN_ORDER_NOTIFY);
/** Registered chat command handlers. */ /** Registered chat command handlers. */
protected static HashMap<String,CommandHandler> _handlers = protected static HashMap<String,CommandHandler> _handlers =
@@ -38,7 +38,10 @@ public interface ChatDisplay
/** /**
* Called to display a chat message. * Called to display a chat message.
* *
* @see ChatMessage * @param alreadyDisplayed true if a previous chat display in the list has
* already displayed this message, false otherwise.
*
* @return true if the message was displayed, false if not.
*/ */
public void displayMessage (ChatMessage msg); public boolean displayMessage (ChatMessage msg, boolean alreadyDisplayed);
} }