aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llgesturemgr.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:04 -0500
committerJacek Antonelli2008-08-15 23:45:04 -0500
commit117e22047c5752352342d64e3fb7ce00a4eb8113 (patch)
treee32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/newview/llgesturemgr.cpp
parentSecond Life viewer sources 1.18.0.6 (diff)
downloadmeta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz
Second Life viewer sources 1.18.1.2
Diffstat (limited to 'linden/indra/newview/llgesturemgr.cpp')
-rw-r--r--linden/indra/newview/llgesturemgr.cpp68
1 files changed, 54 insertions, 14 deletions
diff --git a/linden/indra/newview/llgesturemgr.cpp b/linden/indra/newview/llgesturemgr.cpp
index c94e9e2..bf3c057 100644
--- a/linden/indra/newview/llgesturemgr.cpp
+++ b/linden/indra/newview/llgesturemgr.cpp
@@ -103,7 +103,7 @@ void LLGestureManager::activateGesture(const LLUUID& item_id)
103 mDeactivateSimilarNames.clear(); 103 mDeactivateSimilarNames.clear();
104 104
105 const BOOL inform_server = TRUE; 105 const BOOL inform_server = TRUE;
106 const BOOL deactivate_similar = TRUE; 106 const BOOL deactivate_similar = FALSE;
107 activateGestureWithAsset(item_id, asset_id, inform_server, deactivate_similar); 107 activateGestureWithAsset(item_id, asset_id, inform_server, deactivate_similar);
108} 108}
109 109
@@ -206,6 +206,11 @@ void LLGestureManager::activateGestureWithAsset(const LLUUID& item_id,
206 BOOL inform_server, 206 BOOL inform_server,
207 BOOL deactivate_similar) 207 BOOL deactivate_similar)
208{ 208{
209 if( !gAssetStorage )
210 {
211 llwarns << "LLGestureManager::activateGestureWithAsset without valid gAssetStorage" << llendl;
212 return;
213 }
209 // If gesture is already active, nothing to do. 214 // If gesture is already active, nothing to do.
210 if (isGestureActive(item_id)) 215 if (isGestureActive(item_id))
211 { 216 {
@@ -418,7 +423,7 @@ void LLGestureManager::replaceGesture(const LLUUID& item_id, LLMultiGesture* new
418 LLLoadInfo* info = new LLLoadInfo; 423 LLLoadInfo* info = new LLLoadInfo;
419 info->mItemID = item_id; 424 info->mItemID = item_id;
420 info->mInformServer = TRUE; 425 info->mInformServer = TRUE;
421 info->mDeactivateSimilar = TRUE; 426 info->mDeactivateSimilar = FALSE;
422 427
423 const BOOL high_priority = TRUE; 428 const BOOL high_priority = TRUE;
424 gAssetStorage->getAssetData(asset_id, 429 gAssetStorage->getAssetData(asset_id,
@@ -489,6 +494,8 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s
489 LLString cur_token_lower = cur_token; 494 LLString cur_token_lower = cur_token;
490 LLString::toLower(cur_token_lower); 495 LLString::toLower(cur_token_lower);
491 496
497 // collect gestures that match
498 std::vector <LLMultiGesture *> matching;
492 item_map_t::iterator it; 499 item_map_t::iterator it;
493 for (it = mActive.begin(); it != mActive.end(); ++it) 500 for (it = mActive.begin(); it != mActive.end(); ++it)
494 { 501 {
@@ -496,16 +503,32 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s
496 503
497 // Gesture asset data might not have arrived yet 504 // Gesture asset data might not have arrived yet
498 if (!gesture) continue; 505 if (!gesture) continue;
499 506
500 if (!stricmp(gesture->mTrigger.c_str(), cur_token_lower.c_str())) 507 if (!stricmp(gesture->mTrigger.c_str(), cur_token_lower.c_str()))
501 { 508 {
509 matching.push_back(gesture);
510 }
511
512 gesture = NULL;
513 }
514
515
516 if (matching.size() > 0)
517 {
518 // choose one at random
519 {
520 S32 random = ll_rand(matching.size());
521
522 gesture = matching[random];
523
502 playGesture(gesture); 524 playGesture(gesture);
503 525
504 if (!gesture->mReplaceText.empty()) 526 if (!gesture->mReplaceText.empty())
505 { 527 {
506 if( !first_token ) 528 if( !first_token )
507 { 529 {
508 revised_string->append( " " ); 530 if (revised_string)
531 revised_string->append( " " );
509 } 532 }
510 533
511 // Don't muck with the user's capitalization if we don't have to. 534 // Don't muck with the user's capitalization if we don't have to.
@@ -514,30 +537,34 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s
514 LLString::toLower(output_lower); 537 LLString::toLower(output_lower);
515 if( cur_token_lower == output_lower ) 538 if( cur_token_lower == output_lower )
516 { 539 {
517 revised_string->append( cur_token ); 540 if (revised_string)
541 revised_string->append( cur_token );
518 } 542 }
519 else 543 else
520 { 544 {
521 revised_string->append( output ); 545 if (revised_string)
546 revised_string->append( output );
522 } 547 }
523 } 548 }
524 found_gestures = TRUE; 549 found_gestures = TRUE;
525 break;
526 } 550 }
527 gesture = NULL;
528 } 551 }
529 } 552 }
530 553
531 if( !gesture ) 554 if(!gesture)
532 { 555 {
556 // This token doesn't match a gesture. Pass it through to the output.
533 if( !first_token ) 557 if( !first_token )
534 { 558 {
535 revised_string->append( " " ); 559 if (revised_string)
560 revised_string->append( " " );
536 } 561 }
537 revised_string->append( cur_token ); 562 if (revised_string)
563 revised_string->append( cur_token );
538 } 564 }
539 565
540 first_token = FALSE; 566 first_token = FALSE;
567 gesture = NULL;
541 } 568 }
542 return found_gestures; 569 return found_gestures;
543} 570}
@@ -545,7 +572,10 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s
545 572
546BOOL LLGestureManager::triggerGesture(KEY key, MASK mask) 573BOOL LLGestureManager::triggerGesture(KEY key, MASK mask)
547{ 574{
575 std::vector <LLMultiGesture *> matching;
548 item_map_t::iterator it; 576 item_map_t::iterator it;
577
578 // collect matching gestures
549 for (it = mActive.begin(); it != mActive.end(); ++it) 579 for (it = mActive.begin(); it != mActive.end(); ++it)
550 { 580 {
551 LLMultiGesture* gesture = (*it).second; 581 LLMultiGesture* gesture = (*it).second;
@@ -556,10 +586,20 @@ BOOL LLGestureManager::triggerGesture(KEY key, MASK mask)
556 if (gesture->mKey == key 586 if (gesture->mKey == key
557 && gesture->mMask == mask) 587 && gesture->mMask == mask)
558 { 588 {
559 playGesture(gesture); 589 matching.push_back(gesture);
560 return TRUE;
561 } 590 }
562 } 591 }
592
593 // choose one and play it
594 if (matching.size() > 0)
595 {
596 U32 random = ll_rand(matching.size());
597
598 LLMultiGesture* gesture = matching[random];
599
600 playGesture(gesture);
601 return TRUE;
602 }
563 return FALSE; 603 return FALSE;
564} 604}
565 605