bool CHudSideHintPanel::SetHintText( wchar_t *text ) { // clear the existing text for (int i = 0; i < m_Labels.Count(); i++) { m_Labels[i]->MarkForDeletion(); } m_Labels.RemoveAll(); wchar_t *p = text; while ( p ) { wchar_t *line = p; wchar_t *end = wcschr( p, L'\n' ); int linelengthbytes = 0; if ( end ) { //*end = 0; //eek p = end+1; linelengthbytes = ( end - line ) * 2; } else { p = NULL; } // replace any key references with bound keys wchar_t buf[512]; if (linelengthbytes) UTIL_ReplaceKeyBindings( line, linelengthbytes, buf, sizeof( buf ) ); else { if (!p) UTIL_ReplaceKeyBindings( line, linelengthbytes, buf, sizeof( buf ) ); else buf[0] = '\0'; } // put it in a label vgui::Label *label = vgui::SETUP_PANEL(new vgui::Label(this, NULL, buf)); label->SetFont( m_hFont ); label->SetPaintBackgroundEnabled( false ); label->SetPaintBorderEnabled( false ); label->SizeToContents(); label->SetContentAlignment( vgui::Label::a_west ); label->SetFgColor( GetFgColor() ); m_Labels.AddToTail( vgui::SETUP_PANEL(label) ); } InvalidateLayout( true ); return true; }
//----------------------------------------------------------------------------- // Purpose: Returns specified tip index for specified class //----------------------------------------------------------------------------- const wchar_t *CFRTips::GetTip(int iTip) { static wchar_t wzTip[512] = L""; // get the tip const wchar_t *wzFmt = g_pVGuiLocalize->Find( CFmtStr( "#FR_Tip_%d", iTip ) ); // replace any commands with their bound keys UTIL_ReplaceKeyBindings( wzFmt, 0, wzTip, sizeof( wzTip ) ); return wzTip; }