Open
Description
- Relates To: Game cursors, unit health bars and similar UI elements do not scale well in higher resolutions #108
Enthusiastic 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.
The same as with the contain icons i have scaled the size of the enthusiastic icon by resolution and zoom level. The sizing is taken in relation to how they look when zoomed out at 800x600.
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::drawEnthusiastic(const IRegion2D* healthBarRegion)
{
const Object *obj = getObject();
//
// if we are to show effect make sure we have the animation for it allocated, otherwise
// free any animation we may have allocated back to the animation memory pool
//
// only display if have enthusiasm
if( obj->testWeaponBonusCondition( WEAPONBONUSCONDITION_ENTHUSIASTIC ) == TRUE &&
healthBarRegion != NULL )
{
DrawableIconType iconIndex = ICON_ENTHUSIASTIC;
if (obj->testWeaponBonusCondition( WEAPONBONUSCONDITION_SUBLIMINAL ) == TRUE )// unless...
iconIndex = ICON_ENTHUSIASTIC_SUBLIMINAL;
if( getIconInfo()->m_icon[ iconIndex ] == NULL )
getIconInfo()->m_icon[ iconIndex ] = newInstance(Anim2D)( s_animationTemplates[ iconIndex ], TheAnim2DCollection );
// draw the animation if present
if( getIconInfo()->m_icon[ iconIndex ] != NULL)
{
//
// we are going to draw the healing icon relative to the size of the health bar region
// since that region takes into account hit point size and zoom factor of the camera too
//
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;// used for position
// based on our own kind of we have certain icons to display at a size scale
Real scale;
if( isKindOf( KINDOF_STRUCTURE ) || isKindOf( KINDOF_HUGE_VEHICLE ) )
scale = 1.00f;
else if( isKindOf( KINDOF_VEHICLE ) )
scale = 0.75f;
else
scale = 0.5f;
scale *= 1.5f / TheTacticalView->getZoom();
Real resolutionWidthScale = TheTacticalView->getWidth() / 800.0f;
Real resolutionHeightScale = TheTacticalView->getHeight() / 600.0f;
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale * resolutionWidthScale;
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale * resolutionHeightScale;
#ifdef SCALE_ICONS_WITH_ZOOM_ML
// adjust the width to be a % of the health bar region size
Int size = REAL_TO_INT( barWidth * scale );
frameHeight = REAL_TO_INT((INT_TO_REAL(size) / INT_TO_REAL(frameWidth)) * frameHeight);
frameWidth = size;
#endif
// given our scaled width and height we need to find the bottom left point to draw the image at
ICoord2D screen;
screen.x = REAL_TO_INT( healthBarRegion->lo.x + (barWidth * 0.25f) - (frameWidth * 0.5f) );
screen.y = healthBarRegion->hi.y + (frameHeight * 0.25);
getIconInfo()->m_icon[ iconIndex ]->draw( screen.x, screen.y, frameWidth, frameHeight );
}
}
else
{
killIcon(ICON_ENTHUSIASTIC);
killIcon(ICON_ENTHUSIASTIC_SUBLIMINAL);
}
}