-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customizable Bars of Health Points #1395
base: develop
Are you sure you want to change the base?
Conversation
Initial commit
Nightly build for this pull request:
This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build. |
Those voxels are quite nice and seem to resemble the look and feel of the original game voxels. Did you make those voxels yourself? |
yep |
nice feature for epic vehicle/airship/battleship :) |
Couple of suggestions on the general API stuff: For technos the tag should be I think shields should use that too. |
P.S. Can you do any shape/direction bars this way? I think it's a matter of making the section offset customizable in two dimensions, this way you could specify the 2,2 offset and have the bar go diagonal for example. |
The horizontal (vanilla like) bars were first in mind. I understand vertical ones, but diagonal... |
It's only an example. The point is that if one can specify offset between sections in 2 dimensions then they can come up with whatever weird graphics they want, including diagonal bars, sectioned graphics etc. |
I think, I probably should make some "BarMaker" then, like procedure to draw by position and type. |
#1287 #1309 #1395 |
yeah, so the bars can be used to draw without hovering/selecting. i'm just using bar-drawer in the vanilla health part code. So it behaves like vanilla health bar. |
I mean you can go more aggressive than that, just replace all 4 DrawHealthBar vtbl calls and handle it as well as other things in drawextras. |
- added emptypip - added draw direction - added border offset - changed overall logic
DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->BoardBG_File.Get(), | ||
0, &boardPosition, pBounds, BlitterFlags(0xE00) | blitFlagsBG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please elaborate blitterflags:
BlitterFlags::MultiPass | BlitterFlags::Centered | BlitterFlags::bf_400
{ | ||
position += drawBackwards ? -sectionOffset : sectionOffset; | ||
DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), | ||
sectionEmptyFrame, &position, pBounds, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above for the flags.
{ | ||
position += drawBackwards ? -sectionOffset : sectionOffset; | ||
DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), | ||
frameIdxa, &position, pBounds, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above for the flags.
|
||
if(barType->BoardFG_File && (pThis->IsSelected || barType->BoardFG_ShowWhenNotSelected)) | ||
DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, barType->BoardFG_File.Get(), | ||
0, &boardPosition, pBounds, BlitterFlags(0xE00) | blitFlagsFG, 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above for the flags.
Nullable<SHPStruct*> BoardBG_File; | ||
Valueable<bool> BoardBG_ShowWhenNotSelected; | ||
Nullable<TranslucencyLevel> BoardBG_Translucency; | ||
Nullable<SHPStruct*> BoardFG_File; | ||
Valueable<bool> BoardFG_ShowWhenNotSelected; | ||
Nullable<TranslucencyLevel> BoardFG_Translucency; | ||
Valueable<Vector2D<int>> Board_Offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Board -> Frame?
also BG/FG -> Background/Foreground, please
if(sectionEmptyFrame != -1) | ||
{ | ||
for(int i = 0; i < sectionAmount; ++i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(sectionEmptyFrame != -1) | |
{ | |
for(int i = 0; i < sectionAmount; ++i) | |
if (sectionEmptyFrame != -1) | |
{ | |
for (int i = 0; i < sectionAmount; ++i) |
if(drawBackwards) | ||
for(int i = 0; i < (sectionAmount - sectionsToDraw); ++i) | ||
position -= sectionOffset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(drawBackwards) | |
for(int i = 0; i < (sectionAmount - sectionsToDraw); ++i) | |
position -= sectionOffset; | |
if (drawBackwards) | |
{ | |
for (int i = 0; i < (sectionAmount - sectionsToDraw); ++i) | |
position -= sectionOffset; | |
} |
for(int i = 0; i < (sectionAmount - sectionsToDraw); ++i) | ||
position -= sectionOffset; | ||
|
||
for(int i = 0; i < sectionsToDraw; ++i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for(int i = 0; i < sectionsToDraw; ++i) | |
for (int i = 0; i < sectionsToDraw; ++i) |
, Board_Offset { { 0,0 } } | ||
, Bar_Offset { { 0,0 } } | ||
, Sections_DrawBackwards { false } | ||
, Sections_Pips { { 16,17,18 } } | ||
, Sections_EmptyPip { -1 } | ||
, Sections_Amount { 17 } | ||
, Sections_PositionDelta { { 2,0 } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, Board_Offset { { 0,0 } } | |
, Bar_Offset { { 0,0 } } | |
, Sections_DrawBackwards { false } | |
, Sections_Pips { { 16,17,18 } } | |
, Sections_EmptyPip { -1 } | |
, Sections_Amount { 17 } | |
, Sections_PositionDelta { { 2,0 } } | |
, Board_Offset { { 0, 0 } } | |
, Bar_Offset { { 0, 0 } } | |
, Sections_DrawBackwards { false } | |
, Sections_Pips { { 16, 17, 18 } } | |
, Sections_EmptyPip { -1 } | |
, Sections_Amount { 17 } | |
, Sections_PositionDelta { { 2, 0 } } |
if(!pTypeExt->HealthBar_BarType) | ||
{ | ||
R->AL(pThis->IsSelected); | ||
if(pThisIsInf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(pThisIsInf) | |
if (pThisIsInf) |
frameIdxa, &position, pBounds, BlitterFlags(0x600), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0); | ||
} | ||
|
||
if(barType->BoardFG_File && (pThis->IsSelected || barType->BoardFG_ShowWhenNotSelected)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(barType->BoardFG_File && (pThis->IsSelected || barType->BoardFG_ShowWhenNotSelected)) | |
if (barType->BoardFG_File && (pThis->IsSelected || barType->BoardFG_ShowWhenNotSelected)) |
@@ -168,6 +168,7 @@ class TechnoExt | |||
static Point2D GetBuildingSelectBracketPosition(TechnoClass* pThis, BuildingSelectBracketPosition bracketPosition); | |||
static void ProcessDigitalDisplays(TechnoClass* pThis); | |||
static void GetValuesForDisplay(TechnoClass* pThis, DisplayInfoType infoType, int& value, int& maxValue); | |||
static void DrawBar(TechnoClass* pThis, BarTypeClass* barType, Point2D pLocation, RectangleStruct* pBounds, double barPercentage, double yellowCond, double redCond); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conditionYellow
and conditionRed
maybe?
position.X += drawBackwards ? (int)round(sectionAmount * sectionOffset.X / 2) : -(int)round(sectionAmount * sectionOffset.X / 2); | ||
position.Y += drawBackwards ? (int)round(sectionAmount * sectionOffset.Y / 2) : -(int)round(sectionAmount * sectionOffset.Y / 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Pretty sure you can do math with vectors like normal, you don't need to duplicate it for each coord.
- Instead of a ternary operator and duplication everywhere where you need to decide on the direction of draw you can do
int sign = drawBackwards * -2 + 1;
and multiply by that every time you used a ternary here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all applies to multiple lines in the code btw, forgot to comment on all of them, please see where it is applicable because there's a lot of duplication going on.
for(int i = 0; i < sectionAmount; ++i) | ||
{ | ||
position += drawBackwards ? -sectionOffset : sectionOffset; | ||
DSurface::Temp->DrawSHP(FileSystem::PALETTE_PAL, FileSystem::PIPS_SHP(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could make pips.shp
customizable too?
Nullable<TranslucencyLevel> BoardBG_Translucency; | ||
Nullable<SHPStruct*> BoardFG_File; | ||
Valueable<bool> BoardFG_ShowWhenNotSelected; | ||
Nullable<TranslucencyLevel> BoardFG_Translucency; | ||
Valueable<Vector2D<int>> Board_Offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why translucency flags are nullable here when they can just be valueables with default 0?
Also, you're hooking into the function. But the vanilla function is just one big if-else, and you hook both of the branches. You should replace the entire function. Additionally, your hooks disable other Phobos hooks (shield bars, HeathBar.Height, digital displays). As such, you should move those patches into your replaced function, too. |
Added customizable health bars in form of BarTypes. By default, technos use their own vanilla healthbars.
Adding
HealthBar.BarType
changing health bar to this type. Can be applied to buildings.Example
No docs for now, needs testing.