------------------------------------------------------------------------------
| 614 | |
| 615 | //------------------------------------------------------------------------------ |
| 616 | void GuiPopUpMenuCtrl::addEntry( const char *buf, S32 id, U32 scheme ) |
| 617 | { |
| 618 | if( !buf ) |
| 619 | { |
| 620 | //Con::printf( "GuiPopupMenuCtrlEx::addEntry - Invalid buffer!" ); |
| 621 | return; |
| 622 | } |
| 623 | |
| 624 | // Ensure that there are no other entries with exactly the same name |
| 625 | for ( U32 i = 0; i < mEntries.size(); i++ ) |
| 626 | { |
| 627 | if ( dStrcmp( mEntries[i].buf, buf ) == 0 ) |
| 628 | return; |
| 629 | } |
| 630 | |
| 631 | // If we don't give an id, create one from mIdMax |
| 632 | if( id == -1 ) |
| 633 | id = mIdMax + 1; |
| 634 | |
| 635 | // Increase mIdMax when an id is greater than it |
| 636 | if( id > mIdMax ) |
| 637 | mIdMax = id; |
| 638 | |
| 639 | Entry e; |
| 640 | dStrcpy( e.buf, buf ); |
| 641 | e.id = id; |
| 642 | e.scheme = scheme; |
| 643 | |
| 644 | // see if there is a shortcut key |
| 645 | char * cp = dStrchr( e.buf, '~' ); |
| 646 | e.ascii = cp ? cp[1] : 0; |
| 647 | |
| 648 | // See if there is a colour box defined with the text |
| 649 | char *cb = dStrchr( e.buf, '|' ); |
| 650 | if ( cb ) |
| 651 | { |
| 652 | e.usesColorBox = true; |
| 653 | cb[0] = '\0'; |
| 654 | |
| 655 | char* red = &cb[1]; |
| 656 | cb = dStrchr(red, '|'); |
| 657 | cb[0] = '\0'; |
| 658 | char* green = &cb[1]; |
| 659 | cb = dStrchr(green, '|'); |
| 660 | cb[0] = '\0'; |
| 661 | char* blue = &cb[1]; |
| 662 | |
| 663 | U32 r = dAtoi(red); |
| 664 | U32 g = dAtoi(green); |
| 665 | U32 b = dAtoi(blue); |
| 666 | |
| 667 | e.colorbox = ColorI(r,g,b); |
| 668 | |
| 669 | } |
| 670 | else |
| 671 | { |
| 672 | e.usesColorBox = false; |
| 673 | } |