Skip to content

Commit 58d6451

Browse files
committed
Handle health rect using float coords down to the rendering
1 parent f8af912 commit 58d6451

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
@@ -134,9 +134,15 @@ class Display : public SubsystemInterface
134134
/// draw a rect border on the display in pixel coordinates with the specified color
135135
virtual void drawOpenRect( Int startX, Int startY, Int width, Int height,
136136
Real lineWidth, UnsignedInt lineColor ) = 0;
137+
/// draw a rect border on the display in pixel coordinates with the specified color
138+
virtual void drawOpenRect( Real startX, Real startY, Real width, Real height,
139+
Real lineWidth, UnsignedInt lineColor) = 0;
137140
/// draw a filled rect on the display in pixel coords with the specified color
138141
virtual void drawFillRect( Int startX, Int startY, Int width, Int height,
139142
UnsignedInt color ) = 0;
143+
/// draw a filled rect on the display in float pixel coords with the specified color
144+
virtual void drawFillRect( Real startX, Real startY, Real width, Real height,
145+
UnsignedInt color ) = 0;
140146

141147
/// Draw a percentage of a rectange, much like a clock
142148
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
@@ -2656,7 +2656,7 @@ void Drawable::draw()
26562656
/** Compute the health bar region based on the health of the object and the
26572657
* zoom level of the camera */
26582658
// ------------------------------------------------------------------------------------------------
2659-
static Bool computeHealthRegion( const Drawable *draw, IRegion2D& region )
2659+
static Bool computeHealthRegion( const Drawable *draw, Region2D& region )
26602660
{
26612661

26622662
// sanity
@@ -2732,8 +2732,8 @@ void Drawable::drawIconUI( void )
27322732
{
27332733
if( TheGameLogic->getDrawIconUI() && (TheScriptEngine->getFade()==ScriptEngine::FADE_NONE) )
27342734
{
2735-
IRegion2D healthBarRegionStorage;
2736-
const IRegion2D* healthBarRegion = NULL;
2735+
Region2D healthBarRegionStorage;
2736+
const Region2D* healthBarRegion = NULL;
27372737
if (computeHealthRegion(this, healthBarRegionStorage))
27382738
healthBarRegion = &healthBarRegionStorage; //both data and a PointerAsFlag for logic in the methods below
27392739

@@ -2816,7 +2816,7 @@ void Drawable::setEmoticon( const AsciiString &name, Int duration )
28162816
}
28172817

28182818
//------------------------------------------------------------------------------------------------
2819-
void Drawable::drawEmoticon( const IRegion2D *healthBarRegion )
2819+
void Drawable::drawEmoticon( const Region2D *healthBarRegion )
28202820
{
28212821
if( hasIconInfo() && getIconInfo()->m_icon[ ICON_EMOTICON ] )
28222822
{
@@ -2851,7 +2851,7 @@ void Drawable::drawEmoticon( const IRegion2D *healthBarRegion )
28512851

28522852
// ------------------------------------------------------------------------------------------------
28532853
// ------------------------------------------------------------------------------------------------
2854-
void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
2854+
void Drawable::drawAmmo( const Region2D *healthBarRegion )
28552855
{
28562856
const Object *obj = getObject();
28572857

@@ -2905,7 +2905,7 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
29052905

29062906
// ------------------------------------------------------------------------------------------------
29072907
// ------------------------------------------------------------------------------------------------
2908-
void Drawable::drawContained( const IRegion2D *healthBarRegion )
2908+
void Drawable::drawContained( const Region2D *healthBarRegion )
29092909
{
29102910
const Object *obj = getObject();
29112911

@@ -2979,7 +2979,7 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion )
29792979
}
29802980

29812981
//-------------------------------------------------------------------------------------------------
2982-
void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
2982+
void Drawable::drawBattlePlans( const Region2D *healthBarRegion )
29832983
{
29842984
Object *obj = getObject();
29852985
if( !obj || !healthBarRegion )
@@ -3088,8 +3088,8 @@ void Drawable::drawUIText()
30883088
// GameClient caches a list of us drawables during Drawablepostdraw()
30893089
// then our group numbers get spit out last, so they draw in front
30903090

3091-
const IRegion2D* healthBarRegion = NULL;
3092-
IRegion2D healthBarRegionStorage;
3091+
const Region2D* healthBarRegion = NULL;
3092+
Region2D healthBarRegionStorage;
30933093
if (computeHealthRegion(this, healthBarRegionStorage))
30943094
healthBarRegion = &healthBarRegionStorage; //both data and a PointerAsFlag for logic in the methods below
30953095

@@ -3202,7 +3202,7 @@ void Drawable::drawUIText()
32023202

32033203
// ------------------------------------------------------------------------------------------------
32043204
// ------------------------------------------------------------------------------------------------
3205-
void Drawable::drawHealing(const IRegion2D* healthBarRegion)
3205+
void Drawable::drawHealing(const Region2D* healthBarRegion)
32063206
{
32073207

32083208
const Object *obj = getObject();
@@ -3296,7 +3296,7 @@ void Drawable::drawHealing(const IRegion2D* healthBarRegion)
32963296
// ------------------------------------------------------------------------------------------------
32973297
/** This enthusiastic effect is TEMPORARY for the multiplayer test */
32983298
// ------------------------------------------------------------------------------------------------
3299-
void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
3299+
void Drawable::drawEnthusiastic(const Region2D* healthBarRegion)
33003300
{
33013301

33023302
const Object *obj = getObject();
@@ -3368,7 +3368,7 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
33683368
#ifdef ALLOW_DEMORALIZE
33693369
// ------------------------------------------------------------------------------------------------
33703370
// ------------------------------------------------------------------------------------------------
3371-
void Drawable::drawDemoralized(const IRegion2D* healthBarRegion)
3371+
void Drawable::drawDemoralized(const Region2D* healthBarRegion)
33723372
{
33733373

33743374
const Object *obj = getObject();
@@ -3425,7 +3425,7 @@ enum
34253425
};
34263426
// ------------------------------------------------------------------------------------------------
34273427
// ------------------------------------------------------------------------------------------------
3428-
void Drawable::drawBombed(const IRegion2D* healthBarRegion)
3428+
void Drawable::drawBombed(const Region2D* healthBarRegion)
34293429
{
34303430

34313431
const Object *obj = getObject();
@@ -3604,7 +3604,7 @@ void Drawable::drawBombed(const IRegion2D* healthBarRegion)
36043604
// ------------------------------------------------------------------------------------------------
36053605
/** Draw any icon information that needs to be drawn */
36063606
// ------------------------------------------------------------------------------------------------
3607-
void Drawable::drawDisabled(const IRegion2D* healthBarRegion)
3607+
void Drawable::drawDisabled(const Region2D* healthBarRegion)
36083608
{
36093609

36103610
const Object *obj = getObject();
@@ -3662,7 +3662,7 @@ void Drawable::drawDisabled(const IRegion2D* healthBarRegion)
36623662
//-------------------------------------------------------------------------------------------------
36633663
/** Draw construction percent for drawables that have objects that are "under construction" */
36643664
//-------------------------------------------------------------------------------------------------
3665-
void Drawable::drawConstructPercent( const IRegion2D *healthBarRegion )
3665+
void Drawable::drawConstructPercent( const Region2D *healthBarRegion )
36663666
{
36673667

36683668
// this data is in an attached object
@@ -3727,7 +3727,7 @@ void Drawable::drawConstructPercent( const IRegion2D *healthBarRegion )
37273727
//-------------------------------------------------------------------------------------------------
37283728
/** Draw caption */
37293729
//-------------------------------------------------------------------------------------------------
3730-
void Drawable::drawCaption( const IRegion2D *healthBarRegion )
3730+
void Drawable::drawCaption( const Region2D *healthBarRegion )
37313731
{
37323732
if (!m_captionDisplayString)
37333733
return;
@@ -3763,7 +3763,7 @@ void Drawable::drawCaption( const IRegion2D *healthBarRegion )
37633763
// ------------------------------------------------------------------------------------------------
37643764
/** Draw any veterency markers that should be displayed */
37653765
// ------------------------------------------------------------------------------------------------
3766-
void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
3766+
void Drawable::drawVeterancy( const Region2D *healthBarRegion )
37673767
{
37683768
// get object from drawble
37693769
Object* obj = getObject();
@@ -3811,7 +3811,7 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
38113811
// ------------------------------------------------------------------------------------------------
38123812
/** Draw health bar information for drawable */
38133813
// ------------------------------------------------------------------------------------------------
3814-
void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
3814+
void Drawable::drawHealthBar(const Region2D* healthBarRegion)
38153815
{
38163816
if (!healthBarRegion)
38173817
return;
@@ -3910,9 +3910,18 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
39103910
}
39113911

39123912
Real healthBoxWidth = healthBarRegion->width();
3913-
Real healthBoxHeight = max((Int)defaultHealthBoxHeight, healthBarRegion->height());
3913+
Real healthBoxHeight = max(defaultHealthBoxHeight, healthBarRegion->height());
39143914
Real healthBoxOutlineSize = floorf(1.0f * TheInGameUI->getUnitHealthbarScaleFactor());
39153915

3916+
//TheDisplay->drawFillRect( healthBarRegion->lo.x - 2, healthBarRegion->lo.y - 12,
3917+
// healthBoxWidth + 5, healthBoxHeight + 5,
3918+
// GameMakeColor(255,0,0,255) );
3919+
3920+
//TheDisplay->drawFillRectf( healthBarRegion->lo.x, healthBarRegion->lo.y - 10,
3921+
// healthBoxWidth * healthRatio, 4.6,
3922+
// color );
3923+
3924+
39163925
// draw a filled bar for the health
39173926
// TheSuperHackers @info this takes up the whole size of the health rect area, the border is drawn over the top
39183927
// This simplifies the handling of the health bar
@@ -3922,12 +3931,12 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
39223931

39233932
// draw the health blend line but only for intermediate resolutions
39243933
// TheSuperHackers @info we adjust the line down by the thickness of the border to keep it with one line of exposed pixels
3925-
if (fmod(healthBoxHeight, defaultHealthBoxHeight) > 0.0f) {
3926-
Color outlineBlendColor = outlineColor - 0x77000000;
3927-
TheDisplay->drawLine( healthBarRegion->lo.x, healthBarRegion->lo.y + healthBoxOutlineSize,
3928-
healthBarRegion->lo.x + healthBoxWidth * healthRatio, healthBarRegion->lo.y + healthBoxOutlineSize,
3929-
healthBoxOutlineSize + 1.0f, outlineBlendColor);
3930-
}
3934+
//if (fmod(healthBoxHeight, defaultHealthBoxHeight) > 0.0f) {
3935+
// Color outlineBlendColor = outlineColor - 0x77000000;
3936+
// TheDisplay->drawLine( healthBarRegion->lo.x, healthBarRegion->lo.y + healthBoxOutlineSize,
3937+
// healthBarRegion->lo.x + healthBoxWidth * healthRatio, healthBarRegion->lo.y + healthBoxOutlineSize,
3938+
// healthBoxOutlineSize + 1.0f, outlineBlendColor);
3939+
//}
39313940

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

0 commit comments

Comments
 (0)