优化弹窗UI细节
This commit is contained in:
1 parent
eb48d8e845
commit
b2036cd9bc
30 files changed
+7385
-2859
No files matched your search
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user