Skip to content

Scaling Vetarancy Icon With Resolution And Fixing Its Position #868

@Mauller

Description

@Mauller

It appears that veterancy icons were not setup to scale with zoom level apart from their positioning to a certain degree.

There are three fixes with this issue, the positioning of the veterancy icon, the scaling of it with resolution and the scaling with zoom.

  1. The positioning is fixed by using the calculated rect of the health bar that is fixed in the other issue. The icon is placed at the end of the health bar.
  2. The resolution scaling of the size of the veterancy icon is fixed the same as with the heatlh bar. in relation to 800x600 based on current tactical view size.
  3. The scaling of the veterancy icon is also applied to the size of the veterancy icon so it scaled with zoom instead of being a fixed size.

The following code is a proposed fix for this. Found within Drawable.cpp the same as with the health bar fix.

EDIT: This still needs testing with aspect ratios other than 4:3 such as 16:9, but it is a start to understanding the problem.

void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
{
	// get object from drawble
	Object* obj = getObject();

	if( obj->getExperienceTracker() == NULL )
	{
		//Only objects with experience trackers can possibly have veterancy.
		return;
	}

	VeterancyLevel level = obj->getVeterancyLevel();
	const Image* image = s_veterancyImage[level];
	if (!image)
		return;

	Real scale = 1.3f / TheTacticalView->getZoom();
#ifdef SCALE_ICONS_WITH_ZOOM_ML
	Real objScale = scale * 1.55f;
#else
	Real objScale = 1.0f;
#endif

	Real resolutionWidthScale = TheTacticalView->getWidth() / 800.0f;
	Real resolutionHeightScale = TheTacticalView->getHeight() / 600.0f;

	Real vetBoxWidth = image->getImageWidth() * objScale * scale * resolutionWidthScale;
	Real vetBoxHeight = image->getImageHeight() * objScale * scale * resolutionHeightScale;

	//
	// take the center position of the object, go down to it's bottom extent, and project
	// that point to the screen, that will be the "center" of our veterancy box
	//

	Coord3D p;
	ICoord2D screenCenter;
	obj->getHealthBoxPosition(p);
	if( !TheTacticalView->worldToScreen( &p, &screenCenter ) )
		return;

	Real healthBoxWidth;

	healthBoxWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
	screenCenter.x += healthBoxWidth * 0.5f;

	// draw the image
	TheDisplay->drawImage(image, screenCenter.x + 1, screenCenter.y + 1, screenCenter.x + 1 + vetBoxWidth, screenCenter.y + 1 + vetBoxHeight);

}  // end drawVeterancy

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementIs new feature or requestFixIs fixing somethingGUIFor graphical user interface

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions