feat: consolidate unspool gameplay, 30 release levels, and 5 validation samples (026A/B, 038A, 039, 051)

This commit is contained in:
fannyxl committed 2026-11-26 09:45:05 +08:00
1 parent 96c19dca82
commit f02f9b085e
18 files changed
+2922 -39

No files matched your search

+86 -2
View File
@@ -1,12 +1,15 @@
import { Component, Game, game, Node, view, _decorator } from 'cc';
import { PREVIEW } from 'cc/env';
import { AtelierService } from './core/AtelierService';
import { RELEASE_LEVELS } from './core/ReleaseLevels';
import { SoundService } from './core/SoundService';
import { StorageService } from './core/StorageService';
import { findValidationSample, VALIDATION_SAMPLES, ValidationSampleEntry } from './core/ValidationSamples';
import { EmbroideryRenderer } from './render/EmbroideryRenderer';
import { LobbyView } from './ui/LobbyView';
import { PlayView } from './ui/PlayView';
import { applyResponsivePolicy, computeScreenMetrics, ScreenMetrics } from './ui/ScreenAdapter';
import { createLabel, createPanel, createUINode } from './ui/UiBuilder';
import { createButton, createLabel, createPanel, createUINode, hex, StyledButton } from './ui/UiBuilder';
const { ccclass } = _decorator;
@@ -19,6 +22,9 @@ export class MainController extends Component {
private lobbyView!: LobbyView;
private playView!: PlayView;
private mockCapsuleNode: Node | null = null;
private sampleBarNode: Node | null = null;
private sampleBarBtns: { key: string; btn: StyledButton }[] = [];
private activeSampleKey: string | null = null;
protected onLoad(): void {
applyResponsivePolicy();
@@ -53,7 +59,20 @@ export class MainController extends Component {
game.on(Game.EVENT_SHOW, this.onAppShow, this);
view.on('canvas-resize', this.onCanvasResize, this);
this.applyLayoutMetrics();
this.showLobby();
const sampleParam = PREVIEW && typeof window !== 'undefined'
? new URLSearchParams(window.location?.search ?? '').get('sample')
: null;
const sampleEntry = findValidationSample(sampleParam);
if (sampleEntry) {
this.enterValidationSample(sampleEntry);
} else if (sampleParam === '024') {
this.lobbyView.node.active = false;
this.playView.node.active = true;
this.playView.loadCustomLevel(RELEASE_LEVELS[23], '样板 024 · 晨露叶桥');
} else {
this.showLobby();
}
}
protected onDestroy(): void {
@@ -72,6 +91,70 @@ export class MainController extends Component {
this.lobbyView?.applyScreenMetrics(metrics);
this.playView?.applyScreenMetrics(metrics);
this.syncMockWeChatCapsule(metrics);
this.syncSampleBarPosition(metrics);
}
/** 仅在 PREVIEW 且 URL 带 ?sample= 时显示底部紧凑样板切换条,便于手机一指切换对照测试 */
private ensureSampleBar(): void {
if (!PREVIEW || this.sampleBarNode) return;
const bar = createPanel('SampleSwitcherBar', 726, 48, {
fill: '#2f1e10e8',
stroke: '#d8b06a',
strokeWidth: 1.6,
radius: 16,
depth: 3,
depthColor: '#1a0f07',
}, this.node);
this.sampleBarNode = bar.node;
this.sampleBarBtns = [];
const count = VALIDATION_SAMPLES.length;
const btnW = 134;
const gap = 8;
const totalW = count * btnW + (count - 1) * gap;
VALIDATION_SAMPLES.forEach((entry, idx) => {
const x = -totalW / 2 + btnW / 2 + idx * (btnW + gap);
const btn = createButton({
name: `SampleBtn_${entry.key}`,
text: entry.shortLabel,
w: btnW,
h: 34,
radius: 12,
fill: '#f3e5c7',
stroke: '#c9a367',
depth: 2,
depthColor: '#9c7843',
textColor: '#482e14',
fontSize: 15,
onClick: () => this.enterValidationSample(entry),
}, bar.node);
btn.node.setPosition(x, 0, 0);
this.sampleBarBtns.push({ key: entry.key, btn });
});
this.syncSampleBarPosition(computeScreenMetrics());
}
private syncSampleBarPosition(m: ScreenMetrics): void {
if (!this.sampleBarNode) return;
const bottomSafe = Math.min(54, Math.max(0, m.bottomInset));
this.sampleBarNode.setPosition(0, -m.visibleH / 2 + bottomSafe + 28, 0);
}
private refreshSampleBarHighlight(): void {
for (const item of this.sampleBarBtns) {
const active = item.key === this.activeSampleKey;
item.btn.label.color = hex(active ? '#9f2f23' : '#482e14');
item.btn.node.setScale(active ? 1.05 : 1, active ? 1.05 : 1, 1);
}
}
private enterValidationSample(entry: ValidationSampleEntry): void {
this.activeSampleKey = entry.key;
this.ensureSampleBar();
if (this.sampleBarNode) this.sampleBarNode.active = true;
this.refreshSampleBarHighlight();
this.lobbyView.node.active = false;
this.playView.node.active = true;
this.playView.loadCustomLevel(entry.level, entry.headerTitle);
}
/** 仅在浏览器 URL 带 ?wxsim=iphone15 或 ?wxsim=iphonese 时绘制模拟微信胶囊,方便真机前目视验收 */
@@ -110,6 +193,7 @@ export class MainController extends Component {
private showLobby(): void {
this.atelier?.settleIdle(Date.now());
if (this.sampleBarNode) this.sampleBarNode.active = false;
this.playView.node.active = false;
this.lobbyView.node.active = true;
this.lobbyView.refresh();