llfloatersaveavatar.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llfloatersaveavatar.h"
00035 
00036 #include "lldir.h"
00037 
00038 #include "llagent.h"
00039 #include "llvoavatar.h"
00040 #include "llbutton.h"
00041 #include "lllineeditor.h"
00042 #include "llvieweruictrlfactory.h"
00043 #include "llviewercontrol.h"
00044 
00045 static LLFloaterSaveAvatar* mSingleton = NULL;
00046 
00047 LLFloaterSaveAvatar::LLFloaterSaveAvatar() : LLFloater("Save Avatar")
00048 {
00049         llassert( !mSingleton );
00050         mSingleton = this;
00051 }
00052 
00053 LLFloaterSaveAvatar::~LLFloaterSaveAvatar()
00054 {
00055         llassert( mSingleton == this );
00056         mSingleton = NULL;
00057 }
00058 
00059 // Creates singleton or (if it already exists) brings it to the front
00060 // static
00061 void LLFloaterSaveAvatar::show()
00062 {
00063         if ( !mSingleton)
00064         {
00065                 LLFloaterSaveAvatar *instance = new LLFloaterSaveAvatar();
00066 
00067                 gUICtrlFactory->buildFloater(instance, "floater_save_avatar.xml");
00068                 S32 left;
00069                 S32 top;
00070                 gFloaterView->getNewFloaterPosition(&left, &top);
00071                 instance->setOrigin(left, top - instance->getRect().getHeight());
00072         }
00073         else
00074         {
00075                 mSingleton->open();             /*Flawfinder: ignore*/
00076         }
00077 }
00078 
00079 BOOL LLFloaterSaveAvatar::postBuild()
00080 {
00081         mBaseNameEdit = LLViewerUICtrlFactory::getLineEditorByName(this, "base_name_edit");
00082         mBaseNameEdit->setText(gSavedSettings.getString("AvExportBaseName"));
00083         mPathEdit = LLViewerUICtrlFactory::getLineEditorByName(this, "path_edit");
00084         mPathEdit->setText(gSavedSettings.getString("AvExportPath"));
00085         
00086         mSaveBtn = LLViewerUICtrlFactory::getButtonByName(this, "save_btn");
00087         mSaveBtn->setClickedCallback(onSave);
00088         mSaveBtn->setCallbackUserData(this);
00089 
00090         return TRUE;
00091 }
00092 
00093 //static 
00094 void LLFloaterSaveAvatar::onSave( void* user_data )
00095 {
00096         LLFloaterSaveAvatar* self = (LLFloaterSaveAvatar*)user_data;
00097 
00098         gSavedSettings.setString("AvExportPath", self->mPathEdit->getText());
00099         gSavedSettings.setString("AvExportBaseName", self->mBaseNameEdit->getText());
00100         
00101         std::string path_name = self->mPathEdit->getText();
00102         if (path_name.size() && *(path_name.end() - 1) == '\\')
00103         {
00104                 // remove trailing backslash
00105                 path_name.erase(path_name.end() - 1);
00106         }
00107 
00108         std::string base_name = self->mBaseNameEdit->getText();
00109         if (base_name.size() && *(base_name.end() - 1) == '_')
00110         {
00111                 // remove trailing underscore
00112                 base_name.erase(base_name.end() - 1);
00113         }
00114 
00115         gAgent.getAvatarObject()->writeCAL3D(path_name, base_name);
00116         self->close();
00117 }

Generated on Thu Jul 1 06:08:36 2010 for Second Life Viewer by  doxygen 1.4.7