diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java index 7a1c2fdb0..09a1938f0 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.25 2002/07/17 20:53:31 shaper Exp $ +// $Id: ChatDirector.java,v 1.26 2002/07/22 22:26:26 ray Exp $ package com.threerings.crowd.chat; @@ -351,21 +351,24 @@ public class ChatDirector } String bundle = null; - String message = null; + String message, mode; // determine whether this speak message originated from another // client or from a server entity - if (args.length == 2) { + if (args.length == 3) { message = (String)args[1]; + mode = (String) args[2]; + } else { bundle = (String)args[1]; message = (String)args[2]; + mode = (String) args[3]; } // pass this on to our chat displays for (int i = 0; i < _displays.size(); i++) { ChatDisplay display = (ChatDisplay)_displays.get(i); - display.displaySpeakMessage(type, speaker, bundle, message); + display.displaySpeakMessage(type, speaker, bundle, message, mode); } } diff --git a/src/java/com/threerings/crowd/chat/client/ChatDisplay.java b/src/java/com/threerings/crowd/chat/client/ChatDisplay.java index e2faf40c0..79c984dbd 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDisplay.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDisplay.java @@ -1,5 +1,5 @@ // -// $Id: ChatDisplay.java,v 1.10 2002/07/17 20:53:31 shaper Exp $ +// $Id: ChatDisplay.java,v 1.11 2002/07/22 22:26:26 ray Exp $ package com.threerings.crowd.chat; @@ -27,9 +27,13 @@ public interface ChatDisplay * contain a bundle identifier that should be used to translate the * message text. * @param message the text of the message. + * @param mode the mode of the speak (@see ChatCodes.DEFAULT_MODE + * @see ChatCodes.THINK_MODE, + * @see ChatCodes.EMOTE_MODE ). */ public void displaySpeakMessage ( - String type, String speaker, String bundle, String message); + String type, String speaker, String bundle, String message, + String mode); /** * Called to display a tell message. A tell message is one that is diff --git a/src/java/com/threerings/crowd/chat/data/ChatCodes.java b/src/java/com/threerings/crowd/chat/data/ChatCodes.java index 83328bf2c..94489c73a 100644 --- a/src/java/com/threerings/crowd/chat/data/ChatCodes.java +++ b/src/java/com/threerings/crowd/chat/data/ChatCodes.java @@ -1,5 +1,5 @@ // -// $Id: ChatCodes.java,v 1.7 2002/04/15 16:28:01 shaper Exp $ +// $Id: ChatCodes.java,v 1.8 2002/07/22 22:26:26 ray Exp $ package com.threerings.crowd.chat; @@ -45,6 +45,17 @@ public interface ChatCodes extends InvocationCodes /** The message identifier for a tell notification. */ public static final String TELL_NOTIFICATION = "Tell"; + /** The default mode used by speak requests. */ + public static final String DEFAULT_MODE = "default"; + + /** The think mode to indicate that the user is thinking + * what they're saying, or is it that they're saying what they're + * thinking? */ + public static final String THINK_MODE = "think"; + + /** The mode to indicate that a speak is actually an emote. */ + public static final String EMOTE_MODE = "emote"; + /** An error code delivered when the user targeted for a tell * notification is not online. */ public static final String USER_NOT_ONLINE = "m.user_not_online"; diff --git a/src/java/com/threerings/crowd/chat/server/ChatProvider.java b/src/java/com/threerings/crowd/chat/server/ChatProvider.java index 62cd8e976..47c7c1fa6 100644 --- a/src/java/com/threerings/crowd/chat/server/ChatProvider.java +++ b/src/java/com/threerings/crowd/chat/server/ChatProvider.java @@ -1,5 +1,5 @@ // -// $Id: ChatProvider.java,v 1.10 2002/04/30 17:27:30 mdb Exp $ +// $Id: ChatProvider.java,v 1.11 2002/07/22 22:26:26 ray Exp $ package com.threerings.crowd.chat; @@ -83,12 +83,36 @@ public class ChatProvider */ public static void sendChatMessage ( int placeOid, String speaker, String bundle, String message) + { + sendChatMessage( + placeOid, speaker, bundle, message, ChatCodes.DEFAULT_MODE); + } + + /** + * Sends a chat notification to the specified place object originating + * with the specified speaker (the speaker optionally being a server + * entity that wishes to fake a "speak" message) and with the supplied + * message content. + * + * @param placeOid the place to which to deliver the chat message. + * @param speaker the username of the user that generated the message + * (or some special speaker name for server messages). + * @param bundle null when the message originates from a real human, + * the bundle identifier that will be used by the client to translate + * the message text when the message originates from a server entity + * "faking" a chat message. + * @param message the text of the chat message. + * @param mode the mode of the message, @see ChatCodes.DEFAULT_MODE + */ + public static void sendChatMessage ( + int placeOid, String speaker, String bundle, String message, + String mode) { Object[] outargs = null; if (bundle == null) { - outargs = new Object[] { speaker, message }; + outargs = new Object[] { speaker, message, mode }; } else { - outargs = new Object[] { speaker, bundle, message }; + outargs = new Object[] { speaker, bundle, message, mode }; } MessageEvent nevt = new MessageEvent( placeOid, ChatService.SPEAK_NOTIFICATION, outargs); diff --git a/src/java/com/threerings/micasa/client/ChatPanel.java b/src/java/com/threerings/micasa/client/ChatPanel.java index a3d368358..88291ffc5 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.15 2002/07/17 20:53:31 shaper Exp $ +// $Id: ChatPanel.java,v 1.16 2002/07/22 22:26:26 ray Exp $ package com.threerings.micasa.client; @@ -226,7 +226,7 @@ public class ChatPanel // documentation inherited public void displaySpeakMessage ( - String type, String speaker, String bundle, String message) + String type, String speaker, String bundle, String message, String mode) { // wrap the speaker in brackets speaker = "<" + speaker + "> "; diff --git a/src/java/com/threerings/whirled/spot/client/SpotSceneDirector.java b/src/java/com/threerings/whirled/spot/client/SpotSceneDirector.java index b891c2e83..b15bc673d 100644 --- a/src/java/com/threerings/whirled/spot/client/SpotSceneDirector.java +++ b/src/java/com/threerings/whirled/spot/client/SpotSceneDirector.java @@ -1,5 +1,5 @@ // -// $Id: SpotSceneDirector.java,v 1.14 2002/06/14 01:40:16 ray Exp $ +// $Id: SpotSceneDirector.java,v 1.15 2002/07/22 22:26:26 ray Exp $ package com.threerings.whirled.spot.client; @@ -12,6 +12,7 @@ import com.threerings.presents.dobj.DObjectManager; import com.threerings.presents.dobj.ObjectAccessException; import com.threerings.presents.dobj.Subscriber; +import com.threerings.crowd.chat.ChatCodes; import com.threerings.crowd.chat.ChatDirector; import com.threerings.crowd.client.LocationAdapter; import com.threerings.crowd.client.LocationDirector; @@ -205,6 +206,18 @@ public class SpotSceneDirector * are not in a valid cluster and refused to deliver the request. */ public boolean requestClusterSpeak (String message) + { + return requestClusterSpeak(message, ChatCodes.DEFAULT_MODE); + } + + /** + * Sends a chat message to the other users in the cluster to which the + * location that we currently occupy belongs. + * + * @return true if a cluster speak message was delivered, false if we + * are not in a valid cluster and refused to deliver the request. + */ + public boolean requestClusterSpeak (String message, String mode) { // make sure we're currently in a scene DisplaySpotScene scene = (DisplaySpotScene)_scdir.getScene(); @@ -231,7 +244,7 @@ public class SpotSceneDirector // we're all clear to go SpotService.clusterSpeak( - _ctx.getClient(), scene.getId(), _locationId, message, this); + _ctx.getClient(), scene.getId(), _locationId, message, mode, this); return true; } diff --git a/src/java/com/threerings/whirled/spot/client/SpotService.java b/src/java/com/threerings/whirled/spot/client/SpotService.java index 3dbddd6d8..38849e04f 100644 --- a/src/java/com/threerings/whirled/spot/client/SpotService.java +++ b/src/java/com/threerings/whirled/spot/client/SpotService.java @@ -1,5 +1,5 @@ // -// $Id: SpotService.java,v 1.8 2002/05/15 23:54:34 mdb Exp $ +// $Id: SpotService.java,v 1.9 2002/07/22 22:26:26 ray Exp $ package com.threerings.whirled.spot.client; @@ -56,11 +56,11 @@ public class SpotService implements SpotCodes */ public static void clusterSpeak ( Client client, int sceneId, int locationId, String message, - SpotSceneDirector rsptarget) + String mode, SpotSceneDirector rsptarget) { InvocationDirector invdir = client.getInvocationDirector(); Object[] args = new Object[] { - new Integer(sceneId), new Integer(locationId), message }; + new Integer(sceneId), new Integer(locationId), message, mode }; invdir.invoke(MODULE_NAME, CLUSTER_SPEAK_REQUEST, args, rsptarget); Log.debug("Sent clusterSpeak request [sceneId=" + sceneId + ", locId=" + locationId + ", message=" + message + "]."); diff --git a/src/java/com/threerings/whirled/spot/server/SpotProvider.java b/src/java/com/threerings/whirled/spot/server/SpotProvider.java index 47af74495..383d46c1c 100644 --- a/src/java/com/threerings/whirled/spot/server/SpotProvider.java +++ b/src/java/com/threerings/whirled/spot/server/SpotProvider.java @@ -1,5 +1,5 @@ // -// $Id: SpotProvider.java,v 1.10 2002/06/20 22:38:58 mdb Exp $ +// $Id: SpotProvider.java,v 1.11 2002/07/22 22:26:26 ray Exp $ package com.threerings.whirled.spot.server; @@ -194,10 +194,11 @@ public class SpotProvider extends InvocationProvider * Handles {@link SpotCodes#CLUSTER_SPEAK_REQUEST} messages. */ public void handleClusterSpeakRequest ( - BodyObject source, int invid, int sceneId, int locId, String message) + BodyObject source, int invid, int sceneId, int locId, String message, + String mode) { sendClusterChatMessage(sceneId, locId, source.getOid(), - source.username, null, message); + source.username, null, message, mode); } /** @@ -221,7 +222,7 @@ public class SpotProvider extends InvocationProvider */ public static void sendClusterChatMessage ( int sceneId, int locId, int speakerOid, String speaker, - String bundle, String message) + String bundle, String message, String mode) { // look up the scene manager for the specified scene SpotSceneManager smgr = (SpotSceneManager) @@ -237,7 +238,7 @@ public class SpotProvider extends InvocationProvider // need to check that the location exists and that the speaker // occupies it and so on smgr.handleClusterSpeakRequest( - speakerOid, speaker, locId, bundle, message); + speakerOid, speaker, locId, bundle, message, mode); } } diff --git a/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java b/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java index 2cc5e1efc..7bdf987ac 100644 --- a/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java +++ b/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java @@ -1,5 +1,5 @@ // -// $Id: SpotSceneManager.java,v 1.13 2002/06/20 23:06:40 mdb Exp $ +// $Id: SpotSceneManager.java,v 1.14 2002/07/22 22:26:26 ray Exp $ package com.threerings.whirled.spot.server; @@ -218,7 +218,7 @@ public class SpotSceneManager extends SceneManager */ protected void handleClusterSpeakRequest ( int sourceOid, String source, int locationId, - String bundle, String message) + String bundle, String message, String mode) { // make sure this user occupies the specified location int locidx = _sscene.getLocationIndex(locationId); @@ -243,7 +243,8 @@ public class SpotSceneManager extends SceneManager // all is well, generate a chat notification int clusterOid = _clusterOids[clusterIndex]; if (clusterOid > 0) { - ChatProvider.sendChatMessage(clusterOid, source, bundle, message); + ChatProvider.sendChatMessage( + clusterOid, source, bundle, message, mode); } else { Log.warning("Have no cluster object for CCREQ " +