Skip to content

Commit 33cdc71

Browse files
committed
Handle health rect using float coords down to the rendering
1 parent f7f2ee4 commit 33cdc71

File tree

8 files changed

+312
-43
lines changed

8 files changed

+312
-43
lines changed

GeneralsMD/Code/GameEngine/Include/GameClient/Display.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,15 @@ class Display : public SubsystemInterface
136136
/// draw a rect border on the display in pixel coordinates with the specified color
137137
virtual void drawOpenRect( Int startX, Int startY, Int width, Int height,
138138
Real lineWidth, UnsignedInt lineColor ) = 0;
139+
/// draw a rect border on the display in pixel coordinates with the specified color
140+
virtual void drawOpenRect( Real startX, Real startY, Real width, Real height,
141+
Real lineWidth, UnsignedInt lineColor) = 0;
139142
/// draw a filled rect on the display in pixel coords with the specified color
140143
virtual void drawFillRect( Int startX, Int startY, Int width, Int height,
141144
UnsignedInt color ) = 0;
145+
/// draw a filled rect on the display in float pixel coords with the specified color
146+
virtual void drawFillRect( Real startX, Real startY, Real width, Real height,
147+
UnsignedInt color ) = 0;
142148

143149
/// Draw a percentage of a rectange, much like a clock
144150
virtual void drawRectClock(Int startX, Int startY, Int width, Int height, Int percent, UnsignedInt color) = 0;

GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -756,22 +756,22 @@ class Drawable : public Thing,
756756
void drawUIText( void ); ///< draw the group number of this unit // public so gameclient can call
757757
private:
758758
// "icon" drawing methods **************
759-
void drawConstructPercent( const IRegion2D *healthBarRegion ); ///< display % construction complete
760-
void drawCaption( const IRegion2D *healthBarRegion ); ///< draw caption
761-
void drawAmmo( const IRegion2D *healthBarRegion ); ///< draw icons
762-
void drawContained( const IRegion2D *healthBarRegion ); ///< draw icons
763-
void drawVeterancy( const IRegion2D *healthBarRegion ); ///< draw veterency information
764-
765-
void drawEmoticon( const IRegion2D* healthBarRegion );
766-
void drawHealthBar( const IRegion2D* healthBarRegion ); ///< draw heath bar
767-
void drawHealing( const IRegion2D* healthBarRegion ); ///< draw icons
768-
void drawEnthusiastic( const IRegion2D* healthBarRegin ); ///< draw icons
759+
void drawConstructPercent( const Region2D *healthBarRegion ); ///< display % construction complete
760+
void drawCaption( const Region2D *healthBarRegion ); ///< draw caption
761+
void drawAmmo( const Region2D *healthBarRegion ); ///< draw icons
762+
void drawContained( const Region2D *healthBarRegion ); ///< draw icons
763+
void drawVeterancy( const Region2D *healthBarRegion ); ///< draw veterency information
764+
765+
void drawEmoticon( const Region2D* healthBarRegion );
766+
void drawHealthBar( const Region2D* healthBarRegion ); ///< draw heath bar
767+
void drawHealing( const Region2D* healthBarRegion ); ///< draw icons
768+
void drawEnthusiastic( const Region2D* healthBarRegin ); ///< draw icons
769769
#ifdef ALLOW_DEMORALIZE
770-
void drawDemoralized( const IRegion2D* healthBarRegion ); ///< draw icons
770+
void drawDemoralized( const Region2D* healthBarRegion ); ///< draw icons
771771
#endif
772-
void drawBombed( const IRegion2D* healthBarRegion ); ///< draw icons
773-
void drawDisabled( const IRegion2D* healthBarRegion ); ///< draw icons
774-
void drawBattlePlans( const IRegion2D* healthBarRegion ); ///< Icons rendering for active battle plan statii
772+
void drawBombed( const Region2D* healthBarRegion ); ///< draw icons
773+
void drawDisabled( const Region2D* healthBarRegion ); ///< draw icons
774+
void drawBattlePlans( const Region2D* healthBarRegion ); ///< Icons rendering for active battle plan statii
775775

776776
Bool drawsAnyUIText( void );
777777

GeneralsMD/Code/GameEngine/Include/GameClient/Line2D.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ typedef std::vector<ICoord3D> Coord3DVector;
3737
extern Bool ClipLine2D( ICoord2D *p1, ICoord2D *p2, ICoord2D *c1, ICoord2D *c2,
3838
IRegion2D *clipRegion );
3939

40+
extern Bool ClipLine2D(Coord2D* p1, Coord2D* p2, Coord2D* c1, Coord2D* c2,
41+
IRegion2D* clipRegion);
42+
4043
///< IntersectLine2D will take two segments delimited by ab and cd and will return whether
4144
///< they intersect within the length of ab. They will also return the intersection point out
4245
///< intersection if it is non-NULL.

GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,7 +2664,7 @@ void Drawable::draw()
26642664
/** Compute the health bar region based on the health of the object and the
26652665
* zoom level of the camera */
26662666
// ------------------------------------------------------------------------------------------------
2667-
static Bool computeHealthRegion( const Drawable *draw, IRegion2D& region )
2667+
static Bool computeHealthRegion( const Drawable *draw, Region2D& region )
26682668
{
26692669

26702670
// sanity
@@ -2740,8 +2740,8 @@ void Drawable::drawIconUI( void )
27402740
{
27412741
if( TheGameLogic->getDrawIconUI() && (TheScriptEngine->getFade()==ScriptEngine::FADE_NONE) )
27422742
{
2743-
IRegion2D healthBarRegionStorage;
2744-
const IRegion2D* healthBarRegion = NULL;
2743+
Region2D healthBarRegionStorage;
2744+
const Region2D* healthBarRegion = NULL;
27452745
if (computeHealthRegion(this, healthBarRegionStorage))
27462746
healthBarRegion = &healthBarRegionStorage; //both data and a PointerAsFlag for logic in the methods below
27472747

@@ -2824,7 +2824,7 @@ void Drawable::setEmoticon( const AsciiString &name, Int duration )
28242824
}
28252825

28262826
//------------------------------------------------------------------------------------------------
2827-
void Drawable::drawEmoticon( const IRegion2D *healthBarRegion )
2827+
void Drawable::drawEmoticon( const Region2D *healthBarRegion )
28282828
{
28292829
if( hasIconInfo() && getIconInfo()->m_icon[ ICON_EMOTICON ] )
28302830
{
@@ -2859,7 +2859,7 @@ void Drawable::drawEmoticon( const IRegion2D *healthBarRegion )
28592859

28602860
// ------------------------------------------------------------------------------------------------
28612861
// ------------------------------------------------------------------------------------------------
2862-
void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
2862+
void Drawable::drawAmmo( const Region2D *healthBarRegion )
28632863
{
28642864
const Object *obj = getObject();
28652865

@@ -2913,7 +2913,7 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
29132913

29142914
// ------------------------------------------------------------------------------------------------
29152915
// ------------------------------------------------------------------------------------------------
2916-
void Drawable::drawContained( const IRegion2D *healthBarRegion )
2916+
void Drawable::drawContained( const Region2D *healthBarRegion )
29172917
{
29182918
const Object *obj = getObject();
29192919

@@ -2987,7 +2987,7 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion )
29872987
}
29882988

29892989
//-------------------------------------------------------------------------------------------------
2990-
void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
2990+
void Drawable::drawBattlePlans( const Region2D *healthBarRegion )
29912991
{
29922992
Object *obj = getObject();
29932993
if( !obj || !healthBarRegion )
@@ -3096,8 +3096,8 @@ void Drawable::drawUIText()
30963096
// GameClient caches a list of us drawables during Drawablepostdraw()
30973097
// then our group numbers get spit out last, so they draw in front
30983098

3099-
const IRegion2D* healthBarRegion = NULL;
3100-
IRegion2D healthBarRegionStorage;
3099+
const Region2D* healthBarRegion = NULL;
3100+
Region2D healthBarRegionStorage;
31013101
if (computeHealthRegion(this, healthBarRegionStorage))
31023102
healthBarRegion = &healthBarRegionStorage; //both data and a PointerAsFlag for logic in the methods below
31033103

@@ -3210,7 +3210,7 @@ void Drawable::drawUIText()
32103210

32113211
// ------------------------------------------------------------------------------------------------
32123212
// ------------------------------------------------------------------------------------------------
3213-
void Drawable::drawHealing(const IRegion2D* healthBarRegion)
3213+
void Drawable::drawHealing(const Region2D* healthBarRegion)
32143214
{
32153215

32163216
const Object *obj = getObject();
@@ -3304,7 +3304,7 @@ void Drawable::drawHealing(const IRegion2D* healthBarRegion)
33043304
// ------------------------------------------------------------------------------------------------
33053305
/** This enthusiastic effect is TEMPORARY for the multiplayer test */
33063306
// ------------------------------------------------------------------------------------------------
3307-
void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
3307+
void Drawable::drawEnthusiastic(const Region2D* healthBarRegion)
33083308
{
33093309

33103310
const Object *obj = getObject();
@@ -3376,7 +3376,7 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
33763376
#ifdef ALLOW_DEMORALIZE
33773377
// ------------------------------------------------------------------------------------------------
33783378
// ------------------------------------------------------------------------------------------------
3379-
void Drawable::drawDemoralized(const IRegion2D* healthBarRegion)
3379+
void Drawable::drawDemoralized(const Region2D* healthBarRegion)
33803380
{
33813381

33823382
const Object *obj = getObject();
@@ -3433,7 +3433,7 @@ enum
34333433
};
34343434
// ------------------------------------------------------------------------------------------------
34353435
// ------------------------------------------------------------------------------------------------
3436-
void Drawable::drawBombed(const IRegion2D* healthBarRegion)
3436+
void Drawable::drawBombed(const Region2D* healthBarRegion)
34373437
{
34383438

34393439
const Object *obj = getObject();
@@ -3612,7 +3612,7 @@ void Drawable::drawBombed(const IRegion2D* healthBarRegion)
36123612
// ------------------------------------------------------------------------------------------------
36133613
/** Draw any icon information that needs to be drawn */
36143614
// ------------------------------------------------------------------------------------------------
3615-
void Drawable::drawDisabled(const IRegion2D* healthBarRegion)
3615+
void Drawable::drawDisabled(const Region2D* healthBarRegion)
36163616
{
36173617

36183618
const Object *obj = getObject();
@@ -3670,7 +3670,7 @@ void Drawable::drawDisabled(const IRegion2D* healthBarRegion)
36703670
//-------------------------------------------------------------------------------------------------
36713671
/** Draw construction percent for drawables that have objects that are "under construction" */
36723672
//-------------------------------------------------------------------------------------------------
3673-
void Drawable::drawConstructPercent( const IRegion2D *healthBarRegion )
3673+
void Drawable::drawConstructPercent( const Region2D *healthBarRegion )
36743674
{
36753675

36763676
// this data is in an attached object
@@ -3735,7 +3735,7 @@ void Drawable::drawConstructPercent( const IRegion2D *healthBarRegion )
37353735
//-------------------------------------------------------------------------------------------------
37363736
/** Draw caption */
37373737
//-------------------------------------------------------------------------------------------------
3738-
void Drawable::drawCaption( const IRegion2D *healthBarRegion )
3738+
void Drawable::drawCaption( const Region2D *healthBarRegion )
37393739
{
37403740
if (!m_captionDisplayString)
37413741
return;
@@ -3771,7 +3771,7 @@ void Drawable::drawCaption( const IRegion2D *healthBarRegion )
37713771
// ------------------------------------------------------------------------------------------------
37723772
/** Draw any veterency markers that should be displayed */
37733773
// ------------------------------------------------------------------------------------------------
3774-
void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
3774+
void Drawable::drawVeterancy( const Region2D *healthBarRegion )
37753775
{
37763776
// get object from drawble
37773777
Object* obj = getObject();
@@ -3819,7 +3819,7 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
38193819
// ------------------------------------------------------------------------------------------------
38203820
/** Draw health bar information for drawable */
38213821
// ------------------------------------------------------------------------------------------------
3822-
void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
3822+
void Drawable::drawHealthBar(const Region2D* healthBarRegion)
38233823
{
38243824
if (!healthBarRegion)
38253825
return;
@@ -3918,9 +3918,18 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
39183918
}
39193919

39203920
Real healthBoxWidth = healthBarRegion->width();
3921-
Real healthBoxHeight = max((Int)defaultHealthBoxHeight, healthBarRegion->height());
3921+
Real healthBoxHeight = max(defaultHealthBoxHeight, healthBarRegion->height());
39223922
Real healthBoxOutlineSize = floorf(1.0f * TheInGameUI->getUnitHealthbarScaleFactor());
39233923

3924+
//TheDisplay->drawFillRect( healthBarRegion->lo.x - 2, healthBarRegion->lo.y - 12,
3925+
// healthBoxWidth + 5, healthBoxHeight + 5,
3926+
// GameMakeColor(255,0,0,255) );
3927+
3928+
//TheDisplay->drawFillRectf( healthBarRegion->lo.x, healthBarRegion->lo.y - 10,
3929+
// healthBoxWidth * healthRatio, 4.6,
3930+
// color );
3931+
3932+
39243933
// draw a filled bar for the health
39253934
// TheSuperHackers @info this takes up the whole size of the health rect area, the border is drawn over the top
39263935
// This simplifies the handling of the health bar
@@ -3930,12 +3939,12 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
39303939

39313940
// draw the health blend line but only for intermediate resolutions
39323941
// TheSuperHackers @info we adjust the line down by the thickness of the border to keep it with one line of exposed pixels
3933-
if (fmod(healthBoxHeight, defaultHealthBoxHeight) > 0.0f) {
3934-
Color outlineBlendColor = outlineColor - 0x77000000;
3935-
TheDisplay->drawLine( healthBarRegion->lo.x, healthBarRegion->lo.y + healthBoxOutlineSize,
3936-
healthBarRegion->lo.x + healthBoxWidth * healthRatio, healthBarRegion->lo.y + healthBoxOutlineSize,
3937-
healthBoxOutlineSize + 1.0f, outlineBlendColor);
3938-
}
3942+
//if (fmod(healthBoxHeight, defaultHealthBoxHeight) > 0.0f) {
3943+
// Color outlineBlendColor = outlineColor - 0x77000000;
3944+
// TheDisplay->drawLine( healthBarRegion->lo.x, healthBarRegion->lo.y + healthBoxOutlineSize,
3945+
// healthBarRegion->lo.x + healthBoxWidth * healthRatio, healthBarRegion->lo.y + healthBoxOutlineSize,
3946+
// healthBoxOutlineSize + 1.0f, outlineBlendColor);
3947+
//}
39393948

39403949
// draw the health box outline
39413950
// TheSuperHackers @info when drawing the outline, the underlying function grows the outline towards the center of the region

0 commit comments

Comments
 (0)