fixed # 修复头像框资源位置错误的BUG

This commit is contained in:
2026-10-20 11:49:44 +08:00
parent 2b0fca8828
commit 92a3944e43
20 changed files with 754 additions and 74 deletions
Binary file not shown.
+195
View File
@@ -6195,6 +6195,48 @@
120
]
},
"webgl/panel/CouponIcon.png": {
"sha256": "8f564bf9da5c0fbeb65a3e320cfb47d66648405f09e2309a42825c1f5404caf1",
"size": [
64,
64
]
},
"webgl/panel/ExpBar.png": {
"sha256": "efb13c2dcb1ecd49689ed561d3f816312738f84887e01496385914e86dcf87d5",
"size": [
223,
30
]
},
"webgl/panel/ExpProgress.png": {
"sha256": "fcb1bdc9a568758460e005a1be58c04d8346eaedfcbc3fef59b29ad0dedcfdc0",
"size": [
225,
23
]
},
"webgl/panel/GoldIcon.png": {
"sha256": "5389afb3a3b1245e9fdc8d3a8839c8ff07a653ebf160bb8e43882a461e73ce49",
"size": [
64,
64
]
},
"webgl/panel/HeadFrame.png": {
"sha256": "74e8f716f58f9055d873657eb8fbaea2170ea19365fe83299b8e32f8484b0b62",
"size": [
230,
230
]
},
"webgl/panel/PersionInfoBG.png": {
"sha256": "62971e70743418988982667625f3e6e4e61073e74610c5279919be2e71c1bd10",
"size": [
492,
236
]
},
"webgl/seed.png": {
"sha256": "353ff338fd5ab3f7812e9d2d7f98df11d0de4e04af6de7f9d5aa0249d40b3609",
"size": [
@@ -6210,6 +6252,159 @@
]
}
},
"panel": {
"anchor": "top_left",
"avatar": [
32.2744255065918,
39.76182556152344,
111.38700103759766,
107.70719909667969
],
"fields": [
{
"alignment": 3,
"color": [
74,
31,
0
],
"field": "name",
"rect": [
161.24510192871094,
40.90002250671387,
298.0353088378906,
31.200000762939453
]
},
{
"alignment": 4,
"color": [
91,
110,
3
],
"field": "experience",
"rect": [
177.60003662109375,
89.78792595863342,
223.0,
22.024199962615967
]
},
{
"alignment": 4,
"color": [
216,
112,
0
],
"field": "level",
"rect": [
400.9734191894531,
85.36273193359375,
56.0,
30.0
]
},
{
"alignment": 3,
"color": [
255,
255,
255
],
"field": "point",
"rect": [
178.46239471435547,
128.23919677734375,
123.61039733886719,
30.0
]
},
{
"alignment": 3,
"color": [
255,
255,
255
],
"field": "vip_point",
"rect": [
342.0,
128.23919677734375,
108.0,
30.0
]
}
],
"reference_canvas": [
1920,
1080
],
"source_prefab": "mainscene#WebGLPersionInfo",
"sprites": [
{
"name": "PersionInfoBG",
"rect": [
0.0,
0.0,
492.0,
236.0
],
"sprite": "webgl/panel/PersionInfoBG.png"
},
{
"name": "HeadFrame",
"rect": [
3.092998504638672,
8.865001678466797,
169.75,
169.5
],
"sprite": "webgl/panel/HeadFrame.png"
},
{
"name": "ExpBar",
"rect": [
177.60000610351562,
85.89997100830078,
223.0,
30.0
],
"sprite": "webgl/panel/ExpBar.png"
},
{
"name": "ExpProgress",
"rect": [
179.90000915527344,
89.89997100830078,
215.0,
22.0
],
"sprite": "webgl/panel/ExpProgress.png"
},
{
"name": "GoldIcon",
"rect": [
146.5999984741211,
128.8000030517578,
30.0,
30.0
],
"sprite": "webgl/panel/GoldIcon.png"
},
{
"name": "CouponIcon",
"rect": [
310.5,
128.8000030517578,
30.0,
30.0
],
"sprite": "webgl/panel/CouponIcon.png"
}
]
},
"pest": {
"display_size": [
22,
+53 -33
View File
@@ -17,6 +17,7 @@ from .models import RenderOptions, RenderResult
logger = logging.getLogger(__name__)
MAX_AVATAR_BYTES = 2 * 1024 * 1024
MAX_AVATAR_PIXELS = 4_000_000
PANEL_UNUSED_ROW = (168, 208)
class FarmRenderer:
@@ -218,45 +219,64 @@ class FarmRenderer:
return avatar
def _panel(self, canvas, scene, options, avatar):
s = lambda n: self._scale(n, options)
def paste_asset(name, position):
original = self.assets.metadata["images"][name]["size"]
image = self.assets.image(
name, tuple(max(1, s(n)) for n in original),
)
canvas.paste(image, tuple(s(n) for n in position))
paste_asset("background/userInfo.png", (100, 30))
canvas.paste(
self._avatar(avatar, (max(1, s(140)), max(1, s(150)))),
(s(125), s(85)),
)
paste_asset("background/frame/frame.png", (75, 44))
layout = self.assets.metadata['panel']
s = lambda n: round(n * options.width / layout['reference_canvas'][0])
account = scene.account
level = account.level
current = account.experience - 200 * level * (level + 1) // 2
next_total = 200 * (level + 1) * (level + 2) // 2
progress = min(247, max(0, current * 247 // next_total))
if progress:
canvas.rectangle(
tuple(s(n) for n in (292, 164, 292 + progress, 189)),
(171, 194, 41),
for entry in layout['sprites']:
x, y, w, h = entry['rect']
image = self.assets.image(
entry['sprite'], (max(1, s(w)), max(1, s(h))),
)
lines = (
(account.name, (300, 92), 24, (77, 35, 4), 330),
(f"{current} / {next_total}", (365, 164), 20,
(102, 120, 19), 165),
(str(level), (570, 158), 32, (214, 111, 1), 60),
(str(account.point), (330, 211), 24, (253, 253, 253), 100),
(str(account.vip_point), (570, 211), 24, (253, 253, 253), 40),
)
for value, position, original_size, color, width in lines:
size = max(1, s(original_size))
if entry['name'] == 'PersionInfoBG':
start, end = (s(n) for n in PANEL_UNUSED_ROW)
compact = Image.new('RGBA', (
image.width, image.height - (end - start),
))
compact.paste(image.crop((0, 0, image.width, start)))
compact.paste(image.crop((
0, end, image.width, image.height,
)), (0, start))
image = compact
if entry['name'] == 'ExpProgress':
filled = min(image.width, max(
0, current * image.width // next_total,
))
if not filled:
continue
image = image.crop((0, 0, filled, image.height))
canvas.paste(image, (s(x), s(y)))
if entry['name'] == 'PersionInfoBG':
ax, ay, aw, ah = layout['avatar']
canvas.paste(self._avatar(
avatar, (max(1, s(aw)), max(1, s(ah))),
), (s(ax), s(ay)))
values = {
'name': account.name, 'experience': f'{current} / {next_total}',
'level': str(level), 'point': str(account.point),
'vip_point': str(account.vip_point),
}
for entry in layout['fields']:
x, y, w, h = entry['rect']
value = values[entry['field']]
width, height = max(1, s(w)), max(1, s(h))
size = height
while size > 1:
box = font(self.font_path, size).getbbox(value)
if (box[2]-box[0] <= width
and box[3]-box[1] <= height):
break
size -= 1
text = canvas.fit_text(
value, self.font_path, size, max(1, s(width)),
value, self.font_path, size, width,
)
box = font(self.font_path, size).getbbox(text)
left = s(x) - box[0]
if entry['alignment'] == 4:
left += (width - (box[2]-box[0])) // 2
top = s(y) + (height - (box[3]-box[1])) // 2 - box[1]
canvas.text(
tuple(s(n) for n in position), text,
self.font_path, size, color,
(left, top), text, self.font_path, size, tuple(entry['color']),
)
+195
View File
@@ -25,6 +25,20 @@
],
"sha256": "226c96b60648787fd457d2f968c0eee7c610444f191e6c73fdd071fa6e95bf14"
},
"webgl/panel/GoldIcon.png": {
"size": [
64,
64
],
"sha256": "5389afb3a3b1245e9fdc8d3a8839c8ff07a653ebf160bb8e43882a461e73ce49"
},
"webgl/panel/HeadFrame.png": {
"size": [
230,
230
],
"sha256": "74e8f716f58f9055d873657eb8fbaea2170ea19365fe83299b8e32f8484b0b62"
},
"pest/pest37.png": {
"size": [
44,
@@ -116,6 +130,13 @@
],
"sha256": "1ad3f1bd4521ef462056b88070728853fc93de85457eac1903d8dd11dc175642"
},
"webgl/panel/PersionInfoBG.png": {
"size": [
492,
236
],
"sha256": "62971e70743418988982667625f3e6e4e61073e74610c5279919be2e71c1bd10"
},
"pest/pest69.png": {
"size": [
44,
@@ -172,6 +193,13 @@
],
"sha256": "8a78d0b046991de083334cabba06291fecc7739be501beb2caf3fcc87f5454f7"
},
"webgl/panel/ExpProgress.png": {
"size": [
225,
23
],
"sha256": "fcb1bdc9a568758460e005a1be58c04d8346eaedfcbc3fef59b29ad0dedcfdc0"
},
"pest/pest65.png": {
"size": [
44,
@@ -249,6 +277,13 @@
],
"sha256": "353ff338fd5ab3f7812e9d2d7f98df11d0de4e04af6de7f9d5aa0249d40b3609"
},
"webgl/panel/CouponIcon.png": {
"size": [
64,
64
],
"sha256": "8f564bf9da5c0fbeb65a3e320cfb47d66648405f09e2309a42825c1f5404caf1"
},
"pest/pest27.png": {
"size": [
44,
@@ -263,6 +298,13 @@
],
"sha256": "fc3a21ed236cd2200704d2971c54dcf6f90fe92ada756da6acb70b78d2c9fd82"
},
"webgl/panel/ExpBar.png": {
"size": [
223,
30
],
"sha256": "efb13c2dcb1ecd49689ed561d3f816312738f84887e01496385914e86dcf87d5"
},
"pest/pest61.png": {
"size": [
44,
@@ -285,6 +327,159 @@
"sha256": "5bd1ed7e9db82572119403fce50ff9c7276df33ad4288869aeac3fa5896652e6"
}
},
"panel": {
"reference_canvas": [
1920,
1080
],
"source_prefab": "mainscene#WebGLPersionInfo",
"anchor": "top_left",
"sprites": [
{
"name": "PersionInfoBG",
"sprite": "webgl/panel/PersionInfoBG.png",
"rect": [
0.0,
0.0,
492.0,
236.0
]
},
{
"name": "HeadFrame",
"sprite": "webgl/panel/HeadFrame.png",
"rect": [
3.092998504638672,
8.865001678466797,
169.75,
169.5
]
},
{
"name": "ExpBar",
"sprite": "webgl/panel/ExpBar.png",
"rect": [
177.60000610351562,
85.89997100830078,
223.0,
30.0
]
},
{
"name": "ExpProgress",
"sprite": "webgl/panel/ExpProgress.png",
"rect": [
179.90000915527344,
89.89997100830078,
215.0,
22.0
]
},
{
"name": "GoldIcon",
"sprite": "webgl/panel/GoldIcon.png",
"rect": [
146.5999984741211,
128.8000030517578,
30.0,
30.0
]
},
{
"name": "CouponIcon",
"sprite": "webgl/panel/CouponIcon.png",
"rect": [
310.5,
128.8000030517578,
30.0,
30.0
]
}
],
"avatar": [
32.2744255065918,
39.76182556152344,
111.38700103759766,
107.70719909667969
],
"fields": [
{
"field": "name",
"rect": [
161.24510192871094,
40.90002250671387,
298.0353088378906,
31.200000762939453
],
"alignment": 3,
"color": [
74,
31,
0
]
},
{
"field": "experience",
"rect": [
177.60003662109375,
89.78792595863342,
223.0,
22.024199962615967
],
"alignment": 4,
"color": [
91,
110,
3
]
},
{
"field": "level",
"rect": [
400.9734191894531,
85.36273193359375,
56.0,
30.0
],
"alignment": 4,
"color": [
216,
112,
0
]
},
{
"field": "point",
"rect": [
178.46239471435547,
128.23919677734375,
123.61039733886719,
30.0
],
"alignment": 3,
"color": [
255,
255,
255
]
},
{
"field": "vip_point",
"rect": [
342.0,
128.23919677734375,
108.0,
30.0
],
"alignment": 3,
"color": [
255,
255,
255
]
}
]
},
"pest": {
"frames": [
"pest/pest1.png",
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB