feat: 调整UI
This commit is contained in:
@@ -201,8 +201,16 @@ export default class BattlePassSettlement extends cc.Component {
|
||||
const item = cell.getChildByName('item');
|
||||
const icon = item.getChildByName('icon'); for (const child of icon.children) child.active = child.name === r.type;
|
||||
const label = item.getChildByName('amount');
|
||||
if (r.type === 'infinite_health') NumberToImage.durationToImageNodes(r.count, label);
|
||||
else NumberToImage.numberToImageNodesNumber(r.count, 45, 5, 'big_', label, true);
|
||||
const maxWidth = 180 / item.scaleX;
|
||||
label.x = 0; label.setScale(1);
|
||||
if (r.type === 'infinite_health') {
|
||||
NumberToImage.durationToImageNodes(r.count, label);
|
||||
const left = Math.min(...label.children.map(n => n.x - n.width / 2));
|
||||
const right = Math.max(...label.children.map(n => n.x + n.width / 2));
|
||||
label.setScale(Math.min(1, maxWidth / (right - left)));
|
||||
} else {
|
||||
NumberToImage.rewardTextToImages((r.type === 'coin' ? '' : 'x') + r.count, label, 56, maxWidth);
|
||||
}
|
||||
});
|
||||
}
|
||||
private hideConfirmation() {
|
||||
|
||||
@@ -627,12 +627,15 @@ export default class NumberToImage extends cc.Component {
|
||||
const label = target.getComponent(cc.Label);
|
||||
if (label) label.enabled = false;
|
||||
target.removeAllChildren();
|
||||
const tokens = text.match(/小时|分钟|[0-9x×]/g) || [];
|
||||
const tokens: string[] = text.match(/小时|分钟|[0-9x×]/g) || [];
|
||||
const names = { x: 'cheng', '×': 'cheng', '小时': 'xiaoshi', '分钟': 'fenzhong' };
|
||||
const digitHeight = this.publicFont.getSpriteFrame('big_0').getRect().height;
|
||||
const glyphs = tokens.map(token => {
|
||||
const frame = this.publicFont.getSpriteFrame('big_' + (names[token] || token));
|
||||
const rect = frame.getRect();
|
||||
return { frame, width: height * rect.width / rect.height };
|
||||
// Keep the multiplier's authored size relative to digits, rather than enlarging it to digit height.
|
||||
const glyphHeight = token === 'x' || token === '×' ? height * rect.height / digitHeight : height;
|
||||
return { frame, width: glyphHeight * rect.width / rect.height, height: glyphHeight };
|
||||
});
|
||||
const width = glyphs.reduce((sum, glyph) => sum + glyph.width, 0) + Math.max(0, glyphs.length - 1) * 2;
|
||||
const scale = maxWidth > 0 ? Math.min(1, maxWidth / width) : 1;
|
||||
@@ -642,7 +645,7 @@ export default class NumberToImage extends cc.Component {
|
||||
const sprite = node.addComponent(cc.Sprite);
|
||||
sprite.sizeMode = cc.Sprite.SizeMode.CUSTOM;
|
||||
sprite.spriteFrame = glyph.frame;
|
||||
node.setContentSize(glyph.width * scale, height * scale);
|
||||
node.setContentSize(glyph.width * scale, glyph.height * scale);
|
||||
node.x = x + node.width / 2;
|
||||
x += node.width + 2 * scale;
|
||||
});
|
||||
|
||||
@@ -148,7 +148,7 @@ export default class Reward extends cc.Component {
|
||||
if (rewardData.type == 'coin')
|
||||
NumberToImage.numberToImageNodesNumber(rewardData.count, 45, 5, "big_", label, true);
|
||||
else if (rewardData.type == 'infinite_health') {
|
||||
if (durationUnits) {
|
||||
if (durationUnits || rewardData.battlePass) {
|
||||
this.renderDuration(label, rewardData.count);
|
||||
rewardNode.getChildByName('xnode').active = false;
|
||||
} else {
|
||||
@@ -175,7 +175,7 @@ export default class Reward extends cc.Component {
|
||||
xnode.x = label.x + (firstDigit.x - firstDigit.width * firstDigit.anchorX) * label.scaleX
|
||||
- 6 - xnode.width * (1 - xnode.anchorX) * xnode.scaleX;
|
||||
}
|
||||
if (rewardData.type !== 'infinite_health' || durationUnits)
|
||||
if (rewardData.type !== 'infinite_health' || durationUnits || rewardData.battlePass)
|
||||
this.alignAmount(rewardNode, rewardData.type !== 'coin' && rewardData.type !== 'infinite_health');
|
||||
rewardNode.getChildByName('label').active = false;
|
||||
if (iconNode) {
|
||||
|
||||
@@ -1115,7 +1115,7 @@
|
||||
"__uuid__": "18e345ea-860f-433b-bf7c-7205b266d384"
|
||||
},
|
||||
"coinFrame": {
|
||||
"__uuid__": "0c16c562-f7b6-4eb8-bf67-37d240d76c9b"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"freezeFrame": {
|
||||
"__uuid__": "ac60b2a5-c833-400a-b640-6eb478c96f1f"
|
||||
|
||||
@@ -2098,7 +2098,7 @@
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 148,
|
||||
"height": 120
|
||||
"height": 114.50526315789473
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -2150,10 +2150,10 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "4b766422-3a83-42d7-81d9-27c9f89cbb8c"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
|
||||
@@ -76,7 +76,8 @@ export default class JungleOver extends cc.Component {
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
NumberToImage.rewardTextToImages(text, target, 54);
|
||||
// Battle-pass amounts are 56px glyphs under a 0.7-scale item node.
|
||||
NumberToImage.rewardTextToImages(text, target, 56 * 0.7, 180);
|
||||
}
|
||||
|
||||
private formatCount(type: RewardType, count: number): string {
|
||||
|
||||
@@ -380,7 +380,7 @@ export default class JungleView {
|
||||
);
|
||||
NumberToImage.rewardTextToImages(labelText, label.node, labelFontSize, labelWidth);
|
||||
if (isToolReward) {
|
||||
label.node.setPosition(scaledWidth * 0.34, -scaledHeight * 0.34);
|
||||
label.node.setPosition(0, -scaledHeight * 0.34);
|
||||
}
|
||||
else {
|
||||
label.node.setPosition(0, rows.length === 1 ? -scaledHeight * 0.5 - 10 : -scaledHeight * 0.5 + 17);
|
||||
|
||||
@@ -1335,8 +1335,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 134.4,
|
||||
"height": 103.98315789473683
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -1354,8 +1354,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1.6,
|
||||
1.6,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -1388,7 +1388,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
@@ -2291,8 +2291,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 134.4,
|
||||
"height": 103.98315789473683
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -2310,8 +2310,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1.6,
|
||||
1.6,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -2344,7 +2344,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
@@ -2411,7 +2411,7 @@
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
0,
|
||||
22.703,
|
||||
4.702999999999999,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -3247,8 +3247,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 134.4,
|
||||
"height": 103.98315789473683
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -3266,8 +3266,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1.6,
|
||||
1.6,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -3300,7 +3300,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
@@ -4317,8 +4317,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 134.4,
|
||||
"height": 103.98315789473683
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -4336,8 +4336,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1.6,
|
||||
1.6,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -4370,7 +4370,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
@@ -5273,8 +5273,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 134.4,
|
||||
"height": 103.98315789473683
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -5292,8 +5292,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1.6,
|
||||
1.6,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -5326,7 +5326,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
@@ -8220,8 +8220,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 134.4,
|
||||
"height": 103.98315789473683
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -8239,8 +8239,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1.6,
|
||||
1.6,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -8273,7 +8273,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
@@ -9176,8 +9176,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 134.4,
|
||||
"height": 103.98315789473683
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -9195,8 +9195,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1.6,
|
||||
1.6,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -9229,7 +9229,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
@@ -9296,7 +9296,7 @@
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
0,
|
||||
22.703,
|
||||
4.703,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -10132,8 +10132,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 134.4,
|
||||
"height": 103.98315789473683
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -10151,8 +10151,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1.6,
|
||||
1.6,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -10185,7 +10185,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
@@ -11202,8 +11202,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 134.4,
|
||||
"height": 103.98315789473683
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -11221,8 +11221,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1.6,
|
||||
1.6,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -11255,7 +11255,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
@@ -12158,8 +12158,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 134.4,
|
||||
"height": 103.98315789473683
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -12177,8 +12177,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1.6,
|
||||
1.6,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -12211,7 +12211,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -45,16 +45,19 @@ export default class PyramidSettlement extends cc.Component {
|
||||
icon.y = lines.length === 2 ? 58 : 0;
|
||||
let maxWidth = 0;
|
||||
const height = good.id === 2005 ? 45 : 54;
|
||||
const digitHeight = this.numberAtlas.getSpriteFrame('big_0').getRect().height;
|
||||
lines.forEach((names, row) => {
|
||||
const frames = names.map(name => this.numberAtlas.getSpriteFrame(name));
|
||||
const widths = frames.map(frame => height * frame.getRect().width / frame.getRect().height);
|
||||
const heights = frames.map((frame, index) => names[index] === 'big_cheng'
|
||||
? height * frame.getRect().height / digitHeight : height);
|
||||
const widths = frames.map((frame, index) => heights[index] * frame.getRect().width / frame.getRect().height);
|
||||
const width = widths.reduce((sum, n) => sum + n, 0) + (widths.length - 1) * 2;
|
||||
maxWidth = Math.max(maxWidth, width);
|
||||
let x = -width / 2;
|
||||
frames.forEach((frame, index) => {
|
||||
const digit = new cc.Node(names[index]); target.addChild(digit);
|
||||
const sprite = digit.addComponent(cc.Sprite); sprite.sizeMode = cc.Sprite.SizeMode.CUSTOM; sprite.spriteFrame = frame;
|
||||
digit.setContentSize(widths[index], height); digit.x = x + widths[index] / 2; x += widths[index] + 2;
|
||||
digit.setContentSize(widths[index], heights[index]); digit.x = x + widths[index] / 2; x += widths[index] + 2;
|
||||
digit.y = ((lines.length - 1) / 2 - row) * 50;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3330,6 +3330,9 @@
|
||||
},
|
||||
"uiAtlas": null,
|
||||
"skylineHealth": null,
|
||||
"coinFrame": {
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"iceb": null,
|
||||
"chuizi": null,
|
||||
"starb": null,
|
||||
@@ -10137,4 +10140,4 @@
|
||||
"fileId": "",
|
||||
"sync": false
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -2320,6 +2320,9 @@
|
||||
"skylineHealth": {
|
||||
"__uuid__": "419e6dd8-8ab5-4910-bf94-b82afe18191b"
|
||||
},
|
||||
"coinFrame": {
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"iceb": {
|
||||
"__uuid__": "ac60b2a5-c833-400a-b640-6eb478c96f1f"
|
||||
},
|
||||
|
||||
@@ -37,6 +37,9 @@ export default class PassCheckItem extends cc.Component {
|
||||
@property(cc.SpriteFrame)
|
||||
skylineHealth: cc.SpriteFrame = null;
|
||||
|
||||
@property(cc.SpriteFrame)
|
||||
coinFrame: cc.SpriteFrame = null;
|
||||
|
||||
@property(cc.SpriteFrame)
|
||||
iceb: cc.SpriteFrame = null;
|
||||
|
||||
@@ -54,7 +57,7 @@ export default class PassCheckItem extends cc.Component {
|
||||
// 1001 金币 2001 锤子 2003 魔棒 3001 15分钟无限体力 3002 30分钟 3003 1小时 3004 2小时 3005 3小时
|
||||
// 添加物品ID到图片名称的映射
|
||||
private itemImageMap: { [key: number]: { imageName: string, atlas?: string } } = {
|
||||
1001: { imageName: "coins4", atlas: "texture_atlas" }, // shop/img/texture_atlas-1
|
||||
1001: { imageName: "coinFrame" },
|
||||
2001: { imageName: "iceb" },
|
||||
2002: { imageName: "chuizi" },
|
||||
2003: { imageName: "starb" },
|
||||
@@ -235,7 +238,7 @@ export default class PassCheckItem extends cc.Component {
|
||||
}
|
||||
|
||||
if (imageInfo) {
|
||||
// 道具使用预制体绑定的图片,金币仍从图集取图。
|
||||
// 奖励图标使用预制体绑定的图片。
|
||||
const targetAtlas: cc.SpriteAtlas = imageInfo.atlas ? this[imageInfo.atlas] : null;
|
||||
if (freeReward) {
|
||||
const spriteFrame: cc.SpriteFrame = imageInfo.atlas
|
||||
|
||||
Reference in New Issue
Block a user