Added code to support the new localized system messages; first by creating
a message manager and making it available to the micasa code and second by actually using it to translate system messages. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1075 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ChatPanel.java,v 1.11 2001/12/17 01:06:35 mdb Exp $
|
||||
// $Id: ChatPanel.java,v 1.12 2002/02/26 05:48:11 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -32,6 +32,8 @@ import com.samskivert.swing.HGroupLayout;
|
||||
import com.samskivert.swing.VGroupLayout;
|
||||
import com.samskivert.swing.event.AncestorAdapter;
|
||||
|
||||
import com.threerings.util.MessageBundle;
|
||||
|
||||
import com.threerings.crowd.chat.ChatCodes;
|
||||
import com.threerings.crowd.chat.ChatDirector;
|
||||
import com.threerings.crowd.chat.ChatDisplay;
|
||||
@@ -39,15 +41,15 @@ import com.threerings.crowd.client.OccupantObserver;
|
||||
import com.threerings.crowd.client.PlaceView;
|
||||
import com.threerings.crowd.data.OccupantInfo;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
import com.threerings.crowd.util.CrowdContext;
|
||||
|
||||
import com.threerings.micasa.Log;
|
||||
import com.threerings.micasa.util.MiCasaContext;
|
||||
|
||||
public class ChatPanel
|
||||
extends JPanel
|
||||
implements ActionListener, ChatDisplay, OccupantObserver, PlaceView
|
||||
{
|
||||
public ChatPanel (CrowdContext ctx)
|
||||
public ChatPanel (MiCasaContext ctx)
|
||||
{
|
||||
// keep this around for later
|
||||
_ctx = ctx;
|
||||
@@ -241,8 +243,19 @@ public class ChatPanel
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void displaySystemMessage (String type, String message)
|
||||
public void displaySystemMessage (
|
||||
String type, String bundle, String message)
|
||||
{
|
||||
// translate the message
|
||||
MessageBundle msgb = _ctx.getMessageManager().getBundle(bundle);
|
||||
if (msgb == null) {
|
||||
Log.warning("No message bundle available to translate message " +
|
||||
"[type=" + type + ", bundle=" + bundle +
|
||||
", message=" + message + "].");
|
||||
} else {
|
||||
message = msgb.xlate(message);
|
||||
}
|
||||
|
||||
// stick a newline on the message
|
||||
message = message + "\n";
|
||||
|
||||
@@ -324,7 +337,7 @@ public class ChatPanel
|
||||
return size;
|
||||
}
|
||||
|
||||
protected CrowdContext _ctx;
|
||||
protected MiCasaContext _ctx;
|
||||
protected ChatDirector _chatdtr;
|
||||
|
||||
protected boolean _focus = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MiCasaClient.java,v 1.9 2002/01/19 04:15:25 mdb Exp $
|
||||
// $Id: MiCasaClient.java,v 1.10 2002/02/26 05:48:11 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -11,6 +11,8 @@ import javax.swing.SwingUtilities;
|
||||
|
||||
import com.samskivert.util.Config;
|
||||
|
||||
import com.threerings.util.MessageManager;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.dobj.DObjectManager;
|
||||
|
||||
@@ -102,6 +104,7 @@ public class MiCasaClient
|
||||
_locdir = new LocationDirector(_ctx);
|
||||
_occmgr = new OccupantManager(_ctx);
|
||||
_pardtr = new ParlorDirector(_ctx);
|
||||
_msgmgr = new MessageManager(MESSAGE_MANAGER_PREFIX);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
@@ -167,6 +170,11 @@ public class MiCasaClient
|
||||
{
|
||||
return _frame;
|
||||
}
|
||||
|
||||
public MessageManager getMessageManager ()
|
||||
{
|
||||
return _msgmgr;
|
||||
}
|
||||
}
|
||||
|
||||
protected MiCasaContext _ctx;
|
||||
@@ -177,4 +185,9 @@ public class MiCasaClient
|
||||
protected LocationDirector _locdir;
|
||||
protected OccupantManager _occmgr;
|
||||
protected ParlorDirector _pardtr;
|
||||
protected MessageManager _msgmgr;
|
||||
|
||||
/** The prefix prepended to localization bundle names before looking
|
||||
* them up in the classpath. */
|
||||
protected static final String MESSAGE_MANAGER_PREFIX = "rsrc.messages";
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//
|
||||
// $Id: MiCasaContext.java,v 1.2 2001/10/09 17:47:33 mdb Exp $
|
||||
// $Id: MiCasaContext.java,v 1.3 2002/02/26 05:48:11 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.util;
|
||||
|
||||
import com.threerings.util.MessageManager;
|
||||
import com.threerings.parlor.util.ParlorContext;
|
||||
|
||||
import com.threerings.micasa.client.MiCasaFrame;
|
||||
|
||||
/**
|
||||
@@ -19,4 +19,10 @@ public interface MiCasaContext
|
||||
/** Returns a reference to the primary user interface frame. This can
|
||||
* be used to set the top-level panel when we enter a game, etc. */
|
||||
public MiCasaFrame getFrame ();
|
||||
|
||||
/**
|
||||
* Returns a reference to the message manager used by the client to
|
||||
* generate localized messages.
|
||||
*/
|
||||
public MessageManager getMessageManager ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user