BtBool BtStrCompare( const BtChar* pString1, const BtChar* pString2 ) { BtU32 maxString = MtMax( BtStrLength( pString1 ), BtStrLength( pString2 ) ); if( BtMemory::Compare( (void*)pString1, (void*)pString2, maxString ) == BtTrue ) { return BtTrue; } return BtFalse; }
void LBtStrTrimSpaces( BtChar* szSource, BtU32 nSize ) { BtU32 length = BtStrLength( szSource ); for( BtS32 i=length - 1; i >= 0; i-- ) { BtChar& myChar = szSource[i]; switch( myChar ) { case ' ' : case '\n' : case '\r' : case '\0' : if( myChar == ' ' ) { myChar = '\0'; } break; default: i = -1; break; } } }
// virtual MtVector2 RsFontWin32GL::GetDimension( const BtChar* szText ) { MtVector2 v2LastPosition = MtVector2( 0, 0 ); // Set the start position MtVector2 v2Position = MtVector2( 0, 0 ); // Cache the string length BtU32 length = BtStrLength(szText); // Loop through the string for( BtU32 nCharacterIndex=0; nCharacterIndex<length; nCharacterIndex++ ) { // Cache each character BtUChar Character = szText[nCharacterIndex]; if( Character == '\n' ) { // Cache the font character LBaFontChar& fontChar = m_pFileData->m_characters['A']; v2Position.x = 0; v2Position.y += fontChar.m_fHeight * 1.50f; continue; } // Cache the font character LBaFontChar& fontChar = m_pFileData->m_characters[Character]; // Set the dimension from the width and height of the texture MtVector2 v2Dimension = MtVector2( fontChar.m_fWidth, fontChar.m_fHeight ); // Increment the last position v2LastPosition.x = MtMax( v2LastPosition.x, v2Position.x + v2Dimension.x ); v2LastPosition.y = MtMax( v2LastPosition.y, v2Position.y + v2Dimension.y ); // Increment the position v2Position.x += fontChar.m_nXAdvance; } MtVector2 v2Dimension = v2LastPosition; return v2Dimension; }
void HlDebug::Render() { if( !ApConfig::IsDebug() ) { return; } BtU32 numItems = m_items.GetNumItems(); MtVector2 v2Position( 0, 0 ); MtVector2 v2Dimension( 0, 0 ); for( BtU32 i=0; i<numItems; i++ ) { HlItem &item = m_items[i]; if( !IsHidden(item) ) { RsColour textColour = RsColour::WhiteColour(); if( item.m_isReadOnly ) { textColour = RsColour( 0.7f, 0.7f, 0.7f, 1.0f ); } BtChar text[2048]; sprintf( text, "" ); for(BtU32 j = 0; j < GetNumParents(&item) * 4; j++) { sprintf( text + strlen(text), " "); } if(item.m_type == HlDebugEnum ) { BtU32 current = *item.m_pEnum; sprintf( text + strlen(text), "%s ", item.m_name ); BtU32 index = 0; BtChar *pStr = item.m_pEnumString; while( pStr ) { BtChar temp[32]; BtStrCopy( temp, 32, pStr, BtStrLength( pStr ) ); BtChar *eol = BtStrStr(temp, ";"); if( eol ) { *eol = 0; pStr = BtStrStr(pStr, ";") + 1; } else { pStr = 0; } if(current == index) { sprintf(text + strlen(text), "%s", temp); } ++index; } } else if(item.m_type == HlDebugSave ) { sprintf(text + strlen(text), "Save"); } else if( item.m_type == HlDebugNode ) { sprintf( text + strlen(text), "%s", item.m_name); if( item.m_isCollapsed ) { sprintf( text + strlen(text), "+" ); } else { sprintf(text + strlen(text), "-" ); } } else if( item.m_type == HlDebugFloat ) { BtFloat value = *item.m_pFloat; // Do the conversion if( item.m_unitsSystem == HLDebugKnots ) { value = MtMetersPerSecondToKnots( value ); sprintf(text + strlen(text), "%s %.2fKnts", item.m_name, value); } else { sprintf( text + strlen(text), "%s %.2f", item.m_name, value ); } } else if( item.m_type == HlDebugInteger ) { sprintf( text + strlen(text), "%s %d", item.m_name, *item.m_pInteger ); } else if(item.m_type == HlDebugBool ) { if( *item.m_pBool ) { sprintf(text + strlen(text), "%s True", item.m_name ); } else { sprintf(text + strlen(text), "%s False", item.m_name ); } } else if( item.m_type == HlDebugVector ) { sprintf(text + strlen(text), "%s %.2f %.2f %.2f", item.m_name, item.m_pVector->x, item.m_pVector->y, item.m_pVector->z ); } else if( item.m_type == HlDebugColour ) { sprintf(text + strlen(text), "%s %.2f %.2f %.2f", item.m_name, item.m_pColour->Red(), item.m_pColour->Green(), item.m_pColour->Blue() ); } else if( item.m_type == HlDebugFPS ) { sprintf( text + strlen(text), "FPS %.2f", RsUtil::GetFPS() ); } if( DebugIndex == i ) { sprintf( text + strlen(text), "*" ); } MtVector2 v2FontDimension = HlFont::GetDimension( text ); v2Dimension.x = MtMax( v2Dimension.x, v2Position.x + v2FontDimension.x + 15.0f ); v2Dimension.y = MtMax( v2Dimension.y, v2Position.y + v2FontDimension.y + 15.0f ); HlFont::Render(v2Position, text, textColour, MaxSortOrders - 1); v2Position.y += 15.0f; } } // Display the list of archives BtLinkedList<BaArchiveNode> archives = BaArchive::GetArchives(); BaArchiveNode *pCurrent = archives.pHead(); while( pCurrent ) { BtChar text[2048]; sprintf(text, pCurrent->m_pArchive->GetFilename()); MtVector2 v2FontDimension = HlFont::GetDimension(text); v2Dimension.x = MtMax(v2Dimension.x, v2Position.x + v2FontDimension.x + 30.0f); v2Dimension.y = MtMax(v2Dimension.y, v2Position.y + v2FontDimension.y + 30.0f); HlFont::Render(v2Position, text, RsColour(0.7f, 0.7f, 0.7f, 1.0f), MaxSortOrders - 1); v2Position.y += 15.0f; pCurrent = pCurrent->pNext(); } HlDraw::RenderQuad( MtVector2( 0, 0 ), v2Dimension, RsColour( 0.1f, 0.1f, 0.1f, 1.0f ), MaxSortOrders-1 ); }