Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-05-09 16:35:25 +02:00
parent ac80210ba5
commit c7ff5ae4cf
12 changed files with 287 additions and 21 deletions
+23 -3
View File
@@ -494,9 +494,29 @@ class GameWindow:
if image := kwargs.get("image"):
image_width, image_height = self.get_image_size(image)
image_x = self.target_size[0] // 2 - image_width // 2
self.draw_image(image_x - self.w_offset, content_y - self.h_offset, image, "win")
content_y += image_height + max(14, panel_height // 30)
image_scale = kwargs.get("image_scale")
image_max_width = kwargs.get("image_max_width")
image_max_height = kwargs.get("image_max_height")
scale_limit = 1.0
if image_scale is not None:
scale_limit = min(scale_limit, max(0.01, float(image_scale)))
if image_max_width:
scale_limit = min(scale_limit, float(image_max_width) / image_width)
if image_max_height:
scale_limit = min(scale_limit, float(image_max_height) / image_height)
render_width = max(1, int(round(image_width * scale_limit)))
render_height = max(1, int(round(image_height * scale_limit)))
image_x = self.target_size[0] // 2 - render_width // 2
self.draw_image(
image_x - self.w_offset,
content_y - self.h_offset,
image,
"win",
dest_size=(render_width, render_height),
)
content_y += render_height + max(14, panel_height // 30)
if subtitle := kwargs.get("subtitle"):
subtitle_sprites = [