Skip to content

Commit 1a0d2c0

Browse files
Add paint bar config
1 parent 76ca2b8 commit 1a0d2c0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

client/src/client-config.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const DEFAULT_CONFIG = {
1414
showAllRobotRadii: false,
1515
showTimelineMarkers: true,
1616
showHealthBars: true,
17+
showPaintBars: false,
1718
showPaintMarkers: true,
1819
showMapXY: true,
1920
enableFancyPaint: true,
@@ -28,6 +29,7 @@ const configDescription: Record<keyof ClientConfig, string> = {
2829
showAllRobotRadii: 'Show all robot view and attack radii',
2930
showTimelineMarkers: 'Show user-generated markers on the timeline',
3031
showHealthBars: 'Show health bars below all robots',
32+
showPaintBars: 'Show paint bars below all robots',
3133
showPaintMarkers: 'Show paint markers created using mark()',
3234
showMapXY: 'Show X,Y when hovering a tile',
3335
enableFancyPaint: 'Enable fancy paint rendering',

client/src/playback/Bodies.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ export class Body {
274274
if (focused || config.showHealthBars) {
275275
this.drawHealthBar(match, overlayCtx)
276276
}
277+
if (focused || config.showPaintBars) {
278+
this.drawPaintBar(match, overlayCtx, config.showHealthBars)
279+
}
277280
}
278281
}
279282

@@ -435,6 +438,21 @@ export class Body {
435438
ctx.fillRect(hpBarX, hpBarY, hpBarWidth * (this.hp / this.maxHp), hpBarHeight)
436439
}
437440

441+
private drawPaintBar(match: Match, ctx: CanvasRenderingContext2D, healthVisible: boolean): void {
442+
const dimension = match.currentRound.map.staticMap.dimension
443+
const interpCoords = this.getInterpolatedCoords(match)
444+
const renderCoords = renderUtils.getRenderCoords(interpCoords.x, interpCoords.y, dimension)
445+
const paintBarWidth = 0.8
446+
const paintBarHeight = 0.1
447+
const paintBarYOffset = 0.4 + (healthVisible ? 0.11 : 0)
448+
const paintBarX = renderCoords.x + 0.5 - paintBarWidth / 2
449+
const paintBarY = renderCoords.y + 0.5 + paintBarYOffset
450+
ctx.fillStyle = 'rgba(0,0,0,.3)'
451+
ctx.fillRect(paintBarX, paintBarY, paintBarWidth, paintBarHeight)
452+
ctx.fillStyle = '#c515ed'
453+
ctx.fillRect(paintBarX, paintBarY, paintBarWidth * (this.paint / this.maxPaint), paintBarHeight)
454+
}
455+
438456
protected drawLevel(match: Match, ctx: CanvasRenderingContext2D) {
439457
if (this.level <= 1) return
440458

0 commit comments

Comments
 (0)