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 | |
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 '')
-rw-r--r-- | ChangeLog.txt | 9 | ||||
-rw-r--r-- | linden/indra/newview/llfloatercustomize.cpp | 155 | ||||
-rw-r--r-- | linden/indra/newview/llfloatercustomize.h | 4 | ||||
-rw-r--r-- | linden/indra/newview/llwearable.cpp | 69 | ||||
-rw-r--r-- | linden/indra/newview/llwearable.h | 4 | ||||
-rw-r--r-- | linden/indra/newview/skins/default/xui/en-us/floater_customize.xml | 10 |
6 files changed, 236 insertions, 15 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index c397bc6..f71a3f7 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt | |||
@@ -1,5 +1,14 @@ | |||
1 | 2009-10-12 McCabe Maxsted <hakushakukun@gmail.com> | 1 | 2009-10-12 McCabe Maxsted <hakushakukun@gmail.com> |
2 | 2 | ||
3 | * Added avatar shape import and export from Meerkat viewer. | ||
4 | |||
5 | modified: linden/indra/newview/llfloatercustomize.cpp | ||
6 | modified: linden/indra/newview/llfloatercustomize.h | ||
7 | modified: linden/indra/newview/llwearable.cpp | ||
8 | modified: linden/indra/newview/llwearable.h | ||
9 | modified: linden/indra/newview/skins/default/xui/en-us/floater_customize.xml | ||
10 | |||
11 | |||
3 | * Added check/uncheck all buttons for make outfit from Meerkat viewer. | 12 | * Added check/uncheck all buttons for make outfit from Meerkat viewer. |
4 | 13 | ||
5 | modified: linden/indra/newview/llfloatercustomize.cpp | 14 | modified: linden/indra/newview/llfloatercustomize.cpp |
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 | { |
diff --git a/linden/indra/newview/llfloatercustomize.h b/linden/indra/newview/llfloatercustomize.h index 15fc8f1..ffa943a 100644 --- a/linden/indra/newview/llfloatercustomize.h +++ b/linden/indra/newview/llfloatercustomize.h | |||
@@ -107,6 +107,10 @@ public: | |||
107 | static EWearableType getCurrentWearableType() { return sCurrentWearableType; } | 107 | static EWearableType getCurrentWearableType() { return sCurrentWearableType; } |
108 | 108 | ||
109 | // Callbacks | 109 | // Callbacks |
110 | // reX: new function (thx dudes) | ||
111 | static void onBtnImport( void* userdata ); | ||
112 | // reX: new function | ||
113 | static void onBtnExport( void* userdata ); | ||
110 | static void onBtnSaveAll( void* userdata ); | 114 | static void onBtnSaveAll( void* userdata ); |
111 | static void onBtnSnapshot( void* userdata ); | 115 | static void onBtnSnapshot( void* userdata ); |
112 | static void onBtnMakeOutfit( void* userdata ); | 116 | static void onBtnMakeOutfit( void* userdata ); |
diff --git a/linden/indra/newview/llwearable.cpp b/linden/indra/newview/llwearable.cpp index 6bdc50f..884cda5 100644 --- a/linden/indra/newview/llwearable.cpp +++ b/linden/indra/newview/llwearable.cpp | |||
@@ -150,41 +150,87 @@ EWearableType LLWearable::typeNameToType( const std::string& type_name ) | |||
150 | return WT_INVALID; | 150 | return WT_INVALID; |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | const char* terse_F32_to_string( F32 f, char s[MAX_STRING] ) /* Flawfinder: ignore */ | |
154 | std::string terse_F32_to_string( F32 f ) | ||
155 | { | 154 | { |
156 | std::string r = llformat( "%.2f", f ); | 155 | char* r = s; |
156 | S32 len = snprintf( s, MAX_STRING, "%.2f", f ); /* Flawfinder: ignore */ | ||
157 | 157 | ||
158 | // "1.20" -> "1.2" | 158 | // "1.20" -> "1.2" |
159 | // "24.00" -> "24." | 159 | // "24.00" -> "24." |
160 | S32 len = r.length(); | 160 | while( '0' == r[len - 1] ) |
161 | while( len > 0 && '0' == r[len - 1] ) | ||
162 | { | 161 | { |
163 | r.erase(len-1, 1); | 162 | len--; |
164 | len--; | 163 | r[len] = '\0'; |
165 | } | 164 | } |
166 | 165 | ||
167 | if( '.' == r[len - 1] ) | 166 | if( '.' == r[len - 1] ) |
168 | { | 167 | { |
169 | // "24." -> "24" | 168 | // "24." -> "24" |
170 | r.erase(len-1, 1); | 169 | len--; |
170 | r[len] = '\0'; | ||
171 | } | 171 | } |
172 | else | 172 | else |
173 | if( ('-' == r[0]) && ('0' == r[1]) ) | 173 | if( ('-' == r[0]) && ('0' == r[1]) ) |
174 | { | 174 | { |
175 | // "-0.59" -> "-.59" | 175 | // "-0.59" -> "-.59" |
176 | r.erase(1, 1); | 176 | r++; |
177 | r[0] = '-'; | ||
177 | } | 178 | } |
178 | else | 179 | else |
179 | if( '0' == r[0] ) | 180 | if( '0' == r[0] ) |
180 | { | 181 | { |
181 | // "0.59" -> ".59" | 182 | // "0.59" -> ".59" |
182 | r.erase(0, 1); | 183 | r++; |
183 | } | 184 | } |
184 | 185 | ||
185 | return r; | 186 | return r; |
186 | } | 187 | } |
187 | 188 | ||
189 | // reX: new function | ||
190 | BOOL LLWearable::FileExportParams( FILE* file ) | ||
191 | { | ||
192 | // wearable type | ||
193 | S32 type = (S32)mType; | ||
194 | fprintf( file, "type %d\n", type ); | ||
195 | |||
196 | // parameters | ||
197 | S32 num_parameters = mVisualParamMap.size(); | ||
198 | fprintf( file, "parameters %d\n", num_parameters ); | ||
199 | |||
200 | char s[ MAX_STRING ]; /* Flawfinder: ignore */ | ||
201 | for (param_map_t::iterator iter = mVisualParamMap.begin(); | ||
202 | iter != mVisualParamMap.end(); ++iter) | ||
203 | { | ||
204 | S32 param_id = iter->first; | ||
205 | F32 param_weight = iter->second; | ||
206 | fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight, s ) ); | ||
207 | } | ||
208 | |||
209 | return TRUE; | ||
210 | } | ||
211 | |||
212 | // reX: new function | ||
213 | BOOL LLWearable::FileExportTextures( FILE* file ) | ||
214 | { | ||
215 | // wearable type | ||
216 | S32 type = (S32)mType; | ||
217 | fprintf( file, "type %d\n", type ); | ||
218 | |||
219 | // texture entries | ||
220 | S32 num_textures = mTEMap.size(); | ||
221 | fprintf( file, "textures %d\n", num_textures ); | ||
222 | |||
223 | for (te_map_t::iterator iter = mTEMap.begin(); | ||
224 | iter != mTEMap.end(); ++iter) | ||
225 | { | ||
226 | S32 te = iter->first; | ||
227 | LLUUID& image_id = iter->second; | ||
228 | fprintf( file, "%d %s\n", te, image_id.asString().c_str() ); | ||
229 | } | ||
230 | |||
231 | return TRUE; | ||
232 | } | ||
233 | |||
188 | BOOL LLWearable::exportFile( LLFILE* file ) | 234 | BOOL LLWearable::exportFile( LLFILE* file ) |
189 | { | 235 | { |
190 | // header and version | 236 | // header and version |
@@ -231,12 +277,13 @@ BOOL LLWearable::exportFile( LLFILE* file ) | |||
231 | return FALSE; | 277 | return FALSE; |
232 | } | 278 | } |
233 | 279 | ||
280 | char s[ MAX_STRING ]; /* Flawfinder: ignore */ | ||
234 | for (param_map_t::iterator iter = mVisualParamMap.begin(); | 281 | for (param_map_t::iterator iter = mVisualParamMap.begin(); |
235 | iter != mVisualParamMap.end(); ++iter) | 282 | iter != mVisualParamMap.end(); ++iter) |
236 | { | 283 | { |
237 | S32 param_id = iter->first; | 284 | S32 param_id = iter->first; |
238 | F32 param_weight = iter->second; | 285 | F32 param_weight = iter->second; |
239 | if( fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight ).c_str() ) < 0 ) | 286 | if( fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight, s ) ) < 0 ) |
240 | { | 287 | { |
241 | return FALSE; | 288 | return FALSE; |
242 | } | 289 | } |
diff --git a/linden/indra/newview/llwearable.h b/linden/indra/newview/llwearable.h index ea16d20..9986e85 100644 --- a/linden/indra/newview/llwearable.h +++ b/linden/indra/newview/llwearable.h | |||
@@ -60,6 +60,10 @@ public: | |||
60 | 60 | ||
61 | BOOL exportFile(LLFILE* file); | 61 | BOOL exportFile(LLFILE* file); |
62 | BOOL importFile(LLFILE* file); | 62 | BOOL importFile(LLFILE* file); |
63 | // reX: new function | ||
64 | BOOL FileExportParams(FILE* file); | ||
65 | // reX: new function | ||
66 | BOOL FileExportTextures(FILE* file); | ||
63 | 67 | ||
64 | EWearableType getType() const { return mType; } | 68 | EWearableType getType() const { return mType; } |
65 | void setType( EWearableType type ) { mType = type; } | 69 | void setType( EWearableType type ) { mType = type; } |
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_customize.xml b/linden/indra/newview/skins/default/xui/en-us/floater_customize.xml index e02607c..527ec4e 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_customize.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_customize.xml | |||
@@ -1077,12 +1077,14 @@ scratch and wear it. | |||
1077 | </text> | 1077 | </text> |
1078 | <button bottom="-536" follows="right|bottom" font="SansSerif" halign="center" | 1078 | <button bottom="-536" follows="right|bottom" font="SansSerif" halign="center" |
1079 | height="20" label="Close" label_selected="Close" mouse_opaque="true" | 1079 | height="20" label="Close" label_selected="Close" mouse_opaque="true" |
1080 | name="Close" right="-10" scale_image="true" width="100" /> | 1080 | name="Close" right="-10" scale_image="true" width="80" /> |
1081 | <button bottom="-536" follows="right|bottom" font="SansSerif" halign="center" | 1081 | <button bottom="-536" follows="right|bottom" font="SansSerif" halign="center" |
1082 | height="20" label="Save All" label_selected="Save All" mouse_opaque="true" | 1082 | height="20" label="Save All" label_selected="Save All" mouse_opaque="true" |
1083 | name="Save All" right="-116" scale_image="true" width="100" /> | 1083 | name="Save All" right="-100" scale_image="true" width="80" /> |
1084 | <button bottom="-536" follows="right|bottom" font="SansSerif" halign="center" | 1084 | <button bottom="-536" follows="right|bottom" font="SansSerif" halign="center" |
1085 | height="20" label="Make Outfit" label_selected="Make Outfit" | 1085 | height="20" label="Make Outfit" label_selected="Make Outfit" |
1086 | mouse_opaque="true" name="Make Outfit" right="-222" scale_image="true" | 1086 | mouse_opaque="true" name="Make Outfit" right="-190" scale_image="true" |
1087 | width="100" /> | 1087 | width="80" /> |
1088 | <button bottom="-536" follows="right|bottom" font="SansSerif" halign="center" height="20" hidden="false" label="Export" label_selected="Export" right="-280" mouse_opaque="true" name="Export" scale_image="true" width="80" /> | ||
1089 | <button bottom="-536" follows="right|bottom" font="SansSerif" halign="center" height="20" hidden="false" label="Import" label_selected="Import" right="-370" mouse_opaque="true" name="Import" scale_image="true" width="80" /> | ||
1088 | </floater> | 1090 | </floater> |