more toys

This commit is contained in:
Cary Sandvig 2000-11-16 00:15:38 +00:00
parent 20a6f604b3
commit d038acc35d
4 changed files with 82 additions and 2 deletions

View File

@ -185,6 +185,29 @@ void GuiFrame::add_item(GuiItem* item) {
}
}
void GuiFrame::remove_item(GuiItem* item) {
Boxes::iterator i = find_box(item);
if (i == _items.end())
return;
(*i).erase_all_links();
// should NEVER link forward in the items, only backward, so it should be
// safe to start here, and go to the end
for (Boxes::iterator j=i+1; j!=_items.end(); ++j) {
bool done;
do {
done = true;
for (int k=0; k<(*j).get_num_links(); ++k)
if ((*j).get_nth_to(k) == item) {
done = false;
(*j).erase_nth_link(k);
break;
}
} while (!done);
}
// now get rid of the thing itself
_items.erase(i);
}
void GuiFrame::pack_item(GuiItem* item, Packing rel, GuiItem* to, float gap) {
Boxes::iterator box = find_box(item);
if (box == _items.end()) {

View File

@ -76,6 +76,7 @@ public:
~GuiFrame(void);
void add_item(GuiItem*);
void remove_item(GuiItem*);
void pack_item(GuiItem*, Packing, GuiItem*, float = 0.);
void clear_packing(GuiItem*);
void clear_all_packing(void);

View File

@ -5,7 +5,18 @@
#include "framework.h"
void deadrec_keys(EventHandler& eh) {
static void deadrec_setup(void) {
static bool done = false;
if (done)
return;
// load smiley and put it in the scenegraph
smiley = ModelPool::load_model("smiley");
nassertv(smiley != (Node*)0L);
my_arc = new RenderRelation(render, smiley);
}
static void deadrec_keys(EventHandler& eh) {
deadrec_setup();
}
int main(int argc, char* argv[]) {

View File

@ -5,7 +5,52 @@
#include "framework.h"
void deadrec_keys(EventHandler& eh) {
#include <dconfig.h>
NotifyCategoryDecl(deadrec, EXPCL_MISC, EXPTP_MISC);
NotifyCategoryDef(deadrec, "");
Configure(deadrec);
ConfigureFn(deadrec) {
}
static PT_Node smiley;
static RenderRelation* my_arc;
string hostname = deadrec.GetString("deadrec-rec", "localhost");
int hostport = deadrec.GetInt("deadrec-rec-port", 0xdead);
static QueuedConnectionManager cm;
PT(Connection) conn;
ConnectionWriter* writer;
static void deadrec_setup(void) {
static bool done = false;
if (done)
return;
// load smiley and put it in the scenegraph
smiley = ModelPool::load_model("smiley");
nassertv(smiley != (Node*)0L);
my_arc = new RenderRelation(render, smiley);
// open a connection to the receiver
NetAddress host;
if (!host.set_host(hostname, port)) {
deadrec_cat->fatal() << "Unknown host: " << hostname << endl;
exit();
}
conn = cm.open_TCP_client_connection(host, 5000);
if (conn.is_null()) {
deadrec_cat->fatal() << "no connection." << endl;
exit();
}
if (deadrec->is_debug())
deadrec->debug() << "opened TCP connection to " << hostname << " on port "
<< c->get_address().get_port() << " and IP "
<< c->get_address() << endl;
writer = new ConnectionWriter(&cm, 0);
static void deadrec_keys(EventHandler& eh) {
deadrec_setup();
}
int main(int argc, char* argv[]) {