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

Method addEntry

Engine/source/gui/controls/guiPopUpCtrlEx.cpp:837–904  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

835
836//------------------------------------------------------------------------------
837void GuiPopUpMenuCtrlEx::addEntry(const char *buf, S32 id, U32 scheme)
838{
839 if( !buf )
840 {
841 //Con::printf( "GuiPopupMenuCtrlEx::addEntry - Invalid buffer!" );
842 return;
843 }
844
845 // Ensure that there are no other entries with exactly the same name
846 for ( U32 i = 0; i < mEntries.size(); i++ )
847 {
848 if ( String::compare( mEntries[i].buf, buf ) == 0 )
849 return;
850 }
851
852 // If we don't give an id, create one from mIdMax
853 if( id == -1 )
854 id = mIdMax + 1;
855
856 // Increase mIdMax when an id is greater than it
857 if( id > mIdMax )
858 mIdMax = id;
859
860 Entry e;
861 dStrcpy( e.buf, buf, 256 );
862 e.id = id;
863 e.scheme = scheme;
864
865 // see if there is a shortcut key
866 char * cp = dStrchr( e.buf, '~' );
867 e.ascii = cp ? cp[1] : 0;
868
869 // See if there is a colour box defined with the text
870 char *cb = dStrchr( e.buf, '|' );
871 if ( cb )
872 {
873 e.usesColorBox = true;
874 cb[0] = '\0';
875
876 char* red = &cb[1];
877 cb = dStrchr(red, '|');
878 cb[0] = '\0';
879 char* green = &cb[1];
880 cb = dStrchr(green, '|');
881 cb[0] = '\0';
882 char* blue = &cb[1];
883
884 U32 r = dAtoi(red);
885 U32 g = dAtoi(green);
886 U32 b = dAtoi(blue);
887
888 e.colorbox = ColorI(r,g,b);
889
890 }
891 else
892 {
893 e.usesColorBox = false;
894 }

Callers 3

guiPopUpCtrlEx.cppFile · 0.45
onActionMethod · 0.45
reverseTextListMethod · 0.45

Calls 7

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

Tested by

no test coverage detected