Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/components/editor/SplitEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,11 @@ export default function SplitEditor({ splitFilePayload }: SplitEditorParams) {
</div>

<div className="row">
<label htmlFor="attempts">Attempts</label>
<label htmlFor="runattempts">Attempts</label>
<input
onChange={(e) => setAttempts(Number(e.target.value))}
value={attempts ?? 0}
id="attempts"
id="runattempts"
name="attempts"
inputMode="numeric"
/>
Expand Down
64 changes: 48 additions & 16 deletions frontend/src/components/splitter/SegmentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,39 @@ function isVisible(id: string, parentById: Map<string, string | null>, expandedP
}

export default function SegmentList({ sessionPayload, comparison }: SplitListParameters) {
const [completeClassName, setCompleteClassName] = React.useState<string>("");
const activeRowRef = useRef<HTMLTableRowElement | null>(null);
const containerRef = useRef<HTMLDivElement | null>(null);

useEffect(() => {
let className = "";
if (sessionPayload.loaded_split_file &&
sessionPayload.current_run &&
sessionPayload.leaf_segments) {
if(Object.keys(sessionPayload.current_run.splits).length
== sessionPayload.leaf_segments.length) {
className = "complete";

const pb = sessionPayload.loaded_split_file.pb;
console.log(sessionPayload.loaded_split_file)
if (pb) {
const segments = sessionPayload.leaf_segments;
if (segments) {
const finalSplit = segments[segments.length - 1].id;
const finalTime = sessionPayload.current_run.splits[finalSplit].current_cumulative;
if (finalTime < pb.total_time) {
className += " pb";
}
}
}
}
setCompleteClassName(className);
} else {
setCompleteClassName("");
}

}, [sessionPayload]);

const targets = useMemo<Targets>(() => {
let cumulative = 0;
const results: Targets = { cumulative: {}, individual: {} };
Expand Down Expand Up @@ -353,7 +383,7 @@ export default function SegmentList({ sessionPayload, comparison }: SplitListPar
// Delta pulled from last leaf vs its cumulative target
let parentDelta: JSX.Element | null = null;

if (lastLeafId && lastLeafSplit) {
if (lastLeafId) {
const leafSeg = segmentById.get(lastLeafId);
const cTarget = targets.cumulative[lastLeafId] ?? null;
const iTarget = targets.individual[lastLeafId] ?? null;
Expand All @@ -363,19 +393,21 @@ export default function SegmentList({ sessionPayload, comparison }: SplitListPar
}

if (cTarget != null) {
const delta = lastLeafSplit.current_cumulative - cTarget;
parentDelta = getDeltaDisplayTime(delta);
if (lastLeafSplit != null) {
const delta = lastLeafSplit.current_cumulative - cTarget;
parentDelta = getDeltaDisplayTime(delta);
}
}
}

main.push(
<tr key={segmentData.Segment.id} className="parentRow">
<td className="splitName" style={{ paddingLeft: segmentData.Depth * 16 }}>
<td className={"splitName " + completeClassName} style={{ paddingLeft: segmentData.Depth * 16 }}>
{toggle}
<strong>{segmentData.Segment.name}</strong>
</td>
<td className="splitDelta">{parentDelta}</td>
<td className="splitComparison">{parentComparison}</td>
<td className={"splitDelta " + completeClassName}>{parentDelta}</td>
<td className={"splitComparison "+ completeClassName}>{parentComparison}</td>
</tr>,
);
continue;
Expand Down Expand Up @@ -423,26 +455,26 @@ export default function SegmentList({ sessionPayload, comparison }: SplitListPar
]);

return (
<div id="splitList">
<div id="gameInfo">
<h1 id="gameTitle">
<div id="splitList" className={completeClassName}>
<div id="gameInfo" className={completeClassName}>
<h1 id="gameTitle" className={completeClassName}>
<strong>{sessionPayload.loaded_split_file?.game_name}</strong>
</h1>
<h2 id="gameCategory">
<h2 id="gameCategory" className={completeClassName}>
<small>{sessionPayload.loaded_split_file?.game_category}</small>
</h2>
<div id="attempts">{sessionPayload.loaded_split_file?.attempts}</div>
<div id="attempts" className={completeClassName}>{sessionPayload.loaded_split_file?.attempts}</div>
</div>

<div id="splitBody">
<div ref={containerRef} id="splitContainer">
<table cellSpacing="0">
<div id="splitBody" className={completeClassName}>
<div ref={containerRef} id="splitContainer" className={completeClassName}>
<table cellSpacing="0" className={completeClassName}>
<tbody>{mainRows}</tbody>
</table>
</div>

<div id="finalSegment">
<table>
<div id="finalSegment" className={completeClassName}>
<table className={completeClassName}>
<tbody>{finalRow}</tbody>
</table>
</div>
Expand Down
3 changes: 2 additions & 1 deletion session/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func (s *Service) SetLoadedSplitFile(sf SplitFile) {
s.currentSegmentIndex = -1
s.sessionState = Idle
s.dirty = false
s.loadedSplitFile.BuildStats()
logger.Infof(logModule, "%s loaded in session (segments total/leaf %d/%d)",
sf.GameName, len(sf.Segments), len(s.leafSegments))
}
Expand All @@ -151,6 +152,7 @@ func (s *Service) Split() SplitResult {
case Running:
return s.advanceRun()
case Finished:
s.loadedSplitFile.BuildStats()
s.resetLocked()
return SplitReset
case Paused:
Expand Down Expand Up @@ -326,7 +328,6 @@ func (s *Service) resetLocked() {
func (s *Service) PersistRunToSession() {
if s.currentRun != nil {
s.loadedSplitFile.Runs = append(s.loadedSplitFile.Runs, *s.currentRun)
s.loadedSplitFile.BuildStats()
logger.Info(logModule, "run persisted to session, new stats built")
} else {
logger.Warn(logModule, "persist requested on nil current run")
Expand Down
Binary file modified skin/default-skin.zip
Binary file not shown.