From 5f515133c323b20f9960a032bec3599280983145 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 4 Jun 2003 02:50:19 +0000 Subject: [PATCH] Chat revamp, phase 2. - FeedbackMessage has been subsumed into SystemMessage, which now has three modes: INFO, FEEDBACK, or ATTENTION. - Cleaned up methods for sending those system messages. - on the server: sendInfo(), sendFeedback(), sendAttention() - on the client: displayInfo(), displayFeedback(), displayAttention(). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2635 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../crowd/chat/client/ChatDirector.java | 106 +++++++++--------- .../crowd/chat/client/MuteDirector.java | 6 +- .../crowd/chat/data/FeedbackMessage.java | 23 ---- .../crowd/chat/data/SystemMessage.java | 22 +++- .../crowd/chat/data/TellFeedbackMessage.java | 4 +- .../crowd/chat/server/SpeakProvider.java | 62 +++++++++- .../threerings/micasa/client/ChatPanel.java | 6 +- .../threerings/parlor/game/GameManager.java | 4 +- 8 files changed, 142 insertions(+), 91 deletions(-) delete mode 100644 src/java/com/threerings/crowd/chat/data/FeedbackMessage.java diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java index 5d7094e26..c39dfbbb0 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDirector.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDirector.java @@ -1,5 +1,5 @@ // -// $Id: ChatDirector.java,v 1.45 2003/06/03 23:36:18 ray Exp $ +// $Id: ChatDirector.java,v 1.46 2003/06/04 02:50:18 ray Exp $ package com.threerings.crowd.chat.client; @@ -28,7 +28,6 @@ import com.threerings.crowd.util.CrowdContext; import com.threerings.crowd.chat.data.ChatCodes; import com.threerings.crowd.chat.data.ChatMessage; -import com.threerings.crowd.chat.data.FeedbackMessage; import com.threerings.crowd.chat.data.SystemMessage; import com.threerings.crowd.chat.data.TellFeedbackMessage; import com.threerings.crowd.chat.data.UserMessage; @@ -209,64 +208,69 @@ public class ChatDirector extends BasicDirector } }); } - + /** - * Requests that the specified system message be dispatched to all - * registered chat displays. The message will be delivered as if it - * were received on the main chat object (meaning the chat type will - * be {@link ChatCodes#PLACE_CHAT_TYPE}). + * Display a system INFO message as if it had come from the server. + * The localtype of the message will be PLACE_CHAT_TYPE. * - * @param bundle the message bundle identifier that should be used to - * localize this message. - * @param message the localizable message string. + * Info messages are sent when something happens that was neither + * directly triggered by the user, nor requires direct action. */ - public void displaySystemMessage (String bundle, String message) + public void displayInfo (String bundle, String message) { - displaySystemMessage(bundle, message, PLACE_CHAT_TYPE); + displaySystem(bundle, message, SystemMessage.INFO, PLACE_CHAT_TYPE); } /** - * Requests that the specified system message be dispatched to all - * registered chat displays. + * Display a system INFO message as if it had come from the server. * - * @param bundle the message bundle identifier that should be used to - * localize this message. - * @param message the localizable message string. - * @param localtype {@link ChatCodes#PLACE_CHAT_TYPE} if the message was - * received on the place object or the type associated with the - * auxiliary chat object on which the message was received. + * Info messages are sent when something happens that was neither + * directly triggered by the user, nor requires direct action. */ - public void displaySystemMessage ( - String bundle, String message, String localtype) + public void displayInfo (String bundle, String message, String localtype) { + displaySystem(bundle, message, SystemMessage.INFO, localtype); + } + + /** + * Display a system FEEDBACK message as if it had come from the server. + * The localtype of the message will be PLACE_CHAT_TYPE. + * + * Feedback messages are sent in direct response to a user action, + * usually to indicate success or failure of the user's action. + */ + public void displayFeedback (String bundle, String message) + { + displaySystem( + bundle, message, SystemMessage.FEEDBACK, PLACE_CHAT_TYPE); + } + + /** + * Display a system ATTENTION message as if it had come from the server. + * The localtype of the message will be PLACE_CHAT_TYPE. + * + * Attention messages are sent when something requires user action + * that did not result from direct action by the user. + */ + public void displayAttention (String bundle, String message) + { + displaySystem( + bundle, message, SystemMessage.ATTENTION, PLACE_CHAT_TYPE); + } + + /** + * Display the specified system message as if it had come from the server. + */ + protected void displaySystem ( + String bundle, String message, byte attLevel, String localtype) + { + // nothing should be untranslated, so pass the default bundle if need + // be. + if (bundle == null) { + bundle = _bundle; + } SystemMessage msg = new SystemMessage(); - msg.setClientInfo(xlate(bundle, message), localtype); - dispatchMessage(msg); - } - - /** - * Displays a feedback message translated with the default bundle. - */ - public void displayFeedbackMessage (String message) - { - displayFeedbackMessage(_bundle, message); - } - - /** - * Displays a feedback message. - */ - public void displayFeedbackMessage (String bundle, String message) - { - displayFeedbackMessage(bundle, message, PLACE_CHAT_TYPE); - } - - /** - * Displays a feedback message. - */ - public void displayFeedbackMessage (String bundle, String message, - String localtype) - { - FeedbackMessage msg = new FeedbackMessage(); + msg.attentionLevel = attLevel; msg.setClientInfo(xlate(bundle, message), localtype); dispatchMessage(msg); } @@ -333,7 +337,7 @@ public class ChatDirector extends BasicDirector _cservice.broadcast( _ctx.getClient(), message, new ChatService.InvocationListener() { public void requestFailed (String reason) { - displayFeedbackMessage( + displayFeedback( _bundle, MessageBundle.compose( "m.broadcast_failed", reason)); } @@ -388,7 +392,7 @@ public class ChatDirector extends BasicDirector public void requestFailed (String reason) { String msg = MessageBundle.compose( "m.tell_failed", MessageBundle.taint(target), reason); - displayFeedbackMessage(_bundle, msg); + displayFeedback(_bundle, msg); if (rl != null) { rl.requestFailed(null); } diff --git a/src/java/com/threerings/crowd/chat/client/MuteDirector.java b/src/java/com/threerings/crowd/chat/client/MuteDirector.java index b709a16ed..31632c04f 100644 --- a/src/java/com/threerings/crowd/chat/client/MuteDirector.java +++ b/src/java/com/threerings/crowd/chat/client/MuteDirector.java @@ -1,5 +1,5 @@ // -// $Id: MuteDirector.java,v 1.8 2003/06/03 21:41:33 ray Exp $ +// $Id: MuteDirector.java,v 1.9 2003/06/04 02:50:18 ray Exp $ package com.threerings.crowd.chat.client; @@ -96,7 +96,7 @@ public class MuteDirector extends BasicDirector public void setMuted (String username, boolean mute) { if (mute ? _mutelist.add(username) : _mutelist.remove(username)) { - _chatdir.displayFeedbackMessage(MessageBundle.tcompose( + _chatdir.displayFeedback(null, MessageBundle.tcompose( mute ? "m.muted" : "m.unmuted", username)); notifyObservers(username, mute); } @@ -123,7 +123,7 @@ public class MuteDirector extends BasicDirector public boolean validateTell (String target, String msg) { if (isMuted(target)) { - _chatdir.displayFeedbackMessage("m.no_tell_mute"); + _chatdir.displayFeedback(null, "m.no_tell_mute"); return false; } diff --git a/src/java/com/threerings/crowd/chat/data/FeedbackMessage.java b/src/java/com/threerings/crowd/chat/data/FeedbackMessage.java deleted file mode 100644 index 3b3643910..000000000 --- a/src/java/com/threerings/crowd/chat/data/FeedbackMessage.java +++ /dev/null @@ -1,23 +0,0 @@ -// -// $Id: FeedbackMessage.java,v 1.2 2003/06/03 21:41:33 ray Exp $ - -package com.threerings.crowd.chat.data; - -/** - * A ChatMessage to indicate to the user that an action they took - * has been processed. - */ -public class FeedbackMessage extends ChatMessage -{ - public FeedbackMessage () - { - } - - /** - * Construct a FeedbackMessage. - */ - public FeedbackMessage (String message, String localtype) - { - super(message, localtype); - } -} diff --git a/src/java/com/threerings/crowd/chat/data/SystemMessage.java b/src/java/com/threerings/crowd/chat/data/SystemMessage.java index 79b132128..54a2bf489 100644 --- a/src/java/com/threerings/crowd/chat/data/SystemMessage.java +++ b/src/java/com/threerings/crowd/chat/data/SystemMessage.java @@ -1,5 +1,5 @@ // -// $Id: SystemMessage.java,v 1.2 2003/06/03 21:41:33 ray Exp $ +// $Id: SystemMessage.java,v 1.3 2003/06/04 02:50:18 ray Exp $ package com.threerings.crowd.chat.data; @@ -9,6 +9,23 @@ package com.threerings.crowd.chat.data; */ public class SystemMessage extends ChatMessage { + /** Attention level constant to indicate that this message is merely + * providing the user with information. */ + public static final byte INFO = 0; + + /** Attention level constant to indicate that this message is the + * result of a user action. */ + public static final byte FEEDBACK = 1; + + /** Attention level constant to indicate that some action is required. */ + public static final byte ATTENTION = 2; + + //---- + + /** The attention level of this message. */ + public byte attentionLevel; + + // documentation inherited public SystemMessage () { } @@ -16,8 +33,9 @@ public class SystemMessage extends ChatMessage /** * Construct a SystemMessage. */ - public SystemMessage (String message, String bundle) + public SystemMessage (String message, String bundle, byte attentionLevel) { super(message, bundle); + this.attentionLevel = attentionLevel; } } diff --git a/src/java/com/threerings/crowd/chat/data/TellFeedbackMessage.java b/src/java/com/threerings/crowd/chat/data/TellFeedbackMessage.java index d829eb12b..3ab7eda5a 100644 --- a/src/java/com/threerings/crowd/chat/data/TellFeedbackMessage.java +++ b/src/java/com/threerings/crowd/chat/data/TellFeedbackMessage.java @@ -1,12 +1,12 @@ // -// $Id: TellFeedbackMessage.java,v 1.1 2003/06/03 23:46:10 ray Exp $ +// $Id: TellFeedbackMessage.java,v 1.2 2003/06/04 02:50:18 ray Exp $ package com.threerings.crowd.chat.data; /** * A feedback message to indicate that a tell succeeded. */ -public class TellFeedbackMessage extends FeedbackMessage +public class TellFeedbackMessage extends ChatMessage { /** * A tell feedback message is only composed on the client. diff --git a/src/java/com/threerings/crowd/chat/server/SpeakProvider.java b/src/java/com/threerings/crowd/chat/server/SpeakProvider.java index e6179ad5a..1c6e61fc3 100644 --- a/src/java/com/threerings/crowd/chat/server/SpeakProvider.java +++ b/src/java/com/threerings/crowd/chat/server/SpeakProvider.java @@ -1,5 +1,5 @@ // -// $Id: SpeakProvider.java,v 1.5 2003/06/03 21:41:33 ray Exp $ +// $Id: SpeakProvider.java,v 1.6 2003/06/04 02:50:18 ray Exp $ package com.threerings.crowd.chat.server; @@ -125,21 +125,75 @@ public class SpeakProvider } /** - * Sends a system message notification to the specified object with + * Sends a system INFO message notification to the specified object with * the supplied message content. A system message is one that will be * rendered where the speak messages are rendered, but in a way that * makes it clear that it is a message from the server. * + * Info messages are sent when something happens that was neither + * directly triggered by the user, nor requires direct action. + * * @param speakObj the object on which to deliver the message. * @param bundle the name of the localization bundle that should be * used to translate this system message prior to displaying it to the * client. * @param message the text of the message. */ - public static void sendSystemSpeak ( + public static void sendInfo ( DObject speakObj, String bundle, String message) { - sendMessage(speakObj, new SystemMessage(message, bundle)); + sendSystem(speakObj, bundle, message, SystemMessage.INFO); + } + + /** + * Sends a system FEEDBACK message notification to the specified + * object with the supplied message content. A system message is one + * that will be rendered where the speak messages are rendered, + * but in a way that makes it clear that it is a message from the server. + * + * Feedback messages are sent in direct response to a user action, + * usually to indicate success or failure of the user's action. + * + * @param speakObj the object on which to deliver the message. + * @param bundle the name of the localization bundle that should be + * used to translate this system message prior to displaying it to the + * client. + * @param message the text of the message. + */ + public static void sendFeedback ( + DObject speakObj, String bundle, String message) + { + sendSystem(speakObj, bundle, message, SystemMessage.FEEDBACK); + } + + /** + * Sends a system ATTENTION message notification to the specified + * object with the supplied message content. A system message is one + * that will be rendered where the speak messages are rendered, + * but in a way that makes it clear that it is a message from the server. + * + * Attention messages are sent when something requires user action + * that did not result from direct action by the user. + * + * @param speakObj the object on which to deliver the message. + * @param bundle the name of the localization bundle that should be + * used to translate this system message prior to displaying it to the + * client. + * @param message the text of the message. + */ + public static void sendAttention ( + DObject speakObj, String bundle, String message) + { + sendSystem(speakObj, bundle, message, SystemMessage.ATTENTION); + } + + /** + * Send the specified system message on the specified dobj. + */ + protected static void sendSystem ( + DObject speakObj, String bundle, String message, byte attLevel) + { + sendMessage(speakObj, new SystemMessage(message, bundle, attLevel)); } /** diff --git a/src/java/com/threerings/micasa/client/ChatPanel.java b/src/java/com/threerings/micasa/client/ChatPanel.java index 08ec2fd98..4c6bd4140 100644 --- a/src/java/com/threerings/micasa/client/ChatPanel.java +++ b/src/java/com/threerings/micasa/client/ChatPanel.java @@ -1,5 +1,5 @@ // -// $Id: ChatPanel.java,v 1.24 2003/06/03 23:36:18 ray Exp $ +// $Id: ChatPanel.java,v 1.25 2003/06/04 02:50:19 ray Exp $ package com.threerings.micasa.client; @@ -38,7 +38,6 @@ import com.threerings.crowd.chat.client.ChatDirector; import com.threerings.crowd.chat.client.ChatDisplay; import com.threerings.crowd.chat.data.ChatCodes; import com.threerings.crowd.chat.data.ChatMessage; -import com.threerings.crowd.chat.data.FeedbackMessage; import com.threerings.crowd.chat.data.SystemMessage; import com.threerings.crowd.chat.data.UserMessage; @@ -240,8 +239,7 @@ public class ChatPanel append(msg.message + "\n", _msgStyle); } - } else if ((message instanceof SystemMessage) || - (message instanceof FeedbackMessage)) { + } else if (message instanceof SystemMessage) { append(message.message + "\n", _noticeStyle); } else { diff --git a/src/java/com/threerings/parlor/game/GameManager.java b/src/java/com/threerings/parlor/game/GameManager.java index 112e361e9..013eaed9c 100644 --- a/src/java/com/threerings/parlor/game/GameManager.java +++ b/src/java/com/threerings/parlor/game/GameManager.java @@ -1,5 +1,5 @@ // -// $Id: GameManager.java,v 1.64 2003/06/03 21:41:33 ray Exp $ +// $Id: GameManager.java,v 1.65 2003/06/04 02:50:19 ray Exp $ package com.threerings.parlor.game; @@ -344,7 +344,7 @@ public class GameManager extends PlaceManager } // otherwise, just deliver the message - SpeakProvider.sendSystemSpeak(_gameobj, msgbundle, msg); + SpeakProvider.sendInfo(_gameobj, msgbundle, msg); } // documentation inherited