From: Andrew C. <ac...@us...> - 2002-08-11 23:28:19
|
Update of /cvsroot/planeshift/planeshift/src/client/aws In directory usw-pr-cvs1:/tmp/cvs-serv29927/src/client/aws Modified Files: psaws.cpp pscomp.cpp pscomp.h psinventorywindow.cpp psinventorywindow.h Log Message: Updated the inventory window a little Index: psaws.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/aws/psaws.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** psaws.cpp 8 Aug 2002 14:13:56 -0000 1.17 --- psaws.cpp 11 Aug 2002 23:28:16 -0000 1.18 *************** *** 234,237 **** --- 234,240 ---- aws->RegisterComponentFactory(cmdInp, "PS TextInput"); + + psComponentImageFactory* imgFact = new psComponentImageFactory(aws); + aws->RegisterComponentFactory(imgFact, "PS Image"); } Index: pscomp.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/aws/pscomp.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pscomp.cpp 8 Aug 2002 14:13:56 -0000 1.14 --- pscomp.cpp 11 Aug 2002 23:28:16 -0000 1.15 *************** *** 540,543 **** --- 540,637 ---- } + //------------------------------------------------------------------- + SCF_IMPLEMENT_IBASE(psComponentImage) + SCF_IMPLEMENTS_INTERFACE (iAwsComponent) + SCF_IMPLEMENTS_INTERFACE (iBase) + SCF_IMPLEMENT_IBASE_END + //------------------------------------------------------------------- + psComponentImage::psComponentImage() + { + } + + psComponentImage::~psComponentImage() + { + } + + const char* psComponentImage::Type() + { + return "PS Image"; + } + + bool psComponentImage::Setup( iAws* wmgr, iAwsComponentNode* settings ) + { + if (!awsEmbeddedComponent::Setup( wmgr, settings )) return false; + + iAwsPrefManager* pm = WindowManager()->GetPrefMgr(); + + pm->GetInt(settings, "Alpha", alpha_level ); + + iString* textureName; + pm->GetString( settings,"Image", textureName ); + if ( textureName ) + { + imageTexture = pm->GetTexture( textureName->GetData(), + textureName->GetData()); + + image = new csSimplePixmap(imageTexture); + } + else + return false; + + if ( !pm->GetRect( settings, "Rect", imageRect ) ) + imageRect = Frame(); + + return true; + } + + + void psComponentImage::OnDraw( csRect clip ) + { + iGraphics3D *g3d = WindowManager()->G3D(); + image->DrawScaled( g3d, + Frame().xmin, + Frame().ymin, + Frame().Width(), + Frame().Height(), + alpha_level ); + } + + + //------------------------------------------------------------------- + SCF_IMPLEMENT_IBASE (psComponentImageFactory) + SCF_IMPLEMENTS_INTERFACE (iAwsComponentFactory) + SCF_IMPLEMENTS_INTERFACE (iBase) + SCF_IMPLEMENT_IBASE_END + //------------------------------------------------------------------- + psComponentImageFactory::psComponentImageFactory ( iAws* mgr ) + : awsEmbeddedComponentFactory(mgr) + { + SCF_CONSTRUCT_IBASE( NULL ); + Register("PS Image"); + } + + + psComponentImageFactory::~psComponentImageFactory() + { + } + + + iAwsComponent* psComponentImageFactory::Create() + { + psComponentImage* image = new psComponentImage(); + + + iAwsComponent* comp = wmgr->CreateEmbeddableComponent(); + CS_ASSERT( comp != NULL ); + + image->Initialize(comp); + + return image; + } + + + + + /*-----------------------------------------------------*/ Index: pscomp.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/aws/pscomp.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pscomp.h 8 Aug 2002 12:35:09 -0000 1.11 --- pscomp.h 11 Aug 2002 23:28:16 -0000 1.12 *************** *** 21,28 **** #define PS_AWS_COMPONENTS #include <iaws/aws.h> #include <iaws/awsecomp.h> #include <csutil/garray.h> ! #include <../../../CS/plugins/aws/awskcfct.h> /// Basic PlaneShift GUI component. --- 21,30 ---- #define PS_AWS_COMPONENTS + #include <cstool/cspixmap.h> + #include <iaws/aws.h> #include <iaws/awsecomp.h> #include <csutil/garray.h> ! //#include <../../../CS/plugins/aws/awskcfct.h> /// Basic PlaneShift GUI component. *************** *** 218,222 **** --- 220,272 ---- //------------------------------------------------------------------ + /// A GUI component that will allow us to draw an image. + /** This component offers more control over the basic AWS image + * view which does not respect the alpha values. + */ + class psComponentImage : public psGUIComponent + { + public: + SCF_DECLARE_IBASE; + + psComponentImage(); + ~psComponentImage(); + + virtual bool Setup( iAws* wmgr, iAwsComponentNode* settings ); + virtual const char* Type(); + + virtual void OnDraw( csRect clip ); + private: + + /// Holds the texture handle for the image we are drawing. + iTextureHandle* imageTexture; + + /// Holds the simple pixmap details. + csSimplePixmap* image; + + /// Holds the alpha value to use to draw this component + int alpha_level; + + /// Holds the rect to use from the image. + csRect imageRect; + }; + + + //------------------------------------------------------------------ + /// A factory to construct the image component. + class psComponentImageFactory : public awsEmbeddedComponentFactory + { + public: + SCF_DECLARE_IBASE; + + psComponentImageFactory(iAws* mgr); + virtual ~psComponentImageFactory(); + + iAwsComponent* Create(); + }; + //------------------------------------------------------------------ + + + //------------------------------------------------------------------ class awsComponentNode; /** Index: psinventorywindow.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/aws/psinventorywindow.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** psinventorywindow.cpp 9 Aug 2002 11:46:00 -0000 1.5 --- psinventorywindow.cpp 11 Aug 2002 23:28:16 -0000 1.6 *************** *** 48,63 **** } - void psInventoryWindow::Close(void* sink, iAwsSource*) - { - psInventoryWindow* window = (psInventoryWindow*)sink; - window->GetAWSWindow()->Hide(); - } - void psInventoryWindow::CreateSink(iAws* aws) { sink = aws->GetSinkMgr()->CreateSink(this); sink->RegisterTrigger("Close", &psInventoryWindow::Close); ! aws->GetSinkMgr()->RegisterSink("InventoryWindow", sink); } --- 48,62 ---- } void psInventoryWindow::CreateSink(iAws* aws) { sink = aws->GetSinkMgr()->CreateSink(this); + sink->RegisterTrigger("Close", &psInventoryWindow::Close); ! sink->RegisterTrigger("Stats", &psInventoryWindow::Stats); ! sink->RegisterTrigger("Equipment", &psInventoryWindow::Equipment); ! sink->RegisterTrigger("Bulk", &psInventoryWindow::Bulk); ! ! aws->GetSinkMgr()->RegisterSink("InventoryWindow", sink); } *************** *** 74,77 **** --- 73,84 ---- mainWindow->Hide(); + + // Get some of the children for quick access. + statFrame = mainWindow->FindChild("Stats Frame"); + equipFrame = mainWindow->FindChild("Equipment Frame"); + bulkFrame = mainWindow->FindChild("Bulk Frame"); + controller = mainWindow->FindChild("Inventory Controller"); + + return true; } *************** *** 82,85 **** --- 89,95 ---- printf("[psInventoryWindow::SendCommand(%s)\n", cmd); + /* When the inventory window is opened it has to send a request to the + * server to ask to get the inventory. + */ if ( !strcmp(cmd, "Open") ) { *************** *** 105,108 **** --- 115,119 ---- } + return true; } *************** *** 111,117 **** void psInventoryWindow::HandleMessage( MsgEntry* me ) { ! printf("[psInventoryWindow::HandleMessage( MsgEntry* me )]\n"); psGUIInventoryMessage incomming(me); printf(" Player Inventory is: %s\n", (const char*)incomming.inventoryXML); } --- 122,253 ---- void psInventoryWindow::HandleMessage( MsgEntry* me ) { ! /* The only incomming messages should be the inventory list. This will be ! * used to build the inventory window. It can keep a reference to the last ! * inventory string it was sent and if the new one is different then ! * rebuild ! */ psGUIInventoryMessage incomming(me); printf(" Player Inventory is: %s\n", (const char*)incomming.inventoryXML); } + + void psInventoryWindow::Stats() + { + int resizeWidth = mainWindow->Frame().Width(); + + /// Shift the other panels left or right + if ( statFrame->isHidden() ) + { + statFrame->Show(); + ShiftRight( equipFrame, statFrame->Frame().Width() ); + ShiftRight( bulkFrame, statFrame->Frame().Width() ); + ShiftRight( controller, statFrame->Frame().Width()/2 ); + resizeWidth+= statFrame->Frame().Width(); + } + else + { + // Make sure that there is at least one window open + if ( equipFrame->isHidden() && bulkFrame->isHidden() ) + return; + + ShiftLeft( equipFrame, statFrame->Frame().Width() ); + ShiftLeft( bulkFrame, statFrame->Frame().Width() ); + ShiftLeft( controller, statFrame->Frame().Width()/2 ); + resizeWidth-= statFrame->Frame().Width(); + + statFrame->Hide(); + } + + // Adjust the window accordingly + mainWindow->Resize( resizeWidth, mainWindow->Frame().Height() ); + + } + + void psInventoryWindow::Equipment() + { + int resizeWidth = mainWindow->Frame().Width(); + if ( equipFrame->isHidden() ) + { + equipFrame->Show(); + ShiftRight( bulkFrame, equipFrame->Frame().Width() ); + ShiftRight( controller, equipFrame->Frame().Width()/2 ); + resizeWidth+= equipFrame->Frame().Width(); + } + else + { + // Make sure that there is at least one window open + if ( statFrame->isHidden() && bulkFrame->isHidden() ) + return; + + ShiftLeft( bulkFrame, equipFrame->Frame().Width() ); + ShiftLeft( controller, equipFrame->Frame().Width()/2 ); + equipFrame->Hide(); + resizeWidth-= equipFrame->Frame().Width(); + } + + // Adjust the window accordingly + mainWindow->Resize( resizeWidth, mainWindow->Frame().Height() ); + } + + void psInventoryWindow::Bulk() + { + int resizeWidth = mainWindow->Frame().Width(); + if ( bulkFrame->isHidden() ) + { + bulkFrame->Show(); + ShiftRight( controller, bulkFrame->Frame().Width()/2 ); + resizeWidth+= bulkFrame->Frame().Width(); + } + else + { + // Make sure that there is at least one window open + if ( statFrame->isHidden() && equipFrame->isHidden() ) + return; + + + bulkFrame->Hide(); + ShiftLeft( controller, bulkFrame->Frame().Width()/2 ); + resizeWidth-= bulkFrame->Frame().Width(); + } + mainWindow->Resize( resizeWidth, mainWindow->Frame().Height() ); + } + + //------------------------------------------------------------------- + // Function Pointers + //------------------------------------------------------------------- + void psInventoryWindow::Close(void* sink, iAwsSource*) + { + psInventoryWindow* window = (psInventoryWindow*)sink; + window->GetAWSWindow()->Hide(); + } + + void psInventoryWindow::Stats(void* sink, iAwsSource*) + { + psInventoryWindow* window = (psInventoryWindow*)sink; + window->Stats(); + } + + void psInventoryWindow::Equipment(void* sink, iAwsSource*) + { + psInventoryWindow* window = (psInventoryWindow*)sink; + window->Equipment(); + } + + void psInventoryWindow::Bulk(void* sink, iAwsSource*) + { + psInventoryWindow* window = (psInventoryWindow*)sink; + window->Bulk(); + } + //------------------------------------------------------------------- + + + + void psInventoryWindow::ShiftRight( iAwsComponent* comp, int amount ) + { + comp->Move( amount, 0 ); + } + + void psInventoryWindow::ShiftLeft( iAwsComponent* comp, int amount ) + { + comp->Move( -amount, 0 ); + } Index: psinventorywindow.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/aws/psinventorywindow.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** psinventorywindow.h 17 Jul 2002 23:19:21 -0000 1.3 --- psinventorywindow.h 11 Aug 2002 23:28:16 -0000 1.4 *************** *** 34,37 **** --- 34,39 ---- /// Inventory Window. + /* This handles all the details about how the inventory works. + */ class psInventoryWindow : public iPSWindow { *************** *** 44,47 **** --- 46,51 ---- bool SendCommand( const char* cmd, void* ); + + /// Handles messages from the server. void HandleMessage( MsgEntry* me ); *************** *** 52,56 **** --- 56,75 ---- void CreateSink(iAws* aws); + /// Funtion Pointers static void Close(void* sink, iAwsSource* source); + static void Stats( void* sink, iAwsSource* source ); + static void Equipment( void* sink, iAwsSource* source ); + static void Bulk( void* sink, iAwsSource* source ); + + + /// Toggle the stats frame. + void Stats(); + + // Toggle the equipment ( and quick slots ) frame. + void Equipment(); + + // Toggle the bulk storage frame. + void Bulk(); + /// Holds the main graphics AWS window. iAwsWindow* mainWindow; *************** *** 63,71 **** iAwsSink* sink; ! /// Holds the message handle MsgHandler* msgHandler; /// Usefull for getting stuff. iObjectRegistry* object_reg; }; --- 82,110 ---- iAwsSink* sink; ! /// Holds the message handle only used for outgoing calls. ! /* psAwsManager handles all incomming calls to the GUI ! */ MsgHandler* msgHandler; /// Usefull for getting stuff. iObjectRegistry* object_reg; + + /// Shift the component along. Used when frames are open/closed. + void ShiftRight( iAwsComponent* comp, int amount ); + + /// Shift the component along. Used when frames are open/closed. + void ShiftLeft ( iAwsComponent* comp, int amount ); + + /// Holds the statistic frame for quick access + iAwsComponent* statFrame; + + /// Holds the Equipment Frame for quick access + iAwsComponent* equipFrame; + + /// Holds the Bulk Storage Frame for quick access + iAwsComponent* bulkFrame; + + /// Holds the controller for quick access. + iAwsComponent* controller; }; |