------------------------------------------------------------------------------
| 632 | |
| 633 | //------------------------------------------------------------------------------ |
| 634 | void GuiPopUpMenuCtrl::addEntry( const char *buf, S32 id, U32 scheme ) |
| 635 | { |
| 636 | if( !buf ) |
| 637 | { |
| 638 | //Con::printf( "GuiPopupMenuCtrlEx::addEntry - Invalid buffer!" ); |
| 639 | return; |
| 640 | } |
| 641 | |
| 642 | // Ensure that there are no other entries with exactly the same name |
| 643 | for ( U32 i = 0; i < mEntries.size(); i++ ) |
| 644 | { |
| 645 | if ( String::compare( mEntries[i].buf, buf ) == 0 ) |
| 646 | return; |
| 647 | } |
| 648 | |
| 649 | // If we don't give an id, create one from mIdMax |
| 650 | if( id == -1 ) |
| 651 | id = mIdMax + 1; |
| 652 | |
| 653 | // Increase mIdMax when an id is greater than it |
| 654 | if( id > mIdMax ) |
| 655 | mIdMax = id; |
| 656 | |
| 657 | Entry e; |
| 658 | dStrcpy( e.buf, buf, 256 ); |
| 659 | e.id = id; |
| 660 | e.scheme = scheme; |
| 661 | |
| 662 | // see if there is a shortcut key |
| 663 | char * cp = dStrchr( e.buf, '~' ); |
| 664 | e.ascii = cp ? cp[1] : 0; |
| 665 | |
| 666 | // See if there is a colour box defined with the text |
| 667 | char *cb = dStrchr( e.buf, '|' ); |
| 668 | if ( cb ) |
| 669 | { |
| 670 | e.usesColorBox = true; |
| 671 | cb[0] = '\0'; |
| 672 | |
| 673 | char* red = &cb[1]; |
| 674 | cb = dStrchr(red, '|'); |
| 675 | cb[0] = '\0'; |
| 676 | char* green = &cb[1]; |
| 677 | cb = dStrchr(green, '|'); |
| 678 | cb[0] = '\0'; |
| 679 | char* blue = &cb[1]; |
| 680 | |
| 681 | U32 r = dAtoi(red); |
| 682 | U32 g = dAtoi(green); |
| 683 | U32 b = dAtoi(blue); |
| 684 | |
| 685 | e.colorbox = ColorI(r,g,b); |
| 686 | |
| 687 | } |
| 688 | else |
| 689 | { |
| 690 | e.usesColorBox = false; |
| 691 | } |