aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpreviewgesture.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:11 -0500
committerJacek Antonelli2008-08-15 23:45:11 -0500
commit215f423cbe18fe9ca14a26caef918d303bad28ff (patch)
tree0743442b286216cc8e19aa487c26f4e9345ffd64 /linden/indra/newview/llpreviewgesture.cpp
parentSecond Life viewer sources 1.18.3.5-RC (diff)
downloadmeta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.zip
meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.tar.gz
meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.tar.bz2
meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.tar.xz
Second Life viewer sources 1.18.4.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llpreviewgesture.cpp90
1 files changed, 63 insertions, 27 deletions
diff --git a/linden/indra/newview/llpreviewgesture.cpp b/linden/indra/newview/llpreviewgesture.cpp
index 1afa523..720963c 100644
--- a/linden/indra/newview/llpreviewgesture.cpp
+++ b/linden/indra/newview/llpreviewgesture.cpp
@@ -2,6 +2,8 @@
2 * @file llpreviewgesture.cpp 2 * @file llpreviewgesture.cpp
3 * @brief Editing UI for inventory-based gestures. 3 * @brief Editing UI for inventory-based gestures.
4 * 4 *
5 * $LicenseInfo:firstyear=2004&license=viewergpl$
6 *
5 * Copyright (c) 2004-2007, Linden Research, Inc. 7 * Copyright (c) 2004-2007, Linden Research, Inc.
6 * 8 *
7 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
@@ -24,6 +26,7 @@
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE. 28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
27 */ 30 */
28 31
29#include "llviewerprecompiledheaders.h" 32#include "llviewerprecompiledheaders.h"
@@ -66,6 +69,7 @@
66 69
67#include "llresmgr.h" 70#include "llresmgr.h"
68 71
72// *TODO: Translate?
69const char NONE_LABEL[] = "---"; 73const char NONE_LABEL[] = "---";
70const char SHIFT_LABEL[] = "Shift"; 74const char SHIFT_LABEL[] = "Shift";
71const char CTRL_LABEL[] = "Ctrl"; 75const char CTRL_LABEL[] = "Ctrl";
@@ -147,6 +151,13 @@ LLPreviewGesture* LLPreviewGesture::show(const std::string& title, const LLUUID&
147 hostp->addFloater(self, TRUE); 151 hostp->addFloater(self, TRUE);
148 } 152 }
149 153
154 // Start speculative download of sounds and animations
155 LLUUID animation_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_ANIMATION);
156 gInventory.startBackgroundFetch(animation_folder_id);
157
158 LLUUID sound_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_SOUND);
159 gInventory.startBackgroundFetch(sound_folder_id);
160
150 // this will call refresh when we have everything. 161 // this will call refresh when we have everything.
151 LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->getItem(); 162 LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->getItem();
152 if(item && !item->isComplete()) 163 if(item && !item->isComplete())
@@ -289,6 +300,12 @@ void LLPreviewGesture::onClose(bool app_quitting)
289} 300}
290 301
291// virtual 302// virtual
303void LLPreviewGesture::onUpdateSucceeded()
304{
305 refresh();
306}
307
308// virtual
292void LLPreviewGesture::setMinimized(BOOL minimize) 309void LLPreviewGesture::setMinimized(BOOL minimize)
293{ 310{
294 if (minimize != isMinimized()) 311 if (minimize != isMinimized())
@@ -567,8 +584,10 @@ void LLPreviewGesture::addAnimations()
567 LLComboBox* combo = mAnimationCombo; 584 LLComboBox* combo = mAnimationCombo;
568 585
569 combo->removeall(); 586 combo->removeall();
587
588 LLString none_text = childGetText("none_text");
570 589
571 combo->add("-- None --", LLUUID::null); 590 combo->add(none_text, LLUUID::null);
572 591
573 // Add all the default (legacy) animations 592 // Add all the default (legacy) animations
574 S32 i; 593 S32 i;
@@ -618,6 +637,13 @@ void LLPreviewGesture::addAnimations()
618 637
619void LLPreviewGesture::addSounds() 638void LLPreviewGesture::addSounds()
620{ 639{
640 LLComboBox* combo = mSoundCombo;
641 combo->removeall();
642
643 LLString none_text = childGetText("none_text");
644
645 combo->add(none_text, LLUUID::null);
646
621 // Get all inventory items that are sounds 647 // Get all inventory items that are sounds
622 LLViewerInventoryCategory::cat_array_t cats; 648 LLViewerInventoryCategory::cat_array_t cats;
623 LLViewerInventoryItem::item_array_t items; 649 LLViewerInventoryItem::item_array_t items;
@@ -645,8 +671,6 @@ void LLPreviewGesture::addSounds()
645 std::sort(sounds.begin(), sounds.end(), SortItemPtrsByName()); 671 std::sort(sounds.begin(), sounds.end(), SortItemPtrsByName());
646 672
647 // And load up the combobox 673 // And load up the combobox
648 LLComboBox* combo = mSoundCombo;
649 combo->removeall();
650 std::vector<LLInventoryItem*>::iterator it; 674 std::vector<LLInventoryItem*>::iterator it;
651 for (it = sounds.begin(); it != sounds.end(); ++it) 675 for (it = sounds.begin(); it != sounds.end(); ++it)
652 { 676 {
@@ -752,17 +776,20 @@ void LLPreviewGesture::refresh()
752 mWaitTimeCheck->setVisible(FALSE); 776 mWaitTimeCheck->setVisible(FALSE);
753 mWaitTimeEditor->setVisible(FALSE); 777 mWaitTimeEditor->setVisible(FALSE);
754 778
779 LLString optionstext;
780
755 if (have_step) 781 if (have_step)
756 { 782 {
757 // figure out the type, show proper options, update text 783 // figure out the type, show proper options, update text
758 LLGestureStep* step = (LLGestureStep*)step_item->getUserdata(); 784 LLGestureStep* step = (LLGestureStep*)step_item->getUserdata();
759 EStepType type = step->getType(); 785 EStepType type = step->getType();
786
760 switch(type) 787 switch(type)
761 { 788 {
762 case STEP_ANIMATION: 789 case STEP_ANIMATION:
763 { 790 {
764 LLGestureStepAnimation* anim_step = (LLGestureStepAnimation*)step; 791 LLGestureStepAnimation* anim_step = (LLGestureStepAnimation*)step;
765 mOptionsText->setText("Animation to play:"); 792 optionstext = childGetText("step_anim");
766 mAnimationCombo->setVisible(TRUE); 793 mAnimationCombo->setVisible(TRUE);
767 mAnimationRadio->setVisible(TRUE); 794 mAnimationRadio->setVisible(TRUE);
768 mAnimationRadio->setSelectedIndex((anim_step->mFlags & ANIM_FLAG_STOP) ? 1 : 0); 795 mAnimationRadio->setSelectedIndex((anim_step->mFlags & ANIM_FLAG_STOP) ? 1 : 0);
@@ -772,7 +799,7 @@ void LLPreviewGesture::refresh()
772 case STEP_SOUND: 799 case STEP_SOUND:
773 { 800 {
774 LLGestureStepSound* sound_step = (LLGestureStepSound*)step; 801 LLGestureStepSound* sound_step = (LLGestureStepSound*)step;
775 mOptionsText->setText("Sound to play:"); 802 optionstext = childGetText("step_sound");
776 mSoundCombo->setVisible(TRUE); 803 mSoundCombo->setVisible(TRUE);
777 mSoundCombo->setCurrentByID(sound_step->mSoundAssetID); 804 mSoundCombo->setCurrentByID(sound_step->mSoundAssetID);
778 break; 805 break;
@@ -780,7 +807,7 @@ void LLPreviewGesture::refresh()
780 case STEP_CHAT: 807 case STEP_CHAT:
781 { 808 {
782 LLGestureStepChat* chat_step = (LLGestureStepChat*)step; 809 LLGestureStepChat* chat_step = (LLGestureStepChat*)step;
783 mOptionsText->setText("Chat to say:"); 810 optionstext = childGetText("step_chat");
784 mChatEditor->setVisible(TRUE); 811 mChatEditor->setVisible(TRUE);
785 mChatEditor->setText(chat_step->mChatText); 812 mChatEditor->setText(chat_step->mChatText);
786 break; 813 break;
@@ -788,14 +815,13 @@ void LLPreviewGesture::refresh()
788 case STEP_WAIT: 815 case STEP_WAIT:
789 { 816 {
790 LLGestureStepWait* wait_step = (LLGestureStepWait*)step; 817 LLGestureStepWait* wait_step = (LLGestureStepWait*)step;
791 mOptionsText->setText("Wait:"); 818 optionstext = childGetText("step_wait");
792 mWaitAnimCheck->setVisible(TRUE); 819 mWaitAnimCheck->setVisible(TRUE);
793 mWaitAnimCheck->set(wait_step->mFlags & WAIT_FLAG_ALL_ANIM); 820 mWaitAnimCheck->set(wait_step->mFlags & WAIT_FLAG_ALL_ANIM);
794 mWaitTimeCheck->setVisible(TRUE); 821 mWaitTimeCheck->setVisible(TRUE);
795 mWaitTimeCheck->set(wait_step->mFlags & WAIT_FLAG_TIME); 822 mWaitTimeCheck->set(wait_step->mFlags & WAIT_FLAG_TIME);
796 mWaitTimeEditor->setVisible(TRUE); 823 mWaitTimeEditor->setVisible(TRUE);
797 char buffer[16]; /*Flawfinder: ignore*/ 824 std::string buffer = llformat("%.1f", (double)wait_step->mWaitSeconds);
798 snprintf(buffer, sizeof(buffer), "%.1f", (double)wait_step->mWaitSeconds); /* Flawfinder: ignore */
799 mWaitTimeEditor->setText(buffer); 825 mWaitTimeEditor->setText(buffer);
800 break; 826 break;
801 } 827 }
@@ -803,11 +829,8 @@ void LLPreviewGesture::refresh()
803 break; 829 break;
804 } 830 }
805 } 831 }
806 else 832
807 { 833 mOptionsText->setText(optionstext);
808 // no gesture
809 mOptionsText->setText("");
810 }
811 834
812 BOOL active = gGestureManager.isGestureActive(mItemUUID); 835 BOOL active = gGestureManager.isGestureActive(mItemUUID);
813 mActiveCheck->set(active); 836 mActiveCheck->set(active);
@@ -975,14 +998,14 @@ void LLPreviewGesture::loadUIFromGesture(LLMultiGesture* gesture)
975 switch (gesture->mMask) 998 switch (gesture->mMask)
976 { 999 {
977 default: 1000 default:
978 case MASK_NONE: 1001 case MASK_NONE:
979 mModifierCombo->setSimple( NONE_LABEL ); 1002 mModifierCombo->setSimple( LLString(NONE_LABEL) );
980 break; 1003 break;
981 case MASK_SHIFT: 1004 case MASK_SHIFT:
982 mModifierCombo->setSimple( SHIFT_LABEL ); 1005 mModifierCombo->setSimple( LLString(SHIFT_LABEL) );
983 break; 1006 break;
984 case MASK_CONTROL: 1007 case MASK_CONTROL:
985 mModifierCombo->setSimple( CTRL_LABEL ); 1008 mModifierCombo->setSimple( LLString(CTRL_LABEL) );
986 break; 1009 break;
987 } 1010 }
988 1011
@@ -1120,19 +1143,29 @@ void LLPreviewGesture::saveIfNeeded()
1120 file.setMaxSize(size); 1143 file.setMaxSize(size);
1121 file.write((U8*)buffer, size); 1144 file.write((U8*)buffer, size);
1122 1145
1146 BOOL delayedUpload = FALSE;
1147
1123 // Upload that asset to the database 1148 // Upload that asset to the database
1124 const LLInventoryItem* item = getItem(); 1149 LLViewerInventoryItem* item = (LLViewerInventoryItem*) getItem();
1125 if (item) 1150 if (item)
1126 { 1151 {
1127 std::string agent_url = gAgent.getRegion()->getCapability("UpdateGestureAgentInventory"); 1152 std::string agent_url = gAgent.getRegion()->getCapability("UpdateGestureAgentInventory");
1128 std::string task_url = gAgent.getRegion()->getCapability("UpdateGestureTaskInventory"); 1153 std::string task_url = gAgent.getRegion()->getCapability("UpdateGestureTaskInventory");
1129 if (mObjectUUID.isNull() && !agent_url.empty()) 1154 if (mObjectUUID.isNull() && !agent_url.empty())
1130 { 1155 {
1156 //need to disable the preview floater so item
1157 //isn't re-saved before new asset arrives
1158 //fake out refresh.
1159 item->setComplete(FALSE);
1160 refresh();
1161 item->setComplete(TRUE);
1162
1131 // Saving into agent inventory 1163 // Saving into agent inventory
1132 LLSD body; 1164 LLSD body;
1133 body["item_id"] = mItemUUID; 1165 body["item_id"] = mItemUUID;
1134 LLHTTPClient::post(agent_url, body, 1166 LLHTTPClient::post(agent_url, body,
1135 new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_GESTURE)); 1167 new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_GESTURE));
1168 delayedUpload = TRUE;
1136 } 1169 }
1137 else if (!mObjectUUID.isNull() && !task_url.empty()) 1170 else if (!mObjectUUID.isNull() && !task_url.empty())
1138 { 1171 {
@@ -1153,7 +1186,7 @@ void LLPreviewGesture::saveIfNeeded()
1153 1186
1154 // If this gesture is active, then we need to update the in-memory 1187 // If this gesture is active, then we need to update the in-memory
1155 // active map with the new pointer. 1188 // active map with the new pointer.
1156 if (gGestureManager.isGestureActive(mItemUUID)) 1189 if (!delayedUpload && gGestureManager.isGestureActive(mItemUUID))
1157 { 1190 {
1158 // gesture manager now owns the pointer 1191 // gesture manager now owns the pointer
1159 gGestureManager.replaceGesture(mItemUUID, gesture, asset_id); 1192 gGestureManager.replaceGesture(mItemUUID, gesture, asset_id);
@@ -1170,7 +1203,12 @@ void LLPreviewGesture::saveIfNeeded()
1170 } 1203 }
1171 1204
1172 mDirty = FALSE; 1205 mDirty = FALSE;
1173 refresh(); 1206 // refresh will be called when callback
1207 // if triggered when delayedUpload
1208 if(!delayedUpload)
1209 {
1210 refresh();
1211 }
1174 } 1212 }
1175 1213
1176 delete [] buffer; 1214 delete [] buffer;
@@ -1710,8 +1748,7 @@ void LLPreviewGesture::onClickPreview(void* data)
1710 self->mPreviewGesture->mCallbackData = self; 1748 self->mPreviewGesture->mCallbackData = self;
1711 1749
1712 // set the button title 1750 // set the button title
1713 self->mPreviewBtn->setLabelSelected("Stop"); 1751 self->mPreviewBtn->setLabel(self->childGetText("stop_txt"));
1714 self->mPreviewBtn->setLabelUnselected("Stop");
1715 1752
1716 // play it, and delete when done 1753 // play it, and delete when done
1717 gGestureManager.playGesture(self->mPreviewGesture); 1754 gGestureManager.playGesture(self->mPreviewGesture);
@@ -1733,8 +1770,7 @@ void LLPreviewGesture::onDonePreview(LLMultiGesture* gesture, void* data)
1733{ 1770{
1734 LLPreviewGesture* self = (LLPreviewGesture*)data; 1771 LLPreviewGesture* self = (LLPreviewGesture*)data;
1735 1772
1736 self->mPreviewBtn->setLabelSelected("Preview"); 1773 self->mPreviewBtn->setLabel(self->childGetText("preview_txt"));
1737 self->mPreviewBtn->setLabelUnselected("Preview");
1738 1774
1739 delete self->mPreviewGesture; 1775 delete self->mPreviewGesture;
1740 self->mPreviewGesture = NULL; 1776 self->mPreviewGesture = NULL;