Example #1
0
unsigned long aFont::width( const char* st ) const
{
	unsigned long width, height;
	gos_TextSetAttributes (gosFont, 0, size, false, true, false, false);
	gos_TextStringLength(&width,&height,st);
	return width;
}
Example #2
0
unsigned long aFont::height( ) const
{
	unsigned long width, height;
	gos_TextSetAttributes (gosFont, 0, size, false, true, false, false);
	gos_TextStringLength(&width,&height,"ABCDE");
	return height;
}
Example #3
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();
		}
	}
}
Example #4
0
void aFont::render( const char* text, int xPos, int yPos, int areaWidth, int areaHeight, 
				   unsigned long color, bool bBold, int alignment )
{
	gos_TextSetAttributes( gosFont, color, size, true, true, bBold, false, alignment );
	
	if ( areaWidth < 1 )
	{
		if ( alignment == 1 )
		{
			unsigned long width, height;
			gos_TextStringLength( &width, &height, text );
			xPos -= width;
			areaWidth = width + 1;
		}
		else
			areaWidth = Environment.screenWidth;
	}

	if ( areaHeight < 1 )
	{
		if ( alignment == 3  ) // bottom
		{
			unsigned long width, height;
			gos_TextStringLength( &width, &height, text );
			yPos -= height;
			areaHeight = height + 1;
		}
		
		else
			areaHeight = Environment.screenHeight;
	}

	gos_TextSetRegion( xPos, yPos, xPos + areaWidth, yPos + areaHeight );
	
	gos_TextSetPosition( xPos, yPos );
	gos_TextDraw( text );	

}
Example #5
0
void GameDebugWindow::setFont (char* fontFile) {

	if (font) {
		gos_DeleteFont(font);
		font = NULL;
	}
	if (fontFile) {
		font = gos_LoadFont(fontFile);
		gos_TextSetAttributes(font, 0xffffffff, 1.0, true, true, false, false);
	}
	DWORD height, width;
	gos_TextStringLength(&width, &height, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
	fontHeight = height;
}
Example #6
0
void Appearance::drawPilotName(char *text, unsigned long color )
{
	DWORD width, height;
	Stuff::Vector4D moveHere;
	moveHere = screenPos;


	gos_TextSetAttributes (gosFontHandle, 0, gosFontScale, false, true, false, false);
	gos_TextStringLength(&width,&height,text);

	moveHere.y = lowerRight.y + 10.0f + height;
	moveHere.x -= width / 2;
	moveHere.z = width;
	moveHere.w = height;

	globalFloatHelp->setFloatHelp(text,moveHere,color,SD_BLACK,1.0f,true,false,false,false);
}
Example #7
0
//-----------------------------------------------------------------------------------------
void FloatHelp::getTextStringLength(PSTR  txt,
									uint32_t fColor,
									float scl,
									bool proportional,
									bool bold,
									bool italic,
									bool wordWrap,
									uint32_t& width, uint32_t& height)
{
	// must use globalFloat Scale because of true type fonts
	gos_TextSetAttributes(gosFontHandle, fColor, gosFontScale, wordWrap, proportional, bold, italic);
	uint32_t gHeight = 0, gWidth = 0;
	if(txt[0])
	{
		gos_TextStringLength(&gWidth, &gHeight, txt);
	}
	width = gWidth;
	height = gHeight;
}
Example #8
0
//---------------------------------------------------------------------------
int32_t GameCamera::update(void)
{
	if (lookTargetObject != -1)
		targetObject = getCamObject(lookTargetObject, true);
	if (targetObject && targetObject->getExists() &&
		((targetObject->getCommanderId() == Commander::home->getId()) || !targetObject->isMover() ||
			(targetObject->isMover() &&
				((Mover*)targetObject)->conStat >= CONTACT_SENSOR_QUALITY_1)))
	{
		setPosition(targetObject->getPosition(), false);
	}
	else
	{
		targetObject = nullptr;
	}
	// Force CameraAltitude to be less than max based on angle.  This keeps poly
	// load relatively even
	float anglePercent = (projectionAngle - MIN_PERSPECTIVE) / (MAX_PERSPECTIVE - MIN_PERSPECTIVE);
	float testMax	  = Camera::AltitudeMaximumLo +
		((Camera::AltitudeMaximumHi - Camera::AltitudeMaximumLo) * anglePercent);
	if (cameraAltitude > testMax)
		cameraAltitude = testMax;
	if ((cameraAltitude < testMax) && (cameraAltitudeDesired > testMax))
		cameraAltitude = testMax;
	// calculate new near and far plane distance based on
	// Current altitude above terrain.
	float altitudePercent	 = (cameraAltitude - AltitudeMinimum) / (testMax - AltitudeMinimum);
	Camera::NearPlaneDistance = MinNearPlane + ((MaxNearPlane - MinNearPlane) * altitudePercent);
	Camera::FarPlaneDistance  = MinFarPlane + ((MaxFarPlane - MinFarPlane) * altitudePercent);
	if (userInput->getKeyDown(KEY_LBRACKET) && userInput->ctrl() && userInput->alt() &&
		!userInput->shift())
	{
		useLOSAngle ^= true;
	}
#ifdef DEBUG_CAMERA
	if (userInput->getKeyDown(KEY_RBRACKET) && userInput->ctrl() && userInput->alt() &&
		!userInput->shift())
	{
		Camera::NearPlaneDistance += 10.0f;
	}
	if (userInput->getKeyDown(KEY_APOSTROPHE) && userInput->ctrl() && userInput->alt() &&
		!userInput->shift())
	{
		Camera::FarPlaneDistance -= 1005.00f;
	}
	if (userInput->getKeyDown(KEY_SEMICOLON) && userInput->ctrl() && userInput->alt() &&
		!userInput->shift())
	{
		Camera::FarPlaneDistance += 1005.0f;
	}
	char text[1024];
	sprintf(text, "Near Plane: %f     Far Plane: %f", Camera::NearPlaneDistance,
		Camera::FarPlaneDistance);
	uint32_t width, height;
	Stuff::Vector4D moveHere;
	moveHere.x = 10.0f;
	moveHere.y = 10.0f;
	gos_TextSetAttributes(gosFontHandle, 0, gosFontScale, false, true, false, false);
	gos_TextStringLength(&width, &height, text);
	moveHere.z = width;
	moveHere.w = height;
	globalFloatHelp[currentFloatHelp].setHelpText(text);
	globalFloatHelp[currentFloatHelp].setScreenPos(moveHere);
	globalFloatHelp[currentFloatHelp].setForegroundColor(SD_GREEN);
	globalFloatHelp[currentFloatHelp].setBackgroundColor(SD_BLACK);
	globalFloatHelp[currentFloatHelp].setScale(1.0f);
	globalFloatHelp[currentFloatHelp].setProportional(true);
	globalFloatHelp[currentFloatHelp].setBold(false);
	globalFloatHelp[currentFloatHelp].setItalic(false);
	globalFloatHelp[currentFloatHelp].setWordWrap(false);
	currentFloatHelp++;
	gosASSERT(currentFloatHelp < MAX_FLOAT_HELPS);
#endif
	if (DisplayCameraAngle)
	{
		char text[1024];
		sprintf(text,
			"Camera Angle: %f degrees    Camera Altitude: %f    "
			"CameraPosition: X=%f Y=%f Z=%f   CameraRotation: %f",
			projectionAngle, cameraAltitude, position.x, position.y, position.z, cameraRotation);
		uint32_t width, height;
		Stuff::Vector4D moveHere;
		moveHere.x = 10.0f;
		moveHere.y = 10.0f;
		gos_TextSetAttributes(gosFontHandle, 0, gosFontScale, false, true, false, false);
		gos_TextStringLength(&width, &height, text);
		moveHere.z = width;
		moveHere.w = height;
		globalFloatHelp->setFloatHelp(
			text, moveHere, SD_GREEN, SD_BLACK, 1.0f, true, false, false, false);
	}
	if (!compass) // Create it!
	{
		AppearanceType* appearanceType =
			appearanceTypeList->getAppearance(BLDG_TYPE << 24, "compass");
		compass = new BldgAppearance;
		compass->init(appearanceType);
	}
	int32_t result = Camera::update();
	//	if ((day2NightTransitionTime > 0.0f) && !getIsNight() &&
	//(fabs(lastShadowLightPitch-lightPitch) > MAX_SHADOW_PITCH_CHANGE))
	//	{
	//		forceShadowRecalc = true;
	//		lastShadowLightPitch = lightPitch;
	//	}
	//	else
	//	{
	//		forceShadowRecalc = false;
	//	}
	// Always TRUE for right now.  Debugging....
	//-fs
	// forceShadowRecalc = true;
	bool oldFog		= useFog;
	bool oldShadows = useShadows;
	useFog			= false;
	useShadows		= false;
	if (compass && (turn > 3))
	{
		compass->setObjectParameters(getPosition(), 0.0f, false, 0, 0);
		compass->setMoverParameters(0.0f);
		compass->setGesture(0);
		compass->setObjStatus(OBJECT_STATUS_DESTROYED);
		compass->setInView(true);
		compass->setVisibility(true, true);
		compass->setFilterState(true);
		compass->setIsHudElement();
		compass->update(); // Force it to try and draw or stuff will not work!
	}
	if (theSky)
	{
		Stuff::Vector3D pos = getPosition();
		theSky->setObjectParameters(pos, 0.0f, false, 0, 0);
		theSky->setMoverParameters(0.0f);
		theSky->setGesture(0);
		theSky->setObjStatus(OBJECT_STATUS_NORMAL);
		theSky->setInView(true);
		theSky->setVisibility(true, true);
		theSky->setFilterState(true);
		theSky->setIsHudElement();
		theSky->update(); // Force it to try and draw or stuff will not work!
	}
	useFog	 = oldFog;
	useShadows = oldShadows;
	return result;
}
Example #9
0
unsigned long aFont::height( const char* st, int areaWidth ) const
{
	unsigned long width, height;
	gos_TextSetAttributes (gosFont, 0, size, false, true, false, false);
	gos_TextSetRegion( 0, 0, areaWidth, Environment.screenHeight );
	gos_TextStringLength(&width,&height,st);

	unsigned long lineCount = 1;

	if ( width > areaWidth - 1 )
	{
		unsigned long curLineWidth = 0;

		gosASSERT( strlen( st) < 2048 );

		
		char pLine[2048]; // should be more than adequate

		char* pLastWord = (char*)st;
		char* pTmp = (char*)st;
		char* pTmpLine = (char*)pLine;

		int numberOfWordsPerLine = 0;


		bool bHasSpaces = true;
		if (  !strstr( st, " " ) )
		{
			if ( !strstr( st, "\n" ) )
				bHasSpaces = false;
		}

		while( *pTmp != NULL )
		{
			if ( *pTmp == '\n' )
			{
				lineCount++;
				numberOfWordsPerLine = 0;
				curLineWidth = 0;	
				pTmpLine = pLine;
				pLastWord = pTmp+1;
			}
			else if ( !bHasSpaces )
			{
				if ( pTmp > st )
				{
					char tmp = *(pTmp-1);
					if ( !isleadbyte( tmp ) )
					{
						*(pTmpLine) = NULL;
						gos_TextStringLength( &curLineWidth, &height, pLine );
						if ( curLineWidth > areaWidth )
						{
							lineCount++;
							pTmp--;
							pTmpLine = pLine;
							curLineWidth = 0;
							numberOfWordsPerLine = 0;

						}

					}
					
				
				}
			}

			else if ( isspace( *pTmp ) )
			{
				*(pTmpLine) = NULL;
				gos_TextStringLength( &curLineWidth, &height, pLine );
				if ( curLineWidth > areaWidth )
				{
					gos_TextStringLength( &curLineWidth, &height, pLastWord );
					if ( numberOfWordsPerLine == 0 || curLineWidth > areaWidth )
					{
						static bool firstTime = true;
						if (firstTime)
						{
							Assert( true, 0, "this list box item contains a word of greater "
									" area than the list box, giving up" );
							firstTime = false;
						}
						/*There are times when you just can't guarantee that this won't occur,
						so we have to just continue and deal with it.*/
						//return height;

						pLastWord = pTmp;
					}
					lineCount++;
					pTmpLine = pLine;
					pTmp = pLastWord - 1;
					curLineWidth = 0;
					numberOfWordsPerLine = 0;

				}
		
				pLastWord = pTmp;
				numberOfWordsPerLine++;
			}


			*pTmpLine = *pTmp;
			if ( isleadbyte( *pTmpLine ) )
			{
				*(pTmpLine+1) = *(pTmp+1);
			}

			pTmpLine = (char*)_mbsinc( (unsigned char*)pTmpLine );
			pTmp = (char*)_mbsinc( (unsigned char*)pTmp );
		}

		// one last check
		*pTmpLine = NULL;
		gos_TextStringLength( &curLineWidth, &height, pLine );
		if ( curLineWidth > areaWidth )
		{
			lineCount++;
		}

		if ( *pTmp == NULL )
			lineCount++;	
	}

	gos_TextStringLength( &width, &height, "A" );

	return (height) * lineCount ;
}
Example #10
0
void	aFont::getSize( unsigned long& width, unsigned long& height, const char* pText )
{
	gos_TextSetAttributes (gosFont, 0, size, false, true, false, false);
	gos_TextStringLength(&width,&height,pText);

}