From: <mg...@us...> - 2008-07-28 18:08:17
|
Revision: 1954 http://planeshift.svn.sourceforge.net/planeshift/?rev=1954&view=rev Author: mgist Date: 2008-07-28 18:08:24 +0000 (Mon, 28 Jul 2008) Log Message: ----------- - Merged r1951-1953 from trunk. Modified Paths: -------------- stable/data/gui/illumination.xml stable/docs/history.txt stable/src/client/gui/inventorywindow.cpp stable/src/client/gui/pawscontainerdescwindow.cpp stable/src/client/gui/pawsexchangewindow.cpp stable/src/client/gui/pawsilluminationwindow.cpp stable/src/client/gui/pawsilluminationwindow.h stable/src/client/gui/pawssmallinventory.cpp stable/src/server/adminmanager.cpp Property Changed: ---------------- stable/ Property changes on: stable ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:1911,1915-1916,1918-1919,1923-1927,1930,1934,1936,1939,1941,1945-1949 + /trunk:1911,1915-1916,1918-1919,1923-1927,1930,1934,1936,1939,1941,1945-1949,1951-1953 Modified: stable/data/gui/illumination.xml =================================================================== --- stable/data/gui/illumination.xml 2008-07-28 17:55:07 UTC (rev 1953) +++ stable/data/gui/illumination.xml 2008-07-28 18:08:24 UTC (rev 1954) @@ -62,6 +62,16 @@ <bgimage resource="TextTool" /> <eventMouseDown>Ret = SketchWindow:ClickNameTool()</eventMouseDown> </widget> + <widget name="SaveButton" factory="pawsButton" id="111" tooltip="Save (s)"> + <frame x="180" y="0" width="16" height="16" /> + <bgimage resource="FeatherTool" /> + <eventMouseDown>Ret = SketchWindow:ClickSaveButton()</eventMouseDown> + </widget> + <widget name="LoadButton" factory="pawsButton" id="112" tooltip="Load (l)"> + <frame x="200" y="0" width="16" height="16" /> + <bgimage resource="FeatherTool" /> + <eventMouseDown>Ret = SketchWindow:ClickLoadButton()</eventMouseDown> + </widget> </widget> </widget_description> Modified: stable/docs/history.txt =================================================================== --- stable/docs/history.txt 2008-07-28 17:55:07 UTC (rev 1953) +++ stable/docs/history.txt 2008-07-28 18:08:24 UTC (rev 1954) @@ -1,17 +1,15 @@ *** 2008-07-28 by Andreas Heinchen - Fix for FS#1692 - fixing 2 bugs that caused entities to get lost in a temporary sector - -*** 2008-07-28 by Andreas Heinchen - Cleaned up fix for FS#707 - -*** 2008-07-28 by Andreas Heinchen - Fixed FS#1826 +- Fixed FS#1909, patch by Weltall. *** 2008-07-28 by Mike Gist - Fixed FS#1925, patch by peeg. - Patch for FS#2001 from weltall. - Fixed a memory leak caused by a reference leak in netbase. - Patch for FS#1912 from weltall. +- Patch for FS#1855 from Arerano. *** 2008-07-24 by Steven Patrick - Fixed FS#1991 - deputizing doesn't update GM console, patch by Zwenze. Modified: stable/src/client/gui/inventorywindow.cpp =================================================================== --- stable/src/client/gui/inventorywindow.cpp 2008-07-28 17:55:07 UTC (rev 1953) +++ stable/src/client/gui/inventorywindow.cpp 2008-07-28 18:08:24 UTC (rev 1954) @@ -156,26 +156,36 @@ if ( !SetupSlot("torso") ) return false; if ( !SetupSlot("mind") ) return false; - pawsListBox * bulkList = dynamic_cast <pawsListBox*> (FindWidget("BulkList")); - for (int i = 0; i < INVENTORY_BULK_COUNT/2; i++) + pawsListBox * bulkList = dynamic_cast <pawsListBox*> (FindWidget("BulkList")); + int colCount = bulkList->GetTotalColumns(); + int rowCount = (int) ceil(float(INVENTORY_BULK_COUNT)/colCount); + + for(int r = 0; r < rowCount; r ++) { - pawsListBoxRow * listRow = bulkList->NewRow(i); - for (int j = 0; j < 2; j++) + pawsListBoxRow * listRow = bulkList->NewRow(r); + for (int j = 0; j < colCount; j++) { + int i = r*colCount + j; pawsSlot * slot; slot = dynamic_cast <pawsSlot*> (listRow->GetColumn(j)); slot->SetContainer( CONTAINER_INVENTORY_BULK ); //csString name; - slot->SetSlotID( i*2+j ); + slot->SetSlotID( i ); csString name; - name.Format("invslot_%d", 16 + i*2+j); // 16 equip slots come first + name.Format("invslot_%d", 16 + i ); // 16 equip slots come first slot->SetSlotName(name); + if(i >= INVENTORY_BULK_COUNT) + { + slot->Hide(); + continue; + } + //printf("Subscribing bulk slot to %s.\n",name.GetData() ); PawsManager::GetSingleton().Subscribe( name, slot ); PawsManager::GetSingleton().Subscribe("sigClearInventorySlots", slot); - bulkSlots[i*2+j] = slot; - } + bulkSlots[i] = slot; + } } // Ask the server to send us the inventory Modified: stable/src/client/gui/pawscontainerdescwindow.cpp =================================================================== --- stable/src/client/gui/pawscontainerdescwindow.cpp 2008-07-28 17:55:07 UTC (rev 1953) +++ stable/src/client/gui/pawscontainerdescwindow.cpp 2008-07-28 18:08:24 UTC (rev 1954) @@ -146,7 +146,7 @@ contents->Clear(); containerSlots = PSITEM_MAX_CONTAINER_SLOTS; - const int cols = 6; + const int cols = contents->GetTotalColumns(); //6; const int rows = (int) ceil(float(containerSlots)/cols); for (int i = 0; i < rows; i++) { Modified: stable/src/client/gui/pawsexchangewindow.cpp =================================================================== --- stable/src/client/gui/pawsexchangewindow.cpp 2008-07-28 17:55:07 UTC (rev 1953) +++ stable/src/client/gui/pawsexchangewindow.cpp 2008-07-28 18:08:24 UTC (rev 1954) @@ -114,20 +114,28 @@ if (!bulkList) return false; - int i, j; + int colCount = bulkList->GetTotalColumns(); + int rowCount = (int) ceil(float(EXCHANGE_SLOT_COUNT)/colCount); + int r, j, i; - for (i = 0; i < EXCHANGE_SLOT_COUNT/NUM_COLUMNS; i++) + for (r = 0; r < rowCount; r++) { - pawsListBoxRow * listRow = bulkList->NewRow(i); - for (j = 0; j < NUM_COLUMNS; j++) + pawsListBoxRow * listRow = bulkList->NewRow(r); + for (j = 0; j < colCount; j++) { + i = r*colCount+j; pawsSlot * slot; slot = dynamic_cast <pawsSlot*> (listRow->GetColumn(j)); if (slot == NULL) return false; slot->SetContainer( CONTAINER_EXCHANGE_OFFERING ); - slot->SetSlotID( i*2+j ); - offeringSlots[i*2+j] = slot; + slot->SetSlotID( i ); + if (i >= EXCHANGE_SLOT_COUNT) + { + slot->Hide(); + continue; + } + offeringSlots[i] = slot; } } @@ -136,19 +144,28 @@ if (!bulkList) return false; - for (i = 0; i < EXCHANGE_SLOT_COUNT/NUM_COLUMNS; i++) + colCount = bulkList->GetTotalColumns(); + rowCount = (int) ceil(float(EXCHANGE_SLOT_COUNT)/colCount); + + for (r = 0; r < rowCount; r++) { - pawsListBoxRow * listRow = bulkList->NewRow(i); - for (j = 0; j < NUM_COLUMNS; j++) + pawsListBoxRow * listRow = bulkList->NewRow(r); + for (j = 0; j < colCount; j++) { + i = r*colCount+j; pawsSlot * slot; slot = dynamic_cast <pawsSlot*> (listRow->GetColumn(j)); if (slot == NULL) return false; slot->SetContainer( CONTAINER_EXCHANGE_RECEIVING ); - slot->SetSlotID( i*2+j ); + slot->SetSlotID( i ); slot->SetDrag(false); - receivingSlots[i*2+j] = slot; + if (i >= EXCHANGE_SLOT_COUNT) + { + slot->Hide(); + continue; + } + receivingSlots[i] = slot; } } Modified: stable/src/client/gui/pawsilluminationwindow.cpp =================================================================== --- stable/src/client/gui/pawsilluminationwindow.cpp 2008-07-28 17:55:07 UTC (rev 1953) +++ stable/src/client/gui/pawsilluminationwindow.cpp 2008-07-28 18:08:24 UTC (rev 1954) @@ -54,6 +54,17 @@ bool pawsSketchWindow::PostSetup() { psengine->GetMsgHandler()->Subscribe(this, MSGTYPE_VIEW_SKETCH); + //setup an easy way to access our widgets + FeatherTool = dynamic_cast<pawsWidget*> (FindWidget("FeatherTool")); + TextTool = dynamic_cast<pawsWidget*> (FindWidget("TextTool")); + LineTool = dynamic_cast<pawsWidget*> (FindWidget("LineTool")); + PlusTool = dynamic_cast<pawsWidget*> (FindWidget("PlusTool")); + LeftArrowTool = dynamic_cast<pawsWidget*> (FindWidget("LeftArrowTool")); + RightArrowTool = dynamic_cast<pawsWidget*> (FindWidget("RightArrowTool")); + DeleteTool = dynamic_cast<pawsWidget*> (FindWidget("DeleteTool")); + NameTool = dynamic_cast<pawsWidget*> (FindWidget("NameTool")); + SaveButton = dynamic_cast<pawsWidget*> (FindWidget("SaveButton")); + LoadButton = dynamic_cast<pawsWidget*> (FindWidget("LoadButton")); return true; } @@ -72,14 +83,63 @@ currentItemID = msg.ItemID; Notify4(LOG_PAWS,"Got Sketch for item %u: %s\nLimits:%s\n", msg.ItemID, msg.Sketch.GetData(), msg.limits.GetDataSafe()); objlist.Empty(); - - ParseSketch(msg.Sketch); + dirty = false; ParseLimits(msg.limits); - + ParseSketch(msg.Sketch); + // if char does not have the right to edit (ie not the originator-artist)... if (!msg.rightToEdit) readOnly = true; + + if(readOnly) + { + //hide useless widgets in the window so the sketch is more clean + //to whoever looks at it while not being the author + if(FeatherTool) + FeatherTool->Hide(); + if(TextTool) + TextTool->Hide(); + if(LineTool) + LineTool->Hide(); + if(PlusTool) + PlusTool->Hide(); + if(LeftArrowTool) + LeftArrowTool->Hide(); + if(RightArrowTool) + RightArrowTool->Hide(); + if(DeleteTool) + DeleteTool->Hide(); + if(NameTool) + NameTool->Hide(); + if(SaveButton) + SaveButton->Hide(); + if(LoadButton) + LoadButton->Hide(); + } + else //we have editing rights so let's show buttons to do some editing + { + if(FeatherTool) + FeatherTool->Show(); + if(TextTool) + TextTool->Show(); + if(LineTool) + LineTool->Show(); + if(PlusTool) + PlusTool->Show(); + if(LeftArrowTool) + LeftArrowTool->Show(); + if(RightArrowTool) + RightArrowTool->Show(); + if(DeleteTool) + DeleteTool->Show(); + if(NameTool) + NameTool->Show(); + if(SaveButton) + SaveButton->Show(); + if(LoadButton) + LoadButton->Show(); + } sketchName = msg.name; SetTitle(sketchName); @@ -182,6 +242,16 @@ OnKeyDown(0,'n',0); return 0.0; } + else if (!strcasecmp(functionName,"ClickSaveButton")) + { + OnKeyDown(0,'s',0); + return 0.0; + } + else if (!strcasecmp(functionName,"ClickLoadButton")) + { + OnKeyDown(0,'l',0); + return 0.0; + } // else call parent version to inherit other functions return pawsWidget::CalcFunction(functionName,params); @@ -225,6 +295,11 @@ } return true; } + else if (key == 's' && !readOnly) //allow saving also when not in edit mode but check if the player saving the sketch + { //has editing rights over the sketch it's being saved + SaveSketch(); + return true; + } else if (editMode) { if (key == '+') // keycode is the kbd scan code, key is the ASCII @@ -247,6 +322,11 @@ ChangeSketchName(); return true; } + else if (key == 'l') //allow loading only in editing mode + { + LoadSketch(); + return true; + } switch (keyCode) { case CSKEY_DEL: RemoveSelected(); @@ -301,7 +381,6 @@ { 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); } @@ -310,7 +389,24 @@ sketchName = value; SetTitle(sketchName); } - + else if (!strcasecmp(name,"FileNameBox")) + { + //we got to load the sketch we were asked for + csRef<iVFS> vfs = psengine->GetVFS(); + csString tempFileName; + tempFileName.Format("/planeshift/userdata/sketches/%s", value); + if (!vfs->Exists(tempFileName)) + { + psSystemMessage msg(0, MSG_ERROR, "File not found!" ); + msg.FireEvent(); + return; + } + csRef<iDataBuffer> buff = vfs->ReadFile(tempFileName); //reads the file + csString sketchxml = buff->operator*(); //converts what we have read in something our ParseSketch function can + //understand + objlist.Empty(); //clears the objlist to start loading our new sketch from clean + ParseSketch(sketchxml); //loads our sketch + } } void pawsSketchWindow::AddSketchLine() @@ -401,6 +497,57 @@ } } +void pawsSketchWindow::SaveSketch() +{ + csString xml; + //generates the xml document from the objects currently displayed in the sketch + 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)); + + for (size_t i=0; i<objlist.GetSize(); i++) + objlist[i]->WriteXml(xml); + + xml += "</page></pages>"; + csRef<iVFS> vfs = psengine->GetVFS(); + unsigned int tempNumber = 0; + //searchs for a free sketch slot in the user directory and write in it + csString tempFileNameTemplate = "/planeshift/userdata/sketches/%s.xml", tempFileName; + if (filenameSafe(sketchName).Length()) + { + tempFileName.Format(tempFileNameTemplate, filenameSafe(sketchName).GetData()); + } + else + { + tempFileNameTemplate = "/planeshift/userdata/books/book%d.txt"; + do + { + tempFileName.Format(tempFileNameTemplate, tempNumber); + tempNumber++; + } while (vfs->Exists(tempFileName)); + } + + vfs->WriteFile(tempFileName, xml, xml.Length()); + psSystemMessage msg(0, MSG_ACK, "Sketch saved to %s", tempFileName.GetData()+30 ); + msg.FireEvent(); +} + +void pawsSketchWindow::LoadSketch() +{ + if (!stringPending) + { + stringPending = true; + + //This window calls OnStringEntered when Ok is pressed. + //Asks to the user the file name of the sketch inside the sketches directory under their user directory + pawsStringPromptWindow::Create("Enter local filename", "", + false, 220, 20, this, "FileNameBox",0,true); + } +} + bool pawsSketchWindow::OnMouseDown( int button, int modifiers, int x, int y ) { if (!editMode) @@ -556,6 +703,8 @@ SketchObject *obj=NULL; csRef<iDocumentNode> tmp = pagenodes->Next(); csString type = tmp->GetValue(); + if((int)objlist.GetSize() >= primCount) //are we under the limitations?... + break; //...it seems we aren't so break before going on, at least one part of sketch is available // Determine what type to create, and create it if (type == "ic") // icon obj = new SketchIcon; @@ -937,3 +1086,23 @@ } } } + +bool pawsSketchWindow::isBadChar(char c) +{ + csString badChars = "/\\?%*:|\"<>"; + if (badChars.FindFirst(c) == (size_t) -1) + return false; + else + return true; +} + +csString pawsSketchWindow::filenameSafe(const csString &original) +{ + csString safe; + size_t len = original.Length(); + for (size_t c = 0; c < len; ++c) { + if (!isBadChar(original[c])) + safe += original[c]; + } + return safe; +} Modified: stable/src/client/gui/pawsilluminationwindow.h =================================================================== --- stable/src/client/gui/pawsilluminationwindow.h 2008-07-28 17:55:07 UTC (rev 1953) +++ stable/src/client/gui/pawsilluminationwindow.h 2008-07-28 18:08:24 UTC (rev 1954) @@ -115,6 +115,17 @@ int primCount; bool readOnly; bool stringPending; + + pawsWidget* FeatherTool; + pawsWidget* TextTool; + pawsWidget* LineTool; + pawsWidget* PlusTool; + pawsWidget* LeftArrowTool; + pawsWidget* RightArrowTool; + pawsWidget* DeleteTool; + pawsWidget* NameTool; + pawsWidget* SaveButton; + pawsWidget* LoadButton; void DrawSketch(); bool ParseSketch(const char *xml); @@ -127,6 +138,10 @@ void NextPrevIcon(int delta); void MoveObject(int dx, int dy); void ChangeSketchName(); + void SaveSketch(); + void LoadSketch(); + bool isBadChar(char c); + csString filenameSafe(const csString &original); csString sketchName; Modified: stable/src/client/gui/pawssmallinventory.cpp =================================================================== --- stable/src/client/gui/pawssmallinventory.cpp 2008-07-28 17:55:07 UTC (rev 1953) +++ stable/src/client/gui/pawssmallinventory.cpp 2008-07-28 18:08:24 UTC (rev 1954) @@ -60,25 +60,39 @@ border->JustTitle(); // Setup our inventory slots in the list box. - pawsListBox * bulkList = dynamic_cast <pawsListBox*> (FindWidget("BulkList")); - for (int i = 0; i < INVENTORY_BULK_COUNT/2; i++) + pawsListBox * bulkList = dynamic_cast <pawsListBox*> (FindWidget("BulkList")); + + int colCount = bulkList->GetTotalColumns(); + int rowCount = (int) ceil(float(INVENTORY_BULK_COUNT)/colCount); + + for(int r = 0; r < rowCount; r ++) { - pawsListBoxRow * listRow = bulkList->NewRow(i); - for (int j = 0; j < 2; j++) + pawsListBoxRow * listRow = bulkList->NewRow(r); + for (int j = 0; j < colCount; j++) { + int i = r*colCount + j; pawsSlot * slot; slot = dynamic_cast <pawsSlot*> (listRow->GetColumn(j)); slot->SetContainer( CONTAINER_INVENTORY_BULK ); - slot->SetSlotID( i*2+j ); + //csString name; + slot->SetSlotID( i ); csString name; - name.Format("invslot_%d",16 + i*2+j); + name.Format("invslot_%d", 16 + i ); // 16 equip slots come first slot->SetSlotName(name); + + if(i >= INVENTORY_BULK_COUNT) + { + slot->Hide(); + continue; + } + + //printf("Subscribing bulk slot to %s.\n",name.GetData() ); PawsManager::GetSingleton().Subscribe( name, slot ); PawsManager::GetSingleton().Subscribe("sigClearInventorySlots", slot); - slot->SetName( name ); - bulkSlots[i*2+j] = slot; - } - } + bulkSlots[i] = slot; + } + } + money = dynamic_cast <pawsMoney*> (FindWidget("Money")); if ( !money ) return false; Modified: stable/src/server/adminmanager.cpp =================================================================== --- stable/src/server/adminmanager.cpp 2008-07-28 17:55:07 UTC (rev 1953) +++ stable/src/server/adminmanager.cpp 2008-07-28 18:08:24 UTC (rev 1954) @@ -5999,7 +5999,7 @@ psCharacter* targetchar = target->GetCharacterData(); psCharacter* sourcechar = source->GetCharacterData(); - if (data.item == "tria") + if (data.item.Downcase() == "tria") { psMoney srcMoney = sourcechar->Money(); psMoney targetMoney = targetchar->Money(); @@ -6030,7 +6030,7 @@ if (target->GetClientNum() != me->clientnum) { psserver->SendSystemOK(target->GetClientNum(), - "%d tria was by GM %s.", value, + "%d tria were given by GM %s.", value, source->GetActor()->GetName()); } @@ -6038,7 +6038,7 @@ if (source->GetClientNum() != me->clientnum) { psserver->SendSystemResult(source->GetClientNum(), - "%d tria was taken by %s.", value, + "%d tria were taken by %s.", value, target->GetActor()->GetName()); } return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |