From: Keith F. <ven...@us...> - 2007-01-12 23:47:18
|
Update of /cvsroot/planeshift/planeshift/src/client/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17107/src/client/gui Modified Files: pawsilluminationwindow.cpp pawsilluminationwindow.h Log Message: - Added basic sketch/map functionality to server and client. Basic primitives supported are: icon, text, startPoint and lineTo. I will add the required art to svn as well today or tomorrow. Right-click on the Treasure Map in Vengeance inventory to see the map. Index: pawsilluminationwindow.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/gui/pawsilluminationwindow.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pawsilluminationwindow.cpp 27 Dec 2006 03:10:53 -0000 1.4 --- pawsilluminationwindow.cpp 12 Jan 2007 23:47:16 -0000 1.5 *************** *** 55,58 **** --- 55,75 ---- } + iGraphics2D *pawsSketchWindow::GetG2D() + { + csRef<iGraphics2D> gfx = PawsManager::GetSingleton().GetGraphics2D(); + return gfx; + } + + void pawsSketchWindow::SetLineStart(int x, int y) + { + lineStartX = x; + lineStartY = y; + } + void pawsSketchWindow::GetLineStart(int &x, int &y) + { + x = lineStartX; + y = lineStartY; + } + void pawsSketchWindow::HandleMessage( MsgEntry* me ) { *************** *** 64,73 **** --- 81,103 ---- } + void pawsSketchWindow::Draw() + { + pawsWidget::Draw(); + + // The close button X overrides the clip region so we have to set it back here + ClipToParent(); + + DrawSketch(); + } void pawsSketchWindow::DrawSketch() { + for (size_t i=0; i<objlist.Length(); i++) + objlist[i]->Draw(); } bool pawsSketchWindow::ParseSketch(const char *xmlstr) { + SetLineStart(0,0); // Guard against missing start points in the sketch def + csRef<iDocumentSystem> xml; xml = csQueryRegistry<iDocumentSystem> ( psengine->GetObjectRegistry() ); *************** *** 102,106 **** while (pagenodes->HasNext() ) { ! SketchObject *obj; csRef<iDocumentNode> tmp = pagenodes->Next(); csString type = tmp->GetValue(); --- 132,136 ---- while (pagenodes->HasNext() ) { ! SketchObject *obj=NULL; csRef<iDocumentNode> tmp = pagenodes->Next(); csString type = tmp->GetValue(); *************** *** 110,123 **** else if (type == "tx") // text obj = new SketchText; else return false; ! // Now load it ! if (!obj->Load(tmp)) { ! delete obj; ! return false; } - objlist.Push(obj); } /// TODO: Support multiple pages here. --- 140,162 ---- else if (type == "tx") // text obj = new SketchText; + else if (type == "back") // background specifier + ; // do nothing + else if (type == "ls") + obj = new SketchPoint; + else if (type == "lt") + obj = new SketchLineTo; else return false; ! if (obj) { ! // Now load it ! if (!obj->Load(tmp,this)) ! { ! delete obj; ! return false; ! } ! objlist.Push(obj); } } /// TODO: Support multiple pages here. *************** *** 126,137 **** } ! bool pawsSketchWindow::SketchIcon::Load(iDocumentNode *node) { x = node->GetAttributeValueAsInt("x"); y = node->GetAttributeValueAsInt("y"); ! if (!node->GetAttributeValue("icon")) return false; ! str = node->GetAttributeValue("icon"); // TODO: Convert to common_strings printf("Icon %s at (%d,%d)\n",str.GetDataSafe(),x,y); return true; } --- 165,189 ---- } ! bool pawsSketchWindow::SketchIcon::Load(iDocumentNode *node, pawsSketchWindow *parent) { x = node->GetAttributeValueAsInt("x"); y = node->GetAttributeValueAsInt("y"); ! if (!node->GetAttributeValue("i")) return false; ! str = node->GetAttributeValue("i"); // TODO: Convert to common_strings ! ! psImageDescription * des = PawsManager::GetSingleton().GetTextureManager()->GetImageDescription( str ); ! if (!des) ! return false; ! ! iconImage = new pawsImage; ! iconImage->SetDescription( des ); ! printf("Icon %s at (%d,%d)\n",str.GetDataSafe(),x,y); + + x += parent->ScreenFrame().xmin; + y += parent->ScreenFrame().ymin; + this->parent = parent; + return true; } *************** *** 139,152 **** void pawsSketchWindow::SketchIcon::Draw() { } ! bool pawsSketchWindow::SketchText::Load(iDocumentNode *node) { x = node->GetAttributeValueAsInt("x"); y = node->GetAttributeValueAsInt("y"); ! if (!node->GetAttributeValue("text")) return false; ! str = node->GetAttributeValue("text"); // TODO: Convert to common_strings printf("Text %s at (%d,%d)\n",str.GetDataSafe(),x,y); return true; } --- 191,209 ---- void pawsSketchWindow::SketchIcon::Draw() { + iconImage->Draw(x,y); } ! bool pawsSketchWindow::SketchText::Load(iDocumentNode *node, pawsSketchWindow *parent) { x = node->GetAttributeValueAsInt("x"); y = node->GetAttributeValueAsInt("y"); ! if (!node->GetAttributeValue("t")) return false; ! str = node->GetAttributeValue("t"); // TODO: Convert to common_strings printf("Text %s at (%d,%d)\n",str.GetDataSafe(),x,y); + + x += parent->ScreenFrame().xmin; + y += parent->ScreenFrame().ymin; + this->parent = parent; return true; } *************** *** 154,157 **** --- 211,261 ---- void pawsSketchWindow::SketchText::Draw() { + parent->DrawWidgetText(str,x,y); + } + + bool pawsSketchWindow::SketchPoint::Load(iDocumentNode *node, pawsSketchWindow *parent) + { + x = node->GetAttributeValueAsInt("x"); + y = node->GetAttributeValueAsInt("y"); + printf("Point at (%d,%d)\n",x,y); + + x += parent->ScreenFrame().xmin; + y += parent->ScreenFrame().ymin; + this->parent = parent; + return true; + } + + void pawsSketchWindow::SketchPoint::Draw() + { + parent->SetLineStart(x,y); + } + + bool pawsSketchWindow::SketchLineTo::Load(iDocumentNode *node, pawsSketchWindow *parent) + { + x = node->GetAttributeValueAsInt("x"); + y = node->GetAttributeValueAsInt("y"); + printf("LineTo (%d,%d)\n",x,y); + + x += parent->ScreenFrame().xmin; + y += parent->ScreenFrame().ymin; + this->parent = parent; + return true; } + void pawsSketchWindow::SketchLineTo::Draw() + { + iGraphics2D *graphics2D = parent->GetG2D(); + + int startX, startY; + int black = graphics2D->FindRGB( 0,0,0 ); + + parent->GetLineStart(startX,startY); + + graphics2D->DrawLine( startX, + startY, + x, + y, + black ); + + parent->SetLineStart(x,y); + } Index: pawsilluminationwindow.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/gui/pawsilluminationwindow.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pawsilluminationwindow.h 21 Dec 2006 19:42:13 -0000 1.3 --- pawsilluminationwindow.h 12 Jan 2007 23:47:16 -0000 1.4 *************** *** 32,42 **** int x,y; csString str; ! virtual bool Load(iDocumentNode *node)=0; virtual void Draw()=0; }; struct SketchIcon : public SketchObject { ! virtual bool Load(iDocumentNode *node); virtual void Draw(); }; --- 32,44 ---- int x,y; csString str; + pawsSketchWindow *parent; ! virtual bool Load(iDocumentNode *node, pawsSketchWindow *parent)=0; virtual void Draw()=0; }; struct SketchIcon : public SketchObject { ! pawsImage *iconImage; ! virtual bool Load(iDocumentNode *node, pawsSketchWindow *parent); virtual void Draw(); }; *************** *** 44,48 **** { csString font; ! virtual bool Load(iDocumentNode *node); virtual void Draw(); }; --- 46,60 ---- { csString font; ! virtual bool Load(iDocumentNode *node, pawsSketchWindow *parent); ! virtual void Draw(); ! }; ! struct SketchPoint : public SketchObject ! { ! virtual bool Load(iDocumentNode *node, pawsSketchWindow *parent); ! virtual void Draw(); ! }; ! struct SketchLineTo : public SketchObject ! { ! virtual bool Load(iDocumentNode *node, pawsSketchWindow *parent); virtual void Draw(); }; *************** *** 50,53 **** --- 62,66 ---- protected: csPDelArray<SketchObject> objlist; + int lineStartX,lineStartY; void DrawSketch(); *************** *** 63,66 **** --- 76,83 ---- void HandleMessage( MsgEntry* message ); + void Draw(); + void SetLineStart(int x, int y); + void GetLineStart(int &x, int &y); + iGraphics2D *GetG2D(); }; |