]> code.citadel.org Git - citadel.git/commitdiff
Got the room list basically working
authorArt Cancro <ajc@citadel.org>
Mon, 15 Mar 1999 00:00:32 +0000 (00:00 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 15 Mar 1999 00:00:32 +0000 (00:00 +0000)
daphne/includes.hpp
daphne/main.cpp
daphne/utils.cpp

index 17c1a7d3f603349a490a777c686223b270ebbdd6..6d76bf701f2d8bc38ee7bae33e3903e86e5e1e98 100644 (file)
@@ -202,6 +202,7 @@ private:
 void ListToMultiline(wxString& outputbuf, wxStringList inputlist);
 void MultilineToList(wxStringList& outputlist, wxString inputbuf);
 void extract(wxString& outputbuf, wxString inputbuf, int parmnum);
+int extract_int(wxString inputbuf, int parmnum);
 void load_roomlist(wxTreeCtrl *tree, CitClient *citsock);
 
 
index 48d1273010f35b2eea68aa6a2ab855ed63f62faa..b3b4c0954bd5fadd3f4ae52b15dedfd696f860f2 100644 (file)
@@ -177,13 +177,13 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
         wxLayoutConstraints *t2 = new wxLayoutConstraints;
         t2->top.SameAs(this, wxTop, 4);
         t2->left.SameAs(this, wxLeft, 0);
-       t2->right.PercentOf(this, wxWidth, 20);
+       t2->right.PercentOf(this, wxWidth, 25);
         t2->bottom.SameAs(this, wxBottom, 0);
         RoomList->SetConstraints(t2);
 
        wxLayoutConstraints *t3 = new wxLayoutConstraints;
        t3->top.SameAs(this, wxTop, 4);
-       t3->left.PercentOf(this, wxWidth, 20);
+       t3->left.PercentOf(this, wxWidth, 25);
        t3->right.SameAs(this, wxRight, 0);
        t3->bottom.SameAs(this, wxBottom, 0);
        wxMDIClientWindow *children = GetClientWindow();
index 43f01898dd022f437a44cdeb097185845c79d121..2a76b00e4cb09678680ce945d930b4f0c16957f5 100644 (file)
@@ -3,6 +3,7 @@
 #include <wx/wx.h>
 #include "includes.hpp"
 
+wxTreeItemId floorboards[128];
 
 // The following two functions convert between the wxStringList class used for
 // text transfers to and from the Citadel server, and the wxString class used
@@ -73,11 +74,21 @@ void extract(wxString& outputbuf, wxString inputbuf, int parmnum) {
        }
 }
 
+int extract_int(wxString inputbuf, int parmnum) {
+       wxString buf;
+
+       extract(buf, inputbuf, parmnum);
+       return atoi(buf);
+}
+
 
 
 // Load a tree with a room list
 //
 void load_roomlist(wxTreeCtrl *tree, CitClient *citsock) {
+       wxString sendcmd, recvcmd, buf, floorname, roomname;
+       wxStringList transbuf;
+       int i, floornum;
 
        // First, clear it out.
        tree->DeleteAllItems();
@@ -89,4 +100,37 @@ void load_roomlist(wxTreeCtrl *tree, CitClient *citsock) {
                -1,
                NULL);
 
+       sendcmd = "LFLR";
+       // Bail out silently if we can't retrieve the floor list
+       if (citsock->serv_trans(sendcmd, recvcmd, transbuf) != 1) return;
+
+       // Load the floors one by one onto the tree
+        for (i=0; i<transbuf.Number(); ++i) {
+                buf.Printf("%s", (wxString *)transbuf.Nth(i)->GetData());
+               extract(floorname, buf, 1);
+               floornum = extract_int(buf, 0);
+               floorboards[floornum] = tree->AppendItem(
+                       tree->GetRootItem(),
+                       floorname,
+                       -1,     // FIX use a floor pixmap here
+                       -1,
+                       NULL);
+       }
+
+       // Load the rooms into the tree
+       // FIX (do this in two passes, one for LKRN and one for LKRO)
+
+       sendcmd = "LKRA";
+       if (citsock->serv_trans(sendcmd, recvcmd, transbuf) != 1) return;
+        for (i=0; i<transbuf.Number(); ++i) {
+                buf.Printf("%s", (wxString *)transbuf.Nth(i)->GetData());
+               extract(roomname, buf, 0);
+               floornum = extract_int(buf, 2);
+               tree->AppendItem(
+                       floorboards[floornum],
+                       roomname,
+                       -1,     // FIX use a room pixmap here
+                       -1,
+                       NULL);
+       }
 }