]> code.citadel.org Git - citadel.git/commitdiff
massive ui updates and begining of floor support
authorChilly <chilly@uncensored.citadel.org>
Thu, 29 Jul 1999 17:20:40 +0000 (17:20 +0000)
committerChilly <chilly@uncensored.citadel.org>
Thu, 29 Jul 1999 17:20:40 +0000 (17:20 +0000)
13 files changed:
shaggy/STATUS
shaggy/citFrame.java
shaggy/citPanel.java
shaggy/citadel.java
shaggy/enterPanel.java
shaggy/logoffPanel.java
shaggy/mainPanel.java
shaggy/messagePanel.java
shaggy/net.java
shaggy/pageWindow.java
shaggy/passwordWindow.java
shaggy/server.java
shaggy/user.java

index df3832405b2e18ee80bc5fdf296867bf218a5805..25d5017779898509214edc3a46ca170199496aa2 100644 (file)
@@ -1,4 +1,4 @@
-mod: 28 Jul 1999
+mod: 29 Jul 1999
 
 Basic:
 - Connect to server and login (connects, gets "hello" and throws up window)
@@ -14,7 +14,7 @@ Basic:
 
 "main"
 - Splits rooms up into new and no-new
- * no floor support yet.
+ * limited floor support (shows in message panel)
  * doesn't sort the room names, even though there's "no pressing reason not to"
 
 - Go to next room with messages
index 2c60f9936d897f6ac947d1b91d0d32b7cf5cbcf1..7fa3154d28d4523e39e6a1bacb8a8300303c71f7 100644 (file)
@@ -21,7 +21,7 @@ public class citFrame extends Frame {
   public boolean handleEvent( Event e ) {
     if( e.id == Event.WINDOW_DESTROY ) {
       if( citadel.me.theNet != null )
-       citadel.me.theNet.println( "QUIT" );
+       citadel.me.getReply( "QUIT" );
       System.out.println( "Bye bye!" );
       System.exit( 0 );
     }
index 57c4f4c4171ceb555bfa2f6af90b14e870e8b66f..8c46e505fda206383c5c75373df690b9132365a5 100644 (file)
@@ -22,7 +22,7 @@ public class citPanel extends Panel {
     add( "Enter", ep = new enterPanel() );
     add( "Logoff", offP = new logoffPanel() );
 
-    citadel.me.cp = this;
+    citadel.me.setCitPanel( this );
     login();
   }
 
index fb44cfdd9320e0cfadd3fe77fde3cf43249c2eed..258c94235a84f3ccb706e2ac3c284d0d779ee518 100644 (file)
@@ -9,10 +9,11 @@ public class citadel {
   net                          theNet;
   server                       serverInfo;
   user                         theUser;
-  citPanel                     cp;
+  private citPanel                     cp;
 
   boolean                      floors;
   whoWindow                    wo;
+  roomMap                      rooms;
 
   public static citadel        me;
 
@@ -25,11 +26,24 @@ public class citadel {
     citFrame cf = new citFrame();
   }
 
+  public static int atoi( String s ) {
+    try {
+      return Integer.parseInt( s );
+    } catch( Exception e ) {
+      return 0;
+    }
+  }
+
   public citadel( boolean applet ) {
     me = this;
     this.applet = false;
     theUser = null;
     wo = null;
+    rooms = new roomMap();
+  }
+
+  public void setCitPanel( citPanel cp ) {
+    this.cp = cp;
   }
 
   public void lostNetwork( String reason ) {
@@ -69,7 +83,7 @@ public class citadel {
   }
 
   public String getSystemMessage( String name ) {
-    citReply rep = theNet.getReply( "MESG " + name );
+    citReply rep = getReply( "MESG " + name );
     if( rep.listingFollows() )
       return rep.getData();
     else
@@ -84,33 +98,59 @@ public class citadel {
   }
 
   public citReply getReply( String s ) {
+    return getReply( s, (String)null );
+  }
+
+  public citReply getReply( String s, String d ) {
     if( theNet == null ) return null;
 
-    return theNet.getReply( s );
+    return theNet.getReply( s,d  );
   }
 
   public void enterRoom( String room ) {
     enterRoom( room, null );
   }
 
+  public void gotoRoom( ) {
+    gotoRoom( null, false );
+  }
+
+  public void gotoRoom( String name, boolean flag ) {
+    /* TODO: prompt for room name */
+    System.out.println( "This is where I would ask you for the room's name" );
+  }
+
   public void enterRoom( String room, String pass ) {
     String cmd = "GOTO " + room;
     if( pass != null )
       cmd = cmd + " " + pass;
     citReply   r=getReply( cmd );
     if( r.ok() ) {
-      cp.mp.visited( room );
+      rooms.visited( room );
       cp.enterRoom( r );
     } else if( r.res_code == 540 ) /* ERROR+PASSWORD_REQUIRED */
       new passwordWindow( room );
   }
 
+  public void showMsgPane() {
+    cp.deck.show( cp, "Message" );
+  }
+
+  public void login() {
+    rooms.loadFloorInfo();
+    cp.login();
+  }
+
+  public void mainMenu() {
+    cp.mainMenu();
+  }
+
   public void enterMsg( String room ) {
     cp.enterMsg( room );
   }
 
   public void nextNewRoom() {
-    enterRoom( cp.mp.nextNewRoom() );
+    enterRoom( rooms.nextNewRoom() );
   }
 
   public void expressMsg() {
@@ -124,16 +164,14 @@ public class citadel {
     if( mail ) cmd = cmd + rec;
     cmd = cmd + "|0|0|0";
 
-    citReply   r = getReply( cmd );
-    if( r.sendListing() ) {
-      theNet.println( body );
-      theNet.println( "000" );
-    }
+    citReply   r = getReply( cmd, body );
+    if( r.error() )
+      error( r );
   }
 
   public void logoff() {
     cp.logoff(null);
-    theNet.println( "quit" );
+    getReply( "QUIT" );
   }
 
   public void who_online() {
@@ -150,4 +188,8 @@ public class citadel {
   public void page_user( String who ) {
     new pageWindow( who );
   }
+
+  public void error( citReply r ) {
+    System.out.println( r.line );
+  }
 }
index 652426fc9b181e379959c76fb746171572df3bff..b2289597555a793f9486150afe360e93a5b1c13b 100644 (file)
@@ -71,9 +71,9 @@ public class enterPanel extends Panel {
   public boolean action( Event e, Object o ) {
     if( e.target == ok ) {
       citadel.me.sendMessage( msg.getText(), who.getText(), mail );
-      citadel.me.cp.deck.show( citadel.me.cp, "Message" ); // Umm... this is bad
+      citadel.me.showMsgPane();
     } else if( e.target == cancel ) {
-      citadel.me.cp.deck.show( citadel.me.cp, "Message" ); // Umm... this is bad    } else if( e.taget == who ) {
+      citadel.me.showMsgPane();
       msg.requestFocus();
     }
     return super.action( e, o );
index c3c836299f38cb849078ac822d42237463f4ca17..a62273a4dc494d37f6c557647e401ce3cabfbccc 100644 (file)
@@ -43,7 +43,7 @@ public class logoffPanel extends Panel {
        citadel.me.host = host.getText();
 
       citadel.me.openConnection( citadel.me.host );
-      citadel.me.cp.login();
+      citadel.me.login();
     } else if ( e.target == close ) {
       System.out.println( "Thanks!" );
       System.exit( 0 );
index 4fcaf132e3d69c1011416572fe301bed4a5adfe3..96ad77a61a676d4e3d996c4693d7a55dec22ec51 100644 (file)
@@ -4,7 +4,7 @@
 import java.awt.*;
 
 public class mainPanel extends Panel {
-  List         new_msgs, seen;
+  List         newL, oldL;
   Button       next_room, goto_room;
   Button       who_is_online, page_user;
   Button       logout;
@@ -17,13 +17,13 @@ public class mainPanel extends Panel {
 
     NamedPanel np = new NamedPanel( "New Messages" );
     np.setLayout( new BorderLayout() );
-    np.add( "Center", new_msgs = new List() );
+    np.add( "Center", newL = new List() );
 
     p.add( np );
 
     np = new NamedPanel( "Seen Messages" );
     np.setLayout( new BorderLayout() );
-    np.add( "Center", seen = new List() );
+    np.add( "Center", oldL = new List() );
     p.add( np );
 
     add( "Center", p );
@@ -38,10 +38,12 @@ public class mainPanel extends Panel {
     p = new Panel();
     p.add( logout = new Button( "Logout" ) );
     add( "South", p );
+
+    citadel.me.rooms.setList( newL, oldL );
   }
 
   public boolean action( Event e, Object o ) {
-    if( (e.target == new_msgs) || (e.target == seen) || (e.target == goto_room)) {
+    if( (e.target == newL) || (e.target == oldL) || (e.target == goto_room)) {
       String room = getRoom();
       if( room != null )
        citadel.me.enterRoom( room );
@@ -51,6 +53,8 @@ public class mainPanel extends Panel {
       citadel.me.page_user();
     } else if (e.target == next_room ) {
       citadel.me.nextNewRoom();
+    } else if( e.target == goto_room ) {
+      citadel.me.gotoRoom( getRoom(), true );
     } else if( e.target == logout ) {
       citadel.me.logoff();
     } else {
@@ -62,59 +66,28 @@ public class mainPanel extends Panel {
 
   public boolean handleEvent( Event e ) {
     if( e.id == Event.LIST_SELECT ) {
-      if( e.target == new_msgs ) {
-       int     i = seen.getSelectedIndex();
+      if( e.target == newL ) {
+       int     i = oldL.getSelectedIndex();
        if( i != -1 )
-         seen.deselect( i );
+         oldL.deselect( i );
       } else {
-       int     i = new_msgs.getSelectedIndex();
+       int     i = newL.getSelectedIndex();
        if( i != -1 )
-         new_msgs.deselect( i );
+         newL.deselect( i );
       }
     }
     return super.handleEvent( e );
   }
 
   public void refresh() { 
-    new_msgs.clear(); 
-    parseRooms( new_msgs, citadel.me.getReply( "LKRN" ) );
-
-    seen.clear();
-    parseRooms( seen, citadel.me.getReply( "LKRO" ) );
-  }
-       
-  public void parseRooms( List l, citReply r ) {
-    int                i=0;
-    String     s;
-
-    while( (s = r.getLine( i++) ) != null ) {
-      int j = s.indexOf( '|' );
-      if( j != -1 )
-       l.addItem( s.substring( 0, j ) );
-      else
-       l.addItem( s );
-    }
+    citadel.me.rooms.refresh();
   }
 
   public String getRoom() {
-    String s = new_msgs.getSelectedItem();
-    if( s == null ) s = seen.getSelectedItem();
+    String s = newL.getSelectedItem();
+    if( s == null ) s = oldL.getSelectedItem();
 
     return s;
   }
 
-  public String nextNewRoom() {
-    if( new_msgs.countItems() == 0 ) return "Lobby";
-
-    return new_msgs.getItem( 0 );
-  }
-
-  public void visited( String room ) {
-    for( int i = 0; i < new_msgs.countItems(); i++ ) {
-      if( room.equals( new_msgs.getItem( i ) ) ) {
-       new_msgs.delItem( i );
-       seen.addItem( room );
-      }
-    }
-  }
 }
index 2a70f1ccdd47254927fc2202fff2d1047930ffc7..0f77429c10a36a58d0d6129b0edaa1d5b1402db1 100644 (file)
@@ -7,7 +7,7 @@ import java.util.*;
 public class messagePanel extends Panel {
   Choice       reading;
   Button       who_is_online, room_info;
-  Button       next_room, page_user;
+  Button       next_room, goto_room, page_user;
   Button       next_msg, prev_msg, enter_msg, back;
   TextField    msgInfo;
   TextArea     theMsg;
@@ -24,18 +24,24 @@ public class messagePanel extends Panel {
   public messagePanel() {
     setLayout( new BorderLayout() );
 
-    Panel      p = new Panel();
-    p.add( reading = new Choice() );
+    VertPanel  vp = new VertPanel();
+    vp.add( reading = new Choice() );
     reading.addItem( "Read New" );
     reading.addItem( "Read All" );
     reading.addItem( "Last 5" );
     reading.select( 0 );
 
-    //    p.add( who_is_online = new Button( "Who is Online" ) );
-    p.add( room_info = new Button( "Room Info" ) );
-    p.add( next_room = new Button( "Next Room" ) );
-    p.add( page_user = new Button( "Page User" ) );
-    add( "North", p );
+    vp.add( next_msg = new Button( "Next Message" ) );
+    vp.add( prev_msg = new Button( "Prev Message" ) );
+    vp.add( enter_msg = new Button( "Enter Message" ) );
+    vp.add( next_room = new Button( "Next Room" ) );
+    vp.add( goto_room = new Button( "Goto Room" ) );
+    vp.add( room_info = new Button( "Room Info" ) );
+    vp.add( who_is_online = new Button( "Who is Online" ) );
+    vp.add( page_user = new Button( "Page User" ) );
+    vp.add( back = new Button( "Back" ) );
+
+    add( "West", vp );
 
     np = new NamedPanel( "Message" );
     np.setLayout( new BorderLayout() );
@@ -43,12 +49,8 @@ public class messagePanel extends Panel {
     np.add( "Center", theMsg = new TextArea() );
     add( "Center", np );
 
-    p = new Panel();
-    p.add( next_msg = new Button( "Next Message" ) );
-    p.add( prev_msg = new Button( "Prev Message" ) );
-    p.add( enter_msg = new Button( "Enter Message" ) );
-    p.add( back = new Button( "Back" ) );
-    add( "South", p );
+    /*    Panel p = new Panel();
+         add( "South", p );*/
   }
 
   public boolean action( Event e, Object o ) {
@@ -70,25 +72,27 @@ public class messagePanel extends Panel {
       citadel.me.enterMsg( name );
     } else if( e.target == next_room ) {
       citadel.me.nextNewRoom();
+    } else if( e.target == goto_room ) {
+      citadel.me.gotoRoom();
     } else if( e.target == back ) {
-      citadel.me.cp.mainMenu();
+      citadel.me.mainMenu();
     }
     return super.action( e, o );
   }
 
   public void refresh( citReply r ) {
     name = r.getArg( 0 );
-    np.setLabel( name );
-    total = atoi( r.getArg( 1 ) );
-    unread = atoi( r.getArg( 2 ) );
-    info = atoi( r.getArg( 3 ) );
-    flags = atoi( r.getArg( 4 ) );
-    highest = atoi( r.getArg( 5 ) );
-    highest_read = atoi( r.getArg( 6 ) );
-    mail = atoi( r.getArg( 7 ) ) != 0;
-    aide = atoi( r.getArg( 8 ) ) != 0;
-    mail_num = atoi( r.getArg( 9 ) ); 
-    floor = atoi( r.getArg( 10 ) );
+    np.setLabel( name + " (" + citadel.me.rooms.getRoomsFloorName( name )+")" );
+    total = citadel.atoi( r.getArg( 1 ) );
+    unread = citadel.atoi( r.getArg( 2 ) );
+    info = citadel.atoi( r.getArg( 3 ) );
+    flags = citadel.atoi( r.getArg( 4 ) );
+    highest = citadel.atoi( r.getArg( 5 ) );
+    highest_read = citadel.atoi( r.getArg( 6 ) );
+    mail = citadel.atoi( r.getArg( 7 ) ) != 0;
+    aide = citadel.atoi( r.getArg( 8 ) ) != 0;
+    mail_num = citadel.atoi( r.getArg( 9 ) ); 
+    floor = citadel.atoi( r.getArg( 10 ) );
 
     msgInfo.setText( "" );
     theMsg.setText( "" );
@@ -97,14 +101,6 @@ public class messagePanel extends Panel {
     getMsgsPtrs();
   }
 
-  public int atoi( String s ) {
-    try {
-      return Integer.parseInt( s );
-    } catch( Exception e ) {
-      return 0;
-    }
-  }
-
   public void getMsgsPtrs() {
     msgs = null;
     String     which = "new";
@@ -171,7 +167,7 @@ public class messagePanel extends Panel {
     msgInfo.setText( sum );
     theMsg.setText( r.getData() ); /* this relies on the fact that we've removed the header lines above.  probably a messy way to deal with references. */
 
-    int        n = atoi( num );
+    int        n = citadel.atoi( num );
     if( n > highest_read ) {
       highest_read = n;
       citadel.me.getReply( "SLRP " + num );
index 0ee98fb264bc3f9274d3e6d4f2f2c295b0d713c2..d6ded6dadc9be2def934bcf199353b73a8ea1eed 100644 (file)
@@ -18,7 +18,7 @@ public class net {
     theServer = null;
   }
 
-  public void println( String s ) {
+  private void println( String s ) {
     System.out.println( ">" + s );
     try {
       if( theServer != null )
@@ -32,7 +32,7 @@ public class net {
     }
   }
 
-  public String readLine( ) {
+  private String readLine( ) {
     try {
       if( theServer != null ) {
        String s = in.readLine();
@@ -76,10 +76,14 @@ public class net {
   }
 
   public citReply getReply() {
-    return getReply( (String)null );
+    return getReply( (String)null, (String)null );
   }
 
   public citReply getReply( String cmd ) {
+    return getReply( cmd, (String)null );
+  }
+
+  public citReply getReply( String cmd, String data ) {
     if( cmd != null ) println( cmd );
 
     citReply r = new citReply( readLine() );
@@ -87,6 +91,12 @@ public class net {
       while( r.addData( readLine() ) ) ;
     }
 
+    if( r.sendListing() ) {
+      if( data != null )
+       println( data );
+      println( "000" );
+    }
+
     if( r.expressMessage() )
       citadel.me.expressMsg();
 
index 841b1efb7c6931978411c4b50657b492109b0e28..ce7da0b58f7dbdfd83d100c26d45673afed9fc8d 100644 (file)
@@ -77,12 +77,9 @@ public class pageWindow extends Frame {
       String m = msg.getText();
       if( m.length() > 0 ) {
        if( multi_line ) {
-         citReply      r = citadel.me.getReply( "SEXP " + user + "|-" );
-         if( r.sendListing() ) {
-           citadel.me.theNet.println( m );
-           citadel.me.theNet.println( "" );
-           citadel.me.theNet.println( "000" );
-         }
+         citReply      r = citadel.me.getReply( "SEXP " + user + "|-", m + "\n"  );
+         if( r.error() )
+           citadel.me.error( r );
        } else
          citadel.me.getReply( "SEXP " + user + "|" + m );
       }
index ed332049652243f76fa97da7164d2fbe0d0bb1e2..01b677b15a8c686e2cea96bff5e547ec9116cf01 100644 (file)
@@ -37,15 +37,8 @@ public class passwordWindow extends Frame {
   public boolean action( Event e, Object o ) {
     if( (e.target == text) || (e.target instanceof Button) ) {
       String   s = text.getText();
-      citReply r = citadel.me.getReply( "GOTO " + room + " " + s );
-      if( r.ok() ) {
-       citadel.me.cp.mp.visited( room );
-       citadel.me.cp.enterRoom( r );
-       dispose();
-      } else {
-       dispose();
-       new passwordWindow( room );
-      }
+      dispose();
+      citadel.me.enterRoom( room, s );
     }
     return super.action( e, o );
   }
index 68e4033a2290b5d0b4b1602c82de8f5b5a671bfe..955e0406b0c44a70b50fba8c2a719f9b703ba5aa 100644 (file)
@@ -14,29 +14,20 @@ public class server {
   String       blurb;
 
   public server( citReply r ) {
-    session_id = atoi( r.getLine( 0 ) );
+    session_id = citadel.atoi( r.getLine( 0 ) );
     node_name = r.getLine( 1 );
     human_name = r.getLine( 2 );
     fqdn = r.getLine( 3 );
     server_name = r.getLine( 4 );
-    rev_level = atoi( r.getLine( 5 ) );
+    rev_level = citadel.atoi( r.getLine( 5 ) );
     geo_local = r.getLine( 6 );
     sysadmin = r.getLine( 7 );
-    server_type = atoi( r.getLine( 8 ) );
+    server_type = citadel.atoi( r.getLine( 8 ) );
     page_prompt = r.getLine( 9 );
-    floor_flag = atoi( r.getLine( 10 ) );
-    page_level = atoi( r.getLine( 11 ) );
+    floor_flag = citadel.atoi( r.getLine( 10 ) );
+    page_level = citadel.atoi( r.getLine( 11 ) );
 
     blurb = server_name + " " + human_name + " " + geo_local;
     System.out.println( blurb );
   }
-
-  public int atoi( String s ) {
-    if( s == null ) return 0;
-
-    try {
-      return Integer.parseInt( s );
-    } catch( NumberFormatException nfe ) {};
-    return 0;
-  }
 }
index 752c303500960912c28404334441dd6312325956..617488d3a0bb993aa73d3bf3a5d5dd78b2e32ef7 100644 (file)
@@ -13,23 +13,14 @@ public class user {
 
   public user( citReply r ) {
     username = r.getArg( 0 );
-    access = atoi( r.getArg( 1 ) );
-    call = atoi( r.getArg( 2 ) );
-    msg = atoi( r.getArg( 3 ) );
-    flags = atoi( r.getArg( 4 ) );
-    num = atoi( r.getArg( 5 ) );
+    access = citadel.atoi( r.getArg( 1 ) );
+    call = citadel.atoi( r.getArg( 2 ) );
+    msg = citadel.atoi( r.getArg( 3 ) );
+    flags = citadel.atoi( r.getArg( 4 ) );
+    num = citadel.atoi( r.getArg( 5 ) );
   }
 
   public boolean floors() {
     return (flags & FLOORS)==FLOORS;
   }
-
-  public int atoi( String s ) {
-    if( s == null ) return 0;
-
-    try {
-      return Integer.parseInt( s );
-    } catch( NumberFormatException nfe ) {};
-    return 0;
-  }
 }