fix(ui): keep diagnostic stop clear of Logo skip

This commit is contained in:
2026-09-06 00:45:44 +08:00
parent 84fa739ddd
commit f2a948f059
4 changed files with 74 additions and 6 deletions
@@ -6,7 +6,7 @@ import type { NativeHost } from '../../framework/config/sources/native-settings.
import type { PageModel } from '../../framework/presentation/ui-contracts.ts';
import { createLocalLoginHost, type LocalLoginHost } from './local-login-host.ts';
import type { LocalLoginEvidence } from './local-login-transport.ts';
import { CocosLocalLoginView, CocosLogoCountdownView, createLogoCountdown, createAssetLoadTask, createCocosFrameScheduler, requireNode } from './local-login-view.ts';
import { CocosLocalLoginView, CocosLogoCountdownView, createLogoCountdown, createAssetLoadTask, createCocosFrameScheduler, positionDiagnosticStopButtonBelow, requireNode } from './local-login-view.ts';
const { ccclass, property } = _decorator;
@@ -57,7 +57,9 @@ export class LocalPlatformLogin extends Component {
requireNode(logo, 'group-32').active = false;
const countdownLabels = logo.getComponentsInChildren(Label).filter(label => label.node.name === 'Spirit3104');
if (countdownLabels.length !== 1) throw new Error('Logo requires exactly one Spirit3104 Label');
this.countdownView = new CocosLogoCountdownView(requireNode(logo, 'group-1/Spirit3103'), countdownLabels[0].node,
const logoButton = requireNode(logo, 'group-1/Spirit3103');
positionDiagnosticStopButtonBelow(stopButton, logoButton);
this.countdownView = new CocosLogoCountdownView(logoButton, countdownLabels[0].node,
() => this.countdown?.skip());
this.countdown = createLogoCountdown({ now: () => performance.now(),
schedule: (callback, ms) => {
@@ -8,6 +8,31 @@ interface ViewReferences {
export interface LogoCountdownState { readonly visible: boolean; readonly text: string; }
const DIAGNOSTIC_STOP_GAP = 12;
/** Keeps the scene diagnostic control clear of the native Logo click region. */
export function positionDiagnosticStopButtonBelow(stopButton: Node, logoButton: Node): void {
const stopTransform = stopButton.getComponent(UITransform);
const logoTransform = logoButton.getComponent(UITransform);
const stopParentTransform = stopButton.parent?.getComponent(UITransform);
if (!stopTransform || !logoTransform || !stopParentTransform) {
throw new Error('Diagnostic stop layout requires native UITransform bindings');
}
const widget = stopButton.getComponent(Widget);
if (widget) {
widget.updateAlignment();
widget.enabled = false;
}
const logoBottom = logoTransform.convertToWorldSpaceAR(
new Vec3((0.5 - logoTransform.anchorX) * logoTransform.width, -logoTransform.anchorY * logoTransform.height, 0),
);
const bottomInStopParent = stopParentTransform.convertToNodeSpaceAR(logoBottom);
const current = stopButton.position;
stopButton.setPosition(new Vec3(current.x,
bottomInStopParent.y - DIAGNOSTIC_STOP_GAP - (1 - stopTransform.anchorY) * stopTransform.height,
current.z));
}
/** Native input and measured label layout, independent of serialized label parentage. */
export class CocosLogoCountdownView {
private readonly label: Label;