From: Andrew C. <ac...@us...> - 2002-10-13 03:16:15
|
Update of /cvsroot/planeshift/planeshift/src/client/admin In directory usw-pr-cvs1:/tmp/cvs-serv23329/src/client/admin Modified Files: Makefile.am psadminmanager.cpp psadminmanager.h Added Files: psitemeditor.cpp psitemeditor.h Log Message: Added in 'Add items' to admin console and some general clean ups --- NEW FILE: psitemeditor.cpp --- #include <config.h> #include <iutil/string.h> #include "csutil/scfstr.h" #include "iutil/object.h" #include <pl/pl.h> #include <bl/bl.h> #include <pl/entity.h> #include <pl/propfact.h> #include "../pscelclient.h" #include "psitemeditor.h" #include "iclient/psengine.h" #include "admin/adminmessage.h" #include "util/psxmlparser.h" #include "iaws/awsparm.h" #include "psprop/pc/pspcproxlist.h" psItemEditor::psItemEditor( iAws* AWS ) { aws = AWS; mainWindow = NULL; csRef<iPSEngine> psengine; psengine = CS_QUERY_REGISTRY(aws->GetObjectRegistry(), iPSEngine); msgHandler = psengine->GetMsgHandler(); } psItemEditor::~psItemEditor() { } bool psItemEditor::Launch() { if ( !mainWindow ) { sink = aws->GetSinkMgr()->CreateSink(this); sink->RegisterTrigger("SelectionChanged", &psItemEditor::SelectItem); sink->RegisterTrigger("CreateItem", &psItemEditor::CreateItem); sink->RegisterTrigger("UseCurrentPos", &psItemEditor::UseCurrentPos); aws->GetSinkMgr()->RegisterSink("ItemEditor", sink); aws->GetPrefMgr()->Load("/planeshift/data/itemadmin.def"); mainWindow = aws->CreateWindowFrom("Item Admin"); } if ( !mainWindow ) { return false; } psAdminMessage mesg( 0, ADMIN_ITEM_REQUEST_TYPES, NULL ); msgHandler->SendMessage(mesg.msg); mainWindow->Show(); return true; } void psItemEditor::Close() { if ( mainWindow ) { mainWindow->Hide(); mainWindow->FindChild("Items")->Execute("ClearList"); } } void psItemEditor::HandleMessage( MsgEntry* msg ) { psAdminMessage message(msg); switch ( message.command ) { case ADMIN_ITEM_REQUEST_TYPES: { psXMLString mainString ( message.data ); int start = mainString.FindTag("ITEM"); iAwsParmList *pl = NULL; pl = aws->CreateParmList(); iAwsComponent* comp = mainWindow->FindChild("Items"); do { csString name; psXMLTag tag(mainString, start); tag.GetTagParm("NAME", name); pl->AddString("text0", name); comp->Execute("InsertItem", pl); pl->Clear(); start = mainString.FindTag("ITEM", start+1); }while (start != -1); break; } } } void psItemEditor::SelectItem(void* sink, iAwsSource* source) { psItemEditor *editor = (psItemEditor*)sink; iAwsParmList *pl = editor->aws->CreateParmList(); iAwsComponent * comp = editor->mainWindow->FindChild("Items"); pl->AddString("text0", "empty"); comp->Execute("GetSelectedItem", pl); iString *string = new scfString(); pl->GetString("text0", &string); } void psItemEditor::CreateItem( void* sink, iAwsSource* source ) { psItemEditor *editor = (psItemEditor*)sink; editor->CreateItemV(); } void psItemEditor::CreateItemV() { printf ("Creating ITEM!\n"); // Get the name of the object to create: iAwsParmList* pl = aws->CreateParmList(); iAwsComponent * listbox = mainWindow->FindChild("Items"); pl->AddString("text0", "empty"); listbox->Execute("GetSelectedItem", pl); iString* itemName = new scfString(); pl->GetString("text0", &itemName ); float xpos, ypos, zpos; iString* pos; mainWindow->FindChild("XPos")->GetProperty("Text", (void**)&pos); xpos = atof(pos->GetData()); mainWindow->FindChild("YPos")->GetProperty("Text", (void**)&pos); ypos = atof(pos->GetData()); mainWindow->FindChild("ZPos")->GetProperty("Text", (void**)&pos); zpos = atof(pos->GetData()); iString* sector; mainWindow->FindChild("Sector")->GetProperty("Text", (void**)§or); char outBuffer[1024]; sprintf(outBuffer, "<NEWITEM NAME=\"%s\" " "X=\"%f\" " "Y=\"%f\" " "Z=\"%f\" " "SECTOR=\"%s\" />", itemName->GetData(), xpos,ypos,zpos, sector->GetData()); psAdminMessage outgoing( 0, ADMIN_ITEM_CREATE, outBuffer ); msgHandler->SendMessage(outgoing.msg); } void psItemEditor::UseCurrentPos(void* sink, iAwsSource*) { psItemEditor* editor = (psItemEditor*)sink; editor->UseCurrentPosV(); } void psItemEditor::UseCurrentPosV() { csRef<iPSEngine> psengine; psengine = CS_QUERY_REGISTRY(aws->GetObjectRegistry(), iPSEngine); csRef<iCelEntity> actor = psengine->GetCelClient()->GetMainActor(); csRef<iPcProximityList> proxList; proxList = CEL_QUERY_PROPCLASS(actor->GetPropertyClassList(), iPcProximityList); csVector3 pos; float yRot; iSector* sector; proxList->GetMeshPosition (actor,pos,yRot,sector); csRef<iString> xpos = new scfString(); csRef<iString> ypos = new scfString(); csRef<iString> zpos = new scfString(); csRef<iString> isector = new scfString(); xpos->Format("%f", pos.x); mainWindow->FindChild("XPos")->SetProperty("Text",(void*)xpos); ypos->Format("%f", pos.y); mainWindow->FindChild("YPos")->SetProperty("Text",(void*)ypos); zpos->Format("%f", pos.z); mainWindow->FindChild("ZPos")->SetProperty("Text",(void*)zpos); isector->Format("%s", sector->QueryObject()->GetName()); mainWindow->FindChild("Sector")->SetProperty("Text",(void*)isector); } --- NEW FILE: psitemeditor.h --- #include <csutil/ref.h> #include <csutil/objreg.h> #include <iaws/aws.h> // CEL INCLUDES #include <pl/pl.h> #include <bl/bl.h> #include <pl/entity.h> #include <pl/propfact.h> #include "psbehave/psbehave.h" #include "net/messages.h" #include "admin/adminmessage.h" #include "net/msghandler.h" /// This major class holds all the details about what is needed to create/ // modify/destroy items. class psItemEditor { public: psItemEditor( iAws *aws ); ~psItemEditor(); bool Launch(); void Close(); /// Handle any incomming messages void HandleMessage( MsgEntry*msg ); static void SelectItem( void* sink, iAwsSource* source ); static void CreateItem( void* sink, iAwsSource* source ); static void UseCurrentPos( void* sink, iAwsSource* source ); //private: csRef<MsgHandler> msgHandler; csRef<iAwsComponent> mainWindow; csRef<iAws> aws; csRef<iAwsSink> sink; protected: void CreateItemV(); void UseCurrentPosV(); }; Index: Makefile.am =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/admin/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile.am 27 Sep 2002 22:46:50 -0000 1.1 --- Makefile.am 13 Oct 2002 03:16:12 -0000 1.2 *************** *** 13,18 **** psadmin_la_LDFLAGS = -module -avoid-version -no-undefined psadmin_la_SOURCES = psadminmanager.h psadminmanager.cpp \ ! psadminmain.h psadminmain.cpp ! psadmin_la_LIBADD = --- 13,34 ---- psadmin_la_LDFLAGS = -module -avoid-version -no-undefined psadmin_la_SOURCES = psadminmanager.h psadminmanager.cpp \ ! psadminmain.h psadminmain.cpp \ ! psitemeditor.h psitemeditor.cpp ! ! psadmin_la_LIBADD = $(COMMONSRC)/psbehave/libpsbehave.la \ ! $(COMMONSRC)/admin/libpsadminnet.la \ ! $(COMMONSRC)/util/libpsutil.la \ ! $(COMMONSRC)/net/libpsnet.la ! + $(COMMONSRC)/psbehave/libpsbehave.la: + $(MAKE) -C $(COMMONSRC)/psbehave libpsbehave.la + + $(COMMONSRC)/admin/libpsadminnet.la: + $(MAKE) -C $(COMMONSRC)/admin libpsadminnet.la + $(COMMONSRC)/util/libpsutil.la: + $(MAKE) -C $(COMMONSRC)/util libpsutil.la + + $(COMMONSRC)/psnet/libpsnet.la: + $(MAKE) -C $(COMMONSRC)/psnet libpsnet.la Index: psadminmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/admin/psadminmanager.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** psadminmanager.cpp 27 Sep 2002 22:46:50 -0000 1.1 --- psadminmanager.cpp 13 Oct 2002 03:16:12 -0000 1.2 *************** *** 19,22 **** --- 19,23 ---- #include <config.h> #include "psadminmanager.h" + #include "iclient/psengine.h" CS_IMPLEMENT_PLUGIN *************** *** 33,36 **** --- 34,39 ---- mainToolBar = NULL; + itemEditor = NULL; + msgHandler = NULL; } *************** *** 46,50 **** } - bool psAdminManager::Open(int level) { --- 49,52 ---- *************** *** 63,67 **** return false; ! sink->RegisterTrigger("CloseWindow", &psAdminManager::CloseWindow); aws->GetSinkMgr()->RegisterSink("AdminManager", sink); } --- 65,82 ---- return false; ! /// Trigger to close the window. ! sink->RegisterTrigger("CloseWindow", ! &psAdminManager::CloseWindow); ! ! /// Trigger to launch the item editor window. ! sink->RegisterTrigger("StartItemEditor", ! &psAdminManager::StartItemEditor); ! ! ! sink->RegisterTrigger("CloseItemEditor", ! &psAdminManager::CloseItemEditor); ! ! ! aws->GetSinkMgr()->RegisterSink("AdminManager", sink); } *************** *** 75,78 **** --- 90,102 ---- mainToolBar->awsWindow->Show(); + if ( !msgHandler ) + { + csRef<iPSEngine> psengine; + psengine = CS_QUERY_REGISTRY(object_reg, iPSEngine); + msgHandler = psengine->GetMsgHandler(); + + msgHandler->Subscribe(this, MSGTYPEADMIN); + } + return true; } *************** *** 84,89 **** } ! void psAdminManager::HandleMessage (MsgEntry *) { return; } --- 108,125 ---- } ! void psAdminManager::HandleMessage (MsgEntry *me) { + printf("Got a message!\n"); + + psAdminMessage mesg(me); + switch ( mesg.command ) + { + case ADMIN_ITEM_REQUEST_TYPES: + { + itemEditor->HandleMessage(me); + break; + } + } + return; } *************** *** 95,98 **** --- 131,155 ---- } + void psAdminManager::StartItemEditor( void* sink, iAwsSource* ) + { + printf("Starting Item Editor\n"); + + psAdminManager* admin = (psAdminManager*)sink; + + if ( !admin->itemEditor ) + admin->itemEditor = new psItemEditor( admin->aws ); + if ( !admin->itemEditor ) + return; + + admin->itemEditor->Launch(); + } + + + void psAdminManager::CloseItemEditor( void* sink, iAwsSource* ) + { + psAdminManager* admin = (psAdminManager*)sink; + if ( admin->itemEditor ) + admin->itemEditor->Close(); + } // Export the class from the .so Index: psadminmanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/admin/psadminmanager.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** psadminmanager.h 27 Sep 2002 22:46:50 -0000 1.1 --- psadminmanager.h 13 Oct 2002 03:16:12 -0000 1.2 *************** *** 28,32 **** --- 28,34 ---- #include "interface/subscriber.h" + #include "psadminmain.h" + #include "psitemeditor.h" /// Planeshift Admin Manager *************** *** 35,39 **** public iNetSubscriber { ! public: psAdminManager(iBase* iParent); virtual ~psAdminManager(); --- 37,41 ---- public iNetSubscriber { ! public: psAdminManager(iBase* iParent); virtual ~psAdminManager(); *************** *** 51,62 **** static void CloseWindow( void* sink, iAwsSource* source ); SCF_DECLARE_IBASE; protected: - csRef<iAws> aws; - csRef<iObjectRegistry> object_reg; csRef<iAwsSink> sink; ! psMainAdminWindow* mainToolBar; --- 53,71 ---- static void CloseWindow( void* sink, iAwsSource* source ); + + //launches the ItemEditor Window + static void StartItemEditor( void* sink, iAwsSource* source ); + static void CloseItemEditor( void* sink, iAwsSource* source ); SCF_DECLARE_IBASE; + /// Public for use by static member functions + psItemEditor* itemEditor; + csRef<iAws> aws; + protected: csRef<iAwsSink> sink; ! csRef<iObjectRegistry> object_reg; ! csRef<MsgHandler> msgHandler; psMainAdminWindow* mainToolBar; |