コード例 #1
0
ファイル: statusbar.cpp プロジェクト: Arkshine/NS
void CHudStatusBar::ReparseStringIfNeeded()
{
	if ( m_bReparseString )
	{
		for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
		{
			m_pflNameColors[i] = g_ColorYellow;
			ParseStatusString( i );
		}
		m_bReparseString = FALSE;
	}
	
}
コード例 #2
0
ファイル: statusbar.cpp プロジェクト: AlexCSilva/cs16-client
int CHudStatusBar :: Draw( float fTime )
{
	if ( m_bReparseString )
	{
		for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
		{
			m_pflNameColors[i] = g_ColorYellow;
			ParseStatusString( i );
		}
		m_bReparseString = FALSE;
	}

	if( g_iUser1 > 0 )
	{
		// this is a spectator, so don't draw any statusbars
		return 1;
	}

	int Y_START = ScreenHeight - YRES(32 + 4);

	// Draw the status bar lines
	for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
	{
		int TextHeight, TextWidth;
		DrawUtils::ConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );

		int x = 4;
		int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen

		// let user set status ID bar centering
		if ( i == STATUSBAR_ID_LINE &&
			 hud_centerid->value != 0.0f )
		{
			x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 );
			y = (ScreenHeight / 2) + (TextHeight * hud_centerid->value );
		}

		if ( m_pflNameColors[i] )
			DrawUtils::SetConsoleTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
		DrawUtils::DrawConsoleString( x, y, m_szStatusBar[i] );
	}

	return 1;
}
コード例 #3
0
ファイル: statusbar.cpp プロジェクト: FWGS/XashXT
int CHudStatusBar :: Draw( float fTime )
{
	if( m_bReparseString )
	{
		for( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
		{
			m_pflNameColors[i] = g_ColorYellow;
			ParseStatusString( i );
		}
		m_bReparseString = FALSE;
	}

	int Y_START = ScreenHeight - YRES( 32 + 4 );

	// Draw the status bar lines
	for( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
	{
		int TextHeight, TextWidth;
		GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );

		int x = 4;
		int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen

		// let user set status ID bar centering
		if(( i == STATUSBAR_ID_LINE ) && CVAR_GET_FLOAT( "hud_centerid" ))
		{
			x = max( 0, max( 2, (ScreenWidth - TextWidth)) / 2 );
			y = (ScreenHeight / 2) + (TextHeight * CVAR_GET_FLOAT( "hud_centerid" ));
		}

		if( m_pflNameColors[i] )
			DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );

		DrawConsoleString( x, y, m_szStatusBar[i] );
	}

	return 1;
}
コード例 #4
0
ファイル: statusbar.cpp プロジェクト: Sh1ft0x0EF/HLSDKRevamp
int CHudStatusBar::Draw(float fTime)
{
	int r, g, b, a, name_r, name_g, name_b;

	if(m_bReparseString)
	{
		for(int i = 0; i < MAX_STATUSBAR_LINES; i++)
			ParseStatusString(i);
		m_bReparseString = FALSE;
	}

	//Not Watching anyone
	if(m_iStatusValues[1] == 0)
	{
		m_iFlags &= ~HUD_ACTIVE;
		return 1;
	}

	// Draw the status bar lines
	for(int i = 0; i < MAX_STATUSBAR_LINES; i++)
	{
		int TextHeight     = 0;
		int TotalTextWidth = 0;

		//Ugly way to get
		if(m_iTeamMate[i])
		{
			TotalTextWidth += gHUD.ReturnStringPixelLength(m_szName[i]);
			TotalTextWidth += gHUD.ReturnStringPixelLength(m_szHealth[i]);
			TotalTextWidth += gHUD.ReturnStringPixelLength(m_szArmor[i]);
			TotalTextWidth += 48;
			TextHeight = gHUD.m_scrinfo.iCharHeight;
		}
		else
			TotalTextWidth += gHUD.ReturnStringPixelLength(m_szName[i]);

		TextHeight = gHUD.m_scrinfo.iCharHeight;

		if(g_iNameColors == 1)
		{
			name_r = 255;
			name_g = 50;
			name_b = 50;
		}
		else if(g_iNameColors == 2)
		{
			name_r = 50;
			name_g = 50;
			name_b = 255;
		}
		else
			name_r = name_g = name_b = 255;

		int Y_START;
		if(ScreenHeight >= 480)
			Y_START = ScreenHeight - 55;
		else
			Y_START = ScreenHeight - 45;

		int x = gHUD.m_Ammo.m_iNumberXPosition;
		int y = Y_START; // = ( ScreenHeight / 2 ) + ( TextHeight * 3 );

		int x_offset;
		a = 200;

		UnpackRGB(r, g, b, RGB_NORMAL);
		ScaleColors(r, g, b, a);
		ScaleColors(name_r, name_g, name_b, 125);

		//Draw the name First
		gHUD.DrawHudString(x, y, 1024, m_szName[i], name_r, name_g, name_b);

		if(!m_iTeamMate[i])
			continue;

		//Get the length in pixels for the name
		x_offset = gHUD.ReturnStringPixelLength(m_szName[i]);

		//Add the offset
		x += (x_offset + 8);

		//Now draw the Sprite for the health
		SPR_Set(m_hHealth, r, g, b);
		SPR_DrawHoles(0, x, y, &gHUD.GetSpriteRect(m_iHealthSpriteIndex));

		//Add the sprite width size
		x += 16;

		//Draw the health value ( x + offset for the name lenght + width of the sprite )
		gHUD.DrawHudString(x, y, 1024, m_szHealth[i], name_r, name_g, name_b);

		//Get the length in pixels for the health
		x_offset = gHUD.ReturnStringPixelLength(m_szHealth[i]);

		//Add the offset
		x += (x_offset + 8);

		//Now draw the Sprite for the Armor
		SPR_Set(m_hArmor, r, g, b);
		SPR_DrawHoles(0, x, y, &gHUD.GetSpriteRect(m_iArmorSpriteIndex));

		x += 16;

		//Draw the armor value ( x + offset for the name lenght + width of the sprite )
		gHUD.DrawHudString(x, y, 1024, m_szArmor[i], name_r, name_g, name_b);
	}

	return 1;
}
コード例 #5
0
ファイル: HttpRequest.cpp プロジェクト: dblock/baseclasses
bool CHttpRequest::GetHTTP(float HTTPVersion) {   
    
    /* HTTP request */
    CString Request;
    MakeRequestString(HTTPVersion, &Request);

    Trace(tagHttp, levInfo, ("CHttpRequest - Request {\n%s}", Request.GetBuffer()));
    
    if (m_Dump) {
        cout << "-=-=-=-=-=-=-=-=- Request -=-=-=-=-=-=-=-=-" << endl 
             << Request
             << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" << endl;
    }
    
    if (!m_ClientSocket.Write(Request))
        return false;
    
    /* HTTP response, header */
    m_ClientSocket.ReadLine(&m_RStatusString);

    Trace(tagHttp, levInfo, ("CHttpRequest - StatusString {%s}", m_RStatusString.GetBuffer()));

    if (! ParseStatusString()) {
        m_RData = m_RStatusString;
    }

    if (m_RStatusValue > 0) {
        // finish reading headers
        CString OneLine;
        m_ClientSocket.ReadLine(&OneLine);

        if (m_Dump) {
            cout << "-=-=-=-=-=-=-=-=- Response -=-=-=-=-=-=-=-" << endl 
                 << m_RStatusString
                 << endl;
        }
        
        Trace(tagHttp, levInfo, ("CHttpRequest - Response (start)    : %s", m_RStatusString.GetBuffer()));
        
        while (OneLine.GetLength()) {
    
            if (m_Dump) {
                cout << OneLine << endl;
            }
            
            CStringTable Table;
            CString Name, Value;            
            if (CMimeParser::ParseLine(OneLine, Name, Value, Table)) {
                Trace(tagHttp, levInfo, ("CHttpRequest - Response (continued): %d | %s <table> (%d)", OneLine.GetLength(), Name.GetBuffer(), Table.GetSize()));
                Trace(tagHttp, levInfo, ("CHttpRequest -                       %s", OneLine.GetBuffer()));
                m_RFields.Add(Name, Table);
                m_RPairFields.Add(CStringPair(Name, Value));
            } else {
                Trace(tagHttp, levInfo, ("CHttpRequest - Response (continued): %s (parser failed, ignoring)", OneLine.GetBuffer()));
                // ignore malformed lines
                // $(TODO): support P3P, which looks like P3P CP= ...
                // m_RStatusValue = 400
                // return false;                
            }
            m_ClientSocket.ReadLine(&OneLine);
        }
    
        if (m_Dump) {
            cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" << endl;
        }
        
        Trace(tagHttp, levInfo, ("CHttpRequest - Response (done)"));
    }
    
    if ((m_RequestMethod != htGet)&&(m_RequestMethod != htPost)) 
        return true;

    CString ContentLengthString = m_RFields.FindElement(g_strHttpContentLength).GetValue(g_strHttpContentLength);
    
    int ContentLengthExpected = 0;
    
    if (! ContentLengthString.IsInt(& ContentLengthExpected))
        ContentLengthExpected = -1;
    
    Trace(tagHttp, levInfo, ("CHttpRequest::GetHTTP() - expected content-length: %s {%d}", ContentLengthString.GetBuffer(), ContentLengthExpected));        

    m_RData.Empty();
    
    // document is going to be larger than the current maximum document size limit
    if ((ContentLengthExpected > 0) && (m_RequestSizeLimit > 0) && (m_RequestSizeLimit < ContentLengthExpected)) {
        
        m_RStatusValue = 206; // partial content        
        
    } else {
        
        if (ContentLengthExpected > 0) {
    
            m_ClientSocket.Read(& m_RData, ContentLengthExpected);
            
            if (ContentLengthExpected != (int) m_RData.GetLength()) {
	      Trace(tagHttp, levInfo, ("CHttpRequest::GetHTTP() - expected %d bytes, read %d. (207 Partial Content)", ContentLengthExpected, m_RData.GetLength()));        
	      m_RStatusValue = 207; // partial Content-Length
	      return false;
            }
            
        } else if ((ContentLengthExpected < 0) && (m_RStatusValue == 200)) {
            // content-length was not explicitly zero and the status value says that data should be available
            m_ClientSocket.Read(& m_RData, m_RequestSizeLimit);        
        }
        
        if (m_RStatusValue <= 0) {
            m_RStatusValue = (m_RData.GetLength() > 0) ? 200 : 204;
            
            if (!m_RData.GetLength())
                return false;
        }
    }
    
    Trace(tagHttp, levInfo, ("CHttpRequest::GetHTTP() - m_RStatusValue {%d}", m_RStatusValue));        
    Trace(tagHttp, levInfo, ("CHttpRequest::GetHTTP() - m_RData.Length {%d}", m_RData.GetLength()));        
    
    return true;
}