Behold Vilya, Ring of Air and repository for our game and virtual worldly
extensions to the distributed environment provided by Narya. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@1 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// $Id: MiCasaApp.java 4158 2006-05-30 22:12:15Z 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.micasa.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.samskivert.swing.util.SwingUtil;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.net.UsernamePasswordCreds;
|
||||
|
||||
import com.threerings.micasa.Log;
|
||||
|
||||
/**
|
||||
* The micasa app is the main point of entry for the MiCasa client
|
||||
* application. It creates and initializes the myriad components of the
|
||||
* client and sets all the proper wheels in motion.
|
||||
*/
|
||||
public class MiCasaApp
|
||||
{
|
||||
public void init ()
|
||||
throws IOException
|
||||
{
|
||||
// create a frame
|
||||
_frame = new MiCasaFrame();
|
||||
|
||||
// create our client instance
|
||||
String cclass = null;
|
||||
try {
|
||||
cclass = System.getProperty("client");
|
||||
} catch (Throwable t) {
|
||||
// security manager in effect, no problem
|
||||
}
|
||||
if (cclass == null) {
|
||||
cclass = MiCasaClient.class.getName();
|
||||
}
|
||||
|
||||
try {
|
||||
_client = (MiCasaClient)Class.forName(cclass).newInstance();
|
||||
} catch (Exception e) {
|
||||
Log.warning("Unable to instantiate client class " +
|
||||
"[cclass=" + cclass + "].");
|
||||
Log.logStackTrace(e);
|
||||
}
|
||||
|
||||
// initialize our client instance
|
||||
_client.init(_frame);
|
||||
}
|
||||
|
||||
public void run (String server, String username, String password)
|
||||
{
|
||||
// position everything and show the frame
|
||||
_frame.setSize(800, 600);
|
||||
SwingUtil.centerWindow(_frame);
|
||||
_frame.setVisible(true);
|
||||
|
||||
Client client = _client.getContext().getClient();
|
||||
|
||||
Log.info("Using [server=" + server + ".");
|
||||
client.setServer(server, Client.DEFAULT_SERVER_PORTS);
|
||||
|
||||
// configure the client with some credentials and logon
|
||||
if (username != null && password != null) {
|
||||
// create and set our credentials
|
||||
client.setCredentials(
|
||||
new UsernamePasswordCreds(new Name(username), password));
|
||||
client.logon();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
String server = "localhost";
|
||||
if (args.length > 0) {
|
||||
server = args[0];
|
||||
}
|
||||
String username = (args.length > 1) ? args[1] : null;
|
||||
String password = (args.length > 2) ? args[2] : null;
|
||||
|
||||
MiCasaApp app = new MiCasaApp();
|
||||
try {
|
||||
// initialize the app
|
||||
app.init();
|
||||
} catch (IOException ioe) {
|
||||
Log.warning("Error initializing application.");
|
||||
Log.logStackTrace(ioe);
|
||||
}
|
||||
|
||||
// and run it
|
||||
app.run(server, username, password);
|
||||
}
|
||||
|
||||
protected MiCasaClient _client;
|
||||
protected MiCasaFrame _frame;
|
||||
}
|
||||
Reference in New Issue
Block a user