From: <mr...@us...> - 2008-03-13 22:35:19
|
Revision: 1175 http://planeshift.svn.sourceforge.net/planeshift/?rev=1175&view=rev Author: mr_dave Date: 2008-03-13 15:35:23 -0700 (Thu, 13 Mar 2008) Log Message: ----------- Fix bug FS#1074 Modified Paths: -------------- trunk/data/gui/illumination.xml trunk/docs/history.txt trunk/src/client/gui/pawsilluminationwindow.cpp trunk/src/client/gui/pawsilluminationwindow.h trunk/src/common/net/messages.h trunk/src/server/psserverchar.cpp Modified: trunk/data/gui/illumination.xml =================================================================== --- trunk/data/gui/illumination.xml 2008-03-12 18:42:48 UTC (rev 1174) +++ trunk/data/gui/illumination.xml 2008-03-13 22:35:23 UTC (rev 1175) @@ -57,7 +57,11 @@ <bgimage resource="DeleteTool" /> <eventMouseDown>Ret = SketchWindow:ClickDeleteTool()</eventMouseDown> </widget> - + <widget name="NameTool" factory="pawsButton" id="110" tooltip="Name (n)"> + <frame x="140" y="0" width="16" height="16" /> + <bgimage resource="TextTool" /> + <eventMouseDown>Ret = SketchWindow:ClickNameTool()</eventMouseDown> + </widget> </widget> </widget_description> Modified: trunk/docs/history.txt =================================================================== --- trunk/docs/history.txt 2008-03-12 18:42:48 UTC (rev 1174) +++ trunk/docs/history.txt 2008-03-13 22:35:23 UTC (rev 1175) @@ -1,3 +1,9 @@ +*** 2008-03-13 by Dave Bentham +- Fix for bug FS#1074: can give maps names; but requires a couple of art + issues: 1) a place on the Sketch Viewer to display the name; 2) a new + icon for the naming tool (currently same as Text Entry). +- NETVER BUMP! + *** 2008-03-12 by Kenny Graunke - Ditch csArray in delayed query manager, since its size is statically determined anyway. Modified: trunk/src/client/gui/pawsilluminationwindow.cpp =================================================================== --- trunk/src/client/gui/pawsilluminationwindow.cpp 2008-03-12 18:42:48 UTC (rev 1174) +++ trunk/src/client/gui/pawsilluminationwindow.cpp 2008-03-13 22:35:23 UTC (rev 1175) @@ -81,6 +81,8 @@ if (!msg.rightToEdit) readOnly = true; + sketchName = msg.name; + if (!blackBox) blackBox = PawsManager::GetSingleton().GetTextureManager()->GetDrawable("blackbox"); Show(); @@ -93,11 +95,11 @@ csString xml; xml = "<pages><page "; - xml.AppendFmt("l=\"%d\" t=\"%d\" w=\"%d\" h=\"%d\">", - GetLogicalWidth(screenFrame.xmin), - GetLogicalHeight(screenFrame.ymin), - GetLogicalWidth(screenFrame.xmax-screenFrame.xmin), - GetLogicalHeight(screenFrame.ymax-screenFrame.ymin)); + xml.AppendFmt("l=\"%d\" t=\"%d\" w=\"%d\" h=\"%d\">", + GetLogicalWidth(screenFrame.xmin), + GetLogicalHeight(screenFrame.ymin), + GetLogicalWidth(screenFrame.xmax-screenFrame.xmin), + GetLogicalHeight(screenFrame.ymax-screenFrame.ymin)); // Add background and size stuff here @@ -108,7 +110,7 @@ // printf("Saving sketch as: %s\n",xml.GetDataSafe()); - psSketchMessage sketch(0, currentItemID,0,"", xml, true); + psSketchMessage sketch(0, currentItemID,0,"", xml, true, sketchName); sketch.SendMessage(); } pawsWidget::Hide(); @@ -139,44 +141,49 @@ double pawsSketchWindow::CalcFunction(const char * functionName, const double * params) { - if (!strcasecmp(functionName,"ClickTextTool")) - { - OnKeyDown(0,'t',0); - return 0.0; - } - else if (!strcasecmp(functionName,"ClickEditMode")) - { - OnKeyDown(CSKEY_F2,0,0); - return 0.0; - } - else if (!strcasecmp(functionName,"ClickLineTool")) - { - OnKeyDown(0,'\\',0); - return 0.0; - } - else if (!strcasecmp(functionName,"ClickIconTool")) - { - OnKeyDown(0,'+',0); - return 0.0; - } - else if (!strcasecmp(functionName,"ClickPrevIcon")) - { - OnKeyDown(CSKEY_PGUP,0,0); - return 0.0; - } - else if (!strcasecmp(functionName,"ClickNextIcon")) - { - OnKeyDown(CSKEY_PGDN,0,0); - return 0.0; - } - else if (!strcasecmp(functionName,"ClickDeleteTool")) - { - OnKeyDown(CSKEY_DEL,0,0); - return 0.0; - } + if (!strcasecmp(functionName,"ClickTextTool")) + { + OnKeyDown(0,'t',0); + return 0.0; + } + else if (!strcasecmp(functionName,"ClickEditMode")) + { + OnKeyDown(CSKEY_F2,0,0); + return 0.0; + } + else if (!strcasecmp(functionName,"ClickLineTool")) + { + OnKeyDown(0,'\\',0); + return 0.0; + } + else if (!strcasecmp(functionName,"ClickIconTool")) + { + OnKeyDown(0,'+',0); + return 0.0; + } + else if (!strcasecmp(functionName,"ClickPrevIcon")) + { + OnKeyDown(CSKEY_PGUP,0,0); + return 0.0; + } + else if (!strcasecmp(functionName,"ClickNextIcon")) + { + OnKeyDown(CSKEY_PGDN,0,0); + return 0.0; + } + else if (!strcasecmp(functionName,"ClickDeleteTool")) + { + OnKeyDown(CSKEY_DEL,0,0); + return 0.0; + } + else if (!strcasecmp(functionName,"ClickNameTool")) + { + OnKeyDown(0,'n',0); + return 0.0; + } - // else call parent version to inherit other functions - return pawsWidget::CalcFunction(functionName,params); + // else call parent version to inherit other functions + return pawsWidget::CalcFunction(functionName,params); } bool pawsSketchWindow::OnKeyDown( int keyCode, int key, int modifiers ) @@ -193,9 +200,9 @@ selectedIndex = SIZET_NOT_FOUND; } - editMode = editMode ? false : true; // toggle edit mode - isResizable = editMode; // only resizable in edit mode - dirty=true; // always set this for now to make sure resizes get saved. + editMode = editMode ? false : true; // toggle edit mode + isResizable = editMode; // only resizable in edit mode + dirty=true; // always set this for now to make sure resizes get saved. // notify the user that we are entering/leaving edit mode if (editMode) @@ -234,6 +241,11 @@ AddSketchText(); return true; } + else if (key == 'n') + { + ChangeSketchName(); + return true; + } switch (keyCode) { case CSKEY_DEL: RemoveSelected(); @@ -263,7 +275,7 @@ if ((int)objlist.GetSize() >= primCount) { psSystemMessage sysMsg( 0, MSG_ERROR, PawsManager::GetSingleton().Translate("Your sketch is too complex for you to add more.") ); - sysMsg.FireEvent(); + sysMsg.FireEvent(); return; } @@ -282,11 +294,18 @@ if (!value || !strlen(value)) return; - int x = (ScreenFrame().xmax + ScreenFrame().xmin)/2 - ScreenFrame().xmin; - int y = (ScreenFrame().ymax + ScreenFrame().ymin)/2 - ScreenFrame().ymin; + if (!strcasecmp(name,"AddText")) + { + int x = (ScreenFrame().xmax + ScreenFrame().xmin)/2 - ScreenFrame().xmin; + int y = (ScreenFrame().ymax + ScreenFrame().ymin)/2 - ScreenFrame().ymin; - SketchText *text = new SketchText(x,y,value,this); - objlist.Push(text); + SketchText *text = new SketchText(x,y,value,this); + objlist.Push(text); + } + else if (!strcasecmp(name,"ChangeName")) + { + sketchName = value; + } stringPending = false; } @@ -296,7 +315,7 @@ if ((int)objlist.GetSize() >= primCount) { psSystemMessage sysMsg( 0, MSG_ERROR, PawsManager::GetSingleton().Translate("Your sketch is too complex for you to add more.") ); - sysMsg.FireEvent(); + sysMsg.FireEvent(); return; } @@ -317,7 +336,7 @@ if ((int)objlist.GetSize() >= primCount) { psSystemMessage sysMsg( 0, MSG_ERROR, PawsManager::GetSingleton().Translate("Your sketch is too complex for you to add more.") ); - sysMsg.FireEvent(); + sysMsg.FireEvent(); return; } @@ -367,10 +386,22 @@ } } +void pawsSketchWindow::ChangeSketchName() +{ + if (!stringPending) + { + stringPending = true; + + // This window calls OnStringEntered when Ok is pressed. + pawsStringPromptWindow::Create("Sketch Name", sketchName, + false, 220, 20, this, "ChangeName"); + } +} + bool pawsSketchWindow::OnMouseDown( int button, int modifiers, int x, int y ) { if (!editMode) - return pawsWidget::OnMouseDown(button, modifiers,x,y); + return pawsWidget::OnMouseDown(button, modifiers,x,y); mouseDown = true; @@ -401,13 +432,13 @@ objlist[selectedIndex]->Select(false); selectedIndex = SIZET_NOT_FOUND; } - return pawsWidget::OnMouseDown(button, modifiers,x,y); + return pawsWidget::OnMouseDown(button, modifiers,x,y); } bool pawsSketchWindow::OnMouseUp( int button, int modifiers, int x, int y ) { if (!editMode) - return pawsWidget::OnMouseUp(button, modifiers,x,y); + return pawsWidget::OnMouseUp(button, modifiers,x,y); mouseDown = false; @@ -418,7 +449,7 @@ dirty = true; return true; } - return pawsWidget::OnMouseUp(button, modifiers,x,y); + return pawsWidget::OnMouseUp(button, modifiers,x,y); } bool pawsSketchWindow::ParseLimits(const char *xmlstr) @@ -507,8 +538,8 @@ while ( iter->HasNext() ) { csRef<iDocumentNode> node = iter->Next(); - MoveTo(GetActualWidth(node->GetAttributeValueAsInt("l")),GetActualHeight(node->GetAttributeValueAsInt("t"))); - screenFrame.SetSize(GetActualWidth(node->GetAttributeValueAsInt("w")),GetActualHeight(node->GetAttributeValueAsInt("h"))); + MoveTo(GetActualWidth(node->GetAttributeValueAsInt("l")),GetActualHeight(node->GetAttributeValueAsInt("t"))); + screenFrame.SetSize(GetActualWidth(node->GetAttributeValueAsInt("w")),GetActualHeight(node->GetAttributeValueAsInt("h"))); defaultFrame.xmin = GetActualWidth(node->GetAttributeValueAsInt("l")); defaultFrame.ymin = GetActualHeight(node->GetAttributeValueAsInt("y")); @@ -610,8 +641,8 @@ if (!parent->IsMouseDown() || !selected) iconImage->Draw(parent->GetActualWidth(x) + parent->ScreenFrame().xmin, parent->GetActualHeight(y) + parent->ScreenFrame().ymin, - parent->GetActualWidth(iconImage->GetWidth()), - parent->GetActualHeight(iconImage->GetHeight())); + parent->GetActualWidth(iconImage->GetWidth()), + parent->GetActualHeight(iconImage->GetHeight())); } if (selected) frame = (frame > 29) ? 0 : frame+1; @@ -729,10 +760,10 @@ csRect rect = parent->ScreenFrame(); mouseX -= rect.xmin; mouseY -= rect.ymin; - - mouseX = parent->GetLogicalWidth(mouseX); - mouseY = parent->GetLogicalHeight(mouseY); + mouseX = parent->GetLogicalWidth(mouseX); + mouseY = parent->GetLogicalHeight(mouseY); + dragMode = 0; if (abs(mouseX-x) < 3 && Modified: trunk/src/client/gui/pawsilluminationwindow.h =================================================================== --- trunk/src/client/gui/pawsilluminationwindow.h 2008-03-12 18:42:48 UTC (rev 1174) +++ trunk/src/client/gui/pawsilluminationwindow.h 2008-03-13 22:35:23 UTC (rev 1175) @@ -124,7 +124,10 @@ void RemoveSelected(); void NextPrevIcon(int delta); void MoveObject(int dx, int dy); + void ChangeSketchName(); + csString sketchName; + public: pawsSketchWindow(); virtual ~pawsSketchWindow(); @@ -133,11 +136,11 @@ void HandleMessage( MsgEntry* message ); - // inherited from iOnStringEnteredAction + // inherited from iOnStringEnteredAction void OnStringEntered(const char *name,int param,const char *value); - // inherited from iScriptableVar from pawsWidget - double CalcFunction(const char * functionName, const double * params); + // inherited from iScriptableVar from pawsWidget + double CalcFunction(const char * functionName, const double * params); virtual bool OnMouseDown( int button, int modifiers, int x, int y ); Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2008-03-12 18:42:48 UTC (rev 1174) +++ trunk/src/common/net/messages.h 2008-03-13 22:35:23 UTC (rev 1175) @@ -43,7 +43,7 @@ // This holds the version number of the network code, remember to increase // this each time you do an update which breaks compatibility -#define PS_NETVERSION 0x0087 +#define PS_NETVERSION 0x0088 // Remember to bump the version in pscssetup.h, as well. // NPC Networking version is separate so we don't have to break compatibility @@ -4580,9 +4580,9 @@ class psSketchMessage : public psMessageCracker { public: - psSketchMessage( uint32_t client, uint32_t itemID, uint8_t flags, const char *limitxml,const char *sketch_def, bool rightToEditFlag) + psSketchMessage( uint32_t client, uint32_t itemID, uint8_t flags, const char *limitxml,const char *sketch_def, bool rightToEditFlag, const char *sketch_name) { - msg.AttachNew(new MsgEntry( sizeof(uint32_t)+1+strlen(limitxml)+1+strlen(sketch_def)+1+sizeof(bool) )); + msg.AttachNew(new MsgEntry( sizeof(uint32_t)+1+strlen(limitxml)+1+strlen(sketch_def)+1+sizeof(bool)+strlen(sketch_name)+1 )); msg->SetType(MSGTYPE_VIEW_SKETCH); msg->clientnum = client; @@ -4591,6 +4591,7 @@ msg->Add(limitxml); msg->Add( sketch_def ); msg->Add(rightToEditFlag); + msg->Add(sketch_name); } psSketchMessage( MsgEntry* me ) @@ -4600,6 +4601,7 @@ limits = me->GetStr(); Sketch = me->GetStr(); rightToEdit = me->GetBool(); + name = me->GetStr(); } PSF_DECLARE_MSG_FACTORY(); @@ -4620,6 +4622,7 @@ csString Sketch; csString limits; bool rightToEdit; + csString name; }; /** Modified: trunk/src/server/psserverchar.cpp =================================================================== --- trunk/src/server/psserverchar.cpp 2008-03-12 18:42:48 UTC (rev 1174) +++ trunk/src/server/psserverchar.cpp 2008-03-13 22:35:23 UTC (rev 1175) @@ -163,6 +163,22 @@ psItem *item = client->GetCharacterData()->Inventory().FindItemID(sketchMsg.ItemID); if (item) { + // check title is still unique + csString currentTitle = item->GetName(); + if (sketchMsg.name.Length() > 0) + { + uint32 existingItemID = CacheManager::GetSingleton().BasicItemStatsByNameExist(sketchMsg.name); + if (existingItemID != 0 && existingItemID != item->GetBaseStats()->GetUID()) + { + psserver->SendSystemError(me->clientnum, "The title is not unique"); + } + else if (sketchMsg.name != currentTitle) + { + currentTitle = sketchMsg.name; + item->GetBaseStats()->SetName(sketchMsg.name); + } + } + // TODO: Probably need to validate the xml here somehow if (item->GetBaseStats()->SetSketch(csString(sketchMsg.Sketch))) { @@ -336,7 +352,7 @@ xml += "</limits>"; // Now send all this - psSketchMessage msg( client->GetClientNum(), item->GetUID(), 0, xml, item->GetBaseStats()->GetSketch(), item->GetBaseStats()->IsThisTheCreator(client->GetCharacterData()->GetCharacterID()) ); + psSketchMessage msg( client->GetClientNum(), item->GetUID(), 0, xml, item->GetBaseStats()->GetSketch(), item->GetBaseStats()->IsThisTheCreator(client->GetCharacterData()->GetCharacterID()), item->GetName() ); msg.SendMessage(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |