From 1fdfee6c4a47e048a1303a2078d69f27d30f4fcb Mon Sep 17 00:00:00 2001 From: Mauller <26652186+Mauller@users.noreply.github.com> Date: Fri, 19 Sep 2025 17:23:38 +0100 Subject: [PATCH 1/2] tweak(display): add new functions to return ratios of screen dimensions relative to defaults --- .../Code/GameEngine/Include/GameClient/Display.h | 5 +++++ .../Code/GameEngine/Source/GameClient/Display.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Display.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Display.h index 319b15dc651..32ac368b903 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/Display.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Display.h @@ -90,6 +90,11 @@ class Display : public SubsystemInterface virtual void dumpAssetUsage(const char* mapname) = 0; #endif + //--------------------------------------------------------------------------------------- + // Display scaling methods + Real getWidthScale(); + Real getHeightScale(); + //--------------------------------------------------------------------------------------- // View management virtual void attachView( View *view ); ///< Attach the given view to the world diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Display.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Display.cpp index 9b7bbeaadd8..4204316cdff 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/Display.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Display.cpp @@ -199,6 +199,18 @@ void Display::setHeight( UnsignedInt height ) } +// Return the ratio of the current display width relative to the default resolution +Real Display::getWidthScale(void) +{ + return (Real)m_width / DEFAULT_DISPLAY_WIDTH; +} + +// Return the ratio of the current display height relative to the default resolution +Real Display::getHeightScale(void) +{ + return (Real)m_height / DEFAULT_DISPLAY_HEIGHT; +} + //============================================================================ // Display::playLogoMovie // minMovieLength is in milliseconds From a48293824cd716cbfb7e1ad62f0626dce8821cb2 Mon Sep 17 00:00:00 2001 From: Mauller <26652186+Mauller@users.noreply.github.com> Date: Fri, 19 Sep 2025 20:52:23 +0100 Subject: [PATCH 2/2] fix(gui): implement resolution scaling for unit health bar and info icons --- .../GameEngine/Include/GameClient/InGameUI.h | 9 ++ .../GameEngine/Include/GameLogic/Object.h | 1 + .../GameEngine/Source/GameClient/Drawable.cpp | 110 +++++++++--------- .../GUI/GUICallbacks/Menus/MainMenu.cpp | 2 + .../GUI/GUICallbacks/Menus/OptionsMenu.cpp | 1 + .../GameEngine/Source/GameClient/InGameUI.cpp | 22 ++++ .../Source/GameLogic/Object/Object.cpp | 8 +- .../Source/WWVegas/WW3D2/render2d.cpp | 23 ++-- 8 files changed, 106 insertions(+), 70 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h index 675fd35f8de..602ae884ec7 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h @@ -584,6 +584,15 @@ friend class Drawable; // for selection/deselection transactions void setDrawRMBScrollAnchor(Bool b) { m_drawRMBScrollAnchor = b; } void setMoveRMBScrollAnchor(Bool b) { m_moveRMBScrollAnchor = b; } + // UI scaling function methods + Real m_unitInfoResolutionScaleFactor; + Real m_healthResolutionScaleFactor; + + void calcUnitInfoScaleFactor(); + + Real getUnitInfoScaleFactor(); + Real getUnitHealthbarScaleFactor(); + private: virtual Int getIdleWorkerCount(); virtual Object *findIdleWorker( Object *obj); diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h index bfdf333393f..06d869d2194 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h +++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h @@ -150,6 +150,7 @@ enum CrushSquishTestType CPP_11(: Int) TEST_CRUSH_OR_SQUISH }; +const Real defaultHealthBoxHeight = 3.0f; // --------------------------------------------------- /** diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp index 40abef67afe..1331e122646 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp @@ -2683,22 +2683,21 @@ static Bool computeHealthRegion( const Drawable *draw, IRegion2D& region ) if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth)) return FALSE; - // scale the health bars according to the zoom - Real zoom = TheTacticalView->getZoom(); - //Real widthScale = 1.3f / zoom; - Real widthScale = 1.0f / zoom; - //Real heightScale = 0.8f / zoom; - Real heightScale = 1.0f; + // scale the health bars according to the zoom and resolution + // TheSuperHacker @info Original zoom at default height had a value of ~1.35 + // Recent changes rebased the zoom to be 1.0 at default height, therefore 1.0 / 1.35 = ~0.74 + Real zoomScale = 0.74f / TheTacticalView->getZoom(); - healthBoxWidth *= widthScale; - healthBoxHeight *= heightScale; + healthBoxWidth *= zoomScale * TheInGameUI->getUnitInfoScaleFactor(); + // TheSuperHackers @info For now we are integer scaling the health box height + healthBoxHeight *= floorf(TheDisplay->getHeightScale()); - // do this so health bar doesn't get too skinny or fat after scaling - //healthBoxHeight = max(3.0f, healthBoxHeight); - healthBoxHeight = 3.0f; + + // do this so health bar doesn't get too skinny after scaling + healthBoxHeight = max(defaultHealthBoxHeight, healthBoxHeight); // figure out the final region for the health box - region.lo.x = screenCenter.x - healthBoxWidth * 0.45f; + region.lo.x = screenCenter.x - healthBoxWidth * 0.5f; region.lo.y = screenCenter.y - healthBoxHeight * 0.5f; region.hi.x = region.lo.x + healthBoxWidth; region.hi.y = region.lo.y + healthBoxHeight; @@ -2831,10 +2830,10 @@ void Drawable::drawEmoticon( const IRegion2D *healthBarRegion ) if( healthBarRegion && getIconInfo()->m_keepTillFrame[ ICON_EMOTICON ] >= now ) { //Draw the emoticon. - Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x; + Int barWidth = healthBarRegion->width(); //Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y; - Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth(); - Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight(); + Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor(); + Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor(); #ifdef SCALE_ICONS_WITH_ZOOM_ML // adjust the width to be a % of the health bar region size @@ -2885,9 +2884,9 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion ) Real scale = 1.0f; #endif - Int boxWidth = REAL_TO_INT(s_emptyAmmo->getImageWidth() * scale); - Int boxHeight = REAL_TO_INT(s_emptyAmmo->getImageHeight() * scale); - const Int SPACING = 1; + Int boxWidth = s_emptyAmmo->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor(); + Int boxHeight = s_emptyAmmo->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor(); + const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor(); //Int totalWidth = (boxWidth+SPACING)*numTotal; ICoord2D screenCenter; @@ -2952,9 +2951,9 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion ) #else Real scale = 1.0f; #endif - Int boxWidth = REAL_TO_INT(s_emptyContainer->getImageWidth() * scale); - Int boxHeight = REAL_TO_INT(s_emptyContainer->getImageHeight() * scale); - const Int SPACING = 1; + Int boxWidth = s_emptyContainer->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor(); + Int boxHeight = s_emptyContainer->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor(); + const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor(); //Int totalWidth = (boxWidth+SPACING)*numTotal; ICoord2D screenCenter; @@ -3005,8 +3004,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion ) getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_BOMBARD ], TheAnim2DCollection ); } //Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y; - Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth(); - Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight(); + Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor(); + Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor(); #ifdef SCALE_ICONS_WITH_ZOOM_ML // adjust the width to be a % of the health bar region size @@ -3033,8 +3032,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion ) getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_HOLDTHELINE ], TheAnim2DCollection ); } // draw the icon - Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth(); - Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight(); + Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor(); + Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor(); #ifdef SCALE_ICONS_WITH_ZOOM_ML // adjust the width to be a % of the health bar region size @@ -3061,8 +3060,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion ) getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_SEARCHANDDESTROY ], TheAnim2DCollection ); } // draw the icon - Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth(); - Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight(); + Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor(); + Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor(); #ifdef SCALE_ICONS_WITH_ZOOM_ML // adjust the width to be a % of the health bar region size @@ -3231,10 +3230,10 @@ void Drawable::drawHealing(const IRegion2D* healthBarRegion) // 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; + Int barWidth = healthBarRegion->width(); - Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth(); - Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight(); + Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor(); + Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor(); #ifdef SCALE_ICONS_WITH_ZOOM_ML // adjust the width to be a % of the health bar region size @@ -3294,7 +3293,7 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion) // 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 + Int barWidth = healthBarRegion->width();// used for position // based on our own kind of we have certain icons to display at a size scale Real scale; @@ -3305,8 +3304,8 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion) else scale = 0.5f; - Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale; - Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale; + Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale * TheInGameUI->getUnitInfoScaleFactor(); + Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale * TheInGameUI->getUnitInfoScaleFactor(); #ifdef SCALE_ICONS_WITH_ZOOM_ML // adjust the width to be a % of the health bar region size @@ -3595,10 +3594,10 @@ void Drawable::drawDisabled(const IRegion2D* healthBarRegion) // draw the icon if( healthBarRegion ) { - Int barHeight = healthBarRegion->hi.y - healthBarRegion->lo.y; + Int barHeight = healthBarRegion->height(); - Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth(); - Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight(); + Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor(); + Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor(); #ifdef SCALE_ICONS_WITH_ZOOM_ML // adjust the width to be a % of the health bar region size @@ -3744,19 +3743,19 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion ) if (!image) return; - Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() ); #ifdef SCALE_ICONS_WITH_ZOOM_ML + Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() ); Real objScale = scale * 1.55f; #else Real objScale = 1.0f; #endif - Real vetBoxWidth = image->getImageWidth()*objScale; - Real vetBoxHeight = image->getImageHeight()*objScale; + Real vetBoxWidth = image->getImageWidth() * objScale * TheInGameUI->getUnitInfoScaleFactor(); + Real vetBoxHeight = image->getImageHeight() * objScale * TheInGameUI->getUnitInfoScaleFactor(); // - // take the center position of the object, go down to it's bottom extent, and project + // take the center position of the health region, go down to it's bottom extent, and project // that point to the screen, that will be the "center" of our veterancy box // @@ -3766,11 +3765,7 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion ) if( !TheTacticalView->worldToScreen( &p, &screenCenter ) ) return; - Real healthBoxWidth, healthBoxHeight; - if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth)) - return; - - screenCenter.x += healthBoxWidth * scale * 0.5f; + screenCenter.x += healthBarRegion->width() * 0.65f; // draw the image TheDisplay->drawImage(image, screenCenter.x + 1, screenCenter.y + 1, screenCenter.x + 1 + vetBoxWidth, screenCenter.y + 1 + vetBoxHeight); @@ -3878,23 +3873,24 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion) } + Real healthBoxWidth = healthBarRegion->width(); + Real healthBoxHeight = max((Int)defaultHealthBoxHeight, healthBarRegion->height()); + // TheSuperHackers @info For now we are integer scaling the health box height so we do the same for the health box outline + Real healthBoxOutlineSize = floorf( (healthBarRegion->height() / (Int)defaultHealthBoxHeight) ); - - -/// Real scale = 1.3f / TheTacticalView->getZoom(); - Real healthBoxWidth = healthBarRegion->hi.x - healthBarRegion->lo.x; - - Real healthBoxHeight = max(3, healthBarRegion->hi.y - healthBarRegion->lo.y); - Real healthBoxOutlineSize = 1.0f; + // draw a filled bar for the health + // TheSuperHackers @info this takes up the whole size of the health rect area, the border is drawn over the top + // This simplifies the handling of the health bar + TheDisplay->drawFillRect( healthBarRegion->lo.x, healthBarRegion->lo.y, + healthBoxWidth * healthRatio, healthBoxHeight, + color ); // draw the health box outline - TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y, healthBoxWidth, healthBoxHeight, + // TheSuperHackers @info when drawing the outline, the underlying function grows the outline towards the center of the region + TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y, + healthBoxWidth, healthBoxHeight, healthBoxOutlineSize, outlineColor ); - // draw a filled bar for the health - TheDisplay->drawFillRect( healthBarRegion->lo.x + 1, healthBarRegion->lo.y + 1, - (healthBoxWidth - 2) * healthRatio, healthBoxHeight - 2, - color ); } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp index 9e4cdbbe79f..113e927f49d 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp @@ -725,6 +725,8 @@ void DeclineResolution() TheShell->recreateWindowLayouts(); TheInGameUI->recreateControlBar(); + TheInGameUI->refreshCustomUiResources(); + TheInGameUI->calcUnitInfoScaleFactor(); } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index 2c26f935a9f..32d46f111ff 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -848,6 +848,7 @@ static void saveOptions() TheInGameUI->recreateControlBar(); TheInGameUI->refreshCustomUiResources(); + TheInGameUI->calcUnitInfoScaleFactor(); } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp index 3006f1d226f..81fa4cae18b 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp @@ -1265,6 +1265,9 @@ InGameUI::InGameUI() m_soloNexusSelectedDrawableID = INVALID_DRAWABLE_ID; + m_unitInfoResolutionScaleFactor = 1.0f; + m_healthResolutionScaleFactor = 1.0f; + } //------------------------------------------------------------------------------------------------- @@ -1401,6 +1404,9 @@ void InGameUI::init() setDrawRMBScrollAnchor(TheGlobalData->m_drawScrollAnchor); setMoveRMBScrollAnchor(TheGlobalData->m_moveScrollAnchor); + // TheSuperHackers @todo implement option to retrieve user based scaling options + calcUnitInfoScaleFactor(); + } //------------------------------------------------------------------------------------------------- @@ -6374,3 +6380,19 @@ void InGameUI::drawPlayerInfoList() drawY += lineH; } } + +void InGameUI::calcUnitInfoScaleFactor() +{ + m_unitInfoResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale()); + m_healthResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale()); +} + +Real InGameUI::getUnitInfoScaleFactor() +{ + return m_unitInfoResolutionScaleFactor; +} + +Real InGameUI::getUnitHealthbarScaleFactor() +{ + return m_healthResolutionScaleFactor; +} diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp index 0a03557b1b3..dac3cb90a96 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -3432,7 +3432,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth) if( isKindOf( KINDOF_STRUCTURE ) ) { //enforce healthBoxHeightMinimum/Maximum - healthBoxHeight = min(3.0f, max(5.0f, maxHP/50)); + healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50)); //enforce healthBoxWidthMinimum/Maximum healthBoxWidth = min(150.0f, max(100.0f, maxHP/10)); return true; @@ -3440,7 +3440,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth) else if ( isKindOf(KINDOF_MOB_NEXUS) ) { //enforce healthBoxHeightMinimum/Maximum - healthBoxHeight = min(3.0f, max(5.0f, maxHP/50)); + healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50)); //enforce healthBoxWidthMinimum/Maximum healthBoxWidth = min(100.0f, max(66.0f, maxHP/10)); return true; @@ -3454,7 +3454,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth) else { //enforce healthBoxHeightMinimum/Maximum - healthBoxHeight = min(3.0f, max(5.0f, maxHP/50)); + healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50)); //enforce healthBoxWidthMinimum/Maximum healthBoxWidth = min(150.0f, max(35.0f, maxHP/10)); return true; @@ -3470,7 +3470,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth) //just add the major and minor axes Real size = MAX(20.0f, MIN(150.0f, (getGeometryInfo().getMajorRadius() + getGeometryInfo().getMinorRadius())) ); - healthBoxHeight = 3.0f; + healthBoxHeight = defaultHealthBoxHeight; healthBoxWidth = MAX(20.0f, size * 2.0f); return TRUE; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp index 0266f747df9..66ebf34ff3c 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp @@ -587,15 +587,20 @@ void Render2DClass::Add_Outline( const RectClass & rect, float width, unsigned l void Render2DClass::Add_Outline( const RectClass & rect, float width, const RectClass & uv, unsigned long color ) { - // - // Pretty straight forward, simply add the four side of the rectangle as lines. - // - /** @todo colin, I had to tweak these to get precise line drawing, as we want - the UV bias on, but it just isn't lining up */ - Add_Line (Vector2 (rect.Left + 1, rect.Bottom), Vector2 (rect.Left + 1, rect.Top + 1), width, color); - Add_Line (Vector2 (rect.Left, rect.Top + 1), Vector2 (rect.Right - 1, rect.Top + 1), width, color); - Add_Line (Vector2 (rect.Right, rect.Top), Vector2 (rect.Right, rect.Bottom - 1), width, color); - Add_Line (Vector2 (rect.Right, rect.Bottom), Vector2 (rect.Left + 1, rect.Bottom), width, color); + // Pretty straight forward, add the four side of the rectangle as lines. + float lineWidthOffset = (width / 2); + + // TheSuperHackers @bugfix fixed the lines so they overlap eachother in the corners making a full rectangle + // Also offset the lines by half of their thickness so the border grows into the center of the rectangle + + // Draw left + Add_Line (Vector2 (rect.Left + lineWidthOffset, rect.Bottom), Vector2 (rect.Left + lineWidthOffset, rect.Top), width, color); + // Draw top + Add_Line (Vector2 (rect.Left, rect.Top + lineWidthOffset), Vector2 (rect.Right, rect.Top + lineWidthOffset), width, color); + // Draw right + Add_Line (Vector2 (rect.Right - lineWidthOffset, rect.Top), Vector2 (rect.Right - lineWidthOffset, rect.Bottom), width, color); + // Draw bottom + Add_Line (Vector2 (rect.Right, rect.Bottom - lineWidthOffset), Vector2 (rect.Left, rect.Bottom - lineWidthOffset), width, color); } void Render2DClass::Render()