aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloatercustomize.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llfloatercustomize.cpp222
1 files changed, 221 insertions, 1 deletions
diff --git a/linden/indra/newview/llfloatercustomize.cpp b/linden/indra/newview/llfloatercustomize.cpp
index b5dd018..bfca034 100644
--- a/linden/indra/newview/llfloatercustomize.cpp
+++ b/linden/indra/newview/llfloatercustomize.cpp
@@ -220,6 +220,8 @@ public:
220 220
221 childSetAction("Save", onSave, this ); 221 childSetAction("Save", onSave, this );
222 childSetAction("Cancel", onCancel, this ); 222 childSetAction("Cancel", onCancel, this );
223 childSetAction("Check All", onCheckAll, this );
224 childSetAction("Uncheck All", onUncheckAll, this );
223 } 225 }
224 226
225 BOOL getRenameClothing() 227 BOOL getRenameClothing()
@@ -300,6 +302,26 @@ public:
300 LLMakeOutfitDialog* self = (LLMakeOutfitDialog*) userdata; 302 LLMakeOutfitDialog* self = (LLMakeOutfitDialog*) userdata;
301 self->close(); // destroys this object 303 self->close(); // destroys this object
302 } 304 }
305
306 static void onCheckAll( void* userdata )
307 {
308 LLMakeOutfitDialog* self = (LLMakeOutfitDialog*) userdata;
309 for( S32 i = 0; i < (S32)(self->mCheckBoxList.size()); i++)
310 {
311 std::string name = self->mCheckBoxList[i].first;
312 if(self->childIsEnabled(name))self->childSetValue(name,TRUE);
313 }
314 }
315
316 static void onUncheckAll( void* userdata )
317 {
318 LLMakeOutfitDialog* self = (LLMakeOutfitDialog*) userdata;
319 for( S32 i = 0; i < (S32)(self->mCheckBoxList.size()); i++)
320 {
321 std::string name = self->mCheckBoxList[i].first;
322 if(self->childIsEnabled(name))self->childSetValue(name,FALSE);
323 }
324 }
303}; 325};
304 326
305///////////////////////////////////////////////////////////////////// 327/////////////////////////////////////////////////////////////////////
@@ -492,10 +514,26 @@ void LLPanelEditWearable::setSubpart( ESubpart subpart )
492 item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem(mType); 514 item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem(mType);
493 U32 perm_mask = 0x0; 515 U32 perm_mask = 0x0;
494 BOOL is_complete = FALSE; 516 BOOL is_complete = FALSE;
517 bool can_export = false;
518 bool can_import = false;
495 if(item) 519 if(item)
496 { 520 {
497 perm_mask = item->getPermissions().getMaskOwner(); 521 perm_mask = item->getPermissions().getMaskOwner();
498 is_complete = item->isComplete(); 522 is_complete = item->isComplete();
523
524 if (subpart <= 18) // body parts only
525 {
526 can_import = true;
527
528 if (is_complete &&
529 gAgent.getID() == item->getPermissions().getOwner() &&
530 gAgent.getID() == item->getPermissions().getCreator() &&
531 (PERM_ITEM_UNRESTRICTED &
532 perm_mask) == PERM_ITEM_UNRESTRICTED)
533 {
534 can_export = true;
535 }
536 }
499 } 537 }
500 setUIPermissions(perm_mask, is_complete); 538 setUIPermissions(perm_mask, is_complete);
501 BOOL editable = ((perm_mask & PERM_MODIFY) && is_complete) ? TRUE : FALSE; 539 BOOL editable = ((perm_mask & PERM_MODIFY) && is_complete) ? TRUE : FALSE;
@@ -519,7 +557,8 @@ void LLPanelEditWearable::setSubpart( ESubpart subpart )
519 } 557 }
520 gFloaterCustomize->generateVisualParamHints(NULL, sorted_params); 558 gFloaterCustomize->generateVisualParamHints(NULL, sorted_params);
521 gFloaterCustomize->updateScrollingPanelUI(); 559 gFloaterCustomize->updateScrollingPanelUI();
522 560 gFloaterCustomize->childSetEnabled("Export", can_export);
561 gFloaterCustomize->childSetEnabled("Import", can_import);
523 562
524 // Update the camera 563 // Update the camera
525 gMorphView->setCameraTargetJoint( gAgent.getAvatarObject()->getJoint( part->mTargetJoint ) ); 564 gMorphView->setCameraTargetJoint( gAgent.getAvatarObject()->getJoint( part->mTargetJoint ) );
@@ -1188,6 +1227,17 @@ void LLScrollingPanelParam::onSliderMoved(LLUICtrl* ctrl, void* userdata)
1188 F32 new_weight = self->percentToWeight( (F32)slider->getValue().asReal() ); 1227 F32 new_weight = self->percentToWeight( (F32)slider->getValue().asReal() );
1189 if (current_weight != new_weight ) 1228 if (current_weight != new_weight )
1190 { 1229 {
1230 LLFloaterCustomize* floater_customize = gFloaterCustomize;
1231 if (!floater_customize) return;
1232
1233 //avatar height stuff -Patrick Sapinski (Wednesday, August 19, 2009)
1234 LLVOAvatar* avatar = gAgent.getAvatarObject();
1235 F32 avatar_size = (avatar->mBodySize.mV[VZ]) + (F32)0.17; //mBodySize is actually quite a bit off.
1236
1237 floater_customize->getChild<LLTextBox>("HeightText")->setValue(llformat("%.2f", avatar_size) + "m");
1238 floater_customize->getChild<LLTextBox>("HeightText2")->setValue(llformat("%.2f",llround(avatar_size / 0.3048)) + "'"
1239 + llformat("%.2f",llround(avatar_size * 39.37) % 12) + "\"");
1240
1191 gAgent.getAvatarObject()->setVisualParamWeight( param, new_weight, FALSE); 1241 gAgent.getAvatarObject()->setVisualParamWeight( param, new_weight, FALSE);
1192 gAgent.getAvatarObject()->updateVisualParams(); 1242 gAgent.getAvatarObject()->updateVisualParams();
1193 } 1243 }
@@ -1429,6 +1479,10 @@ BOOL LLFloaterCustomize::postBuild()
1429 childSetAction("Ok", LLFloaterCustomize::onBtnOk, (void*)this); 1479 childSetAction("Ok", LLFloaterCustomize::onBtnOk, (void*)this);
1430 childSetAction("Cancel", LLFloater::onClickClose, (void*)this); 1480 childSetAction("Cancel", LLFloater::onClickClose, (void*)this);
1431 1481
1482 // reX
1483 childSetAction("Import", LLFloaterCustomize::onBtnImport, (void*)this);
1484 childSetAction("Export", LLFloaterCustomize::onBtnExport, (void*)this);
1485
1432 // Wearable panels 1486 // Wearable panels
1433 initWearablePanels(); 1487 initWearablePanels();
1434 1488
@@ -1494,6 +1548,157 @@ void LLFloaterCustomize::setCurrentWearableType( EWearableType type )
1494 } 1548 }
1495} 1549}
1496 1550
1551
1552// reX: new function
1553void LLFloaterCustomize::onBtnImport( void* userdata )
1554{
1555 LLFilePicker& file_picker = LLFilePicker::instance();
1556 if( !file_picker.getOpenFile( LLFilePicker::FFLOAD_XML ) )
1557 {
1558 // User canceled import.
1559 return;
1560 }
1561
1562 const std::string filename = file_picker.getFirstFile();
1563
1564 FILE* fp = LLFile::fopen(filename, "rb");
1565
1566 //char text_buffer[2048]; /* Flawfinder: ignore */
1567 S32 c;
1568 S32 typ;
1569 S32 count;
1570 S32 param_id=0;
1571 F32 param_weight=0;
1572 S32 fields_read;
1573
1574 for( S32 i=0; i < WT_COUNT; i++ )
1575 {
1576 fields_read = fscanf( fp, "type %d\n", &typ);
1577 if( fields_read != 1 )
1578 {
1579 llwarns << "Bad asset type: early end of file" << llendl;
1580 return;
1581 }
1582
1583 fields_read = fscanf( fp, "parameters %d\n", &count);
1584 if( fields_read != 1 )
1585 {
1586 llwarns << "Bad parameters : early end of file" << llendl;
1587 return;
1588 }
1589 for(c=0;c<count;c++)
1590 {
1591 fields_read = fscanf( fp, "%d %f\n", &param_id, &param_weight );
1592 if( fields_read != 2 )
1593 {
1594 llwarns << "Bad parameters list: early end of file" << llendl;
1595 return;
1596 }
1597 gAgent.getAvatarObject()->setVisualParamWeight( param_id, param_weight, TRUE);
1598 gAgent.getAvatarObject()->updateVisualParams();
1599 }
1600 }
1601
1602
1603
1604 //for( S32 i=0; i < WT_COUNT; i++ )
1605 //{
1606 // fields_read = fscanf( fp, "type %d\n", &typ);
1607 // if( fields_read != 1 )
1608 // {
1609 // llwarns << "Bad asset type: early end of file" << llendl;
1610 // return;
1611 // }
1612 // fields_read = fscanf( fp, "textures %d\n", &count);
1613 // if( fields_read != 1 )
1614 // {
1615 // llwarns << "Bad textures: early end of file" << llendl;
1616 // return;
1617 // }
1618 //
1619 // for(c=0;c<count;c++)
1620 // {
1621 // fields_read = fscanf( fp, "%d %2047s\n",text_buffer);
1622 // if( fields_read != 2 )
1623 // {
1624 // llwarns << "Bad textures list: early end of file" << llendl;
1625 // return;
1626 // }
1627 // }
1628
1629
1630 fclose(fp);
1631 return;
1632}
1633
1634// reX: new function
1635void LLFloaterCustomize::onBtnExport( void* userdata )
1636{
1637 LLFilePicker& file_picker = LLFilePicker::instance();
1638 if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_XML ) )
1639 {
1640 // User canceled export.
1641 return;
1642 }
1643
1644 LLViewerInventoryItem* item;
1645 BOOL is_modifiable;
1646
1647 const std::string filename = file_picker.getFirstFile();
1648
1649 FILE* fp = LLFile::fopen(filename, "wb");
1650
1651 for( S32 i=0; i < WT_COUNT; i++ )
1652 {
1653 is_modifiable = FALSE;
1654 LLWearable* old_wearable = gAgent.getWearable((EWearableType)i);
1655 if( old_wearable )
1656 {
1657 item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem((EWearableType)i);
1658 if(item)
1659 {
1660 const LLPermissions& perm = item->getPermissions();
1661 is_modifiable = perm.allowModifyBy(gAgent.getID(), gAgent.getGroupID());
1662 }
1663 }
1664 if (is_modifiable)
1665 {
1666 old_wearable->FileExportParams(fp);
1667 }
1668 if (!is_modifiable)
1669 {
1670 fprintf( fp, "type %d\n",i);
1671 fprintf( fp, "parameters 0\n");
1672 }
1673 }
1674
1675 for( S32 i=0; i < WT_COUNT; i++ )
1676 {
1677 is_modifiable = FALSE;
1678 LLWearable* old_wearable = gAgent.getWearable((EWearableType)i);
1679 if( old_wearable )
1680 {
1681 item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem((EWearableType)i);
1682 if(item)
1683 {
1684 const LLPermissions& perm = item->getPermissions();
1685 is_modifiable = perm.allowModifyBy(gAgent.getID(), gAgent.getGroupID());
1686 }
1687 }
1688 if (is_modifiable)
1689 {
1690 old_wearable->FileExportTextures(fp);
1691 }
1692 if (!is_modifiable)
1693 {
1694 fprintf( fp, "type %d\n",i);
1695 fprintf( fp, "textures 0\n");
1696 }
1697 }
1698
1699 fclose(fp);
1700}
1701
1497// static 1702// static
1498void LLFloaterCustomize::onBtnOk( void* userdata ) 1703void LLFloaterCustomize::onBtnOk( void* userdata )
1499{ 1704{
@@ -1957,6 +2162,21 @@ void LLFloaterCustomize::draw()
1957 // arrives. Figure out some way to avoid this if possible. 2162 // arrives. Figure out some way to avoid this if possible.
1958 updateInventoryUI(); 2163 updateInventoryUI();
1959 2164
2165 LLFloaterCustomize* floater_customize = gFloaterCustomize;
2166 if (!floater_customize) return;
2167
2168 //KOWs avatar height stuff
2169 LLVOAvatar* avatar = gAgent.getAvatarObject();
2170 F32 avatar_size = (avatar->mBodySize.mV[VZ]) + (F32)0.17; //mBodySize is actually quite a bit off.
2171
2172 floater_customize->getChild<LLTextBox>("HeightText")->setValue(llformat("%.2f", avatar_size) + "m");
2173 //inches = avatar_size * 39.37
2174 //round(inches) + inches % 12
2175 std::string temp = llformat("%.0f",(F32)llfloor(avatar_size / 0.3048));
2176 std::string temp2 = llformat("%.0f",(F32)(llround(avatar_size * 39.37) % 12));
2177 floater_customize->getChild<LLTextBox>("HeightText2")->setValue(temp + "'"
2178 + temp2 + "\"");
2179
1960 LLScrollingPanelParam::sUpdateDelayFrames = 0; 2180 LLScrollingPanelParam::sUpdateDelayFrames = 0;
1961 2181
1962 LLFloater::draw(); 2182 LLFloater::draw();