コード例 #1
0
void GameTacMap::drawBlip(const Stuff::Vector3D& pos, int32_t color, int32_t type)
{
	if (color == 0)
		return;
	gos_VERTEX triangle[4];
	gos_SetRenderState(gos_State_AlphaTest, 1);
	gos_SetRenderState(gos_State_Specular, 0);
	gos_SetRenderState(gos_State_Dither, 1);
	gos_SetRenderState(gos_State_Filter, gos_FilterBiLinear);
	gos_SetRenderState(gos_State_ZCompare, 0);
	gos_SetRenderState(gos_State_ZWrite, 0);
	uint32_t gosID = mcTextureManager->get_gosTextureHandle(blipHandle);
	gos_SetRenderState(gos_State_Texture, gosID);
	for (size_t i = 0; i < 4; ++i)
	{
		triangle[i].z	= 0;
		triangle[i].rhw  = .5;
		triangle[i].argb = color;
		triangle[i].frgb = 0;
		triangle[i].u	= 0.f;
		triangle[i].v	= 0.f;
	}
	worldToTacMap((Stuff::Vector3D&)pos, triangle[0]);
	triangle[0].x -= 2.f;
	triangle[1].x = triangle[0].x;
	triangle[2].x = triangle[3].x = triangle[0].x + 4.1f;
	triangle[0].y -= 2.f;
	triangle[3].y = triangle[0].y;
	triangle[1].y = triangle[2].y = triangle[0].y + 4.1f;
	triangle[2].u = triangle[3].u = .250001f;
	triangle[1].v = triangle[2].v = .250001f;
	gos_DrawQuads(triangle, 4);
}
コード例 #2
0
void drawRect( const GUI_RECT& area, unsigned long color )
{
	if ( color & 0xff000000 )
	{
		GUI_RECT clientArea = area;

		if ( clientArea.left < 0 )
			clientArea.left = 0;

		if ( clientArea.right < 0 )
			clientArea.right = 0;

		if ( clientArea.top < 0 )
			clientArea.top = 0;

		if ( clientArea.bottom < 0 )
			clientArea.bottom = 0;

		if ( clientArea.left >= Environment.screenWidth )
			clientArea.left = Environment.screenWidth;

		if ( clientArea.right >= Environment.screenWidth )
			clientArea.right = Environment.screenWidth;

		if ( clientArea.top >= Environment.screenHeight )
			clientArea.top = Environment.screenHeight;

		if ( clientArea.bottom >= Environment.screenHeight )
			clientArea.bottom = Environment.screenHeight;
		
		
		gos_VERTEX v[4];

		memset( v,0,sizeof(v) );
		v[0].rhw =  v[1].rhw = v[2].rhw = v[3].rhw = 1.0;

		v[0].argb =  v[1].argb = v[2].argb = v[3].argb = color;

		v[0].x = (float)clientArea.left;
		v[0].y = (float)clientArea.top;

		v[1].x = (float)clientArea.left;
		v[1].y = (float)clientArea.bottom;

		v[2].x = (float)clientArea.right;
		v[2].y = (float)clientArea.bottom;

		v[3].x = (float)clientArea.right;
		v[3].y = (float)clientArea.top;

		gos_SetRenderState( gos_State_Texture, 0 );
		gos_SetRenderState( gos_State_ZWrite, 0 );
		gos_SetRenderState( gos_State_ZCompare, 0 );
		gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
		gos_DrawQuads( v, 4 );
	}
}
コード例 #3
0
void StaticInfo::render()
{
	unsigned long gosID = mcTextureManager->get_gosTextureHandle( textureHandle );	
	gos_SetRenderState( gos_State_Texture, gosID );
	gos_SetRenderState(gos_State_Filter, gos_FilterNone);
	gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha );
	gos_SetRenderState( gos_State_Clipping, 1);
	gos_DrawQuads( location, 4 );
	
}
コード例 #4
0
void aButton::render()
{
	if ( state != HIDDEN )
	{
		if ( textureHandle )
		{
			unsigned long gosID = mcTextureManager->get_gosTextureHandle( textureHandle );
			gos_SetRenderState( gos_State_Texture, gosID ); 
		}
		else
			gos_SetRenderState( gos_State_Texture, 0 ); 

			gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
			gos_SetRenderState( gos_State_Filter, gos_FilterNone);
			gos_SetRenderState( gos_State_AlphaTest, true);
			gos_SetRenderState( gos_State_TextureAddress, gos_TextureClamp );
			gos_SetRenderState( gos_State_TextureMapBlend,gos_BlendModulateAlpha );

			gos_DrawQuads( location, 4 );


		if ( data.textID && data.textFont )
		{
			char buffer[256];
			cLoadString( data.textID, buffer, 256 );
			DWORD width, height;
			gos_TextSetAttributes(data.textFont, data.textColors[state], data.textSize, true, true, false, false, data.textAlign);			
			gos_TextSetRegion( data.textRect.left, data.textRect.top, data.textRect.right, data.textRect.bottom );
			gos_TextStringLength( &width, &height, buffer );
			gos_TextSetPosition( data.textRect.left, (data.textRect.top + data.textRect.bottom)/2 - height/2 + 1 );
			gos_TextDraw( buffer );

			if ( data.outlineText )
			{
				drawEmptyRect( data.textRect, data.textColors[state], data.textColors[state] );
			}
		}
		if ( data.outline )
		{
			GUI_RECT tmp;
			tmp.left = location[0].x;
			tmp.top = location[0].y;
			tmp.right = location[2].x;
			tmp.bottom = location[2].y;

			drawEmptyRect( tmp, location[0].argb, location[0].argb );
		}

		for ( int i = 0; i < numberOfChildren(); i++ )
		{
			pChildren[i]->render();
		}
	}
}
コード例 #5
0
void aObject::render()
{
	if (showWindow)
	{
		uint32_t gosID = mcTextureManager->get_gosTextureHandle(textureHandle);
		gos_SetRenderState(gos_State_Texture, gosID);
		gos_SetRenderState(gos_State_Filter, gos_FilterNone);
		gos_SetRenderState(gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
		gos_SetRenderState(gos_State_ZCompare, 0);
		gos_SetRenderState(gos_State_ZWrite, 0);
		gos_DrawQuads(location, 4);
		for (size_t i = 0; i < nNumberOfChildren; i++)
		{
			pChildren[i]->render();
		}
	}
}
コード例 #6
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	SortData::DrawQuads()
{
	Start_Timer(GOS_Draw_Time);

#ifdef LAB_ONLY
	if(dontSeeMe == true)
#endif
	{
		if(texture2==0)
		{
//			gos_DrawTriangles( (GOSVertex *)vertices, numVertices);
			gos_DrawQuads( (GOSVertex *)vertices, numVertices);
		}
		else
		{
			STOP(("GOS doesnt suppert gos_DrawQuads for gos_VERTEX_2UV yet."));
//			gos_DrawQuads( (GOSVertex2UV *)vertices, numVertices);
		}

	}
	Stop_Timer(GOS_Draw_Time);
}
コード例 #7
0
void aListBox::render()
{
	if ( showWindow )
	{
		bool bTop  =0;
		bool bBottom = 0;

		gos_SetRenderState( gos_State_Texture, 0 );
		gos_SetRenderState(gos_State_Filter, gos_FilterNone);
		gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha );
		gos_SetRenderState( gos_State_ZCompare, 0 );
		gos_SetRenderState( gos_State_ZWrite, 0 );

		gos_DrawQuads( location, 4 );

		long topHeight = 0;
		long bottomHeight = 0;


		bool bItemOutOfRange = 0;
		for ( int i = 0; i < itemCount; i++ )
		{
			if ( items[i]->globalBottom() > globalTop()
				&& items[i]->globalTop() < globalBottom() )
			{
				items[i]->render();

				if ( items[i]->globalTop() < globalTop() )
				{
					topHeight = items[i]->height();
					bTop = 1;
					bItemOutOfRange = true;
				}
				if ( items[i]->globalBottom() >= globalBottom() )
				{
					bBottom = 1;
					if ( !bottomHeight )
						bottomHeight = items[i]->height();

					bItemOutOfRange = true;
				}
			}
			else 
			{
				bItemOutOfRange = true;
			}
		}

		// draw black box above this
		if ( bTop || bBottom )
		{
			GUI_RECT rect = { globalX(), globalY() - topHeight, globalX() + width(), globalY() };
			if ( bTop )
				drawRect( rect, 0xff000000 ); 
			rect.top = globalY() + height()+1;
			rect.bottom =globalY() + height() + bottomHeight+2;
			if ( bBottom )
				drawRect( rect, 0xff000000 );
		}
		if ( scrollBar )
		{
			if ( bItemOutOfRange )
			{
				scrollBar->Enable( 1 );
			}

			else 
				scrollBar->Enable( 0 );

			scrollBar->render();
		}

			
	}
}
コード例 #8
0
//---------------------------------------------------------------------------
void GameCamera::render(void)
{
	//------------------------------------------------------
	// At present, these actually draw.  Later they will
	// add elements to the draw list and sort and draw.
	// The later time has arrived.  We begin sorting immediately.
	// NO LONGER NEED TO SORT!
	// ZBuffer time has arrived.  Share and Enjoy!
	// Everything SIMPLY draws at the execution point into the zBuffer
	// at the correct depth.  Miracles occur at that point!
	// Big code change but it removes a WHOLE bunch of code and memory!
	//--------------------------------------------------------
	// Get new viewport values to scale stuff.  No longer uses
	// VFX stuff for this.  ALL GOS NOW!
	gos_GetViewport(&viewMulX, &viewMulY, &viewAddX, &viewAddY);
	MidLevelRenderer::MLRState default_state;
	default_state.SetBackFaceOn();
	default_state.SetDitherOn();
	default_state.SetTextureCorrectionOn();
	default_state.SetZBufferCompareOn();
	default_state.SetZBufferWriteOn();
	default_state.SetFilterMode(MidLevelRenderer::MLRState::BiLinearFilterMode);
	float z = 1.0f;
	Stuff::RGBAColor fColor;
	fColor.red   = ((fogColor >> 16) & 0xff);
	fColor.green = ((fogColor >> 8) & 0xff);
	fColor.blue  = ((fogColor)&0xff);
	//--------------------------------------------------------
	// Get new viewport values to scale stuff.  No longer uses
	// VFX stuff for this.  ALL GOS NOW!
	screenResolution.x = viewMulX;
	screenResolution.y = viewMulY;
	calculateProjectionConstants();
	TG_Shape::SetViewport(viewMulX, viewMulY, viewAddX, viewAddY);
	userInput->setViewport(viewMulX, viewMulY, viewAddX, viewAddY);
	gos_TextSetRegion(viewAddX, viewAddY, viewMulX, viewMulY);
	//--------------------------------------------------------
	// Get new viewport values to scale stuff.  No longer uses
	// VFX stuff for this.  ALL GOS NOW!
	screenResolution.x = viewMulX;
	screenResolution.y = viewMulY;
	calculateProjectionConstants();
	globalScaleFactor = getScaleFactor();
	globalScaleFactor *= viewMulX / 640.0; // Scale Mechs to ScreenRES
	//-----------------------------------------------
	// Set Ambient for this pass of rendering
	uint32_t lightRGB = (ambientRed << 16) + (ambientGreen << 8) + ambientBlue;
	eye->setLightColor(1, lightRGB);
	eye->setLightIntensity(1, 1.0);
	MidLevelRenderer::PerspectiveMode = usePerspective;
	theClipper->StartDraw(cameraOrigin, cameraToClip, fColor, &fColor, default_state, &z);
	MidLevelRenderer::GOSVertex::farClipReciprocal =
		(1.0f - cameraToClip(2, 2)) / cameraToClip(3, 2);
	if (active && turn > 1)
	{
		//----------------------------------------------------------
		// Turn stuff on line by line until perspective is working.
		if (Environment.Renderer != 3)
			theSky->render(1);
		land->render(); // render the Terrain
		if (Environment.Renderer != 3)
			craterManager->render();			 // render the craters and footprints
		ObjectManager->render(true, true, true); // render all other objects
		land->renderWater();					 // Draw Water Last!
		if (useShadows && Environment.Renderer != 3)
			ObjectManager->renderShadows(true, true, true);
		if (mission && mission->missionInterface)
			mission->missionInterface->drawVTOL();
		if (!drawOldWay && !inMovieMode)
		{
			if (compass && (turn > 3) && drawCompass)
				compass->render(-1); // Force this to zBuffer in front of everything
		}
		if (!drawOldWay)
			mcTextureManager->renderLists(); // This sends triangles down to the
											 // card.  All "rendering" to this
											 // point has been setting up tri
											 // lists
		if (drawOldWay)
		{
			// Last thing drawn were shadows which are not Gouraud Shaded!!!
			// MLR to be "efficient" doesn't set this state by default at
			// startup!
			gos_SetRenderState(gos_State_ShadeMode, gos_ShadeGouraud);
		}
		theClipper->RenderNow(); // Draw the FX
		if (useNonWeaponEffects)
			weather->render(); // Draw the weather
	}
	if (drawOldWay && !inMovieMode)
	{
		gos_SetRenderState(gos_State_ZCompare, 0);
		gos_SetRenderState(gos_State_ZWrite, 0);
		gos_SetRenderState(gos_State_Perspective, 1);
		if (compass && (turn > 3) && drawCompass)
			compass->render();
	}
	//---------------------------------------------------------
	// Check if we are inMovieMode and should be letterboxed.
	// draw letterboxes here.
	if (inMovieMode && (letterBoxPos != 0.0f))
	{
		// Figure out the two faces we need to draw based on letterBox Pos and
		// Alpha
		float barTopX = screenResolution.y * letterBoxPos;
		float barBotX = screenResolution.y - barTopX;
		gos_SetRenderState(gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
		gos_SetRenderState(gos_State_ShadeMode, gos_ShadeGouraud);
		gos_SetRenderState(gos_State_MonoEnable, 0);
		gos_SetRenderState(gos_State_Perspective, 0);
		gos_SetRenderState(gos_State_Clipping, 1);
		gos_SetRenderState(gos_State_AlphaTest, 1);
		gos_SetRenderState(gos_State_Specular, 0);
		gos_SetRenderState(gos_State_Dither, 1);
		gos_SetRenderState(gos_State_TextureMapBlend, gos_BlendModulate);
		gos_SetRenderState(gos_State_Filter, gos_FilterNone);
		gos_SetRenderState(gos_State_TextureAddress, gos_TextureClamp);
		gos_SetRenderState(gos_State_ZCompare, 0);
		gos_SetRenderState(gos_State_ZWrite, 0);
		gos_SetRenderState(gos_State_Texture, 0);
		//------------------------------------
		gos_VERTEX gVertex[4];
		gVertex[0].x	= 0.0f;
		gVertex[0].y	= 0.0f;
		gVertex[0].z	= 0.00001f;
		gVertex[0].rhw  = 0.00001f;
		gVertex[0].u	= 0.0f;
		gVertex[0].v	= 0.0f;
		gVertex[0].argb = (letterBoxAlpha << 24);
		gVertex[0].frgb = 0xff000000;
		gVertex[1].x	= 0.0f;
		gVertex[1].y	= barTopX;
		gVertex[1].z	= 0.00001f;
		gVertex[1].rhw  = 0.00001f;
		gVertex[1].u	= 0.0f;
		gVertex[1].v	= 0.0f;
		gVertex[1].argb = (letterBoxAlpha << 24);
		gVertex[1].frgb = 0xff000000;
		gVertex[2].x	= screenResolution.x;
		gVertex[2].y	= barTopX;
		gVertex[2].z	= 0.00001f;
		gVertex[2].rhw  = 0.00001f;
		gVertex[2].u	= 0.0f;
		gVertex[2].v	= 0.0f;
		gVertex[2].argb = (letterBoxAlpha << 24);
		gVertex[2].frgb = 0xff000000;
		gVertex[3].x	= screenResolution.x;
		gVertex[3].y	= 0.0f;
		gVertex[3].z	= 0.00001f;
		gVertex[3].rhw  = 0.00001f;
		gVertex[3].u	= 0.0f;
		gVertex[3].v	= 0.0f;
		gVertex[3].argb = (letterBoxAlpha << 24);
		gVertex[3].frgb = 0xff000000;
		gos_DrawQuads(gVertex, 4);
		gVertex[0].x	= 0.0f;
		gVertex[0].y	= barBotX;
		gVertex[0].z	= 0.00001f;
		gVertex[0].rhw  = 0.00001f;
		gVertex[0].u	= 0.0f;
		gVertex[0].v	= 0.0f;
		gVertex[0].argb = (letterBoxAlpha << 24);
		gVertex[0].frgb = 0xff000000;
		gVertex[1].x	= screenResolution.x;
		gVertex[1].y	= barBotX;
		gVertex[1].z	= 0.00001f;
		gVertex[1].rhw  = 0.00001f;
		gVertex[1].u	= 0.0f;
		gVertex[1].v	= 0.0f;
		gVertex[1].argb = (letterBoxAlpha << 24);
		gVertex[1].frgb = 0xff000000;
		gVertex[2].x	= screenResolution.x;
		gVertex[2].y	= screenResolution.y;
		gVertex[2].z	= 0.00001f;
		gVertex[2].rhw  = 0.00001f;
		gVertex[2].u	= 0.0f;
		gVertex[2].v	= 0.0f;
		gVertex[2].argb = (letterBoxAlpha << 24);
		gVertex[2].frgb = 0xff000000;
		gVertex[3].x	= 0.0f;
		gVertex[3].y	= screenResolution.y;
		gVertex[3].z	= 0.00001f;
		gVertex[3].rhw  = 0.00001f;
		gVertex[3].u	= 0.0f;
		gVertex[3].v	= 0.0f;
		gVertex[3].argb = (letterBoxAlpha << 24);
		gVertex[3].frgb = 0xff000000;
		gos_DrawQuads(gVertex, 4);
	}
	if (inMovieMode && (fadeAlpha != 0x0))
	{
		// We are fading to something other then clear screen.
		gos_SetRenderState(gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
		gos_SetRenderState(gos_State_ShadeMode, gos_ShadeGouraud);
		gos_SetRenderState(gos_State_MonoEnable, 0);
		gos_SetRenderState(gos_State_Perspective, 0);
		gos_SetRenderState(gos_State_Clipping, 1);
		gos_SetRenderState(gos_State_AlphaTest, 1);
		gos_SetRenderState(gos_State_Specular, 0);
		gos_SetRenderState(gos_State_Dither, 1);
		gos_SetRenderState(gos_State_TextureMapBlend, gos_BlendModulate);
		gos_SetRenderState(gos_State_Filter, gos_FilterNone);
		gos_SetRenderState(gos_State_TextureAddress, gos_TextureClamp);
		gos_SetRenderState(gos_State_ZCompare, 0);
		gos_SetRenderState(gos_State_ZWrite, 0);
		gos_SetRenderState(gos_State_Texture, 0);
		//------------------------------------
		gos_VERTEX gVertex[4];
		gVertex[0].x	= 0.0f;
		gVertex[0].y	= 0.0f;
		gVertex[0].z	= 0.00001f;
		gVertex[0].rhw  = 0.00001f;
		gVertex[0].u	= 0.0f;
		gVertex[0].v	= 0.0f;
		gVertex[0].argb = (fadeAlpha << 24) + (fadeColor & 0x00ffffff);
		gVertex[0].frgb = 0xff000000;
		gVertex[1].x	= 0.0f;
		gVertex[1].y	= screenResolution.y;
		gVertex[1].z	= 0.00001f;
		gVertex[1].rhw  = 0.00001f;
		gVertex[1].u	= 0.0f;
		gVertex[1].v	= 0.0f;
		gVertex[1].argb = (fadeAlpha << 24) + (fadeColor & 0x00ffffff);
		gVertex[1].frgb = 0xff000000;
		gVertex[2].x	= screenResolution.x;
		gVertex[2].y	= screenResolution.y;
		gVertex[2].z	= 0.00001f;
		gVertex[2].rhw  = 0.00001f;
		gVertex[2].u	= 0.0f;
		gVertex[2].v	= 0.0f;
		gVertex[2].argb = (fadeAlpha << 24) + (fadeColor & 0x00ffffff);
		gVertex[2].frgb = 0xff000000;
		gVertex[3].x	= screenResolution.x;
		gVertex[3].y	= 0.0f;
		gVertex[3].z	= 0.00001f;
		gVertex[3].rhw  = 0.00001f;
		gVertex[3].u	= 0.0f;
		gVertex[3].v	= 0.0f;
		gVertex[3].argb = (fadeAlpha << 24) + (fadeColor & 0x00ffffff);
		gVertex[3].frgb = 0xff000000;
		gos_DrawQuads(gVertex, 4);
	}
	//-----------------------------------------------------
}
コード例 #9
0
void InfoWindow::drawScrollingStuff()
{
	if ( !pUnit )
		return;

	float offset = 0.f;
	if ( infoLength )
	{
		float increment = infoLength/(SCROLLMAX - SCROLLMIN );
		offset = -increment * scrollPos;
	}

	float curY = SCROLLBOXTOP + SECTIONSKIP  + offset;

	if ( icon )
	{
		if ( SCROLLTOP + offset > NAMETOP ) // draw icons if visible
		{
			icon->renderUnitIcon( MECHLEFT, curY, MECHRIGHT, curY + MECHHEIGHT);
			icon->renderUnitIconBack( MECHBACKLEFT, curY, MECHBACKRIGHT, curY + MECHHEIGHT );
		}

		curY += MECHHEIGHT + SECTIONSKIP;

		if( curY > NAMEBOTTOM ) // draw divider if visible
			drawDivider( curY );

	}

	long textColors[4] = { 0xff6E7C00, 0xff005392, 0xffA21600 };
	

	char disabledCount[60][2];
	long ammo[60];
	char ranges[60];
	long names[60];
	memset( disabledCount, 0, sizeof( char ) * 60 * 2);
	memset( names, 0, sizeof( char* ) * 60 );
	memset( ranges, 0, sizeof( char ) * 60 );
	memset( ammo, 0, sizeof( long ) * 60 );

	bool bDraw[4];
	memset( bDraw, 0, sizeof( bool ) * 4 );
	
	int curComponentCount = 60;

	int i = 0;

	for (long curWeapon = pUnit->numOther; curWeapon < (pUnit->numOther + pUnit->numWeapons); curWeapon++) 
	{
			long nName = pUnit->inventory[curWeapon].masterID;
			bool bFound = 0;
			for ( int j = 0; j < i; j++ )
			{
				if ( nName == names[j] )
				{
					disabledCount[j][1] ++;
					if (!pUnit->inventory[curWeapon].disabled && (pUnit->getWeaponShots(curWeapon) > 0)
						&& pUnit->inventory[curWeapon].health > 0 ) 
					{
						disabledCount[j][0]++;
					}
		
					bFound = true;
				}
			}
			if ( bFound )
				continue;
			
			names[i] = nName;
			
			//ONly need to add in the AMMO once!!
			// Glenn has taken the liberty of combining all shots of this type
			// into one master ammo list!!
			if ( MasterComponent::masterList[pUnit->inventory[curWeapon].masterID].getWeaponAmmoType() == WEAPON_AMMO_NONE 
				|| g_unlimitedAmmo )
				ammo[i] = -1;
			else
				ammo[i] += pUnit->getWeaponShots( curWeapon );

			int  range = MasterComponent::masterList[pUnit->inventory[curWeapon].masterID].getWeaponRange();
			ranges[i] = range;
			bDraw[range] = true;

			if (!pUnit->inventory[curWeapon].disabled && (pUnit->getWeaponShots(curWeapon) > 0)
				&& pUnit->inventory[curWeapon].health > 0 ) 
			{
				disabledCount[i][0]++;
			}
			disabledCount[i][1]++;
			i++;
	}

	curY += SECTIONSKIP;


	unsigned long height = componentFont.height();
	

	// removing headers for now
//	long stringIDs[4] = { IDS_SHORT, IDS_MEDIUM, IDS_LONG, IDS_COMPONENT};
//	long headerColors[4] = { 0xFFC8E100, 0xff0091FF, 0xFFFF0000, 0xffFF8A00 };
	EString capHeader;



	for ( int j = 0; j < 3; j++ )
	{
		if ( !bDraw[j] ) // make sure we have one
			continue;

//		char header[64];
		if ( curY > NAMETOP )
		{
//			cLoadString( stringIDs[j], header, 63 );
//			capHeader = header;
			//capHeader.MakeUpper();
//			componentFont.render( capHeader, COMPONENTLEFT, curY, SCROLLLEFT - COMPONENTLEFT, height, headerColors[j], 0, 0 );
		}
//		curY += height;
		
		for ( i = 0; i < curComponentCount; i++ )
		{
			if ( !names[i] )
				break;
			char tmpName[256];
			if ( ranges[i] == j )
			{
				if ( curY > NAMETOP )
				{
					cLoadString( IDS_COMP_ABBR0 + names[i], tmpName, 255 );
					capHeader.Format( "%ld/%ld  %s", disabledCount[i][0], disabledCount[i][1], tmpName );
					componentFont.render( capHeader, COMPONENTLEFT, curY, SCROLLLEFT - COMPONENTLEFT, height, textColors[j], 0, 0 );
				}
				curY += height;	

				if ( ammo[i] != -1 )
				{
					if ( curY > NAMETOP )
					{
						// make the ammo number
						char tmpNumber[64];
						char tmpNumber2[64];
						cLoadString( IDS_MISSION_SHOTSLEFT, tmpNumber, 63 );
						sprintf( tmpNumber2, tmpNumber, ammo[i] );
						componentFont.render( tmpNumber2, COMPONENTLEFT, curY, SCROLLLEFT - COMPONENTLEFT, height,  textColors[j], 0, 0 );	
				
					}
					curY += height;
				}
			}
	
		}

		curY += SECTIONSKIP;

		if ( curY > NAMEBOTTOM )
			drawDivider( curY );

		curY += SECTIONSKIP;

	}

	memset( names, 0, sizeof( char* ) * 60 );
	long count[4];
	count[0] = pUnit->ecm;
	count[1] = pUnit->probe;
	count[2] = pUnit->jumpJets;
	count[3] = pUnit->isMech() ?  pUnit->sensor : 255;

	if ((count[0] || count[1] || count[2] || count[3] ) )
	{
		if ( curY > NAMETOP )
		{
//			cLoadString( stringIDs[j], header, 63 );
//			componentFont.render( header, COMPONENTLEFT, curY, SCROLLLEFT - COMPONENTLEFT, height, headerColors[j], 0, 0 );
		}

//		curY += height;
	}
	
	

	for ( curWeapon = 0; curWeapon < 4; curWeapon++ )
	{
		if ( count[curWeapon] != 255)
		{
			long color = 0xffc29b00;
			//Neither the ecm, probe, sensors or JumpJets can ever REALLY be disabled. No matter what the setting is!!
//			if (pUnit->inventory[count[curWeapon]].disabled) 
//				color = 0xff7f7f7f;

			char tmpName[256];
			cLoadString( IDS_COMP_ABBR0 + pUnit->inventory[count[curWeapon]].masterID, tmpName, 255 );

			if ( curY > NAMETOP )
			{
				componentFont.render( tmpName, COMPONENTLEFT, curY, SCROLLLEFT - COMPONENTLEFT, height, color, 0, 0 );
			}
	
			curY += height;
			curY += InfoWindow::SECTIONSKIP;

		}
	}

	if ( curY > NAMEBOTTOM )
		drawDivider( curY );

	curY += SECTIONSKIP;

	// DON'T DO PILOT INFO if ENEMY OR mech is destroyed or disabled.
	if ( pUnit->getTeam() && !Team::home->isEnemy(pUnit->getTeam()) && pUnit->isMech() && !pUnit->isDisabled() && !pUnit->isDestroyed())
	{
		MechWarrior* pWarrior = pUnit->getPilot();

		if ( icon )
		{
			if ( curY > NAMETOP )
			{
				if ( pWarrior->active() )
					icon->renderPilotIcon( PILOTLEFT, curY, PILOTRIGHT, curY + PILOTHEIGHT );
				GUI_RECT tmpRect = { PILOTLEFT, curY, PILOTRIGHT + 1, curY + PILOTHEIGHT + 1 }; 
				drawEmptyRect( tmpRect, SCROLLCOLOR, SCROLLCOLOR  );
			
				float right = SCROLLLEFT;
				float top = curY + PILOTHEIGHT/2 - height/2;
				float bottom = top + height;
				// draw the name of the pilot
				char deadPilotName[256];
				cLoadString( IDS_NOPILOT, deadPilotName, 255 );
				capHeader = pWarrior->active() ? pWarrior->getName() : deadPilotName;
				componentFont.render( capHeader, PILOTNAMELEFT, top, right - PILOTNAMELEFT, bottom - top, 0xff005392, 0, 0 );
				
			}
			
			curY += PILOTHEIGHT;
			curY += SECTIONSKIP;
		}

		curY += SECTIONSKIP;

		int rank = pWarrior->getRank();
		int skills[2] = { MWS_GUNNERY, MWS_PILOTING };

		char buffer[256];
		//ACE not continguous with other ranks.  Added too late!
		if (rank != 4)
			cLoadString( IDS_GREEN + rank, buffer, 256 );
		else
			cLoadString( IDS_ACE, buffer, 256 );

		if ( curY > NAMETOP )
		{
			componentFont.render( buffer, SKILLLEFT, curY, SCROLLLEFT - SKILLLEFT, height, 0xff005392, 0, 0 );
		}

		int currentSkill = rank;
		for ( j = 0; j < 3; j ++ )
		{
			gos_VERTEX v[4];

			float height = skillInfos[currentSkill].location[1].y - skillInfos[currentSkill].location[0].y;
			for ( i = 0; i < 4; i++ )
			{
				v[i] = skillInfos[currentSkill].location[i];
				v[i].y = curY;	
				v[i].rhw = .5;
			}

			v[1].y = v[2].y = curY + height;		
			
			if ( curY > NAMETOP )
			{
				GUI_RECT tmpRect = { v[0].x - .5, v[0].y - .5, v[2].x + 1.5, v[2].y + 1.5 };
				drawEmptyRect( tmpRect, 0xff002f55, 0xff002f55  );


				unsigned long gosID = mcTextureManager->get_gosTextureHandle( skillInfos[currentSkill].textureHandle );
				gos_SetRenderState( gos_State_Texture, gosID );
				gos_DrawQuads( v, 4 );

				if ( j != 0 )
				{
					int skill = pWarrior->getSkill( skills[j-1] );
					drawSkillBar( skill, curY, height );
				}
			}

			curY += height;
			curY += SECTIONSKIP;
			currentSkill = j + 5;

		}

			
		
		for ( i = 0; i < NUM_SPECIALTY_SKILLS; i++ )
		{
			if ( pWarrior->specialtySkills[i] )
			{
				if ( curY > NAMETOP )
				{
					cLoadString( IDS_SPECIALTY + i, buffer, 256 );
					componentFont.render( buffer, NAMELEFT, curY, NAMERIGHT - NAMELEFT, height, 0xff005392, 0, 0 );
				}
				curY += height;
			}
		}
	}
	else
		curY += 10 * SECTIONSKIP;


	if ( infoLength == 0 )
		infoLength = curY - SCROLLTOP - ( SCROLLBOTTOM - SCROLLTOP );
}
コード例 #10
0
void InfoWindow::render()
{

	
	drawScrollingStuff();

	GUI_RECT tmpRect = { SCROLLBOXLEFT, SCROLLBOXBOTTOM, SCROLLBOXRIGHT, INFOTOP + INFOHEIGHT };
	drawRect( tmpRect, 0xff000000 );

	for ( int i = 0; i < 2; i++ )
	{
		if ( buttons[i].isEnabled() )
			buttons[i].render();
	}
	
	long scrollBarLength = buttons[1].location[0].y - buttons[0].location[2].y - 4 - SCROLLBUTTONHEIGHT;

	gos_VERTEX v[4];
	for ( i = 0; i < 4; i++ )
	{
		v[i].argb = 0xff5c96c2;
		v[i].frgb = 0;
		v[i].rhw = .5;
		v[i].x = SCROLLBUTTONX;
		v[i].y = SCROLLMIN + scrollPos;
		v[i].z = 0.f;
		v[i].u = v[i].v = 0.f;
//		v[i].u = ((float)SCROLLBUTTONU)/256.f + .1/256.f;
//		v[i].v = ((float)SCROLLBUTTONV)/256.f + .1/256.f ;
	}
	if ( infoLength < scrollBarLength  || !pUnit )
	{
		buttons[0].disable( 1 );
		buttons[1].disable( 1 );
		SCROLLMAX = 0;
	}
	else
	{
		buttons[0].disable( 0 );
		buttons[1].disable( 0 );

		float physicalRange = buttons[1].location[0].y - buttons[0].location[2].y;
		float buttonHeight = SCROLLBUTTONHEIGHT;

		float RealRange = infoLength;

		buttonHeight =  physicalRange * physicalRange/(physicalRange + RealRange);

		if ( buttonHeight < SCROLLBUTTONHEIGHT )
			buttonHeight = SCROLLBUTTONHEIGHT;

		SCROLLMAX = buttons[1].location[0].y - buttonHeight - 2;
		



		v[2].x = v[3].x = SCROLLBUTTONX + SCROLLBUTTONWIDTH;
		v[1].y = v[2].y = SCROLLBOTTOM;	
		v[1].y = v[2].y = v[0].y + buttonHeight;

	//	v[2].u = v[3].u = .1/256.f + (float)(SCROLLBUTTONU + ((float)SCROLLBUTTONWIDTH))/256.f;
	//	v[1].v = v[2].v = .1/256.f + (float)(SCROLLBUTTONV + ((float)SCROLLBUTTONHEIGHT))/256.f;

		gos_SetRenderState( gos_State_Texture, 0 );
		gos_DrawQuads( v, 4 );
	}



	// draw the name of the unit
	if ( pUnit )
	{
		drawName( pUnit->getIfaceName() );
	
		gos_SetRenderState( gos_State_Texture, 0 );

		// draw the health bar
		DWORD					color;
		
		float barStatus = pUnit->getAppearance()->barStatus;
			
		if (barStatus > 1.0f)
			barStatus = 1.0f;

		if (barStatus >= 0.5)
			color = SB_GREEN;
		else if (barStatus > 0.2)
			color = SB_YELLOW;
		else 
			color = SB_RED;
			
		v[0].x = v[1].x = HEALTHLEFT;
		v[2].x = v[3].x = HEALTHRIGHT;
		v[0].y = v[3].y = HEALTHTOP;
		v[1].y = v[2].y = HEALTHBOTTOM;

		unsigned long dimColor = ( color & 0xff7f7f7f );
		for ( int i = 0; i < 4; i++ )
			v[i].argb = dimColor;

		gos_DrawQuads( v, 4 );

		v[2].x = v[3].x = HEALTHLEFT + (HEALTHRIGHT - HEALTHLEFT)* barStatus;

		for ( i = 0; i < 4; i++ )
			v[i].argb = color | 0xff000000;

		gos_DrawQuads( v, 4 );
		
	}
	else
	{
		char noUnit[256];
		cLoadString( IDS_NOUNIT, noUnit, 255 );
		drawName( noUnit );
	}

	GUI_RECT border = { SCROLLBOXLEFT, SCROLLBOXTOP, SCROLLBOXRIGHT, SCROLLBOXBOTTOM  };
	drawEmptyRect( border, SCROLLCOLOR, SCROLLCOLOR );
	GUI_RECT rect = { SCROLLLEFT, SCROLLTOP, SCROLLRIGHT, SCROLLBOTTOM };
	drawEmptyRect( rect, SCROLLCOLOR, SCROLLCOLOR );


}
コード例 #11
0
void GameTacMap::render()
{
	if (turn < 2)		//Terrain not setup yet.  Left,Right,Top,Bottom are poopy!
		return;

	gos_VERTEX corners[5];

	gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_OneZero );

	gos_SetRenderState( gos_State_Specular,FALSE );
	gos_SetRenderState( gos_State_AlphaTest, FALSE );
			
	gos_SetRenderState( gos_State_Filter, gos_FilterNone );
	gos_SetRenderState( gos_State_ZWrite, 0 );
	gos_SetRenderState( gos_State_ZCompare, 0 );
	gos_SetRenderState( gos_State_Texture, textureHandle );


	for ( int i = 0; i < 4; ++i )
	{
		corners[i].rhw = 1.0f;
		corners[i].argb = 0xffffffff;
		corners[i].frgb = 0;
		corners[i].z = 0.0f;
	}


	corners[0].x = corners[2].x = left;
	corners[1].x = corners[3].x = right;
	corners[3].y = corners[2].y = bottom;
	corners[0].y = corners[1].y = top;

	corners[0].u = 2.f/(float)bmpWidth;
	corners[3].u = 128.f/(float)bmpWidth;
	corners[2].u = 2.f/(float)bmpWidth;
	corners[1].u = 128.f/(float)bmpWidth;
	corners[0].v = 2.f/(float)bmpWidth;
	corners[3].v = 128.f/(float)bmpHeight;
	corners[2].v = 128.f/(float)bmpHeight;
	corners[1].v = 2.f/(float)bmpWidth;
	
	gos_DrawTriangles( corners, 3 );
	gos_DrawTriangles( &corners[1], 3 );


	Stuff::Vector2DOf<long> screen;
	Stuff::Vector4D 		nScreen;
	Stuff::Vector3D			world;

	//-----------------------------------------------------------
	// Render the objective markers
	long count = 0;
	for ( EList< CObjective*, CObjective* >::EIterator iter =  Team::home->objectives.Begin();
		!iter.IsDone(); iter++ )
	{
		//We are there.  Start flashing.
		if ((objectiveAnimationId == count) && objectiveNumFlashes)
		{
			objectiveFlashTime += g_deltaTime;
			if ( objectiveFlashTime > .5f )
			{
				objectiveFlashTime = 0.0f;
				objectiveNumFlashes--;
			}
			else if ( objectiveFlashTime > 0.25f)
			{
				(*iter)->RenderMarkers(this, 0);
			}

			if (objectiveNumFlashes == 0)
			{
				//Flashing is done.  We now return you to your regularly scheduled program.
				objectiveAnimationId = 0;
			}
		}
		else
		{
			(*iter)->RenderMarkers(this, 0);
		}

		count++;
	}

	
	// this is the little viewing rect

	// Routine that InverseProjects is slightly less accurate but an order of magnitude faster.
	// Can make more accurate later at very little expense to performance.
	// Easy to fix with camera later.  -fs

	screen.x = 1;
	screen.y = 1;
	
	nScreen.x = nScreen.y = 1.0f;
	nScreen.z = nScreen.w = 0.0f;
	
	eye->inverseProjectZ( nScreen, world );
	worldToTacMap( world, corners[0] );

	screen.y = Environment.screenHeight - 1;
	nScreen.y = (Environment.screenHeight * 0.6667f) - 1;
	nScreen.z = nScreen.w = 0.0f;
	eye->inverseProjectZ( nScreen, world );
	worldToTacMap( world, corners[1] );

	screen.x = Environment.screenWidth - 1;
	nScreen.x = Environment.screenWidth - 1;
	nScreen.z = nScreen.w = 0.0f;
	eye->inverseProjectZ( nScreen, world );
	worldToTacMap( world, corners[2] );

	screen.y = 1;
	nScreen.y = 1;
	nScreen.z = nScreen.w = 0.0f;
	eye->inverseProjectZ( nScreen, world );
	worldToTacMap( world, corners[3] );

	corners[0].argb = 0xffffffff;
	corners[1].argb = 0xffffffff;
	corners[2].argb = 0xffffffff;
	corners[3].argb = 0xffffffff;
	corners[0].u = corners[1].u = 0.078125f;
	corners[3].u = corners[2].u = .99875f;
	corners[0].v = corners[3].v = 0.078125f;
	corners[1].v = corners[2].v = .99875f;
	corners[4] = corners[0];

	gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
	gos_SetRenderState( gos_State_ShadeMode, gos_ShadeGouraud);
	gos_SetRenderState( gos_State_MonoEnable, 0);
	gos_SetRenderState( gos_State_Perspective, 0);
	gos_SetRenderState( gos_State_Clipping, 2);
	gos_SetRenderState( gos_State_AlphaTest, 0);
	gos_SetRenderState( gos_State_Specular, 0);
	gos_SetRenderState( gos_State_Dither, 1);
	gos_SetRenderState( gos_State_TextureMapBlend, gos_BlendModulate);
	gos_SetRenderState( gos_State_Filter, gos_FilterBiLinear);
	gos_SetRenderState( gos_State_TextureAddress, gos_TextureWrap );
	gos_SetRenderState( gos_State_ZCompare, 0);
	gos_SetRenderState(	gos_State_ZWrite, 0);
	DWORD gosTextureHandle = mcTextureManager->get_gosTextureHandle(viewRectHandle);

	gos_SetRenderState( gos_State_Texture, gosTextureHandle );

	gos_DrawQuads( &corners[0], 4 );

	unsigned long colors[MAX_MOVERS];
	unsigned long ringColors[MAX_MOVERS];
	Stuff::Vector3D positions[MAX_MOVERS];
	unsigned long ranges[MAX_MOVERS];
	bool		  selected[MAX_MOVERS];

	count = 0;

	//------------------------------------------------------------
	// draw non-movers, must do separate check for vehicles, I'm not sure they
	// have sensors
	for ( i = 0; i < MAX_TEAMS; ++i )
	{
		TeamSensorSystem* pSys = SensorManager->getTeamSensor( i );
		
		if ( pSys )
		{
			for ( int j = 0; j < pSys->numSensors; ++j )
			{
				SensorSystem* pSensor = pSys->sensors[j];

				if ( !pSensor )
					continue;

				if ( pSensor->owner->isDestroyed() || pSensor->owner->isDisabled() || pSensor->owner->getStatus() == OBJECT_STATUS_SHUTDOWN )
					continue;

				if ( pSensor->getRange() < 1.1 || pSensor->broken)
					continue;

				if (!pSensor->owner->getTeam())
					continue;

				ObjectClass objClass = pSensor->owner->getObjectClass();

				unsigned long colorBlip = pSensor->owner->getSelected() ? 0xff4bff4b : 0xff00cc00;
				unsigned long colorRing = 0xff00cc00;

			
				if ( pSensor->owner->getTeam()->isNeutral( Team::home ) )
				{
					colorBlip = pSensor->owner->getSelected() ? 0xff4c4cff : 0xff0000ff;
					colorRing = 0xff0000ff;
				}
				else if ( pSensor->owner->getTeam()->isEnemy( Team::home ) ) // enemy
				{
					
					{
						colorBlip = pSensor->owner->getSelected() ? 0xffff3f3f : 0xffff0000;
						colorRing = 0xffff0000;
					}
				}

				if ( objClass != BATTLEMECH && objClass != GROUNDVEHICLE)
				{
					if ( objClass == ARTILLERY )
					{
						// blink
						s_lastBlinkTime += g_deltaTime;
						if ( s_lastBlinkTime > s_blinkLength )
						{
							colorBlip = 0;
							colorRing = 0;
							s_lastBlinkTime = 0.f;
						}

					}

					colors[count] = colorBlip;
					ringColors[count] = colorRing;
					ranges[count] = pSensor->getRange();
					selected[count] = 0;
					positions[count] = pSensor->owner->getPosition();
					count++;

				}
			}
		}
	}

	unsigned long colorBlip, colorRing;

	//-----------------------------------------------------	
	// draw the movers
	for (i=0;i<(ObjectManager->numMovers);i++)
	{
		MoverPtr mover = ObjectManager->getMover(i);
		if (mover && mover->getExists() && !(mover->isDestroyed() || mover->isDisabled()))
		{
			SensorSystem* pSensor = mover->getSensorSystem();
			float range = pSensor ? pSensor->getRange() : 0;
			long contactStatus = mover->getContactStatus(Team::home->getId(), true);
			if (mover->getTeamId() == Team::home->id)
			{
				if (mover->getCommanderId() == Commander::home->getId())
				{
					if (mover->isOnGUI())
					{
						colorBlip = mover->getSelected() ? 0xff4bff4b : 0xff00cc00;
						mover->getStatus() == OBJECT_STATUS_SHUTDOWN ? colorRing = 0 : colorRing =  0xff00cc00;
					}
					else
						continue;
				}
				else
				{
					if (mover->isOnGUI() && land->IsGameSelectTerrainPosition(mover->getPosition()) && mover->pathLocks)
					{
						colorBlip = mover->getSelected() ? 0xff4b4bff : 0xff0000cc;
						mover->getStatus() == OBJECT_STATUS_SHUTDOWN ? colorRing = 0 : colorRing =  0xff0000cc;
					}
					else
						continue;
				}
			}
			else if (g_dbgShowMovers || (MPlayer && MPlayer->allUnitsDestroyed[MPlayer->commanderID]) || ((mover->getTeamId() != Team::home->id)
				&&  ( contactStatus != CONTACT_NONE )
				&&  (mover->getStatus() != OBJECT_STATUS_SHUTDOWN) 
				&&  (!mover->hasNullSignature())
				&&	(mover->getEcmRange() <= 0.0f) ) )	//Do not draw ECM mechs!!)
			{
				//Not on our side.  Draw by contact status
				colorBlip = mover->getSelected() ? 0xffff3f3f : 0xffff0000;
				colorRing = 0xffff0000;
				
			}
			else
				continue;

			colors[count] = colorBlip;
			ringColors[count] = colorRing;
			ranges[count] = range;
			selected[count] = mover->getSelected();
			positions[count] = mover->getPosition();
			count++;

		}
	}

	for ( i = 0; i < count; i++ )
	{
		drawSensor( positions[i], ranges[i], ringColors[i] );
	}
	bool bSel = 0; // draw unselected first
	for ( int j = 0; j < 2; j++ )
	{
		for ( int i = 0; i < count; i++ )
		{
			if ( selected[i] == bSel )
			{
				drawBlip( positions[i], colors[i], DOT_BLIP );
			}
		}
		bSel = 1;
	}



}