Skip to content

Commit

Permalink
Merge branch 'master' into public-release
Browse files Browse the repository at this point in the history
  • Loading branch information
TheApplePieGod committed Jan 20, 2025
2 parents baa68fd + 41ee67b commit 8b2a6a1
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 23 deletions.
2 changes: 2 additions & 0 deletions client/src/client-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export const ConfigPage: React.FC<Props> = (props) => {

if (keyboard.keyCode === 'KeyF')
context.updateConfigValue('focusRobotTurn', !context.state.config.focusRobotTurn)
if (keyboard.keyCode === 'KeyI')
context.updateConfigValue('showAllIndicators', !context.state.config.showAllIndicators)
}, [keyboard.keyCode])

if (!props.open) return null
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/game/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const FloatingTooltip: React.FC<{

return (
<div
className="absolute bg-black/70 opacity-95 z-20 text-white p-2 rounded-md text-xs whitespace-nowrap pointer-events-none"
className="absolute max-w-[500px] bg-black/70 opacity-95 z-20 text-white p-2 rounded-md text-xs whitespace-pre-line pointer-events-none"
style={{
...tooltipStyle,
visibility: showFloatingTooltip ? 'visible' : 'hidden'
Expand All @@ -72,7 +72,7 @@ export const DraggableTooltip: React.FC<{ container: Rect; content: React.ReactN
return (
<Draggable width={container.width} height={container.height}>
{content && (
<div className="bg-black/90 opacity-95 z-20 text-white p-2 rounded-md text-xs cursor-pointer relative pointer-events-auto">
<div className="max-w-[500px] bg-black/90 opacity-95 z-20 text-white p-2 rounded-md text-xs cursor-pointer relative pointer-events-auto whitespace-pre-line">
{content}
<div className="absolute top-0 right-0" style={{ transform: 'scaleX(0.57) scaleY(0.73)' }}>
<ThreeBarsIcon />
Expand Down
1 change: 1 addition & 0 deletions client/src/components/sidebar/help/help.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export const HelpPage: React.FC<Props> = (props) => {
)}
{hotkeyElement(`R`, 'Resets the map camera if it has been panned/zoomed')}
{hotkeyElement(`C`, 'Hides and unhides game control bar')}
{hotkeyElement(`F`, 'Toggles the show all indicators config')}
{hotkeyElement(`T`, 'Toggles per-turn playback for the current game')}
{hotkeyElement(`F`, 'Toggles per-turn robot focus config')}
{hotkeyElement(`.`, 'Skip to the very last round of the current game')}
Expand Down
26 changes: 15 additions & 11 deletions client/src/components/sidebar/runner/runner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ const MapSelector: React.FC<MapSelectorProps> = ({ maps, availableMaps, onSelect
)
}

export type ConsoleLine = { content: string; type: 'output' | 'error' | 'bold' }
export type ConsoleLine = { content: string; type: 'output' | 'error' | 'bold'; matchIdx: number }

type Props = {
lines: RingBuffer<ConsoleLine>
Expand All @@ -401,19 +401,23 @@ export const Console: React.FC<Props> = ({ lines }) => {
}
}

const focusRobot = (round: number, id: number) => {
const focusRobot = (match: number, round: number, id: number) => {
setPopout(false)
GameRunner.jumpToRound(round)
GameRenderer.setSelectedRobot(id)

// If turn playback is enabled, focus the robot's exact turn as well
if (GameRunner.match?.playbackPerTurn) {
GameRunner.jumpToRobotTurn(id)
}
GameRunner.setMatch(GameRunner.game?.matches[match], round)

// Update selection after a delay so it doesn't get overwritten
setTimeout(() => {
// If turn playback is enabled, focus the robot's exact turn as well
GameRenderer.setSelectedRobot(id)
if (GameRunner.match?.playbackPerTurn) {
GameRunner.jumpToRobotTurn(id)
}
}, 5)
}

const ConsoleRow = (props: { index: number; style: any }) => {
const content = lines.get(props.index)!.content
const row = lines.get(props.index)!
const content = row.content

// Check if the printout is from a bot. If so, add a special click element
// that selects the bot
Expand All @@ -429,7 +433,7 @@ export const Console: React.FC<Props> = ({ lines }) => {
<div className="flex items-center gap-1 sele" style={props.style}>
<span
className="text-blueLight decoration-blueLight text-xs whitespace-nowrap underline cursor-pointer"
onClick={() => focusRobot(round, id)}
onClick={() => focusRobot(row.matchIdx, round, id)}
>
{`[Team ${team}, ID #${id}, Round ${round}]`}
</span>
Expand Down
21 changes: 16 additions & 5 deletions client/src/components/sidebar/runner/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,23 @@ export const useScaffold = (): Scaffold => {
const [error, setError] = useState('')
const matchPID = useRef<string | undefined>(undefined)
const forceUpdate = useForceUpdate()
const consoleLines = useRef<RingBuffer<ConsoleLine>>(new RingBuffer(10000))
const consoleLines = useRef<RingBuffer<ConsoleLine>>(new RingBuffer(50000))

const [webSocketListener, setWebSocketListener] = useState<WebSocketListener | undefined>()

const log = (line: ConsoleLine) => {
// Set match index to be the same as the previous log value
if (consoleLines.current.length() > 0) {
line.matchIdx = consoleLines.current.get(consoleLines.current.length() - 1)!.matchIdx
}

// If we encounter the end-of-match message, increment the match index
if (line.content.startsWith('[server]') && line.content.includes('Finished')) {
line.matchIdx++
}

consoleLines.current.push(line)

forceUpdate()
}

Expand Down Expand Up @@ -107,7 +118,7 @@ export const useScaffold = (): Scaffold => {
)
matchPID.current = newPID
} catch (e: any) {
consoleLines.current.push({ content: e, type: 'error' })
consoleLines.current.push({ content: e, type: 'error', matchIdx: 0 })
}
forceUpdate()
}
Expand Down Expand Up @@ -176,15 +187,15 @@ export const useScaffold = (): Scaffold => {

nativeAPI.child_process.onStdout(({ pid, data }) => {
if (pid !== matchPID.current) return
log({ content: data, type: 'output' })
log({ content: data, type: 'output', matchIdx: 0 })
})
nativeAPI.child_process.onStderr(({ pid, data }) => {
if (pid !== matchPID.current) return
log({ content: data, type: 'error' })
log({ content: data, type: 'error', matchIdx: 0 })
})
nativeAPI.child_process.onExit(({ pid, code, signal }) => {
if (pid !== matchPID.current) return
log({ content: `Exited with code ${code} | ${JSON.stringify(signal)}`, type: 'bold' })
log({ content: `Exited with code ${code} | ${JSON.stringify(signal)}`, type: 'bold', matchIdx: 0 })
matchPID.current = undefined
forceUpdate()
})
Expand Down
2 changes: 1 addition & 1 deletion client/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const CLIENT_VERSION = '2.0.2'
export const CLIENT_VERSION = '2.0.3'
export const SPEC_VERSION = '1'
export const BATTLECODE_YEAR: number = 2025
export const MAP_SIZE_RANGE = {
Expand Down
2 changes: 1 addition & 1 deletion client/src/playback/Bodies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ export class Body {
}`
]
if (this.indicatorString != '') {
defaultInfo.push(`Indicator: ${this.indicatorString}`)
defaultInfo.push(this.indicatorString)
}

return defaultInfo
Expand Down
4 changes: 2 additions & 2 deletions client/src/playback/GameRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ class GameRunnerClass {
})
}

setMatch(match: Match | undefined): void {
setMatch(match: Match | undefined, round: number = 1): void {
this._trigger(this._matchListeners)
if (match) {
match.game.currentMatch = match
this.setGame(match.game)
match._jumpToStart()
match._jumpToRound(round)
GameRenderer.render()
}
this.setPaused(true)
Expand Down
2 changes: 1 addition & 1 deletion engine/src/main/battlecode/common/GameConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class GameConstants {
* The maximum length of indicator strings that a player can associate with a
* robot.
*/
public static final int INDICATOR_STRING_MAX_LENGTH = 64;
public static final int INDICATOR_STRING_MAX_LENGTH = 256;

/** The maximum length of a label to add to the timeline. */
public static final int TIMELINE_LABEL_MAX_LENGTH = 64;
Expand Down
Binary file modified specs/specs.pdf
Binary file not shown.

0 comments on commit 8b2a6a1

Please sign in to comment.