Skip to content

Scaling Contain Icons With Resolution And Zoom Levels #869

@Mauller

Description

@Mauller

Contain icons are not scaled with resolution or zoom levels in the original game. They have a fixed resolution which causes them to shrink in size relative to everything when zooming or increasing resolution.

With this fix i have scaled the size of the contain by resolution and zoom level. This leaves the contain icons with a reasonable looking size in relation to everything else.

This is one where the 800x600 implementation i would say was oversized in relation to the zoomed out version and undersized when zoomed in. With the zoom scaling factor it leaves the contain icons with a more reasonable looking size in relation to the health bar and other information.

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

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::drawContained( const IRegion2D *healthBarRegion )
{
	const Object *obj = getObject();			

	ContainModuleInterface* container = obj->getContain();
	if (!container)
		return;

	if (!(
				TheGlobalData->m_showObjectHealth && 
				(isSelected() || (TheInGameUI && (TheInGameUI->getMousedOverDrawableID() == getID()))) &&
				obj->getControllingPlayer() == ThePlayerList->getLocalPlayer()
			))
		return;

	Int numTotal;
	Int numFull;
	if (!container->getContainerPipsToShow(numTotal, numFull))
		return;

	// if empty, don't show nothin'
	if (numFull == 0)
		return;

	Int numInfantry = 0;
	const ContainedItemsList* contained = container->getContainedItemsList();
	if (contained)
	{
		for (ContainedItemsList::const_iterator it = contained->begin(); it != contained->end(); ++it)
		{
			if ((*it)->isKindOf(KINDOF_INFANTRY))
				++numInfantry;
		}
	}

#ifdef SCALE_ICONS_WITH_ZOOM_ML
	Real scale = TheGlobalData->m_ammoPipScaleFactor / CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
#else
	Real scale = 1.0f / TheTacticalView->getZoom();
#endif

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

	Int boxWidth  = REAL_TO_INT(s_emptyContainer->getImageWidth() * resolutionWidthScale * scale);
	Int boxHeight = REAL_TO_INT(s_emptyContainer->getImageHeight() * resolutionHeightScale * scale);
	const Int SPACING = 1;
	//Int totalWidth = (boxWidth+SPACING)*numTotal;

	ICoord2D screenCenter;
	Coord3D pos = *obj->getPosition();
	pos.x += TheGlobalData->m_containerPipWorldOffset.x;
	pos.y += TheGlobalData->m_containerPipWorldOffset.y;
	pos.z += TheGlobalData->m_containerPipWorldOffset.z + obj->getGeometryInfo().getMaxHeightAbovePosition();
	if( !TheTacticalView->worldToScreen( &pos, &screenCenter ) )
		return;

	Real bounding = obj->getGeometryInfo().getBoundingSphereRadius() * scale;
	
	//Int posx = screenCenter.x + REAL_TO_INT(TheGlobalData->m_containerPipScreenOffset.x*bounding) - totalWidth;
	//**CHANGING CODE: Left justify with health bar min
	Int posx = healthBarRegion->lo.x;
	Int posy = screenCenter.y + REAL_TO_INT(TheGlobalData->m_containerPipScreenOffset.y*bounding);

	for (Int i = 0; i < numTotal; ++i)
	{
		const Color INFANTRY_COLOR = GameMakeColor(0, 255, 0, 255);
		const Color NON_INFANTRY_COLOR = GameMakeColor(0, 0, 255, 255);
		if (i < numFull)
			TheDisplay->drawImage(s_fullContainer, posx, posy, posx + boxWidth, posy + boxHeight, 
				(i < numInfantry) ? INFANTRY_COLOR : NON_INFANTRY_COLOR);
		else
			TheDisplay->drawImage(s_emptyContainer, posx, posy + 1, posx + boxWidth, posy + 1 + boxHeight);
		posx += boxWidth + SPACING;
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementIs new feature or requestFixIs fixing something, but is not user facingGUIFor graphical user interface

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions