MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / addEntry

Method addEntry

Engine/source/gui/controls/guiPopUpCtrl.cpp:616–683  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

614
615//------------------------------------------------------------------------------
616void 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 }

Callers 9

onActionMethod · 0.45
onSubmenuActionMethod · 0.45
_populateMenuMethod · 0.45
_populateMenuMethod · 0.45
buildListMethod · 0.45
updateValueMethod · 0.45
guiPopUpCtrl.cppFile · 0.45
onActionMethod · 0.45
reverseTextListMethod · 0.45

Calls 7

dStrcpyFunction · 0.85
dStrcmpFunction · 0.50
dStrchrFunction · 0.50
dAtoiFunction · 0.50
ColorIClass · 0.50
sizeMethod · 0.45
push_backMethod · 0.45

Tested by 1

_populateMenuMethod · 0.36