-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
496 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/modules/core/components/PlayerStatus/PlayerStatusItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { memo } from 'react' | ||
|
||
import { ScaleLinear } from 'd3-scale' | ||
|
||
import { ShakePlayerWave } from '@/telemetry/models/data' | ||
|
||
const strokeWidth = 3 | ||
|
||
export interface PlayerStatusItemProps { | ||
readonly y: number | ||
readonly start: number | ||
readonly player: ShakePlayerWave | ||
readonly scale: ScaleLinear<number, number, never> | ||
} | ||
|
||
const PlayerStatusItem = function ({ y, start, player, scale }: PlayerStatusItemProps) { | ||
return ( | ||
<g transform={`translate(0,${y})`}> | ||
<line | ||
className='EggGraph-axis-line' | ||
strokeLinecap='square' | ||
x2={-4} | ||
/> | ||
<text | ||
className='EggGraph-axis-text EggGraph-axis-y-text EggGraph-player-name' | ||
x={-4} | ||
dx={-4} | ||
dy='.4em' | ||
> | ||
# | ||
{player.index + 1} | ||
</text> | ||
{player.alives.map(function (alive) { | ||
return ( | ||
<g key={alive[0]}> | ||
<line | ||
className='EggGraph-player-item-alive-bg' | ||
x1={scale(100 + start - alive[0])} | ||
x2={scale(100 + start - alive[1])} | ||
/> | ||
<line | ||
className='EggGraph-player-item-alive' | ||
x1={scale(100 + start - alive[0])} | ||
x2={scale(100 + start - alive[1])} | ||
/> | ||
</g> | ||
) | ||
})} | ||
{player.geggs.map(function (gegg) { | ||
return ( | ||
<line | ||
key={gegg[0]} | ||
className='EggGraph-player-item-gegg' | ||
x1={scale(100 + start - gegg[0])} | ||
x2={scale(100 + start - gegg[1])} | ||
y1={-strokeWidth} | ||
y2={-strokeWidth} | ||
/> | ||
) | ||
})} | ||
</g> | ||
) | ||
} | ||
|
||
export default memo(PlayerStatusItem) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { ScaleLinear } from 'd3-scale' | ||
|
||
import { ShakeDefaultWave } from '@/telemetry/models/data' | ||
|
||
import { GraphLayoutProps } from '../../models/graph' | ||
|
||
import PlayerStatusItem from './PlayerStatusItem' | ||
|
||
// Spacing between player status item and golden egg graph | ||
const playerStatusItemHeight = 20 | ||
const playerStatusItemHeightHalf = 0.5 * playerStatusItemHeight | ||
|
||
export const PlayerStatusGraphHeight = 4 * playerStatusItemHeight | ||
|
||
interface PlayerStatusProps extends Omit<GraphLayoutProps, 'height'> { | ||
readonly data: Readonly<ShakeDefaultWave> | ||
readonly scale: ScaleLinear<number, number, never> | ||
readonly visible?: boolean | ||
} | ||
|
||
const PlayerStatus = function (props: PlayerStatusProps) { | ||
const { | ||
marginTop: y, | ||
marginLeft: x, | ||
width, | ||
|
||
data, | ||
scale, | ||
visible, | ||
} = props | ||
|
||
return visible && ( | ||
<g transform={`translate(${x},${y})`}> | ||
<rect | ||
className='EggGraph-background' | ||
width={width} | ||
height={PlayerStatusGraphHeight} | ||
/> | ||
<line className='EggGraph-axis-line' y2={PlayerStatusGraphHeight} /> | ||
{data.players.map(function (p, i) { | ||
return ( | ||
<PlayerStatusItem | ||
key={i} | ||
y={playerStatusItemHeightHalf + playerStatusItemHeight * i} | ||
start={data.startTimestamp} | ||
player={p} | ||
scale={scale} | ||
/> | ||
) | ||
})} | ||
</g> | ||
) | ||
} | ||
|
||
export default PlayerStatus |
Oops, something went wrong.