diff options
author | McCabe Maxsted | 2009-10-12 05:18:32 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-10-12 05:18:32 -0700 |
commit | 04f607ec08a572f7a98f267677f127a01a5369c3 (patch) | |
tree | 2d0faea69059083b8fa96658e3f2d9f15b73bb1f /linden/indra/newview/llfloatercustomize.cpp | |
parent | Added check/uncheck all buttons for make outfit from Meerkat viewer (diff) | |
download | meta-impy-04f607ec08a572f7a98f267677f127a01a5369c3.zip meta-impy-04f607ec08a572f7a98f267677f127a01a5369c3.tar.gz meta-impy-04f607ec08a572f7a98f267677f127a01a5369c3.tar.bz2 meta-impy-04f607ec08a572f7a98f267677f127a01a5369c3.tar.xz |
Added avatar shape import and export from Meerkat viewer
Diffstat (limited to 'linden/indra/newview/llfloatercustomize.cpp')
-rw-r--r-- | linden/indra/newview/llfloatercustomize.cpp | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloatercustomize.cpp b/linden/indra/newview/llfloatercustomize.cpp index 432af73..c542b37 100644 --- a/linden/indra/newview/llfloatercustomize.cpp +++ b/linden/indra/newview/llfloatercustomize.cpp | |||
@@ -1597,6 +1597,10 @@ BOOL LLFloaterCustomize::postBuild() | |||
1597 | childSetAction("Save All", LLFloaterCustomize::onBtnSaveAll, (void*)this); | 1597 | childSetAction("Save All", LLFloaterCustomize::onBtnSaveAll, (void*)this); |
1598 | childSetAction("Close", LLFloater::onClickClose, (void*)this); | 1598 | childSetAction("Close", LLFloater::onClickClose, (void*)this); |
1599 | 1599 | ||
1600 | // reX | ||
1601 | childSetAction("Import", LLFloaterCustomize::onBtnImport, (void*)this); | ||
1602 | childSetAction("Export", LLFloaterCustomize::onBtnExport, (void*)this); | ||
1603 | |||
1600 | // Wearable panels | 1604 | // Wearable panels |
1601 | initWearablePanels(); | 1605 | initWearablePanels(); |
1602 | 1606 | ||
@@ -1657,6 +1661,157 @@ void LLFloaterCustomize::setCurrentWearableType( EWearableType type ) | |||
1657 | } | 1661 | } |
1658 | } | 1662 | } |
1659 | 1663 | ||
1664 | |||
1665 | // reX: new function | ||
1666 | void LLFloaterCustomize::onBtnImport( void* userdata ) | ||
1667 | { | ||
1668 | LLFilePicker& file_picker = LLFilePicker::instance(); | ||
1669 | if( !file_picker.getOpenFile( LLFilePicker::FFLOAD_XML ) ) | ||
1670 | { | ||
1671 | // User canceled import. | ||
1672 | return; | ||
1673 | } | ||
1674 | |||
1675 | const std::string filename = file_picker.getFirstFile(); | ||
1676 | |||
1677 | FILE* fp = LLFile::fopen(filename, "rb"); | ||
1678 | |||
1679 | //char text_buffer[2048]; /* Flawfinder: ignore */ | ||
1680 | S32 c; | ||
1681 | S32 typ; | ||
1682 | S32 count; | ||
1683 | S32 param_id=0; | ||
1684 | F32 param_weight=0; | ||
1685 | S32 fields_read; | ||
1686 | |||
1687 | for( S32 i=0; i < WT_COUNT; i++ ) | ||
1688 | { | ||
1689 | fields_read = fscanf( fp, "type %d\n", &typ); | ||
1690 | if( fields_read != 1 ) | ||
1691 | { | ||
1692 | llwarns << "Bad asset type: early end of file" << llendl; | ||
1693 | return; | ||
1694 | } | ||
1695 | |||
1696 | fields_read = fscanf( fp, "parameters %d\n", &count); | ||
1697 | if( fields_read != 1 ) | ||
1698 | { | ||
1699 | llwarns << "Bad parameters : early end of file" << llendl; | ||
1700 | return; | ||
1701 | } | ||
1702 | for(c=0;c<count;c++) | ||
1703 | { | ||
1704 | fields_read = fscanf( fp, "%d %f\n", ¶m_id, ¶m_weight ); | ||
1705 | if( fields_read != 2 ) | ||
1706 | { | ||
1707 | llwarns << "Bad parameters list: early end of file" << llendl; | ||
1708 | return; | ||
1709 | } | ||
1710 | gAgent.getAvatarObject()->setVisualParamWeight( param_id, param_weight, TRUE); | ||
1711 | gAgent.getAvatarObject()->updateVisualParams(); | ||
1712 | } | ||
1713 | } | ||
1714 | |||
1715 | |||
1716 | |||
1717 | //for( S32 i=0; i < WT_COUNT; i++ ) | ||
1718 | //{ | ||
1719 | // fields_read = fscanf( fp, "type %d\n", &typ); | ||
1720 | // if( fields_read != 1 ) | ||
1721 | // { | ||
1722 | // llwarns << "Bad asset type: early end of file" << llendl; | ||
1723 | // return; | ||
1724 | // } | ||
1725 | // fields_read = fscanf( fp, "textures %d\n", &count); | ||
1726 | // if( fields_read != 1 ) | ||
1727 | // { | ||
1728 | // llwarns << "Bad textures: early end of file" << llendl; | ||
1729 | // return; | ||
1730 | // } | ||
1731 | // | ||
1732 | // for(c=0;c<count;c++) | ||
1733 | // { | ||
1734 | // fields_read = fscanf( fp, "%d %2047s\n",text_buffer); | ||
1735 | // if( fields_read != 2 ) | ||
1736 | // { | ||
1737 | // llwarns << "Bad textures list: early end of file" << llendl; | ||
1738 | // return; | ||
1739 | // } | ||
1740 | // } | ||
1741 | |||
1742 | |||
1743 | fclose(fp); | ||
1744 | return; | ||
1745 | } | ||
1746 | |||
1747 | // reX: new function | ||
1748 | void LLFloaterCustomize::onBtnExport( void* userdata ) | ||
1749 | { | ||
1750 | LLFilePicker& file_picker = LLFilePicker::instance(); | ||
1751 | if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_XML ) ) | ||
1752 | { | ||
1753 | // User canceled export. | ||
1754 | return; | ||
1755 | } | ||
1756 | |||
1757 | LLViewerInventoryItem* item; | ||
1758 | BOOL is_modifiable; | ||
1759 | |||
1760 | const std::string filename = file_picker.getFirstFile(); | ||
1761 | |||
1762 | FILE* fp = LLFile::fopen(filename, "wb"); | ||
1763 | |||
1764 | for( S32 i=0; i < WT_COUNT; i++ ) | ||
1765 | { | ||
1766 | is_modifiable = FALSE; | ||
1767 | LLWearable* old_wearable = gAgent.getWearable((EWearableType)i); | ||
1768 | if( old_wearable ) | ||
1769 | { | ||
1770 | item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem((EWearableType)i); | ||
1771 | if(item) | ||
1772 | { | ||
1773 | const LLPermissions& perm = item->getPermissions(); | ||
1774 | is_modifiable = perm.allowModifyBy(gAgent.getID(), gAgent.getGroupID()); | ||
1775 | } | ||
1776 | } | ||
1777 | if (is_modifiable) | ||
1778 | { | ||
1779 | old_wearable->FileExportParams(fp); | ||
1780 | } | ||
1781 | if (!is_modifiable) | ||
1782 | { | ||
1783 | fprintf( fp, "type %d\n",i); | ||
1784 | fprintf( fp, "parameters 0\n"); | ||
1785 | } | ||
1786 | } | ||
1787 | |||
1788 | for( S32 i=0; i < WT_COUNT; i++ ) | ||
1789 | { | ||
1790 | is_modifiable = FALSE; | ||
1791 | LLWearable* old_wearable = gAgent.getWearable((EWearableType)i); | ||
1792 | if( old_wearable ) | ||
1793 | { | ||
1794 | item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem((EWearableType)i); | ||
1795 | if(item) | ||
1796 | { | ||
1797 | const LLPermissions& perm = item->getPermissions(); | ||
1798 | is_modifiable = perm.allowModifyBy(gAgent.getID(), gAgent.getGroupID()); | ||
1799 | } | ||
1800 | } | ||
1801 | if (is_modifiable) | ||
1802 | { | ||
1803 | old_wearable->FileExportTextures(fp); | ||
1804 | } | ||
1805 | if (!is_modifiable) | ||
1806 | { | ||
1807 | fprintf( fp, "type %d\n",i); | ||
1808 | fprintf( fp, "textures 0\n"); | ||
1809 | } | ||
1810 | } | ||
1811 | |||
1812 | fclose(fp); | ||
1813 | } | ||
1814 | |||
1660 | // static | 1815 | // static |
1661 | void LLFloaterCustomize::onBtnSaveAll( void* userdata ) | 1816 | void LLFloaterCustomize::onBtnSaveAll( void* userdata ) |
1662 | { | 1817 | { |