Dispatch tell failures via a TellFeedbackMessage so that we can easily route

them to the appropriate ChatDisplay when we're doing chat in IM-style
individual windows.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4663 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-04-16 21:42:18 +00:00
parent 9918594bda
commit 2ec9d50b6f
4 changed files with 13 additions and 7 deletions
@@ -447,7 +447,7 @@ public class ChatDirector extends BasicDirector
var failure :Function = function (reason :String) :void { var failure :Function = function (reason :String) :void {
var msg :String = MessageBundle.compose( var msg :String = MessageBundle.compose(
"m.tell_failed", MessageBundle.taint(target), reason); "m.tell_failed", MessageBundle.taint(target), reason);
displayFeedback(_bundle, msg); dispatchMessage(new TellFeedbackMessage(target, xlate(_bundle, msg), true));
if (rl != null) { if (rl != null) {
rl.requestFailed(null); rl.requestFailed(null);
} }
@@ -31,15 +31,18 @@ public class TellFeedbackMessage extends UserMessage
/** /**
* A tell feedback message is only composed on the client. * A tell feedback message is only composed on the client.
*/ */
public function TellFeedbackMessage (target :Name, message :String) public function TellFeedbackMessage (target :Name, message :String, failed :Boolean = false)
{ {
super(target, null, message); super(target, null, message);
setClientInfo(message, ChatCodes.PLACE_CHAT_TYPE); setClientInfo(message, ChatCodes.PLACE_CHAT_TYPE);
_failed = failed;
} }
override public function getFormat () :String override public function getFormat () :String
{ {
return "m.told_format"; return _failed ? null : "m.told_format";
} }
protected var _failed :Boolean;
} }
} }
@@ -526,7 +526,7 @@ public class ChatDirector extends BasicDirector
} }
protected void success () { protected void success () {
dispatchMessage(new TellFeedbackMessage(target, message)); dispatchMessage(new TellFeedbackMessage(target, message, false));
addChatter(target); addChatter(target);
if (rl != null) { if (rl != null) {
rl.requestCompleted(target); rl.requestCompleted(target);
@@ -536,7 +536,7 @@ public class ChatDirector extends BasicDirector
public void requestFailed (String reason) { public void requestFailed (String reason) {
String msg = MessageBundle.compose( String msg = MessageBundle.compose(
"m.tell_failed", MessageBundle.taint(target), reason); "m.tell_failed", MessageBundle.taint(target), reason);
displayFeedback(_bundle, msg); dispatchMessage(new TellFeedbackMessage(target, xlate(_bundle, msg), true));
if (rl != null) { if (rl != null) {
rl.requestFailed(null); rl.requestFailed(null);
} }
@@ -31,15 +31,18 @@ public class TellFeedbackMessage extends UserMessage
/** /**
* A tell feedback message is only composed on the client. * A tell feedback message is only composed on the client.
*/ */
public TellFeedbackMessage (Name target, String message) public TellFeedbackMessage (Name target, String message, boolean failure)
{ {
super(target, null, message, ChatCodes.DEFAULT_MODE); super(target, null, message, ChatCodes.DEFAULT_MODE);
setClientInfo(message, ChatCodes.PLACE_CHAT_TYPE); setClientInfo(message, ChatCodes.PLACE_CHAT_TYPE);
_failure = failure;
} }
@Override @Override
public String getFormat () public String getFormat ()
{ {
return "m.told_format"; return _failure ? null : "m.told_format";
} }
protected boolean _failure;
} }