Allow a message to specify the name to display for a user separate from the canonical username passed in the message as the speaker variable.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4313 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Mike Thomas
2006-08-09 22:26:38 +00:00
parent be62ca7301
commit e8cd7631fd
2 changed files with 16 additions and 3 deletions
@@ -662,16 +662,19 @@ public class ChatDirector extends BasicDirector
String message = msg.message;
String autoResponse = null;
Name speaker = null;
Name speakerDisplay = null;
byte mode = (byte) -1;
// figure out if the message was triggered by another user
if (msg instanceof UserMessage) {
UserMessage umsg = (UserMessage)msg;
speaker = umsg.speaker;
speakerDisplay = umsg.getSpeakerDisplayName();
mode = umsg.mode;
} else if (msg instanceof UserSystemMessage) {
speaker = ((UserSystemMessage) msg).speaker;
speaker = ((UserSystemMessage)msg).speaker;
speakerDisplay = speaker;
}
// if there was an originating speaker, see if we want to hear it
@@ -703,7 +706,7 @@ public class ChatDirector extends BasicDirector
// if we auto-responded, report as much
if (autoResponse != null) {
String amsg = MessageBundle.tcompose(
"m.auto_responded", speaker, autoResponse);
"m.auto_responded", speakerDisplay, autoResponse);
displayFeedback(_bundle, amsg);
}
}
@@ -1349,7 +1352,7 @@ public class ChatDirector extends BasicDirector
if (err != null) {
return err;
}
// request the broadcast
requestBroadcast(args);
@@ -61,4 +61,14 @@ public class UserMessage extends ChatMessage
this.speaker = speaker;
this.mode = ChatCodes.DEFAULT_MODE;
}
/**
* Returns the name to display for the speaker. Some types of messages
* may wish to not use the canonical name for the speaker and should thus
* override this function.
*/
public Name getSpeakerDisplayName ()
{
return speaker;
}
}