CUtlString CUtlString::Replace( char cFrom, char cTo ) { CUtlString ret = *this; int len = ret.Length(); for ( int i=0; i < len; i++ ) { if ( ret.m_Storage[i] == cFrom ) ret.m_Storage[i] = cTo; } return ret; }
//----------------------------------------------------------------------------- // Paints the overlay text //----------------------------------------------------------------------------- void CMiniViewportEngineRenderArea::PaintOverlayText( ) { if ( !m_OverlayText.Length() ) return; int cw, ch; GetSize( cw, ch ); int nTextWidth, nTextHeight; int nBufLen = m_OverlayText.Length()+1; wchar_t *pTemp = (wchar_t*)_alloca( nBufLen * sizeof(wchar_t) ); ::MultiByteToWideChar( CP_UTF8, 0, m_OverlayText.Get(), -1, pTemp, nBufLen ); g_pMatSystemSurface->GetTextSize( m_OverlayTextFont, pTemp, nTextWidth, nTextHeight ); int lx = (cw - nTextWidth) / 2; if ( lx < 10 ) { lx = 10; } int ly = ch - 10 - nTextHeight; g_pMatSystemSurface->DrawColoredTextRect( m_OverlayTextFont, lx, ly, cw - lx, ch - ly, 255, 255, 255, 255, m_OverlayText.Get() ); }
void CInstructor::DisplayLesson(const CUtlString& sLesson) { if (!lesson_enable.GetBool()) return; if (!m_bActive) return; if (sLesson.Length() == 0 || m_apLessons.Find(sLesson) == -1) { int iLesson = m_apLessons.Find(m_sCurrentLesson); if (m_apLessons[iLesson] && m_apLessons[iLesson]->m_bKillOnFinish) SetActive(false); HideLesson(); return; } HideLesson(); m_sCurrentLesson = sLesson; m_sLastLesson = m_sCurrentLesson; CLesson* pLesson = m_apLessons[m_apLessons.Find(sLesson)]; C_SDKPlayer *pLocalPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if (pLesson->m_iLearningMethod == CLesson::LEARN_DISPLAYING) pLocalPlayer->Instructor_LessonLearned(sLesson); pLocalPlayer->Instructor_LessonShowed(sLesson); int iLessonTrainings = pLocalPlayer->Instructor_GetLessonTrainings(sLesson); if (pLesson->m_sSideHintText.Length() && iLessonTrainings == 0) { CHudElement* pLessonPanel = gHUD.FindElement("CHudSideHintPanel"); static_cast<CHudSideHintPanel*>(pLessonPanel)->SetLesson(pLesson); m_bSideHintShowing = true; } else { CHudElement* pLessonPanel = gHUD.FindElement("CHudLessonPanel"); static_cast<CHudLessonPanel*>(pLessonPanel)->SetLesson(pLesson); } }
CUtlString CUtlString::Replace( char cFrom, char cTo ) const { if (!m_pString) { return CUtlString(); } CUtlString ret = *this; int len = ret.Length(); for ( int i=0; i < len; i++ ) { if ( ret.m_pString[i] == cFrom ) ret.m_pString[i] = cTo; } return ret; }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void CDmxEditApp::PrintHelp( bool bWiki /* = false */ ) { const CDmxEditLua::LuaFunc_s *pLuaFuncs = CDmxEditLua::GetFunctionList(); if ( bWiki && pLuaFuncs ) { lua_State *pLuaState = lua_open(); if ( pLuaState ) { luaL_openlibs( pLuaState ); CUtlString wikiString; for ( int i = 0; i < CDmxEditLua::FunctionCount(); ++i ) { if ( i != 0 ) { Msg( "\n" ); } Msg( ";%s( %s );\n", pLuaFuncs[ i ].m_pFuncName, pLuaFuncs[ i ].m_pFuncPrototype ); Msg( ":%s\n", Wikize( pLuaState, pLuaFuncs[ i ].m_pFuncDesc ) ); } return; } } Msg( "\n" ); Msg( "NAME\n" ); Msg( " dmxedit - Edit dmx files\n" ); Msg( "\n" ); Msg( "SYNOPSIS\n" ); Msg( " dmxedit [ -h | -help ] [ -game <$game> ] [ -set $var=val ] [ script.lua ]\n" ); Msg( "\n" ); Msg( " -h | -help : Prints this information\n" ); Msg( " -g | -game <$game> : Sets the VPROJECT environment variable to the specified game.\n" ); Msg( " -s | -set <$var=val> : Sets the lua variable var to the specified val before the script is run.\n" ); Msg( "\n" ); Msg( "DESCRIPTION\n" ); Msg( " Edits dmx files by executing a lua script of dmx editing functions\n" ); Msg( "\n" ); if ( !pLuaFuncs ) return; Msg( "FUNCTIONS\n" ); const char *pWhitespace = " \t"; for ( int i = 0; i < CDmxEditLua::FunctionCount(); ++i ) { Msg( " %s( %s );\n", pLuaFuncs[ i ].m_pFuncName, pLuaFuncs[ i ].m_pFuncPrototype ); Msg( " * " ); CUtlString tmpStr; const char *pWordBegin = pLuaFuncs[ i ].m_pFuncDesc + strspn( pLuaFuncs[ i ].m_pFuncDesc, pWhitespace ); const char *pWhiteSpaceBegin = pWordBegin; const char *pWordEnd = pWordBegin + strcspn( pWordBegin, pWhitespace ); bool bNewline = false; while ( *pWordBegin ) { if ( pWordEnd - pWhiteSpaceBegin + tmpStr.Length() > 70 ) { if ( bNewline ) { Msg( " " ); } else { bNewline = true; } Msg( "%s\n", tmpStr ); tmpStr.Set( "" ); } if ( tmpStr.Length() ) { tmpStr += CUtlString( pWhiteSpaceBegin, pWordEnd - pWhiteSpaceBegin + 1); } else { tmpStr += CUtlString( pWordBegin, pWordEnd - pWordBegin + 1 ); } pWhiteSpaceBegin = pWordEnd; pWordBegin = pWhiteSpaceBegin + strspn( pWhiteSpaceBegin, pWhitespace ); pWordEnd = pWordBegin + strcspn( pWordBegin, pWhitespace ); } if ( tmpStr.Length() ) { if ( bNewline ) { Msg( " " ); } Msg( "%s\n", tmpStr ); } Msg( "\n" ); } Msg( "CREDITS\n" ); Msg( " Lua Copyright © 1994-2006 Lua.org, PUC-Rio.\n "); Msg( "\n" ); }