MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / buildIconTable

Method buildIconTable

engine/source/gui/guiTreeViewCtrl.cc:1128–1167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126}
1127
1128bool GuiTreeViewCtrl::buildIconTable(const char * icons)
1129{
1130 // Icons should be designated by the bitmap/png file names (minus the file extensions)
1131 // and separated by colons (:). This list should be synchronized with the Icons enum.
1132
1133 // This is an abominal piece of code. -- BJG
1134 if (!icons)
1135 {
1136 icons = "common/gui/images/default:"
1137 "common/gui/images/simgroup:"
1138 "common/gui/images/simgroupClosed:"
1139 "common/gui/images/simgroupSelected:"
1140 "common/gui/images/simgroupSelectedClosed:";
1141 }
1142
1143 // Figure the size of the buffer we need...
1144 const char* temp = dStrchr( icons, '\t' );
1145 U32 textLen = temp ? (U32)( temp - icons ) : dStrlen( icons );
1146
1147 // Allocate temporary space.
1148 FrameAllocatorMarker txtBuff;
1149 char* drawText = (char*)txtBuff.alloc(sizeof(char) * (textLen + 4));
1150 dStrncpy( drawText, icons, textLen );
1151 drawText[textLen] = '\0';
1152
1153 U32 numIcons = 0;
1154 char *buf = (char*)txtBuff.alloc(sizeof(char) * 256);
1155 char* token = dStrtok( drawText, ":" );
1156
1157 // Count the number of icons and store them.
1158 while (token && numIcons < MaxIcons)
1159 {
1160 dSprintf( buf, sizeof( char ) * 256, "%s", token );
1161 mIconTable[numIcons] = TextureHandle( buf, TextureHandle::BitmapKeepTexture );
1162 token = dStrtok( NULL, ":" );
1163 numIcons++;
1164 }
1165
1166 return true;
1167}
1168
1169//------------------------------------------------------------------------------
1170

Callers 1

guiTreeViewCtrl.ccFile · 0.80

Calls 7

dStrchrFunction · 0.50
dStrlenFunction · 0.50
dStrncpyFunction · 0.50
dStrtokFunction · 0.50
dSprintfFunction · 0.50
TextureHandleClass · 0.50
allocMethod · 0.45

Tested by

no test coverage detected