diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloatercustomize.cpp | 224 |
1 files changed, 222 insertions, 2 deletions
diff --git a/linden/indra/newview/llfloatercustomize.cpp b/linden/indra/newview/llfloatercustomize.cpp index b9deb6c..4bcc823 100644 --- a/linden/indra/newview/llfloatercustomize.cpp +++ b/linden/indra/newview/llfloatercustomize.cpp | |||
@@ -245,6 +245,8 @@ public: | |||
245 | 245 | ||
246 | childSetAction("Save", onSave, this ); | 246 | childSetAction("Save", onSave, this ); |
247 | childSetAction("Cancel", onCancel, this ); | 247 | childSetAction("Cancel", onCancel, this ); |
248 | childSetAction("Check All", onCheckAll, this ); | ||
249 | childSetAction("Uncheck All", onUncheckAll, this ); | ||
248 | } | 250 | } |
249 | 251 | ||
250 | BOOL getRenameClothing() | 252 | BOOL getRenameClothing() |
@@ -325,6 +327,26 @@ public: | |||
325 | LLMakeOutfitDialog* self = (LLMakeOutfitDialog*) userdata; | 327 | LLMakeOutfitDialog* self = (LLMakeOutfitDialog*) userdata; |
326 | self->close(); // destroys this object | 328 | self->close(); // destroys this object |
327 | } | 329 | } |
330 | |||
331 | static void onCheckAll( void* userdata ) | ||
332 | { | ||
333 | LLMakeOutfitDialog* self = (LLMakeOutfitDialog*) userdata; | ||
334 | for( S32 i = 0; i < (S32)(self->mCheckBoxList.size()); i++) | ||
335 | { | ||
336 | std::string name = self->mCheckBoxList[i].first; | ||
337 | if(self->childIsEnabled(name))self->childSetValue(name,TRUE); | ||
338 | } | ||
339 | } | ||
340 | |||
341 | static void onUncheckAll( void* userdata ) | ||
342 | { | ||
343 | LLMakeOutfitDialog* self = (LLMakeOutfitDialog*) userdata; | ||
344 | for( S32 i = 0; i < (S32)(self->mCheckBoxList.size()); i++) | ||
345 | { | ||
346 | std::string name = self->mCheckBoxList[i].first; | ||
347 | if(self->childIsEnabled(name))self->childSetValue(name,FALSE); | ||
348 | } | ||
349 | } | ||
328 | }; | 350 | }; |
329 | 351 | ||
330 | ///////////////////////////////////////////////////////////////////// | 352 | ///////////////////////////////////////////////////////////////////// |
@@ -536,10 +558,26 @@ void LLPanelEditWearable::setSubpart( ESubpart subpart ) | |||
536 | item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem(mType); | 558 | item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem(mType); |
537 | U32 perm_mask = 0x0; | 559 | U32 perm_mask = 0x0; |
538 | BOOL is_complete = FALSE; | 560 | BOOL is_complete = FALSE; |
561 | bool can_export = false; | ||
562 | bool can_import = false; | ||
539 | if(item) | 563 | if(item) |
540 | { | 564 | { |
541 | perm_mask = item->getPermissions().getMaskOwner(); | 565 | perm_mask = item->getPermissions().getMaskOwner(); |
542 | is_complete = item->isComplete(); | 566 | is_complete = item->isComplete(); |
567 | |||
568 | if (subpart <= 18) // body parts only | ||
569 | { | ||
570 | can_import = true; | ||
571 | |||
572 | if (is_complete && | ||
573 | gAgent.getID() == item->getPermissions().getOwner() && | ||
574 | gAgent.getID() == item->getPermissions().getCreator() && | ||
575 | (PERM_ITEM_UNRESTRICTED & | ||
576 | perm_mask) == PERM_ITEM_UNRESTRICTED) | ||
577 | { | ||
578 | can_export = true; | ||
579 | } | ||
580 | } | ||
543 | } | 581 | } |
544 | setUIPermissions(perm_mask, is_complete); | 582 | setUIPermissions(perm_mask, is_complete); |
545 | BOOL editable = ((perm_mask & PERM_MODIFY) && is_complete) ? TRUE : FALSE; | 583 | BOOL editable = ((perm_mask & PERM_MODIFY) && is_complete) ? TRUE : FALSE; |
@@ -563,7 +601,8 @@ void LLPanelEditWearable::setSubpart( ESubpart subpart ) | |||
563 | } | 601 | } |
564 | gFloaterCustomize->generateVisualParamHints(NULL, sorted_params); | 602 | gFloaterCustomize->generateVisualParamHints(NULL, sorted_params); |
565 | gFloaterCustomize->updateScrollingPanelUI(); | 603 | gFloaterCustomize->updateScrollingPanelUI(); |
566 | 604 | gFloaterCustomize->childSetEnabled("Export", can_export); | |
605 | gFloaterCustomize->childSetEnabled("Import", can_import); | ||
567 | 606 | ||
568 | // Update the camera | 607 | // Update the camera |
569 | gMorphView->setCameraTargetJoint( gAgent.getAvatarObject()->getJoint( part->mTargetJoint ) ); | 608 | gMorphView->setCameraTargetJoint( gAgent.getAvatarObject()->getJoint( part->mTargetJoint ) ); |
@@ -1287,7 +1326,18 @@ void LLScrollingPanelParam::onSliderMoved(LLUICtrl* ctrl, void* userdata) | |||
1287 | F32 new_weight = self->percentToWeight( (F32)slider->getValue().asReal() ); | 1326 | F32 new_weight = self->percentToWeight( (F32)slider->getValue().asReal() ); |
1288 | if (current_weight != new_weight ) | 1327 | if (current_weight != new_weight ) |
1289 | { | 1328 | { |
1290 | gAgent.getAvatarObject()->setVisualParamWeight( param, new_weight, TRUE); | 1329 | LLFloaterCustomize* floater_customize = gFloaterCustomize; |
1330 | if (!floater_customize) return; | ||
1331 | |||
1332 | //avatar height stuff -Patrick Sapinski (Wednesday, August 19, 2009) | ||
1333 | LLVOAvatar* avatar = gAgent.getAvatarObject(); | ||
1334 | F32 avatar_size = (avatar->mBodySize.mV[VZ]) + (F32)0.17; //mBodySize is actually quite a bit off. | ||
1335 | |||
1336 | floater_customize->getChild<LLTextBox>("HeightText")->setValue(llformat("%.2f", avatar_size) + "m"); | ||
1337 | floater_customize->getChild<LLTextBox>("HeightText2")->setValue(llformat("%.2f",llround(avatar_size / 0.3048)) + "'" | ||
1338 | + llformat("%.2f",llround(avatar_size * 39.37) % 12) + "\""); | ||
1339 | |||
1340 | gAgent.getAvatarObject()->setVisualParamWeight( param, new_weight, FALSE); | ||
1291 | gAgent.getAvatarObject()->updateVisualParams(); | 1341 | gAgent.getAvatarObject()->updateVisualParams(); |
1292 | } | 1342 | } |
1293 | } | 1343 | } |
@@ -1563,6 +1613,10 @@ BOOL LLFloaterCustomize::postBuild() | |||
1563 | childSetAction("Save All", LLFloaterCustomize::onBtnSaveAll, (void*)this); | 1613 | childSetAction("Save All", LLFloaterCustomize::onBtnSaveAll, (void*)this); |
1564 | childSetAction("Close", LLFloater::onClickClose, (void*)this); | 1614 | childSetAction("Close", LLFloater::onClickClose, (void*)this); |
1565 | 1615 | ||
1616 | // reX | ||
1617 | childSetAction("Import", LLFloaterCustomize::onBtnImport, (void*)this); | ||
1618 | childSetAction("Export", LLFloaterCustomize::onBtnExport, (void*)this); | ||
1619 | |||
1566 | // Wearable panels | 1620 | // Wearable panels |
1567 | initWearablePanels(); | 1621 | initWearablePanels(); |
1568 | 1622 | ||
@@ -1623,6 +1677,157 @@ void LLFloaterCustomize::setCurrentWearableType( EWearableType type ) | |||
1623 | } | 1677 | } |
1624 | } | 1678 | } |
1625 | 1679 | ||
1680 | |||
1681 | // reX: new function | ||
1682 | void LLFloaterCustomize::onBtnImport( void* userdata ) | ||
1683 | { | ||
1684 | LLFilePicker& file_picker = LLFilePicker::instance(); | ||
1685 | if( !file_picker.getOpenFile( LLFilePicker::FFLOAD_XML ) ) | ||
1686 | { | ||
1687 | // User canceled import. | ||
1688 | return; | ||
1689 | } | ||
1690 | |||
1691 | const std::string filename = file_picker.getFirstFile(); | ||
1692 | |||
1693 | FILE* fp = LLFile::fopen(filename, "rb"); | ||
1694 | |||
1695 | //char text_buffer[2048]; /* Flawfinder: ignore */ | ||
1696 | S32 c; | ||
1697 | S32 typ; | ||
1698 | S32 count; | ||
1699 | S32 param_id=0; | ||
1700 | F32 param_weight=0; | ||
1701 | S32 fields_read; | ||
1702 | |||
1703 | for( S32 i=0; i < WT_COUNT; i++ ) | ||
1704 | { | ||
1705 | fields_read = fscanf( fp, "type %d\n", &typ); | ||
1706 | if( fields_read != 1 ) | ||
1707 | { | ||
1708 | llwarns << "Bad asset type: early end of file" << llendl; | ||
1709 | return; | ||
1710 | } | ||
1711 | |||
1712 | fields_read = fscanf( fp, "parameters %d\n", &count); | ||
1713 | if( fields_read != 1 ) | ||
1714 | { | ||
1715 | llwarns << "Bad parameters : early end of file" << llendl; | ||
1716 | return; | ||
1717 | } | ||
1718 | for(c=0;c<count;c++) | ||
1719 | { | ||
1720 | fields_read = fscanf( fp, "%d %f\n", ¶m_id, ¶m_weight ); | ||
1721 | if( fields_read != 2 ) | ||
1722 | { | ||
1723 | llwarns << "Bad parameters list: early end of file" << llendl; | ||
1724 | return; | ||
1725 | } | ||
1726 | gAgent.getAvatarObject()->setVisualParamWeight( param_id, param_weight, TRUE); | ||
1727 | gAgent.getAvatarObject()->updateVisualParams(); | ||
1728 | } | ||
1729 | } | ||
1730 | |||
1731 | |||
1732 | |||
1733 | //for( S32 i=0; i < WT_COUNT; i++ ) | ||
1734 | //{ | ||
1735 | // fields_read = fscanf( fp, "type %d\n", &typ); | ||
1736 | // if( fields_read != 1 ) | ||
1737 | // { | ||
1738 | // llwarns << "Bad asset type: early end of file" << llendl; | ||
1739 | // return; | ||
1740 | // } | ||
1741 | // fields_read = fscanf( fp, "textures %d\n", &count); | ||
1742 | // if( fields_read != 1 ) | ||
1743 | // { | ||
1744 | // llwarns << "Bad textures: early end of file" << llendl; | ||
1745 | // return; | ||
1746 | // } | ||
1747 | // | ||
1748 | // for(c=0;c<count;c++) | ||
1749 | // { | ||
1750 | // fields_read = fscanf( fp, "%d %2047s\n",text_buffer); | ||
1751 | // if( fields_read != 2 ) | ||
1752 | // { | ||
1753 | // llwarns << "Bad textures list: early end of file" << llendl; | ||
1754 | // return; | ||
1755 | // } | ||
1756 | // } | ||
1757 | |||
1758 | |||
1759 | fclose(fp); | ||
1760 | return; | ||
1761 | } | ||
1762 | |||
1763 | // reX: new function | ||
1764 | void LLFloaterCustomize::onBtnExport( void* userdata ) | ||
1765 | { | ||
1766 | LLFilePicker& file_picker = LLFilePicker::instance(); | ||
1767 | if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_XML ) ) | ||
1768 | { | ||
1769 | // User canceled export. | ||
1770 | return; | ||
1771 | } | ||
1772 | |||
1773 | LLViewerInventoryItem* item; | ||
1774 | BOOL is_modifiable; | ||
1775 | |||
1776 | const std::string filename = file_picker.getFirstFile(); | ||
1777 | |||
1778 | FILE* fp = LLFile::fopen(filename, "wb"); | ||
1779 | |||
1780 | for( S32 i=0; i < WT_COUNT; i++ ) | ||
1781 | { | ||
1782 | is_modifiable = FALSE; | ||
1783 | LLWearable* old_wearable = gAgent.getWearable((EWearableType)i); | ||
1784 | if( old_wearable ) | ||
1785 | { | ||
1786 | item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem((EWearableType)i); | ||
1787 | if(item) | ||
1788 | { | ||
1789 | const LLPermissions& perm = item->getPermissions(); | ||
1790 | is_modifiable = perm.allowModifyBy(gAgent.getID(), gAgent.getGroupID()); | ||
1791 | } | ||
1792 | } | ||
1793 | if (is_modifiable) | ||
1794 | { | ||
1795 | old_wearable->FileExportParams(fp); | ||
1796 | } | ||
1797 | if (!is_modifiable) | ||
1798 | { | ||
1799 | fprintf( fp, "type %d\n",i); | ||
1800 | fprintf( fp, "parameters 0\n"); | ||
1801 | } | ||
1802 | } | ||
1803 | |||
1804 | for( S32 i=0; i < WT_COUNT; i++ ) | ||
1805 | { | ||
1806 | is_modifiable = FALSE; | ||
1807 | LLWearable* old_wearable = gAgent.getWearable((EWearableType)i); | ||
1808 | if( old_wearable ) | ||
1809 | { | ||
1810 | item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem((EWearableType)i); | ||
1811 | if(item) | ||
1812 | { | ||
1813 | const LLPermissions& perm = item->getPermissions(); | ||
1814 | is_modifiable = perm.allowModifyBy(gAgent.getID(), gAgent.getGroupID()); | ||
1815 | } | ||
1816 | } | ||
1817 | if (is_modifiable) | ||
1818 | { | ||
1819 | old_wearable->FileExportTextures(fp); | ||
1820 | } | ||
1821 | if (!is_modifiable) | ||
1822 | { | ||
1823 | fprintf( fp, "type %d\n",i); | ||
1824 | fprintf( fp, "textures 0\n"); | ||
1825 | } | ||
1826 | } | ||
1827 | |||
1828 | fclose(fp); | ||
1829 | } | ||
1830 | |||
1626 | // static | 1831 | // static |
1627 | void LLFloaterCustomize::onBtnSaveAll( void* userdata ) | 1832 | void LLFloaterCustomize::onBtnSaveAll( void* userdata ) |
1628 | { | 1833 | { |
@@ -2122,6 +2327,21 @@ void LLFloaterCustomize::draw() | |||
2122 | // arrives. Figure out some way to avoid this if possible. | 2327 | // arrives. Figure out some way to avoid this if possible. |
2123 | updateInventoryUI(); | 2328 | updateInventoryUI(); |
2124 | 2329 | ||
2330 | LLFloaterCustomize* floater_customize = gFloaterCustomize; | ||
2331 | if (!floater_customize) return; | ||
2332 | |||
2333 | //KOWs avatar height stuff | ||
2334 | LLVOAvatar* avatar = gAgent.getAvatarObject(); | ||
2335 | F32 avatar_size = (avatar->mBodySize.mV[VZ]) + (F32)0.17; //mBodySize is actually quite a bit off. | ||
2336 | |||
2337 | floater_customize->getChild<LLTextBox>("HeightText")->setValue(llformat("%.2f", avatar_size) + "m"); | ||
2338 | //inches = avatar_size * 39.37 | ||
2339 | //round(inches) + inches % 12 | ||
2340 | std::string temp = llformat("%.0f",(F32)llfloor(avatar_size / 0.3048)); | ||
2341 | std::string temp2 = llformat("%.0f",(F32)(llround(avatar_size * 39.37) % 12)); | ||
2342 | floater_customize->getChild<LLTextBox>("HeightText2")->setValue(temp + "'" | ||
2343 | + temp2 + "\""); | ||
2344 | |||
2125 | LLScrollingPanelParam::sUpdateDelayFrames = 0; | 2345 | LLScrollingPanelParam::sUpdateDelayFrames = 0; |
2126 | 2346 | ||
2127 | childSetEnabled("Save All", isDirty() ); | 2347 | childSetEnabled("Save All", isDirty() ); |