pygkit 2.1.1__tar.gz → 2.2.0__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 (157) hide show
  1. {pygkit-2.1.1 → pygkit-2.2.0}/PKG-INFO +3 -1
  2. {pygkit-2.1.1 → pygkit-2.2.0}/README.md +1 -0
  3. {pygkit-2.1.1 → pygkit-2.2.0}/pyproject.toml +2 -1
  4. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/__init__.py +26 -2
  5. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/animation/sheet.py +91 -40
  6. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/lighting/blend.py +2 -8
  7. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/lighting/lights.py +0 -2
  8. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/lighting/sprites.py +5 -8
  9. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/protocols.py +0 -2
  10. pygkit-2.2.0/src/pygkit/transitions/__init__.py +18 -0
  11. pygkit-2.2.0/src/pygkit/ui/__init__.py +58 -0
  12. pygkit-2.2.0/src/pygkit/ui/base.py +507 -0
  13. pygkit-2.2.0/src/pygkit/ui/button.py +284 -0
  14. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/ui/container.py +54 -15
  15. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/ui/cooldown.py +36 -51
  16. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/ui/dialog.py +23 -9
  17. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/ui/layout.py +81 -10
  18. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/ui/menubar.py +63 -21
  19. pygkit-2.2.0/src/pygkit/ui/panel.py +92 -0
  20. pygkit-2.2.0/src/pygkit/ui/progressbar.py +162 -0
  21. pygkit-2.2.0/src/pygkit/ui/theming.py +268 -0
  22. pygkit-2.2.0/src/pygkit/utils/__init__.py +19 -0
  23. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit.egg-info/PKG-INFO +3 -1
  24. pygkit-2.2.0/src/pygkit.egg-info/SOURCES.txt +151 -0
  25. pygkit-2.2.0/src/pygkit.egg-info/pygkit/__init__.py +46 -0
  26. pygkit-2.2.0/src/pygkit.egg-info/pygkit/__pycache__/__init__.cpython-312.pyc +0 -0
  27. pygkit-2.2.0/src/pygkit.egg-info/pygkit/__pycache__/__init__.cpython-313.pyc +0 -0
  28. pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/__init__.py +6 -0
  29. pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/__pycache__/__init__.cpython-312.pyc +0 -0
  30. pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/__pycache__/__init__.cpython-313.pyc +0 -0
  31. pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/__pycache__/soundmanager.cpython-312.pyc +0 -0
  32. pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/__pycache__/soundmanager.cpython-313.pyc +0 -0
  33. pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/soundmanager.py +89 -0
  34. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__init__.py +103 -0
  35. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/__init__.cpython-313.pyc +0 -0
  36. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/base.cpython-312.pyc +0 -0
  37. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/base.cpython-313.pyc +0 -0
  38. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/compositors.cpython-312.pyc +0 -0
  39. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/compositors.cpython-313.pyc +0 -0
  40. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/generators.cpython-312.pyc +0 -0
  41. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/generators.cpython-313.pyc +0 -0
  42. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/transitions.cpython-313.pyc +0 -0
  43. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/base.py +220 -0
  44. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/__init__.py +32 -0
  45. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/__pycache__/__init__.cpython-313.pyc +0 -0
  46. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/__pycache__/color.cpython-313.pyc +0 -0
  47. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/__pycache__/lighting.cpython-313.pyc +0 -0
  48. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/__pycache__/masks.cpython-313.pyc +0 -0
  49. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/color.py +237 -0
  50. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/lighting.py +261 -0
  51. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/masks.py +287 -0
  52. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/compositors.py +142 -0
  53. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/generators.py +318 -0
  54. pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/transitions.py +194 -0
  55. pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__init__.py +93 -0
  56. pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__pycache__/__init__.cpython-313.pyc +0 -0
  57. pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__pycache__/assets.cpython-313.pyc +0 -0
  58. pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__pycache__/core.cpython-313.pyc +0 -0
  59. pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__pycache__/data.cpython-313.pyc +0 -0
  60. pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__pycache__/ui.cpython-313.pyc +0 -0
  61. pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/assets.py +338 -0
  62. pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/core.py +614 -0
  63. pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/data.py +273 -0
  64. pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/ui.py +775 -0
  65. pygkit-2.2.0/src/pygkit.egg-info/pygkit/protocols.py +29 -0
  66. pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/__pycache__/__init__.cpython-313.pyc +0 -0
  67. pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/__pycache__/base.cpython-313.pyc +0 -0
  68. pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/__pycache__/effects.cpython-313.pyc +0 -0
  69. pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/__pycache__/fades.cpython-313.pyc +0 -0
  70. pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/__pycache__/wipes.cpython-313.pyc +0 -0
  71. pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/base.py +97 -0
  72. pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/effects.py +156 -0
  73. pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/fades.py +196 -0
  74. pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/wipes.py +185 -0
  75. {pygkit-2.1.1/src → pygkit-2.2.0/src/pygkit.egg-info}/pygkit/ui/__init__.py +0 -10
  76. pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/__init__.cpython-313.pyc +0 -0
  77. pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/base.cpython-313.pyc +0 -0
  78. pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/container.cpython-313.pyc +0 -0
  79. pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/cooldown.cpython-313.pyc +0 -0
  80. pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/dialog.cpython-313.pyc +0 -0
  81. pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/progressbar.cpython-313.pyc +0 -0
  82. {pygkit-2.1.1/src → pygkit-2.2.0/src/pygkit.egg-info}/pygkit/ui/base.py +5 -5
  83. pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/container.py +21 -0
  84. pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/cooldown.py +107 -0
  85. pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/dialog.py +540 -0
  86. {pygkit-2.1.1/src → pygkit-2.2.0/src/pygkit.egg-info}/pygkit/ui/progressbar.py +3 -3
  87. pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/__pycache__/__init__.cpython-313.pyc +0 -0
  88. pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/__pycache__/interpolation.cpython-313.pyc +0 -0
  89. pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/__pycache__/text.cpython-313.pyc +0 -0
  90. pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/__pycache__/timer.cpython-313.pyc +0 -0
  91. pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/interpolation.py +45 -0
  92. pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/text.py +147 -0
  93. pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/timer.py +35 -0
  94. pygkit-2.2.0/src/pygkit.egg-info/pygkit.egg-info/dependency_links.txt +1 -0
  95. pygkit-2.2.0/src/pygkit.egg-info/pygkit.egg-info/pkg-info +719 -0
  96. pygkit-2.2.0/src/pygkit.egg-info/pygkit.egg-info/requires.txt +1 -0
  97. pygkit-2.1.1/src/pygkit.egg-info/SOURCES.txt → pygkit-2.2.0/src/pygkit.egg-info/pygkit.egg-info/sources.txt +10 -31
  98. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit.egg-info/requires.txt +3 -0
  99. pygkit-2.2.0/src/pygkit.egg-info/top_level.txt +1 -0
  100. pygkit-2.2.0/tests/test_background_images.py +161 -0
  101. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_box_model.py +33 -1
  102. pygkit-2.2.0/tests/test_button.py +292 -0
  103. pygkit-2.2.0/tests/test_container.py +148 -0
  104. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_cooldown.py +24 -7
  105. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_dialog.py +17 -0
  106. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_layout.py +120 -7
  107. pygkit-2.2.0/tests/test_menubar.py +333 -0
  108. pygkit-2.2.0/tests/test_pack_spritesheet.py +100 -0
  109. pygkit-2.2.0/tests/test_panel.py +70 -0
  110. pygkit-2.2.0/tests/test_progressbar_image.py +144 -0
  111. pygkit-2.2.0/tests/test_theming.py +66 -0
  112. pygkit-2.1.1/src/pygkit/ui/button.py +0 -228
  113. pygkit-2.1.1/tests/test_button.py +0 -143
  114. pygkit-2.1.1/tests/test_container.py +0 -71
  115. pygkit-2.1.1/tests/test_menubar.py +0 -132
  116. {pygkit-2.1.1 → pygkit-2.2.0}/LICENSE +0 -0
  117. {pygkit-2.1.1 → pygkit-2.2.0}/setup.cfg +0 -0
  118. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/animation/__init__.py +0 -0
  119. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/animation/player.py +0 -0
  120. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/audio/__init__.py +0 -0
  121. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/audio/soundmanager.py +0 -0
  122. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/inventory/__init__.py +0 -0
  123. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/inventory/assets.py +0 -0
  124. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/inventory/core.py +0 -0
  125. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/inventory/data.py +0 -0
  126. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/inventory/ui.py +0 -0
  127. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/lighting/__init__.py +0 -0
  128. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/lighting/lightmap.py +0 -0
  129. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/parallax/__init__.py +0 -0
  130. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/parallax/background.py +0 -0
  131. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/parallax/camera.py +0 -0
  132. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/signals/__init__.py +0 -0
  133. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/signals/core.py +0 -0
  134. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/transitions/base.py +0 -0
  135. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/transitions/effects.py +0 -0
  136. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/transitions/fades.py +0 -0
  137. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/transitions/wipes.py +0 -0
  138. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/ui/anchors.py +0 -0
  139. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/utils/interpolation.py +0 -0
  140. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/utils/text.py +0 -0
  141. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit/utils/timer.py +0 -0
  142. {pygkit-2.1.1 → pygkit-2.2.0}/src/pygkit.egg-info/dependency_links.txt +0 -0
  143. {pygkit-2.1.1/src → pygkit-2.2.0/src/pygkit.egg-info}/pygkit/transitions/__init__.py +0 -0
  144. {pygkit-2.1.1/src → pygkit-2.2.0/src/pygkit.egg-info}/pygkit/utils/__init__.py +0 -0
  145. {pygkit-2.1.1/src → pygkit-2.2.0/src/pygkit.egg-info}/pygkit.egg-info/top_level.txt +0 -0
  146. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_anchors.py +0 -0
  147. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_animation.py +0 -0
  148. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_audio.py +0 -0
  149. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_interpolation.py +0 -0
  150. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_inventory.py +0 -0
  151. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_lighting.py +0 -0
  152. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_packaging.py +0 -0
  153. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_parallax.py +0 -0
  154. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_signals.py +0 -0
  155. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_text.py +0 -0
  156. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_timer.py +0 -0
  157. {pygkit-2.1.1 → pygkit-2.2.0}/tests/test_transitions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygkit
3
- Version: 2.1.1
3
+ Version: 2.2.0
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
@@ -694,6 +694,7 @@ Requires-Python: >=3.10
694
694
  Description-Content-Type: text/markdown
695
695
  License-File: LICENSE
696
696
  Requires-Dist: pygame-ce>=2.5
697
+ Requires-Dist: typing_extensions>=4.6; python_version < "3.11"
697
698
  Provides-Extra: ui
698
699
  Provides-Extra: audio
699
700
  Provides-Extra: animation
@@ -718,6 +719,7 @@ import pygkit
718
719
  ## Features
719
720
 
720
721
  - **UI**: Box-model widgets with plugin compositing — progress bars, cooldown overlays, containers, dialog system, buttons, menubar container, anchor/row/grid placement helpers
722
+ - **Events**: Menubar/Container route mouse events to nested layouts; hit-testing is active from the first rendered frame
721
723
  - **Animation**: Multi-state `AnimationPlayer` where every state owns its own spritesheet — mixed image sizes and grids (e.g. `idle_spritesheet.png` vs `run_spritesheet.png`) in one player; pure image API, no JSON
722
724
  - **Dialog**: Typewriter effect with customizable speeds, speaker names, and progress indicators
723
725
  - **Inventory**: Grid-based item management with stacking, weight tracking, events, and serialization
@@ -11,6 +11,7 @@ import pygkit
11
11
  ## Features
12
12
 
13
13
  - **UI**: Box-model widgets with plugin compositing — progress bars, cooldown overlays, containers, dialog system, buttons, menubar container, anchor/row/grid placement helpers
14
+ - **Events**: Menubar/Container route mouse events to nested layouts; hit-testing is active from the first rendered frame
14
15
  - **Animation**: Multi-state `AnimationPlayer` where every state owns its own spritesheet — mixed image sizes and grids (e.g. `idle_spritesheet.png` vs `run_spritesheet.png`) in one player; pure image API, no JSON
15
16
  - **Dialog**: Typewriter effect with customizable speeds, speaker names, and progress indicators
16
17
  - **Inventory**: Grid-based item management with stacking, weight tracking, events, and serialization
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pygkit"
7
- version = "2.1.1"
7
+ version = "2.2.0"
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"
@@ -12,6 +12,7 @@ license = { file = "LICENSE" }
12
12
  authors = [{ name = "pygkit contributors" }]
13
13
  dependencies = [
14
14
  "pygame-ce>=2.5",
15
+ 'typing_extensions>=4.6; python_version < "3.11"',
15
16
  ]
16
17
  classifiers = [
17
18
  "Development Status :: 3 - Alpha",
@@ -87,12 +87,24 @@ _LAZY_ATTRS: dict[str, str] = {
87
87
  "DialogLine": "ui",
88
88
  "TypewriterSpeed": "ui",
89
89
  "Button": "ui",
90
- "ButtonStyle": "ui",
90
+ "UIStyle": "ui",
91
+ "StatePaint": "ui",
92
+ "ResolvedStyle": "ui",
93
+ "ColorLike": "ui",
94
+ "GradientLike": "ui",
95
+ "ShadowLike": "ui",
96
+ "StateKey": "ui",
97
+ "resolve_style": "ui",
98
+ "validate_style": "ui",
91
99
  "Menubar": "ui",
92
100
  "AnchorLayout": "ui",
93
101
  "HBox": "ui",
94
102
  "VBox": "ui",
95
103
  "GridBox": "ui",
104
+ "STATE_KEYS": "ui",
105
+ "SKIN_STATE_KEYS": "ui",
106
+ "Skin": "ui",
107
+ "Panel": "ui",
96
108
  "ItemData": "inventory",
97
109
  "InventoryConfig": "inventory",
98
110
  "ItemStack": "inventory",
@@ -166,12 +178,24 @@ __all__ = [
166
178
  "DialogLine",
167
179
  "TypewriterSpeed",
168
180
  "Button",
169
- "ButtonStyle",
181
+ "UIStyle",
182
+ "StatePaint",
183
+ "ResolvedStyle",
184
+ "ColorLike",
185
+ "GradientLike",
186
+ "ShadowLike",
187
+ "StateKey",
188
+ "resolve_style",
189
+ "validate_style",
170
190
  "Menubar",
171
191
  "AnchorLayout",
172
192
  "HBox",
173
193
  "VBox",
174
194
  "GridBox",
195
+ "STATE_KEYS",
196
+ "SKIN_STATE_KEYS",
197
+ "Skin",
198
+ "Panel",
175
199
  "ItemData",
176
200
  "InventoryConfig",
177
201
  "ItemStack",
@@ -2,10 +2,16 @@ from __future__ import annotations
2
2
 
3
3
  import math
4
4
  import re
5
+ import sys
5
6
  import warnings
6
7
  from pathlib import Path
7
8
  from typing import Literal, TypedDict, Union
8
9
 
10
+ if sys.version_info >= (3, 11):
11
+ from typing import Unpack
12
+ else:
13
+ from typing_extensions import Unpack
14
+
9
15
  import pygame
10
16
  from pygame import Rect, Surface
11
17
 
@@ -32,6 +38,7 @@ _MAX_FRAMES = 100
32
38
 
33
39
  _ALLOWED_PACK_KWARGS = {
34
40
  "pattern",
41
+ "columns",
35
42
  "fg",
36
43
  "bg",
37
44
  "font_name",
@@ -69,7 +76,6 @@ def _natural_key(path: Path, base: Path | None = None) -> list[tuple[int, object
69
76
  if part.isdigit():
70
77
  key.append((0, int(part)))
71
78
  else:
72
- # Use lower for case-insensitive; empty string stays (1, "")
73
79
  key.append((1, part.lower()))
74
80
  return key
75
81
 
@@ -78,7 +84,6 @@ def _scale_surface(surface: Surface, scale: float) -> Surface:
78
84
  if scale == 1.0:
79
85
  return surface
80
86
  try:
81
- # pygame-ce 2.5+ has scale_by which handles float directly
82
87
  return pygame.transform.scale_by(surface, scale) # type: ignore[attr-defined]
83
88
  except (AttributeError, pygame.error, ValueError, TypeError):
84
89
  pass
@@ -94,8 +99,6 @@ def _scale_surface(surface: Surface, scale: float) -> Surface:
94
99
 
95
100
 
96
101
  def _label_from_stem(stem: str) -> str:
97
- # Capture alphabetic words possibly joined by _- but not trailing _-
98
- # e.g. "run_01" -> "run", "idle-anim" -> "idle-anim", "run_" -> "run"
99
102
  m = re.search(r"[A-Za-z]+(?:[_-][A-Za-z]+)*", stem)
100
103
  if m:
101
104
  return m.group(0)
@@ -107,12 +110,12 @@ def _label_from_stem(stem: str) -> str:
107
110
 
108
111
  class PackOptions(TypedDict, total=False):
109
112
  pattern: str | None
113
+ columns: int | None
110
114
  fg: tuple[int, int, int] | tuple[int, int, int, int]
111
115
  bg: tuple[int, int, int] | tuple[int, int, int, int]
112
116
  font_name: str | None
113
117
  font_size: int | None
114
118
  padding: int
115
- strict: bool
116
119
  ignore_bias: bool
117
120
  ignore_mismatch: bool
118
121
  allow_mismatch: bool
@@ -156,7 +159,6 @@ def _collect_image_files(dir_path: Path, pattern: str | None) -> list[Path]:
156
159
  if not found_any_match:
157
160
  raise ValueError(f"No files matching pattern {pattern!r} in directory {dir_path!r}")
158
161
  if not files:
159
- # Pattern matched something but no images (e.g. "*.txt")
160
162
  raise ValueError(f"No image files matching pattern {pattern!r} in directory {dir_path!r}")
161
163
  files.sort(key=lambda p: (_natural_key(p, dir_path), str(p).lower()))
162
164
  return files
@@ -196,7 +198,22 @@ class AnimationSheet:
196
198
  ``2.0`` doubles dimensions, ``0.5`` halves them.
197
199
  """
198
200
 
199
- __slots__ = ("_surface", "_rows", "_cols", "_cell_w", "_cell_h", "_cache", "_frames", "_scale", "_orig_cell_w", "_orig_cell_h", "_start_row", "_start_col", "_sheet_rows", "_sheet_cols")
201
+ __slots__ = (
202
+ "_surface",
203
+ "_rows",
204
+ "_cols",
205
+ "_cell_w",
206
+ "_cell_h",
207
+ "_cache",
208
+ "_frames",
209
+ "_scale",
210
+ "_orig_cell_w",
211
+ "_orig_cell_h",
212
+ "_start_row",
213
+ "_start_col",
214
+ "_sheet_rows",
215
+ "_sheet_cols",
216
+ )
200
217
 
201
218
  def __init__(
202
219
  self,
@@ -214,7 +231,12 @@ class AnimationSheet:
214
231
  raise TypeError("rows and cols must be ints")
215
232
  if rows < 1 or cols < 1:
216
233
  raise ValueError(f"rows and cols must be >= 1, got rows={rows}, cols={cols}")
217
- if not isinstance(start_row, int) or not isinstance(start_col, int) or isinstance(start_row, bool) or isinstance(start_col, bool):
234
+ if (
235
+ not isinstance(start_row, int)
236
+ or not isinstance(start_col, int)
237
+ or isinstance(start_row, bool)
238
+ or isinstance(start_col, bool)
239
+ ):
218
240
  raise TypeError("start_row and start_col must be ints")
219
241
  if start_row < 0 or start_col < 0:
220
242
  raise ValueError(f"start_row and start_col must be >= 0, got start_row={start_row}, start_col={start_col}")
@@ -260,8 +282,6 @@ class AnimationSheet:
260
282
  self._cell_w = cell_w
261
283
  self._cell_h = cell_h
262
284
  else:
263
- # Use scaled surface size for precision, not just round, to avoid 1px drift
264
- # Create a dummy scaled cell to get actual size from _scale_surface
265
285
  dummy = pygame.Surface((cell_w, cell_h), pygame.SRCALPHA)
266
286
  scaled_dummy = _scale_surface(dummy, scale_f)
267
287
  self._cell_w, self._cell_h = scaled_dummy.get_size()
@@ -277,7 +297,9 @@ class AnimationSheet:
277
297
 
278
298
  if path.is_dir():
279
299
  if rows != 1 or cols != 1:
280
- raise ValueError(f"rows and cols are ignored in directory mode (got rows={rows}, cols={cols}); use pattern/scale instead")
300
+ raise ValueError(
301
+ f"rows and cols are ignored in directory mode (got rows={rows}, cols={cols}); use pattern/scale instead"
302
+ )
281
303
  if start_row != 0 or start_col != 0 or sheet_rows is not None or sheet_cols is not None:
282
304
  raise ValueError("start_row/start_col/sheet_rows/sheet_cols are ignored in directory mode")
283
305
  self._scale = scale_f
@@ -329,7 +351,6 @@ class AnimationSheet:
329
351
  def _init_from_directory(self, dir_path: Path, pattern: str | None) -> None:
330
352
  files = _collect_image_files(dir_path, pattern)
331
353
 
332
- # Load surfaces; first frame is source of truth for size.
333
354
  loaded: list[Surface] = []
334
355
  expected_size: tuple[int, int] | None = None
335
356
  scale_f = self._scale
@@ -359,7 +380,6 @@ class AnimationSheet:
359
380
  if not loaded:
360
381
  raise ValueError(f"No image files found in directory {dir_path!r}")
361
382
 
362
- # Directory mode is stored as a flat strip: rows=1, cols=N
363
383
  self._frames = loaded
364
384
  self._surface = loaded[0]
365
385
  self._rows = 1
@@ -370,7 +390,6 @@ class AnimationSheet:
370
390
  if scale_f == 1.0:
371
391
  self._cell_w, self._cell_h = expected_size
372
392
  else:
373
- # Use actual scaled size to avoid drift
374
393
  self._cell_w, self._cell_h = loaded[0].get_size()
375
394
  self._cache = {i: s for i, s in enumerate(loaded)}
376
395
 
@@ -387,7 +406,17 @@ class AnimationSheet:
387
406
  sheet_rows: int | None = None,
388
407
  sheet_cols: int | None = None,
389
408
  ) -> "AnimationSheet":
390
- return cls(path, rows, cols, pattern=pattern, scale=scale, start_row=start_row, start_col=start_col, sheet_rows=sheet_rows, sheet_cols=sheet_cols)
409
+ return cls(
410
+ path,
411
+ rows,
412
+ cols,
413
+ pattern=pattern,
414
+ scale=scale,
415
+ start_row=start_row,
416
+ start_col=start_col,
417
+ sheet_rows=sheet_rows,
418
+ sheet_cols=sheet_cols,
419
+ )
391
420
 
392
421
  @classmethod
393
422
  def from_directory(cls, directory: PathLike, pattern: str | None = None, scale: float = 1.0) -> "AnimationSheet":
@@ -462,7 +491,7 @@ def pack_spritesheet(
462
491
  render_scale: float = 1.0,
463
492
  add_label: bool = False,
464
493
  strict: bool = True,
465
- **kwargs,
494
+ **kwargs: Unpack[PackOptions],
466
495
  ) -> Surface:
467
496
  """Pack a folder into a spritesheet Surface.
468
497
 
@@ -474,12 +503,20 @@ def pack_spritesheet(
474
503
  becomes a row and its files become columns. Linear files in ``source``
475
504
  are ignored.
476
505
 
506
+ ``columns`` (``target="file"`` only) wraps the flat frame list into rows
507
+ of at most ``columns`` frames: ``columns=1`` stacks frames vertically
508
+ (one per row), ``columns=4`` wraps every 4 frames. A short last row is
509
+ padded with transparent cells so the sheet stays a clean grid readable
510
+ by :class:`AnimationSheet` with ``cols=columns``. ``target="dir"`` must
511
+ not pass ``columns`` — its rows already map to subdirectories.
512
+
477
513
  Cell size is strictly uniform as the first frame's size; mismatched
478
514
  frames raise ``ValueError`` when ``strict`` is ``True``. ``render_scale``
479
515
  scales the whole packed surface at the end (whole-surface scaling reduces
480
516
  floating-point error vs per-frame scaling). ``add_label`` adds text
481
- labels: for ``target="file"`` the fixed label ``"animation"`` is used;
482
- for ``target="dir"`` the subdir name's first ``[A-Za-z]+(?:[_-][A-Za-z]+)*``
517
+ labels: for ``target="file"`` the fixed label ``"animation"`` is placed
518
+ after the last row's frames (the only row unless ``columns`` wraps); for
519
+ ``target="dir"`` the subdir name's first ``[A-Za-z]+(?:[_-][A-Za-z]+)*``
483
520
  capture is used, falling back to ``[0-9]+`` then stem (trailing ``_-`` are
484
521
  stripped).
485
522
 
@@ -493,6 +530,8 @@ def pack_spritesheet(
493
530
  ``kwargs`` (all optional, ``total=False``):
494
531
 
495
532
  * ``pattern`` – glob pattern as in :class:`AnimationSheet`
533
+ * ``columns`` – wrap ``target="file"`` frames into rows of this many
534
+ frames (``1`` = vertical strip); ``None`` keeps a single row
496
535
  * ``fg``/``bg`` – label colors, default white on black (validated as tuple)
497
536
  * ``font_name``/``font_size`` – font selection
498
537
  * ``padding`` – outer padding in pixels (right/bottom only)
@@ -516,16 +555,22 @@ def pack_spritesheet(
516
555
  if not isinstance(strict, bool):
517
556
  raise TypeError("strict must be bool")
518
557
  if "size" in kwargs:
519
- raise TypeError("pack_spritesheet() got unexpected keyword argument 'size' (cell size is now strict first frame)")
558
+ raise TypeError(
559
+ "pack_spritesheet() got unexpected keyword argument 'size' (cell size is now strict first frame)"
560
+ )
561
+ columns = kwargs.get("columns")
562
+ if columns is not None:
563
+ if not isinstance(columns, int) or isinstance(columns, bool):
564
+ raise TypeError(f"columns must be int, got {columns!r}")
565
+ if columns < 1:
566
+ raise ValueError(f"columns must be >=1, got {columns!r}")
520
567
  _validate_pack_kwargs(kwargs)
521
- # Alias handling for ignore_bias / ignore_mismatch
522
568
  if "ignore_bias" in kwargs:
523
569
  strict = not bool(kwargs.pop("ignore_bias"))
524
570
  if "ignore_mismatch" in kwargs:
525
571
  strict = not bool(kwargs.pop("ignore_mismatch"))
526
572
  if "allow_mismatch" in kwargs:
527
573
  strict = not bool(kwargs.pop("allow_mismatch"))
528
- # Validate fg/bg types
529
574
  pattern: str | None = kwargs.get("pattern") # type: ignore[assignment]
530
575
  if pattern is not None and not isinstance(pattern, str):
531
576
  raise TypeError("pattern must be str or None")
@@ -533,7 +578,6 @@ def pack_spritesheet(
533
578
  raise ValueError("pattern must not be empty")
534
579
  fg = kwargs.get("fg", (255, 255, 255))
535
580
  bg = kwargs.get("bg", (0, 0, 0))
536
- # Basic validation for colors
537
581
  for name, col in (("fg", fg), ("bg", bg)):
538
582
  if not isinstance(col, tuple) or not all(isinstance(v, int) for v in col) or len(col) not in (3, 4):
539
583
  raise TypeError(f"{name} must be tuple of 3 or 4 ints")
@@ -555,14 +599,21 @@ def pack_spritesheet(
555
599
  if not src.is_dir():
556
600
  raise ValueError(f"source {source!r} is not a directory")
557
601
 
558
- # Determine rows data
559
- rows_data: list[tuple[str, list[Path]]] = []
602
+ rows_data: list[tuple[str, list[Path | None]]] = []
560
603
  if target == "file":
561
604
  files = _collect_image_files(src, pattern)
562
605
  if not files:
563
606
  raise ValueError(f"No image files found in directory {src!r}")
564
- rows_data.append(("animation", files))
607
+ if columns is None:
608
+ rows_data.append(("animation", files))
609
+ else:
610
+ for i in range(0, len(files), columns):
611
+ chunk: list[Path | None] = files[i : i + columns]
612
+ chunk += [None] * (columns - len(chunk))
613
+ rows_data.append(("animation", chunk))
565
614
  else:
615
+ if columns is not None:
616
+ raise ValueError("columns is only valid with target='file' (dir rows already map to subdirectories)")
566
617
  subdirs = [d for d in src.iterdir() if d.is_dir()]
567
618
  subdirs.sort(key=lambda p: (_natural_key(p, src), str(p).lower()))
568
619
  if not subdirs:
@@ -570,15 +621,14 @@ def pack_spritesheet(
570
621
  for sub in subdirs:
571
622
  files = _collect_image_files(sub, pattern)
572
623
  if not files:
573
- # skip empty subdirs? raise to be explicit
574
624
  raise ValueError(f"No image files found in subdirectory {sub!r}")
575
625
  label = _label_from_stem(sub.name) if add_label else ""
576
626
  rows_data.append((label, files))
577
627
  if not rows_data:
578
628
  raise ValueError(f"No image files found in subdirectories of {src!r}")
579
629
 
580
- # Determine cell size - strict uniform as first frame (keep surface for reuse)
581
630
  first_path = rows_data[0][1][0]
631
+ assert first_path is not None, "first row must contain at least one frame"
582
632
  try:
583
633
  tmp_surf = pygame.image.load(str(first_path))
584
634
  except (pygame.error, FileNotFoundError, OSError) as e:
@@ -592,15 +642,13 @@ def pack_spritesheet(
592
642
  if cell_w < 1 or cell_h < 1:
593
643
  raise ValueError(f"Invalid cell size {cell_w}x{cell_h} from {first_path!r}")
594
644
 
595
- # Validate total frames cap
596
- total_frames = sum(len(files) for _, files in rows_data)
645
+ total_frames = sum(1 for _, files in rows_data for f in files if f is not None)
597
646
  if total_frames > _MAX_FRAMES:
598
647
  raise ValueError(f"Too many frames total {total_frames}: exceeds {_MAX_FRAMES}")
599
648
 
600
649
  max_cols = max(len(files) for _, files in rows_data)
601
650
  num_rows = len(rows_data)
602
651
 
603
- # Prepare font and label metrics if needed (single render pass)
604
652
  label_cols_needed = 0
605
653
  label_surfaces: list[Surface | None] = []
606
654
  if add_label:
@@ -618,9 +666,11 @@ def pack_spritesheet(
618
666
  except Exception:
619
667
  font = pygame.font.SysFont(None, eff_font_size)
620
668
 
621
- # Render once and compute max cols
622
- text_surfs: list[Surface] = []
623
- for label, _ in rows_data:
669
+ text_surfs: list[Surface | None] = []
670
+ for idx, (label, _) in enumerate(rows_data):
671
+ if target == "file" and idx != num_rows - 1:
672
+ text_surfs.append(None)
673
+ continue
624
674
  text = label if label else "animation"
625
675
  if target == "file":
626
676
  text = "animation"
@@ -634,9 +684,11 @@ def pack_spritesheet(
634
684
  if cols_needed > label_cols_needed:
635
685
  label_cols_needed = cols_needed
636
686
 
637
- # Build label areas with uniform width
638
687
  if label_cols_needed:
639
688
  for text_surf in text_surfs:
689
+ if text_surf is None:
690
+ label_surfaces.append(None)
691
+ continue
640
692
  area_w = label_cols_needed * cell_w
641
693
  area = pygame.Surface((area_w, cell_h), pygame.SRCALPHA)
642
694
  try:
@@ -658,13 +710,12 @@ def pack_spritesheet(
658
710
  packed = pygame.Surface((unscaled_w, unscaled_h), pygame.SRCALPHA)
659
711
  packed.fill((0, 0, 0, 0))
660
712
 
661
- # Keep first surface to avoid double load
662
713
  first_surf_cached: Surface | None = tmp_surf
663
- # Blit frames - strict uniform size as first frame (or scaled if not strict)
664
- for r, (_, files) in enumerate(rows_data):
665
- for c, fpath in enumerate(files):
714
+ for r, (_, row_files) in enumerate(rows_data):
715
+ for c, fpath in enumerate(row_files):
716
+ if fpath is None:
717
+ continue
666
718
  if r == 0 and c == 0 and first_surf_cached is not None:
667
- # Reuse already loaded first frame (convert handling already done)
668
719
  surf = first_surf_cached
669
720
  first_surf_cached = None
670
721
  else:
@@ -685,7 +736,7 @@ def pack_spritesheet(
685
736
  f"got {sw}x{sh} for {fpath.name!r}"
686
737
  )
687
738
  try:
688
- surf = pygame.transform.smoothscale(surf, (cell_w, cell_h))
739
+ surf = pygame.transform.scale(surf, (cell_w, cell_h))
689
740
  except pygame.error:
690
741
  surf = pygame.transform.scale(surf, (cell_w, cell_h))
691
742
  packed.blit(surf, (c * cell_w, r * cell_h))
@@ -16,26 +16,20 @@ Semantics for a scene-surface with a lightmap overlay (values 0..255):
16
16
 
17
17
  import pygame
18
18
 
19
- # RGB variants (alpha channel of the source is ignored)
20
19
  RGB_ADD = pygame.BLEND_RGB_ADD
21
20
  RGB_SUB = pygame.BLEND_RGB_SUB
22
21
  RGB_MULT = pygame.BLEND_RGB_MULT
23
22
  RGB_MIN = pygame.BLEND_RGB_MIN
24
23
  RGB_MAX = pygame.BLEND_RGB_MAX
25
24
 
26
- # RGBA variants (alpha channel of the source is taken into account)
27
25
  RGBA_ADD = pygame.BLEND_RGBA_ADD
28
26
  RGBA_SUB = pygame.BLEND_RGBA_SUB
29
27
  RGBA_MULT = pygame.BLEND_RGBA_MULT
30
28
  RGBA_MIN = pygame.BLEND_RGBA_MIN
31
29
  RGBA_MAX = pygame.BLEND_RGBA_MAX
32
30
 
33
- # Sensible defaults for the two common jobs. The RGB family is what the
34
- # module docstring recommends for lighting opaque scene surfaces (color
35
- # channels only, destination alpha untouched), so these are the RGB
36
- # variants - the light map pipeline keeps its alpha channel at 255 anyway.
37
- LIGHT_ADD = RGB_ADD # adding a light sprite onto the light map
38
- SCENE_MULT = RGB_MULT # multiplying the scene by the light map
31
+ LIGHT_ADD = RGB_ADD
32
+ SCENE_MULT = RGB_MULT
39
33
 
40
34
  __all__ = [
41
35
  "RGB_ADD",
@@ -596,8 +596,6 @@ class DynamicLight:
596
596
  phase,
597
597
  )
598
598
  self._bake_scale = lightmap.scale
599
- # never share the generator cache: per-light alpha and wobble
600
- # changes must not leak across lights
601
599
  return sprite.copy()
602
600
 
603
601
  def sprite(self, lightmap: LightMap | None = None) -> Surface:
@@ -20,7 +20,7 @@ import pygame
20
20
  from pygame import Surface
21
21
 
22
22
  _cache: dict[tuple[Any, ...], Surface] = {}
23
- _CACHE_MAX = 128 # bound memory when callers vary parameters (e.g. radii)
23
+ _CACHE_MAX = 128
24
24
 
25
25
 
26
26
  def _store(key: tuple[Any, ...], surf: Surface) -> Surface:
@@ -144,15 +144,12 @@ def dynamic_glow_sprite(
144
144
  ux, uy = 1.0, 0.0
145
145
 
146
146
  if s <= 1e-4:
147
- # no wind: fall back to the plain isotropic glow. Note this
148
- # returns the shared glow_sprite cache entry - copy it before
149
- # mutating (set_alpha, fill, ...), just like glow_sprite.
150
147
  return glow_sprite(radius, color, "exp", exponent)
151
148
 
152
- a_axis = 1.0 + (stretch - 1.0) * s # elongate along the wind
153
- b_axis = 1.0 / a_axis # keep area roughly constant
154
- shift = core_shift * radius * s # hot core displaced against the wind
155
- wob = 0.08 * radius * s # subtle seeded waviness
149
+ a_axis = 1.0 + (stretch - 1.0) * s
150
+ b_axis = 1.0 / a_axis
151
+ shift = core_shift * radius * s
152
+ wob = 0.08 * radius * s
156
153
  phase = seed * 0.61803398875
157
154
  r2 = radius * radius
158
155
 
@@ -38,8 +38,6 @@ class Widget(Renderable, Protocol):
38
38
 
39
39
 
40
40
  class Clickable(Widget, Protocol):
41
- # contains/press/activate take screen coords; widgets track origin at render.
42
-
43
41
  on_press: Signal[Any]
44
42
 
45
43
  def contains(self, pos: tuple[int, int]) -> bool: ...
@@ -0,0 +1,18 @@
1
+ from .base import TransitionRunner, TransitionState
2
+ from .effects import PixelDissolve, Shake
3
+ from .fades import Crossfade, FadeFromBlack, FadeToBlack, Flash
4
+ from .wipes import IrisIn, IrisOut, Slide
5
+
6
+ __all__ = [
7
+ "TransitionRunner",
8
+ "TransitionState",
9
+ "FadeToBlack",
10
+ "FadeFromBlack",
11
+ "Crossfade",
12
+ "Flash",
13
+ "IrisIn",
14
+ "IrisOut",
15
+ "Slide",
16
+ "PixelDissolve",
17
+ "Shake",
18
+ ]
@@ -0,0 +1,58 @@
1
+ from .base import UIBase, UIOptions, BoxModel, BoxModelResult, generate_box_model
2
+ from .button import Button
3
+ from .container import Container
4
+ from .cooldown import CooldownOverlay
5
+ from .dialog import DialogBox, DialogConfig, DialogColors, DialogLine, TypewriterSpeed
6
+ from .layout import AnchorLayout, GridBox, HBox, VBox
7
+ from .menubar import Menubar
8
+ from .panel import Panel
9
+ from .progressbar import ProgressBarUI
10
+ from .theming import (
11
+ ColorLike,
12
+ GradientLike,
13
+ ResolvedStyle,
14
+ ShadowLike,
15
+ Skin,
16
+ StateKey,
17
+ StatePaint,
18
+ STATE_KEYS,
19
+ SKIN_STATE_KEYS,
20
+ UIStyle,
21
+ resolve_style,
22
+ validate_style,
23
+ )
24
+
25
+ __all__ = [
26
+ "UIBase",
27
+ "UIOptions",
28
+ "BoxModel",
29
+ "BoxModelResult",
30
+ "generate_box_model",
31
+ "ProgressBarUI",
32
+ "CooldownOverlay",
33
+ "Container",
34
+ "DialogBox",
35
+ "DialogConfig",
36
+ "DialogColors",
37
+ "DialogLine",
38
+ "TypewriterSpeed",
39
+ "Button",
40
+ "UIStyle",
41
+ "StatePaint",
42
+ "ResolvedStyle",
43
+ "ColorLike",
44
+ "GradientLike",
45
+ "ShadowLike",
46
+ "StateKey",
47
+ "STATE_KEYS",
48
+ "SKIN_STATE_KEYS",
49
+ "resolve_style",
50
+ "validate_style",
51
+ "Skin",
52
+ "Menubar",
53
+ "AnchorLayout",
54
+ "HBox",
55
+ "VBox",
56
+ "GridBox",
57
+ "Panel",
58
+ ]