优化弹窗UI细节
This commit is contained in:
1 parent
eb48d8e845
commit
b2036cd9bc
30 files changed
+7385
-2859
No files matched your search
@@ -0,0 +1,210 @@
|
||||
import { Color, Graphics, Layers, Sprite, UITransform } from 'cc';
|
||||
import type { Node } from 'cc';
|
||||
import type { DialogComposer } from './OrchardDialogs';
|
||||
|
||||
type Point = readonly [number, number];
|
||||
type RGB = readonly [number, number, number];
|
||||
type Curve = readonly [number, number, number, number, number, number];
|
||||
|
||||
const LIGHT_CENTRE: Point = [535, 1090];
|
||||
const GOLD: RGB = [255, 210, 125];
|
||||
const PINK: RGB = [255, 135, 199];
|
||||
|
||||
/** 参考图坐标统一转为画布中心坐标。 / Convert reference pixels to canvas coordinates. */
|
||||
function absoluteVertices(graphics: Graphics, points: readonly Point[]): void {
|
||||
graphics.moveTo(points[0][0] - 540, 960 - points[0][1]);
|
||||
for (let index = 1; index < points.length; index++) {
|
||||
graphics.lineTo(points[index][0] - 540, 960 - points[index][1]);
|
||||
}
|
||||
graphics.close();
|
||||
}
|
||||
|
||||
function decorationGraphics(ui: DialogComposer, name: string, parent: Node): Graphics {
|
||||
const node = ui.group(name, parent);
|
||||
node.layer = Layers.Enum.UI_2D;
|
||||
node.getComponent(UITransform)!.setContentSize(1080, 1920);
|
||||
const graphics = node.getComponent(Graphics) ?? node.addComponent(Graphics);
|
||||
graphics.clear();
|
||||
return graphics;
|
||||
}
|
||||
|
||||
function polarPoint(radius: number, angle: number): Point {
|
||||
return [
|
||||
LIGHT_CENTRE[0] + Math.cos(angle) * radius,
|
||||
LIGHT_CENTRE[1] + Math.sin(angle) * radius,
|
||||
];
|
||||
}
|
||||
|
||||
/** 独立扇形径向、横向渐淡,不填充整圆。 / Feather individual rays, never a solid disc. */
|
||||
function authorRays(ui: DialogComposer, parent: Node): void {
|
||||
const graphics = decorationGraphics(ui, 'BonusAwardRaysDecor', parent);
|
||||
const rays: readonly (readonly [number, number, number, number])[] = [
|
||||
[-176, 5, 610, 27], [-158, 9, 650, 30], [-140, 5, 620, 38],
|
||||
[-123, 10, 650, 32], [-105, 5, 650, 43], [-88, 9, 650, 35],
|
||||
[-70, 5, 650, 42], [-53, 10, 650, 31], [-34, 5, 630, 37],
|
||||
[-17, 8, 650, 29], [2, 5, 610, 31], [20, 9, 625, 25],
|
||||
[39, 5, 590, 34], [57, 8, 650, 26], [76, 4, 620, 32],
|
||||
[95, 9, 650, 24], [114, 5, 620, 33], [132, 8, 650, 26],
|
||||
[151, 5, 610, 35], [165, 4, 630, 25],
|
||||
];
|
||||
const feather: readonly (readonly [number, number, number])[] = [
|
||||
[-1, -0.55, 0.2], [-0.55, 0.55, 1], [0.55, 1, 0.2],
|
||||
];
|
||||
const bands = 12;
|
||||
for (let rayIndex = 0; rayIndex < rays.length; rayIndex++) {
|
||||
const [degrees, halfWidth, length, opacity] = rays[rayIndex];
|
||||
const angle = degrees * Math.PI / 180;
|
||||
const spread = halfWidth * Math.PI / 180;
|
||||
const tint = rayIndex % 3 === 0 ? PINK : GOLD;
|
||||
for (let band = 0; band < bands; band++) {
|
||||
const inner = length * band / bands;
|
||||
const outer = length * (band + 1) / bands;
|
||||
const fade = Math.pow(1 - (band + 0.5) / bands, 1.6);
|
||||
for (const [left, right, strength] of feather) {
|
||||
const alpha = Math.round(opacity * fade * strength);
|
||||
if (alpha === 0) continue;
|
||||
graphics.fillColor = new Color(tint[0], tint[1], tint[2], alpha);
|
||||
const a = polarPoint(inner, angle + spread * left);
|
||||
const b = polarPoint(outer, angle + spread * left);
|
||||
const c = polarPoint(outer, angle + spread * right);
|
||||
const d = polarPoint(inner, angle + spread * right);
|
||||
absoluteVertices(graphics, [a, b, c]);
|
||||
if (band > 0) absoluteVertices(graphics, [a, c, d]);
|
||||
graphics.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const RIBBON_START: Point = [-27, -70];
|
||||
const RIBBON_CURVES: readonly Curve[] = [
|
||||
[-65, -62, -53, -20, -12, -27],
|
||||
[32, -37, 50, -12, 21, 4],
|
||||
[-12, 24, -33, 5, -22, -9],
|
||||
[-7, -28, 21, -7, 8, 22],
|
||||
[-4, 48, -15, 54, 11, 75],
|
||||
];
|
||||
|
||||
/** 多层描边表现卷曲彩带的暗边、曲面和高光。 / Layer strokes for ribbon depth and sheen. */
|
||||
function authorRibbon(
|
||||
ui: DialogComposer, parent: Node, name: string, centre: Point,
|
||||
degrees: number, scale: number, violet: boolean,
|
||||
): void {
|
||||
const graphics = decorationGraphics(ui, name, parent);
|
||||
graphics.lineCap = Graphics.LineCap.ROUND;
|
||||
graphics.lineJoin = Graphics.LineJoin.ROUND;
|
||||
const angle = degrees * Math.PI / 180;
|
||||
const cosine = Math.cos(angle);
|
||||
const sine = Math.sin(angle);
|
||||
const transform = (x: number, y: number, offset: Point): Point => [
|
||||
centre[0] + (x * cosine - y * sine + offset[0]) * scale - 540,
|
||||
960 - centre[1] - (x * sine + y * cosine + offset[1]) * scale,
|
||||
];
|
||||
const strokes: readonly { width: number; tint: RGB; alpha: number; offset: Point }[] = [
|
||||
{ width: 18, tint: [72, 12, 102], alpha: 125, offset: [2, 3] },
|
||||
{ width: 14, tint: violet ? [127, 40, 199] : [211, 44, 151], alpha: 245, offset: [0, 0] },
|
||||
{ width: 8, tint: violet ? [197, 105, 247] : [250, 113, 205], alpha: 245, offset: [-1, -1] },
|
||||
{ width: 2.5, tint: [255, 222, 252], alpha: 220, offset: [-3, -2] },
|
||||
];
|
||||
for (const stroke of strokes) {
|
||||
graphics.lineWidth = stroke.width * scale;
|
||||
graphics.strokeColor = new Color(stroke.tint[0], stroke.tint[1], stroke.tint[2], stroke.alpha);
|
||||
const start = transform(RIBBON_START[0], RIBBON_START[1], stroke.offset);
|
||||
graphics.moveTo(start[0], start[1]);
|
||||
for (const curve of RIBBON_CURVES) {
|
||||
const first = transform(curve[0], curve[1], stroke.offset);
|
||||
const second = transform(curve[2], curve[3], stroke.offset);
|
||||
const end = transform(curve[4], curve[5], stroke.offset);
|
||||
graphics.bezierCurveTo(first[0], first[1], second[0], second[1], end[0], end[1]);
|
||||
}
|
||||
graphics.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
function starPoints(x: number, y: number, radius: number): readonly Point[] {
|
||||
const waist = radius * 0.14;
|
||||
return [
|
||||
[x, y - radius], [x + waist, y - waist],
|
||||
[x + radius * 0.76, y], [x + waist, y + waist],
|
||||
[x, y + radius], [x - waist, y + waist],
|
||||
[x - radius * 0.76, y], [x - waist, y - waist],
|
||||
];
|
||||
}
|
||||
|
||||
/** 扩散也使用四角路径,保持星芒轻透。 / Use four-point silhouettes for translucent bloom. */
|
||||
function authorStar(ui: DialogComposer, parent: Node, name: string, x: number, y: number, radius: number): void {
|
||||
const graphics = decorationGraphics(ui, name, parent);
|
||||
const layers = [
|
||||
{ scale: 2.3, tint: GOLD, alpha: 13 },
|
||||
{ scale: 1.65, tint: GOLD, alpha: 31 },
|
||||
{ scale: 1.15, tint: GOLD, alpha: 115 },
|
||||
{ scale: 1, tint: [255, 244, 204] as const, alpha: 240 },
|
||||
{ scale: 0.56, tint: [255, 255, 255] as const, alpha: 255 },
|
||||
];
|
||||
for (const layer of layers) {
|
||||
graphics.fillColor = new Color(layer.tint[0], layer.tint[1], layer.tint[2], layer.alpha);
|
||||
absoluteVertices(graphics, starPoints(x, y, radius * layer.scale));
|
||||
graphics.fill();
|
||||
}
|
||||
}
|
||||
|
||||
/** 原图含叶片,按原始画幅等比适配。 / Preserve the source fruit and leaves without stretching. */
|
||||
function authorFruit(
|
||||
ui: DialogComposer, parent: Node, name: string, key: string,
|
||||
x: number, y: number, width: number, height: number,
|
||||
): void {
|
||||
const node = ui.image(name, key, x, y, width, height, parent);
|
||||
node.layer = Layers.Enum.UI_2D;
|
||||
const frame = node.getComponent(Sprite)!.spriteFrame!;
|
||||
const original = frame.originalSize;
|
||||
const scale = Math.min(width / original.width, height / original.height);
|
||||
node.getComponent(UITransform)!.setContentSize(original.width * scale, original.height * scale);
|
||||
}
|
||||
|
||||
/** 只构建庆祝底饰;标题、次数、徽标与按钮由调用方创建。 / Author decorations behind caller-owned content. */
|
||||
export function authorCelebration(ui: DialogComposer, parent: Node): void {
|
||||
const decor = ui.group('BonusAwardCelebrationDecor', parent);
|
||||
decor.layer = Layers.Enum.UI_2D;
|
||||
decor.getComponent(UITransform)!.setContentSize(1080, 1920);
|
||||
decor.setSiblingIndex(0);
|
||||
|
||||
authorRays(ui, decor);
|
||||
authorRibbon(ui, decor, 'BonusAwardRibbonUpperLeftDecor', [230, 365], -23, 1.08, false);
|
||||
authorRibbon(ui, decor, 'BonusAwardRibbonUpperRightDecor', [865, 410], 19, 0.95, true);
|
||||
authorRibbon(ui, decor, 'BonusAwardRibbonMiddleLeftDecor', [70, 1020], 12, 0.87, true);
|
||||
authorRibbon(ui, decor, 'BonusAwardRibbonMiddleRightDecor', [992, 1125], -13, 0.95, false);
|
||||
authorRibbon(ui, decor, 'BonusAwardRibbonLowerLeftDecor', [90, 1350], -18, 0.86, false);
|
||||
authorRibbon(ui, decor, 'BonusAwardRibbonLowerRightDecor', [980, 1420], 25, 0.82, true);
|
||||
|
||||
authorFruit(ui, decor, 'BonusAwardLeftStrawberryDecor', 'crimson-berry', 203, 1170, 240, 265);
|
||||
authorFruit(ui, decor, 'BonusAwardLeftBlueberriesDecor', 'indigo-bunch', 285, 1240, 160, 164);
|
||||
authorFruit(ui, decor, 'BonusAwardRightStrawberryDecor', 'crimson-berry', 860, 1223, 185, 204);
|
||||
authorFruit(ui, decor, 'BonusAwardRightBlueberriesDecor', 'indigo-bunch', 755, 1228, 177, 182);
|
||||
|
||||
authorStar(ui, decor, 'BonusAwardStarUpperLeftDecor', 216, 475, 26);
|
||||
authorStar(ui, decor, 'BonusAwardStarTopDecor', 780, 365, 23);
|
||||
authorStar(ui, decor, 'BonusAwardStarUpperRightDecor', 980, 647, 30);
|
||||
authorStar(ui, decor, 'BonusAwardStarMiddleLeftDecor', 224, 1030, 26);
|
||||
authorStar(ui, decor, 'BonusAwardStarRightDecor', 970, 1280, 25);
|
||||
authorStar(ui, decor, 'BonusAwardStarLowerLeftDecor', 117, 1515, 16);
|
||||
authorStar(ui, decor, 'BonusAwardStarLowerRightDecor', 945, 1540, 18);
|
||||
}
|
||||
|
||||
/** 只使用现有装饰节点重绘,禁止因加载场景而重新创建节点。 / Redraw on existing decoration nodes without rebuilding UI at runtime. */
|
||||
export function drawCelebrationGraphics(parent: Node): void {
|
||||
const existing = parent.getChildByName('BonusAwardCelebrationDecor');
|
||||
if (!existing) return;
|
||||
const ui = {
|
||||
group: (name: string, owner: Node = parent): Node => {
|
||||
const node = owner.getChildByName(name);
|
||||
if (!node) throw new Error(`Missing celebration drawing node: ${name}`);
|
||||
return node;
|
||||
},
|
||||
image: (name: string, _key: string, _x: number, _y: number, _w: number, _h: number, owner: Node = parent): Node => {
|
||||
const node = owner.getChildByName(name);
|
||||
if (!node) throw new Error(`Missing celebration image node: ${name}`);
|
||||
return node;
|
||||
},
|
||||
} as DialogComposer;
|
||||
authorCelebration(ui, parent);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "7114b1b2-ef88-4471-9f96-9fbdf019a461",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { _decorator, Color, Component, Graphics, Node } from 'cc';
|
||||
import { drawCelebrationGraphics } from './DialogCelebration';
|
||||
const { ccclass } = _decorator;
|
||||
|
||||
/** Graphics的路径不序列化;仅重绘已有节点,不创建运行时UI。 / Redraw saved graphics nodes because drawing commands are not serialized. */
|
||||
@ccclass('DialogEffects')
|
||||
export class DialogEffects extends Component {
|
||||
onLoad(): void {
|
||||
const shade = this.node.getChildByName('Shade')?.getComponent(Graphics);
|
||||
if (shade) {
|
||||
shade.clear(); shade.fillColor = new Color(12, 0, 22, 155);
|
||||
shade.rect(-10000, -10000, 20000, 20000); shade.fill();
|
||||
}
|
||||
const parent = this.node.getChildByName('BonusAwardDialog');
|
||||
if (parent) drawCelebrationGraphics(parent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "04c8a177-fa1f-44c4-b3c9-b098cd4a5d1c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/** 完整切图中心坐标,原点在1080×1920参考图左上角。 / Full-canvas sprite centres in the portrait reference, without alpha trimming. */
|
||||
export type DialogBox = readonly [key: string, x: number, y: number, width: number, height: number];
|
||||
export const REFERENCE_IMAGES: Record<string, DialogBox> = {
|
||||
PreferencesShell: ['preferences-shell', 538, 856, 884, 1050],
|
||||
PreferencesTitle: ['preferences-heading', 539.5, 465.5, 505, 85],
|
||||
PreferencesFlourish: ['preferences-flourish', 540.5, 529.5, 471, 43],
|
||||
PreferencesMusicRow: ['melody-row', 540, 650.5, 788, 155],
|
||||
PreferencesSoundRow: ['effects-row', 540, 816, 788, 155],
|
||||
PreferencesVibrationRow: ['haptics-row', 540, 981.5, 788, 155],
|
||||
PreferencesMusicToggle: ['toggle-lit', 791, 650.5, 210, 91],
|
||||
PreferencesSoundToggle: ['toggle-lit', 791, 816, 210, 91],
|
||||
PreferencesVibrationToggle: ['toggle-lit', 791, 981.5, 210, 91],
|
||||
PreferencesGuide: ['instructions-pill', 540, 1159.5, 630, 133],
|
||||
PreferencesClose: ['dismiss-orb', 890.5, 415.5, 123, 121],
|
||||
RepeatShell: ['repeat-shell', 536.5, 1009, 905, 980],
|
||||
RepeatGarnish: ['repeat-garnish', 544, 521.5, 228, 213],
|
||||
RepeatTitle: ['repeat-title', 537, 663.5, 684, 157],
|
||||
RepeatStart: ['repeat-confirm', 535, 1303.5, 808, 203],
|
||||
RepeatClose: ['dismiss-orb', 902, 595, 114, 112],
|
||||
EmptyWalletShell: ['empty-wallet-shell', 534.5, 957.5, 879, 1135],
|
||||
EmptyWalletTitle: ['empty-wallet-heading', 536.5, 531.5, 747, 329],
|
||||
EmptyWalletGarnish: ['empty-wallet-garnish', 531.5, 845.5, 707, 391],
|
||||
EmptyWalletNote: ['empty-wallet-note', 539.5, 1095.5, 539, 111],
|
||||
EmptyWalletGift: ['empty-wallet-gift', 539, 1262, 780, 175],
|
||||
EmptyWalletLater: ['empty-wallet-later', 537, 1409, 354, 86],
|
||||
EmptyWalletClose: ['shortfall-dismiss', 897, 425, 116, 116],
|
||||
BonusAwardScatter1: ['bonus-award-emblem', 265, 638, 270, 266],
|
||||
BonusAwardScatter2: ['bonus-award-emblem', 538.5, 618.5, 289, 285],
|
||||
BonusAwardScatter3: ['bonus-award-emblem', 815, 638, 270, 266],
|
||||
BonusAwardTitle: ['bonus-award-title', 542, 864, 952, 282],
|
||||
BonusAwardCaption: ['bonus-award-caption', 535, 1323, 756, 122],
|
||||
BonusAwardStart: ['bonus-begin', 541, 1503.5, 646, 219],
|
||||
BonusSummaryShell: ['bonus-summary-shell', 538, 994, 996, 960],
|
||||
BonusSummaryGarnish: ['bonus-summary-garnish', 540.5, 506.5, 499, 259],
|
||||
BonusSummaryTitle: ['bonus-summary-title', 539, 754, 762, 248],
|
||||
BonusSummaryCaption: ['bonus-summary-caption', 543.5, 934, 831, 90],
|
||||
BonusSummaryAmountPlate: ['bonus-summary-amount', 539, 1075.5, 870, 229],
|
||||
BonusSummaryContinue: ['bonus-dismiss', 540, 1291, 684, 206],
|
||||
};
|
||||
|
||||
/** 两种领取状态单独还原,不能仅替换标题而保留错误底板。 / Each gift state owns its complete art and layout. */
|
||||
export const GIFT_REFERENCE: Record<'available' | 'claimed', Record<string, DialogBox>> = {
|
||||
available: {
|
||||
GiftShell: ['gift-shell', 537, 938.5, 960, 1247],
|
||||
GiftTitle: ['gift-heading', 545, 454, 584, 104],
|
||||
GiftGarnish: ['gift-garnish', 530.5, 743.5, 407, 389],
|
||||
GiftAmountPlate: ['gift-amount', 538, 1012.5, 766, 163],
|
||||
GiftDailyLabel: ['gift-daily', 546.5, 1149.5, 731, 65],
|
||||
GiftClaim: ['gift-collect', 537, 1306, 648, 198],
|
||||
GiftClose: ['gift-dismiss', 917, 399, 116, 116],
|
||||
},
|
||||
claimed: {
|
||||
GiftShell: ['claimed-shell', 536, 958, 934, 1212],
|
||||
GiftTitle: ['claimed-heading', 537.5, 517, 763, 372],
|
||||
GiftGarnish: ['claimed-garnish', 540, 844.5, 348, 247],
|
||||
GiftAmountPlate: ['claimed-amount', 535, 1035, 750, 168],
|
||||
GiftDailyLabel: ['claimed-caption', 538.5, 1180.5, 749, 61],
|
||||
GiftCollected: ['gift-collected', 533.5, 1311.5, 567, 143],
|
||||
GiftClose: ['claimed-dismiss', 892, 474, 106, 106],
|
||||
},
|
||||
};
|
||||
export const REPEAT_OPTIONS = [
|
||||
{ count: 10, key: 'ten', x: 356, y: 917 },
|
||||
{ count: 25, key: 'quarter', x: 727, y: 917 },
|
||||
{ count: 50, key: 'half', x: 355, y: 1092 },
|
||||
{ count: 100, key: 'century', x: 730, y: 1092 },
|
||||
] as const;
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "ce1a12b6-3eed-4a84-83e9-dc2a616ca280",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -53,6 +53,11 @@ export const ART: Record<string, string> = {
|
||||
'neon-grid': 'dbe9db6c-7b3d-4fdf-b1f5-49af9986ac4e@f9941',
|
||||
'paired-rubies': '61cc917c-b5b5-42d5-8776-6b25f8a56771@f9941',
|
||||
'preferences-heading': '5cce6650-a0ea-41f6-bc79-7eee5d551984@f9941',
|
||||
'preferences-flourish': '357c3de4-a135-4f4b-824b-4d41147cd585@f9941',
|
||||
'gift-dismiss': 'e64d4a58-5242-4454-a0da-27fa43007a74@f9941',
|
||||
'claimed-dismiss': '6574915a-44a7-4ea8-9782-056044ded147@f9941',
|
||||
'claimed-amount': '1e2c5c21-d85b-4a72-a0f1-c3c96595bd64@f9941',
|
||||
'shortfall-dismiss': '0e42ba08-10e3-4a3a-b255-f1c0334c3b9b@f9941',
|
||||
'preferences-orb': '5aa72211-d961-46f7-9885-bd758762e48d@f9941',
|
||||
'preferences-shell': 'ccd2564c-1f01-421d-99a4-14a702645e7b@f9941',
|
||||
'prism-chime': 'ced72a7e-16ce-4ad2-b797-33f8ba727613@f9941',
|
||||
@@ -100,6 +105,7 @@ export const SYMBOL_ART: Record<SymbolId, string> = {
|
||||
};
|
||||
|
||||
export const FONT_UUID = '76285818-1331-4483-8f03-aefb51af3f34';
|
||||
export const CELEBRATION_FONT_UUID = 'd1794df0-a1e3-4d67-9123-a7f735833c4f';
|
||||
|
||||
export const ART_KEYS = Object.keys(ART).sort();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { _decorator, assetManager, BitmapFont, Component, Graphics, Mask, Sprite, SpriteFrame, UITransform, Widget } from 'cc';
|
||||
import { EDITOR } from 'cc/env';
|
||||
import { ART, ART_KEYS, FONT_UUID, SYMBOL_ART } from './OrchardAssets';
|
||||
import { ART, ART_KEYS, CELEBRATION_FONT_UUID, FONT_UUID, SYMBOL_ART } from './OrchardAssets';
|
||||
import { OrchardComposer } from './OrchardComposer';
|
||||
import { authorDialogs } from './OrchardDialogs';
|
||||
import { OrchardView } from './OrchardView';
|
||||
@@ -12,11 +12,20 @@ const { ccclass, property, executeInEditMode } = _decorator;
|
||||
export class OrchardAuthoring extends Component {
|
||||
@property status = 'Not authored';
|
||||
@property
|
||||
get applyDialogReferences(): boolean { return false; }
|
||||
set applyDialogReferences(value: boolean) {
|
||||
if (!EDITOR || !value || this.status === 'Preparing artwork') return;
|
||||
this.loadArtwork(true);
|
||||
}
|
||||
@property
|
||||
get composeReference(): boolean { return false; }
|
||||
set composeReference(value: boolean) {
|
||||
if (!EDITOR || !value || this.status === 'Preparing artwork') return;
|
||||
this.loadArtwork(false);
|
||||
}
|
||||
private loadArtwork(dialogsOnly: boolean): void {
|
||||
this.status = 'Preparing artwork';
|
||||
assetManager.loadAny([...ART_KEYS.map(key => ART[key]), FONT_UUID], (error, assets) => {
|
||||
assetManager.loadAny([...ART_KEYS.map(key => ART[key]), FONT_UUID, CELEBRATION_FONT_UUID], (error, assets) => {
|
||||
if (!this.isValid) return;
|
||||
if (error) { this.status = 'Artwork preparation failed'; return; }
|
||||
try {
|
||||
@@ -24,8 +33,12 @@ export class OrchardAuthoring extends Component {
|
||||
const view = this.node.getComponent(OrchardView) ?? this.node.addComponent(OrchardView);
|
||||
view.artFrames = list.slice(0, ART_KEYS.length) as SpriteFrame[];
|
||||
view.numerals = list[ART_KEYS.length] as BitmapFont;
|
||||
this.compose(view);
|
||||
this.status = 'Ready: editable reference layout';
|
||||
view.celebrationNumerals = list[ART_KEYS.length + 1] as BitmapFont;
|
||||
if (dialogsOnly) {
|
||||
const ui = new OrchardComposer(this.node, key => view.artFrames[ART_KEYS.indexOf(key)], view.numerals!);
|
||||
authorDialogs(ui, view.celebrationNumerals);
|
||||
} else this.compose(view);
|
||||
this.status = dialogsOnly ? 'Ready: seven dialog references applied' : 'Ready: editable reference layout';
|
||||
} catch (cause) { this.status = `Layout error: ${cause instanceof Error ? cause.message : 'unknown'}`; }
|
||||
});
|
||||
}
|
||||
@@ -85,6 +98,6 @@ export class OrchardAuthoring extends Component {
|
||||
ui.button('GuideAccess', 'guide-pill', 164, 1720, 284, 123);
|
||||
ui.button('GiftAccess', 'daily-pill', 928, 1720, 264, 121);
|
||||
ui.text('GameNotice', '', 540, 191, 760, 84, 30).active = false;
|
||||
authorDialogs(ui);
|
||||
authorDialogs(ui, view.celebrationNumerals ?? undefined);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ export class OrchardComposer implements DialogComposer {
|
||||
group(name: string, parent = this.root): Node {
|
||||
const node = parent.getChildByName(name) ?? new Node(name);
|
||||
node.parent = parent;
|
||||
node.setSiblingIndex(parent.children.length - 1);
|
||||
node.layer = Layers.Enum.UI_2D;
|
||||
node.setPosition(0, 0, 0);
|
||||
node.getComponent(UITransform) ?? node.addComponent(UITransform);
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { BlockInputEvents, Button, Label, Node, Sprite, SpriteFrame, UITransform } from 'cc';
|
||||
import { BitmapFont, BlockInputEvents, Button, Label, LabelShadow, Color, Node, Sprite, SpriteFrame, UITransform, Vec2 } from 'cc';
|
||||
import type { GameSession, GameState } from './GameSession';
|
||||
import { SYMBOL_ART } from './OrchardAssets';
|
||||
import { PAYLINES, PAYTABLE } from './SlotsMath';
|
||||
import type { OrdinarySymbol } from './SlotsMath';
|
||||
import { director } from 'cc';
|
||||
import { GuestLegalLinks } from '../../login/scripts/GuestLegalLinks';
|
||||
import { GIFT_REFERENCE, REFERENCE_IMAGES, REPEAT_OPTIONS, type DialogBox } from './DialogReferenceLayout';
|
||||
import { authorCelebration } from './DialogCelebration';
|
||||
import { DialogEffects } from './DialogEffects';
|
||||
|
||||
/**
|
||||
* Coordinates are screen centres in the 1080 x 1920 reference layout (origin: top left).
|
||||
@@ -33,17 +37,12 @@ const GROUP_NAMES: Record<VisibleDialog, string> = {
|
||||
error: 'ErrorDialog',
|
||||
};
|
||||
|
||||
const AUTO_OPTIONS = [
|
||||
{ count: 10, key: 'ten', x: 340, y: 880 },
|
||||
{ count: 25, key: 'quarter', x: 740, y: 880 },
|
||||
{ count: 50, key: 'half', x: 340, y: 1080 },
|
||||
{ count: 100, key: 'century', x: 740, y: 1080 },
|
||||
] as const;
|
||||
const AUTO_OPTIONS = REPEAT_OPTIONS;
|
||||
|
||||
const PREFERENCES: readonly { key: PreferenceKey; name: string; art: string; y: number }[] = [
|
||||
{ key: 'music', name: 'Music', art: 'melody-row', y: 790 },
|
||||
{ key: 'sound', name: 'Sound', art: 'effects-row', y: 955 },
|
||||
{ key: 'vibration', name: 'Vibration', art: 'haptics-row', y: 1120 },
|
||||
{ key: 'music', name: 'Music', art: 'melody-row', y: 650.5 },
|
||||
{ key: 'sound', name: 'Sound', art: 'effects-row', y: 816 },
|
||||
{ key: 'vibration', name: 'Vibration', art: 'haptics-row', y: 981.5 },
|
||||
];
|
||||
|
||||
const PAYING_SYMBOLS = Object.keys(PAYTABLE) as OrdinarySymbol[];
|
||||
@@ -95,8 +94,9 @@ function body(ui: DialogComposer, name: string, value: string, y: number, h: num
|
||||
* Authors ModalLayer/ Shade + eight independent dialog groups. No scene is saved here.
|
||||
* Button and live-label names below are the shared authoring/runtime contract.
|
||||
*/
|
||||
export function authorDialogs(ui: DialogComposer): void {
|
||||
export function authorDialogs(ui: DialogComposer, celebrationFont?: BitmapFont): void {
|
||||
const layer = ui.group('ModalLayer');
|
||||
layer.getComponent(DialogEffects) ?? layer.addComponent(DialogEffects);
|
||||
const shade = ui.shade('Shade', layer);
|
||||
if (!shade.getComponent(BlockInputEvents)) shade.addComponent(BlockInputEvents);
|
||||
const groups = {} as Record<VisibleDialog, Node>;
|
||||
@@ -105,68 +105,83 @@ export function authorDialogs(ui: DialogComposer): void {
|
||||
groups[kind].active = false;
|
||||
}
|
||||
|
||||
const picture = (name: string, parent: Node, button = false, box: DialogBox = REFERENCE_IMAGES[name]): Node => {
|
||||
const [key, x, y, w, h] = box;
|
||||
const node = button ? ui.button(name, key, x, y, w, h, parent) : ui.image(name, key, x, y, w, h, parent);
|
||||
node.setSiblingIndex(parent.children.length - 1);
|
||||
return node;
|
||||
};
|
||||
const white = (name: string, text: string, x: number, y: number, w: number, h: number, size: number, parent: Node): Node => {
|
||||
const node = ui.text(name, text, x, y, w, h, size, parent);
|
||||
const shadow = node.getComponent(LabelShadow) ?? node.addComponent(LabelShadow);
|
||||
shadow.color = new Color(18, 0, 21, 190); shadow.offset = new Vec2(0, -3); shadow.blur = 2;
|
||||
return node;
|
||||
};
|
||||
const repeat = groups.repeat;
|
||||
ui.image('RepeatShell', 'repeat-shell', 540, 960, 870, 990, repeat);
|
||||
ui.image('RepeatTitle', 'repeat-title', 540, 600, 630, 145, repeat);
|
||||
ui.image('RepeatGarnish', 'repeat-garnish', 225, 705, 150, 140, repeat);
|
||||
ui.text('RepeatHint', 'CHOOSE YOUR SPINS', 595, 735, 570, 60, 34, repeat);
|
||||
picture('RepeatShell', repeat);
|
||||
picture('RepeatGarnish', repeat);
|
||||
picture('RepeatTitle', repeat);
|
||||
white('RepeatHint', 'Choose number of spins', 540, 777, 740, 76, 48, repeat);
|
||||
for (const option of AUTO_OPTIONS) {
|
||||
ui.button(`RepeatCount${option.count}`, `${option.key}-${option.count === 10 ? 'picked' : 'idle'}`,
|
||||
option.x, option.y, 360, 170, repeat);
|
||||
const selected = option.count === 25;
|
||||
ui.button(`RepeatCount${option.count}`, `${option.key}-${selected ? 'picked' : 'idle'}`,
|
||||
option.x, option.y, selected ? 377 : 364, selected ? 178 : 172, repeat);
|
||||
}
|
||||
ui.button('RepeatStart', 'repeat-confirm', 540, 1300, 735, 185, repeat);
|
||||
ui.button('RepeatClose', 'dismiss-orb', 900, 510, 114, 112, repeat);
|
||||
picture('RepeatStart', repeat, true);
|
||||
white('RepeatFooter', 'Stop anytime', 540, 1414, 480, 60, 38, repeat);
|
||||
picture('RepeatClose', repeat, true);
|
||||
|
||||
const preferences = groups.preferences;
|
||||
ui.image('PreferencesShell', 'preferences-shell', 540, 960, 879, 1035, preferences);
|
||||
ui.image('PreferencesTitle', 'preferences-heading', 540, 568, 505, 85, preferences);
|
||||
preferences.getChildByName('PreferencesNote')?.destroy();
|
||||
picture('PreferencesShell', preferences);
|
||||
picture('PreferencesTitle', preferences);
|
||||
picture('PreferencesFlourish', preferences);
|
||||
for (const preference of PREFERENCES) {
|
||||
ui.image(`Preferences${preference.name}Row`, preference.art, 540, preference.y, 788, 155, preferences);
|
||||
ui.button(`Preferences${preference.name}Toggle`, 'toggle-lit', 795, preference.y, 216, 94, preferences);
|
||||
picture(`Preferences${preference.name}Row`, preferences);
|
||||
picture(`Preferences${preference.name}Toggle`, preferences, true);
|
||||
}
|
||||
ui.button('PreferencesGuide', 'instructions-pill', 540, 1318, 630, 133, preferences);
|
||||
ui.text('PreferencesNote', 'Preferences are saved on this device.', 540, 1430, 790, 50, 32, preferences);
|
||||
ui.button('PreferencesClose', 'dismiss-orb', 900, 510, 114, 112, preferences);
|
||||
picture('PreferencesGuide', preferences, true);
|
||||
const privacy = labelButton(ui, 'PreferencesPrivacy', 'Privacy Policy', 335, 1281, 260, preferences);
|
||||
const terms = labelButton(ui, 'PreferencesTerms', 'Terms of Service', 726, 1281, 310, preferences);
|
||||
for (const link of [privacy, terms]) {
|
||||
const text = link.getComponent(Label)!;
|
||||
text.fontSize = 34; text.lineHeight = 42; text.isBold = false; text.isUnderline = true;
|
||||
link.getComponent(UITransform)!.setContentSize(link === privacy ? 260 : 310, 62);
|
||||
}
|
||||
const notice = ui.text('PreferencesLegalNotice', '', 540, 1335, 760, 40, 23, preferences);
|
||||
notice.active = false;
|
||||
const legal = preferences.getComponent(GuestLegalLinks) ?? preferences.addComponent(GuestLegalLinks);
|
||||
legal.privacyButton = privacy.getComponent(Button); legal.termsButton = terms.getComponent(Button); legal.notice = notice.getComponent(Label);
|
||||
picture('PreferencesClose', preferences, true);
|
||||
|
||||
const gift = groups.gift;
|
||||
ui.image('GiftShell', 'gift-shell', 540, 960, 928, 1205, gift);
|
||||
ui.image('GiftTitle', 'gift-heading', 540, 465, 590, 105, gift);
|
||||
ui.image('GiftGarnish', 'gift-garnish', 540, 760, 415, 397, gift);
|
||||
ui.image('GiftAmountPlate', 'gift-amount', 540, 1030, 782, 166, gift);
|
||||
ui.text('GiftAmount', coins(DAILY_COINS), 600, 1030, 530, 120, 96, gift, true);
|
||||
ui.image('GiftDailyLabel', 'gift-daily', 540, 1180, 738, 66, gift);
|
||||
ui.button('GiftClaim', 'gift-collect', 540, 1340, 642, 196, gift);
|
||||
ui.image('GiftCollected', 'gift-collected', 540, 1340, 585, 147, gift).active = false;
|
||||
ui.text('GiftCountdown', 'Available once per UTC day.', 540, 1480, 820, 60, 32, gift);
|
||||
ui.button('GiftClose', 'dismiss-orb', 920, 405, 114, 112, gift);
|
||||
for (const name of ['GiftShell', 'GiftTitle', 'GiftGarnish', 'GiftAmountPlate']) picture(name, gift, false, GIFT_REFERENCE.available[name]);
|
||||
white('GiftAmount', `${coins(DAILY_COINS)} COINS`, 600, 1012.5, 550, 120, 82, gift);
|
||||
picture('GiftDailyLabel', gift, false, GIFT_REFERENCE.available.GiftDailyLabel);
|
||||
picture('GiftClaim', gift, true, GIFT_REFERENCE.available.GiftClaim);
|
||||
picture('GiftCollected', gift, false, GIFT_REFERENCE.claimed.GiftCollected).active = false;
|
||||
const footer = white('GiftCountdown', 'Available once per UTC day.', 540, 1446, 820, 60, 36, gift);
|
||||
footer.getComponent(Label)!.isBold = false;
|
||||
picture('GiftClose', gift, true, GIFT_REFERENCE.available.GiftClose);
|
||||
|
||||
const empty = groups.empty;
|
||||
ui.image('EmptyWalletShell', 'empty-wallet-shell', 540, 960, 862, 1113, empty);
|
||||
ui.image('EmptyWalletTitle', 'empty-wallet-heading', 540, 600, 705, 310, empty);
|
||||
ui.image('EmptyWalletNote', 'empty-wallet-note', 540, 825, 523, 108, empty);
|
||||
ui.image('EmptyWalletGarnish', 'empty-wallet-garnish', 540, 1050, 661, 365, empty);
|
||||
ui.button('EmptyWalletGift', 'empty-wallet-gift', 540, 1300, 703, 158, empty);
|
||||
ui.button('EmptyWalletLater', 'empty-wallet-later', 540, 1435, 350, 85, empty);
|
||||
ui.button('EmptyWalletClose', 'dismiss-orb', 902, 465, 108, 108, empty);
|
||||
for (const name of ['EmptyWalletShell', 'EmptyWalletTitle', 'EmptyWalletGarnish', 'EmptyWalletNote']) picture(name, empty);
|
||||
for (const name of ['EmptyWalletGift', 'EmptyWalletLater', 'EmptyWalletClose']) picture(name, empty, true);
|
||||
|
||||
const award = groups.award;
|
||||
ui.image('BonusAwardShell', 'repeat-shell', 540, 960, 870, 990, award);
|
||||
ui.image('BonusAwardTitle', 'bonus-award-title', 540, 620, 824, 244, award);
|
||||
ui.image('BonusAwardCaption', 'bonus-award-caption', 540, 822, 680, 109, award);
|
||||
ui.text('BonusAwardCount', '0', 540, 985, 440, 200, 180, award, true);
|
||||
for (let index = 0; index < 3; index++) {
|
||||
ui.image(`BonusAwardScatter${index + 1}`, 'bonus-award-emblem', 350 + index * 190, 1145, 155, 153, award);
|
||||
}
|
||||
ui.button('BonusAwardStart', 'bonus-begin', 540, 1340, 640, 217, award);
|
||||
award.getChildByName('BonusAwardShell')?.destroy();
|
||||
authorCelebration(ui, award);
|
||||
for (const name of ['BonusAwardScatter1', 'BonusAwardScatter2', 'BonusAwardScatter3', 'BonusAwardTitle']) picture(name, award);
|
||||
const count = ui.text('BonusAwardCount', '8', 534, 1116, 620, 350, 325, award, true);
|
||||
count.getComponent(Label)!.lineHeight = 325;
|
||||
if (celebrationFont) { count.getComponent(Label)!.font = celebrationFont; count.getComponent(Label)!.useSystemFont = false; }
|
||||
picture('BonusAwardCaption', award);
|
||||
picture('BonusAwardStart', award, true);
|
||||
|
||||
const summary = groups.summary;
|
||||
ui.image('BonusSummaryShell', 'bonus-summary-shell', 540, 960, 1060, 945, summary);
|
||||
ui.image('BonusSummaryTitle', 'bonus-summary-title', 540, 650, 770, 250, summary);
|
||||
ui.image('BonusSummaryCaption', 'bonus-summary-caption', 540, 852, 690, 75, summary);
|
||||
ui.image('BonusSummaryGarnish', 'bonus-summary-garnish', 850, 1180, 330, 171, summary);
|
||||
ui.image('BonusSummaryAmountPlate', 'bonus-summary-amount', 540, 1018, 780, 205, summary);
|
||||
ui.text('BonusSummaryAmount', '0', 540, 1018, 680, 150, 108, summary, true);
|
||||
ui.button('BonusSummaryContinue', 'bonus-dismiss', 540, 1280, 630, 190, summary);
|
||||
for (const name of ['BonusSummaryShell', 'BonusSummaryGarnish', 'BonusSummaryTitle', 'BonusSummaryCaption', 'BonusSummaryAmountPlate']) picture(name, summary);
|
||||
ui.text('BonusSummaryAmount', '0', 619, 1075.5, 480, 146, 126, summary, true);
|
||||
picture('BonusSummaryContinue', summary, true);
|
||||
|
||||
const guide = groups.guide;
|
||||
ui.image('GuideShell', 'preferences-shell', 540, 960, 980, 1550, guide);
|
||||
@@ -278,7 +293,7 @@ export class OrchardDialogs {
|
||||
private visible: VisibleDialog | null = null;
|
||||
private errorReturn: DialogKind | null = null;
|
||||
private guideReturn: 'preferences' | null = null;
|
||||
private selectedCount: number = AUTO_OPTIONS[0].count;
|
||||
private selectedCount: number = 25;
|
||||
private guidePage = 0;
|
||||
private working = false;
|
||||
private persistenceFailed = false;
|
||||
@@ -477,7 +492,9 @@ export class OrchardDialogs {
|
||||
|
||||
private refreshRepeat(): void {
|
||||
for (const option of AUTO_OPTIONS) {
|
||||
this.setArt(`RepeatCount${option.count}`, `${option.key}-${option.count === this.selectedCount ? 'picked' : 'idle'}`);
|
||||
const selected = option.count === this.selectedCount;
|
||||
this.setArt(`RepeatCount${option.count}`, `${option.key}-${selected ? 'picked' : 'idle'}`);
|
||||
this.required(`RepeatCount${option.count}`).getComponent(UITransform)!.setContentSize(selected ? 377 : 364, selected ? 178 : 172);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,30 +507,28 @@ export class OrchardDialogs {
|
||||
|
||||
private refreshGift(): void {
|
||||
const available = this.session.canClaimDaily();
|
||||
for (const [name, key, x, y, w, h] of (available ? [
|
||||
['GiftShell', 'gift-shell', 540, 960, 928, 1205],
|
||||
['GiftTitle', 'gift-heading', 540, 465, 590, 105],
|
||||
['GiftGarnish', 'gift-garnish', 540, 760, 415, 397],
|
||||
['GiftDailyLabel', 'gift-daily', 540, 1180, 738, 66],
|
||||
] : [
|
||||
['GiftShell', 'claimed-shell', 540, 960, 925, 1150],
|
||||
['GiftTitle', 'claimed-heading', 540, 520, 755, 368],
|
||||
['GiftGarnish', 'claimed-garnish', 540, 840, 355, 252],
|
||||
['GiftDailyLabel', 'claimed-caption', 540, 1180, 764, 62],
|
||||
]) as [string, string, number, number, number, number][]) {
|
||||
for (const [name, [key, x, y, w, h]] of Object.entries(GIFT_REFERENCE[available ? 'available' : 'claimed'])) {
|
||||
this.setArt(name, key);
|
||||
this.required(name).setPosition(x - 540, 960 - y, 0);
|
||||
this.required(name).getComponent(UITransform)!.setContentSize(w, h);
|
||||
}
|
||||
this.required('GiftClaim').active = available;
|
||||
this.required('GiftCollected').active = !available;
|
||||
this.label('GiftAmount').string = coins(DAILY_COINS);
|
||||
const amount = this.label('GiftAmount');
|
||||
amount.string = `${coins(DAILY_COINS)} COINS`;
|
||||
amount.fontSize = available ? 82 : 96; amount.lineHeight = available ? 94 : 110;
|
||||
amount.node.setPosition(available ? 60 : -5, available ? -52.5 : -75, 0);
|
||||
amount.node.getComponent(UITransform)!.setContentSize(available ? 550 : 660, 125);
|
||||
const seconds = Math.ceil(Math.max(0, this.session.nextResetMs()) / 1000);
|
||||
const hours = Math.floor(seconds / 3600);
|
||||
const minutes = Math.floor(seconds % 3600 / 60);
|
||||
const remaining = seconds % 60;
|
||||
const time = [hours, minutes, remaining].map(value => String(value).padStart(2, '0')).join(':');
|
||||
this.label('GiftCountdown').string = `${available ? 'Resets' : 'Next gift'} in ${time} (UTC)`;
|
||||
const countdown = this.label('GiftCountdown');
|
||||
countdown.string = available ? 'Available once per UTC day.' : `Next claim in ${time}`;
|
||||
countdown.node.setPosition(0, available ? -486 : -459, 0);
|
||||
countdown.fontSize = available ? 36 : 38;
|
||||
countdown.isBold = !available;
|
||||
}
|
||||
|
||||
private turnGuide(direction: number): void {
|
||||
|
||||
@@ -13,6 +13,7 @@ const { ccclass, property } = _decorator;
|
||||
export class OrchardView extends Component {
|
||||
@property({ type: [SpriteFrame] }) artFrames: SpriteFrame[] = [];
|
||||
@property({ type: BitmapFont }) numerals: BitmapFont | null = null;
|
||||
@property({ type: BitmapFont }) celebrationNumerals: BitmapFont | null = null;
|
||||
ready = false;
|
||||
private session: GameSession | null = null;
|
||||
private reels: ReelPresentation | null = null;
|
||||
|
||||
Reference in new issue
Block a user