Annotation of /trunk/indra/newview/llpreviewanim.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llpreviewanim.cpp | ||
| 3 : | * @brief LLPreviewAnim class implementation | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2004&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 137 | * Copyright (c) 2004-2010, Linden Research, Inc. |
| 8 : | mjm | 135 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | #include "llviewerprecompiledheaders.h" | ||
| 34 : | |||
| 35 : | #include "llpreviewanim.h" | ||
| 36 : | #include "llbutton.h" | ||
| 37 : | #include "llresmgr.h" | ||
| 38 : | #include "llinventory.h" | ||
| 39 : | #include "llinventoryview.h" | ||
| 40 : | #include "llvoavatar.h" | ||
| 41 : | #include "llagent.h" | ||
| 42 : | #include "llkeyframemotion.h" | ||
| 43 : | #include "llfilepicker.h" | ||
| 44 : | #include "lllineeditor.h" | ||
| 45 : | #include "lluictrlfactory.h" | ||
| 46 : | #include "lluictrlfactory.h" | ||
| 47 : | |||
| 48 : | extern LLAgent gAgent; | ||
| 49 : | |||
| 50 : | LLPreviewAnim::LLPreviewAnim(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_uuid, const S32& activate, const LLUUID& object_uuid ) : | ||
| 51 : | LLPreview( name, rect, title, item_uuid, object_uuid) | ||
| 52 : | { | ||
| 53 : | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_animation.xml"); | ||
| 54 : | |||
| 55 : | childSetAction("Anim play btn",playAnim,this); | ||
| 56 : | childSetAction("Anim audition btn",auditionAnim,this); | ||
| 57 : | |||
| 58 : | const LLInventoryItem* item = getItem(); | ||
| 59 : | |||
| 60 : | childSetCommitCallback("desc", LLPreview::onText, this); | ||
| 61 : | childSetText("desc", item->getDescription()); | ||
| 62 : | childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe); | ||
| 63 : | |||
| 64 : | setTitle(title); | ||
| 65 : | |||
| 66 : | if (!getHost()) | ||
| 67 : | { | ||
| 68 : | LLRect curRect = getRect(); | ||
| 69 : | translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop); | ||
| 70 : | } | ||
| 71 : | |||
| 72 : | // preload the animation | ||
| 73 : | if(item) | ||
| 74 : | { | ||
| 75 : | gAgent.getAvatarObject()->createMotion(item->getAssetUUID()); | ||
| 76 : | } | ||
| 77 : | |||
| 78 : | switch ( activate ) | ||
| 79 : | { | ||
| 80 : | case 1: | ||
| 81 : | { | ||
| 82 : | playAnim( (void *) this ); | ||
| 83 : | break; | ||
| 84 : | } | ||
| 85 : | case 2: | ||
| 86 : | { | ||
| 87 : | auditionAnim( (void *) this ); | ||
| 88 : | break; | ||
| 89 : | } | ||
| 90 : | default: | ||
| 91 : | { | ||
| 92 : | //do nothing | ||
| 93 : | } | ||
| 94 : | } | ||
| 95 : | } | ||
| 96 : | |||
| 97 : | // static | ||
| 98 : | void LLPreviewAnim::endAnimCallback( void *userdata ) | ||
| 99 : | { | ||
| 100 : | LLHandle<LLFloater>* handlep = ((LLHandle<LLFloater>*)userdata); | ||
| 101 : | LLFloater* self = handlep->get(); | ||
| 102 : | delete handlep; // done with the handle | ||
| 103 : | if (self) | ||
| 104 : | { | ||
| 105 : | self->childSetValue("Anim play btn", FALSE); | ||
| 106 : | self->childSetValue("Anim audition btn", FALSE); | ||
| 107 : | } | ||
| 108 : | } | ||
| 109 : | |||
| 110 : | // static | ||
| 111 : | void LLPreviewAnim::playAnim( void *userdata ) | ||
| 112 : | { | ||
| 113 : | LLPreviewAnim* self = (LLPreviewAnim*) userdata; | ||
| 114 : | const LLInventoryItem *item = self->getItem(); | ||
| 115 : | |||
| 116 : | if(item) | ||
| 117 : | { | ||
| 118 : | LLUUID itemID=item->getAssetUUID(); | ||
| 119 : | |||
| 120 : | LLButton* btn = self->getChild<LLButton>("Anim play btn"); | ||
| 121 : | if (btn) | ||
| 122 : | { | ||
| 123 : | btn->toggleState(); | ||
| 124 : | } | ||
| 125 : | |||
| 126 : | if (self->childGetValue("Anim play btn").asBoolean() ) | ||
| 127 : | { | ||
| 128 : | self->mPauseRequest = NULL; | ||
| 129 : | gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_START); | ||
| 130 : | |||
| 131 : | LLVOAvatar* avatar = gAgent.getAvatarObject(); | ||
| 132 : | LLMotion* motion = avatar->findMotion(itemID); | ||
| 133 : | |||
| 134 : | if (motion) | ||
| 135 : | { | ||
| 136 : | motion->setDeactivateCallback(&endAnimCallback, (void *)(new LLHandle<LLFloater>(self->getHandle()))); | ||
| 137 : | } | ||
| 138 : | } | ||
| 139 : | else | ||
| 140 : | { | ||
| 141 : | gAgent.getAvatarObject()->stopMotion(itemID); | ||
| 142 : | gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_STOP); | ||
| 143 : | } | ||
| 144 : | } | ||
| 145 : | } | ||
| 146 : | |||
| 147 : | // static | ||
| 148 : | void LLPreviewAnim::auditionAnim( void *userdata ) | ||
| 149 : | { | ||
| 150 : | LLPreviewAnim* self = (LLPreviewAnim*) userdata; | ||
| 151 : | const LLInventoryItem *item = self->getItem(); | ||
| 152 : | |||
| 153 : | if(item) | ||
| 154 : | { | ||
| 155 : | LLUUID itemID=item->getAssetUUID(); | ||
| 156 : | |||
| 157 : | LLButton* btn = self->getChild<LLButton>("Anim audition btn"); | ||
| 158 : | if (btn) | ||
| 159 : | { | ||
| 160 : | btn->toggleState(); | ||
| 161 : | } | ||
| 162 : | |||
| 163 : | if (self->childGetValue("Anim audition btn").asBoolean() ) | ||
| 164 : | { | ||
| 165 : | self->mPauseRequest = NULL; | ||
| 166 : | gAgent.getAvatarObject()->startMotion(item->getAssetUUID()); | ||
| 167 : | |||
| 168 : | LLVOAvatar* avatar = gAgent.getAvatarObject(); | ||
| 169 : | LLMotion* motion = avatar->findMotion(itemID); | ||
| 170 : | |||
| 171 : | if (motion) | ||
| 172 : | { | ||
| 173 : | motion->setDeactivateCallback(&endAnimCallback, (void *)(new LLHandle<LLFloater>(self->getHandle()))); | ||
| 174 : | } | ||
| 175 : | } | ||
| 176 : | else | ||
| 177 : | { | ||
| 178 : | gAgent.getAvatarObject()->stopMotion(itemID); | ||
| 179 : | gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_STOP); | ||
| 180 : | } | ||
| 181 : | } | ||
| 182 : | } | ||
| 183 : | |||
| 184 : | void LLPreviewAnim::onClose(bool app_quitting) | ||
| 185 : | { | ||
| 186 : | const LLInventoryItem *item = getItem(); | ||
| 187 : | |||
| 188 : | if(item) | ||
| 189 : | { | ||
| 190 : | gAgent.getAvatarObject()->stopMotion(item->getAssetUUID()); | ||
| 191 : | gAgent.sendAnimationRequest(item->getAssetUUID(), ANIM_REQUEST_STOP); | ||
| 192 : | |||
| 193 : | LLVOAvatar* avatar = gAgent.getAvatarObject(); | ||
| 194 : | LLMotion* motion = avatar->findMotion(item->getAssetUUID()); | ||
| 195 : | |||
| 196 : | if (motion) | ||
| 197 : | { | ||
| 198 : | // *TODO: minor memory leak here, user data is never deleted (Use real callbacks) | ||
| 199 : | motion->setDeactivateCallback(NULL, (void *)NULL); | ||
| 200 : | } | ||
| 201 : | } | ||
| 202 : | destroy(); | ||
| 203 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

