From 20d1e1d024c1303a1c9047a74a27310f10e0fd53 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 10 Oct 2006 21:48:27 +0000 Subject: [PATCH] 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 --- .../crowd/chat/client/ChatDirector.java | 26 ++++++++++++++----- .../crowd/chat/client/ChatDisplay.java | 7 +++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java index 9007de21b..1c80d2c39 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDirector.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDirector.java @@ -169,8 +169,18 @@ public class ChatDirector extends BasicDirector } /** - * Adds the supplied chat display to the chat display list. It will - * subsequently be notified of incoming chat messages as well as tell + * Adds the supplied chat display to the front of the chat display list. It + * 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. */ public void addChatDisplay (ChatDisplay display) @@ -1088,15 +1098,19 @@ public class ChatDirector extends BasicDirector public void setMessage (ChatMessage message) { _message = message; + _displayed = false; } public boolean apply (ChatDisplay observer) { - observer.displayMessage(_message); + if (observer.displayMessage(_message, _displayed)) { + _displayed = true; + } return true; } protected ChatMessage _message; + protected boolean _displayed; } /** Implements /help. */ @@ -1388,11 +1402,11 @@ public class ChatDirector extends BasicDirector /** A list of registered chat displays. */ protected ObserverList _displays = - new ObserverList(ObserverList.FAST_UNSAFE_NOTIFY); + new ObserverList(ObserverList.SAFE_IN_ORDER_NOTIFY); /** A list of registered chat filters. */ protected ObserverList _filters = - new ObserverList(ObserverList.FAST_UNSAFE_NOTIFY); + new ObserverList(ObserverList.SAFE_IN_ORDER_NOTIFY); /** A mapping from auxiliary chat objects to the types under which * they are registered. */ @@ -1406,7 +1420,7 @@ public class ChatDirector extends BasicDirector /** Observers that are watching our chatters list. */ protected ObserverList _chatterObservers = - new ObserverList(ObserverList.FAST_UNSAFE_NOTIFY); + new ObserverList(ObserverList.SAFE_IN_ORDER_NOTIFY); /** Registered chat command handlers. */ protected static HashMap _handlers = diff --git a/src/java/com/threerings/crowd/chat/client/ChatDisplay.java b/src/java/com/threerings/crowd/chat/client/ChatDisplay.java index 5a91a1870..22d86f6f3 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDisplay.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDisplay.java @@ -38,7 +38,10 @@ public interface ChatDisplay /** * 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); }