fix: 修复打砖块游戏碰撞穿透bug,添加渐进提速机制
This commit is contained in:
@@ -260,9 +260,17 @@
|
||||
rowsKept: number;
|
||||
} | null = null;
|
||||
let devkitStatusTimer: number | null = null;
|
||||
let sessionStartedAt: number = Date.now();
|
||||
|
||||
$: uiCopy = copyByLocale[locale];
|
||||
$: configLinks = buildConfigLinks(locale, activeConfigLinkId, isConfigPanelOpen, isPrecisionTestOpen);
|
||||
$: configLinks = buildConfigLinks(
|
||||
locale,
|
||||
activeConfigLinkId,
|
||||
isConfigPanelOpen,
|
||||
isPrecisionTestOpen,
|
||||
devkitEnabled,
|
||||
isDevKitConfigOpen
|
||||
);
|
||||
$: leftSignalPanels = signalPanels.filter((panel) => panel.side === "left");
|
||||
$: rightSignalPanels = signalPanels.filter((panel) => panel.side === "right");
|
||||
$: rangeTicks = buildRangeTicks(rangeMin, rangeMax);
|
||||
@@ -718,12 +726,12 @@
|
||||
const safeIndex = clamp(index, 0, replayFrames.length - 1);
|
||||
const startIndex = Math.max(0, safeIndex - summaryPointsPerSeries + 1);
|
||||
const points: number[] = [];
|
||||
const frameIds: number[] = [];
|
||||
const xSeconds: number[] = [];
|
||||
for (let cursor = startIndex; cursor <= safeIndex; cursor += 1) {
|
||||
points.push(replayFrameTotal(replayFrames[cursor]));
|
||||
frameIds.push(cursor + 1);
|
||||
xSeconds.push(replayFrames[cursor].dtsMs / 1000);
|
||||
}
|
||||
return buildSummary(points, frameIds);
|
||||
return buildSummary(points, xSeconds);
|
||||
}
|
||||
|
||||
function applyReplayFrame(index: number): void {
|
||||
@@ -952,10 +960,11 @@
|
||||
? summaryValue.points[summaryValue.points.length - 1]
|
||||
: randomBetween(280, 1600);
|
||||
const next = Math.round(clamp(previous + randomBetween(-160, 160), 120, 2400) * 10) / 10;
|
||||
const nowSeconds = Math.round((Date.now() - sessionStartedAt) / 100) / 10;
|
||||
const previousXValues =
|
||||
summaryValue.xValues && summaryValue.xValues.length === summaryValue.points.length
|
||||
? summaryValue.xValues
|
||||
: summaryValue.points.map((_, index) => index + 1);
|
||||
: summaryValue.points.map((_, index) => nowSeconds);
|
||||
const points =
|
||||
summaryValue.points.length >= summaryPointsPerSeries
|
||||
? summaryValue.points.slice(1)
|
||||
@@ -964,7 +973,7 @@
|
||||
previousXValues.length >= summaryPointsPerSeries ? previousXValues.slice(1) : previousXValues.slice();
|
||||
|
||||
points.push(next);
|
||||
xValues.push((xValues[xValues.length - 1] ?? 0) + 1);
|
||||
xValues.push(nowSeconds);
|
||||
return buildSummary(points, xValues);
|
||||
}
|
||||
|
||||
@@ -977,7 +986,17 @@
|
||||
return;
|
||||
}
|
||||
signalPanels = showSignalPanels ? packet.panels : buildInactivePanels();
|
||||
summary = packet.summary;
|
||||
if (packet.summary.points.length > 0) {
|
||||
const nowSeconds = Math.round((Date.now() - sessionStartedAt) / 100) / 10;
|
||||
const pointCount = packet.summary.points.length;
|
||||
const spacing =
|
||||
pointCount > 1 ? Math.min(1.2, nowSeconds / Math.max(pointCount - 1, 1)) : 0;
|
||||
const startX = Math.max(0, nowSeconds - spacing * Math.max(pointCount - 1, 0));
|
||||
const xValues = packet.summary.points.map((_, index) => Math.round((startX + index * spacing) * 10) / 10);
|
||||
summary = { ...packet.summary, xValues };
|
||||
} else {
|
||||
summary = packet.summary;
|
||||
}
|
||||
pressureMatrix = packet.pressureMatrix;
|
||||
hasSignalData = signalPanels.length > 0 || packet.summary.points.length > 0;
|
||||
}
|
||||
@@ -1015,24 +1034,25 @@
|
||||
currentLocale: LocaleCode,
|
||||
activeId: string,
|
||||
isSettingsOpen: boolean,
|
||||
isPrecisionOpen: boolean
|
||||
isPrecisionOpen: boolean,
|
||||
isDevKitEnabled: boolean,
|
||||
isDevKitOpen: boolean
|
||||
): HudConfigLink[] {
|
||||
const labels =
|
||||
currentLocale === "zh-CN"
|
||||
? {
|
||||
streamOn: "打开",
|
||||
streamOff: "关闭",
|
||||
calibrate: "校准",
|
||||
precisionTest: "游戏",
|
||||
settings: "参数"
|
||||
}
|
||||
: {
|
||||
streamOn: "Open",
|
||||
streamOff: "Close",
|
||||
calibrate: "Calib",
|
||||
precisionTest: "Game",
|
||||
settings: "Setup"
|
||||
};
|
||||
const devkitLabel = currentLocale === "zh-CN" ? "开发工具" : "DevKit";
|
||||
|
||||
const links: HudConfigLink[] = [
|
||||
{
|
||||
@@ -1047,12 +1067,6 @@
|
||||
tone: "orange",
|
||||
active: activeId === "stream-off"
|
||||
},
|
||||
{
|
||||
id: "calibrate",
|
||||
label: labels.calibrate,
|
||||
tone: "cyan",
|
||||
active: activeId === "calibrate"
|
||||
},
|
||||
{
|
||||
id: "precision-test",
|
||||
label: labels.precisionTest,
|
||||
@@ -1067,12 +1081,12 @@
|
||||
}
|
||||
];
|
||||
|
||||
if (devkitEnabled) {
|
||||
if (isDevKitEnabled) {
|
||||
links.push({
|
||||
id: "devkit",
|
||||
label: "DevKit",
|
||||
label: devkitLabel,
|
||||
tone: "cyan",
|
||||
active: isDevKitConfigOpen
|
||||
active: isDevKitOpen
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1195,6 +1209,12 @@
|
||||
connectionNotice = "";
|
||||
}
|
||||
|
||||
$: if (updateNoticeVisible && pendingUpdate && !updateInstallBusy) {
|
||||
connectionNotice = locale === "zh-CN"
|
||||
? `发现新版本 ${pendingUpdate.version},是否现在下载并安装?`
|
||||
: `Version ${pendingUpdate.version} is available. Download and install now?`;
|
||||
}
|
||||
|
||||
function handleLocaleChange(event: CustomEvent<LocaleCode>): void {
|
||||
locale = event.detail;
|
||||
}
|
||||
@@ -1726,6 +1746,7 @@
|
||||
onMount(() => {
|
||||
let disposed = false;
|
||||
let unlistenHudStream: UnlistenFn | null = null;
|
||||
let unlistenDevkitPztAngle: UnlistenFn | null = null;
|
||||
let stopMockFeed: (() => void) | null = null;
|
||||
|
||||
void ensureDefaultWindowSize();
|
||||
@@ -1749,6 +1770,23 @@
|
||||
.catch((error) => {
|
||||
console.error("Failed to listen for hud_stream:", error);
|
||||
});
|
||||
void listen<{ seq: number; timestampMs: number; dtsMs: number; angle: number }>(
|
||||
"devkit_pzt_angle",
|
||||
(event) => {
|
||||
console.log("[devkit_pzt_angle]", event.payload);
|
||||
}
|
||||
)
|
||||
.then((unlisten) => {
|
||||
if (disposed) {
|
||||
unlisten();
|
||||
return;
|
||||
}
|
||||
|
||||
unlistenDevkitPztAngle = unlisten;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to listen for devkit_pzt_angle:", error);
|
||||
});
|
||||
} else {
|
||||
stopMockFeed = startMockFeed(applyPacket);
|
||||
}
|
||||
@@ -1758,6 +1796,7 @@
|
||||
pauseReplayPlayback();
|
||||
stopMockFeed?.();
|
||||
unlistenHudStream?.();
|
||||
unlistenDevkitPztAngle?.();
|
||||
if (devkitStatusTimer != null) {
|
||||
window.clearInterval(devkitStatusTimer);
|
||||
devkitStatusTimer = null;
|
||||
@@ -1849,8 +1888,6 @@
|
||||
rangeLabel={uiCopy.rangeLabel}
|
||||
rangeMinLabel={uiCopy.rangeMinLabel}
|
||||
rangeMaxLabel={uiCopy.rangeMaxLabel}
|
||||
colorMapLabel={uiCopy.colorMapLabel}
|
||||
{colorMapOptions}
|
||||
replaySectionLabel={uiCopy.replaySectionLabel}
|
||||
replayPlayLabel={uiCopy.replayPlayLabel}
|
||||
replayPauseLabel={uiCopy.replayPauseLabel}
|
||||
@@ -1863,6 +1900,7 @@
|
||||
{replayProgress}
|
||||
{replayFileName}
|
||||
{replayFrameInfo}
|
||||
{sessionStartedAt}
|
||||
resetConfigLabel={uiCopy.resetConfigLabel}
|
||||
applyLiveHint={uiCopy.applyLiveHint}
|
||||
leftPanels={leftSignalPanels}
|
||||
@@ -1880,7 +1918,7 @@
|
||||
>
|
||||
{#if !isPrecisionTestOpen}
|
||||
<section class="range-scale" aria-label="Signal Range">
|
||||
<p class="range-label">Range</p>
|
||||
<p class="range-label">{locale === "zh-CN" ? "范围" : "Range"}</p>
|
||||
<div class="range-track">
|
||||
{#each rangeTicks as tick}
|
||||
<span class="range-tick">{tick}</span>
|
||||
@@ -1919,12 +1957,10 @@
|
||||
/>
|
||||
|
||||
{#if isDevKitConfigOpen && devkitEnabled}
|
||||
<div class="devkit-overlay" role="dialog" aria-label="DevKit Config">
|
||||
<div class="devkit-overlay" role="dialog" aria-label={locale === "zh-CN" ? "开发工具配置" : "DevKit Config"}>
|
||||
<div class="devkit-float">
|
||||
<DevKitConfigPanel
|
||||
running={devkitRunning}
|
||||
port={devkitPort}
|
||||
framesSent={devkitFramesSent}
|
||||
filterLiftEnabled={devkitFilterLift}
|
||||
saveAsXlsx={devkitSaveXlsx}
|
||||
locale={locale}
|
||||
|
||||
Reference in New Issue
Block a user