]> code.citadel.org Git - citadel.git/commitdiff
Removed some 1.2 only code and added dot-goto
authorChilly <chilly@uncensored.citadel.org>
Thu, 12 Aug 1999 16:34:38 +0000 (16:34 +0000)
committerChilly <chilly@uncensored.citadel.org>
Thu, 12 Aug 1999 16:34:38 +0000 (16:34 +0000)
shaggy/citadel.java
shaggy/enterRoomWindow.java [new file with mode: 0644]
shaggy/expressWindow.java
shaggy/mainPanel.java
shaggy/messagePanel.java
shaggy/room.java
shaggy/whoOnlineWindow.java

index 644a0907217305963593262a6b3c48f86a92c592..e8c54642e9edd1fc62dbf44538aa473663925bbf 100644 (file)
@@ -143,26 +143,33 @@ public class citadel {
        } );
     }
 
-    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 );
 
@@ -176,7 +183,7 @@ public class citadel {
                    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 );
                }
            } } );
     }
diff --git a/shaggy/enterRoomWindow.java b/shaggy/enterRoomWindow.java
new file mode 100644 (file)
index 0000000..701f90a
--- /dev/null
@@ -0,0 +1,79 @@
+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();
+    }
+}
index 9600500b447cdaaa9b9e1cb144487ffc03039f3b..db49827670a1e54b0851dd60ef800762af275a10 100644 (file)
@@ -48,14 +48,13 @@ public class expressWindow extends JFrame {
            }
        } );
 
-       citadel.me.registerWindow( this );
        pack();
        show();
+       citadel.me.registerWindow( this );
     }
 
     public void closeWin() {
        citadel.me.removeWindow( this );
        dispose();
-       System.out.println( "expressWindow:closeWin" );
     }
 }
index 23a7816214ae3a7fa6d7957e181fce758ce6cdc5..53b9cebef686fef89330d2c0c23a8f8b83555a42 100644 (file)
@@ -1,3 +1,4 @@
+
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;
@@ -31,7 +32,7 @@ public class mainPanel extends JPanel {
        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" ) );
index 15cd450381c3b66f9c55d91a3cf443d1abd379e3..e7d77ba04d2917d2b17d8fccc2f6a905df6113ef 100644 (file)
@@ -42,6 +42,13 @@ public class messagePanel extends JPanel {
                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 ) {
index e56ae43e8c45fb502e6ab3095e8c45c6b63a4bcf..e51c23fbe9c81faa235eb6e45a3a13034477c09f 100644 (file)
@@ -24,6 +24,12 @@ public class room {
     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;
   }
index db6954e0f611de05cf9ce552fb83a72e3acc1cff..6f1164dd89a6d33d32a3f5cdf703177daab60f4e 100644 (file)
@@ -98,7 +98,7 @@ public class whoOnlineWindow extends JFrame {
     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();
     }