Пример #1
0
////////////////////////
// Draw the column header
void CListviewColumn::Draw(SDL_Surface *bmpDest, int x, int y, int w, int h)
{
	CColumnStyle *style = getCurrentStyle();

	// Background
	style->cBackground.Draw(bmpDest, x, y, w, h);

	// Text
	SDL_Rect r = {x + style->cBorder.getLeftW(), y + style->cBorder.getTopW(),
		w - ((style->bmpSortArrow.get().get() && iSortDirection != sort_None) ? style->bmpSortArrow->w : 0) - 
		style->cBorder.getLeftW() - style->cBorder.getRightW(), 
		h -	style->cBorder.getTopW() - style->cBorder.getBottomW()};

	style->cText.tFontRect = &r;
	DrawGameText(bmpDest, sText, style->cFont, style->cText);

	// Sort arrow
	SDL_Rect r1(MakeRect(x + w - 3 - style->bmpSortArrow->w, y, w, h));
	SDL_Rect r2(MakeRect(0, 0, style->bmpSortArrow->w, style->bmpSortArrow->h));
	if (style->bmpSortArrow.get().get() && iSortDirection != sort_None)
		DrawImageAdv(bmpDest, style->bmpSortArrow.get(), r1, r2);

	// Border
	style->cBorder.Draw(bmpDest, x, y, w, h);
}
Пример #2
0
void SceneMain::Render() {
    glColor3f(1.0f, 1.0f, 1.0f);
    
    std::stringstream tmp;
    tmp << "Blue Food: " << theGame.blue_colony->food_store << " Pop: " << theGame.blue_colony->ants.size();
    DrawGameText(tmp.str(), "Console", 5, 24 + 5, 0);
    tmp.str("");
    tmp << "Red Food: " << theGame.red_colony->food_store << " Pop: " << theGame.red_colony->ants.size();
    DrawGameText(tmp.str(), "Console", 5, 24 + 24 + 5, 0);
    
    tmp.str("");
    tmp << "LVL: " << theGame.player->level;
    DrawGameText(tmp.str(), "Console", 5, theCamera.GetWindowHeight() - 5 - 24, 0);
    tmp.str("");
    tmp << "HP: " << theGame.player->health << "/" << theGame.player->health_max;
    tmp << " XP: " << theGame.player->experience << "/" << 100;
    DrawGameText(tmp.str(), "Console", 5, theCamera.GetWindowHeight() - 5, 0);
}
Пример #3
0
void AIBrain::Render()
{
	if( !_drawMe )
		return;

	if( _current != _brainStateTable.end() )
	{
		Vector2 screenCenter = MathUtil::WorldToScreen( GetActor()->GetPosition().X, GetActor()->GetPosition().Y );
		//Print some vals
		glColor3f(0,0.f,1.f);
		DrawGameText( (*_current).first, "ConsoleSmall", (int)screenCenter.X, (int)screenCenter.Y );
	}

}
Пример #4
0
void PathFinder::Render()
{
	CONSOLE_DECLAREVAR( ai_drawpath );
	if( ai_drawpath->GetIntVal() == 0 )
		return;
	if( _currentPath.size() > 0 )
	{
		Vector2 lastPt;

		glColor3f(0,0,1.f);
		for ( int i = 0; i < _currentPath.size(); i++ )
		{
			Vector2 curPt = _currentPath[i];
			if( lastPt != Vector2(0) )
			{
				DrawLine( curPt, lastPt );
			}
			lastPt = curPt;
		}

		if( _currentPathIndex >= 0 && _currentPathIndex < _currentPath.size() )
		{
			glColor3f(1,0,1.f);
			
			DrawLine( _currentPath[_currentPathIndex], _currentPos );
			DrawPoint( _currentPath[_currentPathIndex], 0.1f );
		}
		DrawPoint( _currentPath[_currentPath.size()-1], 0.1f );
	}

	String currentState = GetCurrentState()->GetName();

	Vector2 screenCenter = MathUtil::WorldToScreen( _currentPos.X, _currentPos.Y );
	//Print some vals
	glColor3f(0,1.f,1.f);
	DrawGameText( currentState + String(" ") + IntToString(_currentPathIndex), "ConsoleSmall", (int)screenCenter.X, (int)screenCenter.Y );

}
Пример #5
0
void DemoGameManager::Render()
{

	glColor3f(0.5f, 0.5f, 0.5f);
	char* infoString = "";
	int xOffset = 0;
	if (_current == 0)
	{
		infoString = "[A]: Next ";
		xOffset = 925;
	}
	else if (_current == _screens.size() - 1)
	{
		infoString = "[Back]: Previous";
		xOffset = 870;
	}
	else
	{
		infoString = "[A]: Next [Back]: Previous";
		xOffset = 785;
	}
	DrawGameText(infoString, "ConsoleSmall", xOffset, 763);
}
Пример #6
0
void SpatialGraphKDNode::Render()
{
	if( HasChildren() )
	{
		LHC->Render();
		RHC->Render();
		return;
	}

	if( theSpatialGraph.GetDrawBlocked() )
	{
		if( bBlocked )
		{
			glColor4f(1,0,0,0.25f);
			BBox.RenderBox();
		}
	}

	if( theSpatialGraph.GetDrawBounds() )
	{
		glColor4f(0,0,0,1.f);
		BBox.RenderOutline();
	}


	Vector2 centroid = BBox.Centroid();

	if( theSpatialGraph.GetDrawNodeIndex() )
	{
		Vector2 screenCenter = MathUtil::WorldToScreen( centroid.X, centroid.Y );
		//Print some vals
		glColor3f(0,1.f,1.f);
		DrawGameText( IntToString(Index), "ConsoleSmall", (unsigned int)screenCenter.X, (unsigned int)screenCenter.Y );
	}

	if( theSpatialGraph.GetDrawGraph() && !bBlocked )
	{
		glColor3f(1.f,0.f,0.f);
		
		float linePoints[4];
		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(2, GL_FLOAT, 0, linePoints);
		for( unsigned int i = 0; i < Neighbors.size(); i++ )
		{
			if( Neighbors[i]->bBlocked || !NeighborLOS[i] )
				continue;

			//draw centroid to centroid half way point
			Vector2 neighbor = Neighbors[i]->BBox.Centroid();
			neighbor = centroid + ((neighbor - centroid) * 0.6f);
			
			linePoints[0] = centroid.X;
			linePoints[1] = centroid.Y;
			linePoints[2] = neighbor.X;
			linePoints[3] = neighbor.Y;
			glDrawArrays(GL_LINES, 0, 2);
		}
	}

	if( theSpatialGraph.GetDrawGridPoints() )
	{
		glColor3f(1.f,0.f,0.f);
		Vector2List gridPoints;
		int xPoints, yPoints;
		GetGridPoints(gridPoints, xPoints, yPoints );

		for( unsigned int i = 0; i < gridPoints.size(); i++ )
		{
			DrawPoint( gridPoints[i], Tree->GetSmallestDimensions().X * 0.15f );
		}

	}
}
Пример #7
0
void Console::Render()
{
    if( !IsEnabled() )
        return;

    //TODO: Clean up this nonsense

    static float sTestAlpha = 0.75;
    Vec2i winDimensions;
    winDimensions.X = theCamera.GetWindowWidth();
    winDimensions.Y = theCamera.GetWindowHeight();

    static float fScreenHeightPct = 0.5f;
    static int sTextBoxBorder = winDimensions.Y/192;
    static int sTextBoxHeight = winDimensions.Y/32 + sTextBoxBorder;

    int consoleBGHeight = (int)(fScreenHeightPct * (float)winDimensions.Y);

    int consoleBGBottomY = consoleBGHeight;

    glColor4f(0.0f,0.0f,0.0f,sTestAlpha);
    DrawTile(0, consoleBGBottomY, winDimensions.X, consoleBGHeight );

    //Draw log
    static int sLogXPos = sTextBoxBorder;
    int logYPos = consoleBGBottomY - sTextBoxBorder;
    if (_buffer.size() > 0)
    {
        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        StringList::iterator it = _buffer.end();
        while (it != _buffer.begin())
        {
            it--;
            /* Vector2 textSize = */ DrawGameText( *it, "ConsoleSmall", sLogXPos, logYPos );
            logYPos -= (int)_lineHeight + sTextBoxBorder;
        }
    }

    //Draw text box border
    glColor4f(0.0f,1.0f,0.0f,sTestAlpha/2.0f);
    int textBoxBottomY = consoleBGBottomY + sTextBoxHeight;
    DrawTile(0, textBoxBottomY, winDimensions.X, sTextBoxHeight );

    //Draw text box

    int textBoxHeight = sTextBoxHeight - sTextBoxBorder;
    int textBoxWidth = winDimensions.X - sTextBoxBorder;
    int textBoxXPos = (winDimensions.X - textBoxWidth)/2;
    int textBoxYPos = textBoxBottomY - (sTextBoxHeight-textBoxHeight)/2;

    glColor4f(0.0f,0.0f,0.0f,sTestAlpha);
    DrawTile(textBoxXPos, textBoxYPos, textBoxWidth, textBoxHeight);

    textBoxXPos += sTextBoxBorder;
    textBoxYPos -= sTextBoxBorder + (sTextBoxBorder/2);

    glColor4f(0.0f,1.0f,0.0f,1.0f);
    String printInput = _prompt;
    printInput += _currentInput.substr(0, _cursorPos);

    if(_bCursorDisp)
    {
        printInput += "|";
    }
    else
    {
        printInput += " ";
    }

    if (_cursorPos < _currentInput.length())
    {
        printInput += _currentInput.substr(_cursorPos, _currentInput.length());
    }

    DrawGameText(printInput.c_str(), "ConsoleSmall", textBoxXPos, textBoxYPos);

    //Draw autocomplete
    static int sMaxAutoCompleteLines = MAX_AUTO_COMPLETE;
    int numAutoCompleteLines = MathUtil::Min(sMaxAutoCompleteLines, (int)_autoCompleteList.size() );
    int autoCompleteBottomY = textBoxBottomY + (numAutoCompleteLines * sTextBoxHeight);
    int autoCompleteStartY = textBoxBottomY + 2*sTextBoxHeight/3;

    int autoCompleteXPos = textBoxXPos + winDimensions.Y / 24;
    int autoCompleteBoxXPos = autoCompleteXPos - sTextBoxBorder;

    glColor4f(0.0f,0.0f,0.0f,sTestAlpha);
    DrawTile(autoCompleteBoxXPos, autoCompleteBottomY, winDimensions.X-autoCompleteBoxXPos, numAutoCompleteLines * sTextBoxHeight);

    glColor4f(0.0f,1.0f,0.0f,1.0f);
    Vector2 outPos((float)autoCompleteXPos, (float)autoCompleteStartY);
    for( int i = 0; i < numAutoCompleteLines; i++ )
    {
        if( (int)_autoCompleteList.size() > sMaxAutoCompleteLines-1 && i == sMaxAutoCompleteLines-1 )
            DrawGameText( "...", "ConsoleSmall", autoCompleteXPos, (int)outPos.Y );
        else
            DrawGameText( _autoCompleteList[i].c_str(), "ConsoleSmall", autoCompleteXPos, (int)outPos.Y );
        outPos.Y += sTextBoxHeight;
    }


}