添加登录功能
This commit is contained in:
commit
a3f61a29d0
120 files changed
+3974
No files matched your search
@@ -0,0 +1,71 @@
|
||||
import { _decorator, Button, Canvas, Color, Component, Label, Node, Sprite, UITransform, Widget } from 'cc';
|
||||
import { EDITOR } from 'cc/env';
|
||||
const { ccclass, executeInEditMode, property } = _decorator;
|
||||
|
||||
/** 仅按显式开关校准已存在节点,不在运行时重建界面。 / Explicit editor-only calibration of existing nodes; never rebuild UI at runtime. */
|
||||
@ccclass('WelcomeLayoutAuthoring')
|
||||
@executeInEditMode
|
||||
export class WelcomeLayoutAuthoring extends Component {
|
||||
@property
|
||||
get applyReferenceLayout(): boolean { return false; }
|
||||
set applyReferenceLayout(value: boolean) {
|
||||
if (!EDITOR || !value) return;
|
||||
const canvas = this.node;
|
||||
const group = this.child(canvas, 'WelcomeComposition');
|
||||
const widget = canvas.getComponent(Widget);
|
||||
if (widget) { widget.alignFlags = 0; widget.enabled = false; }
|
||||
// 保存的设计画布与项目设置保持一致,运行适配仍由独立组件负责。 / Persist the design canvas; the viewport component owns runtime adaptation.
|
||||
canvas.getComponent(UITransform)!.setContentSize(1080, 1920);
|
||||
canvas.setPosition(540, 960, 0);
|
||||
const camera = canvas.getChildByName('Camera');
|
||||
if (!canvas.getComponent(Canvas) || !camera) throw new Error('Welcome canvas is unavailable.');
|
||||
const backdrop = this.child(canvas, 'OrchardBackdrop');
|
||||
this.box(backdrop, 0, 0, 1080, 1920);
|
||||
backdrop.setSiblingIndex(1);
|
||||
this.sprite(backdrop);
|
||||
this.box(this.child(group, 'BrandMark'), 4, 466.5, 982, 643);
|
||||
this.box(this.child(group, 'FruitArrangement'), -7.5, -78, 991, 456);
|
||||
this.box(this.child(group, 'GuestAccess'), -1.5, -460, 1027, 268);
|
||||
for (const name of ['BrandMark', 'FruitArrangement', 'GuestAccess']) this.sprite(this.child(group, name));
|
||||
const button = this.child(group, 'GuestAccess').getComponent(Button);
|
||||
if (button) { button.transition = Button.Transition.SCALE; button.zoomScale = .97; }
|
||||
this.text(this.child(group, 'GuestReassurance'), 'No account needed', 0, -618, 780, 90, 56);
|
||||
this.text(this.child(group, 'PrivacyLink'), 'Privacy Policy', -190, -765, 300, 88, 38, true);
|
||||
this.text(this.child(group, 'TermsLink'), 'Terms of Service', 179, -765, 340, 88, 38, true);
|
||||
this.text(this.child(group, 'LegalDivider'), '|', -10, -765, 28, 76, 56);
|
||||
this.child(group, 'LegalDivider').getComponent(Label)!.color = new Color(236, 0, 136, 255);
|
||||
const status = this.child(group, 'AuthenticationStatus');
|
||||
this.text(status, '', 0, -692, 960, 50, 25);
|
||||
status.active = false;
|
||||
}
|
||||
private child(parent: Node, name: string): Node {
|
||||
const node = parent.getChildByName(name);
|
||||
if (!node) throw new Error(`Missing welcome node: ${name}`);
|
||||
return node;
|
||||
}
|
||||
private box(node: Node, x: number, y: number, width: number, height: number): void {
|
||||
node.setPosition(x, y, 0);
|
||||
node.setScale(1, 1, 1);
|
||||
node.getComponent(UITransform)!.setContentSize(width, height);
|
||||
}
|
||||
private sprite(node: Node): void {
|
||||
const sprite = node.getComponent(Sprite)!;
|
||||
sprite.sizeMode = Sprite.SizeMode.CUSTOM;
|
||||
sprite.trim = false;
|
||||
}
|
||||
private text(node: Node, text: string, x: number, y: number, width: number, height: number, font: number, underline = false): void {
|
||||
const label = node.getComponent(Label)!;
|
||||
label.overflow = Label.Overflow.SHRINK;
|
||||
label.string = text;
|
||||
label.fontFamily = 'Arial';
|
||||
label.fontSize = font;
|
||||
label.lineHeight = font + 8;
|
||||
label.horizontalAlign = Label.HorizontalAlign.CENTER;
|
||||
label.verticalAlign = Label.VerticalAlign.CENTER;
|
||||
label.enableWrapText = true;
|
||||
label.isBold = false;
|
||||
label.isUnderline = underline;
|
||||
label.color = new Color(250, 250, 250, 255);
|
||||
this.box(node, x, y, width, height);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user