| 1126 | } |
| 1127 | |
| 1128 | bool 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 |
no test coverage detected