]> code.citadel.org Git - citadel.git/commitdiff
Added menus, real room info
authorChilly <chilly@uncensored.citadel.org>
Sat, 28 Aug 1999 12:57:08 +0000 (12:57 +0000)
committerChilly <chilly@uncensored.citadel.org>
Sat, 28 Aug 1999 12:57:08 +0000 (12:57 +0000)
12 files changed:
shaggy/PairPanel.java
shaggy/STATUS
shaggy/VertPanel.java
shaggy/citGui.java
shaggy/citadel.java
shaggy/hostPanel.java
shaggy/message.java
shaggy/messagePanel.java
shaggy/roomFrame.java
shaggy/roomInfo.java
shaggy/roomInfoWindow.java
shaggy/roomMap.java

index 94df50f21c17391cf9a13ac2949776af9a9bbea7..325fa3fcaa6f5232963844b2fa225a551842c3b9 100644 (file)
@@ -2,9 +2,10 @@
  * Utility class so I don't have to think about GridBagLayout
  */
 
+import javax.swing.*;
 import java.awt.*;
 
-public class PairPanel extends Panel {
+public class PairPanel extends JPanel {
   GridBagLayout           gbLayout;
   GridBagConstraints      gbLeft, gbRight;
 
index 544419da1b4de3c61eb28695dd44ed36cd3d0ade..5c5d549085f34cd441904538b157c6a4842385ef 100644 (file)
@@ -25,7 +25,7 @@ Basic:
 - go to any old room by double-clicking from list
 _ can get to hidden or guessable-named rooms
 _ can go to password protected rooms (tested)
-* can't zap rooms
+- can zap rooms
 * can't list zapped rooms
 
 "message"
@@ -43,6 +43,6 @@ _ can go to password protected rooms (tested)
   go to the next room, the three unread messages will still be unread with
   the java client while they wouldn't be with the text client.  I like it
   better personally, but hey, that's me.
-* can't view room info
+- can view room info
 
 everything else isn't done.
index 8b1f0f1eb94b336efee717d28cd8ee358ce14282..fcb055135c2fbd27cf87cf9b4f62f07738f79500 100644 (file)
@@ -1,6 +1,7 @@
+import javax.swing.*;
 import java.awt.*;
 
-public class VertPanel extends Panel {
+public class VertPanel extends JPanel {
   GridBagLayout                gbLayout;
   GridBagConstraints   cur;
   boolean              top = true;
index 5df769a021e23319859daca727ad7e2798d2c4c4..329a5cd9e7af061a989ded18fb63fe069cad0014 100644 (file)
@@ -11,10 +11,20 @@ public class citGui {
     loginPanel lp;
     mainPanel  mp;
     logoffPanel        lfp;
+    JMenu      cit, rooms;
+    JMenuItem  logoff;
 
     public citGui() {
        frame = new JFrame( "Shaggy" );
+       JLayeredPane    p = new JLayeredPane();
+       JMenuBar        mbar = new JMenuBar();
+
        c = frame.getContentPane();
+       c.setLayout( new BorderLayout() );
+       c.add( mbar, BorderLayout.NORTH );
+
+       c.add( p, BorderLayout.CENTER  );
+       c = p;
 
        c.setLayout( cdLayout = new CardLayout() );
        c.add( "Host", hp = new hostPanel() );
@@ -25,10 +35,104 @@ public class citGui {
        frame.addWindowListener( new WindowAdapter() {
            public void windowClosing( WindowEvent e ) {
                citadel.me.closeFrame();
-               System.exit( 0 );
            }
        });
 
+       JMenu           m;
+       JMenuItem       mi;
+
+       m = new JMenu( "File" );
+
+       mi = new JMenuItem( "Load hosts..." );
+       mi.setEnabled( false );
+       m.add( mi );
+
+       mi = new JMenuItem( "Save hosts..." );
+       mi.setEnabled( false );
+       m.add( mi );
+
+       mi = new JMenuItem( "Shaggy Preferences" );
+       mi.setEnabled( false );
+       m.add( mi );
+
+       m.add( new JSeparator() );
+
+       logoff = new JMenuItem( "Logoff" );
+       logoff.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           citadel.me.logoff();
+         } } );
+       m.add( logoff );
+       logoff.setEnabled( false );
+       logoff.setMnemonic( 'L' );
+
+       mi = new JMenuItem( "Quit" );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           citadel.me.closeFrame();
+         } } );
+       m.add( mi );
+       mi.setMnemonic( 'Q' );
+
+       mbar.add( m );
+
+       cit = new JMenu( "Citadel" );
+       cit.setEnabled( false );
+       cit.add( mi = new JMenuItem( "Page User..." ) );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           new pageUserWindow();
+         } } );
+
+       cit.add( mi = new JMenuItem( "Who is Online" ) );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           new whoOnlineWindow();
+         } } );
+
+       cit.add( new JSeparator() );
+       cit.add( mi = new JMenuItem( "User List" ) );
+       mi.setEnabled( false );
+       cit.add( mi = new JMenuItem( "User Biographies" ) );
+       mi.setEnabled( false );
+       cit.add( new JSeparator() );
+       cit.add( mi = new JMenuItem( "User Configuration" ) );
+       mi.setEnabled( false );
+       cit.add( mi = new JMenuItem( "Server Information" ) );
+       mi.setEnabled( false );
+
+       mbar.add( cit );
+
+       rooms = new JMenu( "Rooms" );
+       rooms.setEnabled( false );
+       rooms.add( mi = new JMenuItem( "Next Room" ) );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           citadel.me.enterRoom( citadel.me.rooms.nextNewRoom() );
+         } } );
+
+       rooms.add( mi = new JMenuItem( "Goto Room" ) );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           citadel.me.enterRoom();
+         } } );
+
+       rooms.add( new JSeparator() );
+       rooms.add( mi = new JMenuItem( "List Zapped Rooms" ) );
+       mi.setEnabled( false );
+       rooms.add( mi = new JMenuItem( "Create Room..." ) );
+       mi.setEnabled( false );
+       rooms.add( mi = new JMenuItem( "Edit Room" ) );
+       mi.setEnabled( false );
+
+       mbar.add( rooms );
+
+       frame.getLayeredPane().moveToFront( mbar );
+       frame.getLayeredPane().moveToFront( mi );
+       frame.getLayeredPane().moveToFront( cit );
+       frame.getLayeredPane().moveToFront( rooms );
+       frame.getLayeredPane().moveToBack( p );
+
        frame.pack();
        frame.setVisible( true );
     }
@@ -36,11 +140,17 @@ public class citGui {
     public void showHostBrowser() {
        cdLayout.show( c, "Host" );
        hp.refresh();
+       cit.setEnabled( false );
+       rooms.setEnabled( false );
+       logoff.setEnabled( false );
     }
 
     public void showLoginPanel() {
        cdLayout.show( c, "Login" );
        lp.refresh();
+       cit.setEnabled( false );
+       rooms.setEnabled( false );
+       logoff.setEnabled( false );
     }
 
     public void showLoginPanel( String user, String pass ) {
@@ -53,11 +163,17 @@ public class citGui {
 
     public void showMainPanel() {
        cdLayout.show( c, "Main" );
+       cit.setEnabled( true );
+       rooms.setEnabled( true );
+       logoff.setEnabled( true );
        mp.refresh();
     }
 
     public void showLogoffPanel() {
        cdLayout.show( c, "Logoff" );
+       cit.setEnabled( false );
+       rooms.setEnabled( false );
+       logoff.setEnabled( false );
        lfp.refresh();
     }
 
@@ -75,7 +191,3 @@ public class citGui {
                                      JOptionPane.WARNING_MESSAGE);
     }
 }
-
-
-
-
index 6d7a4208296dcb732622ab4d28cd88fcd8de716d..6f17285da30936a590c26ca220b8b62048791a48 100644 (file)
@@ -92,6 +92,7 @@ public class citadel {
        theNet.done = true;
        cg.errMsg( reason );
        cg.showHostBrowser();
+       cleanup();
     }
 
     public void warning( String text ) {
@@ -99,7 +100,9 @@ public class citadel {
     }
 
     public void closeFrame() {
-       System.out.println( "Closed the friggin frame." );
+      /* prompt here? */
+       System.out.println( "Closed the frame." );
+       System.exit( 0 );
     }
 
     public void networkEvent( String cmd ) {
@@ -199,6 +202,16 @@ public class citadel {
     }
 
     public void logoff() {
+      cleanup();
+
+       cg.showLogoffPanel();
+       networkEvent( "QUIT", new CallBack() {
+           public void run( citReply r ) {
+               theNet.done();
+           } } );
+    }
+
+  public void cleanup() {
        /* close windows */
        if( rf != null )
            rf.dispose();
@@ -207,13 +220,7 @@ public class citadel {
            JFrame      f = (JFrame)e.nextElement();
            f.dispose();
        }
-
-       cg.showLogoffPanel();
-       networkEvent( "QUIT", new CallBack() {
-           public void run( citReply r ) {
-               theNet.done();
-           } } );
-    }
+  }
 
     public void setUser( user theUser ) {
        this.theUser = theUser;
index 15491ccd82a561c95d6cfd1759644bc4770b0650..53198011d947de224b854e2bf4d7543a48a4d44c 100644 (file)
@@ -42,19 +42,42 @@ public class hostPanel extends JPanel {
     PairPanel  pp = new PairPanel(3, 10);
     pp.addLeft( new JLabel( "BBS Name:" ) );
     pp.addRight( h_name = new JTextField( 20 ) );
+    h_name.addActionListener( new ActionListener() {
+      public void actionPerformed( ActionEvent e ) {
+       dns_name.requestFocus();
+      } } );
 
     pp.addLeft( new JLabel( "IP Address:" ) );
     pp.addRight( dns_name = new JTextField( 20 ) );
     dns_name.setText( "127.0.0.1" );
+    dns_name.addActionListener( new ActionListener () {
+      public void actionPerformed( ActionEvent e ) {
+       port.requestFocus();
+      } } );
    
     pp.addLeft( new JLabel( "Port:" ) );
     pp.addRight( port = new JTextField( "504" ) );
+    port.addActionListener( new ActionListener() {
+      public void actionPerformed( ActionEvent e ) {
+       user.requestFocus();
+      } } );
 
     pp.addLeft( new JLabel( "Username:" ) );
     pp.addRight( user = new JTextField( 10 ) );
+    user.addActionListener( new ActionListener() {
+      public void actionPerformed( ActionEvent e ) {
+       pass.requestFocus();
+      } } );
 
     pp.addLeft( new JLabel( "Password:" ) );
     pp.addRight( pass = new JPasswordField( 10 ) );
+    pass.addActionListener(new ActionListener() {
+      public void actionPerformed( ActionEvent e ) {
+       citadel.me.setServer( dns_name.getText(), port.getText() );
+       citadel.me.showLoginPanel( user.getText(), pass.getText() );
+      }
+    });
+
     add( "Center", pp );
 
     JButton    but = new JButton( "Connect" );
index 74dd72c3d98edc7b869de34a7c1cf009bd8c0f74..4a33417f26482e6aaa94c84edae91d1bfb2ecd20 100644 (file)
@@ -21,7 +21,8 @@ public class message {
        time = makeDate( time );
 
        blurb = (cur_pos+1) + "/" + count + " " + time + " from " + from;
-       if( !node.equals( citadel.me.serverInfo.human_name ) )
+       //      if( !node.equals( citadel.me.serverInfo.human_name ) )
+       if( ri.net )
            blurb = blurb + " (@"+node+")";
        if( !rcpt.equals( "" ) )
            blurb = blurb + " to " + rcpt;
index 76e35c443beee13829828225751e3a56ff8ebb1d..6b88571c621f9f998966ef807544511ca63bcf17 100644 (file)
@@ -76,15 +76,13 @@ public class messagePanel extends JPanel {
        p.add( prev_msg = new JButton( "Prev Message" ) );
        prev_msg.addActionListener( new ActionListener() {
            public void actionPerformed( ActionEvent e ) {
-               cur_pos--;
-               displayMessage();
+             prevMessage();
            } } );
 
        p.add( next_msg = new JButton( "Next Message" ) );
        next_msg.addActionListener( new ActionListener() {
            public void actionPerformed( ActionEvent e ) {
-               cur_pos++;
-               displayMessage();
+             nextMessage();
            } } );
 
 
@@ -106,6 +104,16 @@ public class messagePanel extends JPanel {
        add( "Center", p );
     }
 
+  public void nextMessage() {
+    cur_pos++;
+    displayMessage();
+  }
+
+  public void prevMessage() {
+    cur_pos--;
+    displayMessage();
+  }
+
     public void refresh() {
        refresh( ri );
     }
index b0bcefdfad18955cc2e2fdf5e163b4068290be1c..b1eadebcd73b61a39c5d116a287fff5ba96df0b6 100644 (file)
@@ -28,8 +28,59 @@ public class roomFrame extends JFrame {
            }
        } );
 
-       this.pack();
-       this.show();
+       JMenuBar        mbar = new JMenuBar();
+       JMenu           m = new JMenu( "Rooms" );
+       mbar.add( m );
+       JMenuItem       mi = new JMenuItem( "Next Room" );
+       m.add( mi );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           citadel.me.enterRoom( citadel.me.rooms.nextNewRoom() );
+         } } );
+
+       m.add( mi = new JMenuItem( "Goto Room" ) );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           citadel.me.enterRoom();
+         } } );
+
+       m.add( mi = new JMenuItem( "Zap Room" ) );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           if( JOptionPane.showConfirmDialog( null, "Zap " + mp.ri.name + "?" ) == 0 )
+             citadel.me.zapRoom( mp.ri );
+         } } );
+
+       m.add( new JSeparator() );
+
+       m.add( mi = new JMenuItem( "Room Info" ) );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           new roomInfoWindow( mp.ri );
+         } } );
+
+       mbar.add( m = new JMenu( "Messages" ) );
+       m.add( mi = new JMenuItem( "Next Message" ) );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           mp.nextMessage();
+         } } );
+
+       m.add( mi = new JMenuItem( "Previous Message" ) );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           mp.prevMessage();
+         } } );
+
+       m.add( mi = new JMenuItem( "Enter Message" ) );
+       mi.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           enterMessage();
+         } } );
+
+       setJMenuBar( mbar );
+       pack();
+       show();
     }
 
     public void setRoom( roomInfo ri ) {
index 3811819a9b362230cbc6a98bf07916e89c69290c..70495e135211f852e1814dc327efe86fc77d804e 100644 (file)
@@ -1,15 +1,21 @@
 public class roomInfo {
+  public final int PERMANENT=1, PRIVATE=4, PASSWORDED=8, GUESSNAME=16,
+    DIRECTORY=32, UPLOAD=64, DOWNLOAD=128, VISDIR=256, ANONONLY=512,
+    ANON2=1024, NETWORK=2048, PREFONLY=4096, READONLY=8192;
+
     String     name;
     int                total, unread, info, flags, highest, highest_read;
     boolean    mail, aide;
     int                mail_num, floor;
     room       rm;
+  boolean perm, priv, pass, guess, dir, upload, download, vis, a_anon, 
+      o_anon, net, pref, read;
 
     public roomInfo( room rm, citReply r ) {
        this.rm = rm;
        name = r.getArg( 0 );
-       total = citadel.atoi( r.getArg( 1 ) );
-       unread = citadel.atoi( r.getArg( 2 ) );
+       unread = citadel.atoi( r.getArg( 1 ) );
+       total = citadel.atoi( r.getArg( 2 ) );
        info = citadel.atoi( r.getArg( 3 ) );
        flags = citadel.atoi( r.getArg( 4 ) );
        highest = citadel.atoi( r.getArg( 5 ) );
@@ -18,7 +24,25 @@ public class roomInfo {
        aide = citadel.atoi( r.getArg( 8 ) ) != 0;
        mail_num = citadel.atoi( r.getArg( 9 ) ); 
        floor = citadel.atoi( r.getArg( 10 ) );
+
+       perm =    on( PERMANENT );
+       priv =    on( PRIVATE );
+       pass =    on( PASSWORDED );
+       guess =   on( GUESSNAME ); 
+       dir =     on( DIRECTORY );
+       upload =  on( UPLOAD );
+       download= on( DOWNLOAD );
+       vis =     on( VISDIR );
+       a_anon =  on( ANONONLY );
+       o_anon =  on( ANON2 );
+       net =     on( NETWORK ); 
+       pref =    on( PREFONLY );
+       read =    on( READONLY );
     }
+
+  public boolean on( int bit ) {
+    return (flags & bit ) == bit;
+  }
 }
 
 
index 3d482448cb2f9f38a7b3ce6902c6117db1a6fd0f..9f977435db52e2b60bcb889733c17740c62290d9 100644 (file)
@@ -26,35 +26,76 @@ public class roomInfoWindow extends JFrame {
        info.setEditable( false );
        info.setLineWrap( true );
        info.setWrapStyleWord( true );
-       
+
+       VertPanel       vp = new VertPanel();
+       vp.add( new JLabel( ri.total + " messages" ) );
+       vp.add( new JLabel( "Floor: " + citadel.me.rooms.getFloor( ri.floor ).name() ) );
+       JCheckBox       cb;
+       vp.add( cb = new JCheckBox( "Permanent", ri.perm ) );
+       cb.setEnabled( false );
+       vp.add( cb = new JCheckBox( "Private", ri.priv ) );
+       cb.setEnabled( false );
+       vp.add( cb = new JCheckBox( "Password", ri.pass ) );
+       cb.setEnabled( false );
+       vp.add( cb = new JCheckBox( "Directory", ri.dir ) );
+       cb.setEnabled( false );
+       vp.add( cb = new JCheckBox( "Networked", ri.net ) );
+       cb.setEnabled( false );
+       p.add( "East", vp );
+
        c = getContentPane();
        c.setLayout( new BorderLayout() );
        c.add( "Center", p );
        
-       p = new JPanel();
+       JPanel  pp = new JPanel();
+       final JButton   change = new JButton( "Change Info" );
+       pp.add( change );
+       change.setEnabled( false );
+       change.addActionListener( new ActionListener() {
+         public void actionPerformed( ActionEvent e ) {
+           citadel.me.networkEvent( "EINF 1", info.getText(), new CallBack() {
+             public void run( citReply r ) {
+               refresh();
+             } } );
+         } } );
+
        JButton b;
-       p.add( b = new JButton( "Close" ) );
-       c.add( "South", p );
+
+       pp.add( b = new JButton( "Close" ) );
        b.addActionListener( new ActionListener() {
            public void actionPerformed( ActionEvent e ) {
                closeWin();
            } } );
 
+       c.add( "South", pp );
+
        addWindowListener( new WindowAdapter() {
            public void windowClosing( WindowEvent e ) {
                closeWin();
            } } );
 
-       pack();
+       setSize( 400, 400 );
        show();
 
        citadel.me.registerWindow( this );
+       refresh();
+       citadel.me.networkEvent( "EINF 0", new CallBack() {
+         public void run( citReply r ) {
+           if( r.ok() ) {
+             info.setEditable( true );
+             change.setEnabled( true );
+           }
+         } } );
+
+    }
+
+    public void refresh() {
        citadel.me.networkEvent( "RINF", new CallBack() {
            public void run( citReply r ) {
                if( r.error() ) info.setText( r.getArg(0) );
                else info.setText( r.getData() );
            } } );
-    }
+    }  
 
     public void closeWin() {
        citadel.me.removeWindow( this );
index 4cbac602caf37138740da332a8f0450a7c7094dc..1438837c285289ea7bdbc03601dc51bc77124347 100644 (file)
@@ -81,6 +81,10 @@ public class roomMap {
        return cur_floor;
     }
 
+  public floor getFloor( int num ) {
+    return getFloor( "" +  num );
+  }
+
     public floor getFloor( String name ) {
        return (floor)floors.get( name );
     }