diff options
Diffstat (limited to 'indra/newview/llfloatermodelwizard.cpp')
-rw-r--r-- | indra/newview/llfloatermodelwizard.cpp | 141 |
1 files changed, 138 insertions, 3 deletions
diff --git a/indra/newview/llfloatermodelwizard.cpp b/indra/newview/llfloatermodelwizard.cpp index 79c29ef017..6a92e43d1a 100644 --- a/indra/newview/llfloatermodelwizard.cpp +++ b/indra/newview/llfloatermodelwizard.cpp @@ -28,19 +28,71 @@ #include "llviewerprecompiledheaders.h" +#include "llbutton.h" #include "lldrawable.h" +#include "llcombobox.h" #include "llfloater.h" #include "llfloatermodelwizard.h" #include "llfloatermodelpreview.h" #include "llfloaterreg.h" +#include "llslider.h" +static const std::string stateNames[]={ + "choose_file", + "optimize", + "physics", + "review", + "upload"}; LLFloaterModelWizard::LLFloaterModelWizard(const LLSD& key) : LLFloater(key) { } +void LLFloaterModelWizard::setState(int state) +{ + mState = state; + setButtons(state); + + for(size_t t=0; t<LL_ARRAY_SIZE(stateNames); ++t) + { + LLView *view = getChild<LLView>(stateNames[t]+"_panel"); + if (view) + { + view->setVisible(state == (int) t ? TRUE : FALSE); + } + } + + if (state == OPTIMIZE) + { + mModelPreview->genLODs(-1); + } +} + +void LLFloaterModelWizard::setButtons(int state) +{ + for(size_t i=0; i<LL_ARRAY_SIZE(stateNames); ++i) + { + LLButton *button = getChild<LLButton>(stateNames[i]+"_btn"); + + if (i < state) + { + button->setEnabled(TRUE); + button->setToggleState(FALSE); + } + else if (i == state) + { + button->setEnabled(TRUE); + button->setToggleState(TRUE); + } + else + { + button->setEnabled(FALSE); + } + } +} + void LLFloaterModelWizard::loadModel() { mModelPreview->mLoading = TRUE; @@ -48,6 +100,30 @@ void LLFloaterModelWizard::loadModel() (new LLMeshFilePicker(mModelPreview, 3))->getFile(); } +void LLFloaterModelWizard::onClickCancel() +{ + closeFloater(); +} + +void LLFloaterModelWizard::onClickBack() +{ + setState(llmax((int) CHOOSE_FILE, mState-1)); +} + +void LLFloaterModelWizard::onClickNext() +{ + setState(llmin((int) UPLOAD, mState+1)); +} + +bool LLFloaterModelWizard::onEnableNext() +{ + return true; +} + +bool LLFloaterModelWizard::onEnableBack() +{ + return true; +} BOOL LLFloaterModelWizard::postBuild() { @@ -56,7 +132,20 @@ BOOL LLFloaterModelWizard::postBuild() childSetValue("import_scale", (F32) 0.67335826); getChild<LLUICtrl>("browse")->setCommitCallback(boost::bind(&LLFloaterModelWizard::loadModel, this)); + getChild<LLUICtrl>("cancel")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickCancel, this)); + getChild<LLUICtrl>("back")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickBack, this)); + getChild<LLUICtrl>("next")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickNext, this)); + childSetCommitCallback("preview_lod_combo", onPreviewLODCommit, this); + getChild<LLUICtrl>("accuracy_slider")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onAccuracyPerformance, this, _2)); + + childSetAction("ok_btn", onUpload, this); + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + + enable_registrar.add("Next.OnEnable", boost::bind(&LLFloaterModelWizard::onEnableNext, this)); + enable_registrar.add("Back.OnEnable", boost::bind(&LLFloaterModelWizard::onEnableBack, this)); + + mPreviewRect = preview_panel->getRect(); mModelPreview = new LLModelPreview(512, 512, this); @@ -64,9 +153,55 @@ BOOL LLFloaterModelWizard::postBuild() center(); + setState(CHOOSE_FILE); + + childSetTextArg("import_dimensions", "[X]", LLStringUtil::null); + childSetTextArg("import_dimensions", "[Y]", LLStringUtil::null); + childSetTextArg("import_dimensions", "[Z]", LLStringUtil::null); + return TRUE; } +void LLFloaterModelWizard::onUpload(void* user_data) +{ + LLFloaterModelWizard* mp = (LLFloaterModelWizard*) user_data; + + mp->mModelPreview->rebuildUploadData(); + + gMeshRepo.uploadModel(mp->mModelPreview->mUploadData, mp->mModelPreview->mPreviewScale, + mp->childGetValue("upload_textures").asBoolean(), mp->childGetValue("upload_skin"), mp->childGetValue("upload_joints")); + + mp->closeFloater(false); +} + + +void LLFloaterModelWizard::onAccuracyPerformance(const LLSD& data) +{ + int val = (int) data.asInteger(); + + mModelPreview->genLODs(-1, NUM_LOD-val); + + mModelPreview->refresh(); +} + +void LLFloaterModelWizard::onPreviewLODCommit(LLUICtrl* ctrl, void* userdata) +{ + LLFloaterModelWizard *fp =(LLFloaterModelWizard *)userdata; + + if (!fp->mModelPreview) + { + return; + } + + S32 which_mode = 0; + + LLComboBox* combo = (LLComboBox*) ctrl; + + which_mode = (NUM_LOD-1)-combo->getFirstSelectedIndex(); // combo box list of lods is in reverse order + + fp->mModelPreview->setPreviewLOD(which_mode); +} + void LLFloaterModelWizard::draw() { LLFloater::draw(); @@ -74,14 +209,14 @@ void LLFloaterModelWizard::draw() mModelPreview->update(); - if (mModelPreview && mModelPreview->mModelLoader) + if (mModelPreview) { gGL.color3f(1.f, 1.f, 1.f); gGL.getTexUnit(0)->bind(mModelPreview); - - LLView* preview_panel = getChild<LLView>("preview_panel"); + LLView *view = getChild<LLView>(stateNames[mState]+"_panel"); + LLView* preview_panel = view->getChild<LLView>("preview_panel"); LLRect rect = preview_panel->getRect(); if (rect != mPreviewRect) |