} );
}
- public void enterRoom( String s ) {
- enterRoom( s, null );
+ public void enterRoom() {
+ new enterRoomWindow();
}
- public void enterRoom( String s, String p ) {
- enterRoom( cg.mp.rooms.getRoom( s ), p );
+ public void enterRoom( String s ) {
+ enterRoom( s, null );
}
public void enterRoom( room r ) {
- enterRoom( r, null );
+ enterRoom( r.name, null );
}
- public void enterRoom( final room rm, String pass ) {
- String cmd = "GOTO " + rm.name;
+ public void enterRoom( final String roomName, String pass ) {
+ String cmd = "GOTO " + roomName;
if( pass != null )
cmd = cmd + "|" + pass;
networkEvent( cmd, new CallBack() {
public void run( citReply r ) {
if( r.ok() ) {
+ room rm = cg.mp.rooms.getRoom( roomName );
+ if( rm == null ) { /* didn't know about it before */
+ rm = new room( roomName, r.getArg( 10 ) );
+ cg.mp.rooms.rooms.put( roomName, rm );
+ cg.mp.rooms.addToFloor( rm );
+ }
+
System.out.println( "Going to room: " + rm.name );
rm.setNew( false );
rf.setRoom( ri );
cg.mp.updateLists( rooms.getFloor().name() ); // hack
} else if( r.res_code == 540 ) {
- System.out.println( "NEED A PASSWORD FOR THIS ROOM" );
+ new enterRoomWindow( roomName );
}
} } );
}
--- /dev/null
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class enterRoomWindow extends JFrame {
+ JTextField room, pass;
+
+ public enterRoomWindow() {
+ this( null );
+ }
+
+ public enterRoomWindow( String def ) {
+ Container c = getContentPane();
+ pass = null;
+
+ addWindowListener( new WindowAdapter() {
+ public void windowClosing( WindowEvent e ) {
+ closeWin();
+ } } );
+
+ c.setLayout( new BorderLayout() );
+
+ PairPanel pp = new PairPanel();
+ pp.addLeft( new JLabel( "Name:" ) );
+ pp.addRight( room = new JTextField(10) );
+ room.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ pass.requestFocus();
+ } } );
+
+ if( def != null ) {
+ room.setText( def );
+
+ pp.addLeft( new JLabel( "Password: " ) );
+ pp.addRight( pass = new JPasswordField(10) );
+
+ pass.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ enterRoom();
+ } } );
+ }
+
+ c.add( "Center", pp );
+
+ JPanel p = new JPanel();
+ JButton b = new JButton( "Go" );
+ p.add( b );
+
+ b.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ enterRoom();
+ } } );
+
+ p.add( b = new JButton( "Cancel" ) );
+ b.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ closeWin();
+ } } );
+
+ c.add( "South", p );
+
+ citadel.me.registerWindow( this );
+ pack();
+ show();
+ }
+
+ public void closeWin() {
+ citadel.me.removeWindow( this );
+ dispose();
+ }
+
+ public void enterRoom() {
+ String r, p=null;
+ r = room.getText();
+ if( pass != null ) p = pass.getText();
+ citadel.me.enterRoom( r, p );
+ closeWin();
+ }
+}
}
} );
- citadel.me.registerWindow( this );
pack();
show();
+ citadel.me.registerWindow( this );
}
public void closeWin() {
citadel.me.removeWindow( this );
dispose();
- System.out.println( "expressWindow:closeWin" );
}
}
+
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
vp.add( b = new JButton( "Goto Room" ) );
b.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
- System.out.println( "Goto Room" );
+ citadel.me.enterRoom();
}});
vp.add( b = new JButton( "Page User" ) );
parent.enterMessage();
} } );
+ vp.add( b = new JButton( "Read Info" ) );
+ b.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ // new roomInfoWindow( ri );
+ } } );
+ b.setEnabled( false );
+
vp.add( b = new JButton( "Zap Room" ) );
b.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println( "order : " + order );*/
}
+ public room( String name, String floor ) {
+ this.name = name;
+ this.fname = floor;
+ this.floor = citadel.atoi( floor );
+ }
+
public boolean hasNew() {
return nmsgs;
}
public String unpad( String p ) {
StringBuffer s = new StringBuffer( p.substring( 0, Math.min( 29, p.length() ) ) );
while( s.charAt( s.length() - 1) == ' ' )
- s.deleteCharAt( s.length() -1 );
+ s.setLength( s.length() -1 );
return s.toString();
}