diff options
Diffstat (limited to 'linden/indra/newview/floaterao.cpp')
-rw-r--r-- | linden/indra/newview/floaterao.cpp | 1358 |
1 files changed, 1358 insertions, 0 deletions
diff --git a/linden/indra/newview/floaterao.cpp b/linden/indra/newview/floaterao.cpp new file mode 100644 index 0000000..e3083d3 --- /dev/null +++ b/linden/indra/newview/floaterao.cpp | |||
@@ -0,0 +1,1358 @@ | |||
1 | /** | ||
2 | * @file llfloaterao.cpp | ||
3 | * @brief clientside animation overrider | ||
4 | * by Skills Hak | ||
5 | */ | ||
6 | |||
7 | #include "llviewerprecompiledheaders.h" | ||
8 | |||
9 | #include "floaterao.h" | ||
10 | |||
11 | #include "llagent.h" | ||
12 | #include "llvoavatar.h" | ||
13 | #include "llanimationstates.h" | ||
14 | #include "lluictrlfactory.h" | ||
15 | #include "llinventoryview.h" | ||
16 | #include "llstartup.h" | ||
17 | #include "llpreviewnotecard.h" | ||
18 | #include "llviewertexteditor.h" | ||
19 | #include "llcheckboxctrl.h" | ||
20 | #include "llcombobox.h" | ||
21 | #include "llspinctrl.h" | ||
22 | // Uncomment and use instead if we ever add the chatbar as a command line - MC | ||
23 | //#include "chatbar_as_cmdline.h" | ||
24 | #include "llfloaterchat.h" | ||
25 | |||
26 | #include "llinventory.h" | ||
27 | #include "llinventoryview.h" | ||
28 | #include "roles_constants.h" | ||
29 | #include "llviewerregion.h" | ||
30 | |||
31 | #include "llpanelinventory.h" | ||
32 | #include "llinventorybridge.h" | ||
33 | |||
34 | #include "llboost.h" | ||
35 | #include <boost/regex.hpp> | ||
36 | |||
37 | // Uncomment and use instead if we ever add the chatbar as a command line - MC | ||
38 | //void cmdline_printchat(std::string message); | ||
39 | void cmdline_printchat(std::string message) | ||
40 | { | ||
41 | LLChat chat; | ||
42 | chat.mText = message; | ||
43 | chat.mSourceType = CHAT_SOURCE_SYSTEM; | ||
44 | LLFloaterChat::addChat(chat, FALSE, FALSE); | ||
45 | } | ||
46 | |||
47 | |||
48 | // ------------------------------------------------------- | ||
49 | |||
50 | AOStandTimer* mAOStandTimer; | ||
51 | |||
52 | AOStandTimer::AOStandTimer() : LLEventTimer( gSavedSettings.getF32("AOStandInterval") ) | ||
53 | { | ||
54 | AOStandTimer::tick(); | ||
55 | } | ||
56 | AOStandTimer::~AOStandTimer() | ||
57 | { | ||
58 | // llinfos << "dead" << llendl; | ||
59 | } | ||
60 | void AOStandTimer::reset() | ||
61 | { | ||
62 | mPeriod = gSavedSettings.getF32("AOStandInterval"); | ||
63 | mEventTimer.reset(); | ||
64 | // llinfos << "reset" << llendl; | ||
65 | } | ||
66 | BOOL AOStandTimer::tick() | ||
67 | { | ||
68 | LLFloaterAO::stand_iterator++; | ||
69 | // llinfos << "tick" << llendl; | ||
70 | LLFloaterAO::ChangeStand(); | ||
71 | return FALSE; | ||
72 | // return LLFloaterAO::ChangeStand(); //timer is always active now .. | ||
73 | } | ||
74 | |||
75 | // ------------------------------------------------------- | ||
76 | |||
77 | AOInvTimer::AOInvTimer() : LLEventTimer( (F32)1.0 ) | ||
78 | { | ||
79 | } | ||
80 | AOInvTimer::~AOInvTimer() | ||
81 | { | ||
82 | } | ||
83 | BOOL AOInvTimer::tick() | ||
84 | { | ||
85 | if (!(gSavedSettings.getBOOL("AOEnabled"))) return TRUE; | ||
86 | if(LLStartUp::getStartupState() >= STATE_INVENTORY_SEND) | ||
87 | { | ||
88 | if(gInventory.isEverythingFetched()) | ||
89 | { | ||
90 | // cmdline_printchat("Inventory fetched, loading AO."); | ||
91 | LLFloaterAO::init(); | ||
92 | return TRUE; | ||
93 | } | ||
94 | } | ||
95 | return FALSE; | ||
96 | } | ||
97 | // NC DROP ------------------------------------------------------- | ||
98 | |||
99 | class AONoteCardDropTarget : public LLView | ||
100 | { | ||
101 | public: | ||
102 | AONoteCardDropTarget(const std::string& name, const LLRect& rect, void (*callback)(LLViewerInventoryItem*)); | ||
103 | ~AONoteCardDropTarget(); | ||
104 | |||
105 | void doDrop(EDragAndDropType cargo_type, void* cargo_data); | ||
106 | |||
107 | // | ||
108 | // LLView functionality | ||
109 | virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | ||
110 | EDragAndDropType cargo_type, | ||
111 | void* cargo_data, | ||
112 | EAcceptance* accept, | ||
113 | std::string& tooltip_msg); | ||
114 | protected: | ||
115 | void (*mDownCallback)(LLViewerInventoryItem*); | ||
116 | }; | ||
117 | |||
118 | |||
119 | AONoteCardDropTarget::AONoteCardDropTarget(const std::string& name, const LLRect& rect, | ||
120 | void (*callback)(LLViewerInventoryItem*)) : | ||
121 | LLView(name, rect, NOT_MOUSE_OPAQUE, FOLLOWS_ALL), | ||
122 | mDownCallback(callback) | ||
123 | { | ||
124 | } | ||
125 | |||
126 | AONoteCardDropTarget::~AONoteCardDropTarget() | ||
127 | { | ||
128 | } | ||
129 | |||
130 | void AONoteCardDropTarget::doDrop(EDragAndDropType cargo_type, void* cargo_data) | ||
131 | { | ||
132 | // llinfos << "AONoteCardDropTarget::doDrop()" << llendl; | ||
133 | } | ||
134 | |||
135 | BOOL AONoteCardDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | ||
136 | EDragAndDropType cargo_type, | ||
137 | void* cargo_data, | ||
138 | EAcceptance* accept, | ||
139 | std::string& tooltip_msg) | ||
140 | { | ||
141 | BOOL handled = FALSE; | ||
142 | if(getParent()) | ||
143 | { | ||
144 | handled = TRUE; | ||
145 | LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data; | ||
146 | if(gInventory.getItem(inv_item->getUUID())) | ||
147 | { | ||
148 | *accept = ACCEPT_YES_COPY_SINGLE; | ||
149 | if(drop) | ||
150 | { | ||
151 | mDownCallback(inv_item); | ||
152 | } | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | *accept = ACCEPT_NO; | ||
157 | } | ||
158 | } | ||
159 | return handled; | ||
160 | } | ||
161 | |||
162 | AONoteCardDropTarget * LLFloaterAO::mAOItemDropTarget; | ||
163 | |||
164 | |||
165 | // STUFF ------------------------------------------------------- | ||
166 | |||
167 | int LLFloaterAO::mAnimationState = 0; | ||
168 | int LLFloaterAO::stand_iterator = 0; | ||
169 | |||
170 | LLUUID LLFloaterAO::invfolderid = LLUUID::null; | ||
171 | LLUUID LLFloaterAO::mCurrentStandId = LLUUID::null; | ||
172 | |||
173 | LLComboBox* mcomboBox_stands; | ||
174 | LLComboBox* mcomboBox_walks; | ||
175 | LLComboBox* mcomboBox_runs; | ||
176 | LLComboBox* mcomboBox_jumps; | ||
177 | LLComboBox* mcomboBox_sits; | ||
178 | LLComboBox* mcomboBox_gsits; | ||
179 | LLComboBox* mcomboBox_crouchs; | ||
180 | LLComboBox* mcomboBox_cwalks; | ||
181 | LLComboBox* mcomboBox_falls; | ||
182 | LLComboBox* mcomboBox_hovers; | ||
183 | LLComboBox* mcomboBox_flys; | ||
184 | LLComboBox* mcomboBox_flyslows; | ||
185 | LLComboBox* mcomboBox_flyups; | ||
186 | LLComboBox* mcomboBox_flydowns; | ||
187 | LLComboBox* mcomboBox_lands; | ||
188 | LLComboBox* mcomboBox_standups; | ||
189 | LLComboBox* mcomboBox_prejumps; | ||
190 | |||
191 | struct struct_overrides | ||
192 | { | ||
193 | LLUUID orig_id; | ||
194 | LLUUID ao_id; | ||
195 | int state; | ||
196 | }; | ||
197 | std::vector<struct_overrides> mAOOverrides; | ||
198 | |||
199 | struct struct_stands | ||
200 | { | ||
201 | LLUUID ao_id; | ||
202 | std::string anim_name; | ||
203 | }; | ||
204 | std::vector<struct_stands> mAOStands; | ||
205 | |||
206 | struct struct_tokens | ||
207 | { | ||
208 | std::string token; | ||
209 | int state; | ||
210 | }; | ||
211 | std::vector<struct_tokens> mAOTokens; | ||
212 | |||
213 | LLFloaterAO* LLFloaterAO::sInstance = NULL; | ||
214 | |||
215 | LLFloaterAO::LLFloaterAO() | ||
216 | :LLFloater(std::string("floater_ao")) | ||
217 | { | ||
218 | // init(); | ||
219 | llassert_always(sInstance == NULL); | ||
220 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_ao.xml"); | ||
221 | sInstance = this; | ||
222 | } | ||
223 | |||
224 | LLFloaterAO::~LLFloaterAO() | ||
225 | { | ||
226 | sInstance=NULL; | ||
227 | mcomboBox_stands = 0; | ||
228 | mcomboBox_walks = 0; | ||
229 | mcomboBox_runs = 0; | ||
230 | mcomboBox_jumps = 0; | ||
231 | mcomboBox_sits = 0; | ||
232 | mcomboBox_gsits = 0; | ||
233 | mcomboBox_crouchs = 0; | ||
234 | mcomboBox_cwalks = 0; | ||
235 | mcomboBox_falls = 0; | ||
236 | mcomboBox_hovers = 0; | ||
237 | mcomboBox_flys = 0; | ||
238 | mcomboBox_flyslows = 0; | ||
239 | mcomboBox_flyups = 0; | ||
240 | mcomboBox_flydowns = 0; | ||
241 | mcomboBox_lands = 0; | ||
242 | mcomboBox_standups = 0; | ||
243 | mcomboBox_prejumps = 0; | ||
244 | delete mAOItemDropTarget; | ||
245 | mAOItemDropTarget = NULL; | ||
246 | // llinfos << "floater destroyed" << llendl; | ||
247 | } | ||
248 | |||
249 | void LLFloaterAO::show(void*) | ||
250 | { | ||
251 | if (!sInstance) | ||
252 | sInstance = new LLFloaterAO(); | ||
253 | updateLayout(sInstance); | ||
254 | init(); | ||
255 | |||
256 | sInstance->open(); | ||
257 | } | ||
258 | |||
259 | BOOL LLFloaterAO::postBuild() | ||
260 | { | ||
261 | LLView *target_view = getChild<LLView>("ao_notecard"); | ||
262 | if(target_view) | ||
263 | { | ||
264 | if (mAOItemDropTarget) | ||
265 | { | ||
266 | delete mAOItemDropTarget; | ||
267 | } | ||
268 | mAOItemDropTarget = new AONoteCardDropTarget("drop target", target_view->getRect(), AOItemDrop);//, mAvatarID); | ||
269 | addChild(mAOItemDropTarget); | ||
270 | } | ||
271 | if(LLStartUp::getStartupState() == STATE_STARTED) | ||
272 | { | ||
273 | LLUUID itemidimport = (LLUUID)gSavedPerAccountSettings.getString("AOConfigNotecardID"); | ||
274 | LLViewerInventoryItem* itemimport = gInventory.getItem(itemidimport); | ||
275 | if(itemimport) | ||
276 | { | ||
277 | childSetValue("ao_nc_text","Currently set to: "+itemimport->getName()); | ||
278 | } | ||
279 | else if(itemidimport.isNull()) | ||
280 | { | ||
281 | childSetValue("ao_nc_text","Currently not set"); | ||
282 | } | ||
283 | else | ||
284 | { | ||
285 | childSetValue("ao_nc_text","Currently set to a item not on this account"); | ||
286 | } | ||
287 | } | ||
288 | else | ||
289 | { | ||
290 | childSetValue("ao_nc_text","Not logged in"); | ||
291 | } | ||
292 | childSetAction("more_btn", onClickMore, this); | ||
293 | childSetAction("less_btn", onClickLess, this); | ||
294 | |||
295 | childSetAction("reloadcard",onClickReloadCard,this); | ||
296 | childSetAction("opencard",onClickOpenCard,this); | ||
297 | childSetAction("prevstand",onClickPrevStand,this); | ||
298 | childSetAction("nextstand",onClickNextStand,this); | ||
299 | childSetCommitCallback("AOEnabled",onClickToggleAO); | ||
300 | childSetCommitCallback("AOSitsEnabled",onClickToggleSits); | ||
301 | childSetCommitCallback("standtime",onSpinnerCommit); | ||
302 | mcomboBox_stands = getChild<LLComboBox>("stands"); | ||
303 | mcomboBox_walks = getChild<LLComboBox>("walks"); | ||
304 | mcomboBox_runs = getChild<LLComboBox>("runs"); | ||
305 | mcomboBox_jumps = getChild<LLComboBox>("jumps"); | ||
306 | mcomboBox_sits = getChild<LLComboBox>("sits"); | ||
307 | mcomboBox_gsits = getChild<LLComboBox>("gsits"); | ||
308 | mcomboBox_crouchs = getChild<LLComboBox>("crouchs"); | ||
309 | mcomboBox_cwalks = getChild<LLComboBox>("cwalks"); | ||
310 | mcomboBox_falls = getChild<LLComboBox>("falls"); | ||
311 | mcomboBox_hovers = getChild<LLComboBox>("hovers"); | ||
312 | mcomboBox_flys = getChild<LLComboBox>("flys"); | ||
313 | mcomboBox_flyslows = getChild<LLComboBox>("flyslows"); | ||
314 | mcomboBox_flyups = getChild<LLComboBox>("flyups"); | ||
315 | mcomboBox_flydowns = getChild<LLComboBox>("flydowns"); | ||
316 | mcomboBox_lands = getChild<LLComboBox>("lands"); | ||
317 | mcomboBox_standups = getChild<LLComboBox>("standups"); | ||
318 | mcomboBox_prejumps = getChild<LLComboBox>("prejumps"); | ||
319 | getChild<LLComboBox>("stands")->setCommitCallback(onComboBoxCommit); | ||
320 | getChild<LLComboBox>("walks")->setCommitCallback(onComboBoxCommit); | ||
321 | getChild<LLComboBox>("runs")->setCommitCallback(onComboBoxCommit); | ||
322 | getChild<LLComboBox>("jumps")->setCommitCallback(onComboBoxCommit); | ||
323 | getChild<LLComboBox>("sits")->setCommitCallback(onComboBoxCommit); | ||
324 | getChild<LLComboBox>("gsits")->setCommitCallback(onComboBoxCommit); | ||
325 | getChild<LLComboBox>("crouchs")->setCommitCallback(onComboBoxCommit); | ||
326 | getChild<LLComboBox>("cwalks")->setCommitCallback(onComboBoxCommit); | ||
327 | getChild<LLComboBox>("falls")->setCommitCallback(onComboBoxCommit); | ||
328 | getChild<LLComboBox>("hovers")->setCommitCallback(onComboBoxCommit); | ||
329 | getChild<LLComboBox>("flys")->setCommitCallback(onComboBoxCommit); | ||
330 | getChild<LLComboBox>("flyslows")->setCommitCallback(onComboBoxCommit); | ||
331 | getChild<LLComboBox>("flyups")->setCommitCallback(onComboBoxCommit); | ||
332 | getChild<LLComboBox>("flydowns")->setCommitCallback(onComboBoxCommit); | ||
333 | getChild<LLComboBox>("lands")->setCommitCallback(onComboBoxCommit); | ||
334 | getChild<LLComboBox>("standups")->setCommitCallback(onComboBoxCommit); | ||
335 | getChild<LLComboBox>("prejumps")->setCommitCallback(onComboBoxCommit); | ||
336 | |||
337 | return TRUE; | ||
338 | } | ||
339 | |||
340 | void LLFloaterAO::onSpinnerCommit(LLUICtrl* ctrl, void* userdata) | ||
341 | { | ||
342 | LLSpinCtrl* spin = (LLSpinCtrl*) ctrl; | ||
343 | if(spin) | ||
344 | { | ||
345 | if (spin->getName() == "standtime") | ||
346 | { | ||
347 | if (mAOStandTimer) mAOStandTimer->reset(); | ||
348 | } | ||
349 | } | ||
350 | } | ||
351 | |||
352 | void LLFloaterAO::onComboBoxCommit(LLUICtrl* ctrl, void* userdata) | ||
353 | { | ||
354 | LLComboBox* box = (LLComboBox*)ctrl; | ||
355 | if(box) | ||
356 | { | ||
357 | if (box->getName() == "stands") | ||
358 | { | ||
359 | stand_iterator = box->getCurrentIndex(); | ||
360 | cmdline_printchat(llformat("Changing stand to %s.",mAOStands[stand_iterator].anim_name.c_str())); | ||
361 | ChangeStand(); | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | int state = STATE_AGENT_IDLE; | ||
366 | std::string stranim = box->getValue().asString(); | ||
367 | // llinfos << "state " << (gAgent.getAvatarObject()->mIsSitting) << " - " << getAnimationState() << llendl; | ||
368 | if (box->getName() == "walks") | ||
369 | { | ||
370 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_WALK), ANIM_REQUEST_STOP); | ||
371 | gSavedPerAccountSettings.setString("AODefaultWalk",stranim); | ||
372 | state = STATE_AGENT_WALK; | ||
373 | } | ||
374 | else if (box->getName() == "runs") | ||
375 | { | ||
376 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_RUN), ANIM_REQUEST_STOP); | ||
377 | gSavedPerAccountSettings.setString("AODefaultRun",stranim); | ||
378 | state = STATE_AGENT_RUN; | ||
379 | } | ||
380 | else if (box->getName() == "jumps") | ||
381 | { | ||
382 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_JUMP), ANIM_REQUEST_STOP); | ||
383 | gSavedPerAccountSettings.setString("AODefaultJump",stranim); | ||
384 | state = STATE_AGENT_JUMP; | ||
385 | } | ||
386 | else if (box->getName() == "sits") | ||
387 | { | ||
388 | if (gAgent.getAvatarObject() && (gSavedSettings.getBOOL("AOEnabled")) && (gSavedSettings.getBOOL("AOSitsEnabled"))) | ||
389 | { | ||
390 | if ((gAgent.getAvatarObject()->mIsSitting) && (getAnimationState() == STATE_AGENT_SIT)) | ||
391 | { | ||
392 | // llinfos << "sitting " << GetAnimID(ANIM_AGENT_SIT) << " " << getAssetIDByName(stranim) << llendl; | ||
393 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_SIT), ANIM_REQUEST_STOP); | ||
394 | gAgent.sendAnimationRequest(getAssetIDByName(stranim), ANIM_REQUEST_START); | ||
395 | } | ||
396 | } | ||
397 | gSavedPerAccountSettings.setString("AODefaultSit",stranim); | ||
398 | state = STATE_AGENT_SIT; | ||
399 | } | ||
400 | else if (box->getName() == "gsits") | ||
401 | { | ||
402 | // llinfos << "gsitting " << GetAnimID(ANIM_AGENT_SIT_GROUND) << " " << getAssetIDByName(stranim) << llendl; | ||
403 | if (gAgent.getAvatarObject()) | ||
404 | { | ||
405 | if ((gAgent.getAvatarObject()->mIsSitting) && (getAnimationState() == STATE_AGENT_GROUNDSIT)) | ||
406 | { | ||
407 | // llinfos << "gsitting " << GetAnimID(ANIM_AGENT_SIT_GROUND) << " " << getAssetIDByName(stranim) << llendl; | ||
408 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_SIT_GROUND), ANIM_REQUEST_STOP); | ||
409 | gAgent.sendAnimationRequest(getAssetIDByName(stranim), ANIM_REQUEST_START); | ||
410 | } | ||
411 | } | ||
412 | gSavedPerAccountSettings.setString("AODefaultGroundSit",stranim); | ||
413 | state = STATE_AGENT_GROUNDSIT; | ||
414 | } | ||
415 | else if (box->getName() == "crouchs") | ||
416 | { | ||
417 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_CROUCH), ANIM_REQUEST_STOP); | ||
418 | gSavedPerAccountSettings.setString("AODefaultCrouch",stranim); | ||
419 | state = STATE_AGENT_CROUCH; | ||
420 | } | ||
421 | else if (box->getName() == "cwalks") | ||
422 | { | ||
423 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_CROUCHWALK), ANIM_REQUEST_STOP); | ||
424 | gSavedPerAccountSettings.setString("AODefaultCrouchWalk",stranim); | ||
425 | state = STATE_AGENT_CROUCHWALK; | ||
426 | } | ||
427 | else if (box->getName() == "falls") | ||
428 | { | ||
429 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_FALLDOWN), ANIM_REQUEST_STOP); | ||
430 | gSavedPerAccountSettings.setString("AODefaultFall",stranim); | ||
431 | state = STATE_AGENT_FALLDOWN; | ||
432 | } | ||
433 | else if (box->getName() == "hovers") | ||
434 | { | ||
435 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_HOVER), ANIM_REQUEST_STOP); | ||
436 | gSavedPerAccountSettings.setString("AODefaultHover",stranim); | ||
437 | state = STATE_AGENT_HOVER; | ||
438 | } | ||
439 | else if (box->getName() == "flys") | ||
440 | { | ||
441 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_FLY), ANIM_REQUEST_STOP); | ||
442 | gSavedPerAccountSettings.setString("AODefaultFly",stranim); | ||
443 | state = STATE_AGENT_FLY; | ||
444 | } | ||
445 | else if (box->getName() == "flyslows") | ||
446 | { | ||
447 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_FLYSLOW), ANIM_REQUEST_STOP); | ||
448 | gSavedPerAccountSettings.setString("AODefaultFlySlow",stranim); | ||
449 | state = STATE_AGENT_FLYSLOW; | ||
450 | } | ||
451 | else if (box->getName() == "flyups") | ||
452 | { | ||
453 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_HOVER_UP), ANIM_REQUEST_STOP); | ||
454 | gSavedPerAccountSettings.setString("AODefaultFlyUp",stranim); | ||
455 | state = STATE_AGENT_HOVER_UP; | ||
456 | } | ||
457 | else if (box->getName() == "flydowns") | ||
458 | { | ||
459 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_HOVER_DOWN), ANIM_REQUEST_STOP); | ||
460 | gSavedPerAccountSettings.setString("AODefaultFlyDown",stranim); | ||
461 | state = STATE_AGENT_HOVER_DOWN; | ||
462 | } | ||
463 | else if (box->getName() == "lands") | ||
464 | { | ||
465 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_LAND), ANIM_REQUEST_STOP); | ||
466 | gSavedPerAccountSettings.setString("AODefaultLand",stranim); | ||
467 | state = STATE_AGENT_LAND; | ||
468 | } | ||
469 | else if (box->getName() == "standups") | ||
470 | { | ||
471 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_STAND), ANIM_REQUEST_STOP); | ||
472 | gSavedPerAccountSettings.setString("AODefaultStandUp",stranim); | ||
473 | state = STATE_AGENT_STAND; | ||
474 | } | ||
475 | else if (box->getName() == "prejumps") | ||
476 | { | ||
477 | gAgent.sendAnimationRequest(GetAnimID(ANIM_AGENT_PRE_JUMP), ANIM_REQUEST_STOP); | ||
478 | gSavedPerAccountSettings.setString("AODefaultPreJump",stranim); | ||
479 | state = STATE_AGENT_PRE_JUMP; | ||
480 | } | ||
481 | for (std::vector<struct_overrides>::iterator iter = mAOOverrides.begin(); iter != mAOOverrides.end(); ++iter) | ||
482 | { | ||
483 | if (state == iter->state) | ||
484 | { | ||
485 | iter->ao_id = getAssetIDByName(stranim); | ||
486 | } | ||
487 | } | ||
488 | } | ||
489 | } | ||
490 | } | ||
491 | |||
492 | void LLFloaterAO::updateLayout(LLFloaterAO* floater) | ||
493 | { | ||
494 | if (floater) | ||
495 | { | ||
496 | BOOL advanced = gSavedSettings.getBOOL( "AOAdvanced"); | ||
497 | if (advanced) | ||
498 | { | ||
499 | floater->reshape(610,380); //view->getRect().getWidth(), view->getUIWinHeightLong()); | ||
500 | } | ||
501 | else | ||
502 | { | ||
503 | floater->reshape(200,380); //view->getRect().getWidth(), view->getUIWinHeightShort()); | ||
504 | } | ||
505 | |||
506 | floater->childSetVisible("more_btn", !advanced); | ||
507 | floater->childSetVisible("less_btn", advanced); | ||
508 | |||
509 | floater->childSetVisible("tabcontainer", advanced); | ||
510 | floater->childSetVisible("tabdefaultanims", advanced); | ||
511 | |||
512 | floater->childSetVisible("textdefaultwalk", advanced); | ||
513 | floater->childSetVisible("textdefaultrun", advanced); | ||
514 | floater->childSetVisible("textdefaultjump", advanced); | ||
515 | floater->childSetVisible("textdefaultsit", advanced); | ||
516 | floater->childSetVisible("textdefaultgsit", advanced); | ||
517 | floater->childSetVisible("textdefaultcrouch", advanced); | ||
518 | floater->childSetVisible("textdefaultcrouchwalk", advanced); | ||
519 | floater->childSetVisible("textdefaultfall", advanced); | ||
520 | floater->childSetVisible("textdefaulthover", advanced); | ||
521 | floater->childSetVisible("textdefaultfly", advanced); | ||
522 | floater->childSetVisible("textdefaultflyslow", advanced); | ||
523 | floater->childSetVisible("textdefaultflyup", advanced); | ||
524 | floater->childSetVisible("textdefaultflydown", advanced); | ||
525 | floater->childSetVisible("textdefaultland", advanced); | ||
526 | floater->childSetVisible("textdefaultstandup", advanced); | ||
527 | floater->childSetVisible("textdefaultprejump", advanced); | ||
528 | |||
529 | |||
530 | floater->childSetVisible("walks", advanced); | ||
531 | floater->childSetVisible("runs", advanced); | ||
532 | floater->childSetVisible("jumps", advanced); | ||
533 | floater->childSetVisible("sits", advanced); | ||
534 | floater->childSetVisible("gsits", advanced); | ||
535 | floater->childSetVisible("crouchs", advanced); | ||
536 | floater->childSetVisible("crouchwalks", advanced); | ||
537 | floater->childSetVisible("falls", advanced); | ||
538 | floater->childSetVisible("hovers", advanced); | ||
539 | floater->childSetVisible("flys", advanced); | ||
540 | floater->childSetVisible("flyslows", advanced); | ||
541 | floater->childSetVisible("flyups", advanced); | ||
542 | floater->childSetVisible("flydowns", advanced); | ||
543 | floater->childSetVisible("lands", advanced); | ||
544 | floater->childSetVisible("standups", advanced); | ||
545 | floater->childSetVisible("prejumps", advanced); | ||
546 | } | ||
547 | } | ||
548 | |||
549 | void LLFloaterAO::init() | ||
550 | { | ||
551 | mAOStands.clear(); | ||
552 | mAOTokens.clear(); | ||
553 | mAOOverrides.clear(); | ||
554 | |||
555 | struct_tokens tokenloader; | ||
556 | tokenloader.token = | ||
557 | tokenloader.token = "[ Sitting On Ground ]"; tokenloader.state = STATE_AGENT_GROUNDSIT; mAOTokens.push_back(tokenloader); // 0 | ||
558 | tokenloader.token = "[ Sitting ]"; tokenloader.state = STATE_AGENT_SIT; mAOTokens.push_back(tokenloader); // 1 | ||
559 | tokenloader.token = "[ Crouching ]"; tokenloader.state = STATE_AGENT_CROUCH; mAOTokens.push_back(tokenloader); // 3 | ||
560 | tokenloader.token = "[ Crouch Walking ]"; tokenloader.state = STATE_AGENT_CROUCHWALK; mAOTokens.push_back(tokenloader); // 4 | ||
561 | tokenloader.token = "[ Standing Up ]"; tokenloader.state = STATE_AGENT_STANDUP; mAOTokens.push_back(tokenloader); // 6 | ||
562 | tokenloader.token = "[ Falling ]"; tokenloader.state = STATE_AGENT_FALLDOWN; mAOTokens.push_back(tokenloader); // 7 | ||
563 | tokenloader.token = "[ Flying Down ]"; tokenloader.state = STATE_AGENT_HOVER_DOWN; mAOTokens.push_back(tokenloader); // 8 | ||
564 | tokenloader.token = "[ Flying Up ]"; tokenloader.state = STATE_AGENT_HOVER_UP; mAOTokens.push_back(tokenloader); // 9 | ||
565 | tokenloader.token = "[ Flying Slow ]"; tokenloader.state = STATE_AGENT_FLYSLOW; mAOTokens.push_back(tokenloader); // 10 | ||
566 | tokenloader.token = "[ Flying ]"; tokenloader.state = STATE_AGENT_FLY; mAOTokens.push_back(tokenloader); // 11 | ||
567 | tokenloader.token = "[ Hovering ]"; tokenloader.state = STATE_AGENT_HOVER; mAOTokens.push_back(tokenloader); // 12 | ||
568 | tokenloader.token = "[ Jumping ]"; tokenloader.state = STATE_AGENT_JUMP; mAOTokens.push_back(tokenloader); // 13 | ||
569 | tokenloader.token = "[ Pre Jumping ]"; tokenloader.state = STATE_AGENT_PRE_JUMP; mAOTokens.push_back(tokenloader); // 14 | ||
570 | tokenloader.token = "[ Running ]"; tokenloader.state = STATE_AGENT_RUN; mAOTokens.push_back(tokenloader); // 15 | ||
571 | tokenloader.token = "[ Turning Right ]"; tokenloader.state = STATE_AGENT_TURNRIGHT; mAOTokens.push_back(tokenloader); // 16 | ||
572 | tokenloader.token = "[ Turning Left ]"; tokenloader.state = STATE_AGENT_TURNLEFT; mAOTokens.push_back(tokenloader); // 17 | ||
573 | tokenloader.token = "[ Walking ]"; tokenloader.state = STATE_AGENT_WALK; mAOTokens.push_back(tokenloader); // 18 | ||
574 | tokenloader.token = "[ Landing ]"; tokenloader.state = STATE_AGENT_LAND; mAOTokens.push_back(tokenloader); // 19 | ||
575 | tokenloader.token = "[ Standing ]"; tokenloader.state = STATE_AGENT_STAND; mAOTokens.push_back(tokenloader); // 20 | ||
576 | tokenloader.token = "[ Swimming Down ]"; tokenloader.state = 999; mAOTokens.push_back(tokenloader); // 21 | ||
577 | tokenloader.token = "[ Swimming Up ]"; tokenloader.state = 999; mAOTokens.push_back(tokenloader); // 22 | ||
578 | tokenloader.token = "[ Swimming Forward ]"; tokenloader.state = 999; mAOTokens.push_back(tokenloader); // 23 | ||
579 | tokenloader.token = "[ Floating ]"; tokenloader.state = 999; mAOTokens.push_back(tokenloader); // 24 | ||
580 | |||
581 | struct_overrides overrideloader; | ||
582 | overrideloader.orig_id = ANIM_AGENT_WALK; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_WALK; mAOOverrides.push_back(overrideloader); | ||
583 | overrideloader.orig_id = ANIM_AGENT_RUN; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_RUN; mAOOverrides.push_back(overrideloader); | ||
584 | overrideloader.orig_id = ANIM_AGENT_PRE_JUMP; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_PRE_JUMP; mAOOverrides.push_back(overrideloader); | ||
585 | overrideloader.orig_id = ANIM_AGENT_JUMP; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_JUMP; mAOOverrides.push_back(overrideloader); | ||
586 | overrideloader.orig_id = ANIM_AGENT_TURNLEFT; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_TURNLEFT; mAOOverrides.push_back(overrideloader); | ||
587 | overrideloader.orig_id = ANIM_AGENT_TURNRIGHT; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_TURNRIGHT; mAOOverrides.push_back(overrideloader); | ||
588 | |||
589 | overrideloader.orig_id = ANIM_AGENT_SIT; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_SIT; mAOOverrides.push_back(overrideloader); | ||
590 | overrideloader.orig_id = ANIM_AGENT_SIT_FEMALE; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_SIT; mAOOverrides.push_back(overrideloader); | ||
591 | overrideloader.orig_id = ANIM_AGENT_SIT_GENERIC; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_SIT; mAOOverrides.push_back(overrideloader); | ||
592 | overrideloader.orig_id = ANIM_AGENT_SIT_GROUND; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_GROUNDSIT; mAOOverrides.push_back(overrideloader); | ||
593 | overrideloader.orig_id = ANIM_AGENT_SIT_GROUND_CONSTRAINED; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_GROUNDSIT; mAOOverrides.push_back(overrideloader); | ||
594 | |||
595 | overrideloader.orig_id = ANIM_AGENT_HOVER; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_HOVER; mAOOverrides.push_back(overrideloader); | ||
596 | overrideloader.orig_id = ANIM_AGENT_HOVER_DOWN; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_HOVER_DOWN; mAOOverrides.push_back(overrideloader); | ||
597 | overrideloader.orig_id = ANIM_AGENT_HOVER_UP; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_HOVER_UP; mAOOverrides.push_back(overrideloader); | ||
598 | |||
599 | overrideloader.orig_id = ANIM_AGENT_CROUCH; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_CROUCH; mAOOverrides.push_back(overrideloader); | ||
600 | overrideloader.orig_id = ANIM_AGENT_CROUCHWALK; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_CROUCHWALK; mAOOverrides.push_back(overrideloader); | ||
601 | |||
602 | overrideloader.orig_id = ANIM_AGENT_FALLDOWN; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_FALLDOWN; mAOOverrides.push_back(overrideloader); | ||
603 | overrideloader.orig_id = ANIM_AGENT_STANDUP; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_STANDUP; mAOOverrides.push_back(overrideloader); | ||
604 | overrideloader.orig_id = ANIM_AGENT_LAND; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_LAND; mAOOverrides.push_back(overrideloader); | ||
605 | |||
606 | overrideloader.orig_id = ANIM_AGENT_FLY; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_FLY; mAOOverrides.push_back(overrideloader); | ||
607 | overrideloader.orig_id = ANIM_AGENT_FLYSLOW; overrideloader.ao_id = LLUUID::null; overrideloader.state = STATE_AGENT_FLYSLOW; mAOOverrides.push_back(overrideloader); | ||
608 | |||
609 | BOOL success = TRUE; | ||
610 | |||
611 | if(LLStartUp::getStartupState() >= STATE_INVENTORY_SEND) | ||
612 | { | ||
613 | if(gInventory.isEverythingFetched()) | ||
614 | { | ||
615 | LLUUID configncitem = (LLUUID)gSavedPerAccountSettings.getString("AOConfigNotecardID"); | ||
616 | if (configncitem.notNull()) | ||
617 | { | ||
618 | success = FALSE; | ||
619 | const LLInventoryItem* item = gInventory.getItem(configncitem); | ||
620 | if(item) | ||
621 | { | ||
622 | if (gAgent.allowOperation(PERM_COPY, item->getPermissions(),GP_OBJECT_MANIPULATE) || gAgent.isGodlike()) | ||
623 | { | ||
624 | if(!item->getAssetUUID().isNull()) | ||
625 | { | ||
626 | LLUUID* new_uuid = new LLUUID(configncitem); | ||
627 | LLHost source_sim = LLHost::invalid; | ||
628 | invfolderid = item->getParentUUID(); | ||
629 | gAssetStorage->getInvItemAsset(source_sim, | ||
630 | gAgent.getID(), | ||
631 | gAgent.getSessionID(), | ||
632 | item->getPermissions().getOwner(), | ||
633 | LLUUID::null, | ||
634 | item->getUUID(), | ||
635 | item->getAssetUUID(), | ||
636 | item->getType(), | ||
637 | &onNotecardLoadComplete, | ||
638 | (void*)new_uuid, | ||
639 | TRUE); | ||
640 | success = TRUE; | ||
641 | } | ||
642 | } | ||
643 | } | ||
644 | } | ||
645 | } | ||
646 | } | ||
647 | |||
648 | if (!success) | ||
649 | { | ||
650 | cmdline_printchat("Could not read the specified Config Notecard"); | ||
651 | } | ||
652 | |||
653 | // mAnimationState = 0; | ||
654 | // mCurrentStandId = LLUUID::null; | ||
655 | // setAnimationState(STATE_AGENT_IDLE); | ||
656 | |||
657 | } | ||
658 | |||
659 | void LLFloaterAO::onClickMore(void* data) | ||
660 | { | ||
661 | gSavedSettings.setBOOL( "AOAdvanced", TRUE ); | ||
662 | updateLayout(sInstance); | ||
663 | } | ||
664 | void LLFloaterAO::onClickLess(void* data) | ||
665 | { | ||
666 | gSavedSettings.setBOOL( "AOAdvanced", FALSE ); | ||
667 | updateLayout(sInstance); | ||
668 | } | ||
669 | |||
670 | void LLFloaterAO::onClickToggleAO(LLUICtrl *, void*) | ||
671 | { | ||
672 | run(); | ||
673 | } | ||
674 | |||
675 | void LLFloaterAO::onClickToggleSits(LLUICtrl *, void*) | ||
676 | { | ||
677 | run(); | ||
678 | } | ||
679 | |||
680 | |||
681 | void LLFloaterAO::run() | ||
682 | { | ||
683 | setAnimationState(STATE_AGENT_IDLE); // reset state | ||
684 | int state = getAnimationState(); // check if sitting or hovering | ||
685 | if ((state == STATE_AGENT_IDLE) || (state == STATE_AGENT_STAND)) | ||
686 | { | ||
687 | if (gSavedSettings.getBOOL("AOEnabled")) | ||
688 | { | ||
689 | if (mAOStandTimer) | ||
690 | { | ||
691 | mAOStandTimer->reset(); | ||
692 | ChangeStand(); | ||
693 | } | ||
694 | else | ||
695 | { | ||
696 | mAOStandTimer = new AOStandTimer(); | ||
697 | } | ||
698 | } | ||
699 | else | ||
700 | { | ||
701 | stopMotion(getCurrentStandId(), FALSE, TRUE); //stop stand first then set state | ||
702 | setAnimationState(STATE_AGENT_IDLE); | ||
703 | } | ||
704 | } | ||
705 | else | ||
706 | { | ||
707 | if (state == STATE_AGENT_SIT) gAgent.sendAnimationRequest(GetAnimIDFromState(state), (gSavedSettings.getBOOL("AOEnabled") && gSavedSettings.getBOOL("AOSitsEnabled")) ? ANIM_REQUEST_START : ANIM_REQUEST_STOP); | ||
708 | else gAgent.sendAnimationRequest(GetAnimIDFromState(state), gSavedSettings.getBOOL("AOEnabled") ? ANIM_REQUEST_START : ANIM_REQUEST_STOP); | ||
709 | } | ||
710 | } | ||
711 | |||
712 | int LLFloaterAO::getAnimationState() | ||
713 | { | ||
714 | if (gAgent.getAvatarObject()) | ||
715 | { | ||
716 | if (gAgent.getAvatarObject()->mIsSitting) setAnimationState(STATE_AGENT_SIT); | ||
717 | else if (gAgent.getFlying()) setAnimationState(STATE_AGENT_HOVER); | ||
718 | } | ||
719 | return mAnimationState; | ||
720 | } | ||
721 | |||
722 | void LLFloaterAO::setAnimationState(const int state) | ||
723 | { | ||
724 | mAnimationState = state; | ||
725 | } | ||
726 | |||
727 | LLUUID LLFloaterAO::getCurrentStandId() | ||
728 | { | ||
729 | return mCurrentStandId; | ||
730 | } | ||
731 | |||
732 | void LLFloaterAO::setCurrentStandId(const LLUUID& id) | ||
733 | { | ||
734 | mCurrentStandId = id; | ||
735 | } | ||
736 | |||
737 | void LLFloaterAO::AOItemDrop(LLViewerInventoryItem* item) | ||
738 | { | ||
739 | gSavedPerAccountSettings.setString("AOConfigNotecardID", item->getUUID().asString()); | ||
740 | sInstance->childSetValue("ao_nc_text","Currently set to: "+item->getName()); | ||
741 | } | ||
742 | |||
743 | LLUUID LLFloaterAO::GetAnimID(const LLUUID& id) | ||
744 | { | ||
745 | for (std::vector<struct_overrides>::iterator iter = mAOOverrides.begin(); iter != mAOOverrides.end(); ++iter) | ||
746 | { | ||
747 | if (iter->orig_id == id) return iter->ao_id; | ||
748 | } | ||
749 | return LLUUID::null; | ||
750 | } | ||
751 | |||
752 | int LLFloaterAO::GetStateFromAnimID(const LLUUID& id) | ||
753 | { | ||
754 | for (std::vector<struct_overrides>::iterator iter = mAOOverrides.begin(); iter != mAOOverrides.end(); ++iter) | ||
755 | { | ||
756 | if (iter->orig_id == id) return iter->state; | ||
757 | } | ||
758 | return STATE_AGENT_IDLE; | ||
759 | } | ||
760 | |||
761 | LLUUID LLFloaterAO::GetAnimIDFromState(const int state) | ||
762 | { | ||
763 | for (std::vector<struct_overrides>::iterator iter = mAOOverrides.begin(); iter != mAOOverrides.end(); ++iter) | ||
764 | { | ||
765 | if (iter->state == state) return iter->ao_id; | ||
766 | } | ||
767 | return LLUUID::null; | ||
768 | } | ||
769 | |||
770 | int LLFloaterAO::GetStateFromToken(std::string strtoken) | ||
771 | { | ||
772 | for (std::vector<struct_tokens>::iterator iter = mAOTokens.begin(); iter != mAOTokens.end(); ++iter) | ||
773 | { | ||
774 | if (iter->token == strtoken) return iter->state; | ||
775 | } | ||
776 | return STATE_AGENT_IDLE; | ||
777 | } | ||
778 | |||
779 | void LLFloaterAO::onClickPrevStand(void* user_data) | ||
780 | { | ||
781 | if (!(mAOStands.size() > 0)) return; | ||
782 | stand_iterator=stand_iterator-1; | ||
783 | if (stand_iterator < 0) stand_iterator = int( mAOStands.size()-stand_iterator); | ||
784 | if (stand_iterator > int( mAOStands.size()-1)) stand_iterator = 0; | ||
785 | cmdline_printchat(llformat("Changing stand to %s.",mAOStands[stand_iterator].anim_name.c_str())); | ||
786 | ChangeStand(); | ||
787 | } | ||
788 | |||
789 | void LLFloaterAO::onClickNextStand(void* user_data) | ||
790 | { | ||
791 | if (!(mAOStands.size() > 0)) return; | ||
792 | stand_iterator=stand_iterator+1; | ||
793 | if (stand_iterator < 0) stand_iterator = int( mAOStands.size()-stand_iterator); | ||
794 | if (stand_iterator > int( mAOStands.size()-1)) stand_iterator = 0; | ||
795 | cmdline_printchat(llformat("Changing stand to %s.",mAOStands[stand_iterator].anim_name.c_str())); | ||
796 | ChangeStand(); | ||
797 | } | ||
798 | |||
799 | BOOL LLFloaterAO::ChangeStand() | ||
800 | { | ||
801 | if (gSavedSettings.getBOOL("AOEnabled")) | ||
802 | { | ||
803 | if (gAgent.getAvatarObject()) | ||
804 | { | ||
805 | if (gSavedSettings.getBOOL("AONoStandsInMouselook") && gAgent.cameraMouselook()) return FALSE; | ||
806 | |||
807 | if (gAgent.getAvatarObject()->mIsSitting) | ||
808 | { | ||
809 | // stopMotion(getCurrentStandId(), FALSE, TRUE); //stop stand first then set state | ||
810 | // if (getAnimationState() != STATE_AGENT_GROUNDSIT) setAnimationState(STATE_AGENT_SIT); | ||
811 | // setCurrentStandId(LLUUID::null); | ||
812 | return FALSE; | ||
813 | } | ||
814 | } | ||
815 | if ((getAnimationState() == STATE_AGENT_IDLE) || (getAnimationState() == STATE_AGENT_STAND))// stands have lowest priority | ||
816 | { | ||
817 | if (!(mAOStands.size() > 0)) return TRUE; | ||
818 | if (gSavedSettings.getBOOL("AOStandRandomize")) | ||
819 | { | ||
820 | stand_iterator = ll_rand(mAOStands.size()-1); | ||
821 | } | ||
822 | if (stand_iterator < 0) stand_iterator = int( mAOStands.size()-stand_iterator); | ||
823 | if (stand_iterator > int( mAOStands.size()-1)) stand_iterator = 0; | ||
824 | |||
825 | int stand_iterator_previous = stand_iterator -1; | ||
826 | |||
827 | if (stand_iterator_previous < 0) stand_iterator_previous = int( mAOStands.size()-1); | ||
828 | |||
829 | if (mAOStands[stand_iterator].ao_id.notNull()) | ||
830 | { | ||
831 | stopMotion(getCurrentStandId(), FALSE, TRUE); //stop stand first then set state | ||
832 | startMotion(mAOStands[stand_iterator].ao_id, 0, TRUE); | ||
833 | |||
834 | setAnimationState(STATE_AGENT_STAND); | ||
835 | setCurrentStandId(mAOStands[stand_iterator].ao_id); | ||
836 | if ((sInstance)&&(mcomboBox_stands)) mcomboBox_stands->selectNthItem(stand_iterator); | ||
837 | // llinfos << "changing stand to " << mAOStands[stand_iterator].anim_name << llendl; | ||
838 | return FALSE; | ||
839 | } | ||
840 | } | ||
841 | } | ||
842 | else | ||
843 | { | ||
844 | stopMotion(getCurrentStandId(), FALSE, TRUE); | ||
845 | return TRUE; //stop if ao is off | ||
846 | } | ||
847 | return TRUE; | ||
848 | } | ||
849 | |||
850 | |||
851 | BOOL LLFloaterAO::startMotion(const LLUUID& id, F32 time_offset, BOOL stand) | ||
852 | { | ||
853 | if (stand) | ||
854 | { | ||
855 | if (id.notNull()) | ||
856 | { | ||
857 | BOOL sitting = FALSE; | ||
858 | if (gAgent.getAvatarObject()) | ||
859 | { | ||
860 | sitting = gAgent.getAvatarObject()->mIsSitting; | ||
861 | } | ||
862 | if (sitting) return FALSE; | ||
863 | gAgent.sendAnimationRequest(id, ANIM_REQUEST_START); | ||
864 | return TRUE; | ||
865 | } | ||
866 | } | ||
867 | else | ||
868 | { | ||
869 | if (GetAnimID(id).notNull() && gSavedSettings.getBOOL("AOEnabled")) | ||
870 | { | ||
871 | stopMotion(getCurrentStandId(), FALSE, TRUE); //stop stand first then set state | ||
872 | setAnimationState(GetStateFromAnimID(id)); | ||
873 | |||
874 | // llinfos << " state " << getAnimationState() << " start anim " << id << " overriding with " << GetAnimID(id) << llendl; | ||
875 | if ((GetStateFromAnimID(id) == STATE_AGENT_SIT) && !(gSavedSettings.getBOOL("AOSitsEnabled"))) return TRUE; | ||
876 | gAgent.sendAnimationRequest(GetAnimID(id), ANIM_REQUEST_START); | ||
877 | return TRUE; | ||
878 | } | ||
879 | } | ||
880 | return FALSE; | ||
881 | } | ||
882 | |||
883 | BOOL LLFloaterAO::stopMotion(const LLUUID& id, BOOL stop_immediate, BOOL stand) | ||
884 | { | ||
885 | if (stand) | ||
886 | { | ||
887 | setAnimationState(STATE_AGENT_IDLE); | ||
888 | gAgent.sendAnimationRequest(id, ANIM_REQUEST_STOP); | ||
889 | return TRUE; | ||
890 | } | ||
891 | else | ||
892 | { | ||
893 | if (GetAnimID(id).notNull() && gSavedSettings.getBOOL("AOEnabled")) | ||
894 | { | ||
895 | // llinfos << " state " << getAnimationState() << "/" << GetStateFromAnimID(id) << "(now 0) stop anim " << id << " overriding with " << GetAnimID(id) << llendl; | ||
896 | if (getAnimationState() == GetStateFromAnimID(id)) | ||
897 | { | ||
898 | setAnimationState(STATE_AGENT_IDLE); | ||
899 | } | ||
900 | ChangeStand(); // startMotion(getCurrentStandId(), 0, TRUE); | ||
901 | gAgent.sendAnimationRequest(GetAnimID(id), ANIM_REQUEST_STOP); | ||
902 | return TRUE; | ||
903 | } | ||
904 | } | ||
905 | return FALSE; | ||
906 | } | ||
907 | |||
908 | void LLFloaterAO::onClickReloadCard(void* user_data) | ||
909 | { | ||
910 | if(gInventory.isEverythingFetched()) | ||
911 | { | ||
912 | LLFloaterAO::init(); | ||
913 | } | ||
914 | } | ||
915 | |||
916 | void LLFloaterAO::onClickOpenCard(void* user_data) | ||
917 | { | ||
918 | if(gInventory.isEverythingFetched()) | ||
919 | { | ||
920 | LLUUID configncitem = (LLUUID)gSavedPerAccountSettings.getString("AOConfigNotecardID"); | ||
921 | if (configncitem.notNull()) | ||
922 | { | ||
923 | const LLInventoryItem* item = gInventory.getItem(configncitem); | ||
924 | if(item) | ||
925 | { | ||
926 | if (gAgent.allowOperation(PERM_COPY, item->getPermissions(),GP_OBJECT_MANIPULATE) || gAgent.isGodlike()) | ||
927 | { | ||
928 | if(!item->getAssetUUID().isNull()) | ||
929 | open_notecard((LLViewerInventoryItem*)item, std::string("Note: ") + item->getName(), LLUUID::null, FALSE); | ||
930 | // open_notecard((LLViewerInventoryItem*)item, std::string("Note: ") + item->getName(), LLUUID::null, FALSE, LLUUID::null, FALSE); | ||
931 | } | ||
932 | } | ||
933 | } | ||
934 | } | ||
935 | } | ||
936 | |||
937 | struct AOAssetInfo | ||
938 | { | ||
939 | std::string path; | ||
940 | std::string name; | ||
941 | }; | ||
942 | |||
943 | void LLFloaterAO::onNotecardLoadComplete(LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::EType type,void* user_data, S32 status, LLExtStat ext_status) | ||
944 | { | ||
945 | if(status == LL_ERR_NOERR) | ||
946 | { | ||
947 | S32 size = vfs->getSize(asset_uuid, type); | ||
948 | U8* buffer = new U8[size]; | ||
949 | vfs->getData(asset_uuid, type, buffer, 0, size); | ||
950 | |||
951 | if(type == LLAssetType::AT_NOTECARD) | ||
952 | { | ||
953 | LLViewerTextEditor* edit = new LLViewerTextEditor("",LLRect(0,0,0,0),S32_MAX,""); | ||
954 | if(edit->importBuffer((char*)buffer, (S32)size)) | ||
955 | { | ||
956 | llinfos << "ao nc decode success" << llendl; | ||
957 | std::string card = edit->getText(); | ||
958 | edit->die(); | ||
959 | |||
960 | if (mcomboBox_stands) | ||
961 | { | ||
962 | mcomboBox_stands->clear(); | ||
963 | mcomboBox_stands->removeall(); | ||
964 | } | ||
965 | if (mcomboBox_walks) mcomboBox_walks->clear(); | ||
966 | if (mcomboBox_runs) mcomboBox_runs->clear(); | ||
967 | if (mcomboBox_jumps) mcomboBox_jumps->clear(); | ||
968 | if (mcomboBox_sits) mcomboBox_sits->clear(); | ||
969 | if (mcomboBox_gsits) mcomboBox_gsits->clear(); | ||
970 | if (mcomboBox_crouchs) mcomboBox_cwalks->clear(); | ||
971 | if (mcomboBox_cwalks) mcomboBox_cwalks->clear(); | ||
972 | if (mcomboBox_falls) mcomboBox_falls->clear(); | ||
973 | if (mcomboBox_hovers) mcomboBox_hovers->clear(); | ||
974 | if (mcomboBox_flys) mcomboBox_flys->clear(); | ||
975 | if (mcomboBox_flyslows) mcomboBox_flyslows->clear(); | ||
976 | if (mcomboBox_flyups) mcomboBox_flyups->clear(); | ||
977 | if (mcomboBox_flydowns) mcomboBox_flydowns->clear(); | ||
978 | if (mcomboBox_lands) mcomboBox_lands->clear(); | ||
979 | if (mcomboBox_standups) mcomboBox_standups->clear(); | ||
980 | if (mcomboBox_prejumps) mcomboBox_prejumps->clear(); | ||
981 | |||
982 | |||
983 | struct_stands loader; | ||
984 | |||
985 | typedef boost::tokenizer<boost::char_separator<char> > tokenizer; | ||
986 | boost::char_separator<char> sep("\n"); | ||
987 | tokenizer tokline(card, sep); | ||
988 | |||
989 | for (tokenizer::iterator line = tokline.begin(); line != tokline.end(); ++line) | ||
990 | { | ||
991 | // llinfos << *line << llendl; | ||
992 | std::string strline(*line); | ||
993 | // llinfos << "uncommented line: " << strline << llendl; | ||
994 | |||
995 | boost::regex type("^(\\s*)(\\[ )(.*)( \\])"); | ||
996 | boost::smatch what; | ||
997 | if (boost::regex_search(strline, what, type)) | ||
998 | { | ||
999 | // llinfos << "type: " << what[0] << llendl; | ||
1000 | // llinfos << "anims in type: " << boost::regex_replace(strline, type, "") << llendl; | ||
1001 | |||
1002 | boost::char_separator<char> sep("|,"); | ||
1003 | std::string stranimnames(boost::regex_replace(strline, type, "")); | ||
1004 | tokenizer tokanimnames(stranimnames, sep); | ||
1005 | for (tokenizer::iterator anim = tokanimnames.begin(); anim != tokanimnames.end(); ++anim) | ||
1006 | { | ||
1007 | std::string strtoken(what[0]); | ||
1008 | std::string stranim(*anim); | ||
1009 | LLUUID animid(getAssetIDByName(stranim)); | ||
1010 | |||
1011 | // llinfos << invfolderid.asString().c_str() << llendl; | ||
1012 | // llinfos << "anim: " << stranim.c_str() << " assetid: " << animid << llendl; | ||
1013 | if (!(animid.notNull())) | ||
1014 | { | ||
1015 | cmdline_printchat(llformat("Warning: animation '%s' could not be found (Section: %s).",stranim.c_str(),strtoken.c_str())); | ||
1016 | } | ||
1017 | else | ||
1018 | { | ||
1019 | switch(GetStateFromToken(strtoken.c_str())) | ||
1020 | { | ||
1021 | case STATE_AGENT_STAND: | ||
1022 | loader.ao_id = animid; loader.anim_name = stranim.c_str(); mAOStands.push_back(loader); | ||
1023 | if(mcomboBox_stands != NULL) mcomboBox_stands->add(stranim.c_str(), ADD_BOTTOM, TRUE); | ||
1024 | break; | ||
1025 | case STATE_AGENT_WALK: | ||
1026 | { | ||
1027 | if (sInstance && (mcomboBox_walks != NULL)) | ||
1028 | { | ||
1029 | //llinfos << "1 anim: " << stranim.c_str() << " assetid: " << animid << llendl; | ||
1030 | if (!(mcomboBox_walks->selectByValue(stranim.c_str()))) mcomboBox_walks->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1031 | } | ||
1032 | } | ||
1033 | break; | ||
1034 | case STATE_AGENT_RUN: | ||
1035 | { | ||
1036 | if (sInstance && (mcomboBox_runs != NULL)) | ||
1037 | { | ||
1038 | if (!(mcomboBox_runs->selectByValue(stranim.c_str()))) mcomboBox_runs->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1039 | } | ||
1040 | } | ||
1041 | break; | ||
1042 | case STATE_AGENT_JUMP: | ||
1043 | { | ||
1044 | if (sInstance && (mcomboBox_jumps != NULL)) | ||
1045 | { | ||
1046 | if (!(mcomboBox_jumps->selectByValue(stranim.c_str()))) mcomboBox_jumps->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1047 | } | ||
1048 | } | ||
1049 | break; | ||
1050 | case STATE_AGENT_SIT: | ||
1051 | { | ||
1052 | if (sInstance && (mcomboBox_sits != NULL)) | ||
1053 | { | ||
1054 | if (!(mcomboBox_sits->selectByValue(stranim.c_str()))) mcomboBox_sits->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1055 | } | ||
1056 | } | ||
1057 | break; | ||
1058 | case STATE_AGENT_GROUNDSIT: | ||
1059 | { | ||
1060 | if (sInstance && (mcomboBox_gsits != NULL)) | ||
1061 | { | ||
1062 | if (!(mcomboBox_gsits->selectByValue(stranim.c_str()))) mcomboBox_gsits->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1063 | } | ||
1064 | } | ||
1065 | break; | ||
1066 | case STATE_AGENT_CROUCH: | ||
1067 | { | ||
1068 | if (sInstance && (mcomboBox_crouchs != NULL)) | ||
1069 | { | ||
1070 | if (!(mcomboBox_crouchs->selectByValue(stranim.c_str()))) mcomboBox_crouchs->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1071 | } | ||
1072 | } | ||
1073 | break; | ||
1074 | case STATE_AGENT_CROUCHWALK: | ||
1075 | { | ||
1076 | if (sInstance && (mcomboBox_cwalks != NULL)) | ||
1077 | { | ||
1078 | if (!(mcomboBox_cwalks->selectByValue(stranim.c_str()))) mcomboBox_cwalks->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1079 | } | ||
1080 | } | ||
1081 | break; | ||
1082 | case STATE_AGENT_FALLDOWN: | ||
1083 | { | ||
1084 | if (sInstance && (mcomboBox_falls != NULL)) | ||
1085 | { | ||
1086 | if (!(mcomboBox_falls->selectByValue(stranim.c_str()))) mcomboBox_falls->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1087 | } | ||
1088 | } | ||
1089 | break; | ||
1090 | case STATE_AGENT_HOVER: | ||
1091 | { | ||
1092 | if (sInstance && (mcomboBox_hovers != NULL)) | ||
1093 | { | ||
1094 | if (!(mcomboBox_hovers->selectByValue(stranim.c_str()))) mcomboBox_hovers->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1095 | } | ||
1096 | } | ||
1097 | break; | ||
1098 | case STATE_AGENT_FLY: | ||
1099 | { | ||
1100 | if (sInstance && (mcomboBox_flys != NULL)) | ||
1101 | { | ||
1102 | if (!(mcomboBox_flys->selectByValue(stranim.c_str()))) mcomboBox_flys->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1103 | } | ||
1104 | } | ||
1105 | break; | ||
1106 | case STATE_AGENT_FLYSLOW: | ||
1107 | { | ||
1108 | if (sInstance && (mcomboBox_flyslows != NULL)) | ||
1109 | { | ||
1110 | if (!(mcomboBox_flyslows->selectByValue(stranim.c_str()))) mcomboBox_flyslows->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1111 | } | ||
1112 | } | ||
1113 | break; | ||
1114 | case STATE_AGENT_HOVER_UP: | ||
1115 | { | ||
1116 | if (sInstance && (mcomboBox_flyups != NULL)) | ||
1117 | { | ||
1118 | if (!(mcomboBox_flyups->selectByValue(stranim.c_str()))) mcomboBox_flyups->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1119 | } | ||
1120 | } | ||
1121 | break; | ||
1122 | case STATE_AGENT_HOVER_DOWN: | ||
1123 | { | ||
1124 | if (sInstance && (mcomboBox_flydowns != NULL)) | ||
1125 | { | ||
1126 | if (!(mcomboBox_flydowns->selectByValue(stranim.c_str()))) mcomboBox_flydowns->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1127 | } | ||
1128 | } | ||
1129 | break; | ||
1130 | case STATE_AGENT_LAND: | ||
1131 | { | ||
1132 | if (sInstance && (mcomboBox_lands != NULL)) | ||
1133 | { | ||
1134 | if (!(mcomboBox_lands->selectByValue(stranim.c_str()))) mcomboBox_lands->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1135 | } | ||
1136 | } | ||
1137 | break; | ||
1138 | case STATE_AGENT_STANDUP: | ||
1139 | { | ||
1140 | if (sInstance && (mcomboBox_standups != NULL)) | ||
1141 | { | ||
1142 | if (!(mcomboBox_standups->selectByValue(stranim.c_str()))) mcomboBox_standups->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1143 | } | ||
1144 | } | ||
1145 | break; | ||
1146 | case STATE_AGENT_PRE_JUMP: | ||
1147 | { | ||
1148 | if (sInstance && (mcomboBox_prejumps != NULL)) | ||
1149 | { | ||
1150 | if (!(mcomboBox_prejumps->selectByValue(stranim.c_str()))) mcomboBox_prejumps->add(stranim.c_str(), ADD_BOTTOM, TRUE); //check if exist | ||
1151 | } | ||
1152 | } | ||
1153 | break; | ||
1154 | } | ||
1155 | for (std::vector<struct_overrides>::iterator iter = mAOOverrides.begin(); iter != mAOOverrides.end(); ++iter) | ||
1156 | { | ||
1157 | if (GetStateFromToken(strtoken.c_str()) == iter->state) | ||
1158 | { | ||
1159 | iter->ao_id = animid; | ||
1160 | } | ||
1161 | } | ||
1162 | } | ||
1163 | } | ||
1164 | } | ||
1165 | } | ||
1166 | llinfos << "ao nc read sucess" << llendl; | ||
1167 | |||
1168 | for (std::vector<struct_overrides>::iterator iter = mAOOverrides.begin(); iter != mAOOverrides.end(); ++iter) | ||
1169 | { | ||
1170 | switch(iter->state) | ||
1171 | { | ||
1172 | |||
1173 | case STATE_AGENT_WALK: | ||
1174 | { | ||
1175 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultWalk"); | ||
1176 | SetDefault(mcomboBox_walks,iter->ao_id,defaultanim); | ||
1177 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1178 | } | ||
1179 | break; | ||
1180 | case STATE_AGENT_RUN: | ||
1181 | { | ||
1182 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultRun"); | ||
1183 | SetDefault(mcomboBox_runs,iter->ao_id,defaultanim); | ||
1184 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1185 | } | ||
1186 | break; | ||
1187 | case STATE_AGENT_JUMP: | ||
1188 | { | ||
1189 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultJump"); | ||
1190 | SetDefault(mcomboBox_jumps,iter->ao_id,defaultanim); | ||
1191 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1192 | } | ||
1193 | break; | ||
1194 | case STATE_AGENT_SIT: | ||
1195 | { | ||
1196 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultSit"); | ||
1197 | SetDefault(mcomboBox_sits,iter->ao_id,defaultanim); | ||
1198 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1199 | } | ||
1200 | break; | ||
1201 | case STATE_AGENT_CROUCH: | ||
1202 | { | ||
1203 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultCrouch"); | ||
1204 | SetDefault(mcomboBox_crouchs,iter->ao_id,defaultanim); | ||
1205 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1206 | } | ||
1207 | break; | ||
1208 | case STATE_AGENT_GROUNDSIT: | ||
1209 | { | ||
1210 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultGroundSit"); | ||
1211 | SetDefault(mcomboBox_gsits,iter->ao_id,defaultanim); | ||
1212 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1213 | } | ||
1214 | break; | ||
1215 | case STATE_AGENT_CROUCHWALK: | ||
1216 | { | ||
1217 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultCrouchWalk"); | ||
1218 | SetDefault(mcomboBox_cwalks,iter->ao_id,defaultanim); | ||
1219 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1220 | } | ||
1221 | break; | ||
1222 | case STATE_AGENT_FALLDOWN: | ||
1223 | { | ||
1224 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultFall"); | ||
1225 | SetDefault(mcomboBox_falls,iter->ao_id,defaultanim); | ||
1226 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1227 | } | ||
1228 | break; | ||
1229 | case STATE_AGENT_HOVER: | ||
1230 | { | ||
1231 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultHover"); | ||
1232 | SetDefault(mcomboBox_hovers,iter->ao_id,defaultanim); | ||
1233 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1234 | } | ||
1235 | break; | ||
1236 | case STATE_AGENT_FLY: | ||
1237 | { | ||
1238 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultFly"); | ||
1239 | SetDefault(mcomboBox_flys,iter->ao_id,defaultanim); | ||
1240 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1241 | } | ||
1242 | break; | ||
1243 | case STATE_AGENT_HOVER_UP: | ||
1244 | { | ||
1245 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultFlyUp"); | ||
1246 | SetDefault(mcomboBox_flyups,iter->ao_id,defaultanim); | ||
1247 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1248 | } | ||
1249 | break; | ||
1250 | case STATE_AGENT_FLYSLOW: | ||
1251 | { | ||
1252 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultFlySlow"); | ||
1253 | SetDefault(mcomboBox_flyslows,iter->ao_id,defaultanim); | ||
1254 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1255 | } | ||
1256 | break; | ||
1257 | case STATE_AGENT_HOVER_DOWN: | ||
1258 | { | ||
1259 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultFlyDown"); | ||
1260 | SetDefault(mcomboBox_flydowns,iter->ao_id,defaultanim); | ||
1261 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1262 | } | ||
1263 | break; | ||
1264 | case STATE_AGENT_LAND: | ||
1265 | { | ||
1266 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultLand"); | ||
1267 | SetDefault(mcomboBox_lands,iter->ao_id,defaultanim); | ||
1268 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1269 | } | ||
1270 | break; | ||
1271 | case STATE_AGENT_STANDUP: | ||
1272 | { | ||
1273 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultStandUp"); | ||
1274 | SetDefault(mcomboBox_standups,iter->ao_id,defaultanim); | ||
1275 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1276 | } | ||
1277 | break; | ||
1278 | case STATE_AGENT_PRE_JUMP: | ||
1279 | { | ||
1280 | std::string defaultanim = gSavedPerAccountSettings.getString("AODefaultPreJump"); | ||
1281 | SetDefault(mcomboBox_prejumps,iter->ao_id,defaultanim); | ||
1282 | if (getAssetIDByName(defaultanim) != LLUUID::null) iter->ao_id = getAssetIDByName(defaultanim); | ||
1283 | } | ||
1284 | break; | ||
1285 | } | ||
1286 | } | ||
1287 | run(); | ||
1288 | } | ||
1289 | else | ||
1290 | { | ||
1291 | llinfos << "ao nc decode error" << llendl; | ||
1292 | } | ||
1293 | } | ||
1294 | } | ||
1295 | else | ||
1296 | { | ||
1297 | llinfos << "ao nc read error" << llendl; | ||
1298 | } | ||
1299 | } | ||
1300 | |||
1301 | BOOL LLFloaterAO::SetDefault(void* userdata, LLUUID ao_id, std::string defaultanim) | ||
1302 | { | ||
1303 | if (sInstance && (userdata)) | ||
1304 | { | ||
1305 | LLComboBox *box = (LLComboBox *) userdata; | ||
1306 | if (LLUUID::null == ao_id) | ||
1307 | { | ||
1308 | box->clear(); | ||
1309 | box->removeall(); | ||
1310 | } | ||
1311 | else | ||
1312 | { | ||
1313 | box->selectByValue(defaultanim); | ||
1314 | } | ||
1315 | } | ||
1316 | return TRUE; | ||
1317 | } | ||
1318 | |||
1319 | class ObjectNameMatches : public LLInventoryCollectFunctor | ||
1320 | { | ||
1321 | public: | ||
1322 | ObjectNameMatches(std::string name) | ||
1323 | { | ||
1324 | sName = name; | ||
1325 | } | ||
1326 | virtual ~ObjectNameMatches() {} | ||
1327 | virtual bool operator()(LLInventoryCategory* cat, | ||
1328 | LLInventoryItem* item) | ||
1329 | { | ||
1330 | if(item) | ||
1331 | { | ||
1332 | if (item->getParentUUID() == LLFloaterAO::invfolderid) | ||
1333 | { | ||
1334 | return (item->getName() == sName); | ||
1335 | } | ||
1336 | return false; | ||
1337 | } | ||
1338 | return false; | ||
1339 | } | ||
1340 | private: | ||
1341 | std::string sName; | ||
1342 | }; | ||
1343 | |||
1344 | const LLUUID& LLFloaterAO::getAssetIDByName(const std::string& name) | ||
1345 | { | ||
1346 | if (name.empty() || !(gInventory.isEverythingFetched())) return LLUUID::null; | ||
1347 | |||
1348 | LLViewerInventoryCategory::cat_array_t cats; | ||
1349 | LLViewerInventoryItem::item_array_t items; | ||
1350 | ObjectNameMatches objectnamematches(name); | ||
1351 | gInventory.collectDescendentsIf(LLUUID::null,cats,items,FALSE,objectnamematches); | ||
1352 | |||
1353 | if (items.count()) | ||
1354 | { | ||
1355 | return items[0]->getAssetUUID(); | ||
1356 | } | ||
1357 | return LLUUID::null; | ||
1358 | }; | ||