From 67d1545198517ecafc7d4a178702ec96103c35fb Mon Sep 17 00:00:00 2001 From: bridge Date: Sun, 5 Oct 2025 13:45:05 +0800 Subject: [PATCH] fix bug --- src/front/rendering.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/front/rendering.py b/src/front/rendering.py index d253545..cd9fb5d 100644 --- a/src/front/rendering.py +++ b/src/front/rendering.py @@ -139,6 +139,10 @@ def draw_tooltip(pygame_mod, screen, colors, lines: List[str], mouse_x: int, mou x = mouse_x - width - 12 if y + height > screen_h: y = mouse_y - height - 12 + # 进一步夹紧,避免位于窗口上边或左边之外 + x = max(0, min(x, screen_w - width)) + top_limit = 0 # 如需避免覆盖状态栏,可改为 STATUS_BAR_HEIGHT + y = max(top_limit, min(y, screen_h - height)) bg_rect = pygame_mod.Rect(x, y, width, height) pygame_mod.draw.rect(screen, colors["tooltip_bg"], bg_rect, border_radius=6) pygame_mod.draw.rect(screen, colors["tooltip_bd"], bg_rect, 1, border_radius=6)