Checkpoint. This is not compiling right now due to three annoying problems:

- There seems to be a compiler bug that causes classes to be
  imported spuriously, or something. Classes that import only one of the Log
  classes are complaining about visibility of more than one of them.
- static constants are not inherited by subclasses, which is super annoying.
  I will try switching to prototype consts, but there seems to be a problem
  initializing those, and we don't want to make them vars...
- The fact that there are no inner classes combined with no method overloading
  is making things very inconvenient. I've been experimenting with faking
  an anonymous class by instantiating a dynamic object and attaching
  functions to it, but it's not working. I'll continue experimenting, because
  if we can't do this then someone shoot me.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3957 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-03-17 02:19:53 +00:00
parent d1b997b9ff
commit 091c7d2401
22 changed files with 283 additions and 123 deletions
@@ -29,6 +29,8 @@ import com.threerings.util.SimpleMap;
import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.ClientEvent;
import com.threerings.presents.client.InvocationAdapter;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.MessageEvent;
@@ -249,7 +251,7 @@ public class ChatDirector extends BasicDirector
public function displayFeedback (bundle :String, message :String) :void
{
displaySystem(
bundle, message, SystemMessage.FEEDBACK, PLACE_CHAT_TYPE);
bundle, message, SystemMessage.FEEDBACK, ChatCodes.PLACE_CHAT_TYPE);
}
/**
@@ -262,7 +264,7 @@ public class ChatDirector extends BasicDirector
public function displayAttention (bundle :String, message :String) :void
{
displaySystem(
bundle, message, SystemMessage.ATTENTION, PLACE_CHAT_TYPE);
bundle, message, SystemMessage.ATTENTION, ChatCodes.PLACE_CHAT_TYPE);
}
/**
@@ -458,15 +460,15 @@ public class ChatDirector extends BasicDirector
}
// if they are idle, report that
if (idletime > 0) {
// adjust by the time it took them to become idle
idletime += _cctx.getConfig().getValue(
IDLE_TIME_KEY, DEFAULT_IDLE_TIME);
var msg :String = MessageBundle.compose(
"m.recipient_idle", MessageBundle.taint(target),
TimeUtil.getTimeOrderString(idletime, TimeUtil.MINUTE));
displayFeedback(_bundle, msg);
}
// if (idletime > 0) {
// // adjust by the time it took them to become idle
// idletime += _cctx.getConfig().getValue(
// IDLE_TIME_KEY, DEFAULT_IDLE_TIME);
// var msg :String = MessageBundle.compose(
// "m.recipient_idle", MessageBundle.taint(target),
// TimeUtil.getTimeOrderString(idletime, TimeUtil.MINUTE));
// displayFeedback(_bundle, msg);
// }
};
_cservice.tell(_cctx.getClient(), target, message,
@@ -622,32 +624,32 @@ public class ChatDirector extends BasicDirector
}
// documentation inherited
public override function clientDidLogon (client :Client) :void
public override function clientDidLogon (event :ClientEvent) :void
{
super.clientDidLogon(client);
super.clientDidLogon(event);
// listen on the client object for tells
addAuxiliarySource(_clobj = client.getClientObject(),
addAuxiliarySource(_clobj = event.getClient().getClientObject(),
ChatCodes.USER_CHAT_TYPE);
}
// documentation inherited
public override function clientObjectDidChange (client :Client) :void
public override function clientObjectDidChange (event :ClientEvent) :void
{
super.clientObjectDidChange(client);
super.clientObjectDidChange(event);
// change what we're listening to for tells
removeAuxiliarySource(_clobj);
addAuxiliarySource(_clobj = client.getClientObject(),
addAuxiliarySource(_clobj = event.getClient().getClientObject(),
ChatCodes.USER_CHAT_TYPE);
clearDisplays();
}
// documentation inherited
public override function clientDidLogoff (client :Client) :void
public override function clientDidLogoff (event :ClientEvent) :void
{
super.clientDidLogoff(client);
super.clientDidLogoff(event);
// stop listening to it for tells
if (_clobj != null) {
@@ -702,7 +704,7 @@ public class ChatDirector extends BasicDirector
// mogrification may result in something being turned into a slash
// command, in which case we have to run everything through again
// from the start
if (message.startsWith("/")) {
if (message.indexOf("/") == 0) {
return requestChat(speakSvc, message, false);
}
@@ -818,7 +820,7 @@ public class ChatDirector extends BasicDirector
{
var bundle :MessageBundle = _msgmgr.getBundle(_bundle);
if (!bundle.exists(key)) {
return buf;
return text;
}
var repls :Array = bundle.get(key).split("#");
// apply the replacements to each mogrification that matches
@@ -835,7 +837,7 @@ public class ChatDirector extends BasicDirector
* specified command (i.e. the specified command is a prefix of their
* registered command string).
*/
protected function getCommandHandlers (command :String) :SimpleMap
internal function getCommandHandlers (command :String) :SimpleMap
{
var matches :SimpleMap = new SimpleMap();
var user :BodyObject =
@@ -1,5 +1,7 @@
package com.threerings.crowd.chat.client {
import com.threerings.crowd.chat.data.ChatCodes;
public class ClearHandler extends CommandHandler
{
public function ClearHandler (chatdir :ChatDirector)
@@ -1,6 +1,7 @@
package com.threerings.crowd.chat.client {
import com.threerings.util.MessageBundle;
import com.threerings.util.SimpleMap;
import com.threerings.util.StringUtil;
import com.threerings.crowd.chat.data.ChatCodes;
@@ -29,7 +30,7 @@ public class HelpHandler extends CommandHandler
// let the user give commands with or without the /
if (hcmd.charAt(0) == "/") {
hcmd = hcm.substring(1);
hcmd = hcmd.substring(1);
}
// handle "/help help" and "/help boguscmd"
@@ -21,7 +21,7 @@
package com.threerings.crowd.chat.data {
import com.samskivert.util.StringUtil;
import com.threerings.util.ClassUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
@@ -43,6 +43,12 @@ public /*abstract*/ class ChatMessage
* registered with an auxiliary source in the ChatDirector. */
public var localtype :String;
public function ChatMessage (msg :String = null, bundle :String = null)
{
this.message = msg;
this.bundle = bundle;
}
/**
* Once this message reaches the client, the information contained within
* is changed around a bit.
@@ -67,8 +73,8 @@ public /*abstract*/ class ChatMessage
// documentation inherited from interface Streamable
public function readObject (ins :ObjectInputStream) :void
{
message = ins.readField(String);
bundle = ins.readField(String);
message = (ins.readField(String) as String);
bundle = (ins.readField(String) as String);
}
// documentation inherited from interface Streamable
@@ -41,11 +41,16 @@ public class SystemMessage extends ChatMessage
/** Attention level constant to indicate that some action is required. */
public static const ATTENTION :int = 2;
//----
/** The attention level of this message. */
public var attentionLevel :int;
public function SystemMessage (
msg :String = null, bundle :String = null, attLevel :int = 0)
{
super(msg, bundle);
this.attentionLevel = attLevel;
}
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
@@ -0,0 +1,38 @@
//
// $Id: TellFeedbackMessage.java 3098 2004-08-27 02:12:55Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.crowd.chat.data {
/**
* A feedback message to indicate that a tell succeeded.
*/
public class TellFeedbackMessage extends ChatMessage
{
/**
* A tell feedback message is only composed on the client.
*/
public function TellFeedbackMessage (message :String)
{
super(message, null);
setClientInfo(message, ChatCodes.PLACE_CHAT_TYPE);
}
}
}
@@ -0,0 +1,45 @@
//
// $Id$
package com.threerings.crowd.chat.data {
import com.threerings.util.Name;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* A system message triggered by the activity of another user.
* If the user is muted we can suppress this message, unlike a normal
* system message.
*/
public class UserSystemMessage extends SystemMessage
{
/** The "speaker" of this message, the user that triggered that this
* message be sent to us. */
public var speaker :Name;
/**
* Construct a UserSystemMessage.
*/
public function UserSystemMessage (
sender :Name = null, message :String = null, bundle :String = null,
attLevel :int = 0)
{
super(message, bundle, attLevel);
this.speaker = sender;
}
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
speaker = (ins.readObject() as Name);
}
public override function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeObject(speaker);
}
}
}