pygkit 2.1.0__tar.gz → 2.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. {pygkit-2.1.0 → pygkit-2.1.1}/PKG-INFO +1 -1
  2. {pygkit-2.1.0 → pygkit-2.1.1}/pyproject.toml +1 -1
  3. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/__init__.py +8 -12
  4. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/ui/__init__.py +5 -7
  5. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/ui/button.py +90 -2
  6. pygkit-2.1.1/src/pygkit/ui/container.py +176 -0
  7. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/ui/cooldown.py +33 -2
  8. pygkit-2.1.1/src/pygkit/ui/layout.py +250 -0
  9. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit.egg-info/PKG-INFO +1 -1
  10. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit.egg-info/SOURCES.txt +2 -0
  11. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_button.py +39 -0
  12. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_container.py +11 -9
  13. pygkit-2.1.1/tests/test_cooldown.py +71 -0
  14. pygkit-2.1.1/tests/test_layout.py +331 -0
  15. pygkit-2.1.0/src/pygkit/ui/container.py +0 -54
  16. pygkit-2.1.0/tests/test_cooldown.py +0 -42
  17. {pygkit-2.1.0 → pygkit-2.1.1}/LICENSE +0 -0
  18. {pygkit-2.1.0 → pygkit-2.1.1}/README.md +0 -0
  19. {pygkit-2.1.0 → pygkit-2.1.1}/setup.cfg +0 -0
  20. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/animation/__init__.py +0 -0
  21. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/animation/player.py +0 -0
  22. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/animation/sheet.py +0 -0
  23. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/audio/__init__.py +0 -0
  24. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/audio/soundmanager.py +0 -0
  25. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/inventory/__init__.py +0 -0
  26. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/inventory/assets.py +0 -0
  27. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/inventory/core.py +0 -0
  28. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/inventory/data.py +0 -0
  29. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/inventory/ui.py +0 -0
  30. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/lighting/__init__.py +0 -0
  31. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/lighting/blend.py +0 -0
  32. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/lighting/lightmap.py +0 -0
  33. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/lighting/lights.py +0 -0
  34. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/lighting/sprites.py +0 -0
  35. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/parallax/__init__.py +0 -0
  36. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/parallax/background.py +0 -0
  37. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/parallax/camera.py +0 -0
  38. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/protocols.py +0 -0
  39. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/signals/__init__.py +0 -0
  40. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/signals/core.py +0 -0
  41. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/transitions/__init__.py +0 -0
  42. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/transitions/base.py +0 -0
  43. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/transitions/effects.py +0 -0
  44. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/transitions/fades.py +0 -0
  45. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/transitions/wipes.py +0 -0
  46. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/ui/anchors.py +0 -0
  47. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/ui/base.py +0 -0
  48. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/ui/dialog.py +0 -0
  49. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/ui/menubar.py +0 -0
  50. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/ui/progressbar.py +0 -0
  51. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/utils/__init__.py +0 -0
  52. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/utils/interpolation.py +0 -0
  53. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/utils/text.py +0 -0
  54. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit/utils/timer.py +0 -0
  55. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit.egg-info/dependency_links.txt +0 -0
  56. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit.egg-info/requires.txt +0 -0
  57. {pygkit-2.1.0 → pygkit-2.1.1}/src/pygkit.egg-info/top_level.txt +0 -0
  58. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_anchors.py +0 -0
  59. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_animation.py +0 -0
  60. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_audio.py +0 -0
  61. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_box_model.py +0 -0
  62. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_dialog.py +0 -0
  63. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_interpolation.py +0 -0
  64. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_inventory.py +0 -0
  65. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_lighting.py +0 -0
  66. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_menubar.py +0 -0
  67. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_packaging.py +0 -0
  68. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_parallax.py +0 -0
  69. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_signals.py +0 -0
  70. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_text.py +0 -0
  71. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_timer.py +0 -0
  72. {pygkit-2.1.0 → pygkit-2.1.1}/tests/test_transitions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygkit
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
  Summary: General-purpose Pygame CE runtime kit: UI widgets, audio, timers, interpolation, and more.
5
5
  Author: pygkit contributors
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pygkit"
7
- version = "2.1.0"
7
+ version = "2.1.1"
8
8
  description = "General-purpose Pygame CE runtime kit: UI widgets, audio, timers, interpolation, and more."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -89,12 +89,10 @@ _LAZY_ATTRS: dict[str, str] = {
89
89
  "Button": "ui",
90
90
  "ButtonStyle": "ui",
91
91
  "Menubar": "ui",
92
- "ANCHORS": "ui",
93
- "anchor_point": "ui",
94
- "place": "ui",
95
- "row": "ui",
96
- "column": "ui",
97
- "grid": "ui",
92
+ "AnchorLayout": "ui",
93
+ "HBox": "ui",
94
+ "VBox": "ui",
95
+ "GridBox": "ui",
98
96
  "ItemData": "inventory",
99
97
  "InventoryConfig": "inventory",
100
98
  "ItemStack": "inventory",
@@ -170,12 +168,10 @@ __all__ = [
170
168
  "Button",
171
169
  "ButtonStyle",
172
170
  "Menubar",
173
- "ANCHORS",
174
- "anchor_point",
175
- "place",
176
- "row",
177
- "column",
178
- "grid",
171
+ "AnchorLayout",
172
+ "HBox",
173
+ "VBox",
174
+ "GridBox",
179
175
  "ItemData",
180
176
  "InventoryConfig",
181
177
  "ItemStack",
@@ -1,9 +1,9 @@
1
- from .anchors import ANCHORS, anchor_point, column, grid, place, row
2
1
  from .base import UIBase, UIOptions, BoxModel, BoxModelResult, generate_box_model
3
2
  from .button import Button, ButtonStyle
4
3
  from .container import Container
5
4
  from .cooldown import CooldownOverlay
6
5
  from .dialog import DialogBox, DialogConfig, DialogColors, DialogLine, TypewriterSpeed
6
+ from .layout import AnchorLayout, GridBox, HBox, VBox
7
7
  from .menubar import Menubar
8
8
  from .progressbar import ProgressBarUI
9
9
 
@@ -24,10 +24,8 @@ __all__ = [
24
24
  "Button",
25
25
  "ButtonStyle",
26
26
  "Menubar",
27
- "ANCHORS",
28
- "anchor_point",
29
- "place",
30
- "row",
31
- "column",
32
- "grid",
27
+ "AnchorLayout",
28
+ "HBox",
29
+ "VBox",
30
+ "GridBox",
33
31
  ]
@@ -18,6 +18,11 @@ class ButtonStyle:
18
18
  hover_tint: ColorLike | None = (255, 255, 255, 36)
19
19
  pressed_tint: ColorLike | None = (0, 0, 0, 70)
20
20
  disabled_tint: ColorLike | None = (0, 0, 0, 110)
21
+ gradient_top: ColorLike | None = (44, 48, 60, 255)
22
+ gradient_bottom: ColorLike | None = (26, 28, 36, 255)
23
+ shadow_color: ColorLike | None = (0, 0, 0, 80)
24
+ shadow_offset: tuple[int, int] = (0, 2)
25
+ icon_gap: int = 8
21
26
 
22
27
 
23
28
  class Button(UIBase):
@@ -55,7 +60,7 @@ class Button(UIBase):
55
60
  **{
56
61
  "width": width,
57
62
  "height": height,
58
- "border_radius": 6,
63
+ "border_radius": 9,
59
64
  "border_width": 0,
60
65
  "background": (20, 22, 28, 255),
61
66
  },
@@ -66,6 +71,9 @@ class Button(UIBase):
66
71
  self._hovered = False
67
72
  self._label: Surface | None = None
68
73
  self._tint: dict[str, Surface | None] = {"hover": None, "pressed": None, "disabled": None}
74
+ self._background: Surface | None = None
75
+ self._shadow: Surface | None = None
76
+ self._flat_background = "background" in overrides
69
77
  self._origin = (0, 0)
70
78
 
71
79
  def set_text(self, text: str) -> None:
@@ -79,6 +87,64 @@ class Button(UIBase):
79
87
  def invalidate(self) -> None:
80
88
  self._label = None
81
89
  self._tint = {"hover": None, "pressed": None, "disabled": None}
90
+ self._background = None
91
+ self._shadow = None
92
+
93
+ @staticmethod
94
+ def _to_rgba(color: ColorLike) -> tuple[int, int, int, int]:
95
+ c = pygame.Color(color)
96
+ return (c.r, c.g, c.b, c.a)
97
+
98
+ @classmethod
99
+ def _build_gradient(
100
+ cls,
101
+ size: tuple[int, int],
102
+ top: ColorLike,
103
+ bottom: ColorLike,
104
+ radius: int,
105
+ ) -> Surface:
106
+ """Build a vertical gradient with rounded corners (cached, build-time only)."""
107
+ w, h = max(1, size[0]), max(1, size[1])
108
+ surf = Surface((w, h), SRCALPHA)
109
+ surf.fill((0, 0, 0, 0))
110
+ tr, tg, tb, ta = cls._to_rgba(top)
111
+ br, bg, bb, ba = cls._to_rgba(bottom)
112
+ radius = max(0, min(radius, w // 2, h // 2))
113
+ for y in range(h):
114
+ t = y / (h - 1) if h > 1 else 0.0
115
+ color = (
116
+ round(tr + (br - tr) * t),
117
+ round(tg + (bg - tg) * t),
118
+ round(tb + (bb - tb) * t),
119
+ round(ta + (ba - ta) * t),
120
+ )
121
+ if radius <= 0 or (y >= radius and y < h - radius):
122
+ pygame.draw.line(surf, color, (0, y), (w - 1, y))
123
+ else:
124
+ dy = radius - y - 1 if y < radius else y - (h - radius)
125
+ dx = int((radius * radius - dy * dy) ** 0.5)
126
+ x0 = radius - dx
127
+ x1 = w - radius + dx - 1
128
+ if x1 >= x0:
129
+ pygame.draw.line(surf, color, (x0, y), (x1, y))
130
+ # Subtle top highlight for a raised look.
131
+ if w > 2 * radius + 2 and h > 3:
132
+ pygame.draw.line(surf, (255, 255, 255, 22), (radius, 1), (w - radius - 1, 1))
133
+ return surf
134
+
135
+ @classmethod
136
+ def _build_shadow(
137
+ cls,
138
+ size: tuple[int, int],
139
+ radius: int,
140
+ color: ColorLike,
141
+ ) -> Surface:
142
+ """Build a filled rounded shadow sprite (cached, build-time only)."""
143
+ w, h = max(1, size[0]), max(1, size[1])
144
+ surf = Surface((w, h), SRCALPHA)
145
+ surf.fill((0, 0, 0, 0))
146
+ pygame.draw.rect(surf, color, (0, 0, w, h), border_radius=max(0, radius))
147
+ return surf
82
148
 
83
149
  def _ensure(self) -> None:
84
150
  if self._label is None and self.text:
@@ -94,6 +160,23 @@ class Button(UIBase):
94
160
  surf = Surface((max(1, w), max(1, h)), SRCALPHA)
95
161
  surf.fill(color)
96
162
  self._tint[key] = surf
163
+ if self._background is None:
164
+ radius = max(0, self.border["radius"] - self.border["width"])
165
+ if (
166
+ not self._flat_background
167
+ and self.style.gradient_top is not None
168
+ and self.style.gradient_bottom is not None
169
+ ):
170
+ self._background = self._build_gradient(
171
+ (w, h), self.style.gradient_top, self.style.gradient_bottom, radius
172
+ )
173
+ else:
174
+ self._background = None
175
+ if self._shadow is None and self.style.shadow_color is not None:
176
+ full = self.size
177
+ self._shadow = self._build_shadow(
178
+ full, max(0, self.border["radius"]), self.style.shadow_color
179
+ )
97
180
 
98
181
  def render(self, screen: Surface, pos_offset: tuple[int, int] = (0, 0)) -> None:
99
182
  self.draw_base()
@@ -103,11 +186,16 @@ class Button(UIBase):
103
186
  self.box_model["offset_y"] + pos_offset[1],
104
187
  )
105
188
  self._origin = pos
189
+ if self._shadow is not None:
190
+ sx, sy = self.style.shadow_offset
191
+ screen.blit(self._shadow, (pos[0] + sx, pos[1] + sy))
106
192
  base = (self.box_model["left"], self.box_model["top"])
107
193
  _, h = self.size
194
+ if self._background is not None:
195
+ self.local_surface.blit(self._background, base)
108
196
  if self.image is not None:
109
197
  self.local_surface.blit(self.image, base)
110
- x = base[0] + 8
198
+ x = base[0] + max(0, self.style.icon_gap)
111
199
  if self.image is not None and self._label is not None:
112
200
  x = base[0] + (self.size[0] - self._label.get_width()) // 2
113
201
  if self._label is not None:
@@ -0,0 +1,176 @@
1
+ """Composable groups of widgets with cached local layout positions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from typing import Any
7
+
8
+ import pygame
9
+ from pygame import Surface
10
+
11
+ from ..protocols import Widget
12
+
13
+
14
+ @dataclass
15
+ class _Child:
16
+ widget: Widget
17
+ placement: Any
18
+ position: tuple[int, int] = (0, 0)
19
+
20
+
21
+ class Container:
22
+ """Content-sized group with explicit child positions.
23
+
24
+ Positions are local to this container. Negative positions may overflow
25
+ its reported size without increasing it.
26
+ """
27
+
28
+ def __init__(self) -> None:
29
+ self._child_records: list[_Child] = []
30
+ self._layout_dirty = True
31
+ self._size_snapshot: tuple[tuple[int, int], ...] = ()
32
+ self._settings_snapshot: object = None
33
+
34
+ def add(
35
+ self, child: Widget, *, pos: tuple[int, int] = (0, 0)
36
+ ) -> Widget:
37
+ """Add ``child`` at a position relative to this container."""
38
+ self._append_child(child, pos)
39
+ return child
40
+
41
+ def _append_child(self, child: Widget, placement: Any) -> int:
42
+ if not isinstance(child, Widget):
43
+ raise TypeError(
44
+ f"{type(self).__name__}.add() needs render/update/size, "
45
+ f"got {type(child).__name__}"
46
+ )
47
+ self._child_records.append(_Child(child, placement))
48
+ self._layout_dirty = True
49
+ return len(self._child_records) - 1
50
+
51
+ def _child_count(self) -> int:
52
+ return len(self._child_records)
53
+
54
+ def _child_at(self, index: int) -> Widget:
55
+ return self._child_records[index].widget
56
+
57
+ def _placement_at(self, index: int) -> Any:
58
+ return self._child_records[index].placement
59
+
60
+ def _set_placement(self, index: int, placement: Any) -> None:
61
+ self._child_records[index].placement = placement
62
+ self._layout_dirty = True
63
+
64
+ def _set_position(self, index: int, position: tuple[int, int]) -> None:
65
+ self._child_records[index].position = position
66
+
67
+ def _index_of(self, child: Widget) -> int | None:
68
+ return next(
69
+ (
70
+ index
71
+ for index, entry in enumerate(self._child_records)
72
+ if entry.widget is child
73
+ ),
74
+ None,
75
+ )
76
+
77
+ def _layout_settings(self) -> object:
78
+ """Return values that affect placement; subclasses may override."""
79
+ return None
80
+
81
+ def _resolve_layout(self) -> None:
82
+ for index in range(self._child_count()):
83
+ self._set_position(index, self._resolve_position(index))
84
+
85
+ def _resolve_position(self, index: int) -> tuple[int, int]:
86
+ return self._placement_at(index)
87
+
88
+ def _ensure_layout(self) -> None:
89
+ sizes = tuple(
90
+ self._child_at(i).size for i in range(self._child_count())
91
+ )
92
+ settings = self._layout_settings()
93
+ if (
94
+ self._layout_dirty
95
+ or sizes != self._size_snapshot
96
+ or settings != self._settings_snapshot
97
+ ):
98
+ self._resolve_layout()
99
+ self._size_snapshot = sizes
100
+ self._settings_snapshot = settings
101
+ self._layout_dirty = False
102
+
103
+ @property
104
+ def children(self) -> list[tuple[Widget, tuple[int, int]]]:
105
+ """Return a snapshot of children and their resolved local positions."""
106
+ self._ensure_layout()
107
+ return [
108
+ (entry.widget, entry.position) for entry in self._child_records
109
+ ]
110
+
111
+ def relayout(self) -> None:
112
+ """Invalidate cached positions; child size changes are detected too."""
113
+ self._layout_dirty = True
114
+ self._ensure_layout()
115
+
116
+ def remove(self, child: Widget) -> bool:
117
+ index = self._index_of(child)
118
+ if index is None:
119
+ return False
120
+ del self._child_records[index]
121
+ self._layout_dirty = True
122
+ return True
123
+
124
+ @property
125
+ def size(self) -> tuple[int, int]:
126
+ self._ensure_layout()
127
+ return (
128
+ max(
129
+ (
130
+ entry.position[0] + entry.widget.size[0]
131
+ for entry in self._child_records
132
+ ),
133
+ default=0,
134
+ ),
135
+ max(
136
+ (
137
+ entry.position[1] + entry.widget.size[1]
138
+ for entry in self._child_records
139
+ ),
140
+ default=0,
141
+ ),
142
+ )
143
+
144
+ def handle_event(self, event: pygame.event.Event) -> bool:
145
+ self._ensure_layout()
146
+ if event.type not in (pygame.MOUSEBUTTONDOWN, pygame.MOUSEBUTTONUP):
147
+ return False
148
+ if getattr(event, "button", None) != 1:
149
+ return False
150
+ method_name = (
151
+ "press" if event.type == pygame.MOUSEBUTTONDOWN else "activate"
152
+ )
153
+ for entry in reversed(self._child_records):
154
+ method = getattr(entry.widget, method_name, None)
155
+ if method is not None and method(event.pos):
156
+ return True
157
+ route = getattr(entry.widget, "handle_event", None)
158
+ if route is not None and route(event):
159
+ return True
160
+ return False
161
+
162
+ def update(self, dt: float = 0.0) -> None:
163
+ self._ensure_layout()
164
+ for entry in self._child_records:
165
+ entry.widget.update(dt)
166
+
167
+ def render(
168
+ self, screen: Surface, pos_offset: tuple[int, int] = (0, 0)
169
+ ) -> None:
170
+ self._ensure_layout()
171
+ for entry in self._child_records:
172
+ position = entry.position
173
+ entry.widget.render(
174
+ screen,
175
+ (position[0] + pos_offset[0], position[1] + pos_offset[1]),
176
+ )
@@ -39,15 +39,41 @@ class CooldownOverlay(UIBase):
39
39
 
40
40
  self.overlay_parent = Surface((max(1, content_w), max(1, content_h)), SRCALPHA)
41
41
  self._disabled_surf: Optional[Surface] = None
42
+ # Rounded mask matching the content-box background shape, so the
43
+ # icon, sweep, and disabled layers share one silhouette. Square
44
+ # when the radius is 0 (no-op, skipped). Built once; the sweep
45
+ # reuses it per frame with a single blit.
46
+ content_radius = max(0, b - self.border["width"])
47
+ if content_radius > 0 and content_w > 0 and content_h > 0:
48
+ mask = Surface((content_w, content_h), SRCALPHA)
49
+ mask.fill((0, 0, 0, 0))
50
+ draw.rect(
51
+ mask,
52
+ (255, 255, 255, 255),
53
+ (0, 0, content_w, content_h),
54
+ border_radius=content_radius,
55
+ )
56
+ self._mask: Optional[Surface] = mask
57
+ else:
58
+ self._mask = None
42
59
  self.add_plugin(self._draw_overlay)
43
60
  self.add_plugin(self._draw_disabled_overlay)
44
61
  if icon is not None:
45
62
  scale = content_w / icon.width, content_h / icon.height
46
- self.icon = transform.scale_by(icon.copy(), scale)
63
+ scaled = transform.scale_by(icon.copy(), scale)
64
+ canvas = Surface(scaled.get_size(), SRCALPHA)
65
+ canvas.blit(scaled, (0, 0))
66
+ if self._mask is not None:
67
+ canvas.blit(self._mask, (0, 0), special_flags=pygame.BLEND_RGBA_MULT)
68
+ self.icon = canvas
47
69
  self.add_plugin(self._draw_icon)
48
70
 
49
71
  def update(self, dt: float = 0.0) -> None:
50
- self.timer.update(dt)
72
+ # Read-only by design: the overlay never ticks the timer.
73
+ # The owner of the timer advances it; HUD only reads
74
+ # ratio()/reached(). Kept so Container.update() propagation
75
+ # keeps working for mixed children.
76
+ _ = dt
51
77
 
52
78
  def _draw_icon(self, surface: Surface) -> None:
53
79
  icon: Optional[Surface] = getattr(self, "icon", None)
@@ -95,6 +121,9 @@ class CooldownOverlay(UIBase):
95
121
  if len(points) > 2:
96
122
  draw.polygon(op, self.overlay_color, points)
97
123
 
124
+ if self._mask is not None:
125
+ op.blit(self._mask, (0, 0), special_flags=pygame.BLEND_RGBA_MULT)
126
+
98
127
  pos = self.box_model["left"], self.box_model["top"]
99
128
  surface.blit(op, pos)
100
129
 
@@ -108,5 +137,7 @@ class CooldownOverlay(UIBase):
108
137
  self._disabled_surf = Surface((w, h), SRCALPHA)
109
138
 
110
139
  self._disabled_surf.fill(self.disabled_color)
140
+ if self._mask is not None:
141
+ self._disabled_surf.blit(self._mask, (0, 0), special_flags=pygame.BLEND_RGBA_MULT)
111
142
  pos = self.box_model["left"], self.box_model["top"]
112
143
  surface.blit(self._disabled_surf, pos)